From 9ec78763dc1118af79baeb7356f856736a566e7c Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Sat, 6 Feb 2021 02:22:14 +0200 Subject: [PATCH] update prescription --- .../update_prescription_form.dart | 186 +++++++++--------- 1 file changed, 93 insertions(+), 93 deletions(-) diff --git a/lib/screens/prescription/update_prescription_form.dart b/lib/screens/prescription/update_prescription_form.dart index 0d6609aa..714659ac 100644 --- a/lib/screens/prescription/update_prescription_form.dart +++ b/lib/screens/prescription/update_prescription_form.dart @@ -127,78 +127,78 @@ 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: Texts(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 * + // 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: Texts(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 * 0.060, @@ -508,23 +508,18 @@ class _UpdatePrescriptionFormState extends State { 'update prescription'.toUpperCase(), onPressed: () { updatePrescription( - newDrugId: - newSelectedMedication != null - ? newSelectedMedication - .itemId - .toString() - : widget.drugId, newDoseStreangth: strengthController .text.isNotEmpty ? strengthController.text : widget.doseStreangth, - newUnit: units != null + newUnit: units != + null ? units['id'].toString() : widget.doseUnit, doseUnit: widget.doseUnit, - doseStreangth: - widget.doseStreangth, + doseStreangth: widget + .doseStreangth, duration: widget.duration, startDate: widget.startDate, doseId: widget.dose, @@ -532,20 +527,25 @@ class _UpdatePrescriptionFormState extends State { routeId: widget.route, patient: widget.patient, model: widget.model, - newDuration: updatedDuration != - null - ? updatedDuration['id'] - .toString() - : widget.duration, + newDuration: + updatedDuration != + null + ? updatedDuration[ + 'id'] + .toString() + : widget.duration, drugId: widget.drugId, remarks: remarksController.text, - route: route != null + route: route != + null ? route['id'].toString() : widget.route, - frequency: frequencyUpdate != null - ? frequencyUpdate['id'] - .toString() - : widget.frequency, + frequency: + frequencyUpdate != + null + ? frequencyUpdate['id'] + .toString() + : widget.frequency, dose: doseTime != null ? doseTime['id'].toString() : widget.dose, @@ -604,7 +604,7 @@ class _UpdatePrescriptionFormState extends State { updatePrescription( {PrescriptionViewModel model, int drugId, - int newDrugId, + String newDrugId, String frequencyId, String remarks, String dose, @@ -637,7 +637,7 @@ class _UpdatePrescriptionFormState extends State { ? int.parse(newDoseStreangth) : int.parse(doseStreangth), //frequency.isNotEmpty ? int.parse(dose) : 1, - itemId: newDrugId != 0 ? newDrugId : drugId, + itemId: drugId, doseUnitId: newUnit.isNotEmpty ? int.parse(newUnit) : int.parse(doseUnit), route: route.isNotEmpty ? int.parse(route) : int.parse(routeId),