From ba62056c4dd837eae2b6b9ae42cf826ee2f49d0e Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Wed, 16 Feb 2022 13:17:04 +0200 Subject: [PATCH] finish add Prescription --- lib/config/localized_values.dart | 2 +- lib/routes.dart | 8 +- .../profile_gird_for_InPatient.dart | 4 +- .../profile_gird_for_other.dart | 4 +- .../profile_gird_for_search.dart | 4 +- .../add_drug/add_drug_widget.dart | 153 ++++++++++-------- .../prescription_form_widget.dart | 2 - ..._page.dart => old_prescriptions_page.dart} | 26 +-- .../procedures/add-favourite-procedure.dart | 68 ++++---- .../profile/profile_medical_info_widget.dart | 2 +- ...rofile_medical_info_widget_in_patient.dart | 4 +- .../profile_medical_info_widget_search.dart | 2 +- 12 files changed, 139 insertions(+), 140 deletions(-) rename lib/screens/prescription/{prescriptions_page.dart => old_prescriptions_page.dart} (89%) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 6dcf5968..cac9883a 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1129,7 +1129,7 @@ const Map> localizedValues = { "VTE_Type": {"en": "VTE Type", "ar": "VTE Type"}, "pharmacology": {"en": "Pharmacology", "ar": "علم العقاقير"}, "reasonsThrombo": {"en": "Reasons Thrombo", "ar": "أسباب ثرومبو"}, - "youDoNotHaveFavoritePrescription": {"en": "you Don't Have Favorite Prescription", "ar": "ليس لديك وصفة طبية مفضلة"}, + "youDoNotHaveFavoritePrescription": {"en": "You Don't Have Favorite Prescription", "ar": "ليس لديك وصفة طبية مفضلة"}, "pleaseSelectItem": {"en": "please Select Item", "ar": "الرجاء اختيار عنصر"}, "searchFavoriteTemplate": {"en": "search Favorites Template", "ar": "البحث في قالب المفضلة"}, "sorryNoMatch": {"en": "Sorry No Match", "ar": "عذرا لا يوجد تطابق"}, diff --git a/lib/routes.dart b/lib/routes.dart index c50504a7..917b1c6c 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -25,7 +25,7 @@ import 'package:doctor_app_flutter/screens/patients/profile/referral/refer-patie import 'package:doctor_app_flutter/screens/patients/profile/soap_update/update_soap_index.dart'; import 'package:doctor_app_flutter/screens/patients/profile/vte_assessment/vte_assessment_screen.dart'; import 'package:doctor_app_flutter/screens/prescription/new_prescriptions_page.dart'; -import 'package:doctor_app_flutter/screens/prescription/prescriptions_page.dart'; +import 'package:doctor_app_flutter/screens/prescription/old_prescriptions_page.dart'; import 'package:doctor_app_flutter/screens/procedures/procedure_screen.dart'; import './screens/auth/login_screen.dart'; @@ -71,8 +71,8 @@ const String PATIENT_UCAF_REQUEST = 'patients/ucaf'; const String PATIENT_UCAF_DETAIL = 'patients/ucaf/detail'; const String PATIENT_ECG = 'patients/ecg'; const String IN_PATIENT_PRESCRIPTIONS_DETAILS = 'patients/prescription-details'; +const String ORDER_PRESCRIPTION_OLD = 'prescription/prescription_old'; const String ORDER_PRESCRIPTION_NEW = 'prescription/prescription_new'; -const String ORDER_PRESCRIPTION_NEW_By_Elham = 'prescription/prescription_new_elham'; const String ORDER_PROCEDURE = 'procedure/procedure'; const String ADD_SICKLEAVE = 'add-sickleave'; const String RADIOLOGY_PATIENT = 'radiology-patient'; @@ -125,8 +125,8 @@ var routes = { ), IN_PATIENT_PRESCRIPTIONS_DETAILS: (_) => InpatientPrescriptionDetailsScreen(), ADD_SICKLEAVE: (_) => PatientSickLeaveScreen(), - ORDER_PRESCRIPTION_NEW: (_) => PrescriptionsPage(), - ORDER_PRESCRIPTION_NEW_By_Elham: (_) => NewPrescriptionsPage(), + ORDER_PRESCRIPTION_OLD: (_) => OldPrescriptionsPage(), + ORDER_PRESCRIPTION_NEW: (_) => NewPrescriptionsPage(), ORDER_PROCEDURE: (_) => ProcedureScreen(), MY_REFERRAL_DETAIL: (_) => MyReferralDetailScreen(), PATIENT_UCAF_REQUEST: (_) => UCAFPagerScreen(), diff --git a/lib/screens/patients/profile/profile_screen/profile_gird_for_InPatient.dart b/lib/screens/patients/profile/profile_screen/profile_gird_for_InPatient.dart index ed9e2c1d..d4c20025 100644 --- a/lib/screens/patients/profile/profile_screen/profile_gird_for_InPatient.dart +++ b/lib/screens/patients/profile/profile_screen/profile_gird_for_InPatient.dart @@ -61,13 +61,13 @@ class ProfileGridForInPatient extends StatelessWidget { PatientProfileCardModel( TranslationBase.of(context).patient, TranslationBase.of(context).prescription + ' (${TranslationBase.of(context).old})', - ORDER_PRESCRIPTION_NEW, + ORDER_PRESCRIPTION_OLD, 'assets/images/svgs/profile_screen/order prescription.svg', isInPatient: isInpatient), PatientProfileCardModel( TranslationBase.of(context).patient, TranslationBase.of(context).prescription, - ORDER_PRESCRIPTION_NEW_By_Elham, + ORDER_PRESCRIPTION_NEW, 'assets/images/svgs/profile_screen/order prescription.svg', isInPatient: isInpatient), diff --git a/lib/screens/patients/profile/profile_screen/profile_gird_for_other.dart b/lib/screens/patients/profile/profile_screen/profile_gird_for_other.dart index 0ff600a6..b2f844dd 100644 --- a/lib/screens/patients/profile/profile_screen/profile_gird_for_other.dart +++ b/lib/screens/patients/profile/profile_screen/profile_gird_for_other.dart @@ -59,13 +59,13 @@ class ProfileGridForOther extends StatelessWidget { PatientProfileCardModel( TranslationBase.of(context).orders, TranslationBase.of(context).prescription + ' (${TranslationBase.of(context).old})', - ORDER_PRESCRIPTION_NEW, + ORDER_PRESCRIPTION_OLD, 'assets/images/svgs/profile_screen/order prescription.svg', isInPatient: isInpatient), PatientProfileCardModel( TranslationBase.of(context).patient, TranslationBase.of(context).prescription, - ORDER_PRESCRIPTION_NEW_By_Elham, + ORDER_PRESCRIPTION_NEW, 'assets/images/svgs/profile_screen/order prescription.svg', isInPatient: isInpatient), PatientProfileCardModel( diff --git a/lib/screens/patients/profile/profile_screen/profile_gird_for_search.dart b/lib/screens/patients/profile/profile_screen/profile_gird_for_search.dart index 21f5823e..8e54c8ca 100644 --- a/lib/screens/patients/profile/profile_screen/profile_gird_for_search.dart +++ b/lib/screens/patients/profile/profile_screen/profile_gird_for_search.dart @@ -56,13 +56,13 @@ class ProfileGridForSearch extends StatelessWidget { PatientProfileCardModel( TranslationBase.of(context).orders, TranslationBase.of(context).prescription + ' (${TranslationBase.of(context).old})', - ORDER_PRESCRIPTION_NEW, + ORDER_PRESCRIPTION_OLD, 'assets/images/svgs/profile_screen/order prescription.svg', isInPatient: isInpatient), PatientProfileCardModel( TranslationBase.of(context).patient, TranslationBase.of(context).prescription, - ORDER_PRESCRIPTION_NEW_By_Elham, + ORDER_PRESCRIPTION_NEW, 'assets/images/svgs/profile_screen/order prescription.svg', isInPatient: isInpatient), PatientProfileCardModel( diff --git a/lib/screens/prescription/add_prescription/add_drug/add_drug_widget.dart b/lib/screens/prescription/add_prescription/add_drug/add_drug_widget.dart index 8ce52a43..854ec4ae 100644 --- a/lib/screens/prescription/add_prescription/add_drug/add_drug_widget.dart +++ b/lib/screens/prescription/add_prescription/add_drug/add_drug_widget.dart @@ -34,9 +34,25 @@ class AddDrugWidget extends StatefulWidget { final String instruction; final DateTime selectedDate; - const AddDrugWidget({Key key, this.patient, this.prescriptionList, this.medicineModel, - this.modelPrescription, this.units, this.route, this.frequency, this.duration, this.doseTime, - this.uom, this.x, this.selectedMedication, this.strength, this.indication, this.instruction, this.selectedDate}) : super(key: key); + const AddDrugWidget( + {Key key, + this.patient, + this.prescriptionList, + this.medicineModel, + this.modelPrescription, + this.units, + this.route, + this.frequency, + this.duration, + this.doseTime, + this.uom, + this.x, + this.selectedMedication, + this.strength, + this.indication, + this.instruction, + this.selectedDate}) + : super(key: key); @override _AddDrugWidgetState createState() => _AddDrugWidgetState(); @@ -47,75 +63,84 @@ class _AddDrugWidgetState extends State { Widget build(BuildContext context) { return AppScaffold( baseViewModel: widget.medicineModel, - appBar: BottomSheetTitle( - title: TranslationBase.of(context).addMedication), + appBar: + BottomSheetTitle(title: TranslationBase.of(context).addMedication), body: Container( height: SizeConfig.realScreenHeight * .8, width: SizeConfig.realScreenWidth, child: SingleChildScrollView( child: Column( - children: [ - DrugToDrug( - widget.patient, - widget.medicineModel.getPrescriptionForDrug( - widget.prescriptionList, widget.medicineModel - ), - widget.medicineModel.patientAssessmentList), - ], - )), + children: [ + DrugToDrug( + widget.patient, + widget.medicineModel.getPrescriptionForDrug( + widget.prescriptionList, widget.medicineModel), + widget.medicineModel.patientAssessmentList), + ], + )), ), - bottomSheet: widget.medicineModel.state == ViewState.BusyLocal || widget.medicineModel.state == ViewState.Busy + bottomSheet: widget.medicineModel.state == ViewState.BusyLocal || + widget.medicineModel.state == ViewState.Busy ? Container( - height: 0, - ) + height: 0, + ) : BottomSheetDialogButton( - label: TranslationBase.of(context).addMedication, - onTap: () async { - GifLoaderDialogUtils.showMyDialog(context); - await widget.medicineModel.postPrescription( - isLocalBusy: true, - icdCode: widget.medicineModel.patientAssessmentList.isNotEmpty - ? widget.medicineModel.patientAssessmentList[0].icdCode10ID - .isEmpty - ? "test" - : widget.medicineModel.patientAssessmentList[0].icdCode10ID - .toString() - : "test", - dose: widget.strength, - doseUnit: widget.medicineModel.itemMedicineListUnit.length == 1 - ? widget.medicineModel.itemMedicineListUnit[0]['parameterCode'] - .toString() - : widget.units['parameterCode'].toString(), - patient: widget.patient, - doseTimeIn: widget.doseTime['id'].toString(), - model: widget.modelPrescription, - duration: widget.duration['id'].toString(), - frequency: widget.medicineModel.itemMedicineList.length == 1 - ? widget.medicineModel.itemMedicineList[0]['parameterCode'] - .toString() - : widget.frequency['parameterCode'].toString(), - route: widget.medicineModel.itemMedicineListRoute.length == 1 - ? widget.medicineModel.itemMedicineListRoute[0]['parameterCode'] - .toString() - : widget.route['parameterCode'].toString(), - drugId: widget.selectedMedication.itemId.toString(), - strength: widget.strength, - indication: widget.indication, - instruction: widget.instruction, - doseTime: widget.selectedDate, - ); - if (widget.medicineModel.state == ViewState.ErrorLocal) { - GifLoaderDialogUtils.hideDialog(context); - Helpers.showErrorToast(widget.medicineModel.error); - } else if (widget.modelPrescription.state == ViewState.Idle) { - widget.modelPrescription.getPrescriptions(widget.patient); - GifLoaderDialogUtils.hideDialog(context); - DrAppToastMsg.showSuccesToast(TranslationBase.of(context).medicationHasBeenAdded); - Navigator.of(context).pop(); - Navigator.of(context).pop(); - } - }, - ), + label: TranslationBase.of(context).addMedication, + onTap: () async { + GifLoaderDialogUtils.showMyDialog(context); + await widget.medicineModel.postPrescription( + isLocalBusy: true, + icdCode: widget.medicineModel.patientAssessmentList.isNotEmpty + ? widget.medicineModel.patientAssessmentList[0] + .icdCode10ID.isEmpty + ? "test" + : widget.medicineModel.patientAssessmentList[0] + .icdCode10ID + .toString() + : "test", + dose: widget.strength, + doseUnit: + widget.medicineModel.itemMedicineListUnit.length == 1 + ? widget.medicineModel + .itemMedicineListUnit[0]['parameterCode'] + .toString() + : widget.units['parameterCode'].toString(), + patient: widget.patient, + doseTimeIn: widget.doseTime['id'].toString(), + model: widget.modelPrescription, + duration: widget.duration['id'].toString(), + frequency: widget.medicineModel.itemMedicineList.length == 1 + ? widget + .medicineModel.itemMedicineList[0]['parameterCode'] + .toString() + : widget.frequency['parameterCode'].toString(), + route: widget.medicineModel.itemMedicineListRoute.length == 1 + ? widget.medicineModel + .itemMedicineListRoute[0]['parameterCode'] + .toString() + : widget.route['parameterCode'].toString(), + drugId: widget.selectedMedication.itemId.toString(), + strength: widget.strength, + indication: widget.indication, + instruction: widget.instruction, + doseTime: widget.selectedDate, + ); + if (widget.medicineModel.state == ViewState.ErrorLocal) { + GifLoaderDialogUtils.hideDialog(context); + Helpers.showErrorToast(widget.medicineModel.error); + } else if (widget.modelPrescription.state == ViewState.Idle) { + await widget.modelPrescription.getPrescriptionListNew( + appNo: widget.patient.appointmentNo, + mrn: widget.patient.patientMRN, + isLocalBusy: true); + GifLoaderDialogUtils.hideDialog(context); + DrAppToastMsg.showSuccesToast( + TranslationBase.of(context).medicationHasBeenAdded); + Navigator.of(context).pop(); + Navigator.of(context).pop(); + } + }, + ), ); } } diff --git a/lib/screens/prescription/add_prescription/prescription_form_widget.dart b/lib/screens/prescription/add_prescription/prescription_form_widget.dart index 39c9d171..13ec5a15 100644 --- a/lib/screens/prescription/add_prescription/prescription_form_widget.dart +++ b/lib/screens/prescription/add_prescription/prescription_form_widget.dart @@ -68,8 +68,6 @@ class _PrescriptionFormWidgetState extends State { final myController = TextEditingController(); DateTime selectedDate; int strengthChar; - PrescriptionViewModel prescriptionViewModel; - GlobalKey key = new GlobalKey>(); diff --git a/lib/screens/prescription/prescriptions_page.dart b/lib/screens/prescription/old_prescriptions_page.dart similarity index 89% rename from lib/screens/prescription/prescriptions_page.dart rename to lib/screens/prescription/old_prescriptions_page.dart index 43083f60..c969397d 100644 --- a/lib/screens/prescription/prescriptions_page.dart +++ b/lib/screens/prescription/old_prescriptions_page.dart @@ -21,8 +21,7 @@ import 'package:flutter/material.dart'; import '../../util/helpers.dart'; import '../../widgets/shared/errors/error_message.dart'; -///TODO Elham* the design should be fixed By roaa -class PrescriptionsPage extends StatelessWidget { +class OldPrescriptionsPage extends StatelessWidget { @override Widget build(BuildContext context) { final routeArgs = ModalRoute.of(context).settings.arguments as Map; @@ -64,31 +63,12 @@ class PrescriptionsPage extends StatelessWidget { ServiceTitle( title: TranslationBase.of(context).orders, subTitle: TranslationBase.of(context) - .prescriptions, + .prescriptions + "(${TranslationBase.of(context) + .old }) ", ), ], ), ), - if ((patient.patientStatusType != null && - patient.patientStatusType == 43) || - (isFromLiveCare && patient.appointmentNo != null)) - AddNewOrder( - onTap: () { - Navigator.push( - context, - SlideUpPageRoute( - widget: BaseAddProcedureTabPage( - patient: patient, - prescriptionModel: model, - procedureType: - ProcedureType.PRESCRIPTION, - ), - settingRoute: 'AddProcedureTabPage'), - ); - }, - label: TranslationBase.of(context) - .applyForNewPrescriptionsOrder, - ), ListView.builder( physics: BouncingScrollPhysics(), itemCount: model.prescriptionsList.length, diff --git a/lib/screens/procedures/add-favourite-procedure.dart b/lib/screens/procedures/add-favourite-procedure.dart index c062d69b..85261de2 100644 --- a/lib/screens/procedures/add-favourite-procedure.dart +++ b/lib/screens/procedures/add-favourite-procedure.dart @@ -11,6 +11,7 @@ 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_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/errors/error_message.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../patients/profile/soap_update/shared_soap_widgets/bottom_sheet_dialog_button.dart'; @@ -50,43 +51,38 @@ class _AddFavouriteProcedureState extends State { AppScaffold( isShowAppBar: false, baseViewModel: model, - body: Column( - children: [ - (widget.previousProcedureViewModel.templateList.length != 0) - ? Expanded( - child: EntityListCheckboxSearchFavProceduresWidget( - isProcedure: !(widget.procedureType == - ProcedureType.PRESCRIPTION), - model: widget.previousProcedureViewModel, - removeFavProcedure: (item) { - setState(() { - entityList.remove(item); - }); - }, - addFavProcedure: (history) { - setState(() { - entityList.add(history); - }); - }, - isEntityFavListSelected: (master) => - isEntityListSelected(master), - groupProcedures: groupProcedures, - selectProcedures: (selectedProcedure) { - setState(() { - groupProcedures = selectedProcedure; - }); - }, - ), - ) - : Container( - child: Padding( - padding: EdgeInsets.symmetric(vertical: 50.0), - child: AppText( - TranslationBase.of(context).youDoNotHaveFavoritePrescription,), - ), + body: Column(children: [ + (widget.previousProcedureViewModel.templateList.length != 0) + ? Expanded( + child: EntityListCheckboxSearchFavProceduresWidget( + isProcedure: !(widget.procedureType == + ProcedureType.PRESCRIPTION), + model: widget.previousProcedureViewModel, + removeFavProcedure: (item) { + setState(() { + entityList.remove(item); + }); + }, + addFavProcedure: (history) { + setState(() { + entityList.add(history); + }); + }, + isEntityFavListSelected: (master) => + isEntityListSelected(master), + groupProcedures: groupProcedures, + selectProcedures: (selectedProcedure) { + setState(() { + groupProcedures = selectedProcedure; + }); + }, ), - ], - ), + ) + : ErrorMessage( + error: TranslationBase.of(context) + .youDoNotHaveFavoritePrescription, + ), + ]), bottomSheet: BottomSheetDialogButton( label: widget.procedureType.getAddButtonTitle(context) ?? TranslationBase.of(context).addSelectedProcedures, diff --git a/lib/widgets/patients/profile/profile_medical_info_widget.dart b/lib/widgets/patients/profile/profile_medical_info_widget.dart index 4869ca9d..abf548ed 100644 --- a/lib/widgets/patients/profile/profile_medical_info_widget.dart +++ b/lib/widgets/patients/profile/profile_medical_info_widget.dart @@ -102,7 +102,7 @@ class ProfileMedicalInfoWidget extends StatelessWidget { patient: patient, patientType: patientType, arrivalType: arrivalType, - route: ORDER_PRESCRIPTION_NEW, + route: ORDER_PRESCRIPTION_OLD, nameLine1: TranslationBase.of(context).orders, nameLine2: TranslationBase.of(context).prescription, icon: 'assets/images/svgs/profile_screen/order prescription.svg'), diff --git a/lib/widgets/patients/profile/profile_medical_info_widget_in_patient.dart b/lib/widgets/patients/profile/profile_medical_info_widget_in_patient.dart index 48a96bf0..9de84de2 100644 --- a/lib/widgets/patients/profile/profile_medical_info_widget_in_patient.dart +++ b/lib/widgets/patients/profile/profile_medical_info_widget_in_patient.dart @@ -75,7 +75,7 @@ class ProfileMedicalInfoWidgetInPatient extends StatelessWidget { patient: patient, patientType: patientType, arrivalType: arrivalType, - route: ORDER_PRESCRIPTION_NEW, + route: ORDER_PRESCRIPTION_OLD, nameLine1: TranslationBase.of(context).patient, nameLine2:TranslationBase.of(context).prescription + ' (${TranslationBase.of(context).old})', icon: 'assets/images/svgs/profile_screen/order prescription.svg'), @@ -84,7 +84,7 @@ class ProfileMedicalInfoWidgetInPatient extends StatelessWidget { patient: patient, patientType: patientType, arrivalType: arrivalType, - route: ORDER_PRESCRIPTION_NEW_By_Elham, + route: ORDER_PRESCRIPTION_NEW, nameLine1: TranslationBase.of(context).patient, nameLine2: TranslationBase.of(context).prescription, icon: 'assets/images/svgs/profile_screen/order prescription.svg'), diff --git a/lib/widgets/patients/profile/profile_medical_info_widget_search.dart b/lib/widgets/patients/profile/profile_medical_info_widget_search.dart index 41063bdf..297b9d75 100644 --- a/lib/widgets/patients/profile/profile_medical_info_widget_search.dart +++ b/lib/widgets/patients/profile/profile_medical_info_widget_search.dart @@ -114,7 +114,7 @@ class ProfileMedicalInfoWidgetSearch extends StatelessWidget { patient: patient, patientType: patientType, arrivalType: arrivalType, - route: ORDER_PRESCRIPTION_NEW, + route: ORDER_PRESCRIPTION_OLD, nameLine1: TranslationBase.of(context).orders, nameLine2: TranslationBase.of(context).prescription, icon: