From ad8d0f32b6cd9d76d88b2e79c5294cc6cdcc0575 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Sun, 16 Jan 2022 15:30:21 +0200 Subject: [PATCH] plan for refactor prescriptions --- .../prescription/add_prescription_form.dart | 9 +- lib/screens/prescription/drugtodrug.dart | 3 + .../prescription_checkout_screen.dart | 2 + .../prescription/prescription_text_filed.dart | 2 +- .../update_prescription_form.dart | 95 +++---------------- 5 files changed, 26 insertions(+), 85 deletions(-) diff --git a/lib/screens/prescription/add_prescription_form.dart b/lib/screens/prescription/add_prescription_form.dart index 8c07afcf..a8ee8cb8 100644 --- a/lib/screens/prescription/add_prescription_form.dart +++ b/lib/screens/prescription/add_prescription_form.dart @@ -229,6 +229,7 @@ class _PrescriptionFormWidgetState extends State { ProjectViewModel projectViewModel = Provider.of(context); return BaseView( onModelReady: (model) async { + /// TODO Elham* Move this to view model x = model.patientAssessmentList.map((element) { return element.icdCode10ID; }); @@ -331,7 +332,6 @@ class _PrescriptionFormWidgetState extends State { child: Wrap( alignment: WrapAlignment.center, children: [ - // TODO change it secondary button and add loading AppButton( title: TranslationBase.of( context) @@ -647,6 +647,7 @@ class _PrescriptionFormWidgetState extends State { child: InkWell( onTap: () => selectDate( context, widget.model), + /// TODO Elham* Use customTextFields for all TextFields here child: TextField( decoration: textFieldSelectorDecoration( @@ -667,6 +668,7 @@ class _PrescriptionFormWidgetState extends State { ), SizedBox( height: spaceBetweenTextFileds), + /// TODO Elham* Use customTextFields for all PrescriptionTextFiled( element: duration, elementError: durationError, @@ -787,6 +789,7 @@ class _PrescriptionFormWidgetState extends State { .addMedication, fontWeight: FontWeight.w600, onPressed: () async { + /// TODO Elham* Use it to separate function await locator< AnalyticsService>() .logEvent( @@ -1016,7 +1019,7 @@ class _PrescriptionFormWidgetState extends State { }); } } - + /// TODO Elham* Use it from the textfeild utils InputDecoration textFieldSelectorDecoration( String hintText, String selectedText, bool isDropDown, {Icon suffixIcon}) { @@ -1062,6 +1065,7 @@ class _PrescriptionFormWidgetState extends State { showModalBottomSheet( context: context, builder: (context) { + /// TODO Elham* Move this to widget return Container( height: SizeConfig.realScreenHeight * .8, width: SizeConfig.realScreenWidth, @@ -1122,6 +1126,7 @@ class _PrescriptionFormWidgetState extends State { }); } + /// TODO Elham* Move this to view model getPriscriptionforDrug( List prescriptionList, MedicineViewModel model) { var prescriptionDetails = []; diff --git a/lib/screens/prescription/drugtodrug.dart b/lib/screens/prescription/drugtodrug.dart index 78f5afae..5ecb07ce 100644 --- a/lib/screens/prescription/drugtodrug.dart +++ b/lib/screens/prescription/drugtodrug.dart @@ -114,6 +114,9 @@ class _DrugToDrug extends State { } getRequestedData() async { + + /// TODO Elham* rename model to meaning full not just modle with number + await model.getPatientVitalSign(widget.patient); await model2.getPatientAllergy(generalGetReqForSOAP); await model2.getMasterLookup(MasterKeysService.DiagnosisType); diff --git a/lib/screens/prescription/prescription_checkout_screen.dart b/lib/screens/prescription/prescription_checkout_screen.dart index 608dd643..f94c3b52 100644 --- a/lib/screens/prescription/prescription_checkout_screen.dart +++ b/lib/screens/prescription/prescription_checkout_screen.dart @@ -862,6 +862,8 @@ class _PrescriptionCheckOutScreenState } } + /// TODO Elham* Use it from the textfeild utils + InputDecoration textFieldSelectorDecoration( String hintText, String selectedText, bool isDropDown, {Icon suffixIcon}) { diff --git a/lib/screens/prescription/prescription_text_filed.dart b/lib/screens/prescription/prescription_text_filed.dart index 8f2676bc..95b70182 100644 --- a/lib/screens/prescription/prescription_text_filed.dart +++ b/lib/screens/prescription/prescription_text_filed.dart @@ -44,7 +44,7 @@ class _PrescriptionTextFiledState extends State { list: widget.elementList, attributeName: '${widget.keyName}', attributeValueId: widget.elementList.length == 1 - ? widget.elementList[0]['${widget.keyId}'] + ? widget.elementList[0]['${widget.keyId}'].toString() : '${widget.keyId}', okText: TranslationBase.of(context).ok, okFunction: (selectedValue) => diff --git a/lib/screens/prescription/update_prescription_form.dart b/lib/screens/prescription/update_prescription_form.dart index 1a39f7e6..92518fad 100644 --- a/lib/screens/prescription/update_prescription_form.dart +++ b/lib/screens/prescription/update_prescription_form.dart @@ -68,6 +68,7 @@ class _UpdatePrescriptionFormState extends State { int testNum = 0; int strengthChar; PatiantInformtion patient; + /// TODO Elham* add type dynamic route; dynamic doseTime; dynamic frequencyUpdate; @@ -86,6 +87,7 @@ class _UpdatePrescriptionFormState extends State { strengthController.text = widget.doseStreangth; remarksController.text = widget.remarks; indicationList = List(); + /// TODO Elham* create model and try to have them form service and add translation dynamic indication1 = {"id": 545, "name": "Gingival Hyperplasia"}; dynamic indication2 = {"id": 546, "name": "Mild Drowsiness"}; @@ -112,6 +114,7 @@ class _UpdatePrescriptionFormState extends State { indicationList.add(indication9); indicationList.add(indication10); } + /// TODO Elham* Add Translation @override Widget build(BuildContext context) { @@ -120,6 +123,8 @@ class _UpdatePrescriptionFormState extends State { (BuildContext context, StateSetter setState /*You can rename this!*/) { return BaseView( onModelReady: (model) async { + /// TODO Elham* Move this to view model and remove unused data + await model.getMedicationList(); await model.getMedicationStrength(); await model.getMedicationDuration(); @@ -172,78 +177,6 @@ class _UpdatePrescriptionFormState extends State { ), Column( children: [ - // Container( - // height: MediaQuery.of(context).size.height * - // 0.070, - // child: InkWell( - // onTap: model.allMedicationList != null - // ? () { - // setState(() { - // newSelectedMedication = null; - // }); - // } - // : null, - // child: newSelectedMedication == null - // ? AutoCompleteTextField< - // GetMedicationResponseModel>( - // decoration: - // textFieldSelectorDecoration( - // widget.drugNameGeneric, - // newSelectedMedication != null - // ? newSelectedMedication - // .genericName - // : null, - // true, - // ), - // itemSubmitted: (item) => setState( - // () => newSelectedMedication = - // item), - // key: key, - // suggestions: - // model.allMedicationList, - // itemBuilder: (context, - // suggestion) => - // new Padding( - // child: AppText(suggestion - // .description + - // '/' + - // suggestion.genericName), - // padding: - // EdgeInsets.all(8.0)), - // itemSorter: (a, b) => 1, - // itemFilter: (suggestion, input) => - // suggestion.genericName - // .toLowerCase() - // .startsWith( - // input.toLowerCase()) || - // suggestion.description - // .toLowerCase() - // .startsWith( - // input.toLowerCase()) || - // suggestion.keywords - // .toLowerCase() - // .startsWith( - // input.toLowerCase()), - // ) - // : TextField( - // decoration: - // textFieldSelectorDecoration( - // TranslationBase.of(context) - // .searchMedicineNameHere, - // newSelectedMedication != null - // ? newSelectedMedication - // .description + - // ('${newSelectedMedication.genericName}') - // : null, - // true, - // ), - // enabled: false, - // ), - // ), - // ), - // SizedBox( - // height: 12, - // ), Container( height: MediaQuery.of(context).size.height * @@ -284,15 +217,6 @@ class _UpdatePrescriptionFormState extends State { "Only 5 Digits allowed for strength"); } }, - // validator: (value) { - // if (value.isEmpty && - // strengthController.text.length > - // 4) - // return TranslationBase.of(context) - // .emptyMessage; - // else - // return null; - // }, ), ), SizedBox( @@ -805,6 +729,9 @@ class _UpdatePrescriptionFormState extends State { title: 'update prescription' .toUpperCase(), onPressed: () { + + /// TODO Elham* Move this to function + if (double.parse( strengthController.text) > 1000.0) { @@ -912,7 +839,7 @@ class _UpdatePrescriptionFormState extends State { }); } } - + // /// TODO Elham* Use it from the textfeild utils InputDecoration textFieldSelectorDecoration( String hintText, String selectedText, bool isDropDown, {Icon suffixIcon}) { @@ -945,6 +872,7 @@ class _UpdatePrescriptionFormState extends State { ); } + /// TODO Elham* Move this to view model and pass all data as model updatePrescription( {PrescriptionViewModel model, int drugId, @@ -1030,6 +958,9 @@ void updatePrescriptionForm( String uom, int box, String startDate}) { + + /// TODO Elham* remove unused code. + TextEditingController remarksController = TextEditingController(); TextEditingController doseController = TextEditingController(); TextEditingController frequencyController = TextEditingController();