diff --git a/lib/config/config.dart b/lib/config/config.dart index 6e7089c3..704dc7da 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -207,6 +207,9 @@ const POST_ADMISSION_REQUEST = const GET_ITEM_BY_MEDICINE = 'Services/DoctorApplication.svc/REST/GetItemByMedicineCode'; +const GET_PROCEDURE_VALIDATION = + 'Services/DoctorApplication.svc/REST/ValidateProcedures'; + var selectedPatientType = 1; //*********change value to decode json from Dropdown ************ diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index f9f7d6b6..882de2e4 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -738,4 +738,5 @@ const Map> localizedValues = { 'en': "A Sick leave is on Hold status for this patient", 'ar': "الإجازة المرضية في حالة الانتظار لهذا المريض" }, + 'no-clinic': {'en': "No Clinic", 'ar': "لا عيادة"} }; diff --git a/lib/core/model/prescription_model.dart b/lib/core/model/prescription_model.dart index 49001673..2806f861 100644 --- a/lib/core/model/prescription_model.dart +++ b/lib/core/model/prescription_model.dart @@ -58,6 +58,7 @@ class EntityList { dynamic stopDate; dynamic uom; dynamic pharmacistRemarks; + dynamic pharmacyInervention; dynamic refill; EntityList( @@ -91,7 +92,8 @@ class EntityList { this.stopDate, this.uom, this.pharmacistRemarks, - this.refill}); + this.refill, + this.pharmacyInervention}); EntityList.fromJson(Map json) { appointmentNo = json['appointmentNo']; @@ -125,6 +127,7 @@ class EntityList { uom = json['uom']; pharmacistRemarks = json['pharmacistRemarks']; refill = json['refill']; + pharmacyInervention = json['interventionID']; } Map toJson() { @@ -160,6 +163,8 @@ class EntityList { data['uom'] = this.uom; data['pharmacistRemarks'] = this.pharmacistRemarks; data['refill'] = this.refill; + data['interventionID'] = this.pharmacyInervention; + return data; } } diff --git a/lib/core/model/procedure/procedure_valadate_model.dart b/lib/core/model/procedure/procedure_valadate_model.dart new file mode 100644 index 00000000..3a3e23cf --- /dev/null +++ b/lib/core/model/procedure/procedure_valadate_model.dart @@ -0,0 +1,51 @@ +class ProcedureValadteModel { + List entityList; + int rowcount; + dynamic statusMessage; + dynamic success; + + ProcedureValadteModel( + {this.entityList, this.rowcount, this.statusMessage, this.success}); + + ProcedureValadteModel.fromJson(Map json) { + if (json['entityList'] != null) { + entityList = new List(); + json['entityList'].forEach((v) { + entityList.add(new EntityList.fromJson(v)); + }); + } + rowcount = json['rowcount']; + statusMessage = json['statusMessage']; + success = json['success']; + } + + Map toJson() { + final Map data = new Map(); + if (this.entityList != null) { + data['entityList'] = this.entityList.map((v) => v.toJson()).toList(); + } + data['rowcount'] = this.rowcount; + data['statusMessage'] = this.statusMessage; + data['success'] = this.success; + return data; + } +} + +class EntityList { + String procedureId; + List warringMessages; + + EntityList({this.procedureId, this.warringMessages}); + + EntityList.fromJson(Map json) { + procedureId = json['procedureId']; + warringMessages = json['warringMessages'].cast(); + } + + Map toJson() { + final Map data = new Map(); + data['procedureId'] = this.procedureId; + data['warringMessages'] = this.warringMessages; + return data; + } +} diff --git a/lib/core/model/procedure/procedure_valadate_request_model.dart b/lib/core/model/procedure/procedure_valadate_request_model.dart new file mode 100644 index 00000000..0b872b93 --- /dev/null +++ b/lib/core/model/procedure/procedure_valadate_request_model.dart @@ -0,0 +1,32 @@ +class ProcedureValadteRequestModel { + String vidaAuthTokenID; + int patientMRN; + int appointmentNo; + int episodeID; + List procedure; + + ProcedureValadteRequestModel( + {this.vidaAuthTokenID, + this.patientMRN, + this.appointmentNo, + this.episodeID, + this.procedure}); + + ProcedureValadteRequestModel.fromJson(Map json) { + vidaAuthTokenID = json['VidaAuthTokenID']; + patientMRN = json['PatientMRN']; + appointmentNo = json['AppointmentNo']; + episodeID = json['EpisodeID']; + procedure = json['Procedure'].cast(); + } + + Map toJson() { + final Map data = new Map(); + data['VidaAuthTokenID'] = this.vidaAuthTokenID; + data['PatientMRN'] = this.patientMRN; + data['AppointmentNo'] = this.appointmentNo; + data['EpisodeID'] = this.episodeID; + data['Procedure'] = this.procedure; + return data; + } +} diff --git a/lib/core/service/procedure_service.dart b/lib/core/service/procedure_service.dart index 98b1f36d..10b66d94 100644 --- a/lib/core/service/procedure_service.dart +++ b/lib/core/service/procedure_service.dart @@ -5,6 +5,8 @@ import 'package:doctor_app_flutter/core/model/procedure/get_ordered_procedure_re import 'package:doctor_app_flutter/core/model/procedure/get_procedure_model.dart'; import 'package:doctor_app_flutter/core/model/procedure/get_procedure_req_model.dart'; import 'package:doctor_app_flutter/core/model/procedure/post_procedure_req_model.dart'; +import 'package:doctor_app_flutter/core/model/procedure/procedure_valadate_model.dart'; +import 'package:doctor_app_flutter/core/model/procedure/procedure_valadate_request_model.dart'; import 'package:doctor_app_flutter/core/model/procedure/update_procedure_request_model.dart'; import 'package:doctor_app_flutter/core/service/base/base_service.dart'; @@ -13,6 +15,8 @@ import 'package:flutter/foundation.dart'; class ProcedureService extends BaseService { List _procedureList = List(); List get procedureList => _procedureList; + List _valadteProcedureList = List(); + List get valadteProcedureList => _valadteProcedureList; List _categoriesList = List(); List get categoriesList => _categoriesList; List procedureslist = List(); @@ -118,4 +122,18 @@ class ProcedureService extends BaseService { super.error = error; }, body: updateProcedureRequestModel.toJson()); } + + Future valadteProcedure( + ProcedureValadteRequestModel procedureValadteRequestModel) async { + hasError = false; + _valadteProcedureList.clear(); + await baseAppClient.post(GET_PROCEDURE_VALIDATION, + onSuccess: (dynamic response, int statusCode) { + _valadteProcedureList.add( + ProcedureValadteModel.fromJson(response['ValidateProcedureList'])); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: procedureValadteRequestModel.toJson()); + } } diff --git a/lib/core/viewModel/procedure_View_model.dart b/lib/core/viewModel/procedure_View_model.dart index a753052c..199fa308 100644 --- a/lib/core/viewModel/procedure_View_model.dart +++ b/lib/core/viewModel/procedure_View_model.dart @@ -3,6 +3,8 @@ import 'package:doctor_app_flutter/core/model/procedure/categories_procedure.dar import 'package:doctor_app_flutter/core/model/procedure/get_ordered_procedure_model.dart'; import 'package:doctor_app_flutter/core/model/procedure/get_procedure_model.dart'; import 'package:doctor_app_flutter/core/model/procedure/post_procedure_req_model.dart'; +import 'package:doctor_app_flutter/core/model/procedure/procedure_valadate_model.dart'; +import 'package:doctor_app_flutter/core/model/procedure/procedure_valadate_request_model.dart'; import 'package:doctor_app_flutter/core/model/procedure/update_procedure_request_model.dart'; import 'package:doctor_app_flutter/core/service/procedure_service.dart'; import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart'; @@ -13,6 +15,8 @@ class ProcedureViewModel extends BaseViewModel { ProcedureService _procedureService = locator(); List get procedureList => _procedureService.procedureList; + List get valadteProcedureList => + _procedureService.valadteProcedureList; List get categoriesList => _procedureService.categoriesList; List get categoryList => _procedureService.categoryList; @@ -69,6 +73,20 @@ class ProcedureViewModel extends BaseViewModel { } } + Future valadteProcedure( + ProcedureValadteRequestModel procedureValadteRequestModel) async { + hasError = false; + //_insuranceCardService.clearInsuranceCard(); + setState(ViewState.Busy); + await _procedureService.valadteProcedure(procedureValadteRequestModel); + if (_procedureService.hasError) { + error = _procedureService.error; + setState(ViewState.ErrorLocal); + } else { + setState(ViewState.Idle); + } + } + Future updateProcedure( {UpdateProcedureRequestModel updateProcedureRequestModel, int mrn}) async { diff --git a/lib/screens/dashboard_screen.dart b/lib/screens/dashboard_screen.dart index d2369e9d..fbbe6d53 100644 --- a/lib/screens/dashboard_screen.dart +++ b/lib/screens/dashboard_screen.dart @@ -62,7 +62,7 @@ class _DashboardScreenState extends State { bool isExpanded = false; String isInpatient = ""; var clinicName = []; - var clinicId = 1; + var clinicId; void didChangeDependencies() async { super.didChangeDependencies(); if (_isInit) { @@ -144,43 +144,50 @@ class _DashboardScreenState extends State { Container( width: MediaQuery.of(context).size.width * .6, // height: 100, - child: DropdownButtonHideUnderline( - child: DropdownButton( - dropdownColor: Colors.white, - iconEnabledColor: Colors.white, - isExpanded: true, - value: clinicId, - iconSize: 25, - elevation: 16, - selectedItemBuilder: (BuildContext context) { - return projectsProvider.doctorClinicsList - .map((item) { - return Row( - mainAxisSize: MainAxisSize.max, - children: [ - AppText( - item.clinicName, - fontSize: SizeConfig.textMultiplier * 2.1, - color: Colors.white, - ), - ], - ); - }).toList(); - }, - onChanged: (newValue) { - clinicId = newValue; - changeClinic(newValue, context); - }, - items: projectsProvider.doctorClinicsList.map((item) { - return DropdownMenuItem( - child: Text( - item.clinicName, - textAlign: TextAlign.end, - ), - value: item.clinicID, - ); - }).toList(), - )), + child: projectsProvider.doctorClinicsList.length > 0 + ? DropdownButtonHideUnderline( + child: DropdownButton( + dropdownColor: Colors.white, + iconEnabledColor: Colors.white, + isExpanded: true, + value: clinicId == null + ? projectsProvider + .doctorClinicsList[0].clinicID + : clinicId, + iconSize: 25, + elevation: 16, + selectedItemBuilder: (BuildContext context) { + return projectsProvider.doctorClinicsList + .map((item) { + return Row( + mainAxisSize: MainAxisSize.max, + children: [ + AppText( + item.clinicName, + fontSize: + SizeConfig.textMultiplier * 2.1, + color: Colors.white, + ), + ], + ); + }).toList(); + }, + onChanged: (newValue) { + clinicId = newValue; + changeClinic(newValue, context); + }, + items: projectsProvider.doctorClinicsList + .map((item) { + return DropdownMenuItem( + child: Text( + item.clinicName, + textAlign: TextAlign.end, + ), + value: item.clinicID, + ); + }).toList(), + )) + : AppText(TranslationBase.of(context).noClinic), ), ), // InkWell( diff --git a/lib/screens/prescription/prescription_screen.dart b/lib/screens/prescription/prescription_screen.dart index 4800c361..9e3a5f04 100644 --- a/lib/screens/prescription/prescription_screen.dart +++ b/lib/screens/prescription/prescription_screen.dart @@ -10,6 +10,7 @@ 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/network_base_view.dart'; import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; class NewPrescriptionScreen extends StatefulWidget { @override @@ -244,6 +245,17 @@ class _NewPrescriptionScreenState extends State { color: Colors .green, ), + AppText( + Helpers.getTimeFormated(DateTime.parse(model + .prescriptionList[ + 0] + .entityList[ + index] + .createdOn)) + .toString(), + color: Colors + .green, + ), ], ), ), @@ -273,14 +285,10 @@ class _NewPrescriptionScreenState extends State { Expanded( child: AppText( - model - .prescriptionList[ - 0] - .entityList[ - index] - .startDate - .replaceAll("-", - "/"), + Helpers.getDateFormatted(DateTime.parse(model + .prescriptionList[0] + .entityList[index] + .startDate)), fontSize: 12.0, ), @@ -381,6 +389,87 @@ class _NewPrescriptionScreenState extends State { ), ], ), + Row( + children: [ + AppText( + 'UOM: ', + fontWeight: + FontWeight + .w700, + fontSize: + 17.0, + ), + Expanded( + child: + RichText( + maxLines: + 3, + overflow: + TextOverflow.ellipsis, + strutStyle: + StrutStyle(fontSize: 12.0), + text: TextSpan( + style: + TextStyle(color: Colors.black), + text: model.prescriptionList[0].entityList[index].uom), + ), + ), + ], + ), + Row( + children: [ + AppText( + 'BOX Quantity: ', + fontWeight: + FontWeight + .w700, + fontSize: + 17.0, + ), + Expanded( + child: + RichText( + maxLines: + 3, + overflow: + TextOverflow.ellipsis, + strutStyle: + StrutStyle(fontSize: 12.0), + text: TextSpan( + style: + TextStyle(color: Colors.black), + text: model.prescriptionList[0].entityList[index].quantity.toString() == null ? "" : model.prescriptionList[0].entityList[index].quantity.toString()), + ), + ), + ], + ), + Row( + children: [ + AppText( + 'pharmacy Intervention ', + fontWeight: + FontWeight + .w700, + fontSize: + 17.0, + ), + Expanded( + child: + RichText( + maxLines: + 3, + overflow: + TextOverflow.ellipsis, + strutStyle: + StrutStyle(fontSize: 12.0), + text: TextSpan( + style: + TextStyle(color: Colors.black), + text: model.prescriptionList[0].entityList[index].pharmacyInervention.toString() == null ? "" : model.prescriptionList[0].entityList[index].pharmacyInervention.toString()), + ), + ), + ], + ), SizedBox( height: 5.0), diff --git a/lib/screens/procedures/add-procedure-form.dart b/lib/screens/procedures/add-procedure-form.dart index 346de2db..071b4000 100644 --- a/lib/screens/procedures/add-procedure-form.dart +++ b/lib/screens/procedures/add-procedure-form.dart @@ -4,6 +4,7 @@ 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/procedure_valadate_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'; @@ -18,6 +19,16 @@ import 'package:flutter/material.dart'; import 'entity_list_checkbox_search_widget.dart'; +valdateProcedure(ProcedureViewModel model, PatiantInformtion patient, + List entityList) async { + ProcedureValadteRequestModel procedureValadteRequestModel = + new ProcedureValadteRequestModel(); + + procedureValadteRequestModel.patientMRN = patient.appointmentNo; + procedureValadteRequestModel.episodeID = patient.episodeNo; + procedureValadteRequestModel.appointmentNo = patient.appointmentNo; +} + postProcedure( {ProcedureViewModel model, String remarks, @@ -25,6 +36,12 @@ postProcedure( PatiantInformtion patient, List entityList}) async { PostProcedureReqModel postProcedureReqModel = new PostProcedureReqModel(); + ProcedureValadteRequestModel procedureValadteRequestModel = + new ProcedureValadteRequestModel(); + procedureValadteRequestModel.patientMRN = patient.patientMRN; + procedureValadteRequestModel.episodeID = patient.episodeNo; + procedureValadteRequestModel.appointmentNo = patient.appointmentNo; + List controlsProcedure = List(); postProcedureReqModel.appointmentNo = patient.appointmentNo; @@ -33,11 +50,12 @@ postProcedure( postProcedureReqModel.patientMRN = patient.patientMRN; entityList.forEach((element) { + procedureValadteRequestModel.procedure = [element.procedureId]; List controls = List(); controls.add( Controls( code: "remarks", - controlValue: element.remarks.isNotEmpty ? element.remarks : ""), + controlValue: element.remarks != null ? element.remarks : ""), ); controls.add( Controls(code: "ordertype", controlValue: element.type), @@ -49,13 +67,28 @@ postProcedure( }); postProcedureReqModel.procedures = controlsProcedure; - await model.postProcedure(postProcedureReqModel, patient.patientMRN); + await model.valadteProcedure(procedureValadteRequestModel); + if (model.state == ViewState.Idle) { + if (model.valadteProcedureList[0].entityList.length == 0) { + await model.postProcedure(postProcedureReqModel, patient.patientMRN); - if (model.state == ViewState.ErrorLocal) { + if (model.state == ViewState.ErrorLocal) { + helpers.showErrorToast(model.error); + model.getProcedure(mrn: patient.patientMRN); + } else if (model.state == ViewState.Idle) { + DrAppToastMsg.showSuccesToast('procedure has been added'); + } + } else { + if (model.state == ViewState.ErrorLocal) { + helpers.showErrorToast(model.error); + model.getProcedure(mrn: patient.patientMRN); + } else if (model.state == ViewState.Idle) { + helpers.showErrorToast( + model.valadteProcedureList[0].entityList[0].warringMessages); + } + } + } else { helpers.showErrorToast(model.error); - model.getProcedure(mrn: patient.patientMRN); - } else if (model.state == ViewState.Idle) { - DrAppToastMsg.showSuccesToast('procedure has been added'); } } diff --git a/lib/screens/procedures/update-procedure.dart b/lib/screens/procedures/update-procedure.dart index c6af1358..756696fe 100644 --- a/lib/screens/procedures/update-procedure.dart +++ b/lib/screens/procedures/update-procedure.dart @@ -324,7 +324,7 @@ class _UpdateProcedureWidgetState extends State { entityList.isNotEmpty ? entityList.forEach((element) { controlsProcedure.procedure = element.procedureId; - controlsProcedure.category = element.categoryID; + controlsProcedure.category = "0" + element.categoryID; controlsProcedure.controls = controls; }) : controlsProcedure.procedure = procedureId; diff --git a/lib/util/helpers.dart b/lib/util/helpers.dart index 09bc8f50..4f9543c1 100644 --- a/lib/util/helpers.dart +++ b/lib/util/helpers.dart @@ -303,6 +303,14 @@ class Helpers { return ""; } + static String getTimeFormated(DateTime dateTime) { + print(dateTime); + if (dateTime != null) + return dateTime.hour.toString() + ":" + dateTime.minute.toString(); + else + return ""; + } + /* *@author: Mohammad Aljammal *@Date:26/5/2020 diff --git a/lib/util/translations_delegate_base.dart b/lib/util/translations_delegate_base.dart index 99ae043a..3f672218 100644 --- a/lib/util/translations_delegate_base.dart +++ b/lib/util/translations_delegate_base.dart @@ -1118,9 +1118,11 @@ class TranslationBase { String get admissionRequestSuccessMsg => localizedValues['admissionRequestSuccessMsg'][locale.languageCode]; String get infoStatus => localizedValues['infoStatus'][locale.languageCode]; - String get doctorResponse => localizedValues['doctorResponse'][locale.languageCode]; -String get sickleaveonhold => + String get doctorResponse => + localizedValues['doctorResponse'][locale.languageCode]; + String get sickleaveonhold => localizedValues['sickleaveonhold'][locale.languageCode]; + String get noClinic => localizedValues['no-clinic'][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate {