diff --git a/lib/screens/prescription/add_prescription_form.dart b/lib/screens/prescription/add_prescription_form.dart index 07bf9d81..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,10 +639,16 @@ class _PrescriptionFormWidgetState extends State { TranslationBase.of( context) .route, - route != null - ? route[ - 'description'] - : null, + model.itemMedicineListRoute + .length == + 1 + ? model.itemMedicineListRoute[ + 0] + ['description'] + : route != null + ? route[ + 'description'] + : null, true), enabled: false, ), @@ -725,10 +730,16 @@ class _PrescriptionFormWidgetState extends State { TranslationBase.of( context) .frequency, - frequency != null - ? frequency[ - 'description'] - : null, + model.itemMedicineList + .length == + 1 + ? model.itemMedicineList[ + 0] + ['description'] + : frequency != null + ? frequency[ + 'description'] + : null, true), enabled: false, ), @@ -1138,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) @@ -1206,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 @@ -1240,8 +1273,7 @@ class _PrescriptionFormWidgetState extends State { // instruction: // instructionController // .text, - // doseTime: - // selectedDate, + // doseTime: selectedDate, // ); } } @@ -1350,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), @@ -1382,8 +1414,12 @@ class _PrescriptionFormWidgetState extends State { doseTimeIn: doseTime['id'].toString(), model: widget.model, duration: duration['id'].toString(), - frequency: frequency['parameterCode'].toString(), - route: route['parameterCode'].toString(), + frequency: model.itemMedicineList.length == 1 + ? model.itemMedicineList[0]['parameterCode'] + : frequency['parameterCode'].toString(), + route: model.itemMedicineListRoute.length == 1 + ? model.itemMedicineListRoute[0]['parameterCode'] + : route['parameterCode'].toString(), drugId: _selectedMedication.itemId.toString(), strength: strengthController.text, indication: indicationController.text, @@ -1431,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) { @@ -1455,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 }); } diff --git a/pubspec.lock b/pubspec.lock index ee31002d..1a572a0a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -573,7 +573,7 @@ packages: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.2" + version: "0.6.3-nullsafety.1" json_annotation: dependency: transitive description: @@ -615,7 +615,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0-nullsafety.4" mime: dependency: transitive description: @@ -907,7 +907,7 @@ packages: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.1" + version: "1.10.0-nullsafety.2" sticky_headers: dependency: "direct main" description: @@ -1098,5 +1098,5 @@ packages: source: hosted version: "2.2.1" sdks: - dart: ">=2.10.0 <2.11.0" + dart: ">=2.10.0 <=2.11.0-213.1.beta" flutter: ">=1.22.0 <2.0.0"