diff --git a/lib/core/model/procedure/procedure_valadate_request_model.dart b/lib/core/model/procedure/procedure_valadate_request_model.dart index 0b872b93..93aafbcf 100644 --- a/lib/core/model/procedure/procedure_valadate_request_model.dart +++ b/lib/core/model/procedure/procedure_valadate_request_model.dart @@ -1,18 +1,18 @@ -class ProcedureValadteRequestModel { +class ProcedureValidationRequestModel { String vidaAuthTokenID; int patientMRN; int appointmentNo; int episodeID; List procedure; - ProcedureValadteRequestModel( + ProcedureValidationRequestModel( {this.vidaAuthTokenID, this.patientMRN, this.appointmentNo, this.episodeID, this.procedure}); - ProcedureValadteRequestModel.fromJson(Map json) { + ProcedureValidationRequestModel.fromJson(Map json) { vidaAuthTokenID = json['VidaAuthTokenID']; patientMRN = json['PatientMRN']; appointmentNo = json['AppointmentNo']; diff --git a/lib/core/service/patient_medical_file/procedure/procedure_service.dart b/lib/core/service/patient_medical_file/procedure/procedure_service.dart index 8370e968..2c923694 100644 --- a/lib/core/service/patient_medical_file/procedure/procedure_service.dart +++ b/lib/core/service/patient_medical_file/procedure/procedure_service.dart @@ -183,8 +183,8 @@ class ProcedureService extends BaseService { }, body: updateProcedureRequestModel.toJson()); } - Future valadteProcedure( - ProcedureValadteRequestModel procedureValadteRequestModel) async { + Future validationProcedure( + ProcedureValidationRequestModel validationProcedureRequestModel) async { hasError = false; _valadteProcedureList.clear(); await baseAppClient.post(GET_PROCEDURE_VALIDATION, @@ -194,6 +194,6 @@ class ProcedureService extends BaseService { }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; - }, body: procedureValadteRequestModel.toJson()); + }, body: validationProcedureRequestModel.toJson()); } } diff --git a/lib/core/viewModel/procedure_View_model.dart b/lib/core/viewModel/procedure_View_model.dart index 2371437a..76571092 100644 --- a/lib/core/viewModel/procedure_View_model.dart +++ b/lib/core/viewModel/procedure_View_model.dart @@ -1,3 +1,4 @@ +import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/core/enum/filter_type.dart'; import 'package:doctor_app_flutter/core/enum/view_state.dart'; import 'package:doctor_app_flutter/core/model/labs/lab_order_result.dart'; @@ -6,25 +7,28 @@ import 'package:doctor_app_flutter/core/model/labs/patient_lab_orders.dart'; import 'package:doctor_app_flutter/core/model/labs/patient_lab_special_result.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/categories_procedure.dart' as cpe; +import 'package:doctor_app_flutter/core/model/procedure/categories_procedure.dart' + as cpe; import 'package:doctor_app_flutter/core/model/procedure/get_ordered_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_templateModel.dart'; import 'package:doctor_app_flutter/core/model/procedure/procedure_template_details_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/model/radiology/final_radiology.dart'; +import 'package:doctor_app_flutter/core/service/AnalyticsService.dart'; import 'package:doctor_app_flutter/core/service/patient_medical_file/lab_order/labs_service.dart'; import 'package:doctor_app_flutter/core/service/patient_medical_file/procedure/procedure_service.dart'; import 'package:doctor_app_flutter/core/service/patient_medical_file/radiology/radiology_service.dart'; import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart'; import 'package:doctor_app_flutter/locator.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; -import 'package:doctor_app_flutter/screens/procedures/ProcedureType.dart'; +import 'package:doctor_app_flutter/screens/procedures/procedure_type.dart'; import 'package:doctor_app_flutter/utils/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/utils/utils.dart'; +import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; import 'package:flutter/cupertino.dart'; -import '../../widgets/shared/loader/gif_loader_dialog_utils.dart'; class ProcedureViewModel extends BaseViewModel { //TODO Hussam clean it @@ -68,15 +72,17 @@ class ProcedureViewModel extends BaseViewModel { List get procedureTemplateDetails => _procedureService.templateDetailsList; - List _patientLabOrdersListClinic = List(); - List _patientLabOrdersListHospital = List(); - - Future getProcedure({int mrn, String patientType, int appointmentNo}) async { + Future getProcedure( + {int mrn, + String patientType, + int appointmentNo, + bool isLocalBusy = false}) async { hasError = false; await getDoctorProfile(); - - //_insuranceCardService.clearInsuranceCard(); - setState(ViewState.Busy); + if (isLocalBusy) + setState(ViewState.BusyLocal); + else + setState(ViewState.Busy); await _procedureService.getProcedure( mrn: mrn, appointmentNo: appointmentNo); if (_procedureService.hasError) { @@ -90,10 +96,16 @@ class ProcedureViewModel extends BaseViewModel { } Future getProcedureCategory( - {String categoryName, String categoryID, patientId}) async { + {String categoryName, + String categoryID, + patientId, + bool isLocalBusy = false}) async { if (categoryName == null) return; hasError = false; - setState(ViewState.Busy); + if (isLocalBusy) + setState(ViewState.BusyLocal); + else + setState(ViewState.Busy); await _procedureService.getProcedureCategory( categoryName: categoryName, categoryID: categoryID, @@ -117,19 +129,23 @@ class ProcedureViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getProcedureTemplate({String categoryID, bool isLocalBusy = false, BuildContext context}) async { + Future getProcedureTemplate( + {String categoryID, + bool isLocalBusy = false, + BuildContext context}) async { if (isLocalBusy) { setState(ViewState.BusyLocal); } else { - setState(ViewState.Busy); + setState(ViewState.Busy); } - await _procedureService.getProcedureTemplate(categoryID: categoryID, isLocalBusy: false); + await _procedureService.getProcedureTemplate( + categoryID: categoryID, isLocalBusy: false); if (_procedureService.hasError) { error = _procedureService.error; setState(ViewState.ErrorLocal); } else setTemplateListDependOnId(); - setState(ViewState.Idle); + setState(ViewState.Idle); } setTemplateListDependOnId() { @@ -169,27 +185,33 @@ class ProcedureViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future postProcedure( - PostProcedureReqModel postProcedureReqModel, int mrn) async { + Future postProcedure(PostProcedureReqModel postProcedureReqModel, int mrn, + {bool isLocalBusy = false}) async { hasError = false; - //_insuranceCardService.clearInsuranceCard(); - setState(ViewState.Busy); + if (isLocalBusy) + setState(ViewState.BusyLocal); + else + setState(ViewState.Busy); await _procedureService.postProcedure(postProcedureReqModel); if (_procedureService.hasError) { error = _procedureService.error; setState(ViewState.ErrorLocal); } else { - await getProcedure(mrn: mrn); + await getProcedure(mrn: mrn, isLocalBusy:isLocalBusy); setState(ViewState.Idle); } } - Future valadteProcedure( - ProcedureValadteRequestModel procedureValadteRequestModel) async { + Future validationProcedure( + ProcedureValidationRequestModel procedureValidateRequestModel, + {bool isLocalBusy = false}) async { hasError = false; - //_insuranceCardService.clearInsuranceCard(); - setState(ViewState.Busy); - await _procedureService.valadteProcedure(procedureValadteRequestModel); + if (isLocalBusy) { + setState(ViewState.BusyLocal); + } else { + setState(ViewState.Busy); + } + await _procedureService.validationProcedure(procedureValidateRequestModel); if (_procedureService.hasError) { error = _procedureService.error; setState(ViewState.ErrorLocal); @@ -200,9 +222,9 @@ class ProcedureViewModel extends BaseViewModel { Future updateProcedure( {UpdateProcedureRequestModel updateProcedureRequestModel, - int mrn}) async { + int mrn, bool isLocalBusy = false}) async { hasError = false; - //_insuranceCardService.clearInsuranceCard(); + if(isLocalBusy)setState(ViewState.BusyLocal); else setState(ViewState.Busy); await _procedureService.updateProcedure(updateProcedureRequestModel); if (_procedureService.hasError) { @@ -368,15 +390,23 @@ class ProcedureViewModel extends BaseViewModel { DrAppToastMsg.showSuccesToast(mes); } - Future preparePostProcedure( - {String remarks, - String orderType, - PatiantInformtion patient, - List entityList, - ProcedureType procedureType}) async { + Future preparePostProcedure({ + String remarks, + String orderType, + PatiantInformtion patient, + List entityList, + ProcedureType procedureType, + bool isLocalBusy = false, + }) async { + ///TODO Roaa Move it to function + if (isLocalBusy) { + setState(ViewState.BusyLocal); + } else { + setState(ViewState.Busy); + } PostProcedureReqModel postProcedureReqModel = new PostProcedureReqModel(); - ProcedureValadteRequestModel procedureValadteRequestModel = - new ProcedureValadteRequestModel(); + ProcedureValidationRequestModel procedureValadteRequestModel = + new ProcedureValidationRequestModel(); procedureValadteRequestModel.patientMRN = patient.patientMRN; procedureValadteRequestModel.episodeID = patient.episodeNo; procedureValadteRequestModel.appointmentNo = patient.appointmentNo; @@ -409,16 +439,22 @@ class ProcedureViewModel extends BaseViewModel { }); postProcedureReqModel.procedures = controlsProcedure; - await valadteProcedure(procedureValadteRequestModel); + await validationProcedure(procedureValadteRequestModel, + isLocalBusy: isLocalBusy); if (state == ViewState.Idle) { if (valadteProcedureList[0].entityList.length == 0) { - await postProcedure(postProcedureReqModel, patient.patientMRN); + await postProcedure(postProcedureReqModel, patient.patientMRN, + isLocalBusy: isLocalBusy); if (state == ViewState.ErrorLocal) { Utils.showErrorToast(error); - getProcedure(mrn: patient.patientMRN); + getProcedure(mrn: patient.patientMRN, isLocalBusy: isLocalBusy); } else if (state == ViewState.Idle) { DrAppToastMsg.showSuccesToast('procedure has been added'); + if (Navigator.canPop(AppGlobal.CONTEX)) + Navigator.pop(AppGlobal.CONTEX); + if (Navigator.canPop(AppGlobal.CONTEX)) + Navigator.pop(AppGlobal.CONTEX); } } else { if (state == ViewState.ErrorLocal) { @@ -433,4 +469,101 @@ class ProcedureViewModel extends BaseViewModel { Utils.showErrorToast(error); } } + + bool isEntityListSelected( + cpe.EntityList masterKey, List entityList) { + Iterable history = entityList + .where((element) => masterKey.procedureId == element.procedureId); + if (history.length > 0) { + return true; + } + return false; + } + + bool isProcedureEntityListSelected(ProcedureTempleteDetailsModel masterKey, + List entityList) { + Iterable history = entityList.where( + (element) => + masterKey.templateID == element.templateID && + masterKey.procedureName == element.procedureName); + if (history.length > 0) { + return true; + } + return false; + } + + Future addProcedures( + ProcedureViewModel model, + List items, + PatiantInformtion patient, + TextEditingController remarksController, + {bool isLocalBusy = false}) async { + if (isLocalBusy) { + setState(ViewState.BusyLocal); + } else { + setState(ViewState.Busy); + } + List entityList = List(); + items.forEach((element) { + entityList.add( + cpe.EntityList( + procedureId: element.procedureID, + remarks: element.remarks, + categoryID: element.categoryID, + type: element.type, + ), + ); + }); + await locator().logEvent( + eventCategory: "Procedure Checkout Screen", + eventAction: "Add New Procedure", + ); + await model.preparePostProcedure( + entityList: entityList, + patient: patient, + remarks: remarksController.text, + isLocalBusy: isLocalBusy); + } + + Future filterSearchResults(String query, List masterList, + List items) async { + List dummySearchList = List(); + dummySearchList.addAll(masterList); + if (query.isNotEmpty) { + List dummyListData = List(); + dummySearchList.forEach((item) { + if (item.procedureName.toLowerCase().contains(query.toLowerCase())) { + dummyListData.add(item); + } + }); + items.clear(); + items.addAll(dummyListData); + } else { + items.clear(); + items.addAll(masterList); + } + } + + void filterProcedureSearchResults( + String query, + List masterList, + List items) { + List dummySearchList = List(); + if(masterList!= null) + dummySearchList.addAll(masterList); + if (query.isNotEmpty) { + List dummyListData = List(); + dummySearchList.forEach((item) { + if (item.templateName.toLowerCase().contains(query.toLowerCase())) { + dummyListData.add(item); + } + }); + items.clear(); + items.addAll(dummyListData); + return; + } else { + items.clear(); + items.addAll(masterList); + } + } } diff --git a/lib/screens/patients/profile/lab_result/labs_home_page.dart b/lib/screens/patients/profile/lab_result/labs_home_page.dart index fde2dfdb..4ac476d0 100644 --- a/lib/screens/patients/profile/lab_result/labs_home_page.dart +++ b/lib/screens/patients/profile/lab_result/labs_home_page.dart @@ -3,8 +3,8 @@ import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/patients/profile/lab_result/laboratory_result/laboratory_result_page.dart'; -import 'package:doctor_app_flutter/screens/procedures/ProcedureType.dart'; import 'package:doctor_app_flutter/screens/procedures/base_add_procedure_tab_page.dart'; +import 'package:doctor_app_flutter/screens/procedures/procedure_type.dart'; import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; import 'package:doctor_app_flutter/utils/utils.dart'; import 'package:doctor_app_flutter/widgets/patients/patient_service_title.dart'; @@ -16,7 +16,6 @@ import 'package:doctor_app_flutter/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; - import '../../../../widgets/shared/errors/error_message.dart'; class LabsHomePage extends StatefulWidget { @@ -85,7 +84,7 @@ class _LabsHomePageState extends State { MaterialPageRoute( builder: (context) => BaseAddProcedureTabPage( patient: patient, - model: model, + previousProcedureViewModel: model, procedureType: ProcedureType.LAB_RESULT, ), settings: RouteSettings(name: 'AddProcedureTabPage'), diff --git a/lib/screens/patients/profile/radiology/radiology_home_page.dart b/lib/screens/patients/profile/radiology/radiology_home_page.dart index 244fd37f..5978dcf7 100644 --- a/lib/screens/patients/profile/radiology/radiology_home_page.dart +++ b/lib/screens/patients/profile/radiology/radiology_home_page.dart @@ -3,8 +3,8 @@ import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/patients/profile/radiology/radiology_details_page.dart'; -import 'package:doctor_app_flutter/screens/procedures/ProcedureType.dart'; import 'package:doctor_app_flutter/screens/procedures/base_add_procedure_tab_page.dart'; +import 'package:doctor_app_flutter/screens/procedures/procedure_type.dart'; import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; import 'package:doctor_app_flutter/utils/utils.dart'; import 'package:doctor_app_flutter/widgets/patients/patient_service_title.dart'; @@ -17,7 +17,6 @@ import 'package:doctor_app_flutter/widgets/transitions/slide_up_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; - import '../../../../widgets/shared/errors/error_message.dart'; class RadiologyHomePage extends StatefulWidget { @@ -89,7 +88,7 @@ class _RadiologyHomePageState extends State { SlideUpPageRoute( widget: BaseAddProcedureTabPage( patient: patient, - model: model, + previousProcedureViewModel: model, procedureType: ProcedureType.RADIOLOGY, ), settingRoute: 'AddProcedureTabPage'), diff --git a/lib/screens/patients/profile/soap_update/subjective/allergies/add_allergies.dart b/lib/screens/patients/profile/soap_update/subjective/allergies/add_allergies.dart index 9561fe3b..abcc72ad 100644 --- a/lib/screens/patients/profile/soap_update/subjective/allergies/add_allergies.dart +++ b/lib/screens/patients/profile/soap_update/subjective/allergies/add_allergies.dart @@ -29,9 +29,6 @@ class AddAllergies extends StatefulWidget { class _AddAllergiesState extends State { List allergiesList; List allergySeverityList; - TextEditingController remarkController = TextEditingController(); - TextEditingController severityController = TextEditingController(); - TextEditingController allergyController = TextEditingController(); List myAllergiesListLocal; @override diff --git a/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart b/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart index 1523e59b..53195a47 100644 --- a/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart +++ b/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart @@ -293,8 +293,7 @@ class _UpdateSubjectivePageState extends State model.medicationControllerError = ''; model.illnessControllerError = ''; if (complaintsController.text.isNotEmpty && - illnessController.text.isNotEmpty && - complaintsController.text.length > 25) { + illnessController.text.isNotEmpty) { await model.postSubjectServices( patientInfo: widget.patientInfo, complaintsText: complaintsController.text, @@ -312,9 +311,6 @@ class _UpdateSubjectivePageState extends State if (complaintsController.text.isEmpty) { model.complaintsControllerError = TranslationBase.of(context).emptyMessage; - } else if (complaintsController.text.length < 25) { - model.complaintsControllerError = - TranslationBase.of(context).chiefComplaintLength; } if (illnessController.text.isEmpty) { diff --git a/lib/screens/prescription/new_prescriptions_page.dart b/lib/screens/prescription/new_prescriptions_page.dart index e275e076..93345506 100644 --- a/lib/screens/prescription/new_prescriptions_page.dart +++ b/lib/screens/prescription/new_prescriptions_page.dart @@ -2,22 +2,15 @@ import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/viewModel/prescription/prescription_view_model.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; -import 'package:doctor_app_flutter/screens/prescription/prescriptions_items/prescription_items_in_patient.dart'; -import 'package:doctor_app_flutter/screens/prescription/prescriptions_items/prescription_items_out_patient.dart'; -import 'package:doctor_app_flutter/screens/procedures/ProcedureType.dart'; import 'package:doctor_app_flutter/screens/procedures/base_add_procedure_tab_page.dart'; -import 'package:doctor_app_flutter/utils/date-utils.dart'; +import 'package:doctor_app_flutter/screens/procedures/procedure_type.dart'; import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; import 'package:doctor_app_flutter/widgets/patients/patient_service_title.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/add-order/addNewOrder.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/app_bar/patient-profile-app-bar.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/card_with_bg_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/doctor_card.dart'; -import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:doctor_app_flutter/widgets/shared/user-guid/CusomRow.dart'; -import 'package:doctor_app_flutter/widgets/shared/user-guid/in_patient_doctor_card.dart'; -import 'package:doctor_app_flutter/widgets/transitions/fade_page.dart'; import 'package:doctor_app_flutter/widgets/transitions/slide_up_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; diff --git a/lib/screens/prescription/old_prescriptions_page.dart b/lib/screens/prescription/old_prescriptions_page.dart index 71dc4dba..f937c8b1 100644 --- a/lib/screens/prescription/old_prescriptions_page.dart +++ b/lib/screens/prescription/old_prescriptions_page.dart @@ -4,21 +4,15 @@ import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/prescription/prescriptions_items/prescription_items_in_patient.dart'; import 'package:doctor_app_flutter/screens/prescription/prescriptions_items/prescription_items_out_patient.dart'; -import 'package:doctor_app_flutter/screens/procedures/ProcedureType.dart'; -import 'package:doctor_app_flutter/screens/procedures/base_add_procedure_tab_page.dart'; import 'package:doctor_app_flutter/utils/date-utils.dart'; import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; import 'package:doctor_app_flutter/widgets/patients/patient_service_title.dart'; -import 'package:doctor_app_flutter/widgets/patients/profile/add-order/addNewOrder.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/app_bar/patient-profile-app-bar.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/card_with_bg_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/doctor_card.dart'; -import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:doctor_app_flutter/widgets/shared/user-guid/CusomRow.dart'; -import 'package:doctor_app_flutter/widgets/shared/user-guid/in_patient_doctor_card.dart'; import 'package:doctor_app_flutter/widgets/transitions/fade_page.dart'; -import 'package:doctor_app_flutter/widgets/transitions/slide_up_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../utils/utils.dart'; diff --git a/lib/screens/procedures/add-procedure-page.dart b/lib/screens/procedures/add-procedure-page.dart deleted file mode 100644 index 26dde2e0..00000000 --- a/lib/screens/procedures/add-procedure-page.dart +++ /dev/null @@ -1,224 +0,0 @@ -import 'package:doctor_app_flutter/config/size_config.dart'; -import 'package:doctor_app_flutter/core/model/procedure/categories_procedure.dart'; -import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart'; -import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; -import 'package:doctor_app_flutter/screens/base/base_view.dart'; -import 'package:doctor_app_flutter/utils/dr_app_toast_msg.dart'; -import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.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/text_fields/app-textfield-custom.dart'; -import 'package:flutter/material.dart'; - -import '../../config/config.dart'; -import 'ProcedureType.dart'; -import 'entity_list_checkbox_search_widget.dart'; - -class AddProcedurePage extends StatefulWidget { - final ProcedureViewModel model; - final PatiantInformtion patient; - final ProcedureType procedureType; - - const AddProcedurePage( - {Key key, this.model, this.patient, @required this.procedureType}) - : super(key: key); - - @override - _AddProcedurePageState createState() => _AddProcedurePageState( - patient: patient, model: model, procedureType: this.procedureType); -} - -class _AddProcedurePageState extends State { - int selectedType; - ProcedureViewModel model; - PatiantInformtion patient; - ProcedureType procedureType; - - _AddProcedurePageState({this.patient, this.model, this.procedureType}); - - TextEditingController procedureController = TextEditingController(); - TextEditingController remarksController = TextEditingController(); - List entityList = List(); - List entityListProcedure = List(); - TextEditingController procedureName = TextEditingController(); - - dynamic selectedCategory; - - setSelectedType(int val) { - setState(() { - selectedType = val; - }); - } - - @override - Widget build(BuildContext context) { - return BaseView( - onModelReady: (model) { - model.getProcedureCategory( - categoryName: procedureType.getCategoryName(), - categoryID: procedureType.getCategoryId(), - patientId: patient.patientId); - }, - builder: (BuildContext context, ProcedureViewModel model, Widget child) => - AppScaffold( - isShowAppBar: false, - body: Column( - children: [ - Container( - height: MediaQuery.of(context).size.height * 0.070, - ), - Expanded( - child: NetworkBaseView( - baseViewModel: model, - child: SingleChildScrollView( - child: Container( - child: Padding( - padding: EdgeInsets.all(12.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - if (procedureType == ProcedureType.PROCEDURE) - Column( - children: [ - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - AppText( - TranslationBase.of(context) - .pleaseEnterProcedure, - fontWeight: FontWeight.w700, - fontSize: 20, - ), - ], - ), - SizedBox( - height: - MediaQuery.of(context).size.height * 0.02, - ), - Row( - children: [ - Container( - width: MediaQuery.of(context).size.width * - 0.79, - child: AppTextFieldCustom( - hintText: TranslationBase.of(context) - .searchProcedureHere, - isTextFieldHasSuffix: false, - maxLines: 1, - minLines: 1, - hasBorder: true, - controller: procedureName, - ), - ), - SizedBox( - width: MediaQuery.of(context).size.width * - 0.02, - ), - Expanded( - child: InkWell( - onTap: () { - if (procedureName.text.isNotEmpty && - procedureName.text.length >= 3) - model.getProcedureCategory( - patientId: patient.patientId, - categoryName: - procedureName.text); - else - DrAppToastMsg.showErrorToast( - TranslationBase.of(context) - .atLeastThreeCharacters, - ); - }, - child: Icon( - Icons.search, - size: 25.0, - ), - ), - ), - ], - ), - ], - ), - if ((procedureType == ProcedureType.PROCEDURE - ? procedureName.text.isNotEmpty - : true) && - model.categoriesList.length != 0) - NetworkBaseView( - baseViewModel: model, - child: EntityListCheckboxSearchWidget( - model: widget.model, - masterList: - model.categoriesList[0].entityList, - removeHistory: (item) { - setState(() { - entityList.remove(item); - }); - }, - addHistory: (history) { - setState(() { - entityList.add(history); - }); - }, - addSelectedHistories: () { - //TODO build your fun herr - // widget.addSelectedHistories(); - }, - isEntityListSelected: (master) => - isEntityListSelected(master), - )), - ], - ), - ), - ), - ), - ), - ), - Container( - margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5), - child: Wrap( - alignment: WrapAlignment.center, - children: [ - AppButton( - title: procedureType.getAddButtonTitle(context), - fontWeight: FontWeight.w700, - color: AppGlobal.appGreenColor, - onPressed: () async { - if (entityList.isEmpty == true) { - DrAppToastMsg.showErrorToast( - TranslationBase.of(context) - .fillTheMandatoryProcedureDetails, - ); - return; - } - - await this.model.preparePostProcedure( - orderType: selectedType.toString(), - entityList: entityList, - patient: patient, - remarks: remarksController.text); - Navigator.pop(context); - }, - ), - ], - ), - ), - ], - ), - ), - ); - } - - - ///TODO Elham* move it to view model - bool isEntityListSelected(EntityList masterKey) { - Iterable history = entityList - .where((element) => masterKey.procedureId == element.procedureId); - if (history.length > 0) { - return true; - } - return false; - } -} diff --git a/lib/screens/procedures/add_procedure_page.dart b/lib/screens/procedures/add_procedure_page.dart new file mode 100644 index 00000000..a82eaafa --- /dev/null +++ b/lib/screens/procedures/add_procedure_page.dart @@ -0,0 +1,220 @@ +import 'package:doctor_app_flutter/core/enum/view_state.dart'; +import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/core/model/procedure/categories_procedure.dart'; +import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/screens/procedures/procedure_type.dart'; +import 'package:doctor_app_flutter/utils/dr_app_toast_msg.dart'; +import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; +import 'package:doctor_app_flutter/widgets/bottom_sheet/custom_bottom_sheet_container.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/loader/gif_loader_dialog_utils.dart'; +import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; +import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; +import 'package:flutter/material.dart'; + +import 'entity_list_checkbox_search_widget.dart'; + +class AddProcedurePage extends StatefulWidget { + final ProcedureViewModel model; + final PatiantInformtion patient; + final ProcedureType procedureType; + + const AddProcedurePage( + {Key key, this.model, this.patient, @required this.procedureType}) + : super(key: key); + + @override + _AddProcedurePageState createState() => _AddProcedurePageState( + patient: patient, model: model, procedureType: this.procedureType); +} + +class _AddProcedurePageState extends State { + int selectedType; + ProcedureViewModel model; + PatiantInformtion patient; + ProcedureType procedureType; + + _AddProcedurePageState({this.patient, this.model, this.procedureType}); + + TextEditingController procedureController = TextEditingController(); + TextEditingController remarksController = TextEditingController(); + List entityList = List(); + List entityListProcedure = List(); + TextEditingController procedureName = TextEditingController(); + + dynamic selectedCategory; + + setSelectedType(int val) { + setState(() { + selectedType = val; + }); + } + + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) { + model.getProcedureCategory( + categoryName: procedureType.getCategoryName(), + categoryID: procedureType.getCategoryId(), + patientId: patient.patientId); + }, + builder: (BuildContext context, ProcedureViewModel model, Widget child) => + AppScaffold( + isShowAppBar: false, + body: SingleChildScrollView( + child: Column( + children: [ + Container( + height: MediaQuery.of(context).size.height * 0.070, + ), + NetworkBaseView( + baseViewModel: model, + child: Container( + child: Padding( + padding: EdgeInsets.all(12.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (procedureType == ProcedureType.PROCEDURE) + Column( + children: [ + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + AppText( + TranslationBase.of(context) + .pleaseEnterProcedure, + fontWeight: FontWeight.w700, + fontSize: 20, + ), + ], + ), + SizedBox( + height: + MediaQuery.of(context).size.height * 0.02, + ), + Row( + children: [ + Container( + width: MediaQuery.of(context).size.width * + 0.79, + child: AppTextFieldCustom( + hintText: TranslationBase.of(context) + .searchProcedureHere, + isTextFieldHasSuffix: false, + maxLines: 1, + minLines: 1, + hasBorder: true, + controller: procedureName, + ), + ), + SizedBox( + width: MediaQuery.of(context).size.width * + 0.02, + ), + Expanded( + child: InkWell( + onTap: () async { + if (procedureName.text.isNotEmpty && + procedureName.text.length >= 3) { + GifLoaderDialogUtils.showMyDialog( + context); + await model.getProcedureCategory( + patientId: patient.patientId, + categoryName: procedureName.text, + isLocalBusy: true); + if (model.state == + ViewState.ErrorLocal) { + DrAppToastMsg.showErrorToast( + model.error); + } + GifLoaderDialogUtils.hideDialog( + context); + } else { + DrAppToastMsg.showErrorToast( + TranslationBase.of(context) + .atLeastThreeCharacters, + ); + } + }, + child: Icon( + Icons.search, + size: 25.0, + ), + ), + ), + ], + ), + ], + ), + if ((procedureType == ProcedureType.PROCEDURE + ? procedureName.text.isNotEmpty + : true) && + model.categoriesList.length != 0) + NetworkBaseView( + baseViewModel: model, + child: EntityListCheckboxSearchWidget( + model: widget.model, + masterList: model.categoriesList[0].entityList, + removeProcedure: (item) { + setState(() { + entityList.remove(item); + }); + }, + addProcedure: (history) { + setState(() { + entityList.add(history); + }); + }, + addSelectedHistories: () {}, + isEntityListSelected: (master) => widget.model + .isEntityListSelected(master, entityList), + )), + SizedBox( + height: 10, + ) + ], + ), + ), + ), + ), + ], + ), + ), + bottomSheet: model.state == ViewState.BusyLocal + ? Container( + height: 0, + ) + : CustomBottomSheetContainer( + label: procedureType.getAddButtonTitle(context), + onTap: () async { + { + GifLoaderDialogUtils.showMyDialog(context); + if (entityList.isEmpty == true) { + DrAppToastMsg.showErrorToast( + TranslationBase.of(context) + .fillTheMandatoryProcedureDetails, + ); + GifLoaderDialogUtils.hideDialog(context); + return; + } + GifLoaderDialogUtils.showMyDialog(context); + await model.preparePostProcedure( + orderType: selectedType.toString(), + entityList: entityList, + patient: patient, + remarks: remarksController.text, + procedureType: ProcedureType.PROCEDURE, + isLocalBusy: true, + ); + GifLoaderDialogUtils.hideDialog(context); + } + }), + ), + ); + } +} diff --git a/lib/screens/procedures/base_add_procedure_tab_page.dart b/lib/screens/procedures/base_add_procedure_tab_page.dart index 5df0130a..ef36fb97 100644 --- a/lib/screens/procedures/base_add_procedure_tab_page.dart +++ b/lib/screens/procedures/base_add_procedure_tab_page.dart @@ -1,28 +1,26 @@ +import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/core/viewModel/prescription/prescription_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart'; -import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart'; import 'package:doctor_app_flutter/screens/prescription/add_prescription/add_prescription.dart'; +import 'package:doctor_app_flutter/screens/procedures/add_procedure_page.dart'; +import 'package:doctor_app_flutter/screens/procedures/favorite_procedure/add_favourite_procedure.dart'; +import 'package:doctor_app_flutter/screens/procedures/procedure_type.dart'; +import 'package:doctor_app_flutter/screens/procedures/tab_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; -import '../../core/viewModel/project_view_model.dart'; -import '../../utils/tab_utils.dart'; -import 'ProcedureType.dart'; -import 'add-favourite-procedure.dart'; -import 'add-procedure-page.dart'; class BaseAddProcedureTabPage extends StatefulWidget { - final ProcedureViewModel model; + final ProcedureViewModel previousProcedureViewModel; final PrescriptionViewModel prescriptionModel; final PatiantInformtion patient; final ProcedureType procedureType; const BaseAddProcedureTabPage( {Key key, - this.model, + this.previousProcedureViewModel, this.prescriptionModel, this.patient, @required this.procedureType}) @@ -30,16 +28,15 @@ class BaseAddProcedureTabPage extends StatefulWidget { @override _BaseAddProcedureTabPageState createState() => _BaseAddProcedureTabPageState( - patient: patient, model: model, procedureType: procedureType); + patient: patient, procedureType: procedureType); } class _BaseAddProcedureTabPageState extends State with SingleTickerProviderStateMixin { - final ProcedureViewModel model; final PatiantInformtion patient; final ProcedureType procedureType; - _BaseAddProcedureTabPageState({this.patient, this.model, this.procedureType}); + _BaseAddProcedureTabPageState({this.patient, this.procedureType}); TabController _tabController; int _activeTab = 0; @@ -69,20 +66,25 @@ class _BaseAddProcedureTabPageState extends State return BaseView( onModelReady: (model) async { - await model.getProcedureTemplate(categoryID: widget.procedureType.getCategoryId()); + if (widget.previousProcedureViewModel == null) { + await model.getProcedureTemplate( + categoryID: widget.procedureType.getCategoryId()); + } }, builder: (BuildContext context, ProcedureViewModel model, Widget child) => AppScaffold( - baseViewModel: model, - isShowAppBar: true, - appBar: BottomSheetTitle(title: procedureType.getToolbarLabel(context),), - body: NetworkBaseView( + baseViewModel: model, + isShowAppBar: true, + appBar: BottomSheetTitle( + title: procedureType.getToolbarLabel(context), + ), + body: NetworkBaseView( baseViewModel: model, child: Scaffold( extendBodyBehindAppBar: true, appBar: PreferredSize( - preferredSize: Size.fromHeight( - MediaQuery.of(context).size.height * 0.070), + preferredSize: + Size.fromHeight(MediaQuery.of(context).size.height * 0.070), child: TabBar( isScrollable: false, controller: _tabController, @@ -90,24 +92,16 @@ class _BaseAddProcedureTabPageState extends State indicatorWeight: 1.0, indicatorSize: TabBarIndicatorSize.tab, labelColor: Theme.of(context).primaryColor, - labelPadding: EdgeInsets.only( - top: 0, left: 0, right: 0, bottom: 0), + labelPadding: + EdgeInsets.only(top: 0, left: 0, right: 0, bottom: 0), unselectedLabelColor: Colors.grey[800], tabs: [ - tabWidget( - screenSize, - _activeTab == 0, - - procedureType - .getFavouriteTabName(context), - isFirst: true,context: context - ), - tabWidget( - screenSize, - _activeTab == 1, + TabWidget.tabWidget(screenSize, _activeTab == 0, + procedureType.getFavouriteTabName(context), + isFirst: true, context: context), + TabWidget.tabWidget(screenSize, _activeTab == 1, procedureType.getAllLabelName(context), - isLast: true,context: context - ), + isLast: true, context: context), ], ), ), @@ -119,14 +113,13 @@ class _BaseAddProcedureTabPageState extends State controller: _tabController, children: [ AddFavouriteProcedure( - previousProcedureViewModel: model, - prescriptionModel: - widget.prescriptionModel, + previousProcedureViewModel: + widget.previousProcedureViewModel ?? model, + prescriptionModel: widget.prescriptionModel, patient: patient, procedureType: procedureType, ), - if (widget.procedureType == - ProcedureType.PRESCRIPTION) + if (widget.procedureType == ProcedureType.PRESCRIPTION) AddPrescription( widget.prescriptionModel, widget.patient, @@ -134,7 +127,7 @@ class _BaseAddProcedureTabPageState extends State ) else AddProcedurePage( - model: this.model, + model: widget.previousProcedureViewModel, patient: patient, procedureType: procedureType, ), @@ -143,45 +136,7 @@ class _BaseAddProcedureTabPageState extends State ), ], ), - ) - ), - ), - ); - } - - ///TODO Elham* move it to new file - - - Widget tabWidget( - Size screenSize, - bool isActive, - String title, { - int counter = -1, - bool isFirst = false, - bool isMiddle = false, - bool isLast = false, - context, - }) { - ProjectViewModel projectViewModel = Provider.of(context); - - return Center( - child: Container( - height: TabUtils.getTabHeight(context), - decoration: TabUtils.getBoxTabsBoxDecoration( - isActive: isActive, - isFirst: isFirst, - isMiddle: isMiddle, - isLast: isLast, - projectViewModel: projectViewModel), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - - TabUtils.getTabText(title: title, isActive: isActive), - if (counter != -1) - TabUtils.getTabCounter(isActive: isActive, counter: counter) - ], - ), + )), ), ); } diff --git a/lib/screens/procedures/entity_list_checkbox_search_widget.dart b/lib/screens/procedures/entity_list_checkbox_search_widget.dart index 21da5fc9..b5a798fe 100644 --- a/lib/screens/procedures/entity_list_checkbox_search_widget.dart +++ b/lib/screens/procedures/entity_list_checkbox_search_widget.dart @@ -1,10 +1,10 @@ import 'package:doctor_app_flutter/core/model/procedure/categories_procedure.dart'; import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart'; import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; -import 'package:doctor_app_flutter/widgets/shared/text_fields/TextFields.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/divider_with_spaces_around.dart'; import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; +import 'package:doctor_app_flutter/widgets/shared/text_fields/TextFields.dart'; import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -14,24 +14,20 @@ import '../../config/config.dart'; class EntityListCheckboxSearchWidget extends StatefulWidget { final ProcedureViewModel model; final Function addSelectedHistories; - final Function(EntityList) removeHistory; - final Function(EntityList) addHistory; - final Function(EntityList) addRemarks; - + final Function(EntityList) removeProcedure; + final Function(EntityList) addProcedure; final bool Function(EntityList) isEntityListSelected; final List masterList; - /// todo clear the function here - EntityListCheckboxSearchWidget( - {Key key, - this.model, - this.addSelectedHistories, - this.removeHistory, - this.masterList, - this.addHistory, - this.isEntityListSelected, - this.addRemarks}) - : super(key: key); + EntityListCheckboxSearchWidget({ + Key key, + this.model, + this.addSelectedHistories, + this.removeProcedure, + this.masterList, + this.addProcedure, + this.isEntityListSelected, + }) : super(key: key); @override _EntityListCheckboxSearchWidgetState createState() => @@ -84,7 +80,8 @@ class _EntityListCheckboxSearchWidgetState suffixIcon: EvaIcons.search, suffixIconColor: Color(0xff2B353E), onChanged: (value) { - filterSearchResults(value); + widget.model.filterSearchResults( + value, widget.masterList, items); }, hasBorder: false, ), @@ -107,11 +104,11 @@ class _EntityListCheckboxSearchWidgetState setState(() { if (widget.isEntityListSelected( historyInfo)) { - widget.removeHistory( + widget.removeProcedure( historyInfo); } else { - widget - .addHistory(historyInfo); + widget.addProcedure( + historyInfo); } }); }), @@ -246,29 +243,4 @@ class _EntityListCheckboxSearchWidgetState ), ); } - - - ///TODO Elham* move it to view model - void filterSearchResults(String query) { - List dummySearchList = List(); - dummySearchList.addAll(widget.masterList); - if (query.isNotEmpty) { - List dummyListData = List(); - dummySearchList.forEach((item) { - if (item.procedureName.toLowerCase().contains(query.toLowerCase())) { - dummyListData.add(item); - } - }); - setState(() { - items.clear(); - items.addAll(dummyListData); - }); - return; - } else { - setState(() { - items.clear(); - items.addAll(widget.masterList); - }); - } - } } diff --git a/lib/screens/procedures/ExpansionProcedure.dart b/lib/screens/procedures/expansion_procedure.dart similarity index 86% rename from lib/screens/procedures/ExpansionProcedure.dart rename to lib/screens/procedures/expansion_procedure.dart index b0593b06..d48ab586 100644 --- a/lib/screens/procedures/ExpansionProcedure.dart +++ b/lib/screens/procedures/expansion_procedure.dart @@ -3,6 +3,7 @@ import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/core/model/procedure/procedure_templateModel.dart'; import 'package:doctor_app_flutter/core/model/procedure/procedure_template_details_model.dart'; import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart'; +import 'package:doctor_app_flutter/utils/utils.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -13,7 +14,6 @@ class ExpansionProcedure extends StatefulWidget { final Function(ProcedureTempleteDetailsModel) removeFavProcedure; final Function(ProcedureTempleteDetailsModel) addFavProcedure; final Function(ProcedureTempleteDetailsModel) selectProcedures; - final bool Function(ProcedureTempleteModel) isEntityListSelected; final bool Function(ProcedureTempleteDetailsModel) isEntityFavListSelected; final bool isProcedure; @@ -64,8 +64,8 @@ class _ExpansionProcedureState extends State { children: [ Expanded( child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ + crossAxisAlignment: CrossAxisAlignment.start, + children: [ Icon( Icons.folder, size: 20, @@ -76,17 +76,16 @@ class _ExpansionProcedureState extends State { padding: const EdgeInsets.symmetric( horizontal: 10, vertical: 0), child: AppText( - widget.isProcedure == true - ? "Procedures for " + - widget.procedureTempleteModel.templateName - : "Prescription for " + - widget.procedureTempleteModel.templateName, - letterSpacing: -0.72, - fontSize: 16.0, - color: AppGlobal.appTextColor, - fontWeight: FontWeight.w600, + widget.isProcedure == true + ? "Procedures for " + + widget.procedureTempleteModel.templateName + : "Prescription for " + + widget.procedureTempleteModel.templateName, + letterSpacing: -0.72, + fontSize: 16.0, + color: AppGlobal.appTextColor, + fontWeight: FontWeight.w600, ), - ), ), ], @@ -175,11 +174,15 @@ class _ExpansionProcedureState extends State { child: Padding( padding: const EdgeInsets.symmetric( horizontal: 10, vertical: 0), - child: AppText(itemProcedure.procedureName, - fontSize: 14.0, - variant: "bodyText", - bold: true, - color: Color(0xff575757)), + child: AppText( + Utils.convertToTitleCase( + itemProcedure.procedureName), + fontSize: 14.0, + variant: "bodyText", + bold: true, + color: Color(0xff575757), + fontFamily: 'Poppins-Bold.ttf', + ), ), ), ], diff --git a/lib/screens/procedures/add-favourite-procedure.dart b/lib/screens/procedures/favorite_procedure/add_favourite_procedure.dart similarity index 89% rename from lib/screens/procedures/add-favourite-procedure.dart rename to lib/screens/procedures/favorite_procedure/add_favourite_procedure.dart index 7b0d869a..ad689e93 100644 --- a/lib/screens/procedures/add-favourite-procedure.dart +++ b/lib/screens/procedures/favorite_procedure/add_favourite_procedure.dart @@ -1,11 +1,12 @@ +import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/core/model/procedure/procedure_template_details_model.dart'; import 'package:doctor_app_flutter/core/viewModel/prescription/prescription_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart'; -import 'package:doctor_app_flutter/core/model/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/screens/procedures/procedure_checkout_screen.dart'; +import 'package:doctor_app_flutter/screens/procedures/favorite_procedure/entity_list_fav_procedure.dart'; +import 'package:doctor_app_flutter/screens/procedures/favorite_procedure/procedure_checkout_screen.dart'; +import 'package:doctor_app_flutter/screens/procedures/procedure_type.dart'; import 'package:doctor_app_flutter/utils/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; import 'package:doctor_app_flutter/widgets/bottom_sheet/custom_bottom_sheet_container.dart'; @@ -13,7 +14,6 @@ import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/errors/error_message.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'ProcedureType.dart'; class AddFavouriteProcedure extends StatefulWidget { final ProcedureViewModel previousProcedureViewModel; @@ -44,11 +44,10 @@ class _AddFavouriteProcedureState extends State { @override Widget build(BuildContext context) { return BaseView( - builder: (BuildContext context, ProcedureViewModel model_, + builder: (BuildContext context, ProcedureViewModel procedureViewModel, Widget child) => AppScaffold( isShowAppBar: false, - baseViewModel: model, body: Column(children: [ (widget.previousProcedureViewModel.templateList.length != 0) ? Expanded( @@ -67,7 +66,8 @@ class _AddFavouriteProcedureState extends State { }); }, isEntityFavListSelected: (master) => - isEntityListSelected(master), + procedureViewModel.isProcedureEntityListSelected( + master, entityList), groupProcedures: groupProcedures, selectProcedures: (selectedProcedure) { setState(() { @@ -117,7 +117,8 @@ class _AddFavouriteProcedureState extends State { MaterialPageRoute( builder: (context) => ProcedureCheckOutScreen( items: entityList, - model: model, + previousProcedureViewModel: + widget.previousProcedureViewModel, patient: widget.patient, addButtonTitle: widget.procedureType .getAddButtonTitle(context), @@ -131,15 +132,4 @@ class _AddFavouriteProcedureState extends State { })), ); } - - 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/procedures/entity_list_fav_procedure.dart b/lib/screens/procedures/favorite_procedure/entity_list_fav_procedure.dart similarity index 76% rename from lib/screens/procedures/entity_list_fav_procedure.dart rename to lib/screens/procedures/favorite_procedure/entity_list_fav_procedure.dart index 96f88d18..3b6537ff 100644 --- a/lib/screens/procedures/entity_list_fav_procedure.dart +++ b/lib/screens/procedures/favorite_procedure/entity_list_fav_procedure.dart @@ -1,15 +1,16 @@ import 'package:doctor_app_flutter/core/model/procedure/procedure_templateModel.dart'; import 'package:doctor_app_flutter/core/model/procedure/procedure_template_details_model.dart'; import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart'; +import 'package:doctor_app_flutter/screens/procedures/expansion_procedure.dart'; import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.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/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import '../../config/config.dart'; -import '../../widgets/shared/text_fields/app_text_field_custom_serach.dart'; -import 'ExpansionProcedure.dart'; + +import '../../../config/config.dart'; +import '../../../widgets/shared/text_fields/app_text_field_custom_serach.dart'; class EntityListCheckboxSearchFavProceduresWidget extends StatefulWidget { final ProcedureViewModel model; @@ -70,14 +71,12 @@ class _EntityListCheckboxSearchFavProceduresWidgetState @override void initState() { - //items.addAll(widget.masterList); super.initState(); } TextEditingController remarksController = TextEditingController(); TextEditingController patientFileInfoController = TextEditingController(); - @override Widget build(BuildContext context) { return SingleChildScrollView( @@ -89,40 +88,35 @@ class _EntityListCheckboxSearchFavProceduresWidgetState child: Container( margin: EdgeInsets.only(top: 15), decoration: BoxDecoration( - borderRadius: BorderRadius.circular(8), - color: Colors.white), + borderRadius: BorderRadius.circular(8), color: Colors.white), child: ListView( children: [ AppTextFieldCustomSearch( searchController: patientFileInfoController, onChangeFun: (value) { - filterSearchResults(value); + widget.model.filterProcedureSearchResults( + value, widget.masterList, items); }, marginTop: 5, inputFormatters: [ - FilteringTextInputFormatter.allow( - RegExp(ONLY_LETTERS)) + FilteringTextInputFormatter.allow(RegExp(ONLY_LETTERS)) ], inputType: TextInputType.text, hintText: TranslationBase.of(context).searchFavoriteTemplate, - // validationError: TranslationBase.of(context).emptyMessage - // : null, ), SizedBox( height: 15, ), widget.model.templateList.length != 0 ? Column( - children: - widget.model.templateList.map((historyInfo) { + children: widget.model.templateList.map((historyInfo) { return ExpansionProcedure( procedureTempleteModel: historyInfo, model: widget.model, removeFavProcedure: widget.removeFavProcedure, addFavProcedure: widget.addFavProcedure, selectProcedures: widget.selectProcedures, - isEntityListSelected: - widget.isEntityListSelected, + isEntityListSelected: widget.isEntityListSelected, isEntityFavListSelected: widget.isEntityFavListSelected, isProcedure: widget.isProcedure, @@ -143,28 +137,4 @@ class _EntityListCheckboxSearchFavProceduresWidgetState ), ); } - - ///TODO Elham* move it to view model and try to make it work for every search - void filterSearchResults(String query) { - List dummySearchList = List(); - dummySearchList.addAll(widget.masterList); - if (query.isNotEmpty) { - List dummyListData = List(); - dummySearchList.forEach((item) { - if (item.templateName.toLowerCase().contains(query.toLowerCase())) { - dummyListData.add(item); - } - }); - setState(() { - items.clear(); - items.addAll(dummyListData); - }); - return; - } else { - setState(() { - items.clear(); - items.addAll(widget.masterList); - }); - } - } } diff --git a/lib/screens/procedures/favorite_procedure/procedure_checkout_screen.dart b/lib/screens/procedures/favorite_procedure/procedure_checkout_screen.dart new file mode 100644 index 00000000..fa1f880d --- /dev/null +++ b/lib/screens/procedures/favorite_procedure/procedure_checkout_screen.dart @@ -0,0 +1,220 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/core/model/procedure/procedure_template_details_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/screens/patients/patient_search/patient_search_header.dart'; +import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; +import 'package:doctor_app_flutter/utils/utils.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/loader/gif_loader_dialog_utils.dart'; +import 'package:doctor_app_flutter/widgets/shared/text_fields/TextFields.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +import '../../../config/config.dart'; + +class ProcedureCheckOutScreen extends StatefulWidget { + final List items; + final ProcedureViewModel previousProcedureViewModel; + final PatiantInformtion patient; + final String addButtonTitle; + final String toolbarTitle; + + ProcedureCheckOutScreen( + {this.items, + this.previousProcedureViewModel, + this.patient, + @required this.addButtonTitle, + @required this.toolbarTitle}); + + @override + _ProcedureCheckOutScreenState createState() => + _ProcedureCheckOutScreenState(); +} + +class _ProcedureCheckOutScreenState extends State { + List remarksList = List(); + final TextEditingController remarksController = TextEditingController(); + List typeList = List(); + + @override + Widget build(BuildContext context) { + return BaseView( + builder: (BuildContext context, ProcedureViewModel model, Widget child) => + AppScaffold( + backgroundColor: Color(0xffF8F8F8).withOpacity(0.9), + isShowAppBar: true, + appBar: PatientSearchHeader( + title: widget.toolbarTitle ?? 'Add Procedure', + ), + body: SingleChildScrollView( + child: Center( + child: FractionallySizedBox( + widthFactor: 0.95, + child: Column( + children: [ + SizedBox( + height: 30, + ), + ListView.builder( + scrollDirection: Axis.vertical, + itemCount: widget.items.length, + physics: BouncingScrollPhysics(), + shrinkWrap: true, + itemBuilder: (BuildContext ctxt, int index) { + final TextEditingController remarksControllerNew = + TextEditingController( + text: widget.items[index].remarks); + + return Container( + margin: EdgeInsets.only(bottom: 15.0), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: + BorderRadius.all(Radius.circular(10.0))), + child: ExpansionTile( + initiallyExpanded: true, + title: Row( + children: [ + Expanded( + child: AppText( + Utils.convertToTitleCase( + widget.items[index].procedureName), + fontWeight: FontWeight.w700, + color: AppGlobal.appTextColor, + )), + ], + ), + children: [ + Container( + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 12), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Row( + children: [ + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 11), + child: AppText( + TranslationBase.of(context) + .orderType, + fontWeight: FontWeight.w700, + color: Color(0xff2B353E), + ), + ), + ], + ), + Row( + children: [ + Radio( + activeColor: Color(0xFFD02127), + value: 0, + groupValue: widget + .items[index].selectedType, + onChanged: (value) { + widget.items[index].selectedType = + 0; + setState(() { + widget.items[index].type = + value.toString(); + }); + }, + ), + AppText( + 'routine', + color: Color(0xff575757), + fontWeight: FontWeight.w600, + ), + Radio( + activeColor: Color(0xFFD02127), + groupValue: widget + .items[index].selectedType, + value: 1, + onChanged: (value) { + widget.items[index].selectedType = + 1; + setState(() { + widget.items[index].type = + value.toString(); + }); + }, + ), + AppText( + TranslationBase.of(context).urgent, + color: Color(0xff575757), + fontWeight: FontWeight.w600, + ), + ], + ), + ], + ), + ), + ), + SizedBox( + height: 2.0, + ), + Padding( + padding: EdgeInsets.symmetric( + horizontal: 12, vertical: 15.0), + child: TextFields( + hintText: TranslationBase.of(context).remarks, + controller: remarksControllerNew, + onChanged: (value) { + widget.items[index].remarks = value; + }, + minLines: 3, + maxLines: 5, + borderWidth: 0.5, + borderColor: Colors.grey[500], + ), + ), + SizedBox( + height: 19.0, + ), + //DividerWithSpacesAround(), + ], + ), + ); + }), + SizedBox( + height: 90, + ), + ], + ), + ), + ), + ), + bottomSheet: Container( + margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5), + child: Wrap( + alignment: WrapAlignment.center, + children: [ + AppButton( + title: widget.addButtonTitle ?? + TranslationBase.of(context).addSelectedProcedures, + color: AppGlobal.appGreenColor, + fontWeight: FontWeight.w700, + onPressed: () async { + GifLoaderDialogUtils.showMyDialog(context); + await widget.previousProcedureViewModel.addProcedures( + widget.previousProcedureViewModel, + widget.items, + widget.patient, + remarksController, + isLocalBusy: true); + GifLoaderDialogUtils.hideDialog(context); + }, + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/screens/procedures/ProcedureCard.dart b/lib/screens/procedures/procedure_card.dart similarity index 97% rename from lib/screens/procedures/ProcedureCard.dart rename to lib/screens/procedures/procedure_card.dart index 090d5a7f..9f61d556 100644 --- a/lib/screens/procedures/ProcedureCard.dart +++ b/lib/screens/procedures/procedure_card.dart @@ -1,20 +1,19 @@ -//import 'package:doctor_app_flutter/client/base_app_client.dart'; import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/core/model/procedure/get_ordered_procedure_model.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; -import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/utils/date-utils.dart'; -import 'package:doctor_app_flutter/utils/utils.dart'; import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; +import 'package:doctor_app_flutter/utils/utils.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/user-guid/CusomRow.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import 'package:flutter_svg/flutter_svg.dart'; +/// TODO Roaa Add translation and make sure it working fine class ProcedureCard extends StatelessWidget { final Function onTap; @@ -42,7 +41,6 @@ class ProcedureCard extends StatelessWidget { return Container( width: double.maxFinite, - //height: MediaQuery.of(context).size.height * .22, margin: EdgeInsets.all(10), padding: EdgeInsets.only(left: 0, right: 5, bottom: 5, top: 5), decoration: BoxDecoration( @@ -204,9 +202,10 @@ class ProcedureCard extends StatelessWidget { children: [ Expanded( child: AppText( - entityList.remarks!= null?Utils.convertToTitleCase( - entityList.remarks.toString()) : - '', + entityList.remarks != null + ? Utils.convertToTitleCase( + entityList.remarks.toString()) + : '', fontSize: 12, ), ), diff --git a/lib/screens/procedures/procedure_checkout_screen.dart b/lib/screens/procedures/procedure_checkout_screen.dart deleted file mode 100644 index b646f51c..00000000 --- a/lib/screens/procedures/procedure_checkout_screen.dart +++ /dev/null @@ -1,258 +0,0 @@ -import 'package:doctor_app_flutter/config/size_config.dart'; -import 'package:doctor_app_flutter/core/model/procedure/categories_procedure.dart'; -import 'package:doctor_app_flutter/core/model/procedure/procedure_template_details_model.dart'; -import 'package:doctor_app_flutter/core/service/AnalyticsService.dart'; -import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart'; -import 'package:doctor_app_flutter/locator.dart'; -import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; -import 'package:doctor_app_flutter/screens/base/base_view.dart'; -import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; -import 'package:doctor_app_flutter/widgets/shared/text_fields/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:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - -import '../../config/config.dart'; - -class ProcedureCheckOutScreen extends StatefulWidget { - final List items; - final ProcedureViewModel model; - final PatiantInformtion patient; - final String addButtonTitle; - final String toolbarTitle; - - ProcedureCheckOutScreen( - {this.items, - this.model, - this.patient, - @required this.addButtonTitle, - @required this.toolbarTitle}); - - @override - _ProcedureCheckOutScreenState createState() => - _ProcedureCheckOutScreenState(); -} - -class _ProcedureCheckOutScreenState extends State { - List remarksList = List(); - final TextEditingController remarksController = TextEditingController(); - List typeList = List(); - - @override - Widget build(BuildContext context) { - return BaseView( - builder: (BuildContext context, ProcedureViewModel model, Widget child) => - AppScaffold( - backgroundColor: Color(0xffF8F8F8).withOpacity(0.9), - isShowAppBar: false, - body: SingleChildScrollView( - child: Column( - children: [ - Container( - height: MediaQuery.of(context).size.height * 0.070, - color: Colors.white, - ), - Container( - color: Colors.white, - child: Padding( - padding: EdgeInsets.all(12.0), - child: Row( - //mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - InkWell( - child: Icon( - Icons.arrow_back_ios_sharp, - size: 24.0, - ), - onTap: () { - Navigator.pop(context); - }, - ), - SizedBox( - width: 5.0, - ), - AppText( - widget.toolbarTitle ?? 'Add Procedure', - fontWeight: FontWeight.w700, - fontSize: 20, - ), - ], - ), - ), - ), - SizedBox( - height: 30, - ), - - ///TODO Elham* user view list builder - - ...List.generate( - widget.items.length, - (index) => Container( - margin: EdgeInsets.only(bottom: 15.0), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: - BorderRadius.all(Radius.circular(10.0))), - child: ExpansionTile( - initiallyExpanded: true, - title: Row( - children: [ - Icon( - Icons.check_box, - color: Color(0xffD02127), - size: 30.5, - ), - SizedBox( - width: 6.0, - ), - Expanded( - child: AppText( - widget.items[index].procedureName)), - ], - ), - children: [ - Container( - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 12), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Padding( - padding: const EdgeInsets.symmetric( - horizontal: 11), - child: AppText( - TranslationBase.of(context) - .orderType, - fontWeight: FontWeight.w700, - color: Color(0xff2B353E), - ), - ), - ], - ), - Row( - children: [ - Radio( - activeColor: Color(0xFFD02127), - value: 0, - groupValue: - widget.items[index].selectedType, - onChanged: (value) { - widget.items[index].selectedType = - 0; - setState(() { - widget.items[index].type = - value.toString(); - }); - }, - ), - AppText( - 'routine', - color: Color(0xff575757), - fontWeight: FontWeight.w600, - ), - Radio( - activeColor: Color(0xFFD02127), - groupValue: - widget.items[index].selectedType, - value: 1, - onChanged: (value) { - widget.items[index].selectedType = - 1; - setState(() { - widget.items[index].type = - value.toString(); - }); - }, - ), - AppText( - TranslationBase.of(context).urgent, - color: Color(0xff575757), - fontWeight: FontWeight.w600, - ), - ], - ), - ], - ), - ), - ), - SizedBox( - height: 2.0, - ), - Padding( - padding: EdgeInsets.symmetric( - horizontal: 12, vertical: 15.0), - child: TextFields( - hintText: TranslationBase.of(context).remarks, - controller: remarksController, - onChanged: (value) { - widget.items[index].remarks = value; - }, - minLines: 3, - maxLines: 5, - borderWidth: 0.5, - borderColor: Colors.grey[500], - ), - ), - SizedBox( - height: 19.0, - ), - //DividerWithSpacesAround(), - ], - ), - )), - SizedBox( - height: 90, - ), - ], - ), - ), - bottomSheet: Container( - margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5), - child: Wrap( - alignment: WrapAlignment.center, - children: [ - AppButton( - title: widget.addButtonTitle ?? - TranslationBase.of(context).addSelectedProcedures, - color: AppGlobal.appGreenColor, - fontWeight: FontWeight.w700, - onPressed: () async { - - ///TODO Elham* move it to function - - List entityList = List(); - widget.items.forEach((element) { - entityList.add( - EntityList( - procedureId: element.procedureID, - remarks: element.remarks, - categoryID: element.categoryID, - type: element.type, - ), - ); - }); - await locator().logEvent( - eventCategory: "Procedure Checkout Screen", - eventAction: "Add New Procedure", - ); - Navigator.pop(context); - await model.preparePostProcedure( - entityList: entityList, - patient: widget.patient, - remarks: remarksController.text); - Navigator.pop(context); - Navigator.pop(context); - }, - ), - ], - ), - ), - ), - ); - } -} diff --git a/lib/screens/procedures/procedure_screen.dart b/lib/screens/procedures/procedure_screen.dart index c8a2af15..23424463 100644 --- a/lib/screens/procedures/procedure_screen.dart +++ b/lib/screens/procedures/procedure_screen.dart @@ -1,22 +1,23 @@ import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/core/enum/view_state.dart'; -import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart'; import 'package:doctor_app_flutter/core/model/doctor/doctor_profile_model.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; -import 'package:doctor_app_flutter/screens/procedures/update-procedure.dart'; +import 'package:doctor_app_flutter/screens/procedures/procedure_card.dart'; +import 'package:doctor_app_flutter/screens/procedures/procedure_type.dart'; +import 'package:doctor_app_flutter/screens/procedures/update_procedure.dart'; import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; import 'package:doctor_app_flutter/utils/utils.dart'; -import 'package:doctor_app_flutter/widgets/patients/profile/app_bar/patient-profile-app-bar.dart'; import 'package:doctor_app_flutter/widgets/patients/patient_service_title.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/add-order/addNewOrder.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/app_bar/patient-profile-app-bar.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/loader/gif_loader_dialog_utils.dart'; import 'package:doctor_app_flutter/widgets/transitions/slide_up_page.dart'; import 'package:flutter/material.dart'; import '../../widgets/shared/errors/error_message.dart'; -import 'ProcedureCard.dart'; -import 'ProcedureType.dart'; import 'base_add_procedure_tab_page.dart'; class ProcedureScreen extends StatelessWidget { @@ -57,14 +58,10 @@ class ProcedureScreen extends StatelessWidget { SizedBox( height: 12, ), - if (model.procedureList.length == 0 && - patient.patientStatusType != 43) - ServiceTitle( - title: TranslationBase.of(context).orderTestOr, - subTitle: TranslationBase.of(context).procedure, - ), - if (patient.patientStatusType != null && - patient.patientStatusType == 43) + if ((model.procedureList.length == 0 && + patient.patientStatusType != 43) || + patient.patientStatusType != null && + patient.patientStatusType == 43) ServiceTitle( title: TranslationBase.of(context).orderTestOr, subTitle: TranslationBase.of(context).procedure, @@ -72,98 +69,69 @@ class ProcedureScreen extends StatelessWidget { if ((patient.patientStatusType != null && patient.patientStatusType == 43) || (isFromLiveCare && patient.appointmentNo != null)) - InkWell( - onTap: () { + AddNewOrder( + onTap: () async { + GifLoaderDialogUtils.showMyDialog(context); + await model.getProcedureTemplate( + categoryID: ProcedureType.PROCEDURE.getCategoryId(), + isLocalBusy: true); + GifLoaderDialogUtils.hideDialog(context); + Navigator.push( context, SlideUpPageRoute( widget: BaseAddProcedureTabPage( patient: patient, - model: model, + previousProcedureViewModel: model, procedureType: ProcedureType.PROCEDURE, ), settingRoute: 'AddProcedureTabPage'), ); }, - child: Container( - width: double.maxFinite, - height: 140, - margin: EdgeInsets.all(10), - decoration: BoxDecoration( - color: Colors.grey[300], - borderRadius: BorderRadius.circular(10), - ), - child: Center( - child: Container( - height: 90, - child: Column( - children: [ - Container( - height: 40, - width: 40, - decoration: BoxDecoration( - color: Colors.grey[600], - borderRadius: BorderRadius.circular(10), - ), - child: Center( - child: Icon( - Icons.add, - color: Colors.white, - ), - ), - ), - SizedBox( - height: 10, - ), - AppText( - TranslationBase.of(context).addMoreProcedure, - color: Colors.grey[600], - fontWeight: FontWeight.w600, - ) - ], - ), - ), - ), - ), + label: TranslationBase.of(context).addMoreProcedure, ), if (model.procedureList.isNotEmpty) - ///TODO Elham* use list view builder - ...List.generate( - model.procedureList[0].rowcount, - (index) => ProcedureCard( - categoryID: model.procedureList[0].entityList[index].categoryID, - entityList: model.procedureList[0].entityList[index], - onTap: () { - if (model.procedureList[0].entityList[index].categoryID == - 2 || - model.procedureList[0].entityList[index].categoryID == 4) - updateProcedureForm(context, - model: model, - patient: patient, - remarks: model - .procedureList[0].entityList[index].remarks, - orderType: model - .procedureList[0].entityList[index].orderType - .toString(), - orderNo: model - .procedureList[0].entityList[index].orderNo, - procedureName: model.procedureList[0] - .entityList[index].procedureName, - categoreId: model - .procedureList[0].entityList[index].categoryID - .toString(), - procedureId: model.procedureList[0] - .entityList[index].procedureId, - limetNo: model.procedureList[0].entityList[index] - .lineItemNo); - // } else - // Helpers.showErrorToast( - // 'You Cant Update This Procedure'); - }, - patient: patient, - doctorID: model?.doctorProfile?.doctorID, - ), - ), + ListView.builder( + scrollDirection: Axis.vertical, + itemCount: model.procedureList[0].rowcount, + shrinkWrap: true, + physics: BouncingScrollPhysics(), + itemBuilder: (BuildContext ctxt, int index) { + return ProcedureCard( + categoryID: model + .procedureList[0].entityList[index].categoryID, + entityList: model.procedureList[0].entityList[index], + onTap: () { + if (model.procedureList[0].entityList[index].categoryID == + 2 || + model.procedureList[0].entityList[index].categoryID == 4) + updateProcedureForm(context, + model: model, + patient: patient, + remarks: model.procedureList[0] + .entityList[index].remarks, + orderType: model.procedureList[0] + .entityList[index].orderType + .toString(), + orderNo: model.procedureList[0] + .entityList[index].orderNo, + procedureName: model.procedureList[0] + .entityList[index].procedureName, + categoreId: model.procedureList[0] + .entityList[index].categoryID + .toString(), + procedureId: model.procedureList[0] + .entityList[index].procedureId, + limetNo: model.procedureList[0] + .entityList[index].lineItemNo, + + ); + }, + patient: patient, + + doctorID: model?.doctorProfile?.doctorID, + ); + }), if (model.state == ViewState.ErrorLocal || (model.procedureList.isNotEmpty && model.procedureList[0].entityList.isEmpty)) diff --git a/lib/screens/procedures/ProcedureType.dart b/lib/screens/procedures/procedure_type.dart similarity index 100% rename from lib/screens/procedures/ProcedureType.dart rename to lib/screens/procedures/procedure_type.dart diff --git a/lib/screens/procedures/tab_widget.dart b/lib/screens/procedures/tab_widget.dart new file mode 100644 index 00000000..23d77ea2 --- /dev/null +++ b/lib/screens/procedures/tab_widget.dart @@ -0,0 +1,38 @@ +import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; +import 'package:doctor_app_flutter/utils/tab_utils.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class TabWidget { + static Widget tabWidget( + Size screenSize, + bool isActive, + String title, { + int counter = -1, + bool isFirst = false, + bool isMiddle = false, + bool isLast = false, + context, + }) { + ProjectViewModel projectViewModel = Provider.of(context); + return Center( + child: Container( + height: TabUtils.getTabHeight(context), + decoration: TabUtils.getBoxTabsBoxDecoration( + isActive: isActive, + isFirst: isFirst, + isMiddle: isMiddle, + isLast: isLast, + projectViewModel: projectViewModel), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + TabUtils.getTabText(title: title, isActive: isActive), + if (counter != -1) + TabUtils.getTabCounter(isActive: isActive, counter: counter) + ], + ), + ), + ); + } +} diff --git a/lib/screens/procedures/update-procedure.dart b/lib/screens/procedures/update-procedure.dart deleted file mode 100644 index 2e8ca6bb..00000000 --- a/lib/screens/procedures/update-procedure.dart +++ /dev/null @@ -1,279 +0,0 @@ -import 'package:doctor_app_flutter/config/config.dart'; -import 'package:doctor_app_flutter/config/size_config.dart'; -import 'package:doctor_app_flutter/core/enum/view_state.dart'; -import 'package:doctor_app_flutter/core/model/procedure/ControlsModel.dart'; -import 'package:doctor_app_flutter/core/model/procedure/categories_procedure.dart'; -import 'package:doctor_app_flutter/core/model/procedure/update_procedure_request_model.dart'; -import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart'; -import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; -import 'package:doctor_app_flutter/screens/base/base_view.dart'; -import 'package:doctor_app_flutter/utils/dr_app_toast_msg.dart'; -import 'package:doctor_app_flutter/utils/utils.dart'; -import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; -import 'package:doctor_app_flutter/widgets/shared/text_fields/TextFields.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:flutter/material.dart'; -import 'package:hexcolor/hexcolor.dart'; - -void updateProcedureForm(context, - {String procedureName, - int orderNo, - int limetNo, - PatiantInformtion patient, - String orderType, - String procedureId, - String remarks, - ProcedureViewModel model, - String categoreId}) { - TextEditingController remarksController = TextEditingController(); - showModalBottomSheet( - context: context, - isScrollControlled: true, - builder: (BuildContext bc) { - return UpdateProcedureWidget( - procedureName: procedureName, - remarks: remarks, - remarksController: remarksController, - patient: patient, - model: model, - procedureId: procedureId, - categoryId: categoreId, - orderNo: orderNo, - limetNo: limetNo, - ); - }); -} - -class UpdateProcedureWidget extends StatefulWidget { - final PatiantInformtion patient; - final ProcedureViewModel model; - final String procedureName; - final String remarks; - final TextEditingController remarksController; - final String procedureId; - final String categoryId; - final int orderNo; - final int limetNo; - - UpdateProcedureWidget( - {this.model, - this.procedureName, - this.remarks, - this.remarksController, - this.patient, - this.procedureId, - this.categoryId, - this.orderNo, - this.limetNo}); - - @override - _UpdateProcedureWidgetState createState() => _UpdateProcedureWidgetState(); -} - -class _UpdateProcedureWidgetState extends State { - int selectedType = 0; - - setSelectedType(int val) { - setState(() { - selectedType = val; - }); - } - - void initState() { - super.initState(); - widget.remarksController.text = widget.remarks; - } - - List entityList = List(); - dynamic selectedCategory; - - @override - Widget build(BuildContext context) { - final screenSize = MediaQuery.of(context).size; - return StatefulBuilder(builder: - (BuildContext context, StateSetter setState /*You can rename this!*/) { - return BaseView( - onModelReady: (model) => model.getCategory(), - builder: - (BuildContext context, ProcedureViewModel model, Widget child) => - NetworkBaseView( - baseViewModel: model, - child: SingleChildScrollView( - child: Container( - height: MediaQuery.of(context).size.height * 0.9, - child: Form( - child: Padding( - padding: - EdgeInsets.symmetric(horizontal: 20.0, vertical: 10.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - widget.procedureName.toUpperCase(), - fontWeight: FontWeight.w700, - ), - SizedBox( - height: 30.0, - ), - Container( - child: Row( - children: [ - AppText(TranslationBase.of(context).orderType), - Radio( - activeColor: AppGlobal.appRedColor, - value: 0, - groupValue: selectedType, - onChanged: (value) { - setSelectedType(value); - }, - ), - Text('routine'), - Radio( - activeColor: AppGlobal.appRedColor, - groupValue: selectedType, - value: 1, - onChanged: (value) { - setSelectedType(value); - }, - ), - Text(TranslationBase.of(context).urgent), - ], - ), - ), - SizedBox( - height: 12.0, - ), - Container( - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, color: HexColor("#CCCCCC"))), - child: TextFields( - fontSize: 15.0, - controller: widget.remarksController, - hintText: widget.remarksController.text.isEmpty - ? 'No Remarks Added' - : '', - maxLines: 3, - minLines: 2, - onChanged: (value) {}, - ), - ), - SizedBox( - height: 70.0, - ), - Container( - margin: - EdgeInsets.all(SizeConfig.widthMultiplier * 2), - child: Column( - children: [ - AppButton( - color: AppGlobal.appGreenColor, - title: TranslationBase.of(context) - .updateProcedure - .toUpperCase(), - onPressed: () { - Navigator.pop(context); - updateProcedure( - limetNO: widget.limetNo, - orderNo: widget.orderNo, - orderType: selectedType.toString(), - categorieId: widget.categoryId, - procedureId: widget.procedureId, - entityList: entityList, - patient: widget.patient, - model: widget.model, - remarks: widget.remarksController.text); - // authorizationForm(context); - }, - ), - SizedBox( - height: 20.0, - ), - AppButton( - title: TranslationBase.of(context).cancel, - color: AppGlobal.appRedColor, - onPressed: () { - Navigator.pop(context); - }, - ) - ], - ), - ), - ], - ), - ), - )), - ), - ), - ); - }); - } - - updateProcedure( - {ProcedureViewModel model, - String remarks, - int limetNO, - int orderNo, - String newProcedureId, - String newCategorieId, - List entityList, - String orderType, - String procedureId, - PatiantInformtion patient, - String categorieId}) async { - UpdateProcedureRequestModel updateProcedureReqModel = - new UpdateProcedureRequestModel(); - List controls = List(); - ProcedureDetail controlsProcedure = new ProcedureDetail(); - - updateProcedureReqModel.appointmentNo = patient.appointmentNo; - - updateProcedureReqModel.episodeID = patient.episodeNo; - updateProcedureReqModel.patientMRN = patient.patientMRN; - updateProcedureReqModel.lineItemNo = limetNO; - updateProcedureReqModel.orderNo = orderNo; - - { - controls.add( - Controls( - code: "remarks", controlValue: remarks.isNotEmpty ? remarks : ""), - ); - controls.add( - Controls(code: "ordertype", controlValue: orderType), - ); - - controlsProcedure.procedure = procedureId; - controlsProcedure.category = '0' + categorieId; - - controlsProcedure.controls = controls; - } - updateProcedureReqModel.procedureDetail = controlsProcedure; - - await model.updateProcedure( - updateProcedureRequestModel: updateProcedureReqModel, - mrn: patient.patientMRN); - - if (model.state == ViewState.ErrorLocal) { - Utils.showErrorToast(model.error); - model.getProcedure(mrn: patient.patientMRN); - } else if (model.state == ViewState.Idle) { - DrAppToastMsg.showSuccesToast('procedure has been updated'); - model.getProcedure(mrn: patient.patientMRN); - } - } - - - ///TODO Elham* move it to view model - bool isEntityListSelected(EntityList masterKey) { - Iterable history = entityList - .where((element) => masterKey.procedureId == element.procedureId); - if (history.length > 0) { - return true; - } - return false; - } -} diff --git a/lib/screens/procedures/update_procedure.dart b/lib/screens/procedures/update_procedure.dart new file mode 100644 index 00000000..1885582f --- /dev/null +++ b/lib/screens/procedures/update_procedure.dart @@ -0,0 +1,247 @@ +import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/core/enum/view_state.dart'; +import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/core/model/procedure/ControlsModel.dart'; +import 'package:doctor_app_flutter/core/model/procedure/categories_procedure.dart'; +import 'package:doctor_app_flutter/core/model/procedure/update_procedure_request_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart'; +import 'package:doctor_app_flutter/utils/dr_app_toast_msg.dart'; +import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; +import 'package:doctor_app_flutter/utils/utils.dart'; +import 'package:doctor_app_flutter/widgets/bottom_sheet/custom_bottom_sheet_container.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/loader/gif_loader_dialog_utils.dart'; +import 'package:doctor_app_flutter/widgets/shared/text_fields/TextFields.dart'; +import 'package:flutter/material.dart'; +import 'package:hexcolor/hexcolor.dart'; + +void updateProcedureForm(context, + {String procedureName, + int orderNo, + int limetNo, + PatiantInformtion patient, + String orderType, + String procedureId, + String remarks, + ProcedureViewModel model, + String categoreId}) { + TextEditingController remarksController = TextEditingController(); + showModalBottomSheet( + context: context, + isScrollControlled: true, + builder: (BuildContext bc) { + return UpdateProcedureWidget( + procedureName: procedureName, + remarks: remarks, + remarksController: remarksController, + patient: patient, + previousModel: model, + procedureId: procedureId, + categoryId: categoreId, + orderNo: orderNo, + limetNo: limetNo, + selectedType: int.parse(orderType), + ); + }); +} + +class UpdateProcedureWidget extends StatefulWidget { + final PatiantInformtion patient; + final ProcedureViewModel previousModel; + final String procedureName; + final String remarks; + final TextEditingController remarksController; + final String procedureId; + final String categoryId; + final int orderNo; + final int limetNo; + int selectedType; + + + UpdateProcedureWidget( + {this.previousModel, + this.procedureName, + this.remarks, + this.remarksController, + this.patient, + this.procedureId, + this.categoryId, + this.orderNo, + this.limetNo, this.selectedType}); + + @override + _UpdateProcedureWidgetState createState() => _UpdateProcedureWidgetState(); +} + +class _UpdateProcedureWidgetState extends State { + + setSelectedType(int val) { + setState(() { + widget.selectedType = val; + }); + } + + void initState() { + super.initState(); + widget.remarksController.text = widget.remarks; + } + + List entityList = List(); + dynamic selectedCategory; + + /// TODO Roaa Add translation and make sure it working fine + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) => model.getCategory(), + builder: + (BuildContext context, ProcedureViewModel _model, Widget child) => + AppScaffold( + baseViewModel: widget.previousModel, + isShowAppBar: true, + appBar: BottomSheetTitle(title: "Update Procedure"), + body: SingleChildScrollView( + child: Container( + height: MediaQuery.of(context).size.height * 0.9, + child: Form( + child: Padding( + padding: + EdgeInsets.symmetric(horizontal: 20.0, vertical: 10.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + Utils.convertToTitleCase(widget.procedureName), + fontWeight: FontWeight.w700, + ), + SizedBox( + height: 30.0, + ), + Container( + child: Row( + children: [ + AppText(TranslationBase.of(context).orderType), + Radio( + activeColor: AppGlobal.appRedColor, + value: 0, + groupValue: widget.selectedType, + onChanged: (value) { + setSelectedType(value); + }, + ), + Text('routine'), + Radio( + activeColor: AppGlobal.appRedColor, + groupValue: widget.selectedType, + value: 1, + onChanged: (value) { + setSelectedType(value); + }, + ), + Text(TranslationBase.of(context).urgent), + ], + ), + ), + SizedBox( + height: 12.0, + ), + Container( + decoration: BoxDecoration( + borderRadius: + BorderRadius.all(Radius.circular(6.0)), + border: Border.all( + width: 1.0, color: HexColor("#CCCCCC"))), + child: TextFields( + fontSize: 15.0, + controller: widget.remarksController, + hintText: widget.remarksController.text.isEmpty + ? 'No Remarks Added' + : '', + maxLines: 3, + minLines: 2, + onChanged: (value) {}, + ), + ), + SizedBox( + height: 70.0, + ), + ], + ), + ), + )), + ), + bottomSheet: CustomBottomSheetContainer( + label: TranslationBase.of(context).updateProcedure, + onTap: () => updateProcedure( + lineItemNo: widget.limetNo, + orderNo: widget.orderNo, + orderType: widget.selectedType.toString(), + categoryId: widget.categoryId, + procedureId: widget.procedureId, + entityList: entityList, + patient: widget.patient, + model: widget.previousModel, + remarks: widget.remarksController.text), + ), + ), + ); + } + + updateProcedure( + {ProcedureViewModel model, + String remarks, + int lineItemNo, + int orderNo, + String newProcedureId, + String newCategoryId, + List entityList, + String orderType, + String procedureId, + PatiantInformtion patient, + String categoryId}) async { + UpdateProcedureRequestModel updateProcedureReqModel = + new UpdateProcedureRequestModel(); + List controls = List(); + ProcedureDetail controlsProcedure = new ProcedureDetail(); + + updateProcedureReqModel.appointmentNo = patient.appointmentNo; + + updateProcedureReqModel.episodeID = patient.episodeNo; + updateProcedureReqModel.patientMRN = patient.patientMRN; + updateProcedureReqModel.lineItemNo = lineItemNo; + updateProcedureReqModel.orderNo = orderNo; + + { + controls.add( + Controls( + code: "remarks", controlValue: remarks.isNotEmpty ? remarks : ""), + ); + controls.add( + Controls(code: "ordertype", controlValue: orderType), + ); + + controlsProcedure.procedure = procedureId; + controlsProcedure.category = '0' + categoryId; + + controlsProcedure.controls = controls; + } + updateProcedureReqModel.procedureDetail = controlsProcedure; + GifLoaderDialogUtils.showMyDialog(context); + await widget.previousModel.updateProcedure( + updateProcedureRequestModel: updateProcedureReqModel, + mrn: patient.patientMRN, isLocalBusy: true); + + if (model.state == ViewState.ErrorLocal) { + Utils.showErrorToast(model.error); + } else if (model.state == ViewState.Idle) { + DrAppToastMsg.showSuccesToast('procedure has been updated'); + await widget.previousModel.getProcedure(mrn: patient.patientMRN, isLocalBusy: true); + Navigator.of(context).pop(); + + } + GifLoaderDialogUtils.hideDialog(context); + } +}