diff --git a/lib/core/model/prescriptions/request_send_prescription_email.dart b/lib/core/model/prescriptions/request_send_prescription_email.dart index aff0e792..de162296 100644 --- a/lib/core/model/prescriptions/request_send_prescription_email.dart +++ b/lib/core/model/prescriptions/request_send_prescription_email.dart @@ -1,4 +1,5 @@ import 'package:diplomaticquarterapp/core/model/prescriptions/prescription_report.dart'; +import 'package:diplomaticquarterapp/core/model/prescriptions/prescription_report_inp.dart'; class RequestSendPrescriptionEmail { String? appointmentDate; @@ -26,6 +27,7 @@ class RequestSendPrescriptionEmail { int? doctorID; int? projectID; List? listPrescriptions; + List? listPrescriptionsINP; RequestSendPrescriptionEmail( {this.appointmentDate, @@ -102,9 +104,12 @@ class RequestSendPrescriptionEmail { data['PatientMobileNumber'] = this.patientMobileNumber; data['PatientName'] = this.patientName; data['SetupID'] = this.setupID; - if (this.listPrescriptions != null) { + if (this.listPrescriptions != null && this.listPrescriptions!.isNotEmpty) { data['ListPrescriptions'] = this.listPrescriptions!.map((v) => v.toJson()).toList(); } + if (this.listPrescriptionsINP != null && this.listPrescriptionsINP!.isNotEmpty) { + data['ListPrescriptions'] = this.listPrescriptionsINP!.map((v) => v.toJson()).toList(); + } data['ClinicName'] = this.clinicName; data['DoctorName'] = this.doctorName; data['ProjectID'] = this.projectID; diff --git a/lib/core/service/medical/prescriptions_service.dart b/lib/core/service/medical/prescriptions_service.dart index 71a24a39..c5b1a16f 100644 --- a/lib/core/service/medical/prescriptions_service.dart +++ b/lib/core/service/medical/prescriptions_service.dart @@ -98,6 +98,7 @@ class PrescriptionsService extends BaseService { await baseAppClient.post(prescriptions.isInOutPatient! ? GET_PRESCRIPTION_REPORT_ENH : GET_PRESCRIPTION_REPORT, onSuccess: (dynamic response, int statusCode) { prescriptionReportList.clear(); prescriptionReportEnhList.clear(); + prescriptionReportListINP.clear(); isMedDeliveryAllowed = response['IsHomeMedicineDeliverySupported']; if (prescriptions.isInOutPatient!) { response['ListPRM'].forEach((prescriptions) { @@ -120,8 +121,9 @@ class PrescriptionsService extends BaseService { isDentalAllowedBackend: false, ); - Future sendPrescriptionEmail(String appointmentDate, int patientID, String clinicName, String doctorName, int doctorID, int projectID) async { + Future sendPrescriptionEmail(String appointmentDate, int patientID, String clinicName, String doctorName, int doctorID, int projectID, bool isInOutPatient) async { _requestSendPrescriptionEmail.listPrescriptions = prescriptionReportList; + _requestSendPrescriptionEmail.listPrescriptionsINP = prescriptionReportListINP; _requestSendPrescriptionEmail.appointmentDate = appointmentDate; _requestSendPrescriptionEmail.patientID = patientID; _requestSendPrescriptionEmail.clinicName = clinicName; diff --git a/lib/core/viewModels/medical/prescriptions_view_model.dart b/lib/core/viewModels/medical/prescriptions_view_model.dart index a3816d92..8ad23b9b 100644 --- a/lib/core/viewModels/medical/prescriptions_view_model.dart +++ b/lib/core/viewModels/medical/prescriptions_view_model.dart @@ -114,9 +114,9 @@ class PrescriptionsViewModel extends BaseViewModel { } } - sendPrescriptionEmail({required String appointmentDate, required int patientID, required String clinicName, required String doctorName, required int doctorID, required String mes, required int projectID}) async { + sendPrescriptionEmail({required String appointmentDate, required int patientID, required String clinicName, required String doctorName, required int doctorID, required String mes, required int projectID, required bool isInOutPatient}) async { setState(ViewState.BusyLocal); - await _prescriptionsService.sendPrescriptionEmail(appointmentDate, patientID, clinicName, doctorName, doctorID, projectID); + await _prescriptionsService.sendPrescriptionEmail(appointmentDate, patientID, clinicName, doctorName, doctorID, projectID, isInOutPatient); if (_prescriptionsService.hasError) { error = _prescriptionsService.error!; setState(ViewState.ErrorLocal); diff --git a/lib/pages/medical/prescriptions/prescription_items_page.dart b/lib/pages/medical/prescriptions/prescription_items_page.dart index 58f1e7d6..5ff0a7d4 100644 --- a/lib/pages/medical/prescriptions/prescription_items_page.dart +++ b/lib/pages/medical/prescriptions/prescription_items_page.dart @@ -61,9 +61,11 @@ class PrescriptionItemsPage extends StatelessWidget { prescriptions.name!, DateUtil.convertStringToDate(prescriptions.appointmentDate!), DateUtil.formatDateToTime( - model.prescriptionReportEnhList.length > 0 || model.prescriptionReportListINP.length > 0 ? DateUtil.convertStringToDate( - model.prescriptionReportEnhList.length > 0 ? model.prescriptionReportEnhList[0].orderDate! : model.prescriptionReportListINP[0].orderDate!, - ) : DateTime.now(), + model.prescriptionReportEnhList.length > 0 || model.prescriptionReportListINP.length > 0 + ? DateUtil.convertStringToDate( + model.prescriptionReportEnhList.length > 0 ? model.prescriptionReportEnhList[0].orderDate! : model.prescriptionReportListINP[0].orderDate!, + ) + : DateTime.now(), ), prescriptions.nationalityFlagURL ?? "", prescriptions.doctorRate, @@ -433,7 +435,8 @@ class PrescriptionItemsPage extends StatelessWidget { doctorName: prescriptions.doctorName!, doctorID: prescriptions.doctorID!, mes: TranslationBase.of(context).sendSuc, - projectID: prescriptions.projectID!); + projectID: prescriptions.projectID!, + isInOutPatient: prescriptions.isInOutPatient!); }, ), );