diff --git a/lib/core/service/patient_medical_file/medical_report/PatientMedicalReportService.dart b/lib/core/service/patient_medical_file/medical_report/PatientMedicalReportService.dart index a0087e0b..0e1d350a 100644 --- a/lib/core/service/patient_medical_file/medical_report/PatientMedicalReportService.dart +++ b/lib/core/service/patient_medical_file/medical_report/PatientMedicalReportService.dart @@ -99,19 +99,23 @@ class PatientMedicalReportService extends BaseService { }, body: body, patient: patient); } - Future updateMedicalReport(PatiantInformtion patient, String htmlText) async { + Future updateMedicalReport(PatiantInformtion patient, String htmlText, int limitNumber, String invoiceNumber) async { hasError = false; Map body = Map(); // body['TokenID'] = "@dm!n"; + + body['LineItemNo'] = limitNumber; + body['InvoiceNo'] = invoiceNumber; + body['SetupID'] = "91877"; - body['AdmissionNo'] = int.parse(patient.admissionNo); + //body['AdmissionNo'] = int.parse(patient.admissionNo); body['MedicalReportHTML'] = htmlText; if (body['ProjectID'] == null) { body['ProjectID'] = doctorProfile?.projectID; } if (body['DoctorID'] == null) body['DoctorID'] = doctorProfile?.doctorID; - await baseAppClient.postPatient(INSERT_MEDICAL_REPORT, onSuccess: (dynamic response, int statusCode) {}, + await baseAppClient.postPatient(UPDATE_MEDICAL_REPORT, onSuccess: (dynamic response, int statusCode) {}, onFailure: (String error, int statusCode) { hasError = true; super.error = error.toString(); diff --git a/lib/core/viewModel/PatientMedicalReportViewModel.dart b/lib/core/viewModel/PatientMedicalReportViewModel.dart index 4d6f845a..3e6de0fb 100644 --- a/lib/core/viewModel/PatientMedicalReportViewModel.dart +++ b/lib/core/viewModel/PatientMedicalReportViewModel.dart @@ -74,4 +74,14 @@ class PatientMedicalReportViewModel extends BaseViewModel { } else setState(ViewState.Idle); } + + Future updateMedicalReport(PatiantInformtion patient, String htmlText, int limitNumber, String invoiceNumber) async { + setState(ViewState.Busy); + await _service.updateMedicalReport(patient, htmlText, limitNumber, invoiceNumber); + if (_service.hasError) { + error = _service.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } } diff --git a/lib/screens/patients/profile/medical_report/AddVerifyMedicalReport.dart b/lib/screens/patients/profile/medical_report/AddVerifyMedicalReport.dart index 36c38870..8d4cbf15 100644 --- a/lib/screens/patients/profile/medical_report/AddVerifyMedicalReport.dart +++ b/lib/screens/patients/profile/medical_report/AddVerifyMedicalReport.dart @@ -92,9 +92,14 @@ class _AddVerifyMedicalReportState extends State { if (txtOfMedicalReport.isNotEmpty) { GifLoaderDialogUtils.showMyDialog(context); - status == MedicalReportStatus.ADD - ? model.addMedicalReport(patient, txtOfMedicalReport) + medicalReport != null + ? model.updateMedicalReport( + patient, + txtOfMedicalReport, + medicalReport != null ? medicalReport.lineItemNo : null, + medicalReport != null ? medicalReport.invoiceNo : null) : model.addMedicalReport(patient, txtOfMedicalReport); + GifLoaderDialogUtils.hideDialog(context); if (model.state == ViewState.ErrorLocal) { DrAppToastMsg.showErrorToast(model.error); diff --git a/lib/screens/patients/profile/medical_report/MedicalReportPage.dart b/lib/screens/patients/profile/medical_report/MedicalReportPage.dart index 01817985..da1c6cf9 100644 --- a/lib/screens/patients/profile/medical_report/MedicalReportPage.dart +++ b/lib/screens/patients/profile/medical_report/MedicalReportPage.dart @@ -96,7 +96,7 @@ class MedicalReportPage extends StatelessWidget { 'patient': patient, 'patientType': patientType, 'arrivalType': arrivalType, - 'medicalReport': model.medicalReportList[index] + 'medicalReport': model.medicalReportList[index], }); } else { Navigator.of(context).pushNamed(PATIENT_MEDICAL_REPORT_DETAIL, arguments: { @@ -104,7 +104,7 @@ class MedicalReportPage extends StatelessWidget { 'patientType': patientType, 'arrivalType': arrivalType, 'type': MedicalReportStatus.ADD, - 'medicalReport': model.medicalReportList[index] + 'medicalReport': model.medicalReportList[index], }); } },