diff --git a/lib/core/service/prescription_service.dart b/lib/core/service/prescription_service.dart index d5503932..0e52b16c 100644 --- a/lib/core/service/prescription_service.dart +++ b/lib/core/service/prescription_service.dart @@ -48,7 +48,9 @@ class PrescriptionService extends BaseService { }, body: _prescriptionReqModel.toJson()); } - Future getDrugs() async { + Future getDrugs({String drugName}) async { + _drugRequestModel = SearchDrugRequestModel(search: [drugName]); + hasError = false; await baseAppClient.post(SEARCH_DRUG, diff --git a/lib/core/viewModel/prescription_view_model.dart b/lib/core/viewModel/prescription_view_model.dart index e7da4385..467a715c 100644 --- a/lib/core/viewModel/prescription_view_model.dart +++ b/lib/core/viewModel/prescription_view_model.dart @@ -61,11 +61,11 @@ class PrescriptionViewModel extends BaseViewModel { } } - Future getDrugs() async { + Future getDrugs({String drugName}) async { hasError = false; //_insuranceCardService.clearInsuranceCard(); - setState(ViewState.Busy); - await _prescriptionService.getDrugs(); + setState(ViewState.BusyLocal); + await _prescriptionService.getDrugs(drugName: drugName); if (_prescriptionService.hasError) { error = _prescriptionService.error; setState(ViewState.ErrorLocal); diff --git a/lib/core/viewModel/procedure_View_model.dart b/lib/core/viewModel/procedure_View_model.dart index 5e1d8d0c..fb84f505 100644 --- a/lib/core/viewModel/procedure_View_model.dart +++ b/lib/core/viewModel/procedure_View_model.dart @@ -68,7 +68,7 @@ class ProcedureViewModel extends BaseViewModel { } Future updateProcedure( - PostProcedureReqModel postProcedureReqModel, int mrn) async { + {PostProcedureReqModel postProcedureReqModel, int mrn}) async { hasError = false; //_insuranceCardService.clearInsuranceCard(); setState(ViewState.Busy); diff --git a/lib/models/patient/patiant_info_model.dart b/lib/models/patient/patiant_info_model.dart index f7c4b0a2..3547a73d 100644 --- a/lib/models/patient/patiant_info_model.dart +++ b/lib/models/patient/patiant_info_model.dart @@ -42,6 +42,7 @@ class PatiantInformtion { int patientMRN; String admissionNo; String admissionDate; + String createdOn; String roomId; String bedId; String nursingStationId; @@ -77,6 +78,7 @@ class PatiantInformtion { this.patientType, this.admissionNo, this.admissionDate, + this.createdOn, this.roomId, this.bedId, this.nursingStationId, @@ -129,6 +131,7 @@ class PatiantInformtion { patientType: json["PatientType"]?? json["patientType"], admissionNo: json["AdmissionNo"]?? json["admissionNo"], admissionDate: json["AdmissionDate"]?? json["admissionDate"], + createdOn: json["CreatedOn"]?? json["CreatedOn"], roomId: json["RoomID"]?? json["roomID"], bedId: json["BedID"]?? json["bedID"], nursingStationId: json["NursingStationID"]?? json["nursingStationID"], @@ -158,10 +161,4 @@ class PatiantInformtion { patientMRN :json['patientMRN'] ?? json['PatientMRN'], ); - - - - - - } diff --git a/lib/screens/prescription/add_prescription_form.dart b/lib/screens/prescription/add_prescription_form.dart index d708186e..e93e1f3f 100644 --- a/lib/screens/prescription/add_prescription_form.dart +++ b/lib/screens/prescription/add_prescription_form.dart @@ -21,6 +21,7 @@ import 'package:doctor_app_flutter/widgets/shared/app_buttons_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/loader/gif_loader_dialog_utils.dart'; import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; @@ -107,6 +108,12 @@ class _PrescriptionFormWidgetState extends State { TextEditingController drugIdController = TextEditingController(); TextEditingController doseController = TextEditingController(); + final searchController = TextEditingController(); + + var notesList; + var filteredNotesList; + String textSeartch = "Amoxicillin"; + final GlobalKey formKey = GlobalKey(); final double spaceBetweenTextFileds = 12; List referToList; @@ -165,6 +172,24 @@ class _PrescriptionFormWidgetState extends State { 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": 1, "name": "2 Times a day"}; dynamic frequency2 = {"id": 2, "name": "3 Times a day"}; dynamic frequency3 = {"id": 3, "name": "4 Times a day"}; @@ -258,6 +283,24 @@ class _PrescriptionFormWidgetState extends State { 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); @@ -295,12 +338,13 @@ class _PrescriptionFormWidgetState extends State { @override Widget build(BuildContext context) { + ListSelectDialog drugDialog; final screenSize = MediaQuery.of(context).size; // final routeArgs = ModalRoute.of(context).settings.arguments as Map; // patient = routeArgs['patient']; return BaseView( - onModelReady: (model) => model.getDrugs(), + onModelReady: (model) => model.getDrugs(drugName: textSeartch), builder: (BuildContext context, PrescriptionViewModel model, Widget child) => NetworkBaseView( @@ -339,7 +383,7 @@ class _PrescriptionFormWidgetState extends State { onTap: model.drugsList != null && model.drugsList.length > 0 ? () { - ListSelectDialog dialog = + return drugDialog = ListSelectDialog( list: model.drugsList, attributeName: 'GenericName', @@ -352,17 +396,121 @@ class _PrescriptionFormWidgetState extends State { selectedDrug = selectedValue; }); }, + /* searchWidget: Row( + children: [ + Expanded( + child: TextField( + decoration: Helpers + .textFieldSelectorDecoration( + TranslationBase.of( + context) + .search, + searchController.text != + null && + searchController + .text != + "" + ? searchController + .text + : null, + false, + ), + onChanged: (String str) { + textSeartch = str; + }, + controller: + searchController, + enabled: true, + ), + ), + Container( + child: InkWell( + child: Icon( + Icons.search, + color: Colors.black, + ), + onTap: () async { + Navigator.of(context) + .pop(); + await searchMedicine( + context, + model, + textSeartch); + showDialog( + barrierDismissible: + false, + context: context, + builder: (BuildContext + context) { + return drugDialog; + }, + ); + }, + ), + margin: + EdgeInsets.symmetric( + horizontal: 8), + ) + ], + ),*/ ); showDialog( barrierDismissible: false, context: context, builder: (BuildContext context) { - return dialog; + return drugDialog; }, ); } : null, - child: TextField( + child: Row( + children: [ + Expanded( + child: TextField( + decoration: Helpers + .textFieldSelectorDecoration( + TranslationBase.of(context) + .search, + searchController.text != null && + searchController.text != + "" + ? searchController.text + : null, + false, + ), + onChanged: (String str) { + textSeartch = str; + }, + controller: searchController, + enabled: true, + ), + ), + Container( + child: InkWell( + child: Icon( + Icons.search, + color: Colors.black, + ), + onTap: () async { + // Navigator.of(context) + // .pop(); + await searchMedicine( + context, model, textSeartch); + showDialog( + barrierDismissible: false, + context: context, + builder: + (BuildContext context) { + return drugDialog; + }, + ); + }, + ), + margin: EdgeInsets.symmetric( + horizontal: 8), + ) + ], + ), /*TextField( decoration: textFieldSelectorDecoration( TranslationBase.of(context) .searchMedicine, @@ -374,8 +522,8 @@ class _PrescriptionFormWidgetState extends State { Icons.search, color: Colors.black, )), - enabled: false, - ), + enabled: true, + ),*/ ), ), SizedBox( @@ -945,4 +1093,41 @@ class _PrescriptionFormWidgetState extends State { ); }); } + + // searchData(String str, PrescriptionViewModel model) { + // var strExist = str.length > 0 ? true : false; + // + // if (strExist) { + // filteredNotesList = null; + // filteredNotesList = model.drugsList + // .where((note) => + // note["GenericName"].toString().contains(str.toUpperCase())) + // .toList(); + // setState(() { + // notesList = filteredNotesList; + // }); + // } else { + // setState(() { + // notesList = model.drugsList; + // }); + // } + // } + + searchMedicine(context, PrescriptionViewModel model, String str) async { + FocusScope.of(context).unfocus(); + // if (searchController.text.isEmpty()) { + // helpers.showErrorToast(TranslationBase.of(context).typeMedicineName); + // //"Type Medicine Name") + // return; + // } + if (searchController.text.length < 0) { + helpers.showErrorToast(TranslationBase.of(context).moreThan3Letter); + return; + } + + GifLoaderDialogUtils.showMyDialog(context); + + await model.getDrugs(drugName: searchController.text); + GifLoaderDialogUtils.hideDialog(context); + } } diff --git a/lib/screens/prescription/prescription_screen.dart b/lib/screens/prescription/prescription_screen.dart index c1f00092..4d000838 100644 --- a/lib/screens/prescription/prescription_screen.dart +++ b/lib/screens/prescription/prescription_screen.dart @@ -9,6 +9,7 @@ import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/prescription/add_prescription_form.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_profile_widget.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/profile_medical_info_widget.dart'; @@ -337,7 +338,25 @@ class _NewPrescriptionScreenState extends State { child: Column( children: [ AppText( - '8\nDEC', + DateTime.parse(model + .prescriptionList[ + 0] + .entityList[ + index] + .startDate) + .day + .toString(), + color: Colors + .green, + ), + AppText( + Helpers.getMonth(model.prescriptionList[0].entityList[index].startDate != + null + ? (DateTime.parse(model.prescriptionList[0].entityList[index].startDate) + .month) + : DateTime.now() + .month) + .toUpperCase(), color: Colors .green, ) diff --git a/lib/screens/procedures/procedure_screen.dart b/lib/screens/procedures/procedure_screen.dart index 667bcc6d..5483ffd9 100644 --- a/lib/screens/procedures/procedure_screen.dart +++ b/lib/screens/procedures/procedure_screen.dart @@ -11,6 +11,7 @@ import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/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/helpers.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/patient_profile_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/Text.dart'; @@ -271,7 +272,36 @@ class _ProcedureScreenState extends State { child: Column( children: [ AppText( - '8\nDEC', + DateTime.parse(model + .procedureList[ + 0] + .entityList[ + index] + .orderDate) + .day + .toString(), + color: + Colors.green, + ), + AppText( + Helpers.getMonth(model + .procedureList[ + 0] + .entityList[ + index] + .orderDate != + null + ? (DateTime.parse(model + .procedureList[ + 0] + .entityList[ + index] + .orderDate) + .month) + : DateTime + .now() + .month) + .toUpperCase(), color: Colors.green, ) @@ -421,6 +451,8 @@ class _ProcedureScreenState extends State { child: Icon( Icons.edit), onTap: () { + // model + // .updateProcedure(); updateProcedureForm( context, remarks: model @@ -691,7 +723,8 @@ updateProcedure( category: categorieId, procedure: procedureId, controls: controls)); updateProcedureReqModel.procedures = controlsProcedure; - await model.updateProcedure(updateProcedureReqModel, patient.patientMRN); + await model.updateProcedure( + postProcedureReqModel: updateProcedureReqModel, mrn: patient.patientMRN); if (model.state == ViewState.ErrorLocal) { helpers.showErrorToast(model.error); diff --git a/lib/widgets/patients/profile/patient_profile_widget.dart b/lib/widgets/patients/profile/patient_profile_widget.dart index bab7cc84..248d0dd2 100644 --- a/lib/widgets/patients/profile/patient_profile_widget.dart +++ b/lib/widgets/patients/profile/patient_profile_widget.dart @@ -254,8 +254,8 @@ class PatientProfileWidget extends StatelessWidget { ), Expanded( child: AppText( - patient.admissionDate != null - ? "${DateUtils.convertDateFromServerFormat(patient.admissionDate, 'EEEE dd, MMMM yyyy hh:mm a')}" + patient.createdOn != null + ? "${DateUtils.convertDateFromServerFormat(patient.createdOn, 'EEEE dd, MMMM yyyy hh:mm a')}" : "", color: Colors.black, fontWeight: FontWeight.normal, @@ -310,10 +310,10 @@ class PatientProfileWidget extends StatelessWidget { ), ), AppText( - patient.admissionDate != null + patient.createdOn != null ? DateUtils .differenceBetweenServerDateAndCurrent( - patient.admissionDate) + patient.createdOn) : "", color: Colors.black, fontWeight: FontWeight.normal, diff --git a/lib/widgets/patients/profile/profile_medical_info_widget.dart b/lib/widgets/patients/profile/profile_medical_info_widget.dart index 27b38ee2..e839a0b9 100644 --- a/lib/widgets/patients/profile/profile_medical_info_widget.dart +++ b/lib/widgets/patients/profile/profile_medical_info_widget.dart @@ -116,20 +116,22 @@ class ProfileMedicalInfoWidget extends StatelessWidget { nameLine1: TranslationBase.of(context).admission, nameLine2: TranslationBase.of(context).request, icon: 'heartbeat.png'), - PatientProfileButton( - key: key, - patient: patient, - route: ORDER_PRESCRIPTION, - nameLine1: TranslationBase.of(context).orders, - nameLine2: TranslationBase.of(context).prescription, - icon: 'lab.png'), - PatientProfileButton( - key: key, - patient: patient, - route: ORDER_PROCEDURE, - nameLine1: TranslationBase.of(context).orders, - nameLine2: TranslationBase.of(context).procedures, - icon: 'lab.png'), + if (int.parse(patientType) == 7 || int.parse(patientType) == 6) + PatientProfileButton( + key: key, + patient: patient, + route: ORDER_PRESCRIPTION, + nameLine1: TranslationBase.of(context).orders, + nameLine2: TranslationBase.of(context).prescription, + icon: 'lab.png'), + if (int.parse(patientType) == 7 || int.parse(patientType) == 6) + PatientProfileButton( + key: key, + patient: patient, + route: ORDER_PROCEDURE, + nameLine1: TranslationBase.of(context).orders, + nameLine2: TranslationBase.of(context).procedures, + icon: 'lab.png'), if (int.parse(patientType) == 7 || int.parse(patientType) == 6) PatientProfileButton( key: key, diff --git a/lib/widgets/shared/dialogs/dailog-list-select.dart b/lib/widgets/shared/dialogs/dailog-list-select.dart index 68dce5a4..fa33a72d 100644 --- a/lib/widgets/shared/dialogs/dailog-list-select.dart +++ b/lib/widgets/shared/dialogs/dailog-list-select.dart @@ -1,3 +1,6 @@ +import 'package:doctor_app_flutter/client/base_app_client.dart'; +import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; +import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:flutter/material.dart'; @@ -8,13 +11,15 @@ class ListSelectDialog extends StatefulWidget { final okText; final Function(dynamic) okFunction; dynamic selectedValue; + final Widget searchWidget; ListSelectDialog( {@required this.list, @required this.attributeName, @required this.attributeValueId, @required this.okText, - @required this.okFunction}); + @required this.okFunction, + this.searchWidget}); @override _ListSelectDialogState createState() => _ListSelectDialogState(); @@ -63,6 +68,7 @@ class _ListSelectDialogState extends State { child: SingleChildScrollView( child: Column( children: [ + if (widget.searchWidget != null) widget.searchWidget, ...widget.list .map((item) => RadioListTile( title: Text("${item[widget.attributeName].toString()}"), diff --git a/lib/widgets/shared/dialogs/search-drugs-dailog-list.dart b/lib/widgets/shared/dialogs/search-drugs-dailog-list.dart new file mode 100644 index 00000000..68dce5a4 --- /dev/null +++ b/lib/widgets/shared/dialogs/search-drugs-dailog-list.dart @@ -0,0 +1,92 @@ +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:flutter/material.dart'; + +class ListSelectDialog extends StatefulWidget { + final List list; + final String attributeName; + final String attributeValueId; + final okText; + final Function(dynamic) okFunction; + dynamic selectedValue; + + ListSelectDialog( + {@required this.list, + @required this.attributeName, + @required this.attributeValueId, + @required this.okText, + @required this.okFunction}); + + @override + _ListSelectDialogState createState() => _ListSelectDialogState(); +} + +class _ListSelectDialogState extends State { + @override + void initState() { + super.initState(); + widget.selectedValue = widget.selectedValue ?? widget.list[0]; + } + + @override + Widget build(BuildContext context) { + return showAlertDialog(context); + } + + showAlertDialog(BuildContext context) { + // set up the buttons + Widget cancelButton = FlatButton( + child: Text(TranslationBase.of(context).cancel), + onPressed: () { + Navigator.of(context).pop(); + }); + Widget continueButton = FlatButton( + child: Text(this.widget.okText), + onPressed: () { + this.widget.okFunction(widget.selectedValue); + Navigator.of(context).pop(); + }); +// set up the AlertDialog + AlertDialog alert = AlertDialog( + // title: Text(widget.title), + content: createDialogList(), + actions: [ + cancelButton, + continueButton, + ], + ); + return alert; + } + + Widget createDialogList() { + return Container( + height: MediaQuery.of(context).size.height * 0.5, + child: SingleChildScrollView( + child: Column( + children: [ + ...widget.list + .map((item) => RadioListTile( + title: Text("${item[widget.attributeName].toString()}"), + groupValue: widget.selectedValue[widget.attributeValueId] + .toString(), + value: item[widget.attributeValueId].toString(), + activeColor: Colors.blue.shade700, + selected: item[widget.attributeValueId].toString() == + widget.selectedValue[widget.attributeValueId] + .toString(), + onChanged: (val) { + setState(() { + widget.selectedValue = item; + }); + }, + )) + .toList() + ], + ), + ), + ); + } + + static closeAlertDialog(BuildContext context) { + Navigator.of(context).pop(); + } +}