From 9b5899d4e6ffe701f54c5c0371e292da2157061e Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Fri, 29 Jan 2021 19:57:50 +0200 Subject: [PATCH 1/6] bug fix --- lib/screens/prescription/prescription_screen.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/screens/prescription/prescription_screen.dart b/lib/screens/prescription/prescription_screen.dart index 8f53ef69..1f45deb1 100644 --- a/lib/screens/prescription/prescription_screen.dart +++ b/lib/screens/prescription/prescription_screen.dart @@ -1214,8 +1214,8 @@ class _NewPrescriptionScreenState extends State { covered: true, dose: newDoseStreangth.isNotEmpty ? int.parse(newDoseStreangth) - : int.parse( - doseStreangth), //frequency.isNotEmpty ? int.parse(dose) : 1, + : int.parse(doseStreangth), + //frequency.isNotEmpty ? int.parse(dose) : 1, itemId: drugId, doseUnitId: newUnit.isNotEmpty ? int.parse(newUnit) : int.parse(doseUnit), From 29de472c66d3a6d3b27173a3a11527030b49abfb Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Sat, 30 Jan 2021 00:11:57 +0200 Subject: [PATCH 2/6] bug fix --- lib/core/model/medical_file_model.dart | 75 ++++++++++++++++++- .../medical-file/medical_file_details.dart | 30 ++++---- .../prescription/prescription_screen.dart | 9 ++- 3 files changed, 98 insertions(+), 16 deletions(-) diff --git a/lib/core/model/medical_file_model.dart b/lib/core/model/medical_file_model.dart index 4e9d8f3e..f2b4ce3c 100644 --- a/lib/core/model/medical_file_model.dart +++ b/lib/core/model/medical_file_model.dart @@ -169,6 +169,7 @@ class Consulations { List lstPhysicalExam; List lstProcedure; List lstMedicalHistory; + List lstCheifComplaint; Consulations( {this.admissionNo, @@ -194,7 +195,8 @@ class Consulations { this.lstAssessments, this.lstPhysicalExam, this.lstProcedure, - this.lstMedicalHistory}); + this.lstMedicalHistory, + this.lstCheifComplaint}); Consulations.fromJson(Map json) { admissionNo = json['AdmissionNo']; @@ -223,6 +225,12 @@ class Consulations { lstAssessments.add(new LstAssessments.fromJson(v)); }); } + if (json['lstCheifComplaint'] != null) { + lstCheifComplaint = new List(); + json['lstCheifComplaint'].forEach((v) { + lstCheifComplaint.add(new LstCheifComplaint.fromJson(v)); + }); + } if (json['lstPhysicalExam'] != null) { lstPhysicalExam = new List(); json['lstPhysicalExam'].forEach((v) { @@ -269,6 +277,10 @@ class Consulations { data['lstAssessments'] = this.lstAssessments.map((v) => v.toJson()).toList(); } + if (this.lstCheifComplaint != null) { + data['lstCheifComplaint'] = + this.lstCheifComplaint.map((v) => v.toJson()).toList(); + } if (this.lstPhysicalExam != null) { data['lstPhysicalExam'] = this.lstPhysicalExam.map((v) => v.toJson()).toList(); @@ -284,6 +296,67 @@ class Consulations { } } +class LstCheifComplaint { + int appointmentNo; + String cCDate; + String chiefComplaint; + String currentMedication; + int episodeID; + String hOPI; + int patientID; + String patientType; + int projectID; + String projectName; + String setupID; + String dispalyName; + + LstCheifComplaint( + {this.appointmentNo, + this.cCDate, + this.chiefComplaint, + this.currentMedication, + this.episodeID, + this.hOPI, + this.patientID, + this.patientType, + this.projectID, + this.projectName, + this.setupID, + this.dispalyName}); + + LstCheifComplaint.fromJson(Map json) { + appointmentNo = json['AppointmentNo']; + cCDate = json['CCDate']; + chiefComplaint = json['ChiefComplaint']; + currentMedication = json['CurrentMedication']; + episodeID = json['EpisodeID']; + hOPI = json['HOPI']; + patientID = json['PatientID']; + patientType = json['PatientType']; + projectID = json['ProjectID']; + projectName = json['ProjectName']; + setupID = json['SetupID']; + dispalyName = json['dispalyName']; + } + + Map toJson() { + final Map data = new Map(); + data['AppointmentNo'] = this.appointmentNo; + data['CCDate'] = this.cCDate; + data['ChiefComplaint'] = this.chiefComplaint; + data['CurrentMedication'] = this.currentMedication; + data['EpisodeID'] = this.episodeID; + data['HOPI'] = this.hOPI; + data['PatientID'] = this.patientID; + data['PatientType'] = this.patientType; + data['ProjectID'] = this.projectID; + data['ProjectName'] = this.projectName; + data['SetupID'] = this.setupID; + data['dispalyName'] = this.dispalyName; + return data; + } +} + class LstAssessments { int appointmentNo; String condition; diff --git a/lib/screens/medical-file/medical_file_details.dart b/lib/screens/medical-file/medical_file_details.dart index f7525391..a148610b 100644 --- a/lib/screens/medical-file/medical_file_details.dart +++ b/lib/screens/medical-file/medical_file_details.dart @@ -188,16 +188,18 @@ class _MedicalFileDetailsState extends State { .consulations .length != 0) - AppText( - model - .medicalFileList[0] - .entityList[0] - .timelines[encounterNumber] - .timeLineEvents[0] - .consulations[0] - .doctorName - .toUpperCase(), - fontWeight: FontWeight.w700, + Expanded( + child: AppText( + model + .medicalFileList[0] + .entityList[0] + .timelines[encounterNumber] + .timeLineEvents[0] + .consulations[0] + .doctorName + .toUpperCase(), + fontWeight: FontWeight.w700, + ), ), ], ), @@ -315,7 +317,7 @@ class _MedicalFileDetailsState extends State { .timelines[encounterNumber] .timeLineEvents[0] .consulations[0] - .lstMedicalHistory + .lstCheifComplaint .length, itemBuilder: (BuildContext ctxt, int index) { @@ -338,9 +340,9 @@ class _MedicalFileDetailsState extends State { encounterNumber] .timeLineEvents[0] .consulations[0] - .lstMedicalHistory[ + .lstCheifComplaint[ index] - .history + .hOPI .trim(), ), ), @@ -795,7 +797,7 @@ class _MedicalFileDetailsState extends State { .consulations[0] .lstPhysicalExam[ index] - .examType), + .examDesc), ], ), Row( diff --git a/lib/screens/prescription/prescription_screen.dart b/lib/screens/prescription/prescription_screen.dart index 1f45deb1..cef99164 100644 --- a/lib/screens/prescription/prescription_screen.dart +++ b/lib/screens/prescription/prescription_screen.dart @@ -946,7 +946,7 @@ class _NewPrescriptionScreenState extends State { : null, child: TextField( decoration: textFieldSelectorDecoration( - TranslationBase.of(context).route, + 'Route', route != null ? route['name'] : null, @@ -1181,6 +1181,13 @@ class _NewPrescriptionScreenState extends State { }); } + // String getName(String num) { + // dynamic x = routeList.where((i) { + // return i['id'] == int.parse(num); + // }).first(); + // return x.toString(); + // } + updatePrescription( {PrescriptionViewModel model, int drugId, From 23c826b37f3448c804b446e8814b812d0c60d4a1 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Sun, 31 Jan 2021 16:09:28 +0200 Subject: [PATCH 3/6] bug fix --- lib/screens/prescription/prescription_screen.dart | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/screens/prescription/prescription_screen.dart b/lib/screens/prescription/prescription_screen.dart index cef99164..238a3812 100644 --- a/lib/screens/prescription/prescription_screen.dart +++ b/lib/screens/prescription/prescription_screen.dart @@ -559,6 +559,14 @@ class _NewPrescriptionScreenState extends State { ), Row( children: [ + AppText( + TranslationBase.of(context) + .doctorName + + ": ", + fontWeight: + FontWeight + .w600, + ), Expanded( child: AppText( From d66811546f18f3a36ca8a55a124cc22d6db4a0fb Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Sun, 31 Jan 2021 20:37:37 +0200 Subject: [PATCH 4/6] refactoring my code --- .../prescription/prescription_screen.dart | 722 +---------------- .../update_prescription_form.dart | 746 ++++++++++++++++++ lib/screens/procedures/procedure_screen.dart | 17 - 3 files changed, 747 insertions(+), 738 deletions(-) create mode 100644 lib/screens/prescription/update_prescription_form.dart diff --git a/lib/screens/prescription/prescription_screen.dart b/lib/screens/prescription/prescription_screen.dart index 238a3812..290aadca 100644 --- a/lib/screens/prescription/prescription_screen.dart +++ b/lib/screens/prescription/prescription_screen.dart @@ -1,30 +1,15 @@ -import 'package:doctor_app_flutter/client/base_app_client.dart'; -import 'package:doctor_app_flutter/config/config.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/post_prescrition_req_model.dart'; import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; -import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; 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/screens/prescription/add_prescription_form.dart'; -import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; +import 'package:doctor_app_flutter/screens/prescription/update_prescription_form.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/patient-page-header-widget.dart'; -import 'package:doctor_app_flutter/widgets/patients/profile/patient_profile_widget.dart'; -import 'package:doctor_app_flutter/widgets/patients/profile/profile_medical_info_widget.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_scaffold_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/app_text_form_field.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/dialogs/dailog-list-select.dart'; import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:hexcolor/hexcolor.dart'; class NewPrescriptionScreen extends StatefulWidget { @override @@ -38,198 +23,10 @@ class _NewPrescriptionScreenState extends State { int testNum = 0; int strengthChar; PatiantInformtion patient; - dynamic route; - dynamic doseTime; - dynamic frequencyUpdate; - dynamic updatedDuration; - dynamic units; - - List doseTimeList; - List routeList; - List frequencyList; - List durationList; - List unitsList; @override void initState() { super.initState(); - routeList = List(); - doseTimeList = List(); - frequencyList = List(); - durationList = List(); - unitsList = List(); - - dynamic unit1 = {"id": 1, "name": "MG"}; - dynamic unit2 = {"id": 2, "name": "MCG"}; - dynamic unit3 = {"id": 3, "name": "GM"}; - dynamic frequency1 = {"id": 2, "name": "2 Times a day"}; - dynamic frequency2 = {"id": 3, "name": "3 Times a day"}; - dynamic frequency3 = {"id": 4, "name": "4 Times a day"}; - dynamic frequency4 = {"id": 8, "name": "As Needed"}; - dynamic frequency5 = {"id": 9, "name": "Bed Time"}; - dynamic frequency6 = {"id": 11, "name": "Every Other Day"}; - dynamic frequency7 = {"id": 29, "name": "Every Eight Hours"}; - dynamic frequency8 = {"id": 34, "name": "As Directed"}; - dynamic frequency9 = {"id": 22, "name": "Once Per Month"}; - dynamic frequency10 = {"id": 2, "name": "3 Times a day"}; - dynamic frequency11 = {"id": 21, "name": "Every 3 hours"}; - dynamic frequency12 = {"id": 20, "name": "Once a Week"}; - dynamic frequency13 = {"id": 12, "name": "Every Half Hour"}; - dynamic frequency14 = {"id": 10, "name": "4 Times a Day"}; - dynamic frequency15 = {"id": 24, "name": "Once Every 2 Months"}; - dynamic frequency16 = {"id": 25, "name": "Every One Hour"}; - dynamic frequency17 = {"id": 26, "name": "Every Two Hours"}; - dynamic frequency18 = {"id": 28, "name": "Every Six Hours"}; - dynamic doseTime1 = {"id": 1, "name": "Before Meals"}; - dynamic doseTime2 = {"id": 2, "name": "After Meals"}; - dynamic doseTime3 = {"id": 3, "name": "With Meals"}; - dynamic doseTime4 = {"id": 4, "name": "In The Morning"}; - dynamic doseTime5 = {"id": 5, "name": "In the Evening"}; - dynamic doseTime6 = {"id": 6, "name": "After Supper"}; - dynamic doseTime7 = {"id": 7, "name": "With Supper"}; - dynamic doseTime8 = {"id": 8, "name": "Before Breakfast"}; - dynamic doseTime9 = {"id": 9, "name": "In the Afternoon"}; - dynamic doseTime10 = {"id": 10, "name": "While wake"}; - dynamic doseTime11 = {"id": 12, "name": "Any Time"}; - dynamic doseTime12 = {"id": 21, "name": "Bed Time"}; - dynamic doseTime13 = {"id": 13, "name": "30 Minutes Before Meals"}; - dynamic doseTime14 = {"id": 14, "name": "1 Hour Before Meals"}; - dynamic doseTime15 = {"id": 15, "name": "2 Hours After Meal"}; - dynamic doseTime16 = {"id": 16, "name": "After Breakfast"}; - dynamic doseTime17 = {"id": 17, "name": "Before Lunch"}; - dynamic doseTime18 = {"id": 18, "name": "After Lunch"}; - dynamic doseTime19 = {"id": 20, "name": "After Dinner"}; - dynamic doseTime20 = {"id": 21, "name": "Bed Time"}; - dynamic doseTime21 = {"id": 11, "name": "Now"}; - dynamic route1 = {"id": 7, "name": "By Mouth"}; - dynamic route2 = {"id": 10, "name": "Inhale by Mouth"}; - dynamic route3 = {"id": 15, "name": "for INJECTION"}; - dynamic route4 = {"id": 17, "name": "Drops"}; - dynamic route5 = {"id": 18, "name": "Rub On"}; - dynamic route6 = {"id": 20, "name": "Spary"}; - dynamic route7 = {"id": 27, "name": "In Both EYES"}; - dynamic route8 = {"id": 28, "name": "In Both Ears"}; - dynamic route9 = {"id": 32, "name": "Intramuscular"}; - dynamic route10 = {"id": 60, "name": "TRANSDERMAL"}; - dynamic route11 = {"id": 59, "name": "OROPHARYNGEAL"}; - dynamic route12 = {"id": 15, "name": "for INJECTION"}; - dynamic route13 = {"id": 58, "name": "SUBCUTANEOUS"}; - dynamic route14 = {"id": 57, "name": "NASOGASTRIC"}; - dynamic route15 = {"id": 56, "name": "IRRIGATION"}; - dynamic route16 = {"id": 55, "name": "INTRAVITREAL"}; - dynamic route17 = {"id": 54, "name": "INTRAVENOUS BOLUS"}; - dynamic route18 = {"id": 51, "name": "EPIDURAL"}; - dynamic route19 = {"id": 47, "name": "Parenteral"}; - dynamic route20 = {"id": 43, "name": "IM"}; - dynamic route21 = {"id": 42, "name": "IV"}; - dynamic route22 = {"id": 41, "name": "Sublingual"}; - dynamic route23 = {"id": 40, "name": "For Nebulization"}; - dynamic route24 = {"id": 39, "name": "Nasal"}; - dynamic route25 = {"id": 37, "name": "Inserted into Vagina"}; - dynamic route26 = {"id": 36, "name": "Inserted into Rectum"}; - dynamic route27 = {"id": 31, "name": "In Each Nostril"}; - dynamic duration1 = {"id": 1, "name": "For 1 Day"}; - dynamic duration2 = {"id": 2, "name": "For 2 Days"}; - dynamic duration3 = {"id": 3, "name": "For 3 Days"}; - dynamic duration4 = {"id": 4, "name": "For 4 Days"}; - dynamic duration5 = {"id": 5, "name": "For 5 Days"}; - dynamic duration6 = {"id": 6, "name": "For 6 Days"}; - dynamic duration7 = {"id": 7, "name": "For 7 Days"}; - dynamic duration8 = {"id": 8, "name": "For 8 Days"}; - dynamic duration9 = {"id": 9, "name": "For 9 Days"}; - dynamic duration10 = {"id": 10, "name": "For 10 Days"}; - dynamic duration11 = {"id": 14, "name": "For 14 Days"}; - dynamic duration12 = {"id": 21, "name": "For 21 Days"}; - dynamic duration13 = {"id": 30, "name": "For 30 Days"}; - dynamic duration14 = {"id": 45, "name": "For 45 Days"}; - dynamic duration15 = {"id": 60, "name": "For 60 Days"}; - dynamic duration16 = {"id": 90, "name": "For 90 Days"}; - - durationList.add(duration1); - durationList.add(duration2); - durationList.add(duration3); - durationList.add(duration4); - durationList.add(duration5); - durationList.add(duration6); - durationList.add(duration7); - durationList.add(duration8); - durationList.add(duration9); - durationList.add(duration10); - durationList.add(duration11); - durationList.add(duration12); - durationList.add(duration13); - durationList.add(duration14); - durationList.add(duration15); - durationList.add(duration16); - frequencyList.add(frequency1); - frequencyList.add(frequency2); - frequencyList.add(frequency3); - frequencyList.add(frequency4); - frequencyList.add(frequency5); - frequencyList.add(frequency6); - frequencyList.add(frequency7); - frequencyList.add(frequency8); - frequencyList.add(frequency9); - frequencyList.add(frequency10); - frequencyList.add(frequency11); - frequencyList.add(frequency12); - frequencyList.add(frequency13); - frequencyList.add(frequency14); - frequencyList.add(frequency15); - frequencyList.add(frequency16); - frequencyList.add(frequency17); - frequencyList.add(frequency18); - doseTimeList.add(doseTime1); - doseTimeList.add(doseTime2); - doseTimeList.add(doseTime3); - doseTimeList.add(doseTime4); - doseTimeList.add(doseTime5); - doseTimeList.add(doseTime6); - doseTimeList.add(doseTime7); - doseTimeList.add(doseTime8); - doseTimeList.add(doseTime9); - doseTimeList.add(doseTime10); - doseTimeList.add(doseTime11); - doseTimeList.add(doseTime12); - doseTimeList.add(doseTime13); - doseTimeList.add(doseTime14); - doseTimeList.add(doseTime15); - doseTimeList.add(doseTime16); - doseTimeList.add(doseTime17); - doseTimeList.add(doseTime18); - doseTimeList.add(doseTime19); - doseTimeList.add(doseTime20); - doseTimeList.add(doseTime21); - routeList.add(route1); - routeList.add(route2); - routeList.add(route3); - routeList.add(route4); - routeList.add(route5); - routeList.add(route6); - routeList.add(route7); - routeList.add(route8); - routeList.add(route9); - routeList.add(route10); - routeList.add(route11); - routeList.add(route12); - routeList.add(route13); - routeList.add(route14); - routeList.add(route15); - routeList.add(route16); - routeList.add(route17); - routeList.add(route18); - routeList.add(route19); - routeList.add(route20); - routeList.add(route21); - routeList.add(route22); - routeList.add(route23); - routeList.add(route24); - routeList.add(route25); - routeList.add(route26); - routeList.add(route27); - unitsList.add(unit1); - unitsList.add(unit2); - unitsList.add(unit3); } Widget build(BuildContext context) { @@ -773,521 +570,4 @@ class _NewPrescriptionScreenState extends State { }); } } - - void updatePrescriptionForm( - {context, - String drugName, - int drugId, - String remarks, - PrescriptionViewModel model, - PatiantInformtion patient, - String rouat, - String frequency, - String dose, - String duration, - String doseStreangth, - String doseUnit, - String enteredRemarks, - String startDate}) { - TextEditingController remarksController = TextEditingController(); - TextEditingController doseController = TextEditingController(); - TextEditingController frequencyController = TextEditingController(); - TextEditingController routeController = TextEditingController(); - showModalBottomSheet( - context: context, - isScrollControlled: true, - builder: (BuildContext context) { - return StatefulBuilder(builder: (BuildContext context, - StateSetter setState /*You can rename this!*/) { - return DraggableScrollableSheet( - initialChildSize: 0.90, - maxChildSize: 0.90, - minChildSize: 0.6, - builder: - (BuildContext context, ScrollController scrollController) { - return Container( - height: MediaQuery.of(context).size.height * 1.0, - child: Form( - child: Padding( - padding: EdgeInsets.symmetric( - horizontal: 20.0, vertical: 12.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - drugName.toUpperCase(), - fontWeight: FontWeight.w900, - ), - SizedBox( - height: 10.0, - ), - Column( - children: [ - Container( - height: MediaQuery.of(context).size.height * - 0.060, - width: double.infinity, - child: Row( - children: [ - Container( - width: MediaQuery.of(context) - .size - .width * - 0.500, - child: TextFields( - inputFormatters: [ - LengthLimitingTextInputFormatter( - 4) - ], - hintText: - TranslationBase.of(context) - .strength, - controller: strengthController, - keyboardType: TextInputType.number, - onChanged: (String value) { - setState(() { - strengthChar = value.length; - }); - if (strengthChar >= 4) { - DrAppToastMsg.showErrorToast( - "Only 4 Digits allowed for strength"); - } - }, - // validator: (value) { - // if (value.isEmpty && - // strengthController.text.length > - // 4) - // return TranslationBase.of(context) - // .emptyMessage; - // else - // return null; - // }, - ), - ), - SizedBox( - width: 10.0, - ), - Container( - width: MediaQuery.of(context) - .size - .width * - 0.3700, - child: InkWell( - onTap: unitsList != null - ? () { - ListSelectDialog dialog = - ListSelectDialog( - list: unitsList, - attributeName: 'name', - attributeValueId: 'id', - okText: - TranslationBase.of( - context) - .ok, - okFunction: - (selectedValue) { - setState(() { - units = selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext - context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: - textFieldSelectorDecoration( - 'UNIT Type', - units != null - ? units['name'] - : null, - true), - enabled: false, - ), - ), - ), - ], - ), - ), - SizedBox( - height: 12, - ), - Container( - height: MediaQuery.of(context).size.height * - 0.070, - child: InkWell( - onTap: routeList != null - ? () { - ListSelectDialog dialog = - ListSelectDialog( - list: routeList, - attributeName: 'name', - attributeValueId: 'id', - okText: - TranslationBase.of(context) - .ok, - okFunction: (selectedValue) { - setState(() { - route = selectedValue; - }); - if (route == null) { - route = route['id']; - } - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: - (BuildContext context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: textFieldSelectorDecoration( - 'Route', - route != null - ? route['name'] - : null, - true), - enabled: false, - ), - ), - ), - SizedBox( - height: 12.0, - ), - Container( - height: MediaQuery.of(context).size.height * - 0.070, - child: InkWell( - onTap: doseTimeList != null - ? () { - ListSelectDialog dialog = - ListSelectDialog( - list: doseTimeList, - attributeName: 'name', - attributeValueId: 'id', - okText: - TranslationBase.of(context) - .ok, - okFunction: (selectedValue) { - setState(() { - doseTime = selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: - (BuildContext context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: textFieldSelectorDecoration( - TranslationBase.of(context) - .doseTime, - doseTime != null - ? doseTime['name'] - : null, - true), - enabled: false, - ), - ), - ), - SizedBox( - height: 12.0, - ), - Container( - height: MediaQuery.of(context).size.height * - 0.070, - child: InkWell( - onTap: frequencyList != null - ? () { - ListSelectDialog dialog = - ListSelectDialog( - list: frequencyList, - attributeName: 'name', - attributeValueId: 'id', - okText: - TranslationBase.of(context) - .ok, - okFunction: (selectedValue) { - setState(() { - frequencyUpdate = - selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: - (BuildContext context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: textFieldSelectorDecoration( - TranslationBase.of(context) - .frequency, - frequencyUpdate != null - ? frequencyUpdate['name'] - : null, - true), - enabled: false, - ), - ), - ), - SizedBox( - height: 12.0, - ), - Container( - height: MediaQuery.of(context).size.height * - 0.070, - child: InkWell( - onTap: durationList != null - ? () { - ListSelectDialog dialog = - ListSelectDialog( - list: durationList, - attributeName: 'name', - attributeValueId: 'id', - okText: - TranslationBase.of(context) - .ok, - okFunction: (selectedValue) { - setState(() { - updatedDuration = - selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: - (BuildContext context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: textFieldSelectorDecoration( - TranslationBase.of(context) - .duration, - updatedDuration != null - ? updatedDuration['name'] - .toString() - : null, - true), - enabled: false, - ), - ), - ), - SizedBox( - height: 12.0, - ), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: HexColor("#CCCCCC"))), - child: TextFields( - hintText: remarks, - controller: remarksController, - maxLines: 7, - minLines: 4, - ), - ), - SizedBox( - height: 12.0, - ), - SizedBox( - height: MediaQuery.of(context).size.height * - 0.12, - ), - Container( - margin: EdgeInsets.all( - SizeConfig.widthMultiplier * 2), - child: Wrap( - alignment: WrapAlignment.center, - children: [ - AppButton( - title: 'update prescription' - .toUpperCase(), - onPressed: () { - updatePrescription( - newDoseStreangth: - strengthController - .text.isNotEmpty - ? strengthController - .text - : doseStreangth, - newUnit: units != null - ? units['id'].toString() - : doseUnit, - doseUnit: doseUnit, - doseStreangth: doseStreangth, - duration: duration, - startDate: startDate, - doseId: dose, - frequencyId: frequency, - routeId: rouat, - patient: patient, - model: model, - newDuration: updatedDuration != - null - ? updatedDuration['id'] - .toString() - : duration, - drugId: drugId, - remarks: remarksController.text, - route: route != null - ? route['id'].toString() - : rouat, - frequency: frequencyUpdate != null - ? frequencyUpdate['id'] - .toString() - : frequency, - dose: doseTime != null - ? doseTime['id'].toString() - : dose, - enteredRemarks: enteredRemarks); - Navigator.pop(context); - }, - ), - ], - ), - ), - ], - ), - ], - ), - ), - )); - }); - }); - }); - } - - // String getName(String num) { - // dynamic x = routeList.where((i) { - // return i['id'] == int.parse(num); - // }).first(); - // return x.toString(); - // } - - updatePrescription( - {PrescriptionViewModel model, - int drugId, - String frequencyId, - String remarks, - String dose, - String doseId, - String frequency, - String route, - String routeId, - String startDate, - String doseUnit, - String doseStreangth, - String newDoseStreangth, - String duration, - String newDuration, - String newUnit, - String enteredRemarks, - PatiantInformtion patient}) async { - //PrescriptionViewModel model = PrescriptionViewModel(); - PostPrescriptionReqModel updatePrescriptionReqModel = - new PostPrescriptionReqModel(); - List sss = List(); - - updatePrescriptionReqModel.appointmentNo = patient.appointmentNo; - updatePrescriptionReqModel.clinicID = patient.clinicId; - updatePrescriptionReqModel.episodeID = patient.episodeNo; - updatePrescriptionReqModel.patientMRN = patient.patientMRN; - - sss.add(PrescriptionRequestModel( - covered: true, - dose: newDoseStreangth.isNotEmpty - ? int.parse(newDoseStreangth) - : int.parse(doseStreangth), - //frequency.isNotEmpty ? int.parse(dose) : 1, - itemId: drugId, - doseUnitId: - newUnit.isNotEmpty ? int.parse(newUnit) : int.parse(doseUnit), - route: route.isNotEmpty ? int.parse(route) : int.parse(routeId), - frequency: frequency.isNotEmpty - ? int.parse(frequency) - : int.parse(frequencyId), - remarks: remarks.isEmpty ? enteredRemarks : remarks, - approvalRequired: true, - icdcode10Id: "test2", - doseTime: dose.isNotEmpty ? int.parse(dose) : int.parse(doseId), - duration: newDuration.isNotEmpty - ? int.parse(newDuration) - : int.parse(duration), - doseStartDate: startDate)); - updatePrescriptionReqModel.prescriptionRequestModel = sss; - //postProcedureReqModel.procedures = controlsProcedure; - - await model.updatePrescription( - updatePrescriptionReqModel, patient.patientMRN); - - if (model.state == ViewState.ErrorLocal) { - helpers.showErrorToast(model.error); - } else if (model.state == ViewState.Idle) { - DrAppToastMsg.showSuccesToast('Medication has been updated'); - } - } - - InputDecoration textFieldSelectorDecoration( - String hintText, String selectedText, bool isDropDown, - {Icon suffixIcon}) { - return InputDecoration( - focusedBorder: OutlineInputBorder( - borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), - borderRadius: BorderRadius.circular(8), - ), - enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), - borderRadius: BorderRadius.circular(8), - ), - disabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), - borderRadius: BorderRadius.circular(8), - ), - hintText: selectedText != null ? selectedText : hintText, - suffixIcon: isDropDown - ? suffixIcon != null - ? suffixIcon - : Icon( - Icons.arrow_drop_down, - color: Colors.black, - ) - : null, - hintStyle: TextStyle( - fontSize: 14, - color: Colors.grey.shade600, - ), - ); - } } diff --git a/lib/screens/prescription/update_prescription_form.dart b/lib/screens/prescription/update_prescription_form.dart new file mode 100644 index 00000000..01986813 --- /dev/null +++ b/lib/screens/prescription/update_prescription_form.dart @@ -0,0 +1,746 @@ +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/post_prescrition_req_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; +import 'package:doctor_app_flutter/models/patient/patiant_info_model.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/TextFields.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/dialogs/dailog-list-select.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:hexcolor/hexcolor.dart'; + +class UpdatePrescriptionForm extends StatefulWidget { + final String drugName; + final String doseStreangth; + final int drugId; + final String remarks; + final PatiantInformtion patient; + final String duration; + final String route; + final String dose; + final String doseUnit; + final String enteredRemarks; + final String startDate; + final String frequency; + final PrescriptionViewModel model; + + UpdatePrescriptionForm( + {this.drugName, + this.doseStreangth, + this.drugId, + this.remarks, + this.patient, + this.duration, + this.route, + this.dose, + this.startDate, + this.doseUnit, + this.enteredRemarks, + this.frequency, + this.model}); + @override + _UpdatePrescriptionFormState createState() => _UpdatePrescriptionFormState(); +} + +class _UpdatePrescriptionFormState extends State { + TextEditingController strengthController = TextEditingController(); + TextEditingController remarksController = TextEditingController(); + int testNum = 0; + int strengthChar; + PatiantInformtion patient; + dynamic route; + dynamic doseTime; + dynamic frequencyUpdate; + dynamic updatedDuration; + dynamic units; + + List doseTimeList; + List routeList; + List frequencyList; + List durationList; + List unitsList; + + @override + void initState() { + super.initState(); + routeList = List(); + doseTimeList = List(); + frequencyList = List(); + durationList = List(); + unitsList = List(); + + dynamic unit1 = {"id": 1, "name": "MG"}; + dynamic unit2 = {"id": 2, "name": "MCG"}; + dynamic unit3 = {"id": 3, "name": "GM"}; + dynamic frequency1 = {"id": 2, "name": "2 Times a day"}; + dynamic frequency2 = {"id": 3, "name": "3 Times a day"}; + dynamic frequency3 = {"id": 4, "name": "4 Times a day"}; + dynamic frequency4 = {"id": 8, "name": "As Needed"}; + dynamic frequency5 = {"id": 9, "name": "Bed Time"}; + dynamic frequency6 = {"id": 11, "name": "Every Other Day"}; + dynamic frequency7 = {"id": 29, "name": "Every Eight Hours"}; + dynamic frequency8 = {"id": 34, "name": "As Directed"}; + dynamic frequency9 = {"id": 22, "name": "Once Per Month"}; + dynamic frequency10 = {"id": 2, "name": "3 Times a day"}; + dynamic frequency11 = {"id": 21, "name": "Every 3 hours"}; + dynamic frequency12 = {"id": 20, "name": "Once a Week"}; + dynamic frequency13 = {"id": 12, "name": "Every Half Hour"}; + dynamic frequency14 = {"id": 10, "name": "4 Times a Day"}; + dynamic frequency15 = {"id": 24, "name": "Once Every 2 Months"}; + dynamic frequency16 = {"id": 25, "name": "Every One Hour"}; + dynamic frequency17 = {"id": 26, "name": "Every Two Hours"}; + dynamic frequency18 = {"id": 28, "name": "Every Six Hours"}; + dynamic doseTime1 = {"id": 1, "name": "Before Meals"}; + dynamic doseTime2 = {"id": 2, "name": "After Meals"}; + dynamic doseTime3 = {"id": 3, "name": "With Meals"}; + dynamic doseTime4 = {"id": 4, "name": "In The Morning"}; + dynamic doseTime5 = {"id": 5, "name": "In the Evening"}; + dynamic doseTime6 = {"id": 6, "name": "After Supper"}; + dynamic doseTime7 = {"id": 7, "name": "With Supper"}; + dynamic doseTime8 = {"id": 8, "name": "Before Breakfast"}; + dynamic doseTime9 = {"id": 9, "name": "In the Afternoon"}; + dynamic doseTime10 = {"id": 10, "name": "While wake"}; + dynamic doseTime11 = {"id": 12, "name": "Any Time"}; + dynamic doseTime12 = {"id": 21, "name": "Bed Time"}; + dynamic doseTime13 = {"id": 13, "name": "30 Minutes Before Meals"}; + dynamic doseTime14 = {"id": 14, "name": "1 Hour Before Meals"}; + dynamic doseTime15 = {"id": 15, "name": "2 Hours After Meal"}; + dynamic doseTime16 = {"id": 16, "name": "After Breakfast"}; + dynamic doseTime17 = {"id": 17, "name": "Before Lunch"}; + dynamic doseTime18 = {"id": 18, "name": "After Lunch"}; + dynamic doseTime19 = {"id": 20, "name": "After Dinner"}; + dynamic doseTime20 = {"id": 21, "name": "Bed Time"}; + dynamic doseTime21 = {"id": 11, "name": "Now"}; + dynamic route1 = {"id": 7, "name": "By Mouth"}; + dynamic route2 = {"id": 10, "name": "Inhale by Mouth"}; + dynamic route3 = {"id": 15, "name": "for INJECTION"}; + dynamic route4 = {"id": 17, "name": "Drops"}; + dynamic route5 = {"id": 18, "name": "Rub On"}; + dynamic route6 = {"id": 20, "name": "Spary"}; + dynamic route7 = {"id": 27, "name": "In Both EYES"}; + dynamic route8 = {"id": 28, "name": "In Both Ears"}; + dynamic route9 = {"id": 32, "name": "Intramuscular"}; + dynamic route10 = {"id": 60, "name": "TRANSDERMAL"}; + dynamic route11 = {"id": 59, "name": "OROPHARYNGEAL"}; + dynamic route12 = {"id": 15, "name": "for INJECTION"}; + dynamic route13 = {"id": 58, "name": "SUBCUTANEOUS"}; + dynamic route14 = {"id": 57, "name": "NASOGASTRIC"}; + dynamic route15 = {"id": 56, "name": "IRRIGATION"}; + dynamic route16 = {"id": 55, "name": "INTRAVITREAL"}; + dynamic route17 = {"id": 54, "name": "INTRAVENOUS BOLUS"}; + dynamic route18 = {"id": 51, "name": "EPIDURAL"}; + dynamic route19 = {"id": 47, "name": "Parenteral"}; + dynamic route20 = {"id": 43, "name": "IM"}; + dynamic route21 = {"id": 42, "name": "IV"}; + dynamic route22 = {"id": 41, "name": "Sublingual"}; + dynamic route23 = {"id": 40, "name": "For Nebulization"}; + dynamic route24 = {"id": 39, "name": "Nasal"}; + dynamic route25 = {"id": 37, "name": "Inserted into Vagina"}; + dynamic route26 = {"id": 36, "name": "Inserted into Rectum"}; + dynamic route27 = {"id": 31, "name": "In Each Nostril"}; + dynamic duration1 = {"id": 1, "name": "For 1 Day"}; + dynamic duration2 = {"id": 2, "name": "For 2 Days"}; + dynamic duration3 = {"id": 3, "name": "For 3 Days"}; + dynamic duration4 = {"id": 4, "name": "For 4 Days"}; + dynamic duration5 = {"id": 5, "name": "For 5 Days"}; + dynamic duration6 = {"id": 6, "name": "For 6 Days"}; + dynamic duration7 = {"id": 7, "name": "For 7 Days"}; + dynamic duration8 = {"id": 8, "name": "For 8 Days"}; + dynamic duration9 = {"id": 9, "name": "For 9 Days"}; + dynamic duration10 = {"id": 10, "name": "For 10 Days"}; + dynamic duration11 = {"id": 14, "name": "For 14 Days"}; + dynamic duration12 = {"id": 21, "name": "For 21 Days"}; + dynamic duration13 = {"id": 30, "name": "For 30 Days"}; + dynamic duration14 = {"id": 45, "name": "For 45 Days"}; + dynamic duration15 = {"id": 60, "name": "For 60 Days"}; + dynamic duration16 = {"id": 90, "name": "For 90 Days"}; + + durationList.add(duration1); + durationList.add(duration2); + durationList.add(duration3); + durationList.add(duration4); + durationList.add(duration5); + durationList.add(duration6); + durationList.add(duration7); + durationList.add(duration8); + durationList.add(duration9); + durationList.add(duration10); + durationList.add(duration11); + durationList.add(duration12); + durationList.add(duration13); + durationList.add(duration14); + durationList.add(duration15); + durationList.add(duration16); + frequencyList.add(frequency1); + frequencyList.add(frequency2); + frequencyList.add(frequency3); + frequencyList.add(frequency4); + frequencyList.add(frequency5); + frequencyList.add(frequency6); + frequencyList.add(frequency7); + frequencyList.add(frequency8); + frequencyList.add(frequency9); + frequencyList.add(frequency10); + frequencyList.add(frequency11); + frequencyList.add(frequency12); + frequencyList.add(frequency13); + frequencyList.add(frequency14); + frequencyList.add(frequency15); + frequencyList.add(frequency16); + frequencyList.add(frequency17); + frequencyList.add(frequency18); + doseTimeList.add(doseTime1); + doseTimeList.add(doseTime2); + doseTimeList.add(doseTime3); + doseTimeList.add(doseTime4); + doseTimeList.add(doseTime5); + doseTimeList.add(doseTime6); + doseTimeList.add(doseTime7); + doseTimeList.add(doseTime8); + doseTimeList.add(doseTime9); + doseTimeList.add(doseTime10); + doseTimeList.add(doseTime11); + doseTimeList.add(doseTime12); + doseTimeList.add(doseTime13); + doseTimeList.add(doseTime14); + doseTimeList.add(doseTime15); + doseTimeList.add(doseTime16); + doseTimeList.add(doseTime17); + doseTimeList.add(doseTime18); + doseTimeList.add(doseTime19); + doseTimeList.add(doseTime20); + doseTimeList.add(doseTime21); + routeList.add(route1); + routeList.add(route2); + routeList.add(route3); + routeList.add(route4); + routeList.add(route5); + routeList.add(route6); + routeList.add(route7); + routeList.add(route8); + routeList.add(route9); + routeList.add(route10); + routeList.add(route11); + routeList.add(route12); + routeList.add(route13); + routeList.add(route14); + routeList.add(route15); + routeList.add(route16); + routeList.add(route17); + routeList.add(route18); + routeList.add(route19); + routeList.add(route20); + routeList.add(route21); + routeList.add(route22); + routeList.add(route23); + routeList.add(route24); + routeList.add(route25); + routeList.add(route26); + routeList.add(route27); + unitsList.add(unit1); + unitsList.add(unit2); + unitsList.add(unit3); + } + + @override + Widget build(BuildContext context) { + return StatefulBuilder(builder: + (BuildContext context, StateSetter setState /*You can rename this!*/) { + return DraggableScrollableSheet( + initialChildSize: 0.90, + maxChildSize: 0.90, + minChildSize: 0.6, + builder: (BuildContext context, ScrollController scrollController) { + return Container( + height: MediaQuery.of(context).size.height * 1.0, + child: Form( + child: Padding( + padding: + EdgeInsets.symmetric(horizontal: 20.0, vertical: 12.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + widget.drugName.toUpperCase(), + fontWeight: FontWeight.w900, + ), + SizedBox( + height: 10.0, + ), + Column( + children: [ + Container( + height: + MediaQuery.of(context).size.height * 0.060, + width: double.infinity, + child: Row( + children: [ + Container( + width: MediaQuery.of(context).size.width * + 0.500, + child: TextFields( + inputFormatters: [ + LengthLimitingTextInputFormatter(4) + ], + hintText: + TranslationBase.of(context).strength, + controller: strengthController, + keyboardType: TextInputType.number, + onChanged: (String value) { + setState(() { + strengthChar = value.length; + }); + if (strengthChar >= 4) { + DrAppToastMsg.showErrorToast( + "Only 4 Digits allowed for strength"); + } + }, + // validator: (value) { + // if (value.isEmpty && + // strengthController.text.length > + // 4) + // return TranslationBase.of(context) + // .emptyMessage; + // else + // return null; + // }, + ), + ), + SizedBox( + width: 10.0, + ), + Container( + width: MediaQuery.of(context).size.width * + 0.3700, + child: InkWell( + onTap: unitsList != null + ? () { + ListSelectDialog dialog = + ListSelectDialog( + list: unitsList, + attributeName: 'name', + attributeValueId: 'id', + okText: + TranslationBase.of(context) + .ok, + okFunction: (selectedValue) { + setState(() { + units = selectedValue; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: + (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: TextField( + decoration: textFieldSelectorDecoration( + 'UNIT Type', + units != null + ? units['name'] + : null, + true), + enabled: false, + ), + ), + ), + ], + ), + ), + SizedBox( + height: 12, + ), + Container( + height: + MediaQuery.of(context).size.height * 0.070, + child: InkWell( + onTap: routeList != null + ? () { + ListSelectDialog dialog = + ListSelectDialog( + list: routeList, + attributeName: 'name', + attributeValueId: 'id', + okText: + TranslationBase.of(context).ok, + okFunction: (selectedValue) { + setState(() { + route = selectedValue; + }); + if (route == null) { + route = route['id']; + } + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: TextField( + decoration: textFieldSelectorDecoration( + 'Route', + route != null ? route['name'] : null, + true), + enabled: false, + ), + ), + ), + SizedBox( + height: 12.0, + ), + Container( + height: + MediaQuery.of(context).size.height * 0.070, + child: InkWell( + onTap: doseTimeList != null + ? () { + ListSelectDialog dialog = + ListSelectDialog( + list: doseTimeList, + attributeName: 'name', + attributeValueId: 'id', + okText: + TranslationBase.of(context).ok, + okFunction: (selectedValue) { + setState(() { + doseTime = selectedValue; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: TextField( + decoration: textFieldSelectorDecoration( + TranslationBase.of(context).doseTime, + doseTime != null + ? doseTime['name'] + : null, + true), + enabled: false, + ), + ), + ), + SizedBox( + height: 12.0, + ), + Container( + height: + MediaQuery.of(context).size.height * 0.070, + child: InkWell( + onTap: frequencyList != null + ? () { + ListSelectDialog dialog = + ListSelectDialog( + list: frequencyList, + attributeName: 'name', + attributeValueId: 'id', + okText: + TranslationBase.of(context).ok, + okFunction: (selectedValue) { + setState(() { + frequencyUpdate = selectedValue; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: TextField( + decoration: textFieldSelectorDecoration( + TranslationBase.of(context).frequency, + frequencyUpdate != null + ? frequencyUpdate['name'] + : null, + true), + enabled: false, + ), + ), + ), + SizedBox( + height: 12.0, + ), + Container( + height: + MediaQuery.of(context).size.height * 0.070, + child: InkWell( + onTap: durationList != null + ? () { + ListSelectDialog dialog = + ListSelectDialog( + list: durationList, + attributeName: 'name', + attributeValueId: 'id', + okText: + TranslationBase.of(context).ok, + okFunction: (selectedValue) { + setState(() { + updatedDuration = selectedValue; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: TextField( + decoration: textFieldSelectorDecoration( + TranslationBase.of(context).duration, + updatedDuration != null + ? updatedDuration['name'].toString() + : null, + true), + enabled: false, + ), + ), + ), + SizedBox( + height: 12.0, + ), + Container( + decoration: BoxDecoration( + borderRadius: + BorderRadius.all(Radius.circular(6.0)), + border: Border.all( + width: 1.0, color: HexColor("#CCCCCC"))), + child: TextFields( + hintText: widget.remarks, + controller: remarksController, + maxLines: 7, + minLines: 4, + ), + ), + SizedBox( + height: 12.0, + ), + SizedBox( + height: MediaQuery.of(context).size.height * 0.12, + ), + Container( + margin: EdgeInsets.all( + SizeConfig.widthMultiplier * 2), + child: Wrap( + alignment: WrapAlignment.center, + children: [ + AppButton( + title: 'update prescription'.toUpperCase(), + onPressed: () { + updatePrescription( + newDoseStreangth: + strengthController.text.isNotEmpty + ? strengthController.text + : widget.doseStreangth, + newUnit: units != null + ? units['id'].toString() + : widget.doseUnit, + doseUnit: widget.doseUnit, + doseStreangth: widget.doseStreangth, + duration: widget.duration, + startDate: widget.startDate, + doseId: widget.dose, + frequencyId: widget.frequency, + routeId: widget.route, + patient: widget.patient, + model: widget.model, + newDuration: updatedDuration != null + ? updatedDuration['id'].toString() + : widget.duration, + drugId: widget.drugId, + remarks: remarksController.text, + route: route != null + ? route['id'].toString() + : widget.route, + frequency: frequencyUpdate != null + ? frequencyUpdate['id'].toString() + : widget.frequency, + dose: doseTime != null + ? doseTime['id'].toString() + : widget.dose, + enteredRemarks: + widget.enteredRemarks); + Navigator.pop(context); + }, + ), + ], + ), + ), + ], + ), + ], + ), + ), + )); + }); + }); + } + + InputDecoration textFieldSelectorDecoration( + String hintText, String selectedText, bool isDropDown, + {Icon suffixIcon}) { + return InputDecoration( + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), + borderRadius: BorderRadius.circular(8), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), + borderRadius: BorderRadius.circular(8), + ), + disabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), + borderRadius: BorderRadius.circular(8), + ), + hintText: selectedText != null ? selectedText : hintText, + suffixIcon: isDropDown + ? suffixIcon != null + ? suffixIcon + : Icon( + Icons.arrow_drop_down, + color: Colors.black, + ) + : null, + hintStyle: TextStyle( + fontSize: 14, + color: Colors.grey.shade600, + ), + ); + } + + updatePrescription( + {PrescriptionViewModel model, + int drugId, + String frequencyId, + String remarks, + String dose, + String doseId, + String frequency, + String route, + String routeId, + String startDate, + String doseUnit, + String doseStreangth, + String newDoseStreangth, + String duration, + String newDuration, + String newUnit, + String enteredRemarks, + PatiantInformtion patient}) async { + //PrescriptionViewModel model = PrescriptionViewModel(); + PostPrescriptionReqModel updatePrescriptionReqModel = + new PostPrescriptionReqModel(); + List sss = List(); + + updatePrescriptionReqModel.appointmentNo = patient.appointmentNo; + updatePrescriptionReqModel.clinicID = patient.clinicId; + updatePrescriptionReqModel.episodeID = patient.episodeNo; + updatePrescriptionReqModel.patientMRN = patient.patientMRN; + + sss.add(PrescriptionRequestModel( + covered: true, + dose: newDoseStreangth.isNotEmpty + ? int.parse(newDoseStreangth) + : int.parse(doseStreangth), + //frequency.isNotEmpty ? int.parse(dose) : 1, + itemId: drugId, + doseUnitId: + newUnit.isNotEmpty ? int.parse(newUnit) : int.parse(doseUnit), + route: route.isNotEmpty ? int.parse(route) : int.parse(routeId), + frequency: frequency.isNotEmpty + ? int.parse(frequency) + : int.parse(frequencyId), + remarks: remarks.isEmpty ? enteredRemarks : remarks, + approvalRequired: true, + icdcode10Id: "test2", + doseTime: dose.isNotEmpty ? int.parse(dose) : int.parse(doseId), + duration: newDuration.isNotEmpty + ? int.parse(newDuration) + : int.parse(duration), + doseStartDate: startDate)); + updatePrescriptionReqModel.prescriptionRequestModel = sss; + //postProcedureReqModel.procedures = controlsProcedure; + + await model.updatePrescription( + updatePrescriptionReqModel, patient.patientMRN); + + if (model.state == ViewState.ErrorLocal) { + helpers.showErrorToast(model.error); + } else if (model.state == ViewState.Idle) { + DrAppToastMsg.showSuccesToast('Medication has been updated'); + } + } +} + +void updatePrescriptionForm( + {context, + String drugName, + int drugId, + String remarks, + PrescriptionViewModel model, + PatiantInformtion patient, + String rouat, + String frequency, + String dose, + String duration, + String doseStreangth, + String doseUnit, + String enteredRemarks, + String startDate}) { + TextEditingController remarksController = TextEditingController(); + TextEditingController doseController = TextEditingController(); + TextEditingController frequencyController = TextEditingController(); + TextEditingController routeController = TextEditingController(); + showModalBottomSheet( + context: context, + isScrollControlled: true, + builder: (BuildContext context) { + return UpdatePrescriptionForm( + drugName: drugName, + patient: patient, + doseStreangth: doseStreangth, + remarks: remarks, + drugId: drugId, + enteredRemarks: enteredRemarks, + duration: duration, + dose: dose, + doseUnit: doseUnit, + frequency: frequency, + route: rouat, + startDate: startDate, + model: model, + ); + }); +} diff --git a/lib/screens/procedures/procedure_screen.dart b/lib/screens/procedures/procedure_screen.dart index 9fb8510c..ca126609 100644 --- a/lib/screens/procedures/procedure_screen.dart +++ b/lib/screens/procedures/procedure_screen.dart @@ -1,32 +1,15 @@ -import 'package:doctor_app_flutter/client/base_app_client.dart'; -import 'package:doctor_app_flutter/config/shared_pref_kay.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/procedure/ControlsModel.dart'; -import 'package:doctor_app_flutter/core/model/procedure/categories_procedure.dart'; -import 'package:doctor_app_flutter/core/model/procedure/post_procedure_req_model.dart'; -import 'package:doctor_app_flutter/core/model/procedure/update_procedure_request_model.dart'; import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart'; -import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; -import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart'; 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/screens/procedures/add-procedure-form.dart'; -import 'package:doctor_app_flutter/screens/procedures/entity_list_checkbox_search_widget.dart'; import 'package:doctor_app_flutter/screens/procedures/update-procedure.dart'; -import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/patient-page-header-widget.dart'; -import 'package:doctor_app_flutter/widgets/patients/profile/patient_profile_widget.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_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/dialogs/dailog-list-select.dart'; import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:flutter/material.dart'; -import 'package:hexcolor/hexcolor.dart'; class ProcedureScreen extends StatefulWidget { @override From 15dd0f7c1a222d9dbff984577500a3d314e5c14e Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Tue, 2 Feb 2021 13:58:46 +0200 Subject: [PATCH 5/6] bug fix --- lib/core/enum/master_lookup_key.dart | 28 +- lib/core/service/base/lookup-service.dart | 77 +- lib/core/service/prescription_service.dart | 3 +- lib/core/viewModel/medicine_view_model.dart | 94 +- .../prescription/add_prescription_form.dart | 262 +---- .../prescription/prescription_screen.dart | 1 - .../update_prescription_form.dart | 918 ++++++++---------- lib/screens/procedures/update-procedure.dart | 306 ++++-- 8 files changed, 832 insertions(+), 857 deletions(-) diff --git a/lib/core/enum/master_lookup_key.dart b/lib/core/enum/master_lookup_key.dart index f1ba1d46..58faa986 100644 --- a/lib/core/enum/master_lookup_key.dart +++ b/lib/core/enum/master_lookup_key.dart @@ -12,7 +12,13 @@ enum MasterKeysService { DiagnosisType, ICD10, TemperatureMethods, - Speciality + Speciality, + MedicationStrength, + MedicationDuration, + MedicationRoute, + MedicationFrequency, + MedicationDoseTime, + MedicationIndications, } extension SelectedMasterKeysService on MasterKeysService { @@ -45,7 +51,8 @@ extension SelectedMasterKeysService on MasterKeysService { break; case MasterKeysService.physiotherapyGoals: return 117; - break;case MasterKeysService.DiagnosisCondition: + break; + case MasterKeysService.DiagnosisCondition: return 34; break; case MasterKeysService.DiagnosisType: @@ -57,6 +64,23 @@ extension SelectedMasterKeysService on MasterKeysService { return 2005; case MasterKeysService.Speciality: return 10; + case MasterKeysService.MedicationStrength: + return 2100; + break; + case MasterKeysService.MedicationDuration: + return 118; + break; + case MasterKeysService.MedicationRoute: + return 32; + break; + case MasterKeysService.MedicationFrequency: + return 31; + break; + case MasterKeysService.MedicationDoseTime: + return 30; + break; + case MasterKeysService.MedicationIndications: + return 450; break; } } diff --git a/lib/core/service/base/lookup-service.dart b/lib/core/service/base/lookup-service.dart index 3bc6e61e..1acc8cec 100644 --- a/lib/core/service/base/lookup-service.dart +++ b/lib/core/service/base/lookup-service.dart @@ -11,6 +11,13 @@ class LookupService extends BaseService { List get allergySeverityList => _allergySeverityList; List _allergySeverityList = []; + List medicationStrengthList = []; + List medicationDurationList = []; + List medicationRouteList = []; + List medicationFrequencyList = []; + List medicationDoseTimeList = []; + List medicationIndicationsList = []; + List get historyFamilyList => _historyFamilyList; List _historyFamilyList = []; @@ -32,11 +39,11 @@ class LookupService extends BaseService { List _physicalExaminationList = []; // List listOfPhysiotherapyGoals = []; - List listOfDiagnosisType = []; - List listOfDiagnosisCondition = []; - List listOfICD10 = []; - List listOfTemperatureMethods = []; - List listOfSpeciality = []; + List listOfDiagnosisType = []; + List listOfDiagnosisCondition = []; + List listOfICD10 = []; + List listOfTemperatureMethods = []; + List listOfSpeciality = []; Future getMasterLookup(MasterKeysService masterKeys) async { hasError = false; @@ -110,42 +117,72 @@ class LookupService extends BaseService { }); break; - case MasterKeysService.DiagnosisType: - listOfDiagnosisType.clear(); + case MasterKeysService.DiagnosisType: + listOfDiagnosisType.clear(); entryList.forEach((v) { - listOfDiagnosisType - .add(MasterKeyModel.fromJson(v)); + listOfDiagnosisType.add(MasterKeyModel.fromJson(v)); }); break; - case MasterKeysService.DiagnosisCondition: - listOfDiagnosisCondition.clear(); + case MasterKeysService.DiagnosisCondition: + listOfDiagnosisCondition.clear(); entryList.forEach((v) { - listOfDiagnosisCondition - .add(MasterKeyModel.fromJson(v)); + listOfDiagnosisCondition.add(MasterKeyModel.fromJson(v)); }); break; case MasterKeysService.ICD10: listOfICD10.clear(); entryList.forEach((v) { - listOfICD10 - .add(MasterKeyModel.fromJson(v)); + listOfICD10.add(MasterKeyModel.fromJson(v)); }); break; case MasterKeysService.TemperatureMethods: listOfTemperatureMethods.clear(); entryList.forEach((v) { - listOfTemperatureMethods - .add(MasterKeyModel.fromJson(v)); + listOfTemperatureMethods.add(MasterKeyModel.fromJson(v)); }); break; case MasterKeysService.Speciality: listOfSpeciality.clear(); entryList.forEach((v) { - listOfSpeciality - .add(MasterKeyModel.fromJson(v)); + listOfSpeciality.add(MasterKeyModel.fromJson(v)); + }); + break; + case MasterKeysService.MedicationStrength: + medicationStrengthList.clear(); + entryList.forEach((v) { + medicationStrengthList.add(v); + }); + break; + case MasterKeysService.MedicationDuration: + medicationDurationList.clear(); + entryList.forEach((v) { + medicationDurationList.add(v); + }); + break; + case MasterKeysService.MedicationRoute: + medicationRouteList.clear(); + entryList.forEach((v) { + medicationRouteList.add(v); + }); + break; + case MasterKeysService.MedicationFrequency: + medicationFrequencyList.clear(); + entryList.forEach((v) { + medicationFrequencyList.add(v); + }); + break; + case MasterKeysService.MedicationDoseTime: + medicationDoseTimeList.clear(); + entryList.forEach((v) { + medicationDoseTimeList.add(v); + }); + break; + case MasterKeysService.MedicationIndications: + medicationIndicationsList.clear(); + entryList.forEach((v) { + medicationIndicationsList.add(v); }); break; } } - } diff --git a/lib/core/service/prescription_service.dart b/lib/core/service/prescription_service.dart index 9fcf4c2d..b7f9e80e 100644 --- a/lib/core/service/prescription_service.dart +++ b/lib/core/service/prescription_service.dart @@ -6,12 +6,13 @@ import 'package:doctor_app_flutter/core/model/post_prescrition_req_model.dart'; import 'package:doctor_app_flutter/core/model/search_drug_model.dart'; import 'package:doctor_app_flutter/core/model/search_drug_request_model.dart'; import 'package:doctor_app_flutter/core/service/base/base_service.dart'; +import 'package:doctor_app_flutter/core/service/base/lookup-service.dart'; import 'package:doctor_app_flutter/models/SOAP/GetAllergiesResModel.dart'; import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/models/patient/vital_sign/patient-vital-sign-data.dart'; -class PrescriptionService extends BaseService { +class PrescriptionService extends LookupService { List _prescriptionList = List(); List get prescriptionList => _prescriptionList; List _drugsList = List(); diff --git a/lib/core/viewModel/medicine_view_model.dart b/lib/core/viewModel/medicine_view_model.dart index 23dd0306..5b7c2f6a 100644 --- a/lib/core/viewModel/medicine_view_model.dart +++ b/lib/core/viewModel/medicine_view_model.dart @@ -1,5 +1,7 @@ +import 'package:doctor_app_flutter/core/enum/master_lookup_key.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/service/SOAP_service.dart'; import 'package:doctor_app_flutter/core/service/medicine_service.dart'; import 'package:doctor_app_flutter/core/service/prescription_service.dart'; @@ -8,10 +10,25 @@ import 'base_view_model.dart'; class MedicineViewModel extends BaseViewModel { MedicineService _medicineService = locator(); + PrescriptionService _prescriptionService = locator(); + get pharmacyItemsList => _medicineService.pharmacyItemsList; + get pharmaciesList => _medicineService.pharmaciesList; - PrescriptionService _prescriptionService = locator(); + get medicationStrengthList => _prescriptionService.medicationStrengthList; + + get medicationDurationList => _prescriptionService.medicationDurationList; + + get medicationRouteList => _prescriptionService.medicationRouteList; + + get medicationFrequencyList => _prescriptionService.medicationFrequencyList; + + get medicationIndicationsList => + _prescriptionService.medicationIndicationsList; + + get medicationDoseTimeList => _prescriptionService.medicationDoseTimeList; + List get allMedicationList => _prescriptionService.allMedicationList; @@ -35,6 +52,72 @@ class MedicineViewModel extends BaseViewModel { setState(ViewState.Idle); } + Future getMedicationStrength() async { + setState(ViewState.Busy); + await _prescriptionService + .getMasterLookup(MasterKeysService.MedicationStrength); + if (_prescriptionService.hasError) { + error = _prescriptionService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + + Future getMedicationRoute() async { + setState(ViewState.Busy); + await _prescriptionService + .getMasterLookup(MasterKeysService.MedicationRoute); + if (_prescriptionService.hasError) { + error = _prescriptionService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + + Future getMedicationIndications() async { + setState(ViewState.Busy); + await _prescriptionService + .getMasterLookup(MasterKeysService.MedicationIndications); + if (_prescriptionService.hasError) { + error = _prescriptionService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + + Future getMedicationDoseTime() async { + setState(ViewState.Busy); + await _prescriptionService + .getMasterLookup(MasterKeysService.MedicationDoseTime); + if (_prescriptionService.hasError) { + error = _prescriptionService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + + Future getMedicationFrequency() async { + setState(ViewState.Busy); + await _prescriptionService + .getMasterLookup(MasterKeysService.MedicationFrequency); + if (_prescriptionService.hasError) { + error = _prescriptionService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + + Future getMedicationDuration() async { + setState(ViewState.Busy); + await _prescriptionService + .getMasterLookup(MasterKeysService.MedicationDuration); + if (_prescriptionService.hasError) { + error = _prescriptionService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + Future getPharmaciesList(int itemId) async { setState(ViewState.Busy); await _medicineService.getPharmaciesList(itemId); @@ -44,4 +127,13 @@ class MedicineViewModel extends BaseViewModel { } else setState(ViewState.Idle); } + + dynamic getLookupById(List list, String id) { + for (int i = 0; i < list.length; i++) { + if (list[i]['id'].toString() == id) { + return list[i]; + } + } + return null; + } } diff --git a/lib/screens/prescription/add_prescription_form.dart b/lib/screens/prescription/add_prescription_form.dart index 1d481904..a8279634 100644 --- a/lib/screens/prescription/add_prescription_form.dart +++ b/lib/screens/prescription/add_prescription_form.dart @@ -127,13 +127,7 @@ class _PrescriptionFormWidgetState extends State { dynamic indication; dynamic units; - List strengthList; - List routeList; - List frequencyList; - List durationList; - List doseTimeList; List indicationList; - List unitsList; String routeInatial = 'By Mouth'; //PatiantInformtion patient; @@ -142,111 +136,9 @@ class _PrescriptionFormWidgetState extends State { super.initState(); selectedType = 1; referToList = List(); - strengthList = List(); - routeList = List(); - frequencyList = List(); - durationList = List(); - doseTimeList = List(); - indicationList = List(); - unitsList = List(); - dynamic unit1 = {"id": 1, "name": "MG"}; - dynamic unit2 = {"id": 2, "name": "MCG"}; - dynamic unit3 = {"id": 3, "name": "GM"}; - dynamic regularOrder = {"id": 1, "name": "regular Order"}; - dynamic urgentOrder = {"id": 2, "name": "urgent Order"}; - dynamic strength1 = {"id": 1, "name": "1"}; - dynamic strength2 = {"id": 2, "name": "2"}; - dynamic strength3 = {"id": 3, "name": "3"}; - dynamic strength4 = {"id": 4, "name": "4"}; - dynamic strength5 = {"id": 5, "name": "5"}; - dynamic strength6 = {"id": 6, "name": "6"}; - dynamic strength7 = {"id": 7, "name": "7"}; - dynamic strength8 = {"id": 8, "name": "8"}; - dynamic strength9 = {"id": 9, "name": "9"}; - dynamic route1 = {"id": 7, "name": "By Mouth"}; - dynamic route2 = {"id": 10, "name": "Inhale by Mouth"}; - dynamic route3 = {"id": 15, "name": "for INJECTION"}; - dynamic route4 = {"id": 17, "name": "Drops"}; - dynamic route5 = {"id": 18, "name": "Rub On"}; - dynamic route6 = {"id": 20, "name": "Spary"}; - dynamic route7 = {"id": 27, "name": "In Both EYES"}; - dynamic route8 = {"id": 28, "name": "In Both Ears"}; - dynamic route9 = {"id": 32, "name": "Intramuscular"}; - dynamic route10 = {"id": 60, "name": "TRANSDERMAL"}; - dynamic route11 = {"id": 59, "name": "OROPHARYNGEAL"}; - dynamic route12 = {"id": 15, "name": "for INJECTION"}; - dynamic route13 = {"id": 58, "name": "SUBCUTANEOUS"}; - dynamic route14 = {"id": 57, "name": "NASOGASTRIC"}; - dynamic route15 = {"id": 56, "name": "IRRIGATION"}; - dynamic route16 = {"id": 55, "name": "INTRAVITREAL"}; - dynamic route17 = {"id": 54, "name": "INTRAVENOUS BOLUS"}; - dynamic route18 = {"id": 51, "name": "EPIDURAL"}; - dynamic route19 = {"id": 47, "name": "Parenteral"}; - dynamic route20 = {"id": 43, "name": "IM"}; - dynamic route21 = {"id": 42, "name": "IV"}; - dynamic route22 = {"id": 41, "name": "Sublingual"}; - dynamic route23 = {"id": 40, "name": "For Nebulization"}; - dynamic route24 = {"id": 39, "name": "Nasal"}; - dynamic route25 = {"id": 37, "name": "Inserted into Vagina"}; - dynamic route26 = {"id": 36, "name": "Inserted into Rectum"}; - dynamic route27 = {"id": 31, "name": "In Each Nostril"}; - dynamic frequency1 = {"id": 2, "name": "2 Times a day"}; - dynamic frequency2 = {"id": 3, "name": "3 Times a day"}; - dynamic frequency3 = {"id": 4, "name": "4 Times a day"}; - dynamic frequency4 = {"id": 8, "name": "As Needed"}; - dynamic frequency5 = {"id": 9, "name": "Bed Time"}; - dynamic frequency6 = {"id": 11, "name": "Every Other Day"}; - dynamic frequency7 = {"id": 29, "name": "Every Eight Hours"}; - dynamic frequency8 = {"id": 34, "name": "As Directed"}; - dynamic frequency9 = {"id": 22, "name": "Once Per Month"}; - dynamic frequency10 = {"id": 2, "name": "3 Times a day"}; - dynamic frequency11 = {"id": 21, "name": "Every 3 hours"}; - dynamic frequency12 = {"id": 20, "name": "Once a Week"}; - dynamic frequency13 = {"id": 12, "name": "Every Half Hour"}; - dynamic frequency14 = {"id": 10, "name": "4 Times a Day"}; - dynamic frequency15 = {"id": 24, "name": "Once Every 2 Months"}; - dynamic frequency16 = {"id": 25, "name": "Every One Hour"}; - dynamic frequency17 = {"id": 26, "name": "Every Two Hours"}; - dynamic frequency18 = {"id": 28, "name": "Every Six Hours"}; + indicationList = List(); - dynamic duration1 = {"id": 1, "name": "For 1 Day"}; - dynamic duration2 = {"id": 2, "name": "For 2 Days"}; - dynamic duration3 = {"id": 3, "name": "For 3 Days"}; - dynamic duration4 = {"id": 4, "name": "For 4 Days"}; - dynamic duration5 = {"id": 5, "name": "For 5 Days"}; - dynamic duration6 = {"id": 6, "name": "For 6 Days"}; - dynamic duration7 = {"id": 7, "name": "For 7 Days"}; - dynamic duration8 = {"id": 8, "name": "For 8 Days"}; - dynamic duration9 = {"id": 9, "name": "For 9 Days"}; - dynamic duration10 = {"id": 10, "name": "For 10 Days"}; - dynamic duration11 = {"id": 14, "name": "For 14 Days"}; - dynamic duration12 = {"id": 21, "name": "For 21 Days"}; - dynamic duration13 = {"id": 30, "name": "For 30 Days"}; - dynamic duration14 = {"id": 45, "name": "For 45 Days"}; - dynamic duration15 = {"id": 60, "name": "For 60 Days"}; - dynamic duration16 = {"id": 90, "name": "For 90 Days"}; - dynamic doseTime1 = {"id": 1, "name": "Before Meals"}; - dynamic doseTime2 = {"id": 2, "name": "After Meals"}; - dynamic doseTime3 = {"id": 3, "name": "With Meals"}; - dynamic doseTime4 = {"id": 4, "name": "In The Morning"}; - dynamic doseTime5 = {"id": 5, "name": "In the Evening"}; - dynamic doseTime6 = {"id": 6, "name": "After Supper"}; - dynamic doseTime7 = {"id": 7, "name": "With Supper"}; - dynamic doseTime8 = {"id": 8, "name": "Before Breakfast"}; - dynamic doseTime9 = {"id": 9, "name": "In the Afternoon"}; - dynamic doseTime10 = {"id": 10, "name": "While wake"}; - dynamic doseTime11 = {"id": 12, "name": "Any Time"}; - dynamic doseTime12 = {"id": 21, "name": "Bed Time"}; - dynamic doseTime13 = {"id": 13, "name": "30 Minutes Before Meals"}; - dynamic doseTime14 = {"id": 14, "name": "1 Hour Before Meals"}; - dynamic doseTime15 = {"id": 15, "name": "2 Hours After Meal"}; - dynamic doseTime16 = {"id": 16, "name": "After Breakfast"}; - dynamic doseTime17 = {"id": 17, "name": "Before Lunch"}; - dynamic doseTime18 = {"id": 18, "name": "After Lunch"}; - dynamic doseTime19 = {"id": 20, "name": "After Dinner"}; - dynamic doseTime20 = {"id": 21, "name": "Bed Time"}; - dynamic doseTime21 = {"id": 11, "name": "Now"}; dynamic indication1 = {"id": 545, "name": "Gingival Hyperplasia"}; dynamic indication2 = {"id": 546, "name": "Mild Drowsiness"}; dynamic indication3 = {"id": 547, "name": "Hypertrichosis"}; @@ -261,9 +153,6 @@ class _PrescriptionFormWidgetState extends State { dynamic indication9 = {"id": 554, "name": "Purpuric Dermatitis"}; dynamic indication10 = {"id": 555, "name": "Systemic Lupus Erythematosus"}; - unitsList.add(unit1); - unitsList.add(unit2); - unitsList.add(unit3); indicationList.add(indication1); indicationList.add(indication2); indicationList.add(indication3); @@ -274,102 +163,6 @@ class _PrescriptionFormWidgetState extends State { indicationList.add(indication8); indicationList.add(indication9); indicationList.add(indication10); - - doseTimeList.add(doseTime1); - doseTimeList.add(doseTime2); - doseTimeList.add(doseTime3); - doseTimeList.add(doseTime4); - doseTimeList.add(doseTime5); - doseTimeList.add(doseTime6); - doseTimeList.add(doseTime7); - doseTimeList.add(doseTime8); - doseTimeList.add(doseTime9); - doseTimeList.add(doseTime10); - doseTimeList.add(doseTime11); - doseTimeList.add(doseTime12); - doseTimeList.add(doseTime13); - doseTimeList.add(doseTime14); - doseTimeList.add(doseTime15); - doseTimeList.add(doseTime16); - doseTimeList.add(doseTime17); - doseTimeList.add(doseTime18); - doseTimeList.add(doseTime19); - doseTimeList.add(doseTime20); - doseTimeList.add(doseTime21); - - doseTimeList.add(doseTime12); - frequencyList.add(frequency1); - frequencyList.add(frequency2); - frequencyList.add(frequency3); - frequencyList.add(frequency4); - frequencyList.add(frequency5); - frequencyList.add(frequency6); - frequencyList.add(frequency7); - frequencyList.add(frequency8); - frequencyList.add(frequency9); - frequencyList.add(frequency10); - frequencyList.add(frequency11); - frequencyList.add(frequency12); - frequencyList.add(frequency13); - frequencyList.add(frequency14); - frequencyList.add(frequency15); - frequencyList.add(frequency16); - frequencyList.add(frequency17); - frequencyList.add(frequency18); - routeList.add(route1); - routeList.add(route2); - routeList.add(route3); - routeList.add(route4); - routeList.add(route5); - routeList.add(route6); - routeList.add(route7); - routeList.add(route8); - routeList.add(route9); - routeList.add(route10); - routeList.add(route11); - routeList.add(route12); - routeList.add(route13); - routeList.add(route14); - routeList.add(route15); - routeList.add(route16); - routeList.add(route17); - routeList.add(route18); - routeList.add(route19); - routeList.add(route20); - routeList.add(route21); - routeList.add(route22); - routeList.add(route23); - routeList.add(route24); - routeList.add(route25); - routeList.add(route26); - routeList.add(route27); - strengthList.add(strength1); - strengthList.add(strength2); - strengthList.add(strength3); - strengthList.add(strength4); - strengthList.add(strength5); - strengthList.add(strength6); - strengthList.add(strength7); - strengthList.add(strength8); - strengthList.add(strength9); - durationList.add(duration1); - durationList.add(duration2); - durationList.add(duration3); - durationList.add(duration4); - durationList.add(duration5); - durationList.add(duration6); - durationList.add(duration7); - durationList.add(duration8); - durationList.add(duration9); - durationList.add(duration10); - durationList.add(duration11); - durationList.add(duration12); - durationList.add(duration13); - durationList.add(duration14); - durationList.add(duration15); - durationList.add(duration16); - referToList.add(regularOrder); - referToList.add(urgentOrder); } setSelectedType(int val) { @@ -388,6 +181,12 @@ class _PrescriptionFormWidgetState extends State { return BaseView( onModelReady: (model) async { await model.getMedicationList(); + await model.getMedicationStrength(); + await model.getMedicationDuration(); + await model.getMedicationRoute(); + await model.getMedicationFrequency(); + await model.getMedicationDoseTime(); + await model.getMedicationIndications(); }, builder: (BuildContext context, MedicineViewModel model, Widget child) => NetworkBaseView( @@ -564,12 +363,14 @@ class _PrescriptionFormWidgetState extends State { MediaQuery.of(context).size.width * 0.350, child: InkWell( - onTap: unitsList != null + onTap: model.medicationStrengthList != + null ? () { ListSelectDialog dialog = ListSelectDialog( - list: unitsList, - attributeName: 'name', + list: model + .medicationStrengthList, + attributeName: 'nameEn', attributeValueId: 'id', okText: TranslationBase.of( context) @@ -596,7 +397,7 @@ class _PrescriptionFormWidgetState extends State { textFieldSelectorDecoration( 'UNIT Type', units != null - ? units['name'] + ? units['nameEn'] : null, true), enabled: false, @@ -610,12 +411,12 @@ class _PrescriptionFormWidgetState extends State { Container( height: screenSize.height * 0.070, child: InkWell( - onTap: routeList != null + onTap: model.medicationRouteList != null ? () { ListSelectDialog dialog = ListSelectDialog( - list: routeList, - attributeName: 'name', + list: model.medicationRouteList, + attributeName: 'nameEn', attributeValueId: 'id', okText: TranslationBase.of(context) @@ -642,7 +443,9 @@ class _PrescriptionFormWidgetState extends State { child: TextField( decoration: textFieldSelectorDecoration( TranslationBase.of(context).route, - route != null ? route['name'] : null, + route != null + ? route['nameEn'] + : null, true), enabled: false, ), @@ -652,12 +455,13 @@ class _PrescriptionFormWidgetState extends State { Container( height: screenSize.height * 0.070, child: InkWell( - onTap: frequencyList != null + onTap: model.medicationFrequencyList != null ? () { ListSelectDialog dialog = ListSelectDialog( - list: frequencyList, - attributeName: 'name', + list: + model.medicationFrequencyList, + attributeName: 'nameEn', attributeValueId: 'id', okText: TranslationBase.of(context) @@ -681,7 +485,7 @@ class _PrescriptionFormWidgetState extends State { decoration: textFieldSelectorDecoration( TranslationBase.of(context).frequency, frequency != null - ? frequency['name'] + ? frequency['nameEn'] : null, true), enabled: false, @@ -692,12 +496,13 @@ class _PrescriptionFormWidgetState extends State { Container( height: screenSize.height * 0.070, child: InkWell( - onTap: doseTimeList != null + onTap: model.medicationDoseTimeList != null ? () { ListSelectDialog dialog = ListSelectDialog( - list: doseTimeList, - attributeName: 'name', + list: + model.medicationDoseTimeList, + attributeName: 'nameEn', attributeValueId: 'id', okText: TranslationBase.of(context) @@ -721,7 +526,7 @@ class _PrescriptionFormWidgetState extends State { decoration: textFieldSelectorDecoration( TranslationBase.of(context).doseTime, doseTime != null - ? doseTime['name'] + ? doseTime['nameEn'] : null, true), enabled: false, @@ -795,12 +600,13 @@ class _PrescriptionFormWidgetState extends State { Container( height: screenSize.height * 0.070, child: InkWell( - onTap: durationList != null + onTap: model.medicationDurationList != null ? () { ListSelectDialog dialog = ListSelectDialog( - list: durationList, - attributeName: 'name', + list: + model.medicationDurationList, + attributeName: 'nameEn', attributeValueId: 'id', okText: TranslationBase.of(context) @@ -824,7 +630,7 @@ class _PrescriptionFormWidgetState extends State { decoration: textFieldSelectorDecoration( TranslationBase.of(context).duration, duration != null - ? duration['name'] + ? duration['nameEn'] : null, true), enabled: false, diff --git a/lib/screens/prescription/prescription_screen.dart b/lib/screens/prescription/prescription_screen.dart index 290aadca..c7c4c60e 100644 --- a/lib/screens/prescription/prescription_screen.dart +++ b/lib/screens/prescription/prescription_screen.dart @@ -179,7 +179,6 @@ class _NewPrescriptionScreenState extends State { model.prescriptionList[0] .rowcount, (index) => Container( - //height: 240, child: Column( children: [ Row( diff --git a/lib/screens/prescription/update_prescription_form.dart b/lib/screens/prescription/update_prescription_form.dart index 01986813..5c7c6e76 100644 --- a/lib/screens/prescription/update_prescription_form.dart +++ b/lib/screens/prescription/update_prescription_form.dart @@ -2,14 +2,17 @@ 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/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'; 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/TextFields.dart'; import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/dialogs/dailog-list-select.dart'; +import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -60,551 +63,426 @@ class _UpdatePrescriptionFormState extends State { dynamic updatedDuration; dynamic units; - List doseTimeList; - List routeList; - List frequencyList; - List durationList; - List unitsList; - @override void initState() { super.initState(); - routeList = List(); - doseTimeList = List(); - frequencyList = List(); - durationList = List(); - unitsList = List(); - - dynamic unit1 = {"id": 1, "name": "MG"}; - dynamic unit2 = {"id": 2, "name": "MCG"}; - dynamic unit3 = {"id": 3, "name": "GM"}; - dynamic frequency1 = {"id": 2, "name": "2 Times a day"}; - dynamic frequency2 = {"id": 3, "name": "3 Times a day"}; - dynamic frequency3 = {"id": 4, "name": "4 Times a day"}; - dynamic frequency4 = {"id": 8, "name": "As Needed"}; - dynamic frequency5 = {"id": 9, "name": "Bed Time"}; - dynamic frequency6 = {"id": 11, "name": "Every Other Day"}; - dynamic frequency7 = {"id": 29, "name": "Every Eight Hours"}; - dynamic frequency8 = {"id": 34, "name": "As Directed"}; - dynamic frequency9 = {"id": 22, "name": "Once Per Month"}; - dynamic frequency10 = {"id": 2, "name": "3 Times a day"}; - dynamic frequency11 = {"id": 21, "name": "Every 3 hours"}; - dynamic frequency12 = {"id": 20, "name": "Once a Week"}; - dynamic frequency13 = {"id": 12, "name": "Every Half Hour"}; - dynamic frequency14 = {"id": 10, "name": "4 Times a Day"}; - dynamic frequency15 = {"id": 24, "name": "Once Every 2 Months"}; - dynamic frequency16 = {"id": 25, "name": "Every One Hour"}; - dynamic frequency17 = {"id": 26, "name": "Every Two Hours"}; - dynamic frequency18 = {"id": 28, "name": "Every Six Hours"}; - dynamic doseTime1 = {"id": 1, "name": "Before Meals"}; - dynamic doseTime2 = {"id": 2, "name": "After Meals"}; - dynamic doseTime3 = {"id": 3, "name": "With Meals"}; - dynamic doseTime4 = {"id": 4, "name": "In The Morning"}; - dynamic doseTime5 = {"id": 5, "name": "In the Evening"}; - dynamic doseTime6 = {"id": 6, "name": "After Supper"}; - dynamic doseTime7 = {"id": 7, "name": "With Supper"}; - dynamic doseTime8 = {"id": 8, "name": "Before Breakfast"}; - dynamic doseTime9 = {"id": 9, "name": "In the Afternoon"}; - dynamic doseTime10 = {"id": 10, "name": "While wake"}; - dynamic doseTime11 = {"id": 12, "name": "Any Time"}; - dynamic doseTime12 = {"id": 21, "name": "Bed Time"}; - dynamic doseTime13 = {"id": 13, "name": "30 Minutes Before Meals"}; - dynamic doseTime14 = {"id": 14, "name": "1 Hour Before Meals"}; - dynamic doseTime15 = {"id": 15, "name": "2 Hours After Meal"}; - dynamic doseTime16 = {"id": 16, "name": "After Breakfast"}; - dynamic doseTime17 = {"id": 17, "name": "Before Lunch"}; - dynamic doseTime18 = {"id": 18, "name": "After Lunch"}; - dynamic doseTime19 = {"id": 20, "name": "After Dinner"}; - dynamic doseTime20 = {"id": 21, "name": "Bed Time"}; - dynamic doseTime21 = {"id": 11, "name": "Now"}; - dynamic route1 = {"id": 7, "name": "By Mouth"}; - dynamic route2 = {"id": 10, "name": "Inhale by Mouth"}; - dynamic route3 = {"id": 15, "name": "for INJECTION"}; - dynamic route4 = {"id": 17, "name": "Drops"}; - dynamic route5 = {"id": 18, "name": "Rub On"}; - dynamic route6 = {"id": 20, "name": "Spary"}; - dynamic route7 = {"id": 27, "name": "In Both EYES"}; - dynamic route8 = {"id": 28, "name": "In Both Ears"}; - dynamic route9 = {"id": 32, "name": "Intramuscular"}; - dynamic route10 = {"id": 60, "name": "TRANSDERMAL"}; - dynamic route11 = {"id": 59, "name": "OROPHARYNGEAL"}; - dynamic route12 = {"id": 15, "name": "for INJECTION"}; - dynamic route13 = {"id": 58, "name": "SUBCUTANEOUS"}; - dynamic route14 = {"id": 57, "name": "NASOGASTRIC"}; - dynamic route15 = {"id": 56, "name": "IRRIGATION"}; - dynamic route16 = {"id": 55, "name": "INTRAVITREAL"}; - dynamic route17 = {"id": 54, "name": "INTRAVENOUS BOLUS"}; - dynamic route18 = {"id": 51, "name": "EPIDURAL"}; - dynamic route19 = {"id": 47, "name": "Parenteral"}; - dynamic route20 = {"id": 43, "name": "IM"}; - dynamic route21 = {"id": 42, "name": "IV"}; - dynamic route22 = {"id": 41, "name": "Sublingual"}; - dynamic route23 = {"id": 40, "name": "For Nebulization"}; - dynamic route24 = {"id": 39, "name": "Nasal"}; - dynamic route25 = {"id": 37, "name": "Inserted into Vagina"}; - dynamic route26 = {"id": 36, "name": "Inserted into Rectum"}; - dynamic route27 = {"id": 31, "name": "In Each Nostril"}; - dynamic duration1 = {"id": 1, "name": "For 1 Day"}; - dynamic duration2 = {"id": 2, "name": "For 2 Days"}; - dynamic duration3 = {"id": 3, "name": "For 3 Days"}; - dynamic duration4 = {"id": 4, "name": "For 4 Days"}; - dynamic duration5 = {"id": 5, "name": "For 5 Days"}; - dynamic duration6 = {"id": 6, "name": "For 6 Days"}; - dynamic duration7 = {"id": 7, "name": "For 7 Days"}; - dynamic duration8 = {"id": 8, "name": "For 8 Days"}; - dynamic duration9 = {"id": 9, "name": "For 9 Days"}; - dynamic duration10 = {"id": 10, "name": "For 10 Days"}; - dynamic duration11 = {"id": 14, "name": "For 14 Days"}; - dynamic duration12 = {"id": 21, "name": "For 21 Days"}; - dynamic duration13 = {"id": 30, "name": "For 30 Days"}; - dynamic duration14 = {"id": 45, "name": "For 45 Days"}; - dynamic duration15 = {"id": 60, "name": "For 60 Days"}; - dynamic duration16 = {"id": 90, "name": "For 90 Days"}; - - durationList.add(duration1); - durationList.add(duration2); - durationList.add(duration3); - durationList.add(duration4); - durationList.add(duration5); - durationList.add(duration6); - durationList.add(duration7); - durationList.add(duration8); - durationList.add(duration9); - durationList.add(duration10); - durationList.add(duration11); - durationList.add(duration12); - durationList.add(duration13); - durationList.add(duration14); - durationList.add(duration15); - durationList.add(duration16); - frequencyList.add(frequency1); - frequencyList.add(frequency2); - frequencyList.add(frequency3); - frequencyList.add(frequency4); - frequencyList.add(frequency5); - frequencyList.add(frequency6); - frequencyList.add(frequency7); - frequencyList.add(frequency8); - frequencyList.add(frequency9); - frequencyList.add(frequency10); - frequencyList.add(frequency11); - frequencyList.add(frequency12); - frequencyList.add(frequency13); - frequencyList.add(frequency14); - frequencyList.add(frequency15); - frequencyList.add(frequency16); - frequencyList.add(frequency17); - frequencyList.add(frequency18); - doseTimeList.add(doseTime1); - doseTimeList.add(doseTime2); - doseTimeList.add(doseTime3); - doseTimeList.add(doseTime4); - doseTimeList.add(doseTime5); - doseTimeList.add(doseTime6); - doseTimeList.add(doseTime7); - doseTimeList.add(doseTime8); - doseTimeList.add(doseTime9); - doseTimeList.add(doseTime10); - doseTimeList.add(doseTime11); - doseTimeList.add(doseTime12); - doseTimeList.add(doseTime13); - doseTimeList.add(doseTime14); - doseTimeList.add(doseTime15); - doseTimeList.add(doseTime16); - doseTimeList.add(doseTime17); - doseTimeList.add(doseTime18); - doseTimeList.add(doseTime19); - doseTimeList.add(doseTime20); - doseTimeList.add(doseTime21); - routeList.add(route1); - routeList.add(route2); - routeList.add(route3); - routeList.add(route4); - routeList.add(route5); - routeList.add(route6); - routeList.add(route7); - routeList.add(route8); - routeList.add(route9); - routeList.add(route10); - routeList.add(route11); - routeList.add(route12); - routeList.add(route13); - routeList.add(route14); - routeList.add(route15); - routeList.add(route16); - routeList.add(route17); - routeList.add(route18); - routeList.add(route19); - routeList.add(route20); - routeList.add(route21); - routeList.add(route22); - routeList.add(route23); - routeList.add(route24); - routeList.add(route25); - routeList.add(route26); - routeList.add(route27); - unitsList.add(unit1); - unitsList.add(unit2); - unitsList.add(unit3); } @override Widget build(BuildContext context) { return StatefulBuilder(builder: (BuildContext context, StateSetter setState /*You can rename this!*/) { - return DraggableScrollableSheet( - initialChildSize: 0.90, - maxChildSize: 0.90, - minChildSize: 0.6, - builder: (BuildContext context, ScrollController scrollController) { - return Container( - height: MediaQuery.of(context).size.height * 1.0, - child: Form( - child: Padding( - padding: - EdgeInsets.symmetric(horizontal: 20.0, vertical: 12.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - widget.drugName.toUpperCase(), - fontWeight: FontWeight.w900, - ), - SizedBox( - height: 10.0, - ), - Column( + return BaseView( + onModelReady: (model) async { + await model.getMedicationList(); + await model.getMedicationStrength(); + await model.getMedicationDuration(); + await model.getMedicationRoute(); + await model.getMedicationFrequency(); + await model.getMedicationDoseTime(); + await model.getMedicationIndications(); + route = model.getLookupById(model.medicationRouteList, widget.route); + doseTime = + model.getLookupById(model.medicationDoseTimeList, widget.dose); + updatedDuration = model.getLookupById( + model.medicationDurationList, widget.duration); + units = model.getLookupById( + model.medicationStrengthList, widget.doseUnit); + frequencyUpdate = model.getLookupById( + model.medicationFrequencyList, widget.frequency); + }, + builder: + (BuildContext context, MedicineViewModel model, Widget child) => + NetworkBaseView( + baseViewModel: model, + child: DraggableScrollableSheet( + initialChildSize: 0.90, + maxChildSize: 0.90, + minChildSize: 0.6, + builder: + (BuildContext context, ScrollController scrollController) { + return Container( + height: MediaQuery.of(context).size.height * 1.0, + child: Form( + child: Padding( + padding: EdgeInsets.symmetric( + horizontal: 20.0, vertical: 12.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Container( - height: - MediaQuery.of(context).size.height * 0.060, - width: double.infinity, - child: Row( - children: [ - Container( - width: MediaQuery.of(context).size.width * - 0.500, - child: TextFields( - inputFormatters: [ - LengthLimitingTextInputFormatter(4) - ], - hintText: - TranslationBase.of(context).strength, - controller: strengthController, - keyboardType: TextInputType.number, - onChanged: (String value) { - setState(() { - strengthChar = value.length; - }); - if (strengthChar >= 4) { - DrAppToastMsg.showErrorToast( - "Only 4 Digits allowed for strength"); - } - }, - // validator: (value) { - // if (value.isEmpty && - // strengthController.text.length > - // 4) - // return TranslationBase.of(context) - // .emptyMessage; - // else - // return null; - // }, - ), - ), - SizedBox( - width: 10.0, - ), - Container( - width: MediaQuery.of(context).size.width * - 0.3700, - child: InkWell( - onTap: unitsList != null - ? () { - ListSelectDialog dialog = - ListSelectDialog( - list: unitsList, - attributeName: 'name', - attributeValueId: 'id', - okText: - TranslationBase.of(context) - .ok, - okFunction: (selectedValue) { - setState(() { - units = selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: - (BuildContext context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: textFieldSelectorDecoration( - 'UNIT Type', - units != null - ? units['name'] - : null, - true), - enabled: false, - ), - ), - ), - ], - ), + AppText( + widget.drugName.toUpperCase(), + fontWeight: FontWeight.w900, ), SizedBox( - height: 12, + height: 10.0, ), - Container( - height: - MediaQuery.of(context).size.height * 0.070, - child: InkWell( - onTap: routeList != null - ? () { - ListSelectDialog dialog = - ListSelectDialog( - list: routeList, - attributeName: 'name', - attributeValueId: 'id', - okText: - TranslationBase.of(context).ok, - okFunction: (selectedValue) { + Column( + children: [ + Container( + height: MediaQuery.of(context).size.height * + 0.060, + width: double.infinity, + child: Row( + children: [ + Container( + width: + MediaQuery.of(context).size.width * + 0.500, + child: TextFields( + inputFormatters: [ + LengthLimitingTextInputFormatter(4) + ], + hintText: TranslationBase.of(context) + .strength, + controller: strengthController, + keyboardType: TextInputType.number, + onChanged: (String value) { setState(() { - route = selectedValue; + strengthChar = value.length; }); - if (route == null) { - route = route['id']; + if (strengthChar >= 4) { + DrAppToastMsg.showErrorToast( + "Only 4 Digits allowed for strength"); } }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: textFieldSelectorDecoration( - 'Route', - route != null ? route['name'] : null, - true), - enabled: false, + // validator: (value) { + // if (value.isEmpty && + // strengthController.text.length > + // 4) + // return TranslationBase.of(context) + // .emptyMessage; + // else + // return null; + // }, + ), + ), + SizedBox( + width: 10.0, + ), + Container( + width: + MediaQuery.of(context).size.width * + 0.3700, + child: InkWell( + onTap: model.medicationStrengthList != + null + ? () { + ListSelectDialog dialog = + ListSelectDialog( + list: model + .medicationStrengthList, + attributeName: 'nameEn', + attributeValueId: 'id', + okText: TranslationBase.of( + context) + .ok, + okFunction: + (selectedValue) { + setState(() { + units = selectedValue; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: + (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: TextField( + decoration: + textFieldSelectorDecoration( + 'UNIT Type', + units != null + ? units['nameEn'] + : null, + true), + enabled: false, + ), + ), + ), + ], + ), ), - ), - ), - SizedBox( - height: 12.0, - ), - Container( - height: - MediaQuery.of(context).size.height * 0.070, - child: InkWell( - onTap: doseTimeList != null - ? () { - ListSelectDialog dialog = - ListSelectDialog( - list: doseTimeList, - attributeName: 'name', - attributeValueId: 'id', - okText: - TranslationBase.of(context).ok, - okFunction: (selectedValue) { - setState(() { - doseTime = selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: textFieldSelectorDecoration( - TranslationBase.of(context).doseTime, - doseTime != null - ? doseTime['name'] - : null, - true), - enabled: false, + SizedBox( + height: 12, ), - ), - ), - SizedBox( - height: 12.0, - ), - Container( - height: - MediaQuery.of(context).size.height * 0.070, - child: InkWell( - onTap: frequencyList != null - ? () { - ListSelectDialog dialog = - ListSelectDialog( - list: frequencyList, - attributeName: 'name', - attributeValueId: 'id', - okText: - TranslationBase.of(context).ok, - okFunction: (selectedValue) { - setState(() { - frequencyUpdate = selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: textFieldSelectorDecoration( - TranslationBase.of(context).frequency, - frequencyUpdate != null - ? frequencyUpdate['name'] - : null, - true), - enabled: false, + Container( + height: MediaQuery.of(context).size.height * + 0.070, + child: InkWell( + onTap: model.medicationRouteList != null + ? () { + ListSelectDialog dialog = + ListSelectDialog( + list: model.medicationRouteList, + attributeName: 'nameEn', + attributeValueId: 'id', + okText: + TranslationBase.of(context) + .ok, + okFunction: (selectedValue) { + setState(() { + route = selectedValue; + }); + if (route == null) { + route = route['id']; + } + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: TextField( + decoration: textFieldSelectorDecoration( + 'Route', + route != null + ? route['nameEn'] + : null, + true), + enabled: false, + ), + ), ), - ), - ), - SizedBox( - height: 12.0, - ), - Container( - height: - MediaQuery.of(context).size.height * 0.070, - child: InkWell( - onTap: durationList != null - ? () { - ListSelectDialog dialog = - ListSelectDialog( - list: durationList, - attributeName: 'name', - attributeValueId: 'id', - okText: - TranslationBase.of(context).ok, - okFunction: (selectedValue) { - setState(() { - updatedDuration = selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: textFieldSelectorDecoration( - TranslationBase.of(context).duration, - updatedDuration != null - ? updatedDuration['name'].toString() - : null, - true), - enabled: false, + SizedBox( + height: 12.0, ), - ), - ), - SizedBox( - height: 12.0, - ), - Container( - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, color: HexColor("#CCCCCC"))), - child: TextFields( - hintText: widget.remarks, - controller: remarksController, - maxLines: 7, - minLines: 4, - ), - ), - SizedBox( - height: 12.0, - ), - SizedBox( - height: MediaQuery.of(context).size.height * 0.12, - ), - Container( - margin: EdgeInsets.all( - SizeConfig.widthMultiplier * 2), - child: Wrap( - alignment: WrapAlignment.center, - children: [ - AppButton( - title: 'update prescription'.toUpperCase(), - onPressed: () { - updatePrescription( - newDoseStreangth: - strengthController.text.isNotEmpty - ? strengthController.text - : widget.doseStreangth, - newUnit: units != null - ? units['id'].toString() - : widget.doseUnit, - doseUnit: widget.doseUnit, - doseStreangth: widget.doseStreangth, - duration: widget.duration, - startDate: widget.startDate, - doseId: widget.dose, - frequencyId: widget.frequency, - routeId: widget.route, - patient: widget.patient, - model: widget.model, - newDuration: updatedDuration != null - ? updatedDuration['id'].toString() - : widget.duration, - drugId: widget.drugId, - remarks: remarksController.text, - route: route != null - ? route['id'].toString() - : widget.route, - frequency: frequencyUpdate != null - ? frequencyUpdate['id'].toString() - : widget.frequency, - dose: doseTime != null - ? doseTime['id'].toString() - : widget.dose, - enteredRemarks: - widget.enteredRemarks); - Navigator.pop(context); - }, + Container( + height: MediaQuery.of(context).size.height * + 0.070, + child: InkWell( + onTap: model.medicationDoseTimeList != null + ? () { + ListSelectDialog dialog = + ListSelectDialog( + list: + model.medicationDoseTimeList, + attributeName: 'nameEn', + attributeValueId: 'id', + okText: + TranslationBase.of(context) + .ok, + okFunction: (selectedValue) { + setState(() { + doseTime = selectedValue; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: TextField( + decoration: textFieldSelectorDecoration( + TranslationBase.of(context).doseTime, + doseTime != null + ? doseTime['nameEn'] + : null, + true), + enabled: false, + ), ), - ], - ), + ), + SizedBox( + height: 12.0, + ), + Container( + height: MediaQuery.of(context).size.height * + 0.070, + child: InkWell( + onTap: model.medicationFrequencyList != null + ? () { + ListSelectDialog dialog = + ListSelectDialog( + list: + model.medicationFrequencyList, + attributeName: 'nameEn', + attributeValueId: 'id', + okText: + TranslationBase.of(context) + .ok, + okFunction: (selectedValue) { + setState(() { + frequencyUpdate = + selectedValue; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: TextField( + decoration: textFieldSelectorDecoration( + TranslationBase.of(context).frequency, + frequencyUpdate != null + ? frequencyUpdate['nameEn'] + : null, + true), + enabled: false, + ), + ), + ), + SizedBox( + height: 12.0, + ), + Container( + height: MediaQuery.of(context).size.height * + 0.070, + child: InkWell( + onTap: model.medicationDurationList != null + ? () { + ListSelectDialog dialog = + ListSelectDialog( + list: + model.medicationDurationList, + attributeName: 'nameEn', + attributeValueId: 'id', + okText: + TranslationBase.of(context) + .ok, + okFunction: (selectedValue) { + setState(() { + updatedDuration = + selectedValue; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: TextField( + decoration: textFieldSelectorDecoration( + TranslationBase.of(context).duration, + updatedDuration != null + ? updatedDuration['nameEn'] + .toString() + : null, + true), + enabled: false, + ), + ), + ), + SizedBox( + height: 12.0, + ), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(6.0)), + border: Border.all( + width: 1.0, + color: HexColor("#CCCCCC"))), + child: TextFields( + hintText: widget.remarks, + controller: remarksController, + maxLines: 7, + minLines: 4, + ), + ), + SizedBox( + height: 12.0, + ), + SizedBox( + height: + MediaQuery.of(context).size.height * 0.12, + ), + Container( + margin: EdgeInsets.all( + SizeConfig.widthMultiplier * 2), + child: Wrap( + alignment: WrapAlignment.center, + children: [ + AppButton( + title: + 'update prescription'.toUpperCase(), + onPressed: () { + updatePrescription( + newDoseStreangth: + strengthController + .text.isNotEmpty + ? strengthController.text + : widget.doseStreangth, + newUnit: units != + null + ? units['id'].toString() + : widget.doseUnit, + doseUnit: widget.doseUnit, + doseStreangth: widget + .doseStreangth, + duration: widget.duration, + startDate: widget.startDate, + doseId: widget.dose, + frequencyId: widget.frequency, + routeId: widget.route, + patient: widget.patient, + model: widget.model, + newDuration: + updatedDuration != + null + ? updatedDuration[ + 'id'] + .toString() + : widget.duration, + drugId: widget.drugId, + remarks: remarksController.text, + route: route != + null + ? route['id'].toString() + : widget.route, + frequency: + frequencyUpdate != + null + ? frequencyUpdate['id'] + .toString() + : widget.frequency, + dose: doseTime != null + ? doseTime['id'].toString() + : widget.dose, + enteredRemarks: + widget.enteredRemarks); + Navigator.pop(context); + }, + ), + ], + ), + ), + ], ), ], ), - ], - ), - ), - )); - }); + ), + )); + }), + ), + ); }); } diff --git a/lib/screens/procedures/update-procedure.dart b/lib/screens/procedures/update-procedure.dart index 0b0a0c5a..8ed40dc3 100644 --- a/lib/screens/procedures/update-procedure.dart +++ b/lib/screens/procedures/update-procedure.dart @@ -2,14 +2,19 @@ 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/procedure/ControlsModel.dart'; +import 'package:doctor_app_flutter/core/model/procedure/categories_procedure.dart'; import 'package:doctor_app_flutter/core/model/procedure/update_procedure_request_model.dart'; import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart'; 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/screens/procedures/entity_list_checkbox_search_widget.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/TextFields.dart'; import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/dialogs/dailog-list-select.dart'; +import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; @@ -68,102 +73,189 @@ class _UpdateProcedureWidgetState extends State { }); } + List entityList = List(); + dynamic selectedCategory; @override Widget build(BuildContext context) { + final screenSize = MediaQuery.of(context).size; return StatefulBuilder(builder: (BuildContext context, StateSetter setState /*You can rename this!*/) { - return Container( - height: MediaQuery.of(context).size.height * 0.55, - child: Form( - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 10.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - widget.procedureName.toUpperCase(), - fontWeight: FontWeight.w700, - ), - SizedBox( - height: 30.0, - ), - Container( - child: Row( - children: [ - AppText(TranslationBase.of(context).orderType), - Radio( - activeColor: Color(0xFFB9382C), - value: 0, - groupValue: selectedType, - onChanged: (value) { - setSelectedType(value); - }, + return BaseView( + onModelReady: (model) => model.getCategory(), + builder: + (BuildContext context, ProcedureViewModel model, Widget child) => + NetworkBaseView( + baseViewModel: model, + child: Container( + height: MediaQuery.of(context).size.height * 0.95, + child: Form( + child: Padding( + padding: + EdgeInsets.symmetric(horizontal: 20.0, vertical: 10.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + widget.procedureName.toUpperCase(), + fontWeight: FontWeight.w700, + ), + SizedBox( + height: 30.0, + ), + Container( + height: screenSize.height * 0.070, + child: InkWell( + onTap: model.categoryList != null && + model.categoryList.length > 0 + ? () { + ListSelectDialog dialog = ListSelectDialog( + list: model.categoryList, + attributeName: 'categoryName', + attributeValueId: 'categoryId', + okText: TranslationBase.of(context).ok, + okFunction: (selectedValue) { + setState(() { + selectedCategory = selectedValue; + model.getProcedureCategory( + categoryName: selectedCategory[ + 'categoryName']); + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + //model.getProcedureCategory(); + } + : null, + child: TextField( + decoration: textFieldSelectorDecoration( + TranslationBase.of(context).procedureCategorise, + selectedCategory != null + ? selectedCategory['categoryName'] + : null, + true, + suffixIcon: Icon( + Icons.search, + color: Colors.black, + )), + enabled: false, + ), ), - Text(TranslationBase.of(context).urgent), - Radio( - activeColor: Color(0xFFB9382C), - groupValue: selectedType, - value: 1, - onChanged: (value) { - setSelectedType(value); - }, + ), + if (widget.model.categoriesList.length != 0) + NetworkBaseView( + baseViewModel: model, + child: EntityListCheckboxSearchWidget( + model: widget.model, + masterList: + widget.model.categoriesList[0].entityList, + removeHistory: (item) { + setState(() { + entityList.remove(item); + }); + }, + addHistory: (history) { + setState(() { + entityList.add(history); + }); + }, + addSelectedHistories: () { + //TODO build your fun herr + // widget.addSelectedHistories(); + }, + isEntityListSelected: (master) => + isEntityListSelected(master), + ), ), - Text(TranslationBase.of(context).regular), - ], - ), - ), - SizedBox( - height: 12.0, - ), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(6.0)), - border: - Border.all(width: 1.0, color: HexColor("#CCCCCC"))), - child: TextFields( - hintText: widget.remarks, - controller: widget.remarksController, - maxLines: 5, - minLines: 3, - ), - ), - SizedBox( - height: 100.0, - ), - Container( - margin: EdgeInsets.all(SizeConfig.widthMultiplier * 2), - child: Wrap( - alignment: WrapAlignment.center, - children: [ - AppButton( - title: TranslationBase.of(context) - .updateProcedure - .toUpperCase(), - onPressed: () { - Navigator.pop(context); - updateProcedure( - orderType: selectedType.toString(), - categorieId: widget.categoryId, - procedureId: widget.procedureId, - patient: widget.patient, - model: widget.model, - remarks: widget.remarksController.text); - // authorizationForm(context); - }, + Container( + child: Row( + children: [ + AppText(TranslationBase.of(context).orderType), + Radio( + activeColor: Color(0xFFB9382C), + value: 0, + groupValue: selectedType, + onChanged: (value) { + setSelectedType(value); + }, + ), + Text(TranslationBase.of(context).urgent), + Radio( + activeColor: Color(0xFFB9382C), + groupValue: selectedType, + value: 1, + onChanged: (value) { + setSelectedType(value); + }, + ), + Text(TranslationBase.of(context).regular), + ], + ), + ), + SizedBox( + height: 12.0, + ), + Container( + decoration: BoxDecoration( + borderRadius: + BorderRadius.all(Radius.circular(6.0)), + border: Border.all( + width: 1.0, color: HexColor("#CCCCCC"))), + child: TextFields( + hintText: widget.remarks, + controller: widget.remarksController, + maxLines: 5, + minLines: 3, + ), + ), + SizedBox( + height: 50.0, + ), + Container( + margin: EdgeInsets.all(SizeConfig.widthMultiplier * 2), + child: Wrap( + alignment: WrapAlignment.center, + children: [ + AppButton( + title: TranslationBase.of(context) + .updateProcedure + .toUpperCase(), + onPressed: () { + Navigator.pop(context); + updateProcedure( + orderType: selectedType.toString(), + categorieId: widget.categoryId, + procedureId: widget.procedureId, + entityList: entityList, + patient: widget.patient, + model: widget.model, + remarks: widget.remarksController.text); + // authorizationForm(context); + }, + ), + ], ), - ], - ), + ), + ], ), - ], - ), - ), - )); + ), + )), + ), + ); }); } updateProcedure( {ProcedureViewModel model, String remarks, + String newProcedureId, + String newCategorieId, + List entityList, String orderType, String procedureId, PatiantInformtion patient, @@ -187,10 +279,15 @@ class _UpdateProcedureWidgetState extends State { Controls(code: "ordertype", controlValue: "1"), ); - controlsProcedure.procedure = procedureId; + entityList.isNotEmpty + ? entityList.forEach((element) { + controlsProcedure.procedure = element.procedureId; + controlsProcedure.category = element.categoryID; + controlsProcedure.controls = controls; + }) + : controlsProcedure.procedure = procedureId; controlsProcedure.category = categorieId; controlsProcedure.controls = controls; - // controlsProcedure.add(ProcedureDetail( // category: categorieId, procedure: procedureId, controls: controls)); updateProcedureReqModel.procedureDetail = controlsProcedure; @@ -206,4 +303,45 @@ class _UpdateProcedureWidgetState extends State { DrAppToastMsg.showSuccesToast('procedure has been updated'); } } + + bool isEntityListSelected(EntityList masterKey) { + Iterable history = entityList + .where((element) => masterKey.procedureId == element.procedureId); + if (history.length > 0) { + return true; + } + return false; + } + + InputDecoration textFieldSelectorDecoration( + String hintText, String selectedText, bool isDropDown, + {Icon suffixIcon}) { + return InputDecoration( + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), + borderRadius: BorderRadius.circular(8), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), + borderRadius: BorderRadius.circular(8), + ), + disabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), + borderRadius: BorderRadius.circular(8), + ), + hintText: selectedText != null ? selectedText : hintText, + suffixIcon: isDropDown + ? suffixIcon != null + ? suffixIcon + : Icon( + Icons.arrow_drop_down, + color: Colors.black, + ) + : null, + hintStyle: TextStyle( + fontSize: 14, + color: Colors.grey.shade600, + ), + ); + } } From d78aa2321d48ed35624a0f5e244f9df17cb7bce4 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Tue, 2 Feb 2021 14:04:20 +0200 Subject: [PATCH 6/6] bug fix --- lib/core/enum/master_lookup_key.dart | 2 +- lib/core/service/base/lookup-service.dart | 2 +- pubspec.lock | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/core/enum/master_lookup_key.dart b/lib/core/enum/master_lookup_key.dart index 7cb6f1cf..889be9a7 100644 --- a/lib/core/enum/master_lookup_key.dart +++ b/lib/core/enum/master_lookup_key.dart @@ -19,7 +19,7 @@ enum MasterKeysService { MedicationFrequency, MedicationDoseTime, MedicationIndications, - Speciality, + AdmissionRequestType, } diff --git a/lib/core/service/base/lookup-service.dart b/lib/core/service/base/lookup-service.dart index 774cd4ad..0c361003 100644 --- a/lib/core/service/base/lookup-service.dart +++ b/lib/core/service/base/lookup-service.dart @@ -44,7 +44,7 @@ class LookupService extends BaseService { List listOfICD10 = []; List listOfTemperatureMethods = []; List listOfSpeciality = []; - List listOfAdmissionType = []; + List listOfAdmissionType = []; Future getMasterLookup(MasterKeysService masterKeys) async { hasError = false; diff --git a/pubspec.lock b/pubspec.lock index e51c9489..31666673 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -510,7 +510,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: @@ -552,7 +552,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: @@ -823,7 +823,7 @@ packages: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.1" + version: "1.10.0-nullsafety.2" stream_channel: dependency: transitive description: @@ -958,5 +958,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"