diff --git a/lib/screens/prescription/add_prescription_form.dart b/lib/screens/prescription/add_prescription_form.dart index 09d9f29e..71cdd1e4 100644 --- a/lib/screens/prescription/add_prescription_form.dart +++ b/lib/screens/prescription/add_prescription_form.dart @@ -438,7 +438,7 @@ class _PrescriptionFormWidgetState extends State { width: MediaQuery.of(context) .size .width * - 0.550, + 0.450, child: TextFields( inputFormatters: [ LengthLimitingTextInputFormatter( @@ -513,7 +513,7 @@ class _PrescriptionFormWidgetState extends State { width: MediaQuery.of(context) .size .width * - 0.350, + 0.450, child: InkWell( onTap: model.itemMedicineListUnit != @@ -561,14 +561,13 @@ class _PrescriptionFormWidgetState extends State { child: TextField( decoration: textFieldSelectorDecoration( - TranslationBase.of( - context) - .unit, + 'Select', model.itemMedicineListUnit .length == 1 - ? model.itemMedicineListUnit[ - 0][ + ? units = model + .itemMedicineListUnit[0] + [ 'description'] : units != null @@ -640,16 +639,16 @@ class _PrescriptionFormWidgetState extends State { TranslationBase.of( context) .route, - route != null - ? model.itemMedicineListRoute - .length == - 1 - ? model.itemMedicineListRoute[ - 0][ - 'description'] - : route[ + model.itemMedicineListRoute + .length == + 1 + ? model.itemMedicineListRoute[ + 0] + ['description'] + : route != null + ? route[ 'description'] - : null, + : null, true), enabled: false, ), @@ -731,16 +730,16 @@ class _PrescriptionFormWidgetState extends State { TranslationBase.of( context) .frequency, - frequency != null - ? model.itemMedicineList - .length == - 1 - ? model.itemMedicineList[ - 0][ - 'description'] - : frequency[ + model.itemMedicineList + .length == + 1 + ? model.itemMedicineList[ + 0] + ['description'] + : frequency != null + ? frequency[ 'description'] - : null, + : null, true), enabled: false, ), @@ -1150,12 +1149,13 @@ class _PrescriptionFormWidgetState extends State { formKey.currentState.save(); // Navigator.pop(context); // openDrugToDrug(); - if (route == null || - frequency == null || + if (frequency == null || + strengthController + .text == + null || doseTime == null || duration == null || - selectedDate == null || - units == null) { + selectedDate == null) { DrAppToastMsg.showErrorToast( TranslationBase.of( context) @@ -1218,27 +1218,48 @@ class _PrescriptionFormWidgetState extends State { // // .trim()) // // .toList() // // .join(' '), - // dose: - // strengthController - // .text, - // doseUnit: units[ - // 'parameterCode'] - // .toString(), - // patient: - // widget.patient, + // dose: strengthController + // .text, + // doseUnit: model + // .itemMedicineListUnit + // .length == + // 1 + // ? model + // .itemMedicineListUnit[ + // 0][ + // 'parameterCode'] + // .toString() + // : units['parameterCode'] + // .toString(), + // patient: widget.patient, // doseTimeIn: // doseTime['id'] // .toString(), // model: widget.model, - // duration: - // duration['id'] - // .toString(), - // frequency: frequency[ - // 'parameterCode'] - // .toString(), - // route: route[ - // 'parameterCode'] + // duration: duration['id'] // .toString(), + // frequency: model + // .itemMedicineList + // .length == + // 1 + // ? model + // .itemMedicineList[ + // 0][ + // 'parameterCode'] + // .toString() + // : frequency[ + // 'parameterCode'] + // .toString(), + // route: model.itemMedicineListRoute + // .length == + // 1 + // ? model + // .itemMedicineListRoute[ + // 0][ + // 'parameterCode'] + // .toString() + // : route['parameterCode'] + // .toString(), // drugId: // _selectedMedication // .itemId @@ -1252,8 +1273,7 @@ class _PrescriptionFormWidgetState extends State { // instruction: // instructionController // .text, - // doseTime: - // selectedDate, + // doseTime: selectedDate, // ); } } @@ -1362,7 +1382,7 @@ class _PrescriptionFormWidgetState extends State { children: [ DrugToDrug( widget.patient, - getPriscriptionforDrug(widget.prescriptionList), + getPriscriptionforDrug(widget.prescriptionList, model), model.patientAssessmentList), Container( margin: EdgeInsets.all(SizeConfig.widthMultiplier * 3), @@ -1447,7 +1467,17 @@ class _PrescriptionFormWidgetState extends State { }); } - getPriscriptionforDrug(List prescriptionList) { + // selectedValue(itemMdeicationList,key){ + // // String selected = ""; + // // units[key]=itemMdeicationList.length==1? itemMdeicationList[0][key]:units[key].toString(); + // // + // // selected = units[key]; + // // + // // return selected; + // // } + + getPriscriptionforDrug( + List prescriptionList, MedicineViewModel model) { var prescriptionDetails = []; if (prescriptionList.length > 0) { prescriptionList[0].entityList.forEach((element) { @@ -1471,11 +1501,19 @@ class _PrescriptionFormWidgetState extends State { 'DrugId': _selectedMedication.mediSpanGPICode, 'DrugName': _selectedMedication.description, 'Dose': strengthController.text, - 'DoseType': units['parameterCode'].toString(), - 'Unit': units['description'], - 'FrequencyType': frequency['parameterCode'].toString(), + 'DoseType': model.itemMedicineListUnit.length == 1 + ? model.itemMedicineListUnit[0]['parameterCode'].toString() + : units['parameterCode'].toString(), + 'Unit': model.itemMedicineListUnit.length == 1 + ? model.itemMedicineListUnit[0]['description'] + : units['description'], + 'FrequencyType': model.itemMedicineList.length == 1 + ? model.itemMedicineList[0]['parameterCode'] + : frequency['parameterCode'].toString(), 'Duration': duration['id'].toString(), - 'RouteID': route['parameterCode'].toString(), + 'RouteID': model.itemMedicineListRoute.length == 1 + ? model.itemMedicineListRoute[0]['parameterCode'].toString() + : route['parameterCode'].toString(), 'IsScreen': true }); }