Blood Donation appointment implementation completed.

dev_3.3_blood_donation_CR
haroon amjad 2 years ago
parent 4780a3b5f6
commit bbbec1a716

@ -4,6 +4,7 @@ import 'package:diplomaticquarterapp/core/service/blood/blood_donation_service.d
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/models/Appointments/FreeSlot.dart';
import 'package:diplomaticquarterapp/models/Appointments/timeSlot.dart';
import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart';
import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
@ -11,6 +12,7 @@ import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/buttons/custom_text_button.dart';
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
import 'package:diplomaticquarterapp/widgets/dialogs/radio_selection_dialog.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/material.dart';
@ -42,6 +44,8 @@ class _BloodDonationBookAppointmentState extends State<BloodDonationBookAppointm
int _clinicID = 0;
int _doctorID = 0;
String selectedProjectName = "";
List<TimeSlot> docFreeSlots = [];
List<TimeSlot> dayEvents = [];
@ -95,25 +99,32 @@ class _BloodDonationBookAppointmentState extends State<BloodDonationBookAppointm
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CommonDropDownView(TranslationBase.of(context).selectProject, "Select Hospital", () {
List<RadioSelectionDialogModel> list = [];
bloodDonationProjectsListResponse.forEach((element) {
list.add(RadioSelectionDialogModel(element.projectName, element.projectID));
});
showDialog(
context: context,
builder: (cxt) => RadioSelectionDialog(
listData: list,
selectedIndex: 0,
onValueSelected: (index) {
print(index);
_selectedProjectID = index;
getBloodDonationFreeSlots();
setState(() {});
},
),
);
}).withBorderedContainer,
Text("Please select the project you want to book an appointment with: ", style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.w600, letterSpacing: -0.64)),
mHeight(12),
CommonDropDownView(
TranslationBase.of(context).selectProject,
selectedProjectName,
() {
List<RadioSelectionDialogModel> list = [];
bloodDonationProjectsListResponse.forEach((element) {
list.add(RadioSelectionDialogModel(element.projectName, element.projectID));
});
showDialog(
context: context,
builder: (cxt) => RadioSelectionDialog(
listData: list,
selectedIndex: 0,
onValueSelected: (index) {
print(index);
_selectedProjectID = index;
selectedProjectName = bloodDonationProjectsListResponse.firstWhere((element) => element.projectID == index).projectName;
getBloodDonationFreeSlots();
setState(() {});
},
),
);
},
).withBorderedContainer,
mHeight(12),
Container(
decoration: cardRadius(12),
@ -149,16 +160,72 @@ class _BloodDonationBookAppointmentState extends State<BloodDonationBookAppointm
)
: Center(
child: Padding(
padding: const EdgeInsets.only(left: 12.0, right: 12.0),
child: Text(TranslationBase.of(context).noSlotsError, style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.w600, letterSpacing: -0.46, color: CustomColors.grey)),
)),
padding: const EdgeInsets.only(left: 12.0, right: 12.0),
child: Text(TranslationBase.of(context).noSlotsError, style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.w600, letterSpacing: -0.46, color: CustomColors.grey)),
),
),
],
),
),
),
bottomSheet: Container(
color: Colors.white,
height: MediaQuery.of(context).size.height * 0.081,
width: double.infinity,
padding: EdgeInsets.all(12.0),
child: Column(
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width * 0.9,
child: DefaultButton(
TranslationBase.of(context).bookAppo,
() async {
if (BloodDonationBookAppointment.areSlotsAvailable) {
insertBloodDonationAppointment();
} else {
AppToast.showErrorToast(message: TranslationBase.of(context).selectSlot);
}
// GifLoaderDialogUtils.showMyDialog(context);
// await model.sendLabReportEmail(patientLabOrder: widget.patientLabOrders, mes: TranslationBase.of(context).sendSuc, userObj: projectViewModel.user, isVidaPlus: Utils.isVidaPlusProject(projectViewModel, num.parse(widget.patientLabOrders.projectID)), isDownload: true);
// GifLoaderDialogUtils.hideDialog(context);
// try {
// String path = await _createFileFromString(model.labReportPDF, "pdf");
// OpenFilex.open(path);
// } catch (ex) {
// AppToast.showErrorToast(message: "Cannot open file.");
// }
},
textColor: Colors.white,
color: CustomColors.green,
),
),
],
),
),
);
}
void insertBloodDonationAppointment() {
DoctorsListService service = new DoctorsListService();
final timeSlot = BloodDonationBookAppointment.selectedAppoDateTime;
GifLoaderDialogUtils.showMyDialog(context);
service
.insertAppointment(
_doctorID, _clinicID, _selectedProjectID, BloodDonationBookAppointment.selectedTime, BloodDonationBookAppointment.selectedDate, 45, context, null, null, null, projectViewModel)
.then((res) {
GifLoaderDialogUtils.hideDialog(context);
if (res['MessageStatus'] == 1) {
AppToast.showSuccessToast(message: TranslationBase.of(context).bookedSuccess);
Navigator.of(context).pop();
Future.delayed(new Duration(milliseconds: 500), () {
// getToDoCount();
});
} else {
AppToast.showErrorToast(message: res['ErrorEndUserMessage']);
}
});
}
void _onDaySelected(DateTime day, ProjectViewModel projectViewModel) {
final DateFormat formatter = DateFormat('yyyy-MM-dd');
setState(() {

@ -335,7 +335,6 @@ class _BookConfirmState extends State<BookConfirm> {
AppToast.showSuccessToast(message: TranslationBase.of(context).bookedSuccess);
Future.delayed(new Duration(milliseconds: 500), () {
// checkPatientNphiesEligibility(docObject, res['AppointmentNo'], context);
getToDoCount();
getPatientShare(context, res['AppointmentNo'], docObject.clinicID, docObject.projectID, docObject);
});

Loading…
Cancel
Save