From 519e6f2fec046bb2cfe07d81dc5a1c2cdf894daa Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Tue, 1 Jun 2021 12:51:50 +0300 Subject: [PATCH] Prescription favourite templates --- lib/core/viewModel/medicine_view_model.dart | 75 +- lib/core/viewModel/procedure_View_model.dart | 136 +--- .../add_favourite_prescription.dart | 119 +++ .../prescription/add_prescription_form.dart | 4 +- .../prescription_checkout_screen.dart | 760 ++++++++++++++++++ .../prescription_home_screen.dart | 203 +++++ .../prescription/prescriptions_page.dart | 77 +- .../procedures/ExpansionProcedure.dart | 118 +-- .../procedures/entity_list_fav_procedure.dart | 38 +- 9 files changed, 1292 insertions(+), 238 deletions(-) create mode 100644 lib/screens/prescription/add_favourite_prescription.dart create mode 100644 lib/screens/prescription/prescription_checkout_screen.dart create mode 100644 lib/screens/prescription/prescription_home_screen.dart diff --git a/lib/core/viewModel/medicine_view_model.dart b/lib/core/viewModel/medicine_view_model.dart index d49b8cc3..8ccf1a70 100644 --- a/lib/core/viewModel/medicine_view_model.dart +++ b/lib/core/viewModel/medicine_view_model.dart @@ -1,8 +1,10 @@ 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/procedure/procedure_template_details_model.dart'; import 'package:doctor_app_flutter/core/model/search_drug/get_medication_response_model.dart'; import 'package:doctor_app_flutter/core/service/patient_medical_file/prescription/medicine_service.dart'; import 'package:doctor_app_flutter/core/service/patient_medical_file/prescription/prescription_service.dart'; +import 'package:doctor_app_flutter/core/service/patient_medical_file/procedure/procedure_service.dart'; import 'package:doctor_app_flutter/models/SOAP/GetAssessmentReqModel.dart'; import 'package:doctor_app_flutter/models/SOAP/GetAssessmentResModel.dart'; @@ -11,9 +13,12 @@ import '../../locator.dart'; import 'base_view_model.dart'; class MedicineViewModel extends BaseViewModel { + bool hasError = false; MedicineService _medicineService = locator(); + ProcedureService _procedureService = locator(); PrescriptionService _prescriptionService = locator(); - + List get procedureTemplate => _procedureService.templateList; + List templateList = List(); get pharmacyItemsList => _medicineService.pharmacyItemsList; get searchText => _medicineService.searchText; get pharmaciesList => _medicineService.pharmaciesList; @@ -27,20 +32,15 @@ class MedicineViewModel extends BaseViewModel { get medicationFrequencyList => _prescriptionService.medicationFrequencyList; get boxQuintity => _prescriptionService.boxQuantity; - get medicationIndicationsList => - _prescriptionService.medicationIndicationsList; + get medicationIndicationsList => _prescriptionService.medicationIndicationsList; get medicationDoseTimeList => _prescriptionService.medicationDoseTimeList; - List get patientAssessmentList => - _prescriptionService.patientAssessmentList; + List get patientAssessmentList => _prescriptionService.patientAssessmentList; - List get allMedicationList => - _prescriptionService.allMedicationList; + List get allMedicationList => _prescriptionService.allMedicationList; List get itemMedicineList => _prescriptionService.itemMedicineList; - List get itemMedicineListRoute => - _prescriptionService.itemMedicineListRoute; - List get itemMedicineListUnit => - _prescriptionService.itemMedicineListUnit; + List get itemMedicineListRoute => _prescriptionService.itemMedicineListRoute; + List get itemMedicineListUnit => _prescriptionService.itemMedicineListUnit; Future getItem({int itemID}) async { //hasError = false; @@ -54,6 +54,35 @@ class MedicineViewModel extends BaseViewModel { setState(ViewState.Idle); } + setTemplateListDependOnId() { + procedureTemplate.forEach((element) { + List templateListData = + templateList.where((elementTemplate) => elementTemplate.templateId == element.templateID).toList(); + + if (templateListData.length != 0) { + templateList[templateList.indexOf(templateListData[0])].procedureTemplate.add(element); + } else { + var template = ProcedureTempleteDetailsModelList( + templateName: element.templateName, templateId: element.templateID, template: element); + if (!templateList.contains(template)) templateList.add(template); + } + }); + print(templateList.length.toString()); + } + + Future getProcedureTemplate({String categoryID}) async { + hasError = false; + setState(ViewState.Busy); + await _procedureService.getProcedureTemplate(categoryID: categoryID); + if (_procedureService.hasError) { + error = _procedureService.error; + setState(ViewState.ErrorLocal); + } else { + setTemplateListDependOnId(); + setState(ViewState.Idle); + } + } + Future getPrescription({int mrn}) async { //hasError = false; //_insuranceCardService.clearInsuranceCard(); @@ -86,8 +115,7 @@ class MedicineViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getPatientAssessment( - GetAssessmentReqModel getAssessmentReqModel) async { + Future getPatientAssessment(GetAssessmentReqModel getAssessmentReqModel) async { setState(ViewState.Busy); await _prescriptionService.getPatientAssessment(getAssessmentReqModel); if (_prescriptionService.hasError) { @@ -99,8 +127,7 @@ class MedicineViewModel extends BaseViewModel { Future getMedicationStrength() async { setState(ViewState.Busy); - await _prescriptionService - .getMasterLookup(MasterKeysService.MedicationStrength); + await _prescriptionService.getMasterLookup(MasterKeysService.MedicationStrength); if (_prescriptionService.hasError) { error = _prescriptionService.error; setState(ViewState.Error); @@ -110,8 +137,7 @@ class MedicineViewModel extends BaseViewModel { Future getMedicationRoute() async { setState(ViewState.Busy); - await _prescriptionService - .getMasterLookup(MasterKeysService.MedicationRoute); + await _prescriptionService.getMasterLookup(MasterKeysService.MedicationRoute); if (_prescriptionService.hasError) { error = _prescriptionService.error; setState(ViewState.Error); @@ -121,8 +147,7 @@ class MedicineViewModel extends BaseViewModel { Future getMedicationIndications() async { setState(ViewState.Busy); - await _prescriptionService - .getMasterLookup(MasterKeysService.MedicationIndications); + await _prescriptionService.getMasterLookup(MasterKeysService.MedicationIndications); if (_prescriptionService.hasError) { error = _prescriptionService.error; setState(ViewState.Error); @@ -132,8 +157,7 @@ class MedicineViewModel extends BaseViewModel { Future getMedicationDoseTime() async { setState(ViewState.Busy); - await _prescriptionService - .getMasterLookup(MasterKeysService.MedicationDoseTime); + await _prescriptionService.getMasterLookup(MasterKeysService.MedicationDoseTime); if (_prescriptionService.hasError) { error = _prescriptionService.error; setState(ViewState.Error); @@ -143,8 +167,7 @@ class MedicineViewModel extends BaseViewModel { Future getMedicationFrequency() async { setState(ViewState.Busy); - await _prescriptionService - .getMasterLookup(MasterKeysService.MedicationFrequency); + await _prescriptionService.getMasterLookup(MasterKeysService.MedicationFrequency); if (_prescriptionService.hasError) { error = _prescriptionService.error; setState(ViewState.Error); @@ -154,8 +177,7 @@ class MedicineViewModel extends BaseViewModel { Future getMedicationDuration() async { setState(ViewState.Busy); - await _prescriptionService - .getMasterLookup(MasterKeysService.MedicationDuration); + await _prescriptionService.getMasterLookup(MasterKeysService.MedicationDuration); if (_prescriptionService.hasError) { error = _prescriptionService.error; setState(ViewState.Error); @@ -163,8 +185,7 @@ class MedicineViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getBoxQuantity( - {int itemCode, int duration, double strength, int freq}) async { + Future getBoxQuantity({int itemCode, int duration, double strength, int freq}) async { setState(ViewState.Busy); await _prescriptionService.calculateBoxQuantity( strength: strength, itemCode: itemCode, duration: duration, freq: freq); diff --git a/lib/core/viewModel/procedure_View_model.dart b/lib/core/viewModel/procedure_View_model.dart index ad62158e..cb3a2a7e 100644 --- a/lib/core/viewModel/procedure_View_model.dart +++ b/lib/core/viewModel/procedure_View_model.dart @@ -28,14 +28,11 @@ class ProcedureViewModel extends BaseViewModel { bool hasError = false; ProcedureService _procedureService = locator(); - List get procedureList => - _procedureService.procedureList; + List get procedureList => _procedureService.procedureList; - List get valadteProcedureList => - _procedureService.valadteProcedureList; + List get valadteProcedureList => _procedureService.valadteProcedureList; - List get categoriesList => - _procedureService.categoriesList; + List get categoriesList => _procedureService.categoriesList; List get categoryList => _procedureService.categoryList; RadiologyService _radiologyService = locator(); @@ -44,25 +41,18 @@ class ProcedureViewModel extends BaseViewModel { List _finalRadiologyListHospital = List(); List get finalRadiologyList => - filterType == FilterType.Clinic - ? _finalRadiologyListClinic - : _finalRadiologyListHospital; + filterType == FilterType.Clinic ? _finalRadiologyListClinic : _finalRadiologyListHospital; - List get radiologyList => - _radiologyService.finalRadiologyList; + List get radiologyList => _radiologyService.finalRadiologyList; - List get patientLabOrdersList => - _labsService.patientLabOrdersList; + List get patientLabOrdersList => _labsService.patientLabOrdersList; - List get labOrdersResultsList => - _labsService.labOrdersResultsList; + List get labOrdersResultsList => _labsService.labOrdersResultsList; - List get procedureTemplate => - _procedureService.templateList; + List get procedureTemplate => _procedureService.templateList; List templateList = List(); - List get procedureTemplateDetails => - _procedureService.templateDetailsList; + List get procedureTemplateDetails => _procedureService.templateDetailsList; List _patientLabOrdersListClinic = List(); List _patientLabOrdersListHospital = List(); @@ -88,7 +78,7 @@ class ProcedureViewModel extends BaseViewModel { hasError = false; setState(ViewState.Busy); await _procedureService.getProcedureCategory( - categoryName: categoryName, categoryID: categoryID,patientId: patientId); + categoryName: categoryName, categoryID: categoryID, patientId: patientId); if (_procedureService.hasError) { error = _procedureService.error; setState(ViewState.ErrorLocal); @@ -123,22 +113,15 @@ class ProcedureViewModel extends BaseViewModel { setTemplateListDependOnId() { procedureTemplate.forEach((element) { - List templateListData = templateList - .where((elementTemplate) => - elementTemplate.templateId == element.templateID) - .toList(); + List templateListData = + templateList.where((elementTemplate) => elementTemplate.templateId == element.templateID).toList(); if (templateListData.length != 0) { - templateList[templateList.indexOf(templateListData[0])] - .procedureTemplate - .add(element); + templateList[templateList.indexOf(templateListData[0])].procedureTemplate.add(element); } else { var template = ProcedureTempleteDetailsModelList( - templateName: element.templateName, - templateId: element.templateID, - template: element); - if(!templateList.contains(template)) - templateList.add(template); + templateName: element.templateName, templateId: element.templateID, template: element); + if (!templateList.contains(template)) templateList.add(template); } }); print(templateList.length.toString()); @@ -159,8 +142,7 @@ class ProcedureViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future postProcedure( - PostProcedureReqModel postProcedureReqModel, int mrn) async { + Future postProcedure(PostProcedureReqModel postProcedureReqModel, int mrn) async { hasError = false; //_insuranceCardService.clearInsuranceCard(); setState(ViewState.Busy); @@ -174,8 +156,7 @@ class ProcedureViewModel extends BaseViewModel { } } - Future valadteProcedure( - ProcedureValadteRequestModel procedureValadteRequestModel) async { + Future valadteProcedure(ProcedureValadteRequestModel procedureValadteRequestModel) async { hasError = false; //_insuranceCardService.clearInsuranceCard(); setState(ViewState.Busy); @@ -188,9 +169,7 @@ class ProcedureViewModel extends BaseViewModel { } } - Future updateProcedure( - {UpdateProcedureRequestModel updateProcedureRequestModel, - int mrn}) async { + Future updateProcedure({UpdateProcedureRequestModel updateProcedureRequestModel, int mrn}) async { hasError = false; //_insuranceCardService.clearInsuranceCard(); setState(ViewState.Busy); @@ -203,11 +182,9 @@ class ProcedureViewModel extends BaseViewModel { //await getProcedure(mrn: mrn); } - void getPatientRadOrders(PatiantInformtion patient, - {String patientType, bool isInPatient = false}) async { + void getPatientRadOrders(PatiantInformtion patient, {String patientType, bool isInPatient = false}) async { setState(ViewState.Busy); - await _radiologyService.getPatientRadOrders(patient, - isInPatient: isInPatient); + await _radiologyService.getPatientRadOrders(patient, isInPatient: isInPatient); if (_radiologyService.hasError) { error = _radiologyService.error; if (patientType == "7") @@ -216,39 +193,32 @@ class ProcedureViewModel extends BaseViewModel { setState(ViewState.ErrorLocal); } else { _radiologyService.finalRadiologyList.forEach((element) { - List finalRadiologyListClinic = - _finalRadiologyListClinic - .where((elementClinic) => - elementClinic.filterName == element.clinicDescription) - .toList(); + List finalRadiologyListClinic = _finalRadiologyListClinic + .where((elementClinic) => elementClinic.filterName == element.clinicDescription) + .toList(); if (finalRadiologyListClinic.length != 0) { - _finalRadiologyListClinic[ - finalRadiologyListClinic.indexOf(finalRadiologyListClinic[0])] + _finalRadiologyListClinic[finalRadiologyListClinic.indexOf(finalRadiologyListClinic[0])] .finalRadiologyList .add(element); } else { - _finalRadiologyListClinic.add(FinalRadiologyList( - filterName: element.clinicDescription, finalRadiology: element)); + _finalRadiologyListClinic + .add(FinalRadiologyList(filterName: element.clinicDescription, finalRadiology: element)); } // FinalRadiologyList list sort via project - List finalRadiologyListHospital = - _finalRadiologyListHospital - .where( - (elementClinic) => - elementClinic.filterName == element.projectName, - ) - .toList(); + List finalRadiologyListHospital = _finalRadiologyListHospital + .where( + (elementClinic) => elementClinic.filterName == element.projectName, + ) + .toList(); if (finalRadiologyListHospital.length != 0) { - _finalRadiologyListHospital[finalRadiologyListHospital - .indexOf(finalRadiologyListHospital[0])] + _finalRadiologyListHospital[finalRadiologyListHospital.indexOf(finalRadiologyListHospital[0])] .finalRadiologyList .add(element); } else { - _finalRadiologyListHospital.add(FinalRadiologyList( - filterName: element.projectName, finalRadiology: element)); + _finalRadiologyListHospital.add(FinalRadiologyList(filterName: element.projectName, finalRadiology: element)); } }); @@ -258,17 +228,10 @@ class ProcedureViewModel extends BaseViewModel { String get radImageURL => _radiologyService.url; - getRadImageURL( - {int invoiceNo, - int lineItem, - int projectId, - @required PatiantInformtion patient}) async { + getRadImageURL({int invoiceNo, int lineItem, int projectId, @required PatiantInformtion patient}) async { setState(ViewState.Busy); await _radiologyService.getRadImageURL( - invoiceNo: invoiceNo, - lineItem: lineItem, - projectId: projectId, - patient: patient); + invoiceNo: invoiceNo, lineItem: lineItem, projectId: projectId, patient: patient); if (_radiologyService.hasError) { error = _radiologyService.error; setState(ViewState.Error); @@ -281,8 +244,7 @@ class ProcedureViewModel extends BaseViewModel { notifyListeners(); } - List get patientLabSpecialResult => - _labsService.patientLabSpecialResult; + List get patientLabSpecialResult => _labsService.patientLabSpecialResult; List get labResultList => _labsService.labResultList; @@ -304,18 +266,10 @@ class ProcedureViewModel extends BaseViewModel { } getLaboratoryResult( - {String projectID, - int clinicID, - String invoiceNo, - String orderNo, - PatiantInformtion patient}) async { + {String projectID, int clinicID, String invoiceNo, String orderNo, PatiantInformtion patient}) async { setState(ViewState.Busy); await _labsService.getLaboratoryResult( - invoiceNo: invoiceNo, - orderNo: orderNo, - projectID: projectID, - clinicID: clinicID, - patient: patient); + invoiceNo: invoiceNo, orderNo: orderNo, projectID: projectID, clinicID: clinicID, patient: patient); if (_labsService.hasError) { error = _labsService.error; setState(ViewState.Error); @@ -324,15 +278,10 @@ class ProcedureViewModel extends BaseViewModel { } } - getPatientLabOrdersResults( - {PatientLabOrders patientLabOrder, - String procedure, - PatiantInformtion patient}) async { + getPatientLabOrdersResults({PatientLabOrders patientLabOrder, String procedure, PatiantInformtion patient}) async { setState(ViewState.Busy); await _labsService.getPatientLabOrdersResults( - patientLabOrder: patientLabOrder, - procedure: procedure, - patient: patient); + patientLabOrder: patientLabOrder, procedure: procedure, patient: patient); if (_labsService.hasError) { error = _labsService.error; setState(ViewState.Error); @@ -340,9 +289,8 @@ class ProcedureViewModel extends BaseViewModel { bool isShouldClear = false; if (_labsService.labOrdersResultsList.length == 1) { labOrdersResultsList.forEach((element) { - if (element.resultValue.contains('/') || - element.resultValue.contains('*') || - element.resultValue.isEmpty) isShouldClear = true; + if (element.resultValue.contains('/') || element.resultValue.contains('*') || element.resultValue.isEmpty) + isShouldClear = true; }); } if (isShouldClear) _labsService.labOrdersResultsList.clear(); diff --git a/lib/screens/prescription/add_favourite_prescription.dart b/lib/screens/prescription/add_favourite_prescription.dart new file mode 100644 index 00000000..7dad10dd --- /dev/null +++ b/lib/screens/prescription/add_favourite_prescription.dart @@ -0,0 +1,119 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/model/procedure/procedure_template_details_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/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/prescription/prescription_checkout_screen.dart'; +import 'package:doctor_app_flutter/screens/procedures/entity_list_fav_procedure.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/app_scaffold_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; +import 'package:flutter/material.dart'; + +class AddFavPrescription extends StatefulWidget { + final PrescriptionViewModel model; + final PatiantInformtion patient; + final String categoryID; + + const AddFavPrescription({Key key, this.model, this.patient, this.categoryID}) : super(key: key); + + @override + _AddFavPrescriptionState createState() => _AddFavPrescriptionState(); +} + +class _AddFavPrescriptionState extends State { + MedicineViewModel model; + PatiantInformtion patient; + + List entityList = List(); + ProcedureTempleteDetailsModel groupProcedures; + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) => model.getProcedureTemplate(categoryID: widget.categoryID), + builder: (BuildContext context, ProcedureViewModel model, Widget child) => AppScaffold( + isShowAppBar: false, + baseViewModel: model, + body: Column( + children: [ + Container( + height: MediaQuery.of(context).size.height * 0.070, + ), + if (model.templateList.length != 0) + Expanded( + child: NetworkBaseView( + baseViewModel: model, + child: EntityListCheckboxSearchFavProceduresWidget( + isProcedure: false, + model: model, + removeFavProcedure: (item) { + setState(() { + entityList.remove(item); + }); + }, + addFavProcedure: (history) { + setState(() { + entityList.add(history); + }); + }, + isEntityFavListSelected: (master) => isEntityListSelected(master), + groupProcedures: groupProcedures, + selectProcedures: (valasd) { + setState(() { + groupProcedures = valasd; + }); + }, + ), + ), + ), + Container( + margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5), + child: Wrap( + alignment: WrapAlignment.center, + children: [ + AppButton( + title: 'Add Prescription', + color: Color(0xff359846), + fontWeight: FontWeight.w700, + onPressed: () { + if (groupProcedures == null) { + DrAppToastMsg.showErrorToast( + 'Please Select item ', + ); + return; + } + + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => PrescriptionCheckOutScreen( + patient: widget.patient, + model: widget.model, + groupProcedures: groupProcedures, + ), + ), + ); + }, + ), + ], + ), + ), + ], + ), + ), + ); + } + + bool isEntityListSelected(ProcedureTempleteDetailsModel masterKey) { + Iterable history = entityList.where( + (element) => masterKey.templateID == element.templateID && masterKey.procedureName == element.procedureName); + if (history.length > 0) { + return true; + } + return false; + } +} diff --git a/lib/screens/prescription/add_prescription_form.dart b/lib/screens/prescription/add_prescription_form.dart index 3fd1fbb3..797d0255 100644 --- a/lib/screens/prescription/add_prescription_form.dart +++ b/lib/screens/prescription/add_prescription_form.dart @@ -261,7 +261,7 @@ class _PrescriptionFormWidgetState extends State { Column( children: [ SizedBox( - height: 15, + height: 60, ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -468,7 +468,7 @@ class _PrescriptionFormWidgetState extends State { PrescriptionTextFiled( hintText: TranslationBase.of(context).frequency, elementError: frequencyError, - element: frequencyError, + element: frequency, elementList: model.itemMedicineList, keyId: 'parameterCode', keyName: 'description', diff --git a/lib/screens/prescription/prescription_checkout_screen.dart b/lib/screens/prescription/prescription_checkout_screen.dart new file mode 100644 index 00000000..78c78590 --- /dev/null +++ b/lib/screens/prescription/prescription_checkout_screen.dart @@ -0,0 +1,760 @@ +import 'package:autocomplete_textfield/autocomplete_textfield.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/Prescriptions/post_prescrition_req_model.dart'; +import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_model.dart'; +import 'package:doctor_app_flutter/core/model/procedure/procedure_template_details_model.dart'; +import 'package:doctor_app_flutter/core/model/search_drug/get_medication_response_model.dart'; +import 'package:doctor_app_flutter/core/provider/robot_provider.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/icons_app/doctor_app_icons.dart'; +import 'package:doctor_app_flutter/models/SOAP/GetAssessmentReqModel.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/prescription_text_filed.dart'; +import 'package:doctor_app_flutter/util/date-utils.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/shared/TextFields.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/buttons/app_buttons_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; +import 'package:doctor_app_flutter/widgets/shared/speech-text-popup.dart'; +import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; +import 'package:flutter/material.dart'; +import 'package:hexcolor/hexcolor.dart'; +import 'package:permission_handler/permission_handler.dart'; +import 'package:speech_to_text/speech_recognition_error.dart'; +import 'package:speech_to_text/speech_to_text.dart' as stt; + +class PrescriptionCheckOutScreen extends StatefulWidget { + final PrescriptionViewModel model; + final PatiantInformtion patient; + final List prescriptionList; + final ProcedureTempleteDetailsModel groupProcedures; + + const PrescriptionCheckOutScreen({Key key, this.model, this.patient, this.prescriptionList, this.groupProcedures}) + : super(key: key); + + @override + _PrescriptionCheckOutScreenState createState() => _PrescriptionCheckOutScreenState(); +} + +class _PrescriptionCheckOutScreenState extends State { + postPrescription( + {String duration, + String doseTimeIn, + String dose, + String drugId, + String strength, + String route, + String frequency, + String indication, + String instruction, + PrescriptionViewModel model, + DateTime doseTime, + String doseUnit, + String icdCode, + PatiantInformtion patient, + String patientType}) async { + PostPrescriptionReqModel postProcedureReqModel = new PostPrescriptionReqModel(); + List prescriptionList = List(); + + postProcedureReqModel.appointmentNo = patient.appointmentNo; + postProcedureReqModel.clinicID = patient.clinicId; + postProcedureReqModel.episodeID = patient.episodeNo; + postProcedureReqModel.patientMRN = patient.patientMRN; + + prescriptionList.add(PrescriptionRequestModel( + covered: true, + dose: double.parse(dose), + itemId: drugId.isEmpty ? 1 : int.parse(drugId), + doseUnitId: int.parse(doseUnit), + route: route.isEmpty ? 1 : int.parse(route), + frequency: frequency.isEmpty ? 1 : int.parse(frequency), + remarks: instruction, + approvalRequired: true, + icdcode10Id: icdCode.toString(), + doseTime: doseTimeIn.isEmpty ? 1 : int.parse(doseTimeIn), + duration: duration.isEmpty ? 1 : int.parse(duration), + doseStartDate: doseTime.toIso8601String())); + postProcedureReqModel.prescriptionRequestModel = prescriptionList; + await model.postPrescription(postProcedureReqModel, patient.patientMRN); + + if (model.state == ViewState.ErrorLocal) { + Helpers.showErrorToast(model.error); + } else if (model.state == ViewState.Idle) { + model.getPrescriptions(patient); + DrAppToastMsg.showSuccesToast('Medication has been added'); + } + } + + String routeError; + String frequencyError; + String doseTimeError; + String durationError; + String unitError; + String strengthError; + + int selectedType; + + TextEditingController strengthController = TextEditingController(); + TextEditingController indicationController = TextEditingController(); + TextEditingController instructionController = TextEditingController(); + + bool visbiltyPrescriptionForm = true; + bool visbiltySearch = true; + + final myController = TextEditingController(); + DateTime selectedDate; + int strengthChar; + GetMedicationResponseModel _selectedMedication; + GlobalKey key = new GlobalKey>(); + + TextEditingController drugIdController = TextEditingController(); + TextEditingController doseController = TextEditingController(); + final searchController = TextEditingController(); + stt.SpeechToText speech = stt.SpeechToText(); + var event = RobotProvider(); + var reconizedWord; + + final GlobalKey formKey = GlobalKey(); + final double spaceBetweenTextFileds = 12; + dynamic route; + dynamic frequency; + dynamic duration; + dynamic doseTime; + dynamic indication; + dynamic units; + dynamic uom; + dynamic box; + dynamic x; + + @override + void initState() { + super.initState(); + selectedType = 1; + } + + onVoiceText() async { + new SpeechToText(context: context).showAlertDialog(context); + var lang = TranslationBase.of(AppGlobal.CONTEX).locale.languageCode; + bool available = await speech.initialize(onStatus: statusListener, onError: errorListener); + if (available) { + speech.listen( + onResult: resultListener, + listenMode: stt.ListenMode.confirmation, + localeId: lang == 'en' ? 'en-US' : 'ar-SA', + ); + } else { + print("The user has denied the use of speech recognition."); + } + } + + void errorListener(SpeechRecognitionError error) { + event.setValue({"searchText": 'null'}); + print(error); + } + + void statusListener(String status) { + reconizedWord = status == 'listening' ? 'Lisening...' : 'Sorry....'; + } + + void requestPermissions() async { + Map statuses = await [ + Permission.microphone, + ].request(); + } + + void resultListener(result) { + reconizedWord = result.recognizedWords; + event.setValue({"searchText": reconizedWord}); + + if (result.finalResult == true) { + setState(() { + SpeechToText.closeAlertDialog(context); + speech.stop(); + indicationController.text += reconizedWord + '\n'; + }); + } else { + print(result.finalResult); + } + } + + Future initSpeechState() async { + bool hasSpeech = await speech.initialize(onError: errorListener, onStatus: statusListener); + print(hasSpeech); + if (!mounted) return; + } + + setSelectedType(int val) { + setState(() { + selectedType = val; + }); + } + + @override + Widget build(BuildContext context) { + final screenSize = MediaQuery.of(context).size; + return BaseView( + onModelReady: (model) async { + model.getItem(itemID: int.parse(widget.groupProcedures.aliasN.replaceAll("item code ;", ""))); + + x = model.patientAssessmentList.map((element) { + return element.icdCode10ID; + }); + GetAssessmentReqModel getAssessmentReqModel = GetAssessmentReqModel( + patientMRN: widget.patient.patientMRN, + episodeID: widget.patient.episodeNo.toString(), + editedBy: '', + doctorID: '', + appointmentNo: widget.patient.appointmentNo); + if (model.medicationStrengthList.length == 0) { + await model.getMedicationStrength(); + } + if (model.medicationDurationList.length == 0) { + await model.getMedicationDuration(); + } + if (model.medicationDoseTimeList.length == 0) { + await model.getMedicationDoseTime(); + } + await model.getPatientAssessment(getAssessmentReqModel); + }, + builder: ( + BuildContext context, + MedicineViewModel model, + Widget child, + ) => + AppScaffold( + backgroundColor: Color(0xffF8F8F8).withOpacity(0.9), + isShowAppBar: false, + body: NetworkBaseView( + baseViewModel: model, + child: GestureDetector( + onTap: () { + FocusScope.of(context).requestFocus(new FocusNode()); + }, + child: SingleChildScrollView( + child: Container( + height: MediaQuery.of(context).size.height * 1.35, + color: Color(0xffF8F8F8), + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 12.0, vertical: 10.0), + child: Column( + children: [ + Column( + children: [ + SizedBox( + height: 60, + ), + Row( + //mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + InkWell( + child: Icon( + Icons.arrow_back_ios, + size: 24.0, + ), + onTap: () { + Navigator.pop(context); + }, + ), + SizedBox( + width: 7.0, + ), + AppText( + TranslationBase.of(context).newPrescriptionOrder, + fontWeight: FontWeight.w700, + fontSize: 20, + ), + ], + ), + ], + ), + SizedBox( + height: spaceBetweenTextFileds, + ), + Container( + child: Form( + key: formKey, + child: Column( + children: [ + Container( + child: Column( + children: [ + SizedBox( + height: 14.5, + ), + ], + ), + ), + SizedBox( + height: spaceBetweenTextFileds, + ), + Visibility( + visible: visbiltyPrescriptionForm, + child: Container( + child: Column( + children: [ + AppText( + widget.groupProcedures.procedureName ?? "", + bold: true, + ), + Container( + child: Row( + children: [ + AppText( + TranslationBase.of(context).orderType, + fontWeight: FontWeight.w600, + ), + Radio( + activeColor: Color(0xFFB9382C), + value: 1, + groupValue: selectedType, + onChanged: (value) { + setSelectedType(value); + }, + ), + Text(TranslationBase.of(context).regular), + ], + ), + ), + SizedBox(height: spaceBetweenTextFileds), + Container( + width: double.infinity, + child: Row( + children: [ + Container( + width: MediaQuery.of(context).size.width * 0.35, + child: AppTextFieldCustom( + height: 40, + validationError: strengthError, + hintText: 'Strength', + isTextFieldHasSuffix: false, + enabled: true, + controller: strengthController, + onChanged: (String value) { + setState(() { + strengthChar = value.length; + }); + if (strengthChar >= 5) { + DrAppToastMsg.showErrorToast( + TranslationBase.of(context).only5DigitsAllowedForStrength, + ); + } + }, + inputType: TextInputType.numberWithOptions( + decimal: true, + ), + ), + ), + SizedBox( + width: 5.0, + ), + PrescriptionTextFiled( + width: MediaQuery.of(context).size.width * 0.560, + element: units, + elementError: unitError, + keyName: 'description', + keyId: 'parameterCode', + hintText: 'Select', + elementList: model.itemMedicineListUnit, + okFunction: (selectedValue) { + setState(() { + units = selectedValue; + units['isDefault'] = true; + }); + }, + ), + ], + ), + ), + SizedBox(height: spaceBetweenTextFileds), + PrescriptionTextFiled( + elementList: model.itemMedicineListRoute, + element: route, + elementError: routeError, + keyId: 'parameterCode', + keyName: 'description', + okFunction: (selectedValue) { + setState(() { + route = selectedValue; + route['isDefault'] = true; + }); + }, + hintText: TranslationBase.of(context).route, + ), + SizedBox(height: spaceBetweenTextFileds), + PrescriptionTextFiled( + hintText: TranslationBase.of(context).frequency, + elementError: frequencyError, + element: frequency, + elementList: model.itemMedicineList, + keyId: 'parameterCode', + keyName: 'description', + okFunction: (selectedValue) { + setState(() { + frequency = selectedValue; + frequency['isDefault'] = true; + if (_selectedMedication != null && + duration != null && + frequency != null && + strengthController.text != null) { + model.getBoxQuantity( + freq: frequency['parameterCode'], + duration: duration['id'], + itemCode: _selectedMedication.itemId, + strength: double.parse(strengthController.text)); + + return; + } + }); + }), + SizedBox(height: spaceBetweenTextFileds), + PrescriptionTextFiled( + hintText: TranslationBase.of(context).doseTime, + elementError: doseTimeError, + element: doseTime, + elementList: model.medicationDoseTimeList, + keyId: 'id', + keyName: 'nameEn', + okFunction: (selectedValue) { + setState(() { + doseTime = selectedValue; + }); + }), + SizedBox(height: spaceBetweenTextFileds), + if (model.patientAssessmentList.isNotEmpty) + Container( + height: screenSize.height * 0.070, + width: double.infinity, + color: Colors.white, + child: Row( + children: [ + Container( + width: MediaQuery.of(context).size.width * 0.29, + child: TextField( + decoration: textFieldSelectorDecoration( + model.patientAssessmentList[0].icdCode10ID.toString(), + indication != null ? indication['name'] : null, + false), + enabled: true, + readOnly: true, + ), + ), + Container( + width: MediaQuery.of(context).size.width * 0.65, + color: Colors.white, + child: TextField( + maxLines: 5, + decoration: textFieldSelectorDecoration( + model.patientAssessmentList[0].asciiDesc.toString(), + indication != null ? indication['name'] : null, + false), + enabled: true, + readOnly: true, + ), + ), + ], + ), + ), + SizedBox(height: spaceBetweenTextFileds), + Container( + height: screenSize.height * 0.070, + color: Colors.white, + child: InkWell( + onTap: () => selectDate(context, widget.model), + child: TextField( + decoration: textFieldSelectorDecoration( + TranslationBase.of(context).date, + selectedDate != null + ? "${AppDateUtils.convertStringToDateFormat(selectedDate.toString(), "yyyy-MM-dd")}" + : null, + true, + suffixIcon: Icon( + Icons.calendar_today, + color: Colors.black, + )), + enabled: false, + ), + ), + ), + SizedBox(height: spaceBetweenTextFileds), + PrescriptionTextFiled( + element: duration, + elementError: durationError, + hintText: TranslationBase.of(context).duration, + elementList: model.medicationDurationList, + keyName: 'nameEn', + keyId: 'id', + okFunction: (selectedValue) { + setState(() { + duration = selectedValue; + if (_selectedMedication != null && + duration != null && + frequency != null && + strengthController.text != null) { + model.getBoxQuantity( + freq: frequency['parameterCode'], + duration: duration['id'], + itemCode: _selectedMedication.itemId, + strength: double.parse(strengthController.text), + ); + box = model.boxQuintity; + + return; + } + }); + }, + ), + SizedBox(height: spaceBetweenTextFileds), + // Container( + // color: Colors.white, + // child: AppTextFieldCustom( + // hintText: "UOM", + // isTextFieldHasSuffix: false, + // dropDownText: uom != null ? uom : null, + // enabled: false, + // ), + // ), + SizedBox(height: spaceBetweenTextFileds), + // Container( + // color: Colors.white, + // child: AppTextFieldCustom( + // hintText: TranslationBase.of(context).boxQuantity, + // isTextFieldHasSuffix: false, + // dropDownText: box != null + // ? TranslationBase.of(context).boxQuantity + + // ": " + + // model.boxQuintity.toString() + // : null, + // enabled: false, + // ), + // ), + SizedBox(height: spaceBetweenTextFileds), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(6.0)), + border: Border.all(width: 1.0, color: HexColor("#CCCCCC"))), + child: Stack( + children: [ + TextFields( + maxLines: 6, + minLines: 4, + hintText: TranslationBase.of(context).instruction, + controller: instructionController, + //keyboardType: TextInputType.number, + ), + Positioned( + top: 0, + right: 15, + child: IconButton( + icon: Icon( + DoctorApp.speechtotext, + color: Colors.black, + size: 35, + ), + onPressed: () { + initSpeechState().then((value) => {onVoiceText()}); + }, + ), + ), + ], + ), + ), + SizedBox(height: spaceBetweenTextFileds), + Container( + margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5), + child: Wrap( + alignment: WrapAlignment.center, + children: [ + AppButton( + color: Color(0xff359846), + title: TranslationBase.of(context).addMedication, + fontWeight: FontWeight.w600, + onPressed: () async { + if (route != null && + duration != null && + doseTime != null && + frequency != null && + units != null && + selectedDate != null && + strengthController.text != "") { + // if (_selectedMedication.isNarcotic == true) { + // DrAppToastMsg.showErrorToast(TranslationBase.of(context) + // .narcoticMedicineCanOnlyBePrescribedFromVida); + // Navigator.pop(context); + // return; + // } + + if (double.parse(strengthController.text) > 1000.0) { + DrAppToastMsg.showErrorToast("1000 is the MAX for the strength"); + return; + } + if (double.parse(strengthController.text) < 0.0) { + DrAppToastMsg.showErrorToast("strength can't be zero"); + return; + } + + if (formKey.currentState.validate()) { + Navigator.pop(context); + // openDrugToDrug(model); + { + postPrescription( + icdCode: model.patientAssessmentList.isNotEmpty + ? model.patientAssessmentList[0].icdCode10ID.isEmpty + ? "test" + : model.patientAssessmentList[0].icdCode10ID.toString() + : "test", + // icdCode: model + // .patientAssessmentList + // .map((value) => value + // .icdCode10ID + // .trim()) + // .toList() + // .join(' '), + dose: strengthController.text, + doseUnit: model.itemMedicineListUnit.length == 1 + ? model.itemMedicineListUnit[0]['parameterCode'].toString() + : units['parameterCode'].toString(), + patient: widget.patient, + doseTimeIn: doseTime['id'].toString(), + model: widget.model, + duration: duration['id'].toString(), + frequency: model.itemMedicineList.length == 1 + ? model.itemMedicineList[0]['parameterCode'].toString() + : frequency['parameterCode'].toString(), + route: model.itemMedicineListRoute.length == 1 + ? model.itemMedicineListRoute[0]['parameterCode'].toString() + : route['parameterCode'].toString(), + drugId: (widget.groupProcedures.aliasN + .replaceAll("item code ;", "")), + strength: strengthController.text, + indication: indicationController.text, + instruction: instructionController.text, + doseTime: selectedDate, + ); + } + } + } else { + setState(() { + if (duration == null) { + durationError = TranslationBase.of(context).fieldRequired; + } else { + durationError = null; + } + if (doseTime == null) { + doseTimeError = TranslationBase.of(context).fieldRequired; + } else { + doseTimeError = null; + } + if (route == null) { + routeError = TranslationBase.of(context).fieldRequired; + } else { + routeError = null; + } + if (frequency == null) { + frequencyError = TranslationBase.of(context).fieldRequired; + } else { + frequencyError = null; + } + if (units == null) { + unitError = TranslationBase.of(context).fieldRequired; + } else { + unitError = null; + } + if (strengthController.text == "") { + strengthError = TranslationBase.of(context).fieldRequired; + } else { + strengthError = null; + } + }); + } + + formKey.currentState.save(); + }, + ), + ], + ), + ), + ], + ), + ), + ), + ], + ), + ), + ), + ], + ), + ), + ), + ), + ), + ), + ), + ); + } + + selectDate(BuildContext context, PrescriptionViewModel model) async { + Helpers.hideKeyboard(context); + DateTime selectedDate; + selectedDate = DateTime.now(); + final DateTime picked = await showDatePicker( + context: context, + initialDate: selectedDate, + firstDate: DateTime.now(), + lastDate: DateTime(2040), + initialEntryMode: DatePickerEntryMode.calendar, + ); + if (picked != null && picked != selectedDate) { + setState(() { + this.selectedDate = picked; + }); + } + } + + 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(0xFFEFEFEF), width: 2.0), + borderRadius: BorderRadius.circular(8), + ), + disabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Color(0xFFEFEFEF), width: 2.0), + borderRadius: BorderRadius.circular(8), + ), + hintText: selectedText != null ? selectedText : hintText, + suffixIcon: isDropDown + ? suffixIcon != null + ? suffixIcon + : Icon( + Icons.keyboard_arrow_down_sharp, + color: Color(0xff2E303A), + ) + : null, + hintStyle: TextStyle( + fontSize: 13, + color: Color(0xff2E303A), + fontFamily: 'Poppins', + fontWeight: FontWeight.w600, + ), + labelText: selectedText != null ? '$hintText\n$selectedText' : null, + labelStyle: TextStyle( + fontSize: 13, + color: Color(0xff2E303A), + fontFamily: 'Poppins', + fontWeight: FontWeight.w600, + ), + ); + } +} diff --git a/lib/screens/prescription/prescription_home_screen.dart b/lib/screens/prescription/prescription_home_screen.dart new file mode 100644 index 00000000..641b684a --- /dev/null +++ b/lib/screens/prescription/prescription_home_screen.dart @@ -0,0 +1,203 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/viewModel/prescription_view_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/prescription/add_favourite_prescription.dart'; +import 'package:doctor_app_flutter/screens/prescription/add_prescription_form.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/network_base_view.dart'; +import 'package:doctor_app_flutter/widgets/shared/text_fields/text_fields_utils.dart'; +import 'package:flutter/material.dart'; + +class PrescriptionHomeScreen extends StatefulWidget { + final PrescriptionViewModel model; + final PatiantInformtion patient; + + const PrescriptionHomeScreen({Key key, this.model, this.patient}) : super(key: key); + @override + _PrescriptionHomeScreenState createState() => _PrescriptionHomeScreenState(); +} + +class _PrescriptionHomeScreenState extends State with SingleTickerProviderStateMixin { + PrescriptionViewModel model; + PatiantInformtion patient; + TabController _tabController; + int _activeTab = 0; + @override + void initState() { + super.initState(); + _tabController = TabController(length: 2, vsync: this); + _tabController.addListener(_handleTabSelection); + } + + @override + void dispose() { + super.dispose(); + _tabController.dispose(); + } + + _handleTabSelection() { + setState(() { + _activeTab = _tabController.index; + }); + } + + @override + Widget build(BuildContext context) { + final screenSize = MediaQuery.of(context).size; + return BaseView( + //onModelReady: (model) => model.getCategory(), + builder: (BuildContext context, ProcedureViewModel model, Widget child) => AppScaffold( + isShowAppBar: false, + body: NetworkBaseView( + baseViewModel: model, + child: DraggableScrollableSheet( + minChildSize: 0.90, + initialChildSize: 0.95, + maxChildSize: 1.0, + builder: (BuildContext context, ScrollController scrollController) { + return Container( + height: MediaQuery.of(context).size.height * 1.20, + child: Padding( + padding: EdgeInsets.all(12.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row(children: [ + InkWell( + child: Icon( + Icons.arrow_back_ios, + size: 24.0, + ), + onTap: () { + Navigator.pop(context); + }, + ), + SizedBox( + width: 7.0, + ), + AppText( + 'Add prescription', + fontWeight: FontWeight.w700, + fontSize: 20, + ), + ]), + SizedBox( + height: MediaQuery.of(context).size.height * 0.04, + ), + Expanded( + child: Scaffold( + extendBodyBehindAppBar: true, + appBar: PreferredSize( + preferredSize: Size.fromHeight(MediaQuery.of(context).size.height * 0.070), + child: Container( + height: MediaQuery.of(context).size.height * 0.070, + decoration: BoxDecoration( + border: Border( + bottom: + BorderSide(color: Theme.of(context).dividerColor, width: 0.5), //width: 0.7 + ), + color: Colors.white), + child: Center( + child: TabBar( + isScrollable: false, + controller: _tabController, + indicatorColor: Colors.transparent, + indicatorWeight: 1.0, + indicatorSize: TabBarIndicatorSize.tab, + labelColor: Theme.of(context).primaryColor, + labelPadding: EdgeInsets.only(top: 0, left: 0, right: 0, bottom: 0), + unselectedLabelColor: Colors.grey[800], + tabs: [ + tabWidget( + screenSize, + _activeTab == 0, + 'All Prescription', + ), + tabWidget( + screenSize, + _activeTab == 1, + "Favorite Templates", + ), + ], + ), + ), + ), + ), + body: Column( + children: [ + Expanded( + child: TabBarView( + physics: BouncingScrollPhysics(), + controller: _tabController, + children: [ + PrescriptionFormWidget( + widget.model, widget.patient, widget.model.prescriptionList), + AddFavPrescription( + model: widget.model, + patient: widget.patient, + categoryID: '55', + ), + ], + ), + ), + ], + ), + ), + ), + ], + ), + ), + ); + }), + ), + ), + ); + } + + Widget tabWidget(Size screenSize, bool isActive, String title, {int counter = -1}) { + return Center( + child: Container( + height: screenSize.height * 0.070, + decoration: TextFieldsUtils.containerBorderDecoration( + isActive ? Color(0xFFD02127 /*B8382B*/) : Color(0xFFEAEAEA), + isActive ? Color(0xFFD02127) : Color(0xFFEAEAEA), + borderRadius: 4, + borderWidth: 0), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + AppText( + title, + fontSize: SizeConfig.textMultiplier * 1.5, + color: isActive ? Colors.white : Color(0xFF2B353E), + fontWeight: FontWeight.w700, + ), + if (counter != -1) + Container( + margin: EdgeInsets.all(4), + width: 15, + height: 15, + decoration: BoxDecoration( + color: isActive ? Colors.white : Color(0xFFD02127), + shape: BoxShape.circle, + ), + child: Center( + child: FittedBox( + child: AppText( + "$counter", + fontSize: SizeConfig.textMultiplier * 1.5, + color: !isActive ? Colors.white : Color(0xFFD02127), + fontWeight: FontWeight.w700, + ), + ), + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/screens/prescription/prescriptions_page.dart b/lib/screens/prescription/prescriptions_page.dart index 81c8760f..b56befdb 100644 --- a/lib/screens/prescription/prescriptions_page.dart +++ b/lib/screens/prescription/prescriptions_page.dart @@ -2,6 +2,7 @@ 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/screens/prescription/add_prescription_form.dart'; +import 'package:doctor_app_flutter/screens/prescription/prescription_home_screen.dart'; import 'package:doctor_app_flutter/screens/prescription/prescription_item_in_patient_page.dart'; import 'package:doctor_app_flutter/screens/prescription/prescription_items_page.dart'; import 'package:doctor_app_flutter/util/date-utils.dart'; @@ -49,8 +50,7 @@ class PrescriptionsPage extends StatelessWidget { SizedBox( height: 12, ), - if (model.prescriptionsList.isNotEmpty && - patient.patientStatusType != 43) + if (model.prescriptionsList.isNotEmpty && patient.patientStatusType != 43) Padding( padding: const EdgeInsets.all(8.0), child: Column( @@ -70,8 +70,7 @@ class PrescriptionsPage extends StatelessWidget { ], ), ), - if (patient.patientStatusType != null && - patient.patientStatusType == 43) + if (patient.patientStatusType != null && patient.patientStatusType == 43) Padding( padding: const EdgeInsets.all(8.0), child: Column( @@ -91,16 +90,20 @@ class PrescriptionsPage extends StatelessWidget { ], ), ), - if ((patient.patientStatusType != null && - patient.patientStatusType == 43) || + if ((patient.patientStatusType != null && patient.patientStatusType == 43) || (isFromLiveCare && patient.appointmentNo != null)) AddNewOrder( onTap: () { - addPrescriptionForm(context, model, patient, - model.prescriptionList); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => PrescriptionHomeScreen( + patient: patient, + model: model, + )), + ); }, - label: TranslationBase.of(context) - .applyForNewPrescriptionsOrder, + label: TranslationBase.of(context).applyForNewPrescriptionsOrder, ), ...List.generate( model.prescriptionsList.length, @@ -109,8 +112,7 @@ class PrescriptionsPage extends StatelessWidget { context, FadePage( page: PrescriptionItemsPage( - prescriptions: - model.prescriptionsList[index], + prescriptions: model.prescriptionsList[index], patient: patient, patientType: patientType, arrivalType: arrivalType, @@ -118,22 +120,16 @@ class PrescriptionsPage extends StatelessWidget { ), ), child: DoctorCard( - doctorName: - model.prescriptionsList[index].doctorName, - profileUrl: model - .prescriptionsList[index].doctorImageURL, + doctorName: model.prescriptionsList[index].doctorName, + profileUrl: model.prescriptionsList[index].doctorImageURL, branch: model.prescriptionsList[index].name, - clinic: model.prescriptionsList[index] - .clinicDescription, + clinic: model.prescriptionsList[index].clinicDescription, isPrescriptions: true, - appointmentDate: - AppDateUtils.getDateTimeFromServerFormat( - model.prescriptionsList[index] - .appointmentDate, + appointmentDate: AppDateUtils.getDateTimeFromServerFormat( + model.prescriptionsList[index].appointmentDate, ), ))), - if (model.prescriptionsList.isEmpty && - patient.patientStatusType != 43) + if (model.prescriptionsList.isEmpty && patient.patientStatusType != 43) Center( child: Column( crossAxisAlignment: CrossAxisAlignment.center, @@ -144,8 +140,7 @@ class PrescriptionsPage extends StatelessWidget { Image.asset('assets/images/no-data.png'), Padding( padding: const EdgeInsets.all(8.0), - child: AppText(TranslationBase.of(context) - .noPrescriptionsFound), + child: AppText(TranslationBase.of(context).noPrescriptionsFound), ) ], ), @@ -170,38 +165,29 @@ class PrescriptionsPage extends StatelessWidget { FadePage( page: PrescriptionItemsInPatientPage( prescriptionIndex: index, - prescriptions: model - .inPatientPrescription[index], + prescriptions: model.inPatientPrescription[index], patient: patient, patientType: patientType, arrivalType: arrivalType, - startOn: AppDateUtils - .getDateTimeFromServerFormat( - model.inPatientPrescription[index] - .startDatetime, + startOn: AppDateUtils.getDateTimeFromServerFormat( + model.inPatientPrescription[index].startDatetime, ), - stopOn: AppDateUtils - .getDateTimeFromServerFormat( - model.inPatientPrescription[index] - .stopDatetime, + stopOn: AppDateUtils.getDateTimeFromServerFormat( + model.inPatientPrescription[index].stopDatetime, ), ), ), ), child: InPatientDoctorCard( - doctorName: model.inPatientPrescription[index] - .itemDescription, + doctorName: model.inPatientPrescription[index].itemDescription, profileUrl: 'sss', branch: 'hamza', clinic: 'basheer', isPrescriptions: true, - appointmentDate: - AppDateUtils.getDateTimeFromServerFormat( - model.inPatientPrescription[index] - .prescriptionDatetime, + appointmentDate: AppDateUtils.getDateTimeFromServerFormat( + model.inPatientPrescription[index].prescriptionDatetime, ), - createdBy: model.inPatientPrescription[index] - .createdByName, + createdBy: model.inPatientPrescription[index].createdByName, ))), if (model.inPatientPrescription.length == 0) Center( @@ -214,8 +200,7 @@ class PrescriptionsPage extends StatelessWidget { Image.asset('assets/images/no-data.png'), Padding( padding: const EdgeInsets.all(8.0), - child: AppText(TranslationBase.of(context) - .noPrescriptionsFound), + child: AppText(TranslationBase.of(context).noPrescriptionsFound), ) ], ), diff --git a/lib/screens/procedures/ExpansionProcedure.dart b/lib/screens/procedures/ExpansionProcedure.dart index cdad16da..06e56f03 100644 --- a/lib/screens/procedures/ExpansionProcedure.dart +++ b/lib/screens/procedures/ExpansionProcedure.dart @@ -15,10 +15,12 @@ class ExpansionProcedure extends StatefulWidget { final ProcedureViewModel model; final Function(ProcedureTempleteDetailsModel) removeFavProcedure; final Function(ProcedureTempleteDetailsModel) addFavProcedure; - final Function(ProcedureTempleteDetailsModel) addProceduresRemarks; + final Function(ProcedureTempleteDetailsModel) selectProcedures; final bool Function(ProcedureTempleteModel) isEntityListSelected; final bool Function(ProcedureTempleteDetailsModel) isEntityFavListSelected; + final bool isProcedure; + final ProcedureTempleteDetailsModel groupProcedures; const ExpansionProcedure( {Key key, @@ -26,9 +28,11 @@ class ExpansionProcedure extends StatefulWidget { this.model, this.removeFavProcedure, this.addFavProcedure, - this.addProceduresRemarks, + this.selectProcedures, this.isEntityListSelected, - this.isEntityFavListSelected}) + this.isEntityFavListSelected, + this.isProcedure = true, + this.groupProcedures}) : super(key: key); @override @@ -70,11 +74,11 @@ class _ExpansionProcedureState extends State { ), Expanded( child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 10, vertical: 0), + padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 0), child: AppText( - "Procedures for " + - widget.procedureTempleteModel.templateName, + widget.isProcedure == true + ? "Procedures for " + widget.procedureTempleteModel.templateName + : "Prescription for " + widget.procedureTempleteModel.templateName, fontSize: 16.0, variant: "bodyText", bold: true, @@ -87,9 +91,7 @@ class _ExpansionProcedureState extends State { width: 25, height: 25, child: Icon( - _isShowMore - ? Icons.keyboard_arrow_up - : Icons.keyboard_arrow_down, + _isShowMore ? Icons.keyboard_arrow_up : Icons.keyboard_arrow_down, color: Colors.grey[800], size: 22, ), @@ -111,48 +113,62 @@ class _ExpansionProcedureState extends State { )), duration: Duration(milliseconds: 7000), child: Column( - children: widget.procedureTempleteModel.procedureTemplate - .map((itemProcedure) { - return Container( - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 12), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Padding( - padding: - const EdgeInsets.symmetric(horizontal: 11), - child: Checkbox( - value: widget - .isEntityFavListSelected(itemProcedure), - activeColor: Color(0xffD02127), - onChanged: (bool newValue) { - setState(() { - if (widget.isEntityFavListSelected( - itemProcedure)) { - widget - .removeFavProcedure(itemProcedure); - } else { - widget.addFavProcedure(itemProcedure); - } - }); - }), - ), - Expanded( - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 0), - child: AppText(itemProcedure.procedureName, - fontSize: 14.0, - variant: "bodyText", - bold: true, - color: Color(0xff575757)), + children: widget.procedureTempleteModel.procedureTemplate.map((itemProcedure) { + return InkWell( + onTap: () { + if (widget.isProcedure) { + setState(() { + if (widget.isEntityFavListSelected(itemProcedure)) { + widget.removeFavProcedure(itemProcedure); + } else { + widget.addFavProcedure(itemProcedure); + } + }); + } else { + widget.selectProcedures(itemProcedure); + } + }, + child: Container( + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Padding( + padding: const EdgeInsets.symmetric(horizontal: 11), + child: widget.isProcedure + ? Checkbox( + value: widget.isEntityFavListSelected(itemProcedure), + activeColor: Color(0xffD02127), + onChanged: (bool newValue) { + setState(() { + if (widget.isEntityFavListSelected(itemProcedure)) { + widget.removeFavProcedure(itemProcedure); + } else { + widget.addFavProcedure(itemProcedure); + } + }); + }) + : Radio( + value: itemProcedure, + groupValue: widget.groupProcedures, + activeColor: Color(0xffD02127), + onChanged: (newValue) { + widget.selectProcedures(newValue); + })), + Expanded( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 0), + child: AppText(itemProcedure.procedureName, + fontSize: 14.0, variant: "bodyText", bold: true, color: Color(0xff575757)), + ), ), - ), - ], - ), - ], + ], + ), + ], + ), ), ), ); diff --git a/lib/screens/procedures/entity_list_fav_procedure.dart b/lib/screens/procedures/entity_list_fav_procedure.dart index 822726ce..c386afc8 100644 --- a/lib/screens/procedures/entity_list_fav_procedure.dart +++ b/lib/screens/procedures/entity_list_fav_procedure.dart @@ -22,12 +22,15 @@ class EntityListCheckboxSearchFavProceduresWidget extends StatefulWidget { final Function(ProcedureTempleteDetailsModel) removeFavProcedure; final Function(ProcedureTempleteDetailsModel) addFavProcedure; - final Function(ProcedureTempleteDetailsModel) addProceduresRemarks; + final Function(ProcedureTempleteDetailsModel) selectProcedures; + final ProcedureTempleteDetailsModel groupProcedures; final bool Function(ProcedureTempleteModel) isEntityListSelected; final bool Function(ProcedureTempleteDetailsModel) isEntityFavListSelected; final List masterList; + final bool isProcedure; + EntityListCheckboxSearchFavProceduresWidget( {Key key, this.model, @@ -36,11 +39,13 @@ class EntityListCheckboxSearchFavProceduresWidget extends StatefulWidget { this.masterList, this.addHistory, this.addFavProcedure, - this.addProceduresRemarks, + this.selectProcedures, this.removeFavProcedure, this.isEntityListSelected, this.isEntityFavListSelected, - this.addRemarks}) + this.addRemarks, + this.isProcedure = true, + this.groupProcedures}) : super(key: key); @override @@ -48,8 +53,7 @@ class EntityListCheckboxSearchFavProceduresWidget extends StatefulWidget { _EntityListCheckboxSearchFavProceduresWidgetState(); } -class _EntityListCheckboxSearchFavProceduresWidgetState - extends State { +class _EntityListCheckboxSearchFavProceduresWidgetState extends State { int selectedType = 0; int typeUrgent; int typeRegular; @@ -85,9 +89,7 @@ class _EntityListCheckboxSearchFavProceduresWidgetState child: Center( child: Container( margin: EdgeInsets.only(top: 15), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(8), - color: Colors.white), + decoration: BoxDecoration(borderRadius: BorderRadius.circular(8), color: Colors.white), child: ListView( children: [ TextFields( @@ -106,20 +108,20 @@ class _EntityListCheckboxSearchFavProceduresWidgetState ? Column( children: widget.model.templateList.map((historyInfo) { return ExpansionProcedure( - procedureTempleteModel: historyInfo, - model: widget.model, - removeFavProcedure: widget.removeFavProcedure, - addFavProcedure: widget.addFavProcedure, - addProceduresRemarks: widget.addProceduresRemarks, - isEntityListSelected: widget.isEntityListSelected, - isEntityFavListSelected: widget.isEntityFavListSelected, - ); + procedureTempleteModel: historyInfo, + model: widget.model, + removeFavProcedure: widget.removeFavProcedure, + addFavProcedure: widget.addFavProcedure, + selectProcedures: widget.selectProcedures, + isEntityListSelected: widget.isEntityListSelected, + isEntityFavListSelected: widget.isEntityFavListSelected, + isProcedure: widget.isProcedure, + groupProcedures: widget.groupProcedures); }).toList(), ) : Center( child: Container( - child: AppText("Sorry , No Match", - color: Color(0xFFB9382C)), + child: AppText("Sorry , No Match", color: Color(0xFFB9382C)), ), ) ],