From 19548ccb1e07bfb7c6711dbc5547a5f5356b2bc2 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Sun, 27 Jun 2021 14:47:37 +0300 Subject: [PATCH] Medical Report change status --- .../PatientMedicalReportService.dart | 5 +++++ .../viewModel/PatientMedicalReportViewModel.dart | 9 ++++++--- lib/locator.dart | 2 +- .../medical_report/AddVerifyMedicalReport.dart | 10 ++++++++-- .../profile/medical_report/MedicalReportPage.dart | 15 ++++++++++----- 5 files changed, 30 insertions(+), 11 deletions(-) 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 0e1d350a..68307f70 100644 --- a/lib/core/service/patient_medical_file/medical_report/PatientMedicalReportService.dart +++ b/lib/core/service/patient_medical_file/medical_report/PatientMedicalReportService.dart @@ -23,6 +23,7 @@ class PatientMedicalReportService extends BaseService { medicalReportList.add(MedicalReportModel.fromJson(v)); }); } + medicalReportList = medicalReportList.reversed.toList(); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error.toString(); @@ -72,6 +73,10 @@ class PatientMedicalReportService extends BaseService { body['AdmissionNo'] = patient.admissionNo; body['InvoiceNo'] = medicalReport.invoiceNo; body['LineItemNo'] = medicalReport.lineItemNo; + if (body['ProjectID'] == null) { + body['ProjectID'] = doctorProfile?.projectID; + } + if (body['DoctorID'] == null) body['DoctorID'] = doctorProfile?.doctorID; await baseAppClient.postPatient(PATIENT_MEDICAL_REPORT_VERIFIED, onSuccess: (dynamic response, int statusCode) {}, onFailure: (String error, int statusCode) { diff --git a/lib/core/viewModel/PatientMedicalReportViewModel.dart b/lib/core/viewModel/PatientMedicalReportViewModel.dart index 3e6de0fb..7866fa69 100644 --- a/lib/core/viewModel/PatientMedicalReportViewModel.dart +++ b/lib/core/viewModel/PatientMedicalReportViewModel.dart @@ -62,7 +62,8 @@ class PatientMedicalReportViewModel extends BaseViewModel { error = _service.error; setState(ViewState.ErrorLocal); } else - setState(ViewState.Idle); + getMedicalReportList(patient); + setState(ViewState.Idle); } Future addMedicalReport(PatiantInformtion patient, String htmlText) async { @@ -72,7 +73,8 @@ class PatientMedicalReportViewModel extends BaseViewModel { error = _service.error; setState(ViewState.ErrorLocal); } else - setState(ViewState.Idle); + getMedicalReportList(patient); + setState(ViewState.Idle); } Future updateMedicalReport(PatiantInformtion patient, String htmlText, int limitNumber, String invoiceNumber) async { @@ -82,6 +84,7 @@ class PatientMedicalReportViewModel extends BaseViewModel { error = _service.error; setState(ViewState.ErrorLocal); } else - setState(ViewState.Idle); + getMedicalReportList(patient); + setState(ViewState.Idle); } } diff --git a/lib/locator.dart b/lib/locator.dart index d74fad8b..e2c578df 100644 --- a/lib/locator.dart +++ b/lib/locator.dart @@ -124,6 +124,6 @@ void setupLocator() { locator.registerFactory(() => PatientSearchViewModel()); locator.registerFactory(() => HospitalViewModel()); locator.registerFactory(() => LiveCarePatientViewModel()); - locator.registerFactory(() => PatientMedicalReportViewModel()); + locator.registerLazySingleton(() => PatientMedicalReportViewModel()); locator.registerFactory(() => ScanQrViewModel()); } diff --git a/lib/screens/patients/profile/medical_report/AddVerifyMedicalReport.dart b/lib/screens/patients/profile/medical_report/AddVerifyMedicalReport.dart index 8d4cbf15..304b39ac 100644 --- a/lib/screens/patients/profile/medical_report/AddVerifyMedicalReport.dart +++ b/lib/screens/patients/profile/medical_report/AddVerifyMedicalReport.dart @@ -4,6 +4,7 @@ import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/models/patient/MedicalReport/MeidcalReportModel.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/screens/patients/profile/medical_report/MedicalReportPage.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/app_loader_widget.dart'; @@ -26,12 +27,13 @@ class _AddVerifyMedicalReportState extends State { Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); final routeArgs = ModalRoute.of(context).settings.arguments as Map; + PatientMedicalReportViewModel patientMedicalReportViewModel = routeArgs['model']; PatiantInformtion patient = routeArgs['patient']; - MedicalReportStatus status = routeArgs['status']; + MedicalReportStatus status = routeArgs['status'] as MedicalReportStatus; MedicalReportModel medicalReport = routeArgs.containsKey("medicalReport") ? routeArgs['medicalReport'] : null; return BaseView( - onModelReady: (model) => model.getMedicalReportTemplate(), + onModelReady: (_) => patientMedicalReportViewModel.getMedicalReportTemplate(), builder: (_, model, w) => AppScaffold( baseViewModel: model, isShowAppBar: true, @@ -99,6 +101,9 @@ class _AddVerifyMedicalReportState extends State { medicalReport != null ? medicalReport.lineItemNo : null, medicalReport != null ? medicalReport.invoiceNo : null) : model.addMedicalReport(patient, txtOfMedicalReport); + //model.getMedicalReportList(patient); + + Navigator.pop(context); GifLoaderDialogUtils.hideDialog(context); if (model.state == ViewState.ErrorLocal) { @@ -123,6 +128,7 @@ class _AddVerifyMedicalReportState extends State { GifLoaderDialogUtils.showMyDialog(context); await model.verifyMedicalReport(patient, medicalReport); GifLoaderDialogUtils.hideDialog(context); + Navigator.pop(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 da1c6cf9..10cb4be6 100644 --- a/lib/screens/patients/profile/medical_report/MedicalReportPage.dart +++ b/lib/screens/patients/profile/medical_report/MedicalReportPage.dart @@ -23,7 +23,12 @@ import 'package:provider/provider.dart'; import '../../../../routes.dart'; import 'AddVerifyMedicalReport.dart'; -class MedicalReportPage extends StatelessWidget { +class MedicalReportPage extends StatefulWidget { + @override + _MedicalReportPageState createState() => _MedicalReportPageState(); +} + +class _MedicalReportPageState extends State { @override Widget build(BuildContext context) { final routeArgs = ModalRoute.of(context).settings.arguments as Map; @@ -35,9 +40,6 @@ class MedicalReportPage extends StatelessWidget { return BaseView( onModelReady: (model) async { await model.getMedicalReportList(patient); - // if (model.state == ViewState.ErrorLocal) { - // DrAppToastMsg.showErrorToast(model.error); - // } }, builder: (_, model, w) => AppScaffold( baseViewModel: model, @@ -81,7 +83,8 @@ class MedicalReportPage extends StatelessWidget { 'patient': patient, 'patientType': patientType, 'arrivalType': arrivalType, - 'type': MedicalReportStatus.ADD + 'type': MedicalReportStatus.ADD, + 'model': model, }); }, label: TranslationBase.of(context).createNewMedicalReport, @@ -97,6 +100,7 @@ class MedicalReportPage extends StatelessWidget { 'patientType': patientType, 'arrivalType': arrivalType, 'medicalReport': model.medicalReportList[index], + 'model': model, }); } else { Navigator.of(context).pushNamed(PATIENT_MEDICAL_REPORT_DETAIL, arguments: { @@ -105,6 +109,7 @@ class MedicalReportPage extends StatelessWidget { 'arrivalType': arrivalType, 'type': MedicalReportStatus.ADD, 'medicalReport': model.medicalReportList[index], + 'model': model, }); } },