From f32d25b007b0d3b9e9756d41bbf3f0ec2505ade3 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Sun, 21 Feb 2021 14:45:01 +0200 Subject: [PATCH] updating prescription after backend fix --- lib/core/model/post_prescrition_req_model.dart | 2 +- .../prescription/add_prescription_form.dart | 14 +++++++------- .../prescription/update_prescription_form.dart | 15 ++++++++------- lib/screens/procedures/add-procedure-form.dart | 8 +++----- .../entity_list_checkbox_search_widget.dart | 8 ++++---- lib/screens/procedures/update-procedure.dart | 18 +++++++++++------- 6 files changed, 34 insertions(+), 31 deletions(-) diff --git a/lib/core/model/post_prescrition_req_model.dart b/lib/core/model/post_prescrition_req_model.dart index 6fc71199..06a524ed 100644 --- a/lib/core/model/post_prescrition_req_model.dart +++ b/lib/core/model/post_prescrition_req_model.dart @@ -47,7 +47,7 @@ class PrescriptionRequestModel { int itemId; String doseStartDate; int duration; - int dose; + double dose; int doseUnitId; int route; int frequency; diff --git a/lib/screens/prescription/add_prescription_form.dart b/lib/screens/prescription/add_prescription_form.dart index b25d3928..5ec6e240 100644 --- a/lib/screens/prescription/add_prescription_form.dart +++ b/lib/screens/prescription/add_prescription_form.dart @@ -61,7 +61,7 @@ postProcedure( sss.add(PrescriptionRequestModel( covered: true, - dose: int.parse(dose), + dose: double.parse(dose), itemId: drugId.isEmpty ? 1 : int.parse(drugId), doseUnitId: int.parse(doseUnit), route: route.isEmpty ? 1 : int.parse(route), @@ -361,8 +361,8 @@ class _PrescriptionFormWidgetState extends State { 0.550, child: TextFields( inputFormatters: [ - LengthLimitingTextInputFormatter( - 4), + // LengthLimitingTextInputFormatter( + // 4), // WhitelistingTextInputFormatter // .digitsOnly ], @@ -767,16 +767,16 @@ class _PrescriptionFormWidgetState extends State { "Please Fill All Fields"); return; } - if (int.parse( + if (double.parse( strengthController.text) > - 1000) { + 1000.0) { DrAppToastMsg.showErrorToast( "1000 is the MAX for the strength"); return; } - if (int.parse( + if (double.parse( strengthController.text) == - 0) { + 0.0) { DrAppToastMsg.showErrorToast( "Streangth can't be zero"); return; diff --git a/lib/screens/prescription/update_prescription_form.dart b/lib/screens/prescription/update_prescription_form.dart index ace71350..8ed5c79b 100644 --- a/lib/screens/prescription/update_prescription_form.dart +++ b/lib/screens/prescription/update_prescription_form.dart @@ -703,16 +703,17 @@ class _UpdatePrescriptionFormState extends State { title: 'update prescription' .toUpperCase(), onPressed: () { - if (int.parse( + if (double.parse( strengthController.text) > - 1000) { + 1000.0) { DrAppToastMsg.showErrorToast( "1000 is the MAX for the strength"); return; } - if (int.parse(strengthController - .text) == - 0) { + if (double.parse( + strengthController + .text) == + 0.0) { DrAppToastMsg.showErrorToast( "Streangth can't be zero"); return; @@ -872,8 +873,8 @@ class _UpdatePrescriptionFormState extends State { sss.add(PrescriptionRequestModel( covered: true, dose: newDoseStreangth.isNotEmpty - ? int.parse(newDoseStreangth) - : int.parse(doseStreangth), + ? double.parse(newDoseStreangth) + : double.parse(doseStreangth), //frequency.isNotEmpty ? int.parse(dose) : 1, itemId: drugId, doseUnitId: diff --git a/lib/screens/procedures/add-procedure-form.dart b/lib/screens/procedures/add-procedure-form.dart index 2fa0c428..346de2db 100644 --- a/lib/screens/procedures/add-procedure-form.dart +++ b/lib/screens/procedures/add-procedure-form.dart @@ -25,14 +25,15 @@ postProcedure( PatiantInformtion patient, List entityList}) async { PostProcedureReqModel postProcedureReqModel = new PostProcedureReqModel(); - List controls = List(); List controlsProcedure = List(); postProcedureReqModel.appointmentNo = patient.appointmentNo; postProcedureReqModel.episodeID = patient.episodeNo; postProcedureReqModel.patientMRN = patient.patientMRN; + entityList.forEach((element) { + List controls = List(); controls.add( Controls( code: "remarks", @@ -41,16 +42,13 @@ postProcedure( controls.add( Controls(code: "ordertype", controlValue: element.type), ); - }); - - entityList.forEach((element) { controlsProcedure.add(Procedures( category: element.categoryID, procedure: element.procedureId, controls: controls)); }); - postProcedureReqModel.procedures = controlsProcedure; + postProcedureReqModel.procedures = controlsProcedure; await model.postProcedure(postProcedureReqModel, patient.patientMRN); if (model.state == ViewState.ErrorLocal) { diff --git a/lib/screens/procedures/entity_list_checkbox_search_widget.dart b/lib/screens/procedures/entity_list_checkbox_search_widget.dart index 73cf0115..f68b88cd 100644 --- a/lib/screens/procedures/entity_list_checkbox_search_widget.dart +++ b/lib/screens/procedures/entity_list_checkbox_search_widget.dart @@ -136,8 +136,8 @@ class _EntityListCheckboxSearchWidgetState historyInfo.type = setSelectedType(value) .toString(); - // historyInfo.type = - // value.toString(); + historyInfo.type = + value.toString(); }, ), Text('routine'), @@ -149,8 +149,8 @@ class _EntityListCheckboxSearchWidgetState historyInfo.type = setSelectedType(value) .toString(); - // historyInfo.type = - // value.toString(); + historyInfo.type = + value.toString(); }, ), Text(TranslationBase.of(context) diff --git a/lib/screens/procedures/update-procedure.dart b/lib/screens/procedures/update-procedure.dart index 038b5d59..c6af1358 100644 --- a/lib/screens/procedures/update-procedure.dart +++ b/lib/screens/procedures/update-procedure.dart @@ -91,7 +91,7 @@ class _UpdateProcedureWidgetState extends State { builder: (BuildContext context, ProcedureViewModel model, Widget child) => NetworkBaseView( - baseViewModel: widget.model, + baseViewModel: model, child: DraggableScrollableSheet( minChildSize: 0.90, initialChildSize: 0.95, @@ -310,12 +310,16 @@ class _UpdateProcedureWidgetState extends State { updateProcedureReqModel.lineItemNo = 1; updateProcedureReqModel.orderNo = orderNo; - controls.add( - Controls(code: "remarks", controlValue: remarks.isEmpty ? '' : remarks), - ); - controls.add( - Controls(code: "ordertype", controlValue: "1"), - ); + entityList.forEach((element) { + controls.add( + Controls( + code: "remarks", + controlValue: element.remarks.isNotEmpty ? element.remarks : ""), + ); + controls.add( + Controls(code: "ordertype", controlValue: '1'), + ); + }); entityList.isNotEmpty ? entityList.forEach((element) {