From 539f7facc78d15b066a491fb4b2b1d73bace120e Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Thu, 4 Feb 2021 17:20:45 +0200 Subject: [PATCH] jira bugs fix --- lib/core/model/prescription_model.dart | 10 +- .../prescription/add_prescription_form.dart | 83 +++++++---- .../prescription/prescription_screen.dart | 66 ++++++--- .../update_prescription_form.dart | 133 ++++++++++++++---- 4 files changed, 218 insertions(+), 74 deletions(-) diff --git a/lib/core/model/prescription_model.dart b/lib/core/model/prescription_model.dart index 9fcf3050..49001673 100644 --- a/lib/core/model/prescription_model.dart +++ b/lib/core/model/prescription_model.dart @@ -57,6 +57,8 @@ class EntityList { dynamic status; dynamic stopDate; dynamic uom; + dynamic pharmacistRemarks; + dynamic refill; EntityList( {this.appointmentNo, @@ -87,7 +89,9 @@ class EntityList { this.startDate, this.status, this.stopDate, - this.uom}); + this.uom, + this.pharmacistRemarks, + this.refill}); EntityList.fromJson(Map json) { appointmentNo = json['appointmentNo']; @@ -119,6 +123,8 @@ class EntityList { status = json['status']; stopDate = json['stopDate']; uom = json['uom']; + pharmacistRemarks = json['pharmacistRemarks']; + refill = json['refill']; } Map toJson() { @@ -152,6 +158,8 @@ class EntityList { data['status'] = this.status; data['stopDate'] = this.stopDate; data['uom'] = this.uom; + data['pharmacistRemarks'] = this.pharmacistRemarks; + data['refill'] = this.refill; return data; } } diff --git a/lib/screens/prescription/add_prescription_form.dart b/lib/screens/prescription/add_prescription_form.dart index b079a661..80d77f3e 100644 --- a/lib/screens/prescription/add_prescription_form.dart +++ b/lib/screens/prescription/add_prescription_form.dart @@ -48,6 +48,7 @@ postProcedure( PrescriptionViewModel model, DateTime doseTime, String doseUnit, + String icdCode, PatiantInformtion patient}) async { PostPrescriptionReqModel postProcedureReqModel = new PostPrescriptionReqModel(); @@ -67,7 +68,7 @@ postProcedure( frequency: frequency.isEmpty ? 1 : int.parse(frequency), remarks: instruction, approvalRequired: true, - icdcode10Id: "test2", + icdcode10Id: icdCode.toString(), doseTime: doseTimeIn.isEmpty ? 1 : int.parse(doseTimeIn), duration: duration.isEmpty ? 1 : int.parse(duration), doseStartDate: doseTime.toIso8601String())); @@ -127,6 +128,7 @@ class _PrescriptionFormWidgetState extends State { dynamic doseTime; dynamic indication; dynamic units; + dynamic x; List indicationList; String routeInatial = 'By Mouth'; @@ -176,11 +178,15 @@ class _PrescriptionFormWidgetState extends State { Widget build(BuildContext context) { ListSelectDialog drugDialog; final screenSize = MediaQuery.of(context).size; + // final routeArgs = ModalRoute.of(context).settings.arguments as Map; // patient = routeArgs['patient']; return BaseView( onModelReady: (model) async { + x = model.patientAssessmentList.map((element) { + return element.icdCode10ID; + }); GetAssessmentReqModel getAssessmentReqModel = GetAssessmentReqModel( patientMRN: widget.patient.patientMRN, episodeID: widget.patient.episodeNo.toString(), @@ -193,7 +199,7 @@ class _PrescriptionFormWidgetState extends State { await model.getMedicationRoute(); await model.getMedicationFrequency(); await model.getMedicationDoseTime(); - await model.getMedicationIndications(); + //await model.getMedicationIndications(); await model.getPatientAssessment(getAssessmentReqModel); }, builder: ( @@ -210,7 +216,7 @@ class _PrescriptionFormWidgetState extends State { builder: (BuildContext context, ScrollController scrollController) { return SingleChildScrollView( child: Container( - height: 980, + height: 1010, child: Padding( padding: EdgeInsets.symmetric(horizontal: 12.0, vertical: 10.0), @@ -691,7 +697,6 @@ class _PrescriptionFormWidgetState extends State { // openDrugToDrug(); if (route == null || frequency == null || - indication == null || doseTime == null || duration == null || selectedDate == null || @@ -704,30 +709,54 @@ class _PrescriptionFormWidgetState extends State { if (formKey.currentState.validate()) { Navigator.pop(context); { + // var x = model + // .patientAssessmentList + // .map((value) => + // value.icdCode10ID) + // .toList() + // .join(','); postProcedure( - dose: strengthController.text, - doseUnit: - units['id'].toString(), - patient: widget.patient, - doseTimeIn: - doseTime['id'].toString(), - model: widget.model, - duration: - duration['id'].toString(), - frequency: frequency['id'] - .toString(), - route: route['id'].toString(), - drugId: _selectedMedication - .itemId - .toString(), - strength: - strengthController.text, - indication: - indicationController.text, - instruction: - instructionController - .text, - doseTime: selectedDate); + icdCode: model + .patientAssessmentList[ + 0] + .icdCode10ID + .isEmpty + ? "test" + : model + .patientAssessmentList[ + 0] + .icdCode10ID + .toString(), + // icdCode: model + // .patientAssessmentList + // .map((value) => value + // .icdCode10ID + // .trim()) + // .toList() + // .join(' '), + dose: strengthController.text, + doseUnit: + units['id'].toString(), + patient: widget.patient, + doseTimeIn: + doseTime['id'].toString(), + model: widget.model, + duration: + duration['id'].toString(), + frequency: + frequency['id'].toString(), + route: route['id'].toString(), + drugId: _selectedMedication + .itemId + .toString(), + strength: + strengthController.text, + indication: + indicationController.text, + instruction: + instructionController.text, + doseTime: selectedDate, + ); } } { diff --git a/lib/screens/prescription/prescription_screen.dart b/lib/screens/prescription/prescription_screen.dart index 1588c4c4..5a212f56 100644 --- a/lib/screens/prescription/prescription_screen.dart +++ b/lib/screens/prescription/prescription_screen.dart @@ -200,7 +200,7 @@ class _NewPrescriptionScreenState extends State { context) .size .height * - 0.24, + 0.33, width: MediaQuery.of( context) .size @@ -239,7 +239,7 @@ class _NewPrescriptionScreenState extends State { context) .size .height * - 0.3499, + 0.3899, width: MediaQuery.of( context) .size @@ -357,6 +357,28 @@ class _NewPrescriptionScreenState extends State { ) ], ), + SizedBox( + height: + 5.0), + Row( + children: [ + AppText( + 'pharmacist Remarks : ', + fontWeight: + FontWeight + .w700, + fontSize: + 17.0, + ), + Expanded( + child: AppText( + model.prescriptionList[0].entityList[index].pharmacistRemarks == null + ? "" + : model.prescriptionList[0].entityList[index].pharmacistRemarks, + fontSize: 15.0), + ) + ], + ), SizedBox( height: 20.0, ), @@ -383,20 +405,23 @@ class _NewPrescriptionScreenState extends State { ) ], ), + SizedBox( + height: 8.0, + ), Row( children: [ Expanded( child: Container( height: - 30, + 25, child: AppText( model.prescriptionList[0].entityList[index].remarks == null ? "" : model.prescriptionList[0].entityList[index].remarks, fontSize: - 11.5, + 12.5, ), ), ), @@ -417,7 +442,7 @@ class _NewPrescriptionScreenState extends State { context) .size .height * - 0.08, + 0.16, width: MediaQuery.of( context) .size @@ -431,32 +456,31 @@ class _NewPrescriptionScreenState extends State { .edit), onTap: () { updatePrescriptionForm( - doseUnit: - model.prescriptionList[0].entityList[index].doseDailyUnitID - .toString(), - doseStreangth: - model.prescriptionList[0].entityList[index].doseDailyQuantity - .toString(), - duration: - model.prescriptionList[0].entityList[index].doseDurationDays - .toString(), - startDate: - model.prescriptionList[0].entityList[index].startDate - .toString(), - dose: model + drugNameGeneric: model .prescriptionList[ 0] .entityList[ index] - .doseTimingID + .medicationName, + doseUnit: model.prescriptionList[0].entityList[index].doseDailyUnitID .toString(), - frequency: model + doseStreangth: model.prescriptionList[0].entityList[index].doseDailyQuantity + .toString(), + duration: model.prescriptionList[0].entityList[index].doseDurationDays + .toString(), + startDate: + model.prescriptionList[0].entityList[index].startDate + .toString(), + dose: model .prescriptionList[ 0] .entityList[ index] - .frequencyID + .doseTimingID .toString(), + frequency: + model.prescriptionList[0].entityList[index].frequencyID + .toString(), rouat: model .prescriptionList[ 0] diff --git a/lib/screens/prescription/update_prescription_form.dart b/lib/screens/prescription/update_prescription_form.dart index 68a7e739..0d6609aa 100644 --- a/lib/screens/prescription/update_prescription_form.dart +++ b/lib/screens/prescription/update_prescription_form.dart @@ -1,6 +1,8 @@ +import 'package:autocomplete_textfield/autocomplete_textfield.dart'; import 'package:doctor_app_flutter/client/base_app_client.dart'; import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; +import 'package:doctor_app_flutter/core/model/get_medication_response_model.dart'; import 'package:doctor_app_flutter/core/model/post_prescrition_req_model.dart'; import 'package:doctor_app_flutter/core/viewModel/medicine_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; @@ -8,6 +10,7 @@ import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/Text.dart'; import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; @@ -31,6 +34,7 @@ class UpdatePrescriptionForm extends StatefulWidget { final String enteredRemarks; final String startDate; final String frequency; + final String drugNameGeneric; final PrescriptionViewModel model; UpdatePrescriptionForm( @@ -46,7 +50,8 @@ class UpdatePrescriptionForm extends StatefulWidget { this.doseUnit, this.enteredRemarks, this.frequency, - this.model}); + this.model, + this.drugNameGeneric}); @override _UpdatePrescriptionFormState createState() => _UpdatePrescriptionFormState(); } @@ -62,6 +67,9 @@ class _UpdatePrescriptionFormState extends State { dynamic frequencyUpdate; dynamic updatedDuration; dynamic units; + GetMedicationResponseModel newSelectedMedication; + GlobalKey key = + new GlobalKey>(); @override void initState() { @@ -80,7 +88,7 @@ class _UpdatePrescriptionFormState extends State { await model.getMedicationRoute(); await model.getMedicationFrequency(); await model.getMedicationDoseTime(); - await model.getMedicationIndications(); + //await model.getMedicationIndications(); route = model.getLookupById(model.medicationRouteList, widget.route); doseTime = model.getLookupById(model.medicationDoseTimeList, widget.dose); @@ -96,13 +104,13 @@ class _UpdatePrescriptionFormState extends State { NetworkBaseView( baseViewModel: model, child: DraggableScrollableSheet( - initialChildSize: 0.90, - maxChildSize: 0.90, + initialChildSize: 0.95, + maxChildSize: 0.99, minChildSize: 0.6, builder: (BuildContext context, ScrollController scrollController) { return Container( - height: MediaQuery.of(context).size.height * 1.0, + height: MediaQuery.of(context).size.height * 1.3, child: Form( child: Padding( padding: EdgeInsets.symmetric( @@ -119,6 +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.060, @@ -428,18 +508,23 @@ 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, @@ -447,25 +532,20 @@ 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, @@ -524,6 +604,7 @@ class _UpdatePrescriptionFormState extends State { updatePrescription( {PrescriptionViewModel model, int drugId, + int newDrugId, String frequencyId, String remarks, String dose, @@ -556,7 +637,7 @@ class _UpdatePrescriptionFormState extends State { ? int.parse(newDoseStreangth) : int.parse(doseStreangth), //frequency.isNotEmpty ? int.parse(dose) : 1, - itemId: drugId, + itemId: newDrugId != 0 ? newDrugId : drugId, doseUnitId: newUnit.isNotEmpty ? int.parse(newUnit) : int.parse(doseUnit), route: route.isNotEmpty ? int.parse(route) : int.parse(routeId), @@ -588,6 +669,7 @@ class _UpdatePrescriptionFormState extends State { void updatePrescriptionForm( {context, String drugName, + String drugNameGeneric, int drugId, String remarks, PrescriptionViewModel model, @@ -622,6 +704,7 @@ void updatePrescriptionForm( route: rouat, startDate: startDate, model: model, + drugNameGeneric: drugNameGeneric, ); }); }