From ea4bf159c65bff1012c6b6a535eab5383918c5be Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Thu, 31 Dec 2020 08:37:30 +0200 Subject: [PATCH 01/15] commit issue --- lib/config/config.dart | 10 +-- lib/core/service/SOAP_service.dart | 6 +- .../profile/SOAP/assessment_page.dart | 56 +++++++------ .../patients/profile/SOAP/objective_page.dart | 74 +++++++++-------- .../patients/profile/SOAP/plan_page.dart | 32 ++++---- .../patients/profile/SOAP/steps_widget.dart | 14 ++-- .../SOAP/subjective/subjective_page.dart | 82 ++++++++++--------- 7 files changed, 141 insertions(+), 133 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index 1a13d7e9..08417a05 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -123,12 +123,12 @@ const GET_PATIENT_ARRIVAL_LIST = const GET_ALLERGIES = 'Services/DoctorApplication.svc/REST/GetAllergies'; const GET_MASTER_LOOKUP_LIST = 'Services/DoctorApplication.svc/REST/GetMasterLookUpList'; -const PATCH_ALLERGY = 'Services/DoctorApplication.svc/REST/PatchAllergies'; -const PATCH_HISTORY = 'Services/DoctorApplication.svc/REST/PatchHistory'; -const PATCH_CHIEF_COMPLAINT = - 'Services/DoctorApplication.svc/REST/PatchChiefcomplaint'; +const POST_ALLERGY = 'Services/DoctorApplication.svc/REST/PostAllergies'; +const POST_HISTORY = 'Services/DoctorApplication.svc/REST/PostHistory'; +const POST_CHIEF_COMPLAINT = + 'Services/DoctorApplication.svc/REST/PostChiefcomplaint'; const POST_PHYSICAL_EXAM = - 'Services/DoctorApplication.svc/REST/PatchPhysicalExam'; + 'Services/DoctorApplication.svc/REST/PostPhysicalExam'; const POST_PROGRESS_NOTE = 'Services/DoctorApplication.svc/REST/PostProgressNote'; diff --git a/lib/core/service/SOAP_service.dart b/lib/core/service/SOAP_service.dart index 45777511..3219ef6a 100644 --- a/lib/core/service/SOAP_service.dart +++ b/lib/core/service/SOAP_service.dart @@ -31,7 +31,7 @@ class SOAPService extends LookupService { Future postAllergy(PostAllergyRequestModel postAllergyRequestModel) async { hasError = false; - await baseAppClient.post(PATCH_ALLERGY, + await baseAppClient.post(POST_ALLERGY, onSuccess: (dynamic response, int statusCode) { print("Success"); }, onFailure: (String error, int statusCode) { @@ -43,7 +43,7 @@ class SOAPService extends LookupService { Future postHistories( PostHistoriesRequestModel postHistoriesRequestModel) async { hasError = false; - await baseAppClient.post(PATCH_HISTORY, + await baseAppClient.post(POST_HISTORY, onSuccess: (dynamic response, int statusCode) { print("Success"); }, onFailure: (String error, int statusCode) { @@ -55,7 +55,7 @@ class SOAPService extends LookupService { Future postChiefComplaint( PostChiefComplaintRequestModel postChiefComplaintRequestModel) async { hasError = false; - await baseAppClient.post(PATCH_CHIEF_COMPLAINT, + await baseAppClient.post(POST_CHIEF_COMPLAINT, onSuccess: (dynamic response, int statusCode) { print("Success"); }, onFailure: (String error, int statusCode) { diff --git a/lib/widgets/patients/profile/SOAP/assessment_page.dart b/lib/widgets/patients/profile/SOAP/assessment_page.dart index 76c6cdec..7c55dca6 100644 --- a/lib/widgets/patients/profile/SOAP/assessment_page.dart +++ b/lib/widgets/patients/profile/SOAP/assessment_page.dart @@ -310,34 +310,36 @@ class _AssessmentPageState extends State { } submitAssessment(SOAPViewModel model) async { - if (widget.mySelectedAssessment.selectedDiagnosisCondition != null && - widget.mySelectedAssessment.selectedDiagnosisType != null) { - PostAssessmentRequestModel postAssessmentRequestModel = - new PostAssessmentRequestModel( - patientMRN: widget.patientInfo.patientMRN, - episodeId: widget.patientInfo.episodeNo, - appointmentNo: widget.patientInfo.appointmentNo, - icdCodeDetails: [ - new IcdCodeDetails( - remarks: widget.mySelectedAssessment.remark, - complexDiagnosis: true, - conditionId: - widget.mySelectedAssessment.selectedDiagnosisCondition.id, - diagnosisTypeId: - widget.mySelectedAssessment.selectedDiagnosisType.id, - icdcode10Id: "1") - ]); + // if (widget.mySelectedAssessment.selectedDiagnosisCondition != null && + // widget.mySelectedAssessment.selectedDiagnosisType != null) { + // PostAssessmentRequestModel postAssessmentRequestModel = + // new PostAssessmentRequestModel( + // patientMRN: widget.patientInfo.patientMRN, + // episodeId: widget.patientInfo.episodeNo, + // appointmentNo: widget.patientInfo.appointmentNo, + // icdCodeDetails: [ + // new IcdCodeDetails( + // remarks: widget.mySelectedAssessment.remark, + // complexDiagnosis: true, + // conditionId: + // widget.mySelectedAssessment.selectedDiagnosisCondition.id, + // diagnosisTypeId: + // widget.mySelectedAssessment.selectedDiagnosisType.id, + // icdcode10Id: "1") + // ]); + // + // await model.postAssessment(postAssessmentRequestModel); + // + // if (model.state == ViewState.ErrorLocal) { + // helpers.showErrorToast(model.error); + // } else { + // widget.changePageViewIndex(3); + // } + // } else { + // helpers.showErrorToast('Please add required field correctly'); + // } - await model.postAssessment(postAssessmentRequestModel); - - if (model.state == ViewState.ErrorLocal) { - helpers.showErrorToast(model.error); - } else { - widget.changePageViewIndex(3); - } - } else { - helpers.showErrorToast('Please add required field correctly'); - } + widget.changePageViewIndex(3); } openAssessmentDialog(BuildContext context) { diff --git a/lib/widgets/patients/profile/SOAP/objective_page.dart b/lib/widgets/patients/profile/SOAP/objective_page.dart index 6441ac6c..db0a27d0 100644 --- a/lib/widgets/patients/profile/SOAP/objective_page.dart +++ b/lib/widgets/patients/profile/SOAP/objective_page.dart @@ -321,43 +321,45 @@ class _ObjectivePageState extends State { } submitObjectivePage(SOAPViewModel model) async { - if(widget.mySelectedExamination.isNotEmpty){ - PostPhysicalExamRequestModel postPhysicalExamRequestModel = new PostPhysicalExamRequestModel(); - widget.mySelectedExamination.forEach((exam) { - if (postPhysicalExamRequestModel.listHisProgNotePhysicalExaminationVM == - null) - postPhysicalExamRequestModel.listHisProgNotePhysicalExaminationVM = []; + // if(widget.mySelectedExamination.isNotEmpty){ + // PostPhysicalExamRequestModel postPhysicalExamRequestModel = new PostPhysicalExamRequestModel(); + // widget.mySelectedExamination.forEach((exam) { + // if (postPhysicalExamRequestModel.listHisProgNotePhysicalExaminationVM == + // null) + // postPhysicalExamRequestModel.listHisProgNotePhysicalExaminationVM = []; + // // TODO : change createdBy editedBy + // postPhysicalExamRequestModel.listHisProgNotePhysicalExaminationVM.add( + // ListHisProgNotePhysicalExaminationVM( + // patientMRN: widget.patientInfo.patientMRN, + // episodeId: widget.patientInfo.episodeNo, + // appointmentNo: widget.patientInfo.appointmentNo, + // remarks: exam.remark ?? '', + // createdBy: 4709, + // createdOn: DateTime.now().toIso8601String(), + // editedBy: 4709, + // editedOn: DateTime.now().toIso8601String(), + // examId: exam.selectedExamination.id, + // examType: exam.selectedExamination.typeId, + // isAbnormal: exam.isAbnormal, + // isNormal: exam.isNormal, + // masterDescription: exam.selectedExamination, + // notExamined: false + // + // )); + // }); + // + // await model.postPhysicalExam(postPhysicalExamRequestModel); + // + // if (model.state == ViewState.ErrorLocal) { + // helpers.showErrorToast(model.error); + // } else { + // widget.changePageViewIndex(2); + // } + // } else { + // helpers.showErrorToast('Please add required field correctly'); + // } - postPhysicalExamRequestModel.listHisProgNotePhysicalExaminationVM.add( - ListHisProgNotePhysicalExaminationVM( - patientMRN: widget.patientInfo.patientMRN, - episodeId: widget.patientInfo.episodeNo, - appointmentNo: widget.patientInfo.appointmentNo, - remarks: exam.remark ?? '', - createdBy: 1485, - createdOn: DateTime.now().toIso8601String(), - editedBy: 1485, - editedOn: DateTime.now().toIso8601String(), - examId: exam.selectedExamination.id, - examType: exam.selectedExamination.typeId, - isAbnormal: exam.isAbnormal, - isNormal: exam.isNormal, - masterDescription: exam.selectedExamination, - notExamined: false - - )); - }); - - await model.postPhysicalExam(postPhysicalExamRequestModel); - - if (model.state == ViewState.ErrorLocal) { - helpers.showErrorToast(model.error); - } else { - widget.changePageViewIndex(2); - } - } else { - helpers.showErrorToast('Please add required field correctly'); - } + widget.changePageViewIndex(2); } removeExamination(MasterKeyModel masterKey) { diff --git a/lib/widgets/patients/profile/SOAP/plan_page.dart b/lib/widgets/patients/profile/SOAP/plan_page.dart index 3bf7aa5e..e0653b3e 100644 --- a/lib/widgets/patients/profile/SOAP/plan_page.dart +++ b/lib/widgets/patients/profile/SOAP/plan_page.dart @@ -269,22 +269,24 @@ class _PlanPageState extends State { } submitPlan(SOAPViewModel model) async { - if (progressNoteController.text.isNotEmpty) { - PostProgressNoteRequestModel postProgressNoteRequestModel = new PostProgressNoteRequestModel( - patientMRN: widget.patientInfo.patientMRN, - episodeId: widget.patientInfo.episodeNo, - appointmentNo: widget.patientInfo.appointmentNo, - planNote: progressNoteController.text); + // if (progressNoteController.text.isNotEmpty) { + // PostProgressNoteRequestModel postProgressNoteRequestModel = new PostProgressNoteRequestModel( + // patientMRN: widget.patientInfo.patientMRN, + // episodeId: widget.patientInfo.episodeNo, + // appointmentNo: widget.patientInfo.appointmentNo, + // planNote: progressNoteController.text); + // + // + // await model.postProgressNote(postProgressNoteRequestModel); + // + // if (model.state == ViewState.ErrorLocal) { + // helpers.showErrorToast(model.error); + // } else { + // Navigator.of(context).pop(); + // } + // } - - await model.postProgressNote(postProgressNoteRequestModel); - - if (model.state == ViewState.ErrorLocal) { - helpers.showErrorToast(model.error); - } else { - Navigator.of(context).pop(); - } - } + Navigator.of(context).pop(); } openProgressNote(BuildContext context) { diff --git a/lib/widgets/patients/profile/SOAP/steps_widget.dart b/lib/widgets/patients/profile/SOAP/steps_widget.dart index d5cb7ddc..d67d94e3 100644 --- a/lib/widgets/patients/profile/SOAP/steps_widget.dart +++ b/lib/widgets/patients/profile/SOAP/steps_widget.dart @@ -34,7 +34,7 @@ class StepsWidget extends StatelessWidget { top: index == 0 ? 15 : 30, left: 0, child: InkWell( - onTap: () => changeCurrentTab(0), + //onTap: () => changeCurrentTab(0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -84,7 +84,7 @@ class StepsWidget extends StatelessWidget { top: index == 1 ? 15 : 30, left: MediaQuery.of(context).size.width * 0.28, child: InkWell( - onTap: () => index >= 1 ? changeCurrentTab(1) : null, + //onTap: () => index >= 1 ? changeCurrentTab(1) : null, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -187,7 +187,7 @@ class StepsWidget extends StatelessWidget { top: index == 3 ? 15 : 30, right: 0, child: InkWell( - onTap: () => index >= 3 ? changeCurrentTab(4) : null, + //onTap: () => index >= 3 ? changeCurrentTab(4) : null, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -257,7 +257,7 @@ class StepsWidget extends StatelessWidget { top: index == 0 ? 15 : 30, right: 0, child: InkWell( - onTap: () => changeCurrentTab(0), + //onTap: () => changeCurrentTab(0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -307,7 +307,7 @@ class StepsWidget extends StatelessWidget { top: index == 1 ? 15 : 30, right: MediaQuery.of(context).size.width * 0.28, child: InkWell( - onTap: () => index >= 2 ? changeCurrentTab(1) : null, + //onTap: () => index >= 2 ? changeCurrentTab(1) : null, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -357,7 +357,7 @@ class StepsWidget extends StatelessWidget { top: index == 2 ? 15 : 30, right: MediaQuery.of(context).size.width * 0.52, child: InkWell( - onTap: () => index >= 3 ? changeCurrentTab(2) : null, + //onTap: () => index >= 3 ? changeCurrentTab(2) : null, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -411,7 +411,7 @@ class StepsWidget extends StatelessWidget { top: index == 3 ? 15 : 30, left: 0, child: InkWell( - onTap: () => index >= 3 ? changeCurrentTab(4) : null, + //onTap: () => index >= 3 ? changeCurrentTab(4) : null, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ diff --git a/lib/widgets/patients/profile/SOAP/subjective/subjective_page.dart b/lib/widgets/patients/profile/SOAP/subjective/subjective_page.dart index 18849aa5..c3d56fe8 100644 --- a/lib/widgets/patients/profile/SOAP/subjective/subjective_page.dart +++ b/lib/widgets/patients/profile/SOAP/subjective/subjective_page.dart @@ -277,45 +277,47 @@ class _SubjectivePageState extends State { formKey.currentState.validate(); - if(complaintsController.text.isNotEmpty && illnessController.text.isNotEmpty && complaintsController.text.length>25) { - await postChiefComplaint(model: model); - if (model.state == ViewState.ErrorLocal) { - helpers.showErrorToast(model.error); - } else { - if (myHistoryList.length != 0) { - await postHistories(model: model, myHistoryList: myHistoryList); - if (model.state == ViewState.ErrorLocal) { - helpers.showErrorToast(model.error); - } else { - if (myAllergiesList.length != 0) { - await postAllergy(myAllergiesList: myAllergiesList, model: model); - if (model.state == ViewState.ErrorLocal) { - helpers.showErrorToast(model.error); - } else { - widget.changePageViewIndex(1); - } - } else { - widget.changePageViewIndex(1); + // if(complaintsController.text.isNotEmpty && illnessController.text.isNotEmpty && complaintsController.text.length>25) { + // await postChiefComplaint(model: model); + // if (model.state == ViewState.ErrorLocal) { + // helpers.showErrorToast(model.error); + // } else { + // if (myHistoryList.length != 0) { + // await postHistories(model: model, myHistoryList: myHistoryList); + // if (model.state == ViewState.ErrorLocal) { + // helpers.showErrorToast(model.error); + // } else { + // if (myAllergiesList.length != 0) { + // await postAllergy(myAllergiesList: myAllergiesList, model: model); + // if (model.state == ViewState.ErrorLocal) { + // helpers.showErrorToast(model.error); + // } else { + // widget.changePageViewIndex(1); + // } + // } else { + // widget.changePageViewIndex(1); + // + // } + // + // } + // } else { + // if (myAllergiesList.length != 0) { + // await postAllergy(myAllergiesList: myAllergiesList, model: model); + // if (model.state == ViewState.ErrorLocal) { + // helpers.showErrorToast(model.error); + // } else { + // widget.changePageViewIndex(1); + // } + // } else { + // widget.changePageViewIndex(1); + // } + // } + // } + // } else { + // helpers.showErrorToast('Please add required field correctly'); + // } - } - - } - } else { - if (myAllergiesList.length != 0) { - await postAllergy(myAllergiesList: myAllergiesList, model: model); - if (model.state == ViewState.ErrorLocal) { - helpers.showErrorToast(model.error); - } else { - widget.changePageViewIndex(1); - } - } else { - widget.changePageViewIndex(1); - } - } - } - } else { - helpers.showErrorToast('Please add required field correctly'); - } + widget.changePageViewIndex(1); } @@ -337,10 +339,10 @@ class _SubjectivePageState extends State { appointmentNo: widget.patientInfo.appointmentNo, severity: allergy.selectedAllergySeverity.id, remarks: allergy.remark, - createdBy: 1485, + createdBy: 4709, // createdOn: DateTime.now().toIso8601String(),//"2020-08-14T20:37:22.780Z", - editedBy: 1485, + editedBy: 4709, editedOn: DateTime.now().toIso8601String(),//"2020-08-14T20:37:22.780Z", isChecked: false, isUpdatedByNurse: false)); From b3345a86eff841653202d045fdca6432c82dc1ad Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Thu, 31 Dec 2020 12:39:34 +0200 Subject: [PATCH 02/15] post prescription --- lib/core/service/prescription_service.dart | 2 +- .../viewModel/prescription_view_model.dart | 4 +- lib/core/viewModel/procedure_View_model.dart | 4 +- .../patients/patient_search_screen.dart | 18 +- .../prescription/add_prescription_form.dart | 525 +++++++++++------- .../prescription/prescription_screen.dart | 139 +++-- lib/screens/procedures/procedure_screen.dart | 327 ++++++++--- .../SOAP/subjective/subjective_page.dart | 70 +-- 8 files changed, 699 insertions(+), 390 deletions(-) diff --git a/lib/core/service/prescription_service.dart b/lib/core/service/prescription_service.dart index 65e74dda..9d1cb102 100644 --- a/lib/core/service/prescription_service.dart +++ b/lib/core/service/prescription_service.dart @@ -9,7 +9,7 @@ class PrescriptionService extends BaseService { List get prescriptionList => _prescriptionList; PrescriptionReqModel _prescriptionReqModel = PrescriptionReqModel( - patientMRN: 1231755, + patientMRN: 3120877, vidaAuthTokenID: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIyODA0IiwianRpIjoiNzNiNmUyZDctMjA0ZC00NzAyLTkxMDYtODE3MzI3OTZkYzI5IiwiZW1haWwiOiJNb2hhbWVkLlJlc3dhbkBjbG91ZHNvbHV0aW9uLXNhLmNvbSIsImlkIjoiMjgwNCIsIk5hbWUiOiJNVUhBTU1BRCBBWkFNIiwiRW1wbG95ZWVJZCI6IjE0ODUiLCJGYWNpbGl0eUdyb3VwSWQiOiIwMTAyNjYiLCJGYWNpbGl0eUlkIjoiMTUiLCJQaGFyYW1jeUZhY2lsaXR5SWQiOiI1NSIsIklTX1BIQVJNQUNZX0NPTk5FQ1RFRCI6IlRydWUiLCJEb2N0b3JJZCI6IjE0ODUiLCJTRVNTSU9OSUQiOiIyMTU3NjIwOSIsIkNsaW5pY0lkIjoiMyIsInJvbGUiOlsiU0VDVVJJVFkgQURNSU5JU1RSQVRPUlMiLCJTRVRVUCBBRE1JTklTVFJBVE9SUyIsIkNFTydTIiwiRVhFQ1VUSVZFIERJUkVDVE9SUyIsIk1BTkFHRVJTIiwiU1VQRVJWSVNPUlMiLCJDTElFTlQgU0VSVklDRVMgQ09PUkRJTkFUT1JTIiwiQ0xJRU5UIFNFUlZJQ0VTIFNVUEVSVklTT1JTIiwiQ0xJRU5UIFNFUlZJQ0VTIE1BTkdFUlMiLCJIRUFEIE5VUlNFUyIsIkRPQ1RPUlMiLCJDSElFRiBPRiBNRURJQ0FMIFNUQUZGUyIsIkJJTy1NRURJQ0FMIFRFQ0hOSUNJQU5TIiwiQklPLU1FRElDQUwgRU5HSU5FRVJTIiwiQklPLU1FRElDQUwgREVQQVJUTUVOVCBIRUFEUyIsIklUIEhFTFAgREVTSyIsIkFETUlOSVNUUkFUT1JTIiwiTEFCIEFETUlOSVNUUkFUT1IiLCJMQUIgVEVDSE5JQ0lBTiIsIkJVU0lORVNTIE9GRklDRSBTVEFGRiIsIkZJTkFOQ0UgQUNDT1VOVEFOVFMiLCJQSEFSTUFDWSBTVEFGRiIsIkFDQ09VTlRTIFNUQUZGIiwiTEFCIFJFQ0VQVElPTklTVCIsIkVSIE5VUlNFIiwiSU5QQVRJRU5UIEJJTExJTkcgU1VQRVJWSVNPUiIsIkxEUi1PUiBOVVJTRVMiLCJBRE1JU1NJT04gU1RBRkYiLCJIRUxQIERFU0sgQURNSU4iLCJBUFBST1ZBTCBTVEFGRiIsIklOUEFUSUVOVCBCSUxMSU5HIENPT1JESU5BVE9SIiwiQklMTElORyBTVEFGRiIsIkNPTlNFTlQgIiwiQ29uc2VudCAtIERlbnRhbCIsIldFQkVNUiJdLCJuYmYiOjE2MDgyMzY2MjAsImV4cCI6MTYwOTEwMDYyMCwiaWF0IjoxNjA4MjM2NjIwfQ.z4Lh0dCRr9GWXvaTo7x5GPV7R5z8ONyh3-0uk3PXMu8", ); diff --git a/lib/core/viewModel/prescription_view_model.dart b/lib/core/viewModel/prescription_view_model.dart index 6c3fe7b2..7923c3d7 100644 --- a/lib/core/viewModel/prescription_view_model.dart +++ b/lib/core/viewModel/prescription_view_model.dart @@ -33,7 +33,9 @@ class PrescriptionViewModel extends BaseViewModel { if (_prescriptionService.hasError) { error = _prescriptionService.error; setState(ViewState.ErrorLocal); - } else + } else { + await getPrescription(); setState(ViewState.Idle); + } } } diff --git a/lib/core/viewModel/procedure_View_model.dart b/lib/core/viewModel/procedure_View_model.dart index 13e18ed3..b051d04d 100644 --- a/lib/core/viewModel/procedure_View_model.dart +++ b/lib/core/viewModel/procedure_View_model.dart @@ -45,7 +45,9 @@ class ProcedureViewModel extends BaseViewModel { if (_procedureService.hasError) { error = _procedureService.error; setState(ViewState.ErrorLocal); - } else + } else { + await getProcedure(); setState(ViewState.Idle); + } } } diff --git a/lib/screens/patients/patient_search_screen.dart b/lib/screens/patients/patient_search_screen.dart index 9de384b6..f64a43f5 100644 --- a/lib/screens/patients/patient_search_screen.dart +++ b/lib/screens/patients/patient_search_screen.dart @@ -72,9 +72,9 @@ class _PatientSearchScreenState extends State { //_selectedType=='3'? //===================== - Map profile = await sharedPref.getObj(DOCTOR_PROFILE); - DoctorProfileModel doctorProfile = - new DoctorProfileModel.fromJson(profile); + //Map profile = await sharedPref.getObj(DOCTOR_PROFILE); + // DoctorProfileModel doctorProfile = + // new DoctorProfileModel.fromJson(profile); if (_formKey.currentState.validate()) { _formKey.currentState.save(); @@ -83,16 +83,16 @@ class _PatientSearchScreenState extends State { print('_selectedType${_selectedType}'); String token = await sharedPref.getString(TOKEN); - _patientSearchFormValues.TokenID = token; - _patientSearchFormValues.ProjectID = doctorProfile.projectID; //15 - _patientSearchFormValues.DoctorID = doctorProfile.doctorID; - _patientSearchFormValues.ClinicID = doctorProfile.clinicID; + // _patientSearchFormValues.TokenID = token; + // _patientSearchFormValues.ProjectID = doctorProfile.projectID; //15 + // _patientSearchFormValues.DoctorID = doctorProfile.doctorID; + // _patientSearchFormValues.ClinicID = doctorProfile.clinicID; //===================== // _patientSearchFormValues. //===================== - print("=============doctorProfile.clinicID=" + - doctorProfile.clinicID.toString()); + // print("=============doctorProfile.clinicID=" + + // doctorProfile.clinicID.toString()); Navigator.of(context).pushNamed(PATIENTS, arguments: { "patientSearchForm": _patientSearchFormValues, diff --git a/lib/screens/prescription/add_prescription_form.dart b/lib/screens/prescription/add_prescription_form.dart index 5782a166..a988b61c 100644 --- a/lib/screens/prescription/add_prescription_form.dart +++ b/lib/screens/prescription/add_prescription_form.dart @@ -5,250 +5,355 @@ import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/model/post_prescrition_req_model.dart'; import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; import 'package:doctor_app_flutter/models/livecare/transfer_to_admin.dart'; +import 'package:doctor_app_flutter/screens/prescription/prescription_screen.dart'; import 'package:doctor_app_flutter/screens/prescription/prescription_warnings.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_text_form_field.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; -void addPrescriptionForm(context) { +void addPrescriptionForm(context, PrescriptionViewModel model) { TextEditingController durationController = TextEditingController(); + TextEditingController strengthController = TextEditingController(); + TextEditingController routeController = TextEditingController(); + TextEditingController frequencyController = TextEditingController(); + TextEditingController indicationController = TextEditingController(); + TextEditingController instructions = TextEditingController(); + + TextEditingController drugIdController = TextEditingController(); TextEditingController doseController = TextEditingController(); - final GlobalKey _formKey = GlobalKey(); + final GlobalKey formKey = GlobalKey(); final double spaceBetweenTextFileds = 12; showModalBottomSheet( isScrollControlled: true, context: context, builder: (BuildContext bc) { - return SingleChildScrollView( - child: Container( - height: 700, - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 12.0, vertical: 10.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - //mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - AppText( - TranslationBase.of(context).medicines.toUpperCase(), - fontWeight: FontWeight.w900, - ), - SizedBox( - height: spaceBetweenTextFileds, - ), - Container( - child: Form( - key: _formKey, - child: Column( - //mainAxisAlignment: MainAxisAlignment.end, - children: [ - Container( - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, color: HexColor("#CCCCCC"))), - child: AppTextFormField( - labelText: - TranslationBase.of(context).searchMedicine, - borderColor: Colors.white, - textInputType: TextInputType.text, - inputFormatter: ONLY_LETTERS, - ), - ), - SizedBox( - height: spaceBetweenTextFileds, - ), - Container( - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, color: HexColor("#CCCCCC"))), - child: AppTextFormField( - labelText: TranslationBase.of(context).orderType, - borderColor: Colors.white, - textInputType: TextInputType.number, - inputFormatter: ONLY_NUMBERS, - ), - ), - SizedBox(height: spaceBetweenTextFileds), - Container( - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, color: HexColor("#CCCCCC"))), - child: AppTextFormField( - labelText: TranslationBase.of(context).strength, - borderColor: Colors.white, - textInputType: TextInputType.number, - inputFormatter: ONLY_NUMBERS, - ), - ), - SizedBox(height: spaceBetweenTextFileds), - Container( - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, color: HexColor("#CCCCCC"))), - child: AppTextFormField( - labelText: TranslationBase.of(context).route, - borderColor: Colors.white, - textInputType: TextInputType.number, - inputFormatter: ONLY_NUMBERS, - ), - ), - SizedBox(height: spaceBetweenTextFileds), - Container( - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, color: HexColor("#CCCCCC"))), - child: AppTextFormField( - labelText: TranslationBase.of(context).frequency, - borderColor: Colors.white, - textInputType: TextInputType.number, - inputFormatter: ONLY_NUMBERS, - ), - ), - SizedBox(height: spaceBetweenTextFileds), - Container( - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, color: HexColor("#CCCCCC"))), - child: AppTextFormField( - labelText: TranslationBase.of(context).doseTime, - borderColor: Colors.white, - textInputType: TextInputType.number, - inputFormatter: ONLY_NUMBERS, - controller: doseController, - ), - ), - SizedBox(height: spaceBetweenTextFileds), - Container( - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, color: HexColor("#CCCCCC"))), - child: AppTextFormField( - labelText: TranslationBase.of(context).indication, - borderColor: Colors.white, - textInputType: TextInputType.number, - inputFormatter: ONLY_NUMBERS, - ), - ), - SizedBox(height: spaceBetweenTextFileds), - Container( - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, color: HexColor("#CCCCCC"))), - child: AppTextFormField( - labelText: TranslationBase.of(context).fromDate, - borderColor: Colors.white, - textInputType: TextInputType.number, - inputFormatter: ONLY_NUMBERS, - ), - ), - SizedBox(height: spaceBetweenTextFileds), - Container( - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, color: HexColor("#CCCCCC"))), - child: AppTextFormField( - labelText: TranslationBase.of(context).duration, - borderColor: Colors.white, - textInputType: TextInputType.number, - inputFormatter: ONLY_NUMBERS, - controller: durationController, - validator: (value) { - if (value == null || value == "") - return TranslationBase.of(context) - .emptyMessage; - else - return null; - }), - ), - SizedBox(height: spaceBetweenTextFileds), - Container( - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, color: HexColor("#CCCCCC"))), - child: AppTextFormField( - labelText: - TranslationBase.of(context).instruction, - borderColor: Colors.white, - textInputType: TextInputType.number, - inputFormatter: ONLY_NUMBERS, - ), - ), - SizedBox(height: spaceBetweenTextFileds), - Container( - margin: - EdgeInsets.all(SizeConfig.widthMultiplier * 5), - child: Wrap( - alignment: WrapAlignment.center, - children: [ - AppButton( - title: - TranslationBase.of(context).addMedication, - onPressed: () { - //prescriptionWarning(context); - postProcedure( - duration: durationController.text, - dose: doseController.text); - Navigator.pop(context); - }, + return DraggableScrollableSheet( + initialChildSize: 0.90, + maxChildSize: 0.90, + minChildSize: 0.9, + builder: (BuildContext context, ScrollController scrollController) { + return SingleChildScrollView( + child: Container( + height: 980, + child: Padding( + padding: + EdgeInsets.symmetric(horizontal: 12.0, vertical: 10.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + //mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + AppText( + TranslationBase.of(context).medicines.toUpperCase(), + fontWeight: FontWeight.w900, + ), + SizedBox( + height: spaceBetweenTextFileds, + ), + Container( + child: Form( + key: formKey, + child: Column( + //mainAxisAlignment: MainAxisAlignment.end, + children: [ + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(6.0)), + border: Border.all( + width: 1.0, + color: HexColor("#CCCCCC"))), + child: TextFields( + hintText: TranslationBase.of(context) + .searchMedicine, + controller: drugIdController, + keyboardType: TextInputType.number, + validator: (value) { + if (value.isEmpty) + return TranslationBase.of(context) + .emptyMessage; + else + return null; + }), + ), + SizedBox( + height: spaceBetweenTextFileds, + ), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(6.0)), + border: Border.all( + width: 1.0, + color: HexColor("#CCCCCC"))), + child: TextFields( + hintText: + TranslationBase.of(context).orderType, + ), + ), + SizedBox(height: spaceBetweenTextFileds), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(6.0)), + border: Border.all( + width: 1.0, + color: HexColor("#CCCCCC"))), + child: TextFields( + hintText: + TranslationBase.of(context).strength, + keyboardType: TextInputType.number, + controller: strengthController, + validator: (value) { + if (value.isEmpty) + return TranslationBase.of(context) + .emptyMessage; + else + return null; + }, + ), + ), + SizedBox(height: spaceBetweenTextFileds), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(6.0)), + border: Border.all( + width: 1.0, + color: HexColor("#CCCCCC"))), + child: TextFields( + hintText: TranslationBase.of(context).route, + controller: routeController, + keyboardType: TextInputType.number, + validator: (value) { + if (value.isEmpty) + return TranslationBase.of(context) + .emptyMessage; + else + return null; + }, + ), + ), + SizedBox(height: spaceBetweenTextFileds), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(6.0)), + border: Border.all( + width: 1.0, + color: HexColor("#CCCCCC"))), + child: TextFields( + hintText: + TranslationBase.of(context).frequency, + controller: frequencyController, + keyboardType: TextInputType.number, + validator: (value) { + if (value.isEmpty) + return TranslationBase.of(context) + .emptyMessage; + else + return null; + }, + ), + ), + SizedBox(height: spaceBetweenTextFileds), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(6.0)), + border: Border.all( + width: 1.0, + color: HexColor("#CCCCCC"))), + child: TextFields( + hintText: + TranslationBase.of(context).doseTime, + controller: doseController, + keyboardType: TextInputType.number, + validator: (value) { + if (value.isEmpty) + return TranslationBase.of(context) + .emptyMessage; + else + return null; + }, + ), + ), + SizedBox(height: spaceBetweenTextFileds), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(6.0)), + border: Border.all( + width: 1.0, + color: HexColor("#CCCCCC"))), + child: TextFields( + hintText: + TranslationBase.of(context).indication, + controller: indicationController, + keyboardType: TextInputType.number, + validator: (value) { + if (value.isEmpty) + return TranslationBase.of(context) + .emptyMessage; + else + return null; + }, + ), + ), + SizedBox(height: spaceBetweenTextFileds), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(6.0)), + border: Border.all( + width: 1.0, + color: HexColor("#CCCCCC"))), + child: TextFields( + hintText: + TranslationBase.of(context).fromDate, + keyboardType: TextInputType.datetime, + validator: (value) { + if (value.isEmpty) + return TranslationBase.of(context) + .emptyMessage; + else + return null; + }, + ), + ), + SizedBox(height: spaceBetweenTextFileds), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(6.0)), + border: Border.all( + width: 1.0, + color: HexColor("#CCCCCC"))), + child: TextFields( + hintText: + TranslationBase.of(context).duration, + // borderColor: Colors.white, + keyboardType: TextInputType.number, + controller: durationController, + validator: (value) { + if (value.isEmpty) + return TranslationBase.of(context) + .emptyMessage; + else + return null; + }), + ), + SizedBox(height: spaceBetweenTextFileds), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(6.0)), + border: Border.all( + width: 1.0, + color: HexColor("#CCCCCC"))), + child: TextFields( + hintText: + TranslationBase.of(context).instruction, + controller: indicationController, + keyboardType: TextInputType.number, + validator: (value) { + if (value.isEmpty) + return TranslationBase.of(context) + .emptyMessage; + else + return null; + }, + ), + ), + SizedBox(height: spaceBetweenTextFileds), + Container( + margin: EdgeInsets.all( + SizeConfig.widthMultiplier * 5), + child: Wrap( + alignment: WrapAlignment.center, + children: [ + AppButton( + title: TranslationBase.of(context) + .addMedication, + onPressed: () { + formKey.currentState.save(); + + if (formKey.currentState.validate()) { + postPrescription( + model: model, + duration: durationController.text, + dose: doseController.text, + frequency: + frequencyController.text, + route: routeController.text, + drugId: drugIdController.text, + strength: strengthController.text, + indication: + indicationController.text, + instruction: + indicationController.text, + ); + Navigator.pop(context); + } + { + // Navigator.push( + // context, + // MaterialPageRoute( + // builder: (context) => + // NewPrescriptionScreen()), + // ); + } + }, + ), + ], + ), ), ], ), ), - ], - ), + ), + ], ), ), - ], - ), - ), - ), - ); + ), + ); + }); }); } -postProcedure({String duration, String dose}) async { - PrescriptionViewModel model = new PrescriptionViewModel(); +postPrescription( + {String duration, + String dose, + String drugId, + String strength, + String route, + String frequency, + String indication, + String instruction, + PrescriptionViewModel model}) async { PostPrescriptionReqModel postProcedureReqModel = new PostPrescriptionReqModel(); List sss = List(); - postProcedureReqModel.appointmentNo = 2016055175; - postProcedureReqModel.clinicID = 1; - postProcedureReqModel.episodeID = 200012335; - postProcedureReqModel.patientMRN = 1234; + postProcedureReqModel.appointmentNo = 2016055159; + postProcedureReqModel.clinicID = 17; + postProcedureReqModel.episodeID = 200012330; + postProcedureReqModel.patientMRN = 3120877; postProcedureReqModel.vidaAuthTokenID = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMDAyIiwianRpIjoiOGFjNDRjZGQtOWE0Mi00M2YxLWE2YTQtMWQ4NzBmZmYwNTUyIiwiZW1haWwiOiIiLCJpZCI6IjEwMDIiLCJOYW1lIjoiVEVNUCAtIERPQ1RPUiIsIkVtcGxveWVlSWQiOiI0NzA5IiwiRmFjaWxpdHlHcm91cElkIjoiMDEwMjY2IiwiRmFjaWxpdHlJZCI6IjE1IiwiUGhhcmFtY3lGYWNpbGl0eUlkIjoiNTUiLCJJU19QSEFSTUFDWV9DT05ORUNURUQiOiJUcnVlIiwiRG9jdG9ySWQiOiI0NzA5IiwiU0VTU0lPTklEIjoiMjE1OTU2NDkiLCJDbGluaWNJZCI6IjEiLCJyb2xlIjpbIkRPQ1RPUlMiLCJIRUFEIERPQ1RPUlMiLCJBRE1JTklTVFJBVE9SUyIsIlJFQ0VQVElPTklTVCIsIkVSIE5VUlNFIiwiRVIgUkVDRVBUSU9OSVNUIiwiUEhBUk1BQ1kgQUNDT1VOVCBTVEFGRiIsIlBIQVJNQUNZIE5VUlNFIiwiSU5QQVRJRU5UIFBIQVJNQUNJU1QiLCJBRE1JU1NJT04gU1RBRkYiLCJBUFBST1ZBTCBTVEFGRiIsIkNPTlNFTlQgIiwiTUVESUNBTCBSRVBPUlQgLSBTSUNLIExFQVZFIE1BTkFHRVIiXSwibmJmIjoxNjA4NzM2NjY5LCJleHAiOjE2MDk2MDA2NjksImlhdCI6MTYwODczNjY2OX0.9EDgYrbe5fQA2CvgLdFT4s_PL7hD5R_Qggfpv4lDtUY"; sss.add(PrescriptionRequestModel( covered: true, dose: int.parse(dose), - itemId: 8, + itemId: int.parse(drugId), doseUnitId: 1, - route: 1, - frequency: 1, - remarks: "test2", + route: int.parse(route), + frequency: int.parse(frequency), + remarks: instruction, approvalRequired: true, icdcode10Id: "test2", doseTime: 1, @@ -261,7 +366,7 @@ postProcedure({String duration, String dose}) async { if (model.state == ViewState.ErrorLocal) { helpers.showErrorToast(model.error); - } else { + } else if (model.state == ViewState.Idle) { DrAppToastMsg.showSuccesToast('Medication has been added'); } } diff --git a/lib/screens/prescription/prescription_screen.dart b/lib/screens/prescription/prescription_screen.dart index 742cfad8..4f6fe133 100644 --- a/lib/screens/prescription/prescription_screen.dart +++ b/lib/screens/prescription/prescription_screen.dart @@ -110,7 +110,7 @@ class _NewPrescriptionScreenState extends State { children: [ InkWell( onTap: () { - addPrescriptionForm(context); + addPrescriptionForm(context, model); //model.postPrescription(); }, child: CircleAvatar( @@ -156,7 +156,7 @@ class _NewPrescriptionScreenState extends State { ], ) : Padding( - padding: EdgeInsets.all(12.0), + padding: EdgeInsets.all(14.0), child: NetworkBaseView( baseViewModel: model, child: Column( @@ -194,7 +194,7 @@ class _NewPrescriptionScreenState extends State { ), ), onTap: () { - addPrescriptionForm(context); + addPrescriptionForm(context, model); //model.postPrescription(); }, ), @@ -204,19 +204,22 @@ class _NewPrescriptionScreenState extends State { ...List.generate( model.prescriptionList[0].rowcount, (index) => Container( + //height: 240, child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment .spaceBetween, + // crossAxisAlignment: + // CrossAxisAlignment.start, children: [ Container( height: MediaQuery.of(context) .size .height * - 0.2, + 0.23, width: MediaQuery.of(context) .size @@ -236,12 +239,12 @@ class _NewPrescriptionScreenState extends State { MediaQuery.of(context) .size .height * - 0.24, + 0.282, width: MediaQuery.of(context) .size .width * - 0.81, + 0.77, child: Column( children: [ Row( @@ -250,17 +253,20 @@ class _NewPrescriptionScreenState extends State { 'Start Date:', fontWeight: FontWeight - .w900, - fontSize: 15.0, + .w700, + fontSize: 14.0, ), - AppText( - model - .prescriptionList[ - 0] - .entityList[ - index] - .startDate, - fontSize: 11.0, + Expanded( + child: AppText( + model + .prescriptionList[ + 0] + .entityList[ + index] + .startDate, + fontSize: + 12.0, + ), ), SizedBox( width: 6.0, @@ -269,22 +275,25 @@ class _NewPrescriptionScreenState extends State { 'Order Type:', fontWeight: FontWeight - .w900, - fontSize: 15.0, + .w700, + fontSize: 14.0, ), - AppText( - model - .prescriptionList[ - 0] - .entityList[ - index] - .orderTypeDescription, - fontSize: 13.0, + Expanded( + child: AppText( + model + .prescriptionList[ + 0] + .entityList[ + index] + .orderTypeDescription, + fontSize: + 13.0, + ), ), ], ), SizedBox( - height: 2.5, + height: 5.5, ), Row( children: [ @@ -298,11 +307,19 @@ class _NewPrescriptionScreenState extends State { .entityList[ index] .medicationName, + fontWeight: + FontWeight + .w700, + fontSize: + 15.0, ), ), ) ], ), + SizedBox( + height: 5.5, + ), Row( children: [ Expanded( @@ -314,7 +331,7 @@ class _NewPrescriptionScreenState extends State { index] .doseDetail, fontSize: - 13.0, + 15.0, ), ) ], @@ -328,7 +345,8 @@ class _NewPrescriptionScreenState extends State { 'Indication: ', fontWeight: FontWeight - .w900, + .w700, + fontSize: 17.0, ), Expanded( child: AppText( @@ -339,40 +357,48 @@ class _NewPrescriptionScreenState extends State { index] .indication, fontSize: - 12.9), + 15.0), ) ], ), SizedBox( - height: 15.0, + height: 18.0, ), Row( children: [ - AppText( - model - .prescriptionList[ - 0] - .entityList[ - index] - .doctorName, - fontWeight: - FontWeight - .w900, + Expanded( + child: AppText( + model + .prescriptionList[ + 0] + .entityList[ + index] + .doctorName, + fontWeight: + FontWeight + .w700, + ), ) ], ), Row( children: [ - AppText(model - .prescriptionList[ - 0] - .entityList[ - index] - .remarks), + Expanded( + child: AppText( + model + .prescriptionList[ + 0] + .entityList[ + index] + .remarks, + fontSize: + 14.0, + ), + ), ], ), SizedBox( - height: 15.0, + height: 10.0, ), Divider( @@ -386,6 +412,23 @@ class _NewPrescriptionScreenState extends State { ], ), ), + Container( + height: + MediaQuery.of(context) + .size + .height * + 0.05, + width: + MediaQuery.of(context) + .size + .width * + 0.06, + child: Column( + children: [ + Icon(Icons.edit) + ], + ), + ), ], ), ], diff --git a/lib/screens/procedures/procedure_screen.dart b/lib/screens/procedures/procedure_screen.dart index 5b6b10f3..2bdb7f78 100644 --- a/lib/screens/procedures/procedure_screen.dart +++ b/lib/screens/procedures/procedure_screen.dart @@ -111,7 +111,10 @@ class _ProcedureScreenState extends State { children: [ InkWell( onTap: () { - addSelectedProcedure(context); + model.getCategories().then((value) { + addSelectedProcedure(context, model); + }); + //model.postPrescription(); }, child: CircleAvatar( @@ -149,7 +152,7 @@ class _ProcedureScreenState extends State { AppText( TranslationBase.of(context).addNow, color: Color(0XFFB8382C), - fontWeight: FontWeight.w900, + fontWeight: FontWeight.w700, ), ], ), @@ -194,7 +197,12 @@ class _ProcedureScreenState extends State { ), ), onTap: () { - addSelectedProcedure(context); + model.getCategories().then((value) { + addSelectedProcedure( + context, model); + }); + + //model.postPrescription(); }, ), // Container( @@ -252,7 +260,7 @@ class _ProcedureScreenState extends State { 'Code #: ', fontWeight: FontWeight - .w900, + .w700, fontSize: 15.0, ), AppText( @@ -272,7 +280,7 @@ class _ProcedureScreenState extends State { 'Order Type: ', fontWeight: FontWeight - .w900, + .w700, fontSize: 15.0, ), AppText( @@ -310,7 +318,7 @@ class _ProcedureScreenState extends State { 'Price: ', fontWeight: FontWeight - .w900, + .w700, ), Expanded( child: AppText( @@ -382,7 +390,6 @@ class _ProcedureScreenState extends State { } postProcedure({ProcedureViewModel model}) async { - model = new ProcedureViewModel(); PostProcedureReqModel postProcedureReqModel = new PostProcedureReqModel(); List controls = List(); List controlsProcedure = List(); @@ -402,98 +409,248 @@ postProcedure({ProcedureViewModel model}) async { postProcedureReqModel.procedures = controlsProcedure; await model.postProcedure(postProcedureReqModel); - DrAppToastMsg.showSuccesToast('Procedure had been added'); + if (model.state == ViewState.ErrorLocal) { helpers.showErrorToast(model.error); + } else if (model.state == ViewState.Idle) { + DrAppToastMsg.showSuccesToast('procedure has been added'); } } -void addSelectedProcedure(context) { +void addSelectedProcedure(context, ProcedureViewModel model) { + showModalBottomSheet( + context: context, + builder: (BuildContext bc) { + return AddSelectedProcedure( + model: model, + ); + }); +} + +class AddSelectedProcedure extends StatefulWidget { + final ProcedureViewModel model; + + const AddSelectedProcedure({Key key, this.model}) : super(key: key); + @override + _AddSelectedProcedureState createState() => _AddSelectedProcedureState(); +} + +class _AddSelectedProcedureState extends State { TextEditingController procedureController = TextEditingController(); + + @override + Widget build(BuildContext context) { + return NetworkBaseView( + baseViewModel: widget.model, + child: SingleChildScrollView( + child: Container( + height: 490, + child: Padding( + padding: EdgeInsets.all(12.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + 'Select Procedure'.toUpperCase(), + fontWeight: FontWeight.w900, + ), + if (widget.model.categoriesList.length != 0) + Container( + // child: ListView( + // children: [ + // Column( + // children: model.historyFamilyList + // .map((historyInfo) { + // return Column( + // children: [ + // Row( + // children: [ + // Checkbox( + // value: isServiceSelected( + // historyInfo), + // activeColor: + // Colors.red[800], + // onChanged: + // (bool newValue) { + // setState(() { + // if (isServiceSelected( + // historyInfo + // )) { + // widget + // .removeHistory( + // historyInfo + // ); + // } + // else { + // widget + // .myHistoryList + // .add( + // historyInfo); + // } + // }); + // }), + // Expanded( + // child: Padding( + // padding: + // const EdgeInsets + // .symmetric( + // horizontal: 10, + // vertical: 0), + // child: Texts( + // historyInfo.nameEn, + // variant: "bodyText", + // bold: true, + // color: + // Colors.black), + // ), + // ), + // ], + // ), + // DividerWithSpacesAround(), + // ], + // ); + // }).toList(), + // ), + // ], + // ), + height: 120.0, + child: ListView.builder( + scrollDirection: Axis.vertical, + shrinkWrap: true, + itemCount: widget.model.categoriesList[0].rowcount, + itemBuilder: (BuildContext ctxt, int index) { + return Container( + child: AppText(widget.model.categoriesList[0] + .entityList[index].procedureName), + ); + }), + ), + SizedBox( + height: 0.0, + ), + Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(6.0)), + border: Border.all( + width: 1.0, color: HexColor("#CCCCCC"))), + child: AppTextFormField( + labelText: 'Add Delected Procedures'.toUpperCase(), + borderColor: Colors.white, + textInputType: TextInputType.text, + inputFormatter: ONLY_LETTERS, + controller: procedureController, + ), + ), + SizedBox( + height: 80.0, + ), + Container( + margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5), + child: Wrap( + alignment: WrapAlignment.center, + children: [ + AppButton( + title: TranslationBase.of(context).addMedication, + onPressed: () { + Navigator.pop(context); + postProcedure(model: widget.model); + }, + ), + ], + ), + ), + ], + ) + ], + ), + ), + ), + ), + ); + } +} + +// isServiceSelected(ProcedureViewModel masterKey) { +// Iterable history = widget.myHistoryList.where((element) => +// masterKey.id == element.id && masterKey.typeId == element.typeId); +// if (history.length > 0) { +// return true; +// } +// return false; +// } + +void updateProcedureForm(context) { showModalBottomSheet( context: context, + isScrollControlled: true, builder: (BuildContext bc) { - return BaseView( - onModelReady: (model) => model.getCategories(), - builder: - (BuildContext context, ProcedureViewModel model, Widget child) => - NetworkBaseView( - baseViewModel: model, - child: SingleChildScrollView( - child: Container( - height: 490, - child: Padding( - padding: EdgeInsets.all(12.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - 'Select Procedure'.toUpperCase(), - fontWeight: FontWeight.w900, + return Container( + height: 500, + child: Form( + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 10.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + 'Procedure Name'.toUpperCase(), + fontWeight: FontWeight.w900, + ), + SizedBox( + height: 30.0, + ), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(6.0)), + border: Border.all( + width: 1.0, color: HexColor("#CCCCCC"))), + child: AppTextFormField( + labelText: 'Order ', + borderColor: Colors.white, + textInputType: TextInputType.number, + inputFormatter: ONLY_NUMBERS, ), - if (model.categoriesList.length != 0) - Container( - height: 120.0, - child: ListView.builder( - scrollDirection: Axis.vertical, - shrinkWrap: true, - itemCount: model.categoriesList[0].rowcount, - itemBuilder: (BuildContext ctxt, int index) { - return Container( - child: AppText(model.categoriesList[0] - .entityList[index].procedureName), - ); - }), - ), - SizedBox( - height: 0.0, + ), + SizedBox( + height: 12.0, + ), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(6.0)), + border: Border.all( + width: 1.0, color: HexColor("#CCCCCC"))), + child: AppTextFormField( + labelText: 'Password', + borderColor: Colors.white, + textInputType: TextInputType.text, + inputFormatter: ONLY_LETTERS, + obscureText: true, ), - Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, color: HexColor("#CCCCCC"))), - child: AppTextFormField( - labelText: - 'Add Delected Procedures'.toUpperCase(), - borderColor: Colors.white, - textInputType: TextInputType.text, - inputFormatter: ONLY_LETTERS, - controller: procedureController, - ), - ), - SizedBox( - height: 80.0, - ), - Container( - margin: - EdgeInsets.all(SizeConfig.widthMultiplier * 5), - child: Wrap( - alignment: WrapAlignment.center, - children: [ - AppButton( - title: - TranslationBase.of(context).addMedication, - onPressed: () { - Navigator.pop(context); - postProcedure(); - }, - ), - ], - ), + ), + SizedBox( + height: 190.0, + ), + Container( + margin: EdgeInsets.all(SizeConfig.widthMultiplier * 2), + child: Wrap( + alignment: WrapAlignment.center, + children: [ + AppButton( + title: 'CONTINUE', + onPressed: () { + Navigator.pop(context); + // authorizationForm(context); + }, ), ], - ) - ], - ), + ), + ), + ], ), ), - ), - ), - ); + )); }); } diff --git a/lib/widgets/patients/profile/SOAP/subjective/subjective_page.dart b/lib/widgets/patients/profile/SOAP/subjective/subjective_page.dart index d4ed9c86..20833a02 100644 --- a/lib/widgets/patients/profile/SOAP/subjective/subjective_page.dart +++ b/lib/widgets/patients/profile/SOAP/subjective/subjective_page.dart @@ -24,9 +24,13 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart'; class SubjectivePage extends StatefulWidget { final Function changePageViewIndex; final List myAllergiesList; - final List myHistoryList ; + final List myHistoryList; - SubjectivePage({Key key, this.changePageViewIndex, this.myAllergiesList, this.myHistoryList}); + SubjectivePage( + {Key key, + this.changePageViewIndex, + this.myAllergiesList, + this.myHistoryList}); @override _SubjectivePageState createState() => _SubjectivePageState(); @@ -102,15 +106,13 @@ class _SubjectivePageState extends State { minLines: 13, controller: complaintsController, validator: (value) { - if (value == null || value =="") - return TranslationBase - .of(context) + if (value == null || value == "") + return TranslationBase.of(context) .emptyMessage; else if (value.length < 25) - return TranslationBase - .of(context) + return TranslationBase.of(context) .chiefComplaintLength; - //""; + //""; else return null; }), @@ -129,9 +131,8 @@ class _SubjectivePageState extends State { minLines: 13, controller: illnessController, validator: (value) { - if (value == null || value =="") - return TranslationBase - .of(context) + if (value == null || value == "") + return TranslationBase.of(context) .emptyMessage; else return null; @@ -146,7 +147,6 @@ class _SubjectivePageState extends State { ), isExpand: isChiefExpand, ), - SizedBox( height: 30, ), @@ -222,15 +222,16 @@ class _SubjectivePageState extends State { : EvaIcons.plus)) ], ), - bodyWidget:Column( + bodyWidget: Column( children: [ - AddAllergiesWidget(myAllergiesList: widget.myAllergiesList,), + AddAllergiesWidget( + myAllergiesList: widget.myAllergiesList, + ), SizedBox( height: 30, ), ], - ) - , + ), isExpand: isAllergiesExpand, ), SizedBox( @@ -308,7 +309,6 @@ class _SubjectivePageState extends State { // } else { // helpers.showErrorToast('Please add required field correctly'); // } - } postAllergy( @@ -320,8 +320,8 @@ class _SubjectivePageState extends State { null) postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM = []; //TODO: make static value dynamic - postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM - .add(ListHisProgNotePatientAllergyDiseaseVM( + postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM.add( + ListHisProgNotePatientAllergyDiseaseVM( allergyDiseaseId: allergy.selectedAllergy.id, allergyDiseaseType: allergy.selectedAllergy.typeId, patientMRN: 3120690, @@ -331,9 +331,11 @@ class _SubjectivePageState extends State { remarks: allergy.remark, createdBy: 1485, // - createdOn: DateTime.now().toIso8601String(),//"2020-08-14T20:37:22.780Z", + createdOn: DateTime.now() + .toIso8601String(), //"2020-08-14T20:37:22.780Z", editedBy: 1485, - editedOn: DateTime.now().toIso8601String(),//"2020-08-14T20:37:22.780Z", + editedOn: DateTime.now() + .toIso8601String(), //"2020-08-14T20:37:22.780Z", isChecked: false, isUpdatedByNurse: false)); }); @@ -371,23 +373,21 @@ class _SubjectivePageState extends State { postChiefComplaint({SOAPViewModel model}) async { formKey.currentState.save(); - if(formKey.currentState.validate()){ + if (formKey.currentState.validate()) { PostChiefComplaintRequestModel postChiefComplaintRequestModel = - //TODO: make static value dynamic - new PostChiefComplaintRequestModel( - patientMRN: 3120690, - episodeID: 200012117, - appointmentNo: 2016054573, - chiefComplaint: complaintsController.text, - currentMedication: "currentMedication", - hopi: illnessController.text, - isLactation: false, - ispregnant: false, - numberOfWeeks: 22); + //TODO: make static value dynamic + new PostChiefComplaintRequestModel( + patientMRN: 3120690, + episodeID: 200012117, + appointmentNo: 2016054573, + chiefComplaint: complaintsController.text, + currentMedication: "currentMedication", + hopi: illnessController.text, + isLactation: false, + ispregnant: false, + numberOfWeeks: 22); await model.postChiefComplaint(postChiefComplaintRequestModel); - } - } } From f0fd5d30e134c8ac5d895b29ebb802c0c9d08bfe Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Thu, 31 Dec 2020 14:00:22 +0200 Subject: [PATCH 03/15] First step from update process --- lib/config/config.dart | 25 +- lib/config/test.dart | 0 lib/core/service/SOAP_service.dart | 161 +++- lib/core/service/base/lookup-service.dart | 6 +- lib/core/viewModel/SOAP_view_model.dart | 127 +++- .../GetChiefComplaintResModel.dart | 60 ++ lib/models/SOAP/GeneralGetReqForSOAP.dart | 25 + .../SOAP/post_assessment_request_model.dart | 4 +- .../post_progress_note_request_model.dart | 4 +- lib/routes.dart | 5 +- .../profile/SOAP/assessment_page.dart | 56 +- .../patients/profile/SOAP/plan_page.dart | 34 +- .../SOAP/subjective/add_allergies_widget.dart | 6 +- .../profile/profile_medical_info_widget.dart | 2 +- .../subjective/update_allergies_widget.dart | 343 +++++++++ .../subjective/update_history_widget.dart | 574 ++++++++++++++ .../subjective/update_medication_widget.dart | 107 +++ .../subjective/update_subjective_page.dart | 405 ++++++++++ .../soap_update/update_assessment_page.dart | 706 ++++++++++++++++++ .../soap_update/update_objective_page.dart | 580 ++++++++++++++ .../profile/soap_update/update_plan_page.dart | 347 +++++++++ .../soap_update/update_soap_index.dart | 133 ++++ 22 files changed, 3648 insertions(+), 62 deletions(-) create mode 100644 lib/config/test.dart create mode 100644 lib/models/SOAP/ChiefComplaint/GetChiefComplaintResModel.dart create mode 100644 lib/models/SOAP/GeneralGetReqForSOAP.dart create mode 100644 lib/widgets/patients/profile/soap_update/subjective/update_allergies_widget.dart create mode 100644 lib/widgets/patients/profile/soap_update/subjective/update_history_widget.dart create mode 100644 lib/widgets/patients/profile/soap_update/subjective/update_medication_widget.dart create mode 100644 lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart create mode 100644 lib/widgets/patients/profile/soap_update/update_assessment_page.dart create mode 100644 lib/widgets/patients/profile/soap_update/update_objective_page.dart create mode 100644 lib/widgets/patients/profile/soap_update/update_plan_page.dart create mode 100644 lib/widgets/patients/profile/soap_update/update_soap_index.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index 08417a05..4a1b706b 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -131,10 +131,33 @@ const POST_PHYSICAL_EXAM = 'Services/DoctorApplication.svc/REST/PostPhysicalExam'; const POST_PROGRESS_NOTE = 'Services/DoctorApplication.svc/REST/PostProgressNote'; - const POST_ASSESSMENT = 'Services/DoctorApplication.svc/REST/PostAssessment'; + + +const PATCH_ALLERGY = 'Services/DoctorApplication.svc/REST/PatchAllergies'; +const PATCH_HISTORY = 'Services/DoctorApplication.svc/REST/PatchHistory'; +const PATCH_CHIEF_COMPLAINT = + 'Services/DoctorApplication.svc/REST/PatchChiefcomplaint'; +const PATCH_PHYSICAL_EXAM = + 'Services/DoctorApplication.svc/REST/PatchPhysicalExam'; +const PATCH_PROGRESS_NOTE = + 'Services/DoctorApplication.svc/REST/PatchProgressNote'; +const PATCH_ASSESSMENT = + 'Services/DoctorApplication.svc/REST/PatchAssessment'; + +const GET_ALLERGY = 'Services/DoctorApplication.svc/REST/GetAllergies'; +const GET_HISTORY = 'Services/DoctorApplication.svc/REST/GetHistory'; +const GET_CHIEF_COMPLAINT = + 'Services/DoctorApplication.svc/REST/GetChiefcomplaint'; +const GET_PHYSICAL_EXAM = + 'Services/DoctorApplication.svc/REST/GetPhysicalExam'; +const GET_PROGRESS_NOTE = + 'Services/DoctorApplication.svc/REST/GetProgressNote'; +const GET_ASSESSMENT = + 'Services/DoctorApplication.svc/REST/GetAssessment'; + const GET_CATEGORISE_PROCEDURE = 'Services/DoctorApplication.svc/REST/GetCategories'; diff --git a/lib/config/test.dart b/lib/config/test.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/core/service/SOAP_service.dart b/lib/core/service/SOAP_service.dart index 3219ef6a..f4b8ef1c 100644 --- a/lib/core/service/SOAP_service.dart +++ b/lib/core/service/SOAP_service.dart @@ -1,4 +1,6 @@ import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/models/SOAP/ChiefComplaint/GetChiefComplaintResModel.dart'; +import 'package:doctor_app_flutter/models/SOAP/GeneralGetReqForSOAP.dart'; import 'package:doctor_app_flutter/models/SOAP/get_Allergies_request_model.dart'; import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; import 'package:doctor_app_flutter/models/SOAP/post_allergy_request_model.dart'; @@ -7,17 +9,20 @@ import 'package:doctor_app_flutter/models/SOAP/post_chief_complaint_request_mode import 'package:doctor_app_flutter/models/SOAP/post_histories_request_model.dart'; import 'package:doctor_app_flutter/models/SOAP/post_physical_exam_request_model.dart'; import 'package:doctor_app_flutter/models/SOAP/post_progress_note_request_model.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/soap_update/update_assessment_page.dart'; import 'base/lookup-service.dart'; class SOAPService extends LookupService { + List chiefComplaintList = []; + Future getAllergies(GetAllergiesRequestModel getAllergiesRequestModel) async { await baseAppClient.post( GET_ALLERGIES, onSuccess: (dynamic response, int statusCode) { - listOfAllergies.clear(); + allergiesList.clear(); response['List_Allergies']['entityList'].forEach((v) { - listOfAllergies.add(MasterKeyModel.fromJson(v)); + allergiesList.add(MasterKeyModel.fromJson(v)); }); }, onFailure: (String error, int statusCode) { @@ -99,4 +104,156 @@ class SOAPService extends LookupService { super.error = error; }, body: postAssessmentRequestModel.toJson()); } + + + + Future patchAllergy(PostAllergyRequestModel patchAllergyRequestModel) async { + hasError = false; + + await baseAppClient.post(PATCH_ALLERGY, + onSuccess: (dynamic response, int statusCode) { + print("Success"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: patchAllergyRequestModel.toJson()); + } + + Future patchHistories( + PostHistoriesRequestModel patchHistoriesRequestModel) async { + hasError = false; + await baseAppClient.post(PATCH_HISTORY, + onSuccess: (dynamic response, int statusCode) { + print("Success"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: patchHistoriesRequestModel.toJson()); + } + + Future patchChiefComplaint( + PostChiefComplaintRequestModel patchChiefComplaintRequestModel) async { + hasError = false; + await baseAppClient.post(PATCH_CHIEF_COMPLAINT, + onSuccess: (dynamic response, int statusCode) { + print("Success"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: patchChiefComplaintRequestModel.toJson()); + } + + Future patchPhysicalExam( + PostPhysicalExamRequestModel patchPhysicalExamRequestModel) async { + hasError = false; + await baseAppClient.post(PATCH_PHYSICAL_EXAM, + onSuccess: (dynamic response, int statusCode) { + print("Success"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: patchPhysicalExamRequestModel.toJson()); + } + + Future patchProgressNote( + PostProgressNoteRequestModel patchProgressNoteRequestModel) async { + hasError = false; + await baseAppClient.post(PATCH_PROGRESS_NOTE, + onSuccess: (dynamic response, int statusCode) { + print("Success"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: patchProgressNoteRequestModel.toJson()); + } + + Future patchAssessment( + PatchAssessmentReqModel patchAssessmentRequestModel) async { + hasError = false; + await baseAppClient.post(PATCH_ASSESSMENT, + onSuccess: (dynamic response, int statusCode) { + print("Success"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: patchAssessmentRequestModel.toJson()); + } + + + + Future getPatientAllergy(PostAllergyRequestModel getPatientAllergyRequestModel) async { + hasError = false; + + await baseAppClient.post (GET_ALLERGY, + onSuccess: (dynamic response, int statusCode) { + print("Success"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: getPatientAllergyRequestModel.toJson()); + } + + Future getPatientHistories( + PostHistoriesRequestModel getPatientHistoriesRequestModel) async { + hasError = false; + await baseAppClient.post (GET_HISTORY, + onSuccess: (dynamic response, int statusCode) { + print("Success"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: getPatientHistoriesRequestModel.toJson()); + } + + Future getPatientChiefComplaint( + GeneralGetReqForSOAP getPatientChiefComplaintRequestModel) async { + hasError = false; + await baseAppClient.post (GET_CHIEF_COMPLAINT, + onSuccess: (dynamic response, int statusCode) { + print("Success"); + chiefComplaintList.clear(); + response['List_ChiefComplaint']['entityList'].forEach((v) { + chiefComplaintList.add(GetChiefComplaintResModel.fromJson(v)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: getPatientChiefComplaintRequestModel.toJson()); + } + + Future getPatientPhysicalExam( + PostPhysicalExamRequestModel getPatientPhysicalExamRequestModel) async { + hasError = false; + await baseAppClient.post (GET_PHYSICAL_EXAM, + onSuccess: (dynamic response, int statusCode) { + print("Success"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: getPatientPhysicalExamRequestModel.toJson()); + } + + Future getPatientProgressNote( + PostProgressNoteRequestModel getPatientProgressNoteRequestModel) async { + hasError = false; + await baseAppClient.post (GET_PROGRESS_NOTE, + onSuccess: (dynamic response, int statusCode) { + print("Success"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: getPatientProgressNoteRequestModel.toJson()); + } + + Future getPatientAssessment( + PostAssessmentRequestModel getPatientAssessmentRequestModel) async { + hasError = false; + await baseAppClient.post (GET_ASSESSMENT, + onSuccess: (dynamic response, int statusCode) { + print("Success"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: getPatientAssessmentRequestModel.toJson()); + } } diff --git a/lib/core/service/base/lookup-service.dart b/lib/core/service/base/lookup-service.dart index d677201b..eabac69b 100644 --- a/lib/core/service/base/lookup-service.dart +++ b/lib/core/service/base/lookup-service.dart @@ -5,7 +5,7 @@ import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; import 'base_service.dart'; class LookupService extends BaseService { - List listOfAllergies = []; + List allergiesList = []; List get allergySeverityList => _allergySeverityList; List _allergySeverityList = []; @@ -53,9 +53,9 @@ class LookupService extends BaseService { setMasterLookupInCorrectArray(entryList, MasterKeysService masterKeys) { switch (masterKeys) { case MasterKeysService.Allergies: - listOfAllergies.clear(); + allergiesList.clear(); entryList.forEach((v) { - listOfAllergies.add(MasterKeyModel.fromJson(v)); + allergiesList.add(MasterKeyModel.fromJson(v)); }); break; case MasterKeysService.HistoryFamily: diff --git a/lib/core/viewModel/SOAP_view_model.dart b/lib/core/viewModel/SOAP_view_model.dart index 422f554a..43107275 100644 --- a/lib/core/viewModel/SOAP_view_model.dart +++ b/lib/core/viewModel/SOAP_view_model.dart @@ -2,6 +2,7 @@ import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/service/SOAP_service.dart'; import 'package:doctor_app_flutter/models/SOAP/Allergy_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/GeneralGetReqForSOAP.dart'; import 'package:doctor_app_flutter/models/SOAP/get_Allergies_request_model.dart'; import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; import 'package:doctor_app_flutter/models/SOAP/post_allergy_request_model.dart'; @@ -10,6 +11,7 @@ import 'package:doctor_app_flutter/models/SOAP/post_chief_complaint_request_mode import 'package:doctor_app_flutter/models/SOAP/post_histories_request_model.dart'; import 'package:doctor_app_flutter/models/SOAP/post_physical_exam_request_model.dart'; import 'package:doctor_app_flutter/models/SOAP/post_progress_note_request_model.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/soap_update/update_assessment_page.dart'; import '../../locator.dart'; import 'base_view_model.dart'; @@ -17,7 +19,7 @@ import 'base_view_model.dart'; class SOAPViewModel extends BaseViewModel { SOAPService _SOAPService = locator(); - List get listOfAllergies => _SOAPService.listOfAllergies; + List get allergiesList => _SOAPService.allergiesList; List get allergySeverityList => _SOAPService.allergySeverityList; @@ -120,4 +122,127 @@ class SOAPViewModel extends BaseViewModel { } + Future patchAllergy(PostAllergyRequestModel patchAllergyRequestModel) async { + setState(ViewState.BusyLocal); + await _SOAPService.patchAllergy(patchAllergyRequestModel); + if (_SOAPService.hasError) { + error = _SOAPService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } + + Future patchHistories(PostHistoriesRequestModel patchHistoriesRequestModel) async { + setState(ViewState.BusyLocal); + await _SOAPService.patchHistories(patchHistoriesRequestModel); + if (_SOAPService.hasError) { + error = _SOAPService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } + + Future patchChiefComplaint(PostChiefComplaintRequestModel patchChiefComplaintRequestModel) async { + setState(ViewState.BusyLocal); + await _SOAPService.patchChiefComplaint(patchChiefComplaintRequestModel); + if (_SOAPService.hasError) { + error = _SOAPService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } + + Future patchPhysicalExam(PostPhysicalExamRequestModel patchPhysicalExamRequestModel) async { + setState(ViewState.BusyLocal); + await _SOAPService.patchPhysicalExam(patchPhysicalExamRequestModel); + if (_SOAPService.hasError) { + error = _SOAPService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } + + Future patchProgressNote(PostProgressNoteRequestModel patchProgressNoteRequestModel) async { + setState(ViewState.BusyLocal); + await _SOAPService.patchProgressNote(patchProgressNoteRequestModel); + if (_SOAPService.hasError) { + error = _SOAPService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } + + Future patchAssessment(PatchAssessmentReqModel patchAssessmentRequestModel) async { + setState(ViewState.BusyLocal); + await _SOAPService.patchAssessment(patchAssessmentRequestModel); + if (_SOAPService.hasError) { + error = _SOAPService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } + + + + + Future getPatientAllergy(PostAllergyRequestModel getPatientAllergyRequestModel) async { + setState(ViewState.Busy); + await _SOAPService.getPatientAllergy(getPatientAllergyRequestModel); + if (_SOAPService.hasError) { + error = _SOAPService.error; + setState(ViewState.Busy); + } else + setState(ViewState.Idle); + } + + Future getPatientHistories(PostHistoriesRequestModel getPatientHistoriesRequestModel) async { + setState(ViewState.Busy); + await _SOAPService.getPatientHistories(getPatientHistoriesRequestModel); + if (_SOAPService.hasError) { + error = _SOAPService.error; + setState(ViewState.Busy); + } else + setState(ViewState.Idle); + } + + Future getPatientChiefComplaint(GeneralGetReqForSOAP getPatientChiefComplaintRequestModel) async { + setState(ViewState.Busy); + await _SOAPService.getPatientChiefComplaint(getPatientChiefComplaintRequestModel); + if (_SOAPService.hasError) { + error = _SOAPService.error; + setState(ViewState.Busy); + } else + setState(ViewState.Idle); + } + + Future getPatientPhysicalExam(PostPhysicalExamRequestModel getPatientPhysicalExamRequestModel) async { + setState(ViewState.Busy); + await _SOAPService.getPatientPhysicalExam(getPatientPhysicalExamRequestModel); + if (_SOAPService.hasError) { + error = _SOAPService.error; + setState(ViewState.Busy); + } else + setState(ViewState.Idle); + } + + Future getPatientProgressNote(PostProgressNoteRequestModel getPatientProgressNoteRequestModel) async { + setState(ViewState.Busy); + await _SOAPService.getPatientProgressNote(getPatientProgressNoteRequestModel); + if (_SOAPService.hasError) { + error = _SOAPService.error; + setState(ViewState.Busy); + } else + setState(ViewState.Idle); + } + + Future getPatientAssessment(PostAssessmentRequestModel getPatientAssessmentRequestModel) async { + setState(ViewState.Busy); + await _SOAPService.getPatientAssessment(getPatientAssessmentRequestModel); + if (_SOAPService.hasError) { + error = _SOAPService.error; + setState(ViewState.Busy); + } else + setState(ViewState.Idle); + } + } diff --git a/lib/models/SOAP/ChiefComplaint/GetChiefComplaintResModel.dart b/lib/models/SOAP/ChiefComplaint/GetChiefComplaintResModel.dart new file mode 100644 index 00000000..85ada324 --- /dev/null +++ b/lib/models/SOAP/ChiefComplaint/GetChiefComplaintResModel.dart @@ -0,0 +1,60 @@ +class GetChiefComplaintResModel { + int appointmentNo; + String ccdate; + String chiefComplaint; + String clinicDescription; + int clinicID; + String currentMedication; + int doctorID; + String doctorName; + int episodeId; + String hopi; + int patientMRN; + int status; + + GetChiefComplaintResModel( + {this.appointmentNo, + this.ccdate, + this.chiefComplaint, + this.clinicDescription, + this.clinicID, + this.currentMedication, + this.doctorID, + this.doctorName, + this.episodeId, + this.hopi, + this.patientMRN, + this.status}); + + GetChiefComplaintResModel.fromJson(Map json) { + appointmentNo = json['appointmentNo']; + ccdate = json['ccdate']; + chiefComplaint = json['chiefComplaint']; + clinicDescription = json['clinicDescription']; + clinicID = json['clinicID']; + currentMedication = json['currentMedication']; + doctorID = json['doctorID']; + doctorName = json['doctorName']; + episodeId = json['episodeId']; + hopi = json['hopi']; + patientMRN = json['patientMRN']; + status = json['status']; + } + + Map toJson() { + final Map data = new Map(); + data['appointmentNo'] = this.appointmentNo; + data['ccdate'] = this.ccdate; + data['chiefComplaint'] = this.chiefComplaint; + data['clinicDescription'] = this.clinicDescription; + data['clinicID'] = this.clinicID; + data['currentMedication'] = this.currentMedication; + data['doctorID'] = this.doctorID; + data['doctorName'] = this.doctorName; + data['episodeId'] = this.episodeId; + data['hopi'] = this.hopi; + data['patientMRN'] = this.patientMRN; + data['status'] = this.status; + return data; + } +} diff --git a/lib/models/SOAP/GeneralGetReqForSOAP.dart b/lib/models/SOAP/GeneralGetReqForSOAP.dart new file mode 100644 index 00000000..488a06d4 --- /dev/null +++ b/lib/models/SOAP/GeneralGetReqForSOAP.dart @@ -0,0 +1,25 @@ +class GeneralGetReqForSOAP { + int patientMRN; + int appointmentNo; + int episodeId; + String doctorID; + + GeneralGetReqForSOAP( + {this.patientMRN, this.appointmentNo, this.episodeId, this.doctorID}); + + GeneralGetReqForSOAP.fromJson(Map json) { + patientMRN = json['PatientMRN']; + appointmentNo = json['AppointmentNo']; + episodeId = json['EpisodeId']; + doctorID = json['DoctorID']; + } + + Map toJson() { + final Map data = new Map(); + data['PatientMRN'] = this.patientMRN; + data['AppointmentNo'] = this.appointmentNo; + data['EpisodeId'] = this.episodeId; + data['DoctorID'] = this.doctorID; + return data; + } +} diff --git a/lib/models/SOAP/post_assessment_request_model.dart b/lib/models/SOAP/post_assessment_request_model.dart index c8a1ebfd..af577671 100644 --- a/lib/models/SOAP/post_assessment_request_model.dart +++ b/lib/models/SOAP/post_assessment_request_model.dart @@ -13,7 +13,7 @@ class PostAssessmentRequestModel { PostAssessmentRequestModel.fromJson(Map json) { patientMRN = json['PatientMRN']; appointmentNo = json['AppointmentNo']; - episodeId = json['EpisodeId']; + episodeId = json['EpisodeID']; if (json['icdCodeDetails'] != null) { icdCodeDetails = new List(); json['icdCodeDetails'].forEach((v) { @@ -26,7 +26,7 @@ class PostAssessmentRequestModel { final Map data = new Map(); data['PatientMRN'] = this.patientMRN; data['AppointmentNo'] = this.appointmentNo; - data['EpisodeId'] = this.episodeId; + data['EpisodeID'] = this.episodeId; if (this.icdCodeDetails != null) { data['icdCodeDetails'] = this.icdCodeDetails.map((v) => v.toJson()).toList(); diff --git a/lib/models/SOAP/post_progress_note_request_model.dart b/lib/models/SOAP/post_progress_note_request_model.dart index 2217d4ee..069f4dbf 100644 --- a/lib/models/SOAP/post_progress_note_request_model.dart +++ b/lib/models/SOAP/post_progress_note_request_model.dart @@ -9,7 +9,7 @@ class PostProgressNoteRequestModel { PostProgressNoteRequestModel.fromJson(Map json) { appointmentNo = json['AppointmentNo']; - episodeId = json['EpisodeId']; + episodeId = json['EpisodeID']; patientMRN = json['PatientMRN']; planNote = json['PlanNote']; } @@ -17,7 +17,7 @@ class PostProgressNoteRequestModel { Map toJson() { final Map data = new Map(); data['AppointmentNo'] = this.appointmentNo; - data['EpisodeId'] = this.episodeId; + data['EpisodeID'] = this.episodeId; data['PatientMRN'] = this.patientMRN; data['PlanNote'] = this.planNote; return data; diff --git a/lib/routes.dart b/lib/routes.dart index 09e08b0e..1915a89d 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -11,6 +11,7 @@ import 'package:doctor_app_flutter/screens/sick-leave/add-sickleave.dart'; import 'package:doctor_app_flutter/screens/sick-leave/sick_leave.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/SOAP/add_SOAP_index.dart'; import 'package:doctor_app_flutter/screens/procedures/procedure_screen.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/soap_update/update_soap_index.dart'; import './screens/QR_reader_screen.dart'; import './screens/auth/change_password_screen.dart'; @@ -80,8 +81,8 @@ const String PATIENT_INSURANCE_APPROVALS = 'patients/patient_insurance_approvals'; const String VITAL_SIGN_DETAILS = 'patients/vital-sign-details'; const String CREATE_EPISODE = 'patients/create-episode'; +const String UPDATE_EPISODE = 'patients/update-episode'; const String PATIENT_VITAL_SIGN = 'patients/vital-sign-data'; -const String UPDATE_EPISODE = 'patients/create-episode'; const String BODY_MEASUREMENTS = 'patients/body-measurements'; const String IN_PATIENT_PRESCRIPTIONS_DETAILS = 'patients/prescription-details'; @@ -127,7 +128,7 @@ var routes = { VITAL_SIGN_DETAILS: (_) => VitalSignDetailsScreen(), PATIENT_VITAL_SIGN: (_) => PatientVitalSignScreen(), CREATE_EPISODE: (_) => AddSOAPIndex(), - UPDATE_EPISODE: (_) => AddSOAPIndex(isUpdate: true,), + UPDATE_EPISODE: (_) => UpdateSoapIndex(isUpdate: true,), BODY_MEASUREMENTS: (_) => VitalSignItemDetailsScreen(), IN_PATIENT_PRESCRIPTIONS_DETAILS: (_) => InpatientPrescriptionDetailsScreen(), // VIDEO_CALL: (_) => VideoCallPage(patientData: null), diff --git a/lib/widgets/patients/profile/SOAP/assessment_page.dart b/lib/widgets/patients/profile/SOAP/assessment_page.dart index 7c55dca6..722cefe0 100644 --- a/lib/widgets/patients/profile/SOAP/assessment_page.dart +++ b/lib/widgets/patients/profile/SOAP/assessment_page.dart @@ -310,34 +310,34 @@ class _AssessmentPageState extends State { } submitAssessment(SOAPViewModel model) async { - // if (widget.mySelectedAssessment.selectedDiagnosisCondition != null && - // widget.mySelectedAssessment.selectedDiagnosisType != null) { - // PostAssessmentRequestModel postAssessmentRequestModel = - // new PostAssessmentRequestModel( - // patientMRN: widget.patientInfo.patientMRN, - // episodeId: widget.patientInfo.episodeNo, - // appointmentNo: widget.patientInfo.appointmentNo, - // icdCodeDetails: [ - // new IcdCodeDetails( - // remarks: widget.mySelectedAssessment.remark, - // complexDiagnosis: true, - // conditionId: - // widget.mySelectedAssessment.selectedDiagnosisCondition.id, - // diagnosisTypeId: - // widget.mySelectedAssessment.selectedDiagnosisType.id, - // icdcode10Id: "1") - // ]); - // - // await model.postAssessment(postAssessmentRequestModel); - // - // if (model.state == ViewState.ErrorLocal) { - // helpers.showErrorToast(model.error); - // } else { - // widget.changePageViewIndex(3); - // } - // } else { - // helpers.showErrorToast('Please add required field correctly'); - // } + if (widget.mySelectedAssessment.selectedDiagnosisCondition != null && + widget.mySelectedAssessment.selectedDiagnosisType != null) { + PostAssessmentRequestModel postAssessmentRequestModel = + new PostAssessmentRequestModel( + patientMRN: widget.patientInfo.patientMRN, + episodeId: widget.patientInfo.episodeNo, + appointmentNo: widget.patientInfo.appointmentNo, + icdCodeDetails: [ + new IcdCodeDetails( + remarks: widget.mySelectedAssessment.remark, + complexDiagnosis: true, + conditionId: + widget.mySelectedAssessment.selectedDiagnosisCondition.id, + diagnosisTypeId: + widget.mySelectedAssessment.selectedDiagnosisType.id, + icdcode10Id: "1") + ]); + + await model.postAssessment(postAssessmentRequestModel); + + if (model.state == ViewState.ErrorLocal) { + helpers.showErrorToast(model.error); + } else { + widget.changePageViewIndex(3); + } + } else { + helpers.showErrorToast('Please add required field correctly'); + } widget.changePageViewIndex(3); } diff --git a/lib/widgets/patients/profile/SOAP/plan_page.dart b/lib/widgets/patients/profile/SOAP/plan_page.dart index e0653b3e..1bde4b6c 100644 --- a/lib/widgets/patients/profile/SOAP/plan_page.dart +++ b/lib/widgets/patients/profile/SOAP/plan_page.dart @@ -269,24 +269,24 @@ class _PlanPageState extends State { } submitPlan(SOAPViewModel model) async { - // if (progressNoteController.text.isNotEmpty) { - // PostProgressNoteRequestModel postProgressNoteRequestModel = new PostProgressNoteRequestModel( - // patientMRN: widget.patientInfo.patientMRN, - // episodeId: widget.patientInfo.episodeNo, - // appointmentNo: widget.patientInfo.appointmentNo, - // planNote: progressNoteController.text); - // - // - // await model.postProgressNote(postProgressNoteRequestModel); - // - // if (model.state == ViewState.ErrorLocal) { - // helpers.showErrorToast(model.error); - // } else { - // Navigator.of(context).pop(); - // } - // } + if (progressNoteController.text.isNotEmpty) { + PostProgressNoteRequestModel postProgressNoteRequestModel = new PostProgressNoteRequestModel( + patientMRN: widget.patientInfo.patientMRN, + episodeId: widget.patientInfo.episodeNo, + appointmentNo: widget.patientInfo.appointmentNo, + planNote: progressNoteController.text); - Navigator.of(context).pop(); + + await model.postProgressNote(postProgressNoteRequestModel); + + if (model.state == ViewState.ErrorLocal) { + helpers.showErrorToast(model.error); + } else { + Navigator.of(context).pop(); + } + } + + // Navigator.of(context).pop(); } openProgressNote(BuildContext context) { diff --git a/lib/widgets/patients/profile/SOAP/subjective/add_allergies_widget.dart b/lib/widgets/patients/profile/SOAP/subjective/add_allergies_widget.dart index 7f764a0d..e2c49d85 100644 --- a/lib/widgets/patients/profile/SOAP/subjective/add_allergies_widget.dart +++ b/lib/widgets/patients/profile/SOAP/subjective/add_allergies_widget.dart @@ -179,7 +179,7 @@ class _AddAllergiesState extends State { heightFactor: 0.7, child: BaseView( onModelReady: (model) async { - if (model.listOfAllergies.length == 0) { + if (model.allergiesList.length == 0) { await model.getMasterLookup(MasterKeysService.Allergies); } if (model.allergySeverityList.length == 0) { @@ -212,10 +212,10 @@ class _AddAllergiesState extends State { Container( height: screenSize.height * 0.070, child: InkWell( - onTap: model.listOfAllergies != null + onTap: model.allergiesList != null ? () { MasterKeyDailog dialog = MasterKeyDailog( - list: model.listOfAllergies, + list: model.allergiesList, okText: TranslationBase .of(context) .ok, diff --git a/lib/widgets/patients/profile/profile_medical_info_widget.dart b/lib/widgets/patients/profile/profile_medical_info_widget.dart index 20038540..96d7fa35 100644 --- a/lib/widgets/patients/profile/profile_medical_info_widget.dart +++ b/lib/widgets/patients/profile/profile_medical_info_widget.dart @@ -41,7 +41,7 @@ class ProfileMedicalInfoWidget extends StatelessWidget { patient: patient, nameLine1: "Update", nameLine2: "Episode", - route: CREATE_EPISODE, + route: UPDATE_EPISODE, icon: 'heartbeat.png'), PatientProfileButton( key: key, diff --git a/lib/widgets/patients/profile/soap_update/subjective/update_allergies_widget.dart b/lib/widgets/patients/profile/soap_update/subjective/update_allergies_widget.dart new file mode 100644 index 00000000..d7bbd0af --- /dev/null +++ b/lib/widgets/patients/profile/soap_update/subjective/update_allergies_widget.dart @@ -0,0 +1,343 @@ +import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; +import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/my_selected_allergy.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/Text.dart'; +import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/dialogs/master_key_dailog.dart'; +import 'package:eva_icons_flutter/eva_icons_flutter.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +class UpdateAllergiesWidget extends StatefulWidget { + final List myAllergiesList; + + UpdateAllergiesWidget({Key key, this.myAllergiesList}); + + @override + _UpdateAllergiesWidgetState createState() => _UpdateAllergiesWidgetState(); +} + +class _UpdateAllergiesWidgetState extends State { + + TextEditingController remarkController = TextEditingController(); + + @override + Widget build(BuildContext context) { + final screenSize = MediaQuery.of(context).size; + + return Column( + children: [ + Container( + margin: EdgeInsets.only(left: 10, right: 10, top: 15), + child: TextFields( + hintText: "Add Allergies", + fontSize: 13.5, + onTapTextFields: () { + openAllergiesList(context); + }, + readOnly: true, + // hintColor: Colors.black, + suffixIcon: EvaIcons.plusCircleOutline, + suffixIconColor: AppGlobal.appPrimaryColor, + fontWeight: FontWeight.w600, + // controller: messageController, + validator: (value) { + if (value == null) + return TranslationBase + .of(context) + .emptyMessage; + else + return null; + }), + ), + SizedBox( + height: 20, + ), + Container( + margin: + EdgeInsets.only(left: 15, right: 15, top: 15), + child: Column( + children: widget.myAllergiesList.map((selectedAllergy) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Texts(selectedAllergy.selectedAllergy.nameEn.toUpperCase(), + variant: "bodyText", bold: true, color: Colors.black), + Texts( + selectedAllergy.selectedAllergySeverity.nameEn + .toUpperCase(), + variant: "bodyText", + bold: true, + color: AppGlobal.appPrimaryColor), + InkWell( + child: Icon( + FontAwesomeIcons.trash, + color: Colors.grey, + size: 20, + ), + onTap: () => removeAllergy(selectedAllergy), + ) + ], + ), + SizedBox( + height: 10, + ), + ], + ); + }).toList()), + ) + ], + ); + } + + removeAllergy(MySelectedAllergy mySelectedAllergy) { + Iterable allergy = + widget.myAllergiesList.where((element) => mySelectedAllergy == element); + + if (allergy.length > 0) + setState(() { + widget.myAllergiesList.remove(allergy.first); + }); + } + + openAllergiesList(BuildContext context) { + showModalBottomSheet( + backgroundColor: Colors.white, + isScrollControlled: true, + context: context, + builder: (context) { + return AddAllergies( + addAllergiesFun: (MySelectedAllergy mySelectedAllergy) { + setState(() { + widget.myAllergiesList.add(mySelectedAllergy); + Navigator.of(context).pop(); + }); + },); + }); + } + +} + +class AddAllergies extends StatefulWidget { + final Function addAllergiesFun; + + const AddAllergies({Key key, this.addAllergiesFun}) : super(key: key); + + @override + _AddAllergiesState createState() => _AddAllergiesState(); +} + +class _AddAllergiesState extends State { + List allergiesList; + List allergySeverityList; + MasterKeyModel _selectedAllergySeverity; + MasterKeyModel _selectedAllergy; + TextEditingController remarkController = TextEditingController(); + + + InputDecoration textFieldSelectorDecoration(String hintText, + String selectedText, bool isDropDown) { + return InputDecoration( + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), + borderRadius: BorderRadius.circular(8), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), + borderRadius: BorderRadius.circular(8), + ), + disabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), + borderRadius: BorderRadius.circular(8), + ), + hintText: selectedText != null ? selectedText : hintText, + suffixIcon: isDropDown ? Icon(Icons.arrow_drop_down) : null, + hintStyle: TextStyle( + fontSize: 14, + color: Colors.grey.shade600, + ), + ); + } + + @override + Widget build(BuildContext context) { + final screenSize = MediaQuery + .of(context) + .size; + return FractionallySizedBox( + heightFactor: 0.7, + child: BaseView( + onModelReady: (model) async { + if (model.allergiesList.length == 0) { + await model.getMasterLookup(MasterKeysService.Allergies); + } + if (model.allergySeverityList.length == 0) { + await model.getMasterLookup(MasterKeysService.AllergySeverity); + } + }, + builder: (_, model, w) => + AppScaffold( + baseViewModel: model, + isShowAppBar: false, + body: SingleChildScrollView( + child: Center( + child: FractionallySizedBox( + widthFactor: 0.9, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + + SizedBox( + height: 16, + ), + AppText( + "Add Allergy", + fontWeight: FontWeight.bold, + fontSize: 16, + ), + SizedBox( + height: 16, + ), + Container( + height: screenSize.height * 0.070, + child: InkWell( + onTap: model.allergiesList != null + ? () { + MasterKeyDailog dialog = MasterKeyDailog( + list: model.allergiesList, + okText: TranslationBase + .of(context) + .ok, + okFunction: (MasterKeyModel selectedValue) { + setState(() { + _selectedAllergy = selectedValue; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: TextField( + decoration: textFieldSelectorDecoration( + "Select Allergy", + _selectedAllergy != null + ? _selectedAllergy.nameEn + : null, + true), + enabled: false, + ), + ), + ), + SizedBox( + height: 10, + ), Container( + height: screenSize.height * 0.070, + child: InkWell( + onTap: model.allergySeverityList != null + ? () { + MasterKeyDailog dialog = MasterKeyDailog( + list: model.allergySeverityList, + okText: TranslationBase + .of(context) + .ok, + okFunction: (selectedValue) { + setState(() { + _selectedAllergySeverity = + selectedValue; + // model.getDoctorBranch().then((value) { + // _selectedBranch = value; + // if (_referTo['id'] == 1) { + // model.getClinics( + // _selectedBranch['ID']); + // } + // }); + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: TextField( + decoration: textFieldSelectorDecoration( + "Select Severity", + _selectedAllergySeverity != null + ? _selectedAllergySeverity.nameEn + : null, + true), + enabled: false, + ), + ), + ), + SizedBox( + height: 10, + ), + Container( + margin: EdgeInsets.only( + left: 0, right: 0, top: 15), + child: TextFields( + hintText: "Remarks", + fontSize: 13.5, + // hintColor: Colors.black, + fontWeight: FontWeight.w600, + maxLines: 25, + minLines: 13, + controller: remarkController, + validator: (value) { + if (value == null) + return TranslationBase + .of(context) + .emptyMessage; + else + return null; + }), + ), SizedBox( + height: 10, + ), + AppButton( + title: "Add".toUpperCase(), + onPressed: () { + MySelectedAllergy mySelectedAllergy = new MySelectedAllergy( + remark: remarkController.text, + selectedAllergy: _selectedAllergy, + selectedAllergySeverity: _selectedAllergySeverity); + widget.addAllergiesFun(mySelectedAllergy); + }, + ), + ] + + ), + ), + ), + )), + ), + ); + } +} + + + + + diff --git a/lib/widgets/patients/profile/soap_update/subjective/update_history_widget.dart b/lib/widgets/patients/profile/soap_update/subjective/update_history_widget.dart new file mode 100644 index 00000000..d8f2b888 --- /dev/null +++ b/lib/widgets/patients/profile/soap_update/subjective/update_history_widget.dart @@ -0,0 +1,574 @@ +import 'package:doctor_app_flutter/config/config.dart'; +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/viewModel/SOAP_view_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/Text.dart'; +import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/divider_with_spaces_around.dart'; +import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; +import 'package:eva_icons_flutter/eva_icons_flutter.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:hexcolor/hexcolor.dart'; + +class UpdateHistoryWidget extends StatefulWidget { + final List myHistoryList; + + const UpdateHistoryWidget({Key key, this.myHistoryList}) : super(key: key); + + @override + _UpdateHistoryWidgetState createState() => _UpdateHistoryWidgetState(); +} + +class _UpdateHistoryWidgetState extends State + with TickerProviderStateMixin { + PageController _controller; + int _currentIndex = 0; + + changePageViewIndex(pageIndex) { + _controller.jumpToPage(pageIndex); + } + + @override + void initState() { + _controller = new PageController(); + + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Column( + children: [ + Container( + margin: EdgeInsets.only(left: 10, right: 10, top: 15), + child: TextFields( + hintText: "Add History", + fontSize: 13.5, + onTapTextFields: () { + openHistoryList(context); + }, + readOnly: true, + // hintColor: Colors.black, + suffixIcon: EvaIcons.plusCircleOutline, + suffixIconColor: AppGlobal.appPrimaryColor, + fontWeight: FontWeight.w600, + // controller: messageController, + validator: (value) { + if (value == null) + return TranslationBase.of(context) + .emptyMessage; + else + return null; + }), + ), + SizedBox( + height: 20, + ), + Container( + margin: + EdgeInsets.only(left: 15, right: 15, top: 15), + child: Column( + children: widget.myHistoryList.map((myHistory) { + return Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts(myHistory.nameEn, + variant: "bodyText", bold: true, color: Colors.black), + InkWell( + child: Icon( + FontAwesomeIcons.trash, + color: Colors.grey, + size: 20, + ), + onTap: () => removeHistory(myHistory), + ) + ], + ), + SizedBox( + height: 20, + ), + ], + ); + }).toList(), + ), + ) + ], + ); + } + + removeHistory(MasterKeyModel masterKey) { + Iterable history = widget.myHistoryList.where((element) => + masterKey.id == element.id && masterKey.typeId == element.typeId); + + if (history.length > 0) + setState(() { + widget.myHistoryList.remove(history.first); + }); + } + + openHistoryList(BuildContext context) { + showModalBottomSheet( + backgroundColor: Colors.white, + isScrollControlled: true, + context: context, + builder: (context) { + return AddHistoryDialog( + changePageViewIndex: changePageViewIndex, + controller: _controller, + myHistoryList: widget.myHistoryList, + addSelectedHistories: () { + setState(() { + Navigator.of(context).pop(); + }); + }, + removeHistory: (masterKey) => removeHistory(masterKey), + ); + }); + } +} + +class PriorityBar extends StatefulWidget { + final Function onTap; + + const PriorityBar({Key key, this.onTap}) : super(key: key); + + @override + _PriorityBarState createState() => _PriorityBarState(); +} + +class _PriorityBarState extends State { + int _activePriority = 0; + + List _priorities = [ + "Family", + "Surgical/Sports", + "Medical", + ]; + + BoxDecoration containerBorderDecoration( + Color containerColor, Color borderColor) { + return BoxDecoration( + color: containerColor, + shape: BoxShape.rectangle, + borderRadius: BorderRadius.all(Radius.circular(6)), + border: Border.fromBorderSide(BorderSide( + color: borderColor, + width: 2.0, + )), + ); + } + + @override + Widget build(BuildContext context) { + final screenSize = MediaQuery.of(context).size; + + return Container( + height: screenSize.height * 0.070, + decoration: + containerBorderDecoration(Color(0Xffffffff), Color(0xFFCCCCCC)), + child: Row( + mainAxisSize: MainAxisSize.max, + crossAxisAlignment: CrossAxisAlignment.center, + children: _priorities.map((item) { + bool _isActive = _priorities[_activePriority] == item ? true : false; + return Expanded( + child: InkWell( + child: Center( + child: Container( + height: screenSize.height * 0.070, + decoration: containerBorderDecoration( + _isActive ? HexColor("#B8382B") : Colors.white, + _isActive ? HexColor("#B8382B") : Colors.white), + child: Center( + child: Text( + item, + style: TextStyle( + fontSize: 12, + color: _isActive + ? Colors.white + : Colors.black, //Colors.black, + fontWeight: FontWeight.bold, + ), + ), + )), + ), + onTap: () { + widget.onTap(_priorities.indexOf(item)); + + setState(() { + _activePriority = _priorities.indexOf(item); + }); + }), + ); + }).toList(), + ), + ); + } +} + +class AddHistoryDialog extends StatefulWidget { + final Function changePageViewIndex; + final PageController controller; + final List myHistoryList; + final Function addSelectedHistories; + final Function (MasterKeyModel) removeHistory; + + const AddHistoryDialog( + {Key key, this.changePageViewIndex, this.controller, this.myHistoryList, this.addSelectedHistories, this.removeHistory}) + : super(key: key); + + @override + _AddHistoryDialogState createState() => _AddHistoryDialogState(); +} + +class _AddHistoryDialogState extends State { + @override + Widget build(BuildContext context) { + return FractionallySizedBox( + heightFactor: 0.7, + child: BaseView( + onModelReady: (model) async { + if (model.historyFamilyList.length == 0) { + await model.getMasterLookup(MasterKeysService.HistoryFamily); + } + }, + builder: (_, model, w) => AppScaffold( + // baseViewModel: model, + isShowAppBar: false, + body: Center( + child: Container( + child: FractionallySizedBox( + widthFactor: 0.9, + child: Column( + children: [ + SizedBox( + height: 10, + ), + PriorityBar(onTap: (activePriority) async { + widget.changePageViewIndex(activePriority); + if(activePriority ==1) { + if (model.historySurgicalList.length == 0) { + await model.getMasterLookup(MasterKeysService.HistorySurgical); + await model.getMasterLookup(MasterKeysService.HistorySports); + } + } + if(activePriority ==2) { + if (model.historyMedicalList.length == 0) { + await model.getMasterLookup(MasterKeysService.HistoryMedical); + } + } + }), + SizedBox( + height: 20, + ), + Expanded( + child: PageView( + physics: NeverScrollableScrollPhysics(), + controller: widget.controller, + onPageChanged: (index) { + setState(() { + // currentIndex = index; + }); + }, + scrollDirection: Axis.horizontal, + children: [ + Container( + child: Column( + children: [ + NetworkBaseView( + baseViewModel: model, + child: Container( + height: + MediaQuery.of(context).size.height * 0.5, + child: Center( + child: Container( + margin: EdgeInsets.only(top: 15), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + color: Colors.white), + child: ListView( + children: [ + Column( + children: model.historyFamilyList + .map((historyInfo) { + return Column( + children: [ + Row( + children: [ + Checkbox( + value: isServiceSelected( + historyInfo), + activeColor: + Colors.red[800], + onChanged: + (bool newValue) { + setState(() { + if (isServiceSelected( + historyInfo + )) { + widget + .removeHistory( + historyInfo + ); + } + else { + widget + .myHistoryList + .add( + historyInfo); + } + }); + }), + Expanded( + child: Padding( + padding: + const EdgeInsets + .symmetric( + horizontal: 10, + vertical: 0), + child: Texts( + historyInfo.nameEn, + variant: "bodyText", + bold: true, + color: + Colors.black), + ), + ), + ], + ), + DividerWithSpacesAround(), + ], + ); + }).toList(), + ), + ], + ), + )), + ), + ), + SizedBox( + height: 10, + ), + if (model.state == ViewState.Idle) + AppButton( + title: "Add SELECTED HISTORIES" + .toUpperCase(), + onPressed: () { + widget.addSelectedHistories(); + }, + ), + ], + ), + ), + Container( + child: Column( + children: [ + NetworkBaseView( + baseViewModel: model, + child: Container( + height: + MediaQuery.of(context).size.height * 0.5, + child: Center( + child: Container( + margin: EdgeInsets.only(top: 15), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + color: Colors.white), + child: ListView( + children: [ + Column( + children: model.mergeHistorySurgicalWithHistorySportList + .map((historyInfo) { + return Column( + children: [ + Row( + children: [ + Checkbox( + value: isServiceSelected( + historyInfo), + activeColor: + Colors.red[800], + onChanged: + ( + bool newValue) { + setState(() { + if (isServiceSelected( + historyInfo + )) { + widget + .removeHistory( + historyInfo + ); + } + else { + widget + .myHistoryList + .add( + historyInfo); + } + }); + }), + Expanded( + child: Padding( + padding: + const EdgeInsets + .symmetric( + horizontal: 10, + vertical: 0), + child: Texts( + historyInfo.nameEn, + variant: "bodyText", + bold: true, + color: + Colors.black), + ), + ), + ], + ), + DividerWithSpacesAround(), + ], + ); + }).toList(), + ), + ], + ), + )), + ), + ), + SizedBox( + height: 10, + ), + if (model.state == ViewState.Idle) + AppButton( + title: "Add SELECTED HISTORIES" + .toUpperCase(), + onPressed: () { + widget.addSelectedHistories(); + }, + ), + ], + ), + ), + Container( + child: Column( + children: [ + NetworkBaseView( + baseViewModel: model, + child: Container( + height: + MediaQuery.of(context).size.height * 0.5, + child: Center( + child: Container( + margin: EdgeInsets.only(top: 15), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + color: Colors.white), + child: ListView( + children: [ + Column( + children: model.historyMedicalList + .map((historyInfo) { + return Column( + children: [ + Row( + children: [ + Checkbox( + value: isServiceSelected( + historyInfo), + activeColor: + Colors.red[800], + onChanged: + ( + bool newValue) { + setState(() { + if (isServiceSelected( + historyInfo + )) { + widget + .removeHistory( + historyInfo + ); + } + else { + widget + .myHistoryList + .add( + historyInfo); + } + }); + }), + Expanded( + child: Padding( + padding: + const EdgeInsets + .symmetric( + horizontal: 10, + vertical: 0), + child: Texts( + historyInfo.nameEn, + variant: "bodyText", + bold: true, + color: + Colors.black), + ), + ), + ], + ), + DividerWithSpacesAround(), + ], + ); + }).toList(), + ), + ], + ), + )), + ), + ), + SizedBox( + height: 10, + ), + if (model.state == ViewState.Idle) + AppButton( + title: "Add SELECTED HISTORIES" + .toUpperCase(), + onPressed: () { + setState(() { + widget.addSelectedHistories(); + }); + }, + ), + ], + ), + ), + ], + ), + ), + ], + ), + )), + ), + ), + )); + } + + isServiceSelected(MasterKeyModel masterKey) { + Iterable history = + widget + .myHistoryList + .where((element) => + masterKey.id == element.id && masterKey.typeId == element.typeId); + if (history.length > 0) { + return true; + } + return false; + } + +} diff --git a/lib/widgets/patients/profile/soap_update/subjective/update_medication_widget.dart b/lib/widgets/patients/profile/soap_update/subjective/update_medication_widget.dart new file mode 100644 index 00000000..6584d415 --- /dev/null +++ b/lib/widgets/patients/profile/soap_update/subjective/update_medication_widget.dart @@ -0,0 +1,107 @@ + +import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/Text.dart'; +import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; +import 'package:eva_icons_flutter/eva_icons_flutter.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +class UpdateMedication extends StatefulWidget { + @override + _UpdateMedicationState createState() => _UpdateMedicationState(); +} + +class _UpdateMedicationState extends State { + @override + Widget build(BuildContext context) { + return Column( + children: [ + Container( + margin: + EdgeInsets.only(left: 10, right: 10, top: 15), + child: TextFields( + hintText: "Current Medications", + fontSize: 13.5, + onTapTextFields: () { + openMedicationsList(context); + }, + readOnly: true, + // hintColor: Colors.black, + suffixIcon: EvaIcons.plusCircleOutline, + suffixIconColor: AppGlobal.appPrimaryColor, + fontWeight: FontWeight.w600, + // controller: messageController, + validator: (value) { + if (value == null) + return TranslationBase.of(context) + .emptyMessage; + else + return null; + }), + ), + SizedBox( + height: 20, + ), + Container( + margin: + EdgeInsets.only(left: 15, right: 15, top: 15), + child: Column( + children: [ + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Texts('Abdomen Pain', + variant: "bodyText", + bold: true, + color: Colors.black), + Icon( + FontAwesomeIcons.trash, + color: Colors.grey, + size: 20, + ) + ], + ), + SizedBox( + height: 20, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Texts('Back Pain', + variant: "bodyText", + bold: true, + color: Colors.black), + Icon( + FontAwesomeIcons.trash, + color: Colors.grey, + size: 20, + ) + ], + ), + ], + ), + ) + ], + ); + } + openMedicationsList(BuildContext context) { + showModalBottomSheet( + backgroundColor: Colors.white, + isScrollControlled: true, + context: context, + builder: (context) { + return FractionallySizedBox( + heightFactor: 0.7, + child: Container( + child: Center( + child: Texts("dfdfd"), + )), + ); + }); + } + +} + diff --git a/lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart b/lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart new file mode 100644 index 00000000..24be10e1 --- /dev/null +++ b/lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart @@ -0,0 +1,405 @@ +import 'package:doctor_app_flutter/client/base_app_client.dart'; +import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/core/enum/viewstate.dart'; +import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/my_selected_allergy.dart'; +import 'package:doctor_app_flutter/models/SOAP/post_allergy_request_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/post_chief_complaint_request_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/post_histories_request_model.dart'; +import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/SOAP/subjective/add_allergies_widget.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/SOAP/subjective/add_history_widget.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/soap_update/subjective/update_allergies_widget.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/soap_update/subjective/update_history_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/Text.dart'; +import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/expandable-widget-header-body.dart'; +import 'package:eva_icons_flutter/eva_icons_flutter.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +class UpdateSubjectivePage extends StatefulWidget { + final Function changePageViewIndex; + final List myAllergiesList; + final List myHistoryList; + final PatiantInformtion patientInfo; + + UpdateSubjectivePage( + {Key key, + this.changePageViewIndex, + this.myAllergiesList, + this.myHistoryList, + this.patientInfo}); + + @override + _UpdateSubjectivePageState createState() => _UpdateSubjectivePageState(); +} + +class _UpdateSubjectivePageState extends State { + bool isChiefExpand = false; + bool isHistoryExpand = false; + bool isAllergiesExpand = false; + TextEditingController illnessController = TextEditingController(); + TextEditingController complaintsController = TextEditingController(); + final formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return BaseView( + // onModelReady: (model) => model.getMasterLookup(MasterKeysService.Allergies), + builder: (_, model, w) => AppScaffold( + isShowAppBar: false, + baseViewModel: model, + body: SingleChildScrollView( + physics: ScrollPhysics(), + child: Center( + child: FractionallySizedBox( + widthFactor: 0.9, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + SizedBox( + height: 30, + ), + HeaderBodyExpandableNotifier( + headerWidget: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Texts('CHIEF COMPLAINTS', + variant: isChiefExpand ? "bodyText" : '', + bold: isChiefExpand ? true : false, + color: Colors.black), + Icon( + FontAwesomeIcons.asterisk, + color: AppGlobal.appPrimaryColor, + size: 12, + ) + ], + ), + InkWell( + onTap: () { + setState(() { + isChiefExpand = !isChiefExpand; + }); + }, + child: Icon( + isChiefExpand ? EvaIcons.minus : EvaIcons.plus)) + ], + ), + bodyWidget: Form( + key: formKey, + child: Column(children: [ + SizedBox( + height: 20, + ), + Container( + margin: EdgeInsets.only(left: 10, right: 10, top: 15), + child: TextFields( + hintText: "Add Chief Complaints", + fontSize: 13.5, + // hintColor: Colors.black, + fontWeight: FontWeight.w600, + maxLines: 25, + minLines: 13, + controller: complaintsController, + validator: (value) { + if (value == null || value =="") + return TranslationBase + .of(context) + .emptyMessage; + else if (value.length < 25) + return TranslationBase + .of(context) + .chiefComplaintLength; + //""; + else + return null; + }), + ), + SizedBox( + height: 20, + ), + Container( + margin: EdgeInsets.only(left: 10, right: 10, top: 15), + child: TextFields( + hintText: "History of Present Illness", + fontSize: 13.5, + // hintColor: Colors.black, + fontWeight: FontWeight.w600, + maxLines: 25, + minLines: 13, + controller: illnessController, + validator: (value) { + if (value == null || value =="") + return TranslationBase + .of(context) + .emptyMessage; + else + return null; + }), + ), + SizedBox( + height: 20, + ), + // TODO return it back when we need it. + // AddMedication(), + ]), + ), + isExpand: isChiefExpand, + ), + + SizedBox( + height: 30, + ), + Container( + width: double.infinity, + height: 1, + color: Color(0xffCCCCCC), + ), + SizedBox( + height: 30, + ), + HeaderBodyExpandableNotifier( + headerWidget: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Texts('History'.toUpperCase(), + variant: isHistoryExpand ? "bodyText" : '', + bold: isHistoryExpand ? true : false, + color: Colors.black), + ], + ), + InkWell( + onTap: () { + setState(() { + isHistoryExpand = !isHistoryExpand; + }); + }, + child: Icon(isHistoryExpand + ? EvaIcons.minus + : EvaIcons.plus)) + ], + ), + bodyWidget: Column( + children: [ + UpdateHistoryWidget(myHistoryList: widget.myHistoryList) + ], + ), + isExpand: isHistoryExpand, + ), + SizedBox( + height: 30, + ), + Container( + width: double.infinity, + height: 1, + color: Color(0xffCCCCCC), + ), + SizedBox( + height: 30, + ), + HeaderBodyExpandableNotifier( + headerWidget: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Texts('Allergies'.toUpperCase(), + variant: isAllergiesExpand ? "bodyText" : '', + bold: isAllergiesExpand ? true : false, + color: Colors.black), + ], + ), + InkWell( + onTap: () { + setState(() { + isAllergiesExpand = !isAllergiesExpand; + }); + }, + child: Icon(isAllergiesExpand + ? EvaIcons.minus + : EvaIcons.plus)) + ], + ), + bodyWidget:Column( + children: [ + UpdateAllergiesWidget(myAllergiesList: widget.myAllergiesList,), + SizedBox( + height: 30, + ), + ], + ) + , + isExpand: isAllergiesExpand, + ), + SizedBox( + height: 30, + ), + Container( + width: double.infinity, + height: 1, + color: Color(0xffCCCCCC), + ), + SizedBox( + height: 30, + ), + AppButton( + title: TranslationBase.of(context).next, + loading: model.state == ViewState.BusyLocal, + onPressed: () async { + addSubjectiveInfo( + model: model, + myAllergiesList: widget.myAllergiesList, + myHistoryList: widget.myHistoryList); + }, + ), + ], + ), + ), + ), + ), + ), + ); + } + + addSubjectiveInfo( + {SOAPViewModel model, + List myAllergiesList, + List myHistoryList}) async { + formKey.currentState.save(); + formKey.currentState.validate(); + + + // if(complaintsController.text.isNotEmpty && illnessController.text.isNotEmpty && complaintsController.text.length>25) { + // await postChiefComplaint(model: model); + // if (model.state == ViewState.ErrorLocal) { + // helpers.showErrorToast(model.error); + // } else { + // if (myHistoryList.length != 0) { + // await postHistories(model: model, myHistoryList: myHistoryList); + // if (model.state == ViewState.ErrorLocal) { + // helpers.showErrorToast(model.error); + // } else { + // if (myAllergiesList.length != 0) { + // await postAllergy(myAllergiesList: myAllergiesList, model: model); + // if (model.state == ViewState.ErrorLocal) { + // helpers.showErrorToast(model.error); + // } else { + // widget.changePageViewIndex(1); + // } + // } else { + // widget.changePageViewIndex(1); + // + // } + // + // } + // } else { + // if (myAllergiesList.length != 0) { + // await postAllergy(myAllergiesList: myAllergiesList, model: model); + // if (model.state == ViewState.ErrorLocal) { + // helpers.showErrorToast(model.error); + // } else { + // widget.changePageViewIndex(1); + // } + // } else { + // widget.changePageViewIndex(1); + // } + // } + // } + // } else { + // helpers.showErrorToast('Please add required field correctly'); + // } + + widget.changePageViewIndex(1); + + } + + postAllergy( + {List myAllergiesList, SOAPViewModel model}) async { + PostAllergyRequestModel postAllergyRequestModel = + new PostAllergyRequestModel(); + widget.myAllergiesList.forEach((allergy) { + if (postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM == + null) + postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM = []; + //TODO: make static value dynamic + postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM + .add(ListHisProgNotePatientAllergyDiseaseVM( + allergyDiseaseId: allergy.selectedAllergy.id, + allergyDiseaseType: allergy.selectedAllergy.typeId, + patientMRN: widget.patientInfo.patientMRN, + episodeId: widget.patientInfo.episodeNo, + appointmentNo: widget.patientInfo.appointmentNo, + severity: allergy.selectedAllergySeverity.id, + remarks: allergy.remark, + createdBy: 1485, + // + createdOn: DateTime.now().toIso8601String(),//"2020-08-14T20:37:22.780Z", + editedBy: 1485, + editedOn: DateTime.now().toIso8601String(),//"2020-08-14T20:37:22.780Z", + isChecked: false, + isUpdatedByNurse: false)); + }); + await model.patchAllergy(postAllergyRequestModel); + + if (model.state == ViewState.ErrorLocal) { + helpers.showErrorToast(model.error); + } + } + + postHistories( + {List myHistoryList, SOAPViewModel model}) async { + PostHistoriesRequestModel postHistoriesRequestModel = + new PostHistoriesRequestModel(); + widget.myHistoryList.forEach((history) { + if (postHistoriesRequestModel.listMedicalHistoryVM == null) + postHistoriesRequestModel.listMedicalHistoryVM = []; + //TODO: make static value dynamic + postHistoriesRequestModel.listMedicalHistoryVM.add(ListMedicalHistoryVM( + patientMRN: widget.patientInfo.patientMRN, + episodeId: widget.patientInfo.episodeNo, + appointmentNo: widget.patientInfo.appointmentNo, + remarks: "", + historyId: history.id, + historyType: history.typeId, + isChecked: false, + )); + }); + await model.patchHistories(postHistoriesRequestModel); + + if (model.state == ViewState.ErrorLocal) { + helpers.showErrorToast(model.error); + } + } + + postChiefComplaint({SOAPViewModel model}) async { + formKey.currentState.save(); + if(formKey.currentState.validate()){ + PostChiefComplaintRequestModel postChiefComplaintRequestModel = + //TODO: make static value dynamic + new PostChiefComplaintRequestModel( + patientMRN: widget.patientInfo.patientMRN, + episodeID: widget.patientInfo.episodeNo, + appointmentNo: widget.patientInfo.appointmentNo, + chiefComplaint: complaintsController.text, + currentMedication: " currentMedication ", + hopi: illnessController.text, + isLactation: false, + ispregnant: false, + numberOfWeeks: 22); + + await model.patchChiefComplaint(postChiefComplaintRequestModel); + + } + + } +} diff --git a/lib/widgets/patients/profile/soap_update/update_assessment_page.dart b/lib/widgets/patients/profile/soap_update/update_assessment_page.dart new file mode 100644 index 00000000..556949e8 --- /dev/null +++ b/lib/widgets/patients/profile/soap_update/update_assessment_page.dart @@ -0,0 +1,706 @@ +import 'package:doctor_app_flutter/client/base_app_client.dart'; +import 'package:doctor_app_flutter/config/config.dart'; +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/viewModel/SOAP_view_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/my_selected_assement.dart'; +import 'package:doctor_app_flutter/models/SOAP/post_assessment_request_model.dart'; +import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/Text.dart'; +import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/dialogs/master_key_dailog.dart'; +import 'package:doctor_app_flutter/widgets/shared/divider_with_spaces_around.dart'; +import 'package:doctor_app_flutter/widgets/shared/expandable-widget-header-body.dart'; +import 'package:eva_icons_flutter/eva_icons_flutter.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +class UpdateAssessmentPage extends StatefulWidget { + final Function changePageViewIndex; + final MySelectedAssessment mySelectedAssessment; + final PatiantInformtion patientInfo; + + UpdateAssessmentPage( + {Key key, this.changePageViewIndex, this.mySelectedAssessment, this.patientInfo}); + + @override + _UpdateAssessmentPageState createState() => _UpdateAssessmentPageState(); +} + +class _UpdateAssessmentPageState extends State { + bool isAssessmentExpand = false; + + List assessmentList; + dynamic _referTo; + + TextEditingController remarksController = TextEditingController(); + + @override + Widget build(BuildContext context) { + final screenSize = MediaQuery.of(context).size; + + return BaseView( + builder: (_, model, w) => AppScaffold( + isShowAppBar: false, + body: SingleChildScrollView( + physics: ScrollPhysics(), + child: Center( + child: FractionallySizedBox( + widthFactor: 0.9, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + SizedBox( + height: 30, + ), + HeaderBodyExpandableNotifier( + headerWidget: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Texts('ASSESSMENT', + variant: + isAssessmentExpand ? "bodyText" : '', + bold: isAssessmentExpand ? true : false, + color: Colors.black), + Icon( + FontAwesomeIcons.asterisk, + color: AppGlobal.appPrimaryColor, + size: 12, + ) + ], + ), + InkWell( + onTap: () { + setState(() { + isAssessmentExpand = !isAssessmentExpand; + }); + }, + child: Icon(isAssessmentExpand + ? EvaIcons.minus + : EvaIcons.plus)) + ], + ), + bodyWidget: Column(children: [ + SizedBox( + height: 20, + ), + Column( + children: [ + Container( + margin: + EdgeInsets.only(left: 5, right: 5, top: 15), + child: TextFields( + hintText: "Add ASSESSMENT", + fontSize: 13.5, + onTapTextFields: () { + openAssessmentDialog(context); + }, + readOnly: true, + // hintColor: Colors.black, + suffixIcon: EvaIcons.plusCircleOutline, + suffixIconColor: AppGlobal.appPrimaryColor, + fontWeight: FontWeight.w600, + // controller: messageController, + validator: (value) { + if (value == null) + return TranslationBase + .of(context) + .emptyMessage; + else + return null; + }), + ), + SizedBox( + height: 20, + ), + if(widget.mySelectedAssessment != null && + widget.mySelectedAssessment + .appointmentId != + null && widget.mySelectedAssessment + .selectedDiagnosisType != null && + widget.mySelectedAssessment + .selectedDiagnosisCondition != null) + Container( + margin: EdgeInsets.only( + left: 5, right: 5, top: 15), + child: Row( + mainAxisAlignment: MainAxisAlignment + .spaceBetween, + crossAxisAlignment: CrossAxisAlignment + .start, + children: [ + Column( + mainAxisAlignment: MainAxisAlignment + .start, + children: [ + Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + AppText( + "12".toUpperCase(), + fontWeight: FontWeight.bold, + fontSize: 16, + ), + AppText( + "DEC".toUpperCase(), + fontSize: 10, + color: Colors.grey, + ), + ], + ) + ], + ), + Column( + crossAxisAlignment: CrossAxisAlignment + .start, + children: [ + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + AppText( + "Appointment #: ", + fontWeight: FontWeight.bold, + fontSize: 16, + ), + AppText( + widget.mySelectedAssessment + .appointmentId + .toString(), + fontSize: 10, + color: Colors.grey, + ), + ], + ), + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + AppText( + widget.mySelectedAssessment + .selectedDiagnosisCondition + .nameEn, + fontWeight: FontWeight.bold, + fontSize: 16, + ), + ], + ), + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + AppText( + "Type : ", + fontWeight: FontWeight.bold, + fontSize: 16, + ), + AppText( + widget.mySelectedAssessment + .selectedDiagnosisType + .nameEn, + fontSize: 10, + color: Colors.grey, + ), + ], + ), + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + AppText( + "Doc : ", + fontWeight: FontWeight.bold, + fontSize: 16, + ), + AppText( + "Anas Abdullah", + fontSize: 10, + color: Colors.grey, + ), + ], + ), + SizedBox( + height: 6, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + SizedBox( + height: 6, + ), + AppText( + widget.mySelectedAssessment.remark, + fontSize: 10, + color: Colors.grey, + ), + ], + ), + ], + ), + Column( + crossAxisAlignment: CrossAxisAlignment + .start, + children: [ + Row( + + children: [ + AppText( + "ICD: ".toUpperCase(), + fontWeight: FontWeight.bold, + fontSize: 16, + ), + AppText( + "R07.1".toUpperCase(), + fontSize: 10, + color: Colors.grey, + ), + ], + ) + ], + ), + Column( + children: [ + InkWell( + onTap: () { + openAssessmentDialog(context); + }, + child: Icon(EvaIcons + .edit2Outline), + ) + ], + ), + ], + ), + ) + ], + ) + ]), + isExpand: isAssessmentExpand, + ), + DividerWithSpacesAround( + height: 30, + ), + AppButton( + title: TranslationBase.of(context).next, + loading: model.state == ViewState.BusyLocal, + onPressed: () async { + await submitAssessment(model); + }, + ), + SizedBox( + height: 30, + ), + ], + ), + ), + ), + ))); + } + + submitAssessment(SOAPViewModel model) async { + if (widget.mySelectedAssessment.selectedDiagnosisCondition != null && + widget.mySelectedAssessment.selectedDiagnosisType != null) { + PatchAssessmentReqModel patchAssessmentReqModel = + new PatchAssessmentReqModel( + patientMRN: widget.patientInfo.patientMRN, + episodeId: widget.patientInfo.episodeNo, + appointmentNo: widget.patientInfo.appointmentNo, + remarks: widget.mySelectedAssessment.remark, + complexDiagnosis: true, + conditionId: + widget.mySelectedAssessment.selectedDiagnosisCondition.id, + diagnosisTypeId: + widget.mySelectedAssessment.selectedDiagnosisType.id, + icdcode10Id: "1", + prevIcdCode10ID: "1" + ); + + await model.patchAssessment(patchAssessmentReqModel); + + if (model.state == ViewState.ErrorLocal) { + helpers.showErrorToast(model.error); + } else { + widget.changePageViewIndex(3); + } + } else { + helpers.showErrorToast('Please add required field correctly'); + } + + widget.changePageViewIndex(3); + } + + openAssessmentDialog(BuildContext context) { + showModalBottomSheet( + backgroundColor: Colors.white, + isScrollControlled: true, + context: context, + builder: (context) { + return AddAssessmentDetails( + mySelectedAssessment: widget.mySelectedAssessment, + addSelectedAssessment: () { + setState(() { + Navigator.of(context).pop(); + }); + }); + }); + } + +} + +class AddAssessmentDetails extends StatefulWidget { + final MySelectedAssessment mySelectedAssessment; + final Function() addSelectedAssessment; + + const AddAssessmentDetails( + {Key key, this.mySelectedAssessment, this.addSelectedAssessment}) + : super(key: key); + + @override + _AddAssessmentDetailsState createState() => _AddAssessmentDetailsState(); +} + +class _AddAssessmentDetailsState extends State { + // MasterKeyModel _selectedDiagnosisCondition; + // MasterKeyModel _selectedDiagnosisType; + TextEditingController remarkController = TextEditingController(); + TextEditingController appointmentIdController = TextEditingController( + text: "234567"); + + @override + Widget build(BuildContext context) { + remarkController.text = widget.mySelectedAssessment.remark??""; + final screenSize = MediaQuery + .of(context) + .size; + InputDecoration textFieldSelectorDecoration(String hintText, + String selectedText, bool isDropDown) { + //TODO: make one Input InputDecoration for all + return InputDecoration( + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), + borderRadius: BorderRadius.circular(8), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), + borderRadius: BorderRadius.circular(8), + ), + disabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), + borderRadius: BorderRadius.circular(8), + ), + hintText: selectedText != null ? selectedText : hintText, + suffixIcon: isDropDown ? Icon(Icons.arrow_drop_down) : null, + hintStyle: TextStyle( + fontSize: 14, + color: Colors.grey.shade600, + ), + ); + } + return FractionallySizedBox( + heightFactor: 0.75, + child: BaseView( + onModelReady: (model) async { + if (model.listOfDiagnosisCondition.length == 0) { + await model.getMasterLookup(MasterKeysService.DiagnosisCondition); + } + if (model.listOfDiagnosisType.length == 0) { + await model.getMasterLookup(MasterKeysService.DiagnosisType); + } + // if (model.listOfICD10.length == 0) { + // await model.getMasterLookup(MasterKeysService.ICD10); + // } + }, + builder: (_, model, w) => + AppScaffold( + baseViewModel: model, + isShowAppBar: false, + body: SingleChildScrollView( + child: Center( + child: FractionallySizedBox( + widthFactor: 0.9, + child: Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 16, + ), + AppText( + "Add Assessment Details".toUpperCase(), + fontWeight: FontWeight.bold, + fontSize: 16, + ), + SizedBox( + height: 16, + ), + Container( + margin: EdgeInsets.only( + left: 0, right: 0, top: 15), + child: TextFields( + hintText: "Appointment Number", + fontSize: 13.5, + // hintColor: Colors.black, + fontWeight: FontWeight.w600, + readOnly: true, + controller: appointmentIdController, + validator: (value) { + if (value == null) + return TranslationBase + .of(context) + .emptyMessage; + else + return null; + }), + ), + SizedBox( + height: 10, + ), + Container( + height: screenSize.height * 0.070, + child: InkWell( + onTap: model.listOfDiagnosisType != null + ? () { + MasterKeyDailog dialog = MasterKeyDailog( + isICD: true, + list: model.listOfDiagnosisType, + selectedValue: widget + .mySelectedAssessment + .selectedICD, + okText: TranslationBase + .of(context) + .ok, + okFunction: + (MasterKeyModel selectedValue) { + setState(() { + widget.mySelectedAssessment + .selectedICD = + selectedValue; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: TextField( + decoration: textFieldSelectorDecoration( + "Name / ICD", + widget.mySelectedAssessment + .selectedICD != + null + ? widget.mySelectedAssessment + .selectedICD.nameEn + : null, + true), + enabled: false, + ), + ), + ), + SizedBox( + height: 10, + ), + Container( + height: screenSize.height * 0.070, + child: InkWell( + onTap: model.listOfDiagnosisCondition != + null + ? () { + MasterKeyDailog dialog = MasterKeyDailog( + list: model.listOfDiagnosisCondition, + okText: TranslationBase + .of(context) + .ok, + okFunction: ( + MasterKeyModel selectedValue) { + setState(() { + widget.mySelectedAssessment + .selectedDiagnosisCondition = + selectedValue; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: TextField( + decoration: textFieldSelectorDecoration( + "Condition", + widget.mySelectedAssessment + .selectedDiagnosisCondition != null + ? widget.mySelectedAssessment + .selectedDiagnosisCondition + .nameEn + : null, + true), + enabled: false, + ), + ), + ), + SizedBox( + height: 10, + ), + Container( + height: screenSize.height * 0.070, + child: InkWell( + onTap: model.listOfDiagnosisType != null + ? () { + MasterKeyDailog dialog = MasterKeyDailog( + list: model.listOfDiagnosisType, + okText: TranslationBase + .of(context) + .ok, + okFunction: ( + MasterKeyModel selectedValue) { + setState(() { + // _selectedDiagnosisType = + // selectedValue; + widget.mySelectedAssessment + .selectedDiagnosisType = + selectedValue; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: TextField( + decoration: textFieldSelectorDecoration( + "Type", + widget.mySelectedAssessment + .selectedDiagnosisType != null + ? widget.mySelectedAssessment + .selectedDiagnosisType.nameEn + : null, + true), + enabled: false, + ), + ), + ), + SizedBox( + height: 10, + ), + Container( + margin: EdgeInsets.only( + left: 0, right: 0, top: 15), + child: TextFields( + hintText: "Remarks", + fontSize: 13.5, + // hintColor: Colors.black, + fontWeight: FontWeight.w600, + maxLines: 18, + minLines: 5, + controller: remarkController, + validator: (value) { + if (value == null) + return TranslationBase + .of(context) + .emptyMessage; + else + return null; + }), + ), + SizedBox( + height: 10, + ), + AppButton( + title: "Add".toUpperCase(), + onPressed: () { + setState(() { + widget.mySelectedAssessment.remark = + remarkController.text; + widget.mySelectedAssessment + .appointmentId = int.parse( + appointmentIdController.text); + + widget.addSelectedAssessment(); + }); + }, + ), + ])), + ), + ), + ))), + ); + } +} + + +class PatchAssessmentReqModel { + int patientMRN; + int appointmentNo; + int episodeId; + String icdcode10Id; + String prevIcdCode10ID; + int conditionId; + int diagnosisTypeId; + bool complexDiagnosis; + String remarks; + + PatchAssessmentReqModel( + {this.patientMRN, + this.appointmentNo, + this.episodeId, + this.icdcode10Id, + this.prevIcdCode10ID, + this.conditionId, + this.diagnosisTypeId, + this.complexDiagnosis, + this.remarks}); + + PatchAssessmentReqModel.fromJson(Map json) { + patientMRN = json['patientMRN']; + appointmentNo = json['appointmentNo']; + episodeId = json['episodeId']; + icdcode10Id = json['icdcode10Id']; + prevIcdCode10ID = json['prevIcdCode10ID']; + conditionId = json['conditionId']; + diagnosisTypeId = json['diagnosisTypeId']; + complexDiagnosis = json['complexDiagnosis']; + remarks = json['remarks']; + } + + Map toJson() { + final Map data = new Map(); + data['patientMRN'] = this.patientMRN; + data['appointmentNo'] = this.appointmentNo; + data['episodeId'] = this.episodeId; + data['icdcode10Id'] = this.icdcode10Id; + data['prevIcdCode10ID'] = this.prevIcdCode10ID; + data['conditionId'] = this.conditionId; + data['diagnosisTypeId'] = this.diagnosisTypeId; + data['complexDiagnosis'] = this.complexDiagnosis; + data['remarks'] = this.remarks; + return data; + } +} + + diff --git a/lib/widgets/patients/profile/soap_update/update_objective_page.dart b/lib/widgets/patients/profile/soap_update/update_objective_page.dart new file mode 100644 index 00000000..a073c578 --- /dev/null +++ b/lib/widgets/patients/profile/soap_update/update_objective_page.dart @@ -0,0 +1,580 @@ +import 'package:doctor_app_flutter/client/base_app_client.dart'; +import 'package:doctor_app_flutter/config/config.dart'; +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/viewModel/SOAP_view_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/my_selected_examination.dart'; +import 'package:doctor_app_flutter/models/SOAP/post_physical_exam_request_model.dart'; +import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/Text.dart'; +import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/divider_with_spaces_around.dart'; +import 'package:doctor_app_flutter/widgets/shared/expandable-widget-header-body.dart'; +import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; +import 'package:eva_icons_flutter/eva_icons_flutter.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +class UpdateObjectivePage extends StatefulWidget { + final Function changePageViewIndex; + final List mySelectedExamination; + final PatiantInformtion patientInfo; + UpdateObjectivePage( + {Key key, this.changePageViewIndex, this.mySelectedExamination, this.patientInfo}); + + @override + _UpdateObjectivePageState createState() => _UpdateObjectivePageState(); +} + +class _UpdateObjectivePageState extends State { + bool isSysExaminationExpand = false; + TextEditingController remarksController = TextEditingController(); + + BoxDecoration containerBorderDecoration( + Color containerColor, Color borderColor) { + return BoxDecoration( + color: containerColor, + shape: BoxShape.rectangle, + borderRadius: BorderRadius.all(Radius.circular(6)), + border: Border.fromBorderSide(BorderSide( + color: borderColor, + width: 0.5, + )), + ); + } + @override + Widget build(BuildContext context) { + final screenSize = MediaQuery.of(context).size; + + return BaseView( + // onModelReady: (model) => model.getMasterLookup(MasterKeysService.Allergies), + builder: (_, model, w) => AppScaffold( + isShowAppBar: false, + body: SingleChildScrollView( + physics: ScrollPhysics(), + child: Center( + child: FractionallySizedBox( + widthFactor: 0.9, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + SizedBox( + height: 30, + ), + HeaderBodyExpandableNotifier( + headerWidget: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Texts('Physical/System Examination', + variant: + isSysExaminationExpand ? "bodyText" : '', + bold: isSysExaminationExpand ? true : false, + color: Colors.black), + Icon( + FontAwesomeIcons.asterisk, + color: AppGlobal.appPrimaryColor, + size: 12, + ) + ], + ), + InkWell( + onTap: () { + setState(() { + isSysExaminationExpand = + !isSysExaminationExpand; + }); + }, + child: Icon(isSysExaminationExpand + ? EvaIcons.minus + : EvaIcons.plus)) + ], + ), + bodyWidget: Column(children: [ + SizedBox( + height: 20, + ), + Column( + children: [ + Container( + margin: + EdgeInsets.only(left: 10, right: 10, top: 15), + child: TextFields( + hintText: "Add Examination", + fontSize: 13.5, + onTapTextFields: () { + openExaminationList(context); + }, + readOnly: true, + // hintColor: Colors.black, + suffixIcon: EvaIcons.plusCircleOutline, + suffixIconColor: AppGlobal.appPrimaryColor, + fontWeight: FontWeight.w600, + // controller: messageController, + validator: (value) { + if (value == null) + return TranslationBase.of(context) + .emptyMessage; + else + return null; + }), + ), + SizedBox( + height: 20, + ), + Column( + children: + widget.mySelectedExamination.map((examination) { + return Container( + margin: EdgeInsets.only( + left: 15, right: 15, top: 15), + child: Column(children: [ + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Texts( + examination + .selectedExamination.nameEn + .toUpperCase(), + variant: "bodyText", + bold: true, + color: Colors.black) + ], + ), + SizedBox( + height: 8, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + InkWell( + child: Center( + child: Container( + height: + screenSize.height * + 0.070, + decoration: + containerBorderDecoration( + examination + .isNormal + ? Color( + 0xFF515A5D) + : Colors + .white, + Colors.grey), + child: Center( + child: Padding( + padding: + const EdgeInsets + .all(8.0), + child: Text( + "Normal", + style: TextStyle( + fontSize: 12, + color: + examination + .isNormal + ? Colors.white + : Colors + .black, + //Colors.black, + fontWeight: + FontWeight + .bold, + ), + ), + ), + )), + ), + onTap: () { + setState(() { + examination.isAbnormal = + !examination.isAbnormal; + examination.isNormal = + !examination.isNormal; + }); + }), + SizedBox( + width: 12, + ), + InkWell( + child: Center( + child: Container( + height: + screenSize.height * + 0.070, + decoration: + containerBorderDecoration( + examination + .isAbnormal + ? Color( + 0xFF515A5D) + : Colors + .white, + Colors.black), + child: Center( + child: Padding( + padding: + const EdgeInsets + .all(8.0), + child: Text( + "Abnormal", + style: TextStyle( + fontSize: 12, + color: + examination + .isAbnormal + ? Colors.white + : Colors + .black, + //Colors.black, + fontWeight: + FontWeight + .bold, + ), + ), + ), + )), + ), + onTap: () { + setState(() { + examination.isAbnormal = + !examination.isAbnormal; + examination.isNormal = + !examination.isNormal; + }); + }), + ], + ), + InkWell( + + child: Icon( + FontAwesomeIcons.trash, + color: Colors.grey, + size: 20, + ), + onTap: () => removeExamination( + examination.selectedExamination), + ) + ], + ), + SizedBox( + height: 20, + ), + Container( + margin: EdgeInsets.only( + left: 10, right: 10, top: 15), + child: TextFields( + hintText: "Remarks", + fontSize: 13.5, + // hintColor: Colors.black, + fontWeight: FontWeight.w600, + maxLines: 25, + minLines: 13, + controller: remarksController, + validator: (value) { + if (value == null) + return TranslationBase.of(context) + .emptyMessage; + else + return null; + }), + ), + SizedBox( + height: 20, + ), + ])); + }).toList(), + ) + ], + ) + ]), + isExpand: isSysExaminationExpand, + ), + DividerWithSpacesAround(height: 30,), + AppButton( + title: TranslationBase.of(context).next, + loading: model.state == ViewState.BusyLocal, + onPressed: () async { + await submitUpdateObjectivePage(model); + }, + ), + SizedBox( + height: 30, + ), + ], + ), + ), + ), + ))); + } + + submitUpdateObjectivePage(SOAPViewModel model) async { + if(widget.mySelectedExamination.isNotEmpty){ + PostPhysicalExamRequestModel postPhysicalExamRequestModel = new PostPhysicalExamRequestModel(); + widget.mySelectedExamination.forEach((exam) { + if (postPhysicalExamRequestModel.listHisProgNotePhysicalExaminationVM == + null) + postPhysicalExamRequestModel.listHisProgNotePhysicalExaminationVM = []; + + postPhysicalExamRequestModel.listHisProgNotePhysicalExaminationVM.add( + ListHisProgNotePhysicalExaminationVM( + patientMRN: widget.patientInfo.patientMRN, + episodeId: widget.patientInfo.episodeNo, + appointmentNo: widget.patientInfo.appointmentNo, + remarks: exam.remark ?? '', + createdBy: 4709, + createdOn: DateTime.now().toIso8601String(), + editedBy: 4709, + editedOn: DateTime.now().toIso8601String(), + examId: exam.selectedExamination.id, + examType: exam.selectedExamination.typeId, + isAbnormal: exam.isAbnormal, + isNormal: exam.isNormal, + masterDescription: exam.selectedExamination, + notExamined: false + + )); + }); + + await model.patchPhysicalExam(postPhysicalExamRequestModel); + + if (model.state == ViewState.ErrorLocal) { + helpers.showErrorToast(model.error); + } else { + widget.changePageViewIndex(2); + } + } else { + helpers.showErrorToast('Please add required field correctly'); + } + + widget.changePageViewIndex(2); + } + + removeExamination(MasterKeyModel masterKey) { + Iterable history = widget.mySelectedExamination + .where( + (element) => + masterKey.id == element.selectedExamination.id && + masterKey.typeId == element.selectedExamination.typeId); + + if (history.length > 0) + setState(() { + widget.mySelectedExamination.remove(history.first); + }); + } + + openExaminationList(BuildContext context) { + final screenSize = MediaQuery + .of(context) + .size; + InputDecoration textFieldSelectorDecoration(String hintText, + String selectedText, bool isDropDown) { + return InputDecoration( + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), + borderRadius: BorderRadius.circular(8), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), + borderRadius: BorderRadius.circular(8), + ), + disabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), + borderRadius: BorderRadius.circular(8), + ), + hintText: selectedText != null ? selectedText : hintText, + suffixIcon: isDropDown ? Icon(Icons.arrow_drop_down) : null, + hintStyle: TextStyle( + fontSize: 14, + color: Colors.grey.shade600, + ), + ); + } + + showModalBottomSheet( + backgroundColor: Colors.white, + isScrollControlled: true, + context: context, + builder: (context) { + return AddExaminationDailog( + mySelectedExamination: widget.mySelectedExamination, + addSelectedExamination: () { + setState(() { + Navigator.of(context).pop(); + }); + }, + removeExamination: (masterKey) => removeExamination(masterKey),); + }); + } +} + +class AddExaminationDailog extends StatefulWidget { + final List mySelectedExamination; + final Function addSelectedExamination; + final Function (MasterKeyModel) removeExamination; + + const AddExaminationDailog( + {Key key, this.mySelectedExamination, this.addSelectedExamination, this.removeExamination}) + : super(key: key); + + @override + _AddExaminationDailogState createState() => _AddExaminationDailogState(); +} + +class _AddExaminationDailogState extends State { + @override + Widget build(BuildContext context) { + return FractionallySizedBox( + heightFactor: 0.7, + child: BaseView( + onModelReady: (model) async { + if (model.physicalExaminationList.length == 0) { + await model.getMasterLookup( + MasterKeysService.PhysicalExamination); + } + }, + builder: (_, model, w) => + AppScaffold( + // baseViewModel: model, + isShowAppBar: false, + body: Center( + child: Container( + child: FractionallySizedBox( + widthFactor: 0.9, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 16, + ), + AppText( + "Examinations", + fontWeight: FontWeight.bold, + fontSize: 16, + ), + SizedBox( + height: 16, + ), + NetworkBaseView( + baseViewModel: model, + child: Container( + height: + MediaQuery + .of(context) + .size + .height * 0.5, + child: Center( + child: Container( + margin: EdgeInsets.only(top: 15), + decoration: BoxDecoration( + borderRadius: BorderRadius + .circular(12), + color: Colors.white), + child: ListView( + children: [ + Column( + children: model + .physicalExaminationList + .map((examinationInfo) { + return Column( + children: [ + Row( + children: [ + Checkbox( + value: isServiceSelected( + examinationInfo), + activeColor: + Colors.red[800], + onChanged: + ( + bool newValue) { + setState(() { + if (isServiceSelected( + examinationInfo + )) { + widget + .removeExamination( + examinationInfo + ); + } + else { + MySelectedExamination mySelectedExamination = new MySelectedExamination( + selectedExamination: examinationInfo + ); + widget + .mySelectedExamination + .add( + mySelectedExamination); + } + }); + }), + Expanded( + child: Padding( + padding: + const EdgeInsets + .symmetric( + horizontal: 10, + vertical: 0), + child: Texts( + examinationInfo + .nameEn, + variant: "bodyText", + bold: true, + color: + Colors.black), + ), + ), + ], + ), + DividerWithSpacesAround(), + ], + ); + }).toList(), + ), + ], + ), + )), + ), + ), + SizedBox( + height: 10, + ), + if (model.state == ViewState.Idle) + AppButton( + title: "Add SELECTED Examinations" + .toUpperCase(), + onPressed: () { + widget.addSelectedExamination(); + }, + ), + ]), + ))), + )), + ); + } + + isServiceSelected(MasterKeyModel masterKey) { + Iterable exam = + widget + .mySelectedExamination + .where((element) => + masterKey.id == element.selectedExamination.id && + masterKey.typeId == element.selectedExamination.typeId); + if (exam.length > 0) { + return true; + } + return false; + } +} diff --git a/lib/widgets/patients/profile/soap_update/update_plan_page.dart b/lib/widgets/patients/profile/soap_update/update_plan_page.dart new file mode 100644 index 00000000..a6ce8fad --- /dev/null +++ b/lib/widgets/patients/profile/soap_update/update_plan_page.dart @@ -0,0 +1,347 @@ +import 'package:doctor_app_flutter/client/base_app_client.dart'; +import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/core/enum/viewstate.dart'; +import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/post_progress_note_request_model.dart'; +import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/Text.dart'; +import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/divider_with_spaces_around.dart'; +import 'package:doctor_app_flutter/widgets/shared/expandable-widget-header-body.dart'; +import 'package:eva_icons_flutter/eva_icons_flutter.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +class UpdatePlanPage extends StatefulWidget { + final Function changePageViewIndex; + final PatiantInformtion patientInfo; + + UpdatePlanPage({Key key, this.changePageViewIndex, this.patientInfo}); + + @override + _UpdatePlanPageState createState() => _UpdatePlanPageState(); +} + +class _UpdatePlanPageState extends State { + bool isProgressNoteExpand = false; + + List progressNoteList; + + TextEditingController progressNoteController = + TextEditingController(text: null); + + BoxDecoration containerBorderDecoration( + Color containerColor, Color borderColor) { + return BoxDecoration( + color: containerColor, + shape: BoxShape.rectangle, + borderRadius: BorderRadius.all(Radius.circular(6)), + border: Border.fromBorderSide(BorderSide( + color: borderColor, + width: 0.5, + )), + ); + } + + @override + Widget build(BuildContext context) { + final screenSize = MediaQuery.of(context).size; + + return BaseView( + // onModelReady: (model) => model.getMasterLookup(MasterKeysService.Allergies), + builder: (_, model, w) => AppScaffold( + isShowAppBar: false, + body: SingleChildScrollView( + physics: ScrollPhysics(), + child: Center( + child: FractionallySizedBox( + widthFactor: 0.9, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + SizedBox( + height: 30, + ), + HeaderBodyExpandableNotifier( + headerWidget: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Texts('Progress Note', + variant: + isProgressNoteExpand ? "bodyText" : '', + bold: isProgressNoteExpand ? true : false, + color: Colors.black), + Icon( + FontAwesomeIcons.asterisk, + color: AppGlobal.appPrimaryColor, + size: 12, + ) + ], + ), + InkWell( + onTap: () { + setState(() { + isProgressNoteExpand = + !isProgressNoteExpand; + }); + }, + child: Icon(isProgressNoteExpand + ? EvaIcons.minus + : EvaIcons.plus)) + ], + ), + bodyWidget: Column(children: [ + SizedBox( + height: 20, + ), + Column( + children: [ + Container( + margin: + EdgeInsets.only(left: 10, right: 10, top: 15), + child: TextFields( + hintText: "Add Progress Note", + fontSize: 13.5, + onTapTextFields: () { + openProgressNote(context); + }, + readOnly: true, + // hintColor: Colors.black, + suffixIcon: EvaIcons.plusCircleOutline, + suffixIconColor: AppGlobal.appPrimaryColor, + fontWeight: FontWeight.w600, + // controller: messageController, + validator: (value) { + if (value == null) + return TranslationBase + .of(context) + .emptyMessage; + else + return null; + }), + ), + SizedBox( + height: 20, + ), + if (progressNoteController.text.isNotEmpty) + Container( + margin: + EdgeInsets.only(left: 5, right: 5, top: 15), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + AppText( + "12".toUpperCase(), + fontWeight: FontWeight.bold, + fontSize: 16, + ), + AppText( + "DEC".toUpperCase(), + fontSize: 10, + color: Colors.grey, + ), + ], + ) + ], + ), + Column( + crossAxisAlignment: CrossAxisAlignment + .start, + children: [ + + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + SizedBox( + height: 6, + ), + Padding( + padding: const EdgeInsets.all(0.0), + child: Container( + width: MediaQuery + .of(context) + .size + .width * 0.6, + child: AppText( + progressNoteController.text, + fontSize: 10, + + color: Colors.grey, + ), + ), + ), + ], + ), SizedBox( + height: 8, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + AppText( + "Created By : ", + fontWeight: FontWeight.bold, + fontSize: 16, + ), + AppText( + "Anas Abdullah on 12 De", + fontSize: 10, + color: Colors.grey, + ), + ], + ), + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + AppText( + "Edited By : ", + fontWeight: FontWeight.bold, + fontSize: 16, + ), + AppText( + "Rahim on 13 Dec", + fontSize: 10, + color: Colors.grey, + ), + ], + ), + + ], + ), + Column( + children: [ + InkWell( + onTap: () { + openProgressNote(context); + }, + child: Icon(EvaIcons.edit2Outline), + ) + ], + ), + ], + ), + ) + ], + ) + ]), + isExpand: isProgressNoteExpand, + ), + DividerWithSpacesAround(height: 30,), + AppButton( + title: TranslationBase + .of(context) + .next, + loading: model.state == ViewState.BusyLocal, + onPressed: () { + + submitPlan(model); + // widget.changePageViewIndex(2); + }, + ), + SizedBox( + height: 30, + ), + ], + ), + ), + ), + ),),); + } + + submitPlan(SOAPViewModel model) async { + if (progressNoteController.text.isNotEmpty) { + PostProgressNoteRequestModel postProgressNoteRequestModel = new PostProgressNoteRequestModel( + patientMRN: widget.patientInfo.patientMRN, + episodeId: widget.patientInfo.episodeNo, + appointmentNo: widget.patientInfo.appointmentNo, + planNote: progressNoteController.text); + + + await model.patchProgressNote(postProgressNoteRequestModel); + + if (model.state == ViewState.ErrorLocal) { + helpers.showErrorToast(model.error); + } else { + Navigator.of(context).pop(); + } + } + } + + openProgressNote(BuildContext context) { + showModalBottomSheet( + backgroundColor: Colors.white, + isScrollControlled: true, + context: context, + builder: (context) { + return FractionallySizedBox( + heightFactor: 0.5, + child: Container( + child: FractionallySizedBox( + widthFactor: 0.9, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 16, + ), + AppText( + "Add Progress Note", + fontWeight: FontWeight.bold, + fontSize: 16, + ), + SizedBox( + height: 10, + ), + Container( + margin: EdgeInsets.only(left: 0, right: 0, top: 15), + child: TextFields( + hintText: "Add progress note here", + fontSize: 13.5, + // hintColor: Colors.black, + fontWeight: FontWeight.w600, + maxLines: 16, + minLines: 8, + controller: progressNoteController, + validator: (value) { + if (value == null) + return TranslationBase + .of(context) + .emptyMessage; + else + return null; + }), + ),SizedBox( + height: 10, + ), + AppButton( + title: "Add".toUpperCase(), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ]), + )), + ); + }); + } +} diff --git a/lib/widgets/patients/profile/soap_update/update_soap_index.dart b/lib/widgets/patients/profile/soap_update/update_soap_index.dart new file mode 100644 index 00000000..59557145 --- /dev/null +++ b/lib/widgets/patients/profile/soap_update/update_soap_index.dart @@ -0,0 +1,133 @@ +import 'package:doctor_app_flutter/core/viewModel/doctor_replay_view_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/my_selected_allergy.dart'; +import 'package:doctor_app_flutter/models/SOAP/my_selected_assement.dart'; +import 'package:doctor_app_flutter/models/SOAP/my_selected_examination.dart'; +import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/SOAP/steps_widget.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/patient-page-header-widget.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/soap_update/update_assessment_page.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/soap_update/update_objective_page.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/soap_update/update_plan_page.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + + +class UpdateSoapIndex extends StatefulWidget { + final bool isUpdate; + + const UpdateSoapIndex({Key key, this.isUpdate}) : super(key: key); + @override + _UpdateSoapIndexState createState() => _UpdateSoapIndexState(); +} + +class _UpdateSoapIndexState extends State + with TickerProviderStateMixin { + PageController _controller; + int _currentIndex = 0; + List myAllergiesList= List(); + List myHistoryList = List(); + List mySelectedExamination = List(); + MySelectedAssessment mySelectedAssessment = new MySelectedAssessment(); + changePageViewIndex(pageIndex) { + _controller.jumpToPage(pageIndex); + } + + @override + void initState() { + // TODO: implement initState + _controller = new PageController(); + + super.initState(); + } + @override + Widget build(BuildContext context) { + final routeArgs = ModalRoute.of(context).settings.arguments as Map; + PatiantInformtion patient = routeArgs['patient']; + return BaseView( + builder: (_, model, w) => AppScaffold( + baseViewModel: model, + appBarTitle: TranslationBase.of(context).healthRecordInformation, + body: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + decoration: + BoxDecoration(boxShadow: [], color: Colors.white), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + PatientPageHeaderWidget(patient), + FractionallySizedBox( + child: SingleChildScrollView( + child: Container( + height: MediaQuery.of(context).size.height * 0.75, + child: Column( + children: [ + Container( + margin: EdgeInsets.only( + left: + MediaQuery.of(context).size.width * 0.05, + right: + MediaQuery.of(context).size.width * 0.05), + child: StepsWidget( + index: _currentIndex, + changeCurrentTab: changePageViewIndex, + ), + ), + Expanded( + child: PageView( + physics: NeverScrollableScrollPhysics(), + controller: _controller, + onPageChanged: (index) { + setState(() { + _currentIndex = index; + }); + }, + scrollDirection: Axis.horizontal, + children: [ + UpdateSubjectivePage( + changePageViewIndex: changePageViewIndex, + myAllergiesList: myAllergiesList, + myHistoryList: myHistoryList, + patientInfo: patient, + ), + UpdateObjectivePage( + changePageViewIndex: changePageViewIndex, + mySelectedExamination: + mySelectedExamination, + patientInfo: patient, + ), + UpdateAssessmentPage( + changePageViewIndex: changePageViewIndex, + mySelectedAssessment: + mySelectedAssessment, + patientInfo: patient, + ), + UpdatePlanPage( + changePageViewIndex: changePageViewIndex, + patientInfo: patient, + ) + ], + ), + ), + ], + ), + ), + ), + ) + ], + ), + ), + ], + ), + ), + ), + ); + } +} From 93bece09d72e8201ce5509dd8cdf62926d606d9b Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Thu, 31 Dec 2020 16:28:15 +0200 Subject: [PATCH 04/15] add search in SOAP --- .../profile/SOAP/assessment_page.dart | 62 ++-- .../patients/profile/SOAP/objective_page.dart | 112 ++---- .../SOAP/subjective/add_allergies_widget.dart | 56 ++- .../SOAP/subjective/add_history_widget.dart | 326 +++--------------- .../master_key_checkbox_search_widget.dart | 149 ++++++++ pubspec.lock | 7 + pubspec.yaml | 3 + 7 files changed, 292 insertions(+), 423 deletions(-) create mode 100644 lib/widgets/shared/master_key_checkbox_search_widget.dart diff --git a/lib/widgets/patients/profile/SOAP/assessment_page.dart b/lib/widgets/patients/profile/SOAP/assessment_page.dart index 22778913..eadc327b 100644 --- a/lib/widgets/patients/profile/SOAP/assessment_page.dart +++ b/lib/widgets/patients/profile/SOAP/assessment_page.dart @@ -1,8 +1,10 @@ +import 'package:autocomplete_textfield/autocomplete_textfield.dart'; import 'package:doctor_app_flutter/client/base_app_client.dart'; import 'package:doctor_app_flutter/config/config.dart'; 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/viewModel/SOAP_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; import 'package:doctor_app_flutter/models/SOAP/my_selected_assement.dart'; import 'package:doctor_app_flutter/models/SOAP/post_assessment_request_model.dart'; @@ -19,6 +21,7 @@ import 'package:doctor_app_flutter/widgets/shared/expandable-widget-header-body. import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; class AssessmentPage extends StatefulWidget { final Function changePageViewIndex; @@ -375,15 +378,17 @@ class _AddAssessmentDetailsState extends State { TextEditingController remarkController = TextEditingController(); TextEditingController appointmentIdController = TextEditingController( text: "234567"); + GlobalKey key = new GlobalKey>(); @override Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); remarkController.text = widget.mySelectedAssessment.remark??""; final screenSize = MediaQuery .of(context) .size; InputDecoration textFieldSelectorDecoration(String hintText, - String selectedText, bool isDropDown) { + String selectedText, bool isDropDown,{IconData icon}) { //TODO: make one Input InputDecoration for all return InputDecoration( focusedBorder: OutlineInputBorder( @@ -399,7 +404,7 @@ class _AddAssessmentDetailsState extends State { borderRadius: BorderRadius.circular(8), ), hintText: selectedText != null ? selectedText : hintText, - suffixIcon: isDropDown ? Icon(Icons.arrow_drop_down) : null, + suffixIcon: isDropDown ? Icon(icon??Icons.arrow_drop_down) : null, hintStyle: TextStyle( fontSize: 14, color: Colors.grey.shade600, @@ -470,43 +475,28 @@ class _AddAssessmentDetailsState extends State { child: InkWell( onTap: model.listOfICD10 != null ? () { - MasterKeyDailog dialog = MasterKeyDailog( - isICD: true, - list: model.listOfICD10, - selectedValue: widget - .mySelectedAssessment - .selectedICD, - okText: TranslationBase - .of(context) - .ok, - okFunction: - (MasterKeyModel selectedValue) { - setState(() { - widget.mySelectedAssessment - .selectedICD = - selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); + setState(() { + widget.mySelectedAssessment.selectedICD = null; + }); } : null, - child: TextField( + child:widget.mySelectedAssessment.selectedICD == null ? AutoCompleteTextField( + decoration: textFieldSelectorDecoration("Name or ICD", widget.mySelectedAssessment.selectedICD != null ? widget.mySelectedAssessment.selectedICD.nameEn : null, true,icon: EvaIcons.search), + itemSubmitted: (item) => setState(() => widget.mySelectedAssessment.selectedICD = item), + key: key, + suggestions: model.listOfICD10, + itemBuilder: (context, suggestion) => new Padding( + child:Texts( suggestion.description +" / "+ suggestion.code.toString()), + padding: EdgeInsets.all(8.0)), + itemSorter: (a, b) => 1, + itemFilter: (suggestion, input) => + suggestion.description.toLowerCase().startsWith(input.toLowerCase()) ||suggestion.description.toLowerCase().startsWith(input.toLowerCase()) + ||suggestion.code.toLowerCase().startsWith(input.toLowerCase()) + , + ): TextField( decoration: textFieldSelectorDecoration( - "Name / ICD", - widget.mySelectedAssessment - .selectedICD != - null - ? widget.mySelectedAssessment - .selectedICD.nameEn - : null, - true), + widget.mySelectedAssessment.selectedICD != null ? widget.mySelectedAssessment.selectedICD.code :"Name or ICD", + widget.mySelectedAssessment.selectedICD != null ? widget.mySelectedAssessment.selectedICD.nameEn : null, true,icon: EvaIcons.search), enabled: false, ), ), diff --git a/lib/widgets/patients/profile/SOAP/objective_page.dart b/lib/widgets/patients/profile/SOAP/objective_page.dart index 8d12e1c9..a4d94279 100644 --- a/lib/widgets/patients/profile/SOAP/objective_page.dart +++ b/lib/widgets/patients/profile/SOAP/objective_page.dart @@ -8,6 +8,7 @@ import 'package:doctor_app_flutter/models/SOAP/my_selected_examination.dart'; import 'package:doctor_app_flutter/models/SOAP/post_physical_exam_request_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/master_key_checkbox_search_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/Text.dart'; import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart'; @@ -469,98 +470,35 @@ class _AddExaminationDailogState extends State { SizedBox( height: 16, ), + NetworkBaseView( baseViewModel: model, - child: Container( - height: - MediaQuery - .of(context) - .size - .height * 0.5, - child: Center( - child: Container( - margin: EdgeInsets.only(top: 15), - decoration: BoxDecoration( - borderRadius: BorderRadius - .circular(12), - color: Colors.white), - child: ListView( - children: [ - Column( - children: model - .physicalExaminationList - .map((examinationInfo) { - return Column( - children: [ - Row( - children: [ - Checkbox( - value: isServiceSelected( - examinationInfo), - activeColor: - Colors.red[800], - onChanged: - ( - bool newValue) { - setState(() { - if (isServiceSelected( - examinationInfo - )) { - widget - .removeExamination( - examinationInfo - ); - } - else { - MySelectedExamination mySelectedExamination = new MySelectedExamination( - selectedExamination: examinationInfo - ); - widget - .mySelectedExamination - .add( - mySelectedExamination); - } - }); - }), - Expanded( - child: Padding( - padding: - const EdgeInsets - .symmetric( - horizontal: 10, - vertical: 0), - child: Texts( - examinationInfo - .nameEn, - variant: "bodyText", - bold: true, - color: - Colors.black), - ), - ), - ], - ), - DividerWithSpacesAround(), - ], - ); - }).toList(), - ), - ], - ), - )), - ), - ), - SizedBox( - height: 10, - ), - if (model.state == ViewState.Idle) - AppButton( - title: "Add SELECTED Examinations" - .toUpperCase(), - onPressed: () { + child: MasterKeyCheckboxSearchWidget( + model: model, + masterList: model.physicalExaminationList, + removeHistory: (history){ + setState(() { + widget.removeExamination(history); + }); + }, + addHistory: (history){ + setState(() { + MySelectedExamination mySelectedExamination = new MySelectedExamination( + selectedExamination: history + ); + widget + .mySelectedExamination + .add( + mySelectedExamination); + }); + }, + addSelectedHistories: (){ widget.addSelectedExamination(); }, + isServiceSelected: (master) =>isServiceSelected(master), ), + ), + ]), ))), )), diff --git a/lib/widgets/patients/profile/SOAP/subjective/add_allergies_widget.dart b/lib/widgets/patients/profile/SOAP/subjective/add_allergies_widget.dart index 7f764a0d..fd3cb917 100644 --- a/lib/widgets/patients/profile/SOAP/subjective/add_allergies_widget.dart +++ b/lib/widgets/patients/profile/SOAP/subjective/add_allergies_widget.dart @@ -1,6 +1,8 @@ +import 'package:autocomplete_textfield/autocomplete_textfield.dart'; import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; import 'package:doctor_app_flutter/models/SOAP/my_selected_allergy.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; @@ -14,6 +16,7 @@ import 'package:doctor_app_flutter/widgets/shared/dialogs/master_key_dailog.dart import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; class AddAllergiesWidget extends StatefulWidget { final List myAllergiesList; @@ -43,11 +46,9 @@ class _AddAllergiesWidgetState extends State { openAllergiesList(context); }, readOnly: true, - // hintColor: Colors.black, suffixIcon: EvaIcons.plusCircleOutline, suffixIconColor: AppGlobal.appPrimaryColor, fontWeight: FontWeight.w600, - // controller: messageController, validator: (value) { if (value == null) return TranslationBase @@ -147,7 +148,7 @@ class _AddAllergiesState extends State { InputDecoration textFieldSelectorDecoration(String hintText, - String selectedText, bool isDropDown) { + String selectedText, bool isDropDown,{IconData icon}) { return InputDecoration( focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), @@ -162,16 +163,19 @@ class _AddAllergiesState extends State { borderRadius: BorderRadius.circular(8), ), hintText: selectedText != null ? selectedText : hintText, - suffixIcon: isDropDown ? Icon(Icons.arrow_drop_down) : null, + suffixIcon: isDropDown ? Icon(icon?? Icons.arrow_drop_down) : null, hintStyle: TextStyle( fontSize: 14, color: Colors.grey.shade600, ), ); } + bool _isShowSearch = false; + GlobalKey key = new GlobalKey>(); @override Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); final screenSize = MediaQuery .of(context) .size; @@ -209,38 +213,30 @@ class _AddAllergiesState extends State { SizedBox( height: 16, ), + Container( height: screenSize.height * 0.070, child: InkWell( onTap: model.listOfAllergies != null ? () { - MasterKeyDailog dialog = MasterKeyDailog( - list: model.listOfAllergies, - okText: TranslationBase - .of(context) - .ok, - okFunction: (MasterKeyModel selectedValue) { - setState(() { - _selectedAllergy = selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); - } + setState(() { + _selectedAllergy = null; + }); + } : null, - child: TextField( - decoration: textFieldSelectorDecoration( - "Select Allergy", - _selectedAllergy != null - ? _selectedAllergy.nameEn - : null, - true), + child: _selectedAllergy==null? AutoCompleteTextField( + decoration: textFieldSelectorDecoration("Select Allergy", _selectedAllergy != null ? _selectedAllergy.nameEn : null, true,icon: EvaIcons.search), + itemSubmitted: (item) => setState(() => _selectedAllergy = item), + key: key, + suggestions: model.listOfAllergies, + itemBuilder: (context, suggestion) => new Padding( + child:Texts( projectViewModel.isArabic? suggestion.nameAr: suggestion.nameEn), + padding: EdgeInsets.all(8.0)), + itemSorter: (a, b) => 1, + itemFilter: (suggestion, input) => + suggestion.nameAr.toLowerCase().startsWith(input.toLowerCase()) ||suggestion.nameEn.toLowerCase().startsWith(input.toLowerCase()), + ):TextField( + decoration: textFieldSelectorDecoration("Select Allergy", _selectedAllergy != null ? _selectedAllergy.nameEn : null, true,icon: EvaIcons.search), enabled: false, ), ), diff --git a/lib/widgets/patients/profile/SOAP/subjective/add_history_widget.dart b/lib/widgets/patients/profile/SOAP/subjective/add_history_widget.dart index 1907453d..6e7bbe00 100644 --- a/lib/widgets/patients/profile/SOAP/subjective/add_history_widget.dart +++ b/lib/widgets/patients/profile/SOAP/subjective/add_history_widget.dart @@ -16,6 +16,8 @@ import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:hexcolor/hexcolor.dart'; +import '../../../../shared/master_key_checkbox_search_widget.dart'; + class AddHistoryWidget extends StatefulWidget { final List myHistoryList; @@ -280,273 +282,59 @@ class _AddHistoryDialogState extends State { }, scrollDirection: Axis.horizontal, children: [ - Container( - child: Column( - children: [ - NetworkBaseView( - baseViewModel: model, - child: Container( - height: - MediaQuery.of(context).size.height * 0.5, - child: Center( - child: Container( - margin: EdgeInsets.only(top: 15), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - color: Colors.white), - child: ListView( - children: [ - Column( - children: model.historyFamilyList - .map((historyInfo) { - return Column( - children: [ - Row( - children: [ - Checkbox( - value: isServiceSelected( - historyInfo), - activeColor: - Colors.red[800], - onChanged: - (bool newValue) { - setState(() { - if (isServiceSelected( - historyInfo - )) { - widget - .removeHistory( - historyInfo - ); - } - else { - widget - .myHistoryList - .add( - historyInfo); - } - }); - }), - Expanded( - child: Padding( - padding: - const EdgeInsets - .symmetric( - horizontal: 10, - vertical: 0), - child: Texts( - historyInfo.nameEn, - variant: "bodyText", - bold: true, - color: - Colors.black), - ), - ), - ], - ), - DividerWithSpacesAround(), - ], - ); - }).toList(), - ), - ], - ), - )), - ), - ), - SizedBox( - height: 10, - ), - if (model.state == ViewState.Idle) - AppButton( - title: "Add SELECTED HISTORIES" - .toUpperCase(), - onPressed: () { - widget.addSelectedHistories(); - }, - ), - ], - ), + MasterKeyCheckboxSearchWidget( + model: model, + masterList: model.historyFamilyList, + removeHistory: (history){ + setState(() { + widget.removeHistory(history); + }); + }, + addHistory: (history){ + setState(() { + widget.myHistoryList.add(history); + }); + }, + addSelectedHistories: (){ + widget.addSelectedHistories(); + }, + isServiceSelected: (master) =>isServiceSelected(master), ), - Container( - child: Column( - children: [ - NetworkBaseView( - baseViewModel: model, - child: Container( - height: - MediaQuery.of(context).size.height * 0.5, - child: Center( - child: Container( - margin: EdgeInsets.only(top: 15), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - color: Colors.white), - child: ListView( - children: [ - Column( - children: model.mergeHistorySurgicalWithHistorySportList - .map((historyInfo) { - return Column( - children: [ - Row( - children: [ - Checkbox( - value: isServiceSelected( - historyInfo), - activeColor: - Colors.red[800], - onChanged: - ( - bool newValue) { - setState(() { - if (isServiceSelected( - historyInfo - )) { - widget - .removeHistory( - historyInfo - ); - } - else { - widget - .myHistoryList - .add( - historyInfo); - } - }); - }), - Expanded( - child: Padding( - padding: - const EdgeInsets - .symmetric( - horizontal: 10, - vertical: 0), - child: Texts( - historyInfo.nameEn, - variant: "bodyText", - bold: true, - color: - Colors.black), - ), - ), - ], - ), - DividerWithSpacesAround(), - ], - ); - }).toList(), - ), - ], - ), - )), - ), - ), - SizedBox( - height: 10, - ), - if (model.state == ViewState.Idle) - AppButton( - title: "Add SELECTED HISTORIES" - .toUpperCase(), - onPressed: () { - widget.addSelectedHistories(); - }, - ), - ], - ), + MasterKeyCheckboxSearchWidget( + model: model, + masterList: model.mergeHistorySurgicalWithHistorySportList, + removeHistory: (history){ + setState(() { + widget.removeHistory(history); + }); + }, + addHistory: (history){ + setState(() { + widget.myHistoryList.add(history); + }); + }, + addSelectedHistories: (){ + widget.addSelectedHistories(); + }, + isServiceSelected: (master) =>isServiceSelected(master), ), - Container( - child: Column( - children: [ - NetworkBaseView( - baseViewModel: model, - child: Container( - height: - MediaQuery.of(context).size.height * 0.5, - child: Center( - child: Container( - margin: EdgeInsets.only(top: 15), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - color: Colors.white), - child: ListView( - children: [ - Column( - children: model.historyMedicalList - .map((historyInfo) { - return Column( - children: [ - Row( - children: [ - Checkbox( - value: isServiceSelected( - historyInfo), - activeColor: - Colors.red[800], - onChanged: - ( - bool newValue) { - setState(() { - if (isServiceSelected( - historyInfo - )) { - widget - .removeHistory( - historyInfo - ); - } - else { - widget - .myHistoryList - .add( - historyInfo); - } - }); - }), - Expanded( - child: Padding( - padding: - const EdgeInsets - .symmetric( - horizontal: 10, - vertical: 0), - child: Texts( - historyInfo.nameEn, - variant: "bodyText", - bold: true, - color: - Colors.black), - ), - ), - ], - ), - DividerWithSpacesAround(), - ], - ); - }).toList(), - ), - ], - ), - )), - ), - ), - SizedBox( - height: 10, - ), - if (model.state == ViewState.Idle) - AppButton( - title: "Add SELECTED HISTORIES" - .toUpperCase(), - onPressed: () { - setState(() { - widget.addSelectedHistories(); - }); - }, - ), - ], - ), + MasterKeyCheckboxSearchWidget( + model: model, + masterList: model.historyMedicalList, + removeHistory: (history){ + setState(() { + widget.removeHistory(history); + }); + }, + addHistory: (history){ + setState(() { + widget.myHistoryList.add(history); + }); + }, + addSelectedHistories: (){ + widget.addSelectedHistories(); + }, + isServiceSelected: (master) =>isServiceSelected(master), ), ], ), @@ -559,12 +347,10 @@ class _AddHistoryDialogState extends State { )); } - isServiceSelected(MasterKeyModel masterKey) { + bool isServiceSelected(MasterKeyModel masterKey) { Iterable history = - widget - .myHistoryList - .where((element) => - masterKey.id == element.id && masterKey.typeId == element.typeId); + widget.myHistoryList.where((element) => masterKey.id == element.id && masterKey.typeId == element.typeId); + if (history.length > 0) { return true; } diff --git a/lib/widgets/shared/master_key_checkbox_search_widget.dart b/lib/widgets/shared/master_key_checkbox_search_widget.dart new file mode 100644 index 00000000..550d3127 --- /dev/null +++ b/lib/widgets/shared/master_key_checkbox_search_widget.dart @@ -0,0 +1,149 @@ +import 'package:doctor_app_flutter/core/enum/viewstate.dart'; +import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; +import 'package:doctor_app_flutter/widgets/shared/Text.dart'; +import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/divider_with_spaces_around.dart'; +import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; +import 'package:eva_icons_flutter/eva_icons_flutter.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class MasterKeyCheckboxSearchWidget extends StatefulWidget { + final SOAPViewModel model; + final Function addSelectedHistories; + final Function(MasterKeyModel) removeHistory; + final Function(MasterKeyModel) addHistory; + final bool Function(MasterKeyModel) isServiceSelected; + final List masterList; + + MasterKeyCheckboxSearchWidget( + {Key key, + this.model, + this.addSelectedHistories, + this.removeHistory, + this.masterList, + this.addHistory, + this.isServiceSelected}) + : super(key: key); + + @override + _MasterKeyCheckboxSearchWidgetState createState() => _MasterKeyCheckboxSearchWidgetState(); +} + +class _MasterKeyCheckboxSearchWidgetState extends State { + List items = List(); + + @override + void initState() { + items.addAll(widget.masterList); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Container( + child: Column( + children: [ + NetworkBaseView( + baseViewModel: widget.model, + child: Container( + height: MediaQuery.of(context).size.height * 0.5, + child: Center( + child: Container( + margin: EdgeInsets.only(top: 15), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + color: Colors.white), + child: ListView( + children: [ + TextFields( + hintText: 'Search history', + suffixIcon: EvaIcons.search, + onChanged: (value) { + filterSearchResults(value); + }, + ), + SizedBox(height: 15,), + Column( + children: items.map((historyInfo) { + return Column( + children: [ + Row( + children: [ + Checkbox( + value: + widget.isServiceSelected(historyInfo), + activeColor: Colors.red[800], + onChanged: (bool newValue) { + setState(() { + if (widget + .isServiceSelected(historyInfo)) { + widget.removeHistory(historyInfo); + } else { + widget.addHistory(historyInfo); + } + }); + }), + Expanded( + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 10, vertical: 0), + child: Texts(historyInfo.nameEn, + variant: "bodyText", + bold: true, + color: Colors.black), + ), + ), + ], + ), + DividerWithSpacesAround(), + ], + ); + }).toList(), + ), + ], + ), + )), + ), + ), + SizedBox( + height: 10, + ), + if (widget.model.state == ViewState.Idle) + AppButton( + title: "Add SELECTED HISTORIES".toUpperCase(), + onPressed: () { + widget.addSelectedHistories(); + }, + ), + ], + ), + ); + } + + void filterSearchResults(String query) { + List dummySearchList = List(); + dummySearchList.addAll(widget.masterList); + if (query.isNotEmpty) { + List dummyListData = List(); + dummySearchList.forEach((item) { + if (item.nameAr.toLowerCase().contains(query.toLowerCase()) || + item.nameEn.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/pubspec.lock b/pubspec.lock index 17f02b95..c6829dad 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -36,6 +36,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.5.0-nullsafety.1" + autocomplete_textfield: + dependency: "direct main" + description: + name: autocomplete_textfield + url: "https://pub.dartlang.org" + source: hosted + version: "1.7.3" barcode_scan: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index aa7499d5..e15a7182 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -60,6 +60,9 @@ dependencies: get_it: ^4.0.2 + #Autocomplete TextField + autocomplete_textfield: ^1.7.3 + #speech to text From 45edddb49ff06a5f14b2529c27557cf94962214e Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Thu, 31 Dec 2020 17:19:35 +0200 Subject: [PATCH 05/15] Add search in Procedure Screen --- .../entity_list_checkbox_search_widget.dart | 148 ++++++++ lib/screens/procedures/procedure_screen.dart | 334 ++++++++---------- 2 files changed, 294 insertions(+), 188 deletions(-) create mode 100644 lib/screens/procedures/entity_list_checkbox_search_widget.dart diff --git a/lib/screens/procedures/entity_list_checkbox_search_widget.dart b/lib/screens/procedures/entity_list_checkbox_search_widget.dart new file mode 100644 index 00000000..b9962d27 --- /dev/null +++ b/lib/screens/procedures/entity_list_checkbox_search_widget.dart @@ -0,0 +1,148 @@ +import 'package:doctor_app_flutter/core/enum/viewstate.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/widgets/shared/Text.dart'; +import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/divider_with_spaces_around.dart'; +import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; +import 'package:eva_icons_flutter/eva_icons_flutter.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class EntityListCheckboxSearchWidget extends StatefulWidget { + final ProcedureViewModel model; + final Function addSelectedHistories; + final Function(EntityList) removeHistory; + final Function(EntityList) addHistory; + final bool Function(EntityList) isEntityListSelected; + final List masterList; + + EntityListCheckboxSearchWidget( + {Key key, + this.model, + this.addSelectedHistories, + this.removeHistory, + this.masterList, + this.addHistory, + this.isEntityListSelected}) + : super(key: key); + + @override + _EntityListCheckboxSearchWidgetState createState() => _EntityListCheckboxSearchWidgetState(); +} + +class _EntityListCheckboxSearchWidgetState extends State { + List items = List(); + + @override + void initState() { + items.addAll(widget.masterList); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Container( + child: Column( + children: [ + NetworkBaseView( + baseViewModel: widget.model, + child: Container( + height: MediaQuery.of(context).size.height * 0.5, + child: Center( + child: Container( + margin: EdgeInsets.only(top: 15), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + color: Colors.white), + child: ListView( + children: [ + TextFields( + hintText: 'Search ', + suffixIcon: EvaIcons.search, + onChanged: (value) { + filterSearchResults(value); + }, + ), + SizedBox(height: 15,), + Column( + children: items.map((historyInfo) { + return Column( + children: [ + Row( + children: [ + Checkbox( + value: + widget.isEntityListSelected(historyInfo), + activeColor: Colors.red[800], + onChanged: (bool newValue) { + setState(() { + if (widget + .isEntityListSelected(historyInfo)) { + widget.removeHistory(historyInfo); + } else { + widget.addHistory(historyInfo); + } + }); + }), + Expanded( + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 10, vertical: 0), + child: Texts(historyInfo.procedureName, + variant: "bodyText", + bold: true, + color: Colors.black), + ), + ), + ], + ), + DividerWithSpacesAround(), + ], + ); + }).toList(), + ), + ], + ), + )), + ), + ), + SizedBox( + height: 10, + ), + if (widget.model.state == ViewState.Idle) + AppButton(//TODO change the button name + title: "Add ".toUpperCase(), + onPressed: () { + widget.addSelectedHistories(); + }, + ), + ], + ), + ); + } + + 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); + }); + } + } +} \ No newline at end of file diff --git a/lib/screens/procedures/procedure_screen.dart b/lib/screens/procedures/procedure_screen.dart index 2bdb7f78..97ac65dd 100644 --- a/lib/screens/procedures/procedure_screen.dart +++ b/lib/screens/procedures/procedure_screen.dart @@ -2,21 +2,27 @@ import 'package:doctor_app_flutter/client/base_app_client.dart'; import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; +import 'package:doctor_app_flutter/core/model/procedure/categories_procedure.dart'; import 'package:doctor_app_flutter/core/model/procedure/post_procedure_req_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/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/screens/procedures/entity_list_checkbox_search_widget.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/patient_profile_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/Text.dart'; +import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_text_form_field.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/divider_with_spaces_around.dart'; +import 'package:doctor_app_flutter/widgets/shared/master_key_checkbox_search_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; +import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; @@ -249,121 +255,121 @@ class _ProcedureScreenState extends State { ], ), ), - Container( - height: 120, - width: 325.0, - child: Column( - children: [ - Row( - children: [ - AppText( - 'Code #: ', - fontWeight: - FontWeight - .w700, - fontSize: 15.0, - ), - AppText( - model - .procedureList[ - 0] - .entityList[ - index] - .procedureId - .toString(), - fontSize: 13.0, - ), - SizedBox( - width: 12.0, - ), - AppText( - 'Order Type: ', - fontWeight: - FontWeight - .w700, - fontSize: 15.0, - ), - AppText( - 'Urgent', - fontSize: 13.0, - color: - Colors.red, - ), - ], - ), - Row( - children: [ - Container( - child: Expanded( - child: - AppText( - model - .procedureList[ - 0] - .entityList[ - index] - .procedureName, - fontWeight: - FontWeight - .w800, - ), + Expanded( + child: Container( + height: 120, + width: 325.0, + child: Column( + children: [ + Row( + children: [ + AppText( + 'Code #: ', + fontWeight: + FontWeight + .w700, + fontSize: 15.0, + ), + AppText( + model + .procedureList[ + 0] + .entityList[ + index] + .procedureId + .toString(), + fontSize: 13.0, ), - ) - ], - ), + SizedBox( + width: 12.0, + ), + AppText( + 'Order Type: ', + fontWeight: + FontWeight + .w700, + fontSize: 15.0, + ), + AppText( + 'Urgent', + fontSize: 13.0, + color: + Colors.red, + ), + ], + ), + Row( + children: [ + Container( + child: Expanded( + child: + AppText( + model + .procedureList[ + 0] + .entityList[ + index] + .procedureName, + fontWeight: + FontWeight + .w800, + ), + ), + ) + ], + ), - Row( - children: [ - AppText( - 'Price: ', - fontWeight: - FontWeight - .w700, - ), - Expanded( - child: AppText( - model - .procedureList[ - 0] - .entityList[ - index] - .price - .toString(), - fontSize: - 13.0), - ) - ], - ), - SizedBox( - height: 10.0, - ), + Row( + children: [ + AppText( + 'Price: ', + fontWeight: + FontWeight + .w700, + ), + Expanded( + child: AppText( + model + .procedureList[ + 0] + .entityList[ + index] + .price + .toString(), + fontSize: + 13.0), + ) + ], + ), + SizedBox( + height: 10.0, + ), - Row( - children: [ - AppText( - 'Some short remark about the procedure', - fontSize: 13.5, - ), - ], - ), - SizedBox( - height: 10.0, - ), + Row( + children: [ + AppText( + 'Some short remark about the procedure', + fontSize: 13.5, + ), + ], + ), + SizedBox( + height: 10.0, + ), - Divider( - height: 5.0, - thickness: 1.0, - color: Colors.grey, - ) - // SizedBox( - // height: 40, - // ), - ], + Divider( + height: 5.0, + thickness: 1.0, + color: Colors.grey, + ) + // SizedBox( + // height: 40, + // ), + ], + ), ), ), Container( - width: 30, - height: 120, child: Column( children: [ Icon(Icons.edit) @@ -420,6 +426,7 @@ postProcedure({ProcedureViewModel model}) async { void addSelectedProcedure(context, ProcedureViewModel model) { showModalBottomSheet( context: context, + isScrollControlled: true, builder: (BuildContext bc) { return AddSelectedProcedure( model: model, @@ -437,14 +444,14 @@ class AddSelectedProcedure extends StatefulWidget { class _AddSelectedProcedureState extends State { TextEditingController procedureController = TextEditingController(); - + List entityList= List(); @override Widget build(BuildContext context) { return NetworkBaseView( baseViewModel: widget.model, child: SingleChildScrollView( child: Container( - height: 490, + //height: 490, child: Padding( padding: EdgeInsets.all(12.0), child: Column( @@ -455,76 +462,26 @@ class _AddSelectedProcedureState extends State { fontWeight: FontWeight.w900, ), if (widget.model.categoriesList.length != 0) - Container( - // child: ListView( - // children: [ - // Column( - // children: model.historyFamilyList - // .map((historyInfo) { - // return Column( - // children: [ - // Row( - // children: [ - // Checkbox( - // value: isServiceSelected( - // historyInfo), - // activeColor: - // Colors.red[800], - // onChanged: - // (bool newValue) { - // setState(() { - // if (isServiceSelected( - // historyInfo - // )) { - // widget - // .removeHistory( - // historyInfo - // ); - // } - // else { - // widget - // .myHistoryList - // .add( - // historyInfo); - // } - // }); - // }), - // Expanded( - // child: Padding( - // padding: - // const EdgeInsets - // .symmetric( - // horizontal: 10, - // vertical: 0), - // child: Texts( - // historyInfo.nameEn, - // variant: "bodyText", - // bold: true, - // color: - // Colors.black), - // ), - // ), - // ], - // ), - // DividerWithSpacesAround(), - // ], - // ); - // }).toList(), - // ), - // ], - // ), - height: 120.0, - child: ListView.builder( - scrollDirection: Axis.vertical, - shrinkWrap: true, - itemCount: widget.model.categoriesList[0].rowcount, - itemBuilder: (BuildContext ctxt, int index) { - return Container( - child: AppText(widget.model.categoriesList[0] - .entityList[index].procedureName), - ); - }), - ), + EntityListCheckboxSearchWidget( + model: widget.model, + masterList: widget.model.categoriesList[0].entityList, + removeHistory: (item){ + setState(() { + entityList.remove(item); + }); + }, + addHistory: (history){ + setState(() { + entityList.add(history); + }); + }, + addSelectedHistories: (){ + //TODO build your fun herr + // widget.addSelectedHistories(); + }, + isEntityListSelected: (master) => isEntityListSelected(master), + ), + SizedBox( height: 0.0, ), @@ -571,16 +528,17 @@ class _AddSelectedProcedureState extends State { ), ); } + bool isEntityListSelected(EntityList masterKey) { + Iterable history = + entityList.where((element) => masterKey.procedureId == element.procedureId); + if (history.length > 0) { + return true; + } + return false; + } } -// isServiceSelected(ProcedureViewModel masterKey) { -// Iterable history = widget.myHistoryList.where((element) => -// masterKey.id == element.id && masterKey.typeId == element.typeId); -// if (history.length > 0) { -// return true; -// } -// return false; -// } + void updateProcedureForm(context) { showModalBottomSheet( From 39970fe1a830fc3ea3e38c133af6573fc8ace6e0 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Thu, 31 Dec 2020 17:20:58 +0200 Subject: [PATCH 06/15] get update_subjective_page.dart --- lib/core/service/SOAP_service.dart | 21 ++- lib/core/service/base/lookup-service.dart | 2 + lib/core/viewModel/SOAP_view_model.dart | 174 ++++++++++++++++-- lib/models/SOAP/GetAllergiesResModel.dart | 60 ++++++ .../subjective/update_subjective_page.dart | 162 ++++++++++------ .../soap_update/update_soap_index.dart | 4 + 6 files changed, 344 insertions(+), 79 deletions(-) create mode 100644 lib/models/SOAP/GetAllergiesResModel.dart diff --git a/lib/core/service/SOAP_service.dart b/lib/core/service/SOAP_service.dart index f4b8ef1c..8c7631a3 100644 --- a/lib/core/service/SOAP_service.dart +++ b/lib/core/service/SOAP_service.dart @@ -1,6 +1,7 @@ import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/models/SOAP/ChiefComplaint/GetChiefComplaintResModel.dart'; import 'package:doctor_app_flutter/models/SOAP/GeneralGetReqForSOAP.dart'; +import 'package:doctor_app_flutter/models/SOAP/GetAllergiesResModel.dart'; import 'package:doctor_app_flutter/models/SOAP/get_Allergies_request_model.dart'; import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; import 'package:doctor_app_flutter/models/SOAP/post_allergy_request_model.dart'; @@ -14,7 +15,8 @@ import 'package:doctor_app_flutter/widgets/patients/profile/soap_update/update_a import 'base/lookup-service.dart'; class SOAPService extends LookupService { - List chiefComplaintList = []; + List patientChiefComplaintList = []; + List patientAllergiesList = []; Future getAllergies(GetAllergiesRequestModel getAllergiesRequestModel) async { await baseAppClient.post( @@ -181,16 +183,19 @@ class SOAPService extends LookupService { - Future getPatientAllergy(PostAllergyRequestModel getPatientAllergyRequestModel) async { + Future getPatientAllergy(GeneralGetReqForSOAP generalGetReqForSOAP) async { hasError = false; await baseAppClient.post (GET_ALLERGY, onSuccess: (dynamic response, int statusCode) { - print("Success"); + patientAllergiesList.clear(); + response['List_Allergies']['entityList'].forEach((v) { + patientAllergiesList.add(GetAllergiesResModel.fromJson(v)); + }); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; - }, body: getPatientAllergyRequestModel.toJson()); + }, body: generalGetReqForSOAP.toJson()); } Future getPatientHistories( @@ -206,19 +211,19 @@ class SOAPService extends LookupService { } Future getPatientChiefComplaint( - GeneralGetReqForSOAP getPatientChiefComplaintRequestModel) async { + GeneralGetReqForSOAP generalGetReqForSOAP) async { hasError = false; await baseAppClient.post (GET_CHIEF_COMPLAINT, onSuccess: (dynamic response, int statusCode) { print("Success"); - chiefComplaintList.clear(); + patientChiefComplaintList.clear(); response['List_ChiefComplaint']['entityList'].forEach((v) { - chiefComplaintList.add(GetChiefComplaintResModel.fromJson(v)); + patientChiefComplaintList.add(GetChiefComplaintResModel.fromJson(v)); }); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; - }, body: getPatientChiefComplaintRequestModel.toJson()); + }, body: generalGetReqForSOAP.toJson()); } Future getPatientPhysicalExam( diff --git a/lib/core/service/base/lookup-service.dart b/lib/core/service/base/lookup-service.dart index eabac69b..a57c939b 100644 --- a/lib/core/service/base/lookup-service.dart +++ b/lib/core/service/base/lookup-service.dart @@ -1,6 +1,7 @@ import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; +import 'package:flutter/cupertino.dart'; import 'base_service.dart'; @@ -130,4 +131,5 @@ class LookupService extends BaseService { break; } } + } diff --git a/lib/core/viewModel/SOAP_view_model.dart b/lib/core/viewModel/SOAP_view_model.dart index 43107275..bcc98a7b 100644 --- a/lib/core/viewModel/SOAP_view_model.dart +++ b/lib/core/viewModel/SOAP_view_model.dart @@ -1,8 +1,9 @@ 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/service/SOAP_service.dart'; -import 'package:doctor_app_flutter/models/SOAP/Allergy_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/ChiefComplaint/GetChiefComplaintResModel.dart'; import 'package:doctor_app_flutter/models/SOAP/GeneralGetReqForSOAP.dart'; +import 'package:doctor_app_flutter/models/SOAP/GetAllergiesResModel.dart'; import 'package:doctor_app_flutter/models/SOAP/get_Allergies_request_model.dart'; import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; import 'package:doctor_app_flutter/models/SOAP/post_allergy_request_model.dart'; @@ -12,6 +13,7 @@ import 'package:doctor_app_flutter/models/SOAP/post_histories_request_model.dart import 'package:doctor_app_flutter/models/SOAP/post_physical_exam_request_model.dart'; import 'package:doctor_app_flutter/models/SOAP/post_progress_note_request_model.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/soap_update/update_assessment_page.dart'; +import 'package:flutter/material.dart'; import '../../locator.dart'; import 'base_view_model.dart'; @@ -32,14 +34,29 @@ class SOAPViewModel extends BaseViewModel { List get historySportList => _SOAPService.historySportList; List get historySocialList => _SOAPService.historySocialList; - List get historySurgicalList => _SOAPService.historySurgicalList; - List get mergeHistorySurgicalWithHistorySportList => [...historySurgicalList,...historySportList]; - List get physicalExaminationList => _SOAPService.physicalExaminationList; - List get listOfDiagnosisType => _SOAPService.listOfDiagnosisType; - List get listOfDiagnosisCondition => _SOAPService.listOfDiagnosisCondition; - List get listOfICD10 => _SOAPService.listOfICD10; + List get historySurgicalList => + _SOAPService.historySurgicalList; + List get mergeHistorySurgicalWithHistorySportList => + [...historySurgicalList, ...historySportList]; + + List get physicalExaminationList => + _SOAPService.physicalExaminationList; + + List get listOfDiagnosisType => + _SOAPService.listOfDiagnosisType; + + List get listOfDiagnosisCondition => + _SOAPService.listOfDiagnosisCondition; + + List get listOfICD10 => _SOAPService.listOfICD10; + + List get chiefComplaintList => + _SOAPService.patientChiefComplaintList; + + List get patientAllergiesList => + _SOAPService.patientAllergiesList; Future getAllergies(GetAllergiesRequestModel getAllergiesRequestModel) async { setState(ViewState.Busy); @@ -183,11 +200,9 @@ class SOAPViewModel extends BaseViewModel { } - - - Future getPatientAllergy(PostAllergyRequestModel getPatientAllergyRequestModel) async { + Future getPatientAllergy(GeneralGetReqForSOAP generalGetReqForSOAP) async { setState(ViewState.Busy); - await _SOAPService.getPatientAllergy(getPatientAllergyRequestModel); + await _SOAPService.getPatientAllergy(generalGetReqForSOAP); if (_SOAPService.hasError) { error = _SOAPService.error; setState(ViewState.Busy); @@ -205,9 +220,10 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getPatientChiefComplaint(GeneralGetReqForSOAP getPatientChiefComplaintRequestModel) async { + Future getPatientChiefComplaint( + GeneralGetReqForSOAP generalGetReqForSOAP) async { setState(ViewState.Busy); - await _SOAPService.getPatientChiefComplaint(getPatientChiefComplaintRequestModel); + await _SOAPService.getPatientChiefComplaint(generalGetReqForSOAP); if (_SOAPService.hasError) { error = _SOAPService.error; setState(ViewState.Busy); @@ -235,7 +251,8 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getPatientAssessment(PostAssessmentRequestModel getPatientAssessmentRequestModel) async { + Future getPatientAssessment( + PostAssessmentRequestModel getPatientAssessmentRequestModel) async { setState(ViewState.Busy); await _SOAPService.getPatientAssessment(getPatientAssessmentRequestModel); if (_SOAPService.hasError) { @@ -245,4 +262,133 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.Idle); } + + // ignore: missing_return + MasterKeyModel getOneMasterKey( + {@required MasterKeysService masterKeys, int id, int typeId}) { + switch (masterKeys) { + case MasterKeysService.Allergies: + List result = allergiesList.where((element) { + print(element.id == id); + return element.id == id && + element.typeId == masterKeys.getMasterKeyService(); + }).toList(); + if (result.isNotEmpty) { + return result.first; + } + break; + + case MasterKeysService.HistoryFamily: + List result = historyFamilyList.where((element) { + print(element.id == id); + return element.id == id && + element.typeId == masterKeys.getMasterKeyService(); + }).toList(); + if (result.isNotEmpty) { + return result.first; + } + break; + case MasterKeysService.HistoryMedical: + List result = historyMedicalList.where((element) { + print(element.id == id); + return element.id == id && + element.typeId == masterKeys.getMasterKeyService(); + }).toList(); + if (result.isNotEmpty) { + return result.first; + } + break; + case MasterKeysService.HistorySocial: + List result = historySocialList.where((element) { + print(element.id == id); + return element.id == id && + element.typeId == masterKeys.getMasterKeyService(); + }).toList(); + if (result.isNotEmpty) { + return result.first; + } + break; + case MasterKeysService.HistorySports: + List result = historySocialList.where((element) { + print(element.id == id); + return element.id == id && + element.typeId == masterKeys.getMasterKeyService(); + }).toList(); + if (result.isNotEmpty) { + return result.first; + } + break; + case MasterKeysService.HistorySurgical: + List result = historySurgicalList.where((element) { + print(element.id == id); + return element.id == id && + element.typeId == masterKeys.getMasterKeyService(); + }).toList(); + if (result.isNotEmpty) { + return result.first; + } + break; + case MasterKeysService.PhysicalExamination: + List result = physicalExaminationList.where((element) { + print(element.id == id); + return element.id == id && + element.typeId == masterKeys.getMasterKeyService(); + }).toList(); + if (result.isNotEmpty) { + return result.first; + } + break; + case MasterKeysService.AllergySeverity: + List result = allergySeverityList.where((element) { + print(element.id == id); + return element.id == id && + element.typeId == masterKeys.getMasterKeyService(); + }).toList(); + if (result.isNotEmpty) { + return result.first; + } + break; + // case MasterKeysService.physiotherapyGoals: + // listOfPhysiotherapyGoals.clear(); + // entryList.forEach((v) { + // listOfPhysiotherapyGoals.add(MasterKeyModel.fromJson(v)); + // }); + // break; + + case MasterKeysService.DiagnosisType: + List result = listOfDiagnosisType.where((element) { + print(element.id == id); + return element.id == id && + element.typeId == masterKeys.getMasterKeyService(); + }).toList(); + if (result.isNotEmpty) { + return result.first; + } + break; + case MasterKeysService.DiagnosisCondition: + List result = listOfDiagnosisCondition.where((element) { + print(element.id == id); + return element.id == id && + element.typeId == masterKeys.getMasterKeyService(); + }).toList(); + if (result.isNotEmpty) { + return result.first; + } + break; + case MasterKeysService.ICD10: + listOfICD10.clear(); + List result = listOfICD10.where((element) { + print(element.id == id); + return element.id == id && + element.typeId == masterKeys.getMasterKeyService(); + }).toList(); + if (result.isNotEmpty) { + return result.first; + } + break; + break; + } + } + + } diff --git a/lib/models/SOAP/GetAllergiesResModel.dart b/lib/models/SOAP/GetAllergiesResModel.dart new file mode 100644 index 00000000..a403bd2e --- /dev/null +++ b/lib/models/SOAP/GetAllergiesResModel.dart @@ -0,0 +1,60 @@ +class GetAllergiesResModel { + int allergyDiseaseId; + String allergyDiseaseName; + int allergyDiseaseType; + int appointmentNo; + int createdBy; + String createdByName; + String createdOn; + int episodeID; + bool isChecked; + bool isUpdatedByNurse; + int severity; + String severityName; + + GetAllergiesResModel( + {this.allergyDiseaseId, + this.allergyDiseaseName, + this.allergyDiseaseType, + this.appointmentNo, + this.createdBy, + this.createdByName, + this.createdOn, + this.episodeID, + this.isChecked, + this.isUpdatedByNurse, + this.severity, + this.severityName}); + + GetAllergiesResModel.fromJson(Map json) { + allergyDiseaseId = json['allergyDiseaseId']; + allergyDiseaseName = json['allergyDiseaseName']; + allergyDiseaseType = json['allergyDiseaseType']; + appointmentNo = json['appointmentNo']; + createdBy = json['createdBy']; + createdByName = json['createdByName']; + createdOn = json['createdOn']; + episodeID = json['episodeID']; + isChecked = json['isChecked']; + isUpdatedByNurse = json['isUpdatedByNurse']; + severity = json['severity']; + severityName = json['severityName']; + } + + Map toJson() { + final Map data = new Map(); + data['allergyDiseaseId'] = this.allergyDiseaseId; + data['allergyDiseaseName'] = this.allergyDiseaseName; + data['allergyDiseaseType'] = this.allergyDiseaseType; + data['appointmentNo'] = this.appointmentNo; + data['createdBy'] = this.createdBy; + data['createdByName'] = this.createdByName; + data['createdOn'] = this.createdOn; + data['episodeID'] = this.episodeID; + data['isChecked'] = this.isChecked; + data['isUpdatedByNurse'] = this.isUpdatedByNurse; + data['severity'] = this.severity; + data['severityName'] = this.severityName; + return data; + } +} diff --git a/lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart b/lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart index 24be10e1..9fae8b21 100644 --- a/lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart +++ b/lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart @@ -1,7 +1,9 @@ import 'package:doctor_app_flutter/client/base_app_client.dart'; import 'package:doctor_app_flutter/config/config.dart'; +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/viewModel/SOAP_view_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/GeneralGetReqForSOAP.dart'; import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; import 'package:doctor_app_flutter/models/SOAP/my_selected_allergy.dart'; import 'package:doctor_app_flutter/models/SOAP/post_allergy_request_model.dart'; @@ -10,8 +12,6 @@ import 'package:doctor_app_flutter/models/SOAP/post_histories_request_model.dart import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; -import 'package:doctor_app_flutter/widgets/patients/profile/SOAP/subjective/add_allergies_widget.dart'; -import 'package:doctor_app_flutter/widgets/patients/profile/SOAP/subjective/add_history_widget.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/soap_update/subjective/update_allergies_widget.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/soap_update/subjective/update_history_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/Text.dart'; @@ -51,7 +51,41 @@ class _UpdateSubjectivePageState extends State { @override Widget build(BuildContext context) { return BaseView( - // onModelReady: (model) => model.getMasterLookup(MasterKeysService.Allergies), + onModelReady: (model) async { + GeneralGetReqForSOAP generalGetReqForSOAP = GeneralGetReqForSOAP( + patientMRN: widget.patientInfo.patientMRN, + episodeId: widget.patientInfo.episodeNo, + appointmentNo: widget.patientInfo.appointmentNo); + + if (model.allergiesList.isEmpty) + await model.getMasterLookup(MasterKeysService.Allergies); + if (model.allergySeverityList.isEmpty) + await model.getMasterLookup(MasterKeysService.AllergySeverity); + await model.getPatientChiefComplaint(generalGetReqForSOAP); + if (model.chiefComplaintList.isNotEmpty) { + complaintsController.text = + model.chiefComplaintList[0].chiefComplaint; + illnessController.text = model.chiefComplaintList[0].hopi; + } + await model.getPatientAllergy(generalGetReqForSOAP); + if (model.patientAllergiesList.isNotEmpty) { + model.patientAllergiesList.forEach((element) { + MasterKeyModel selectedAllergy = model.getOneMasterKey( + masterKeys: MasterKeysService.Allergies, + id: element.allergyDiseaseId, + typeId: element.allergyDiseaseType); + MasterKeyModel selectedAllergySeverity = model.getOneMasterKey( + masterKeys: MasterKeysService.AllergySeverity, + id: element.severity, + ); + MySelectedAllergy mySelectedAllergy = MySelectedAllergy( + selectedAllergy: selectedAllergy, + selectedAllergySeverity: selectedAllergySeverity); + + widget.myAllergiesList.add(mySelectedAllergy); + }); + } + }, builder: (_, model, w) => AppScaffold( isShowAppBar: false, baseViewModel: model, @@ -279,45 +313,45 @@ class _UpdateSubjectivePageState extends State { formKey.currentState.validate(); - // if(complaintsController.text.isNotEmpty && illnessController.text.isNotEmpty && complaintsController.text.length>25) { - // await postChiefComplaint(model: model); - // if (model.state == ViewState.ErrorLocal) { - // helpers.showErrorToast(model.error); - // } else { - // if (myHistoryList.length != 0) { - // await postHistories(model: model, myHistoryList: myHistoryList); - // if (model.state == ViewState.ErrorLocal) { - // helpers.showErrorToast(model.error); - // } else { - // if (myAllergiesList.length != 0) { - // await postAllergy(myAllergiesList: myAllergiesList, model: model); - // if (model.state == ViewState.ErrorLocal) { - // helpers.showErrorToast(model.error); - // } else { - // widget.changePageViewIndex(1); - // } - // } else { - // widget.changePageViewIndex(1); - // - // } - // - // } - // } else { - // if (myAllergiesList.length != 0) { - // await postAllergy(myAllergiesList: myAllergiesList, model: model); - // if (model.state == ViewState.ErrorLocal) { - // helpers.showErrorToast(model.error); - // } else { - // widget.changePageViewIndex(1); - // } - // } else { - // widget.changePageViewIndex(1); - // } - // } - // } - // } else { - // helpers.showErrorToast('Please add required field correctly'); - // } + if (complaintsController.text.isNotEmpty && + illnessController.text.isNotEmpty && + complaintsController.text.length > 25) { + await postChiefComplaint(model: model); + if (model.state == ViewState.ErrorLocal) { + helpers.showErrorToast(model.error); + } else { + if (myHistoryList.length != 0) { + await postHistories(model: model, myHistoryList: myHistoryList); + if (model.state == ViewState.ErrorLocal) { + helpers.showErrorToast(model.error); + } else { + if (myAllergiesList.length != 0) { + await postAllergy(myAllergiesList: myAllergiesList, model: model); + if (model.state == ViewState.ErrorLocal) { + helpers.showErrorToast(model.error); + } else { + widget.changePageViewIndex(1); + } + } else { + widget.changePageViewIndex(1); + } + } + } else { + if (myAllergiesList.length != 0) { + await postAllergy(myAllergiesList: myAllergiesList, model: model); + if (model.state == ViewState.ErrorLocal) { + helpers.showErrorToast(model.error); + } else { + widget.changePageViewIndex(1); + } + } else { + widget.changePageViewIndex(1); + } + } + } + } else { + helpers.showErrorToast('Please add required field correctly'); + } widget.changePageViewIndex(1); @@ -334,22 +368,28 @@ class _UpdateSubjectivePageState extends State { //TODO: make static value dynamic postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM .add(ListHisProgNotePatientAllergyDiseaseVM( - allergyDiseaseId: allergy.selectedAllergy.id, - allergyDiseaseType: allergy.selectedAllergy.typeId, - patientMRN: widget.patientInfo.patientMRN, - episodeId: widget.patientInfo.episodeNo, - appointmentNo: widget.patientInfo.appointmentNo, - severity: allergy.selectedAllergySeverity.id, - remarks: allergy.remark, - createdBy: 1485, - // - createdOn: DateTime.now().toIso8601String(),//"2020-08-14T20:37:22.780Z", - editedBy: 1485, - editedOn: DateTime.now().toIso8601String(),//"2020-08-14T20:37:22.780Z", - isChecked: false, - isUpdatedByNurse: false)); + allergyDiseaseId: allergy.selectedAllergy.id, + allergyDiseaseType: allergy.selectedAllergy.id, + patientMRN: widget.patientInfo.patientMRN, + episodeId: widget.patientInfo.episodeNo, + appointmentNo: widget.patientInfo.appointmentNo, + severity: allergy.selectedAllergySeverity.id, + remarks: allergy.remark, + createdBy: 4709, + // + createdOn: DateTime.now().toIso8601String(), + //"2020-08-14T20:37:22.780Z", + editedBy: 4709, + editedOn: DateTime.now().toIso8601String(), + //"2020-08-14T20:37:22.780Z", + isChecked: false, + isUpdatedByNurse: false)); }); - await model.patchAllergy(postAllergyRequestModel); + if (model.patientAllergiesList.isEmpty) { + await model.postAllergy(postAllergyRequestModel); + } else { + await model.patchAllergy(postAllergyRequestModel); + } if (model.state == ViewState.ErrorLocal) { helpers.showErrorToast(model.error); @@ -374,6 +414,14 @@ class _UpdateSubjectivePageState extends State { isChecked: false, )); }); + + + if (model.patientAllergiesList.isEmpty) { + await model.postHistories(postHistoriesRequestModel); + } else { + await model.patchHistories(postHistoriesRequestModel); + } + await model.patchHistories(postHistoriesRequestModel); if (model.state == ViewState.ErrorLocal) { diff --git a/lib/widgets/patients/profile/soap_update/update_soap_index.dart b/lib/widgets/patients/profile/soap_update/update_soap_index.dart index 59557145..744f5244 100644 --- a/lib/widgets/patients/profile/soap_update/update_soap_index.dart +++ b/lib/widgets/patients/profile/soap_update/update_soap_index.dart @@ -6,7 +6,11 @@ import 'package:doctor_app_flutter/models/SOAP/my_selected_examination.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/SOAP/assessment_page.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/SOAP/objective_page.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/SOAP/plan_page.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/SOAP/steps_widget.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/SOAP/subjective/subjective_page.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/patient-page-header-widget.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/soap_update/update_assessment_page.dart'; From 9bf08e81dab7ba6eea875cea1d90aa7001034d55 Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Thu, 31 Dec 2020 17:34:23 +0200 Subject: [PATCH 07/15] Add search button name and hint search text in MasterKeyCheckboxSearchWidget --- lib/widgets/shared/master_key_checkbox_search_widget.dart | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/widgets/shared/master_key_checkbox_search_widget.dart b/lib/widgets/shared/master_key_checkbox_search_widget.dart index 550d3127..f164be4b 100644 --- a/lib/widgets/shared/master_key_checkbox_search_widget.dart +++ b/lib/widgets/shared/master_key_checkbox_search_widget.dart @@ -17,6 +17,8 @@ class MasterKeyCheckboxSearchWidget extends StatefulWidget { final Function(MasterKeyModel) addHistory; final bool Function(MasterKeyModel) isServiceSelected; final List masterList; + final String buttonName; + final String hintSearchText; MasterKeyCheckboxSearchWidget( {Key key, @@ -25,7 +27,7 @@ class MasterKeyCheckboxSearchWidget extends StatefulWidget { this.removeHistory, this.masterList, this.addHistory, - this.isServiceSelected}) + this.isServiceSelected, this.buttonName, this.hintSearchText}) : super(key: key); @override @@ -59,7 +61,7 @@ class _MasterKeyCheckboxSearchWidgetState extends State Date: Thu, 31 Dec 2020 17:45:18 +0200 Subject: [PATCH 08/15] fix merger --- lib/screens/patients/patients_screen.dart | 184 +++++++++--------- .../profile/SOAP/assessment_page.dart | 3 +- .../SOAP/subjective/add_allergies_widget.dart | 6 +- 3 files changed, 98 insertions(+), 95 deletions(-) diff --git a/lib/screens/patients/patients_screen.dart b/lib/screens/patients/patients_screen.dart index cb0c7248..74c9234c 100644 --- a/lib/screens/patients/patients_screen.dart +++ b/lib/screens/patients/patients_screen.dart @@ -569,100 +569,102 @@ class _PatientsScreenState extends State { ), ], ), - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - // mainAxisAlignment: - // MainAxisAlignment - // .spaceBetween, - children: < - Widget>[ - SizedBox( - height: - 0.5, - ), - SizedBox( - height: - 0, - ), - Wrap( - children: [ - AppText( - TranslationBase.of(context).age2, - fontSize: 1.8 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - backGroundcolor: Colors.white, - ), - AppText( - item.age.toString(), - fontSize: 1.8 * SizeConfig.textMultiplier, - fontWeight: FontWeight.w300, - backGroundcolor: Colors.white, - ), - ], - ), - SizedBox( - height: - 2.5, - ), - Wrap( - children: [ - AppText( - TranslationBase.of(context).gender2, - fontSize: 1.8 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - backGroundcolor: Colors.white, - ), - AppText( - item.gender.toString() == '1' ? 'Male' : 'Female', - fontSize: 1.8 * SizeConfig.textMultiplier, - fontWeight: FontWeight.w300, - backGroundcolor: Colors.white, - ), - ], - ), - SizedBox( - height: - 8, - ), - SERVICES_PATIANT2[int.parse(patientType)] == "List_MyOutPatient" - ? Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - height: 15, - width: 60, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(25), - color: HexColor("#20A169"), + Expanded( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + // mainAxisAlignment: + // MainAxisAlignment + // .spaceBetween, + children: < + Widget>[ + SizedBox( + height: + 0.5, + ), + SizedBox( + height: + 0, + ), + Wrap( + children: [ + AppText( + TranslationBase.of(context).age2, + fontSize: 1.8 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + backGroundcolor: Colors.white, + ), + AppText( + item.age.toString(), + fontSize: 1.8 * SizeConfig.textMultiplier, + fontWeight: FontWeight.w300, + backGroundcolor: Colors.white, + ), + ], + ), + SizedBox( + height: + 2.5, + ), + Wrap( + children: [ + AppText( + TranslationBase.of(context).gender2, + fontSize: 1.8 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + backGroundcolor: Colors.white, + ), + AppText( + item.gender.toString() == '1' ? 'Male' : 'Female', + fontSize: 1.8 * SizeConfig.textMultiplier, + fontWeight: FontWeight.w300, + backGroundcolor: Colors.white, + ), + ], + ), + SizedBox( + height: + 8, + ), + SERVICES_PATIANT2[int.parse(patientType)] == "List_MyOutPatient" + ? Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + height: 15, + width: 60, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(25), + color: HexColor("#20A169"), + ), + child: AppText( + item.startTime, + color: Colors.white, + fontSize: 1.5 * SizeConfig.textMultiplier, + textAlign: TextAlign.center, + fontWeight: FontWeight.bold, + ), ), - child: AppText( - item.startTime, - color: Colors.white, - fontSize: 1.5 * SizeConfig.textMultiplier, - textAlign: TextAlign.center, - fontWeight: FontWeight.bold, + SizedBox( + width: 3.5, ), - ), - SizedBox( - width: 3.5, - ), - Container( - child: AppText( - convertDateFormat2(item.appointmentDate.toString()), - fontSize: 1.5 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, + Container( + child: AppText( + convertDateFormat2(item.appointmentDate.toString()), + fontSize: 1.5 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), ), - ), - SizedBox( - height: 25.5, - ), - ], - ) - : SizedBox( - height: 15, - ), - ], + SizedBox( + height: 25.5, + ), + ], + ) + : SizedBox( + height: 15, + ), + ], + ), ), ], ), diff --git a/lib/widgets/patients/profile/SOAP/assessment_page.dart b/lib/widgets/patients/profile/SOAP/assessment_page.dart index 1527d46b..0f7a8e31 100644 --- a/lib/widgets/patients/profile/SOAP/assessment_page.dart +++ b/lib/widgets/patients/profile/SOAP/assessment_page.dart @@ -10,6 +10,7 @@ import 'package:doctor_app_flutter/models/SOAP/my_selected_assement.dart'; import 'package:doctor_app_flutter/models/SOAP/post_assessment_request_model.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/Text.dart'; import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; @@ -43,7 +44,7 @@ class _AssessmentPageState extends State { dynamic _referTo; TextEditingController remarksController = TextEditingController(); - + Helpers helpers = Helpers(); @override Widget build(BuildContext context) { final screenSize = MediaQuery.of(context).size; diff --git a/lib/widgets/patients/profile/SOAP/subjective/add_allergies_widget.dart b/lib/widgets/patients/profile/SOAP/subjective/add_allergies_widget.dart index 446df7ee..0a4ce08e 100644 --- a/lib/widgets/patients/profile/SOAP/subjective/add_allergies_widget.dart +++ b/lib/widgets/patients/profile/SOAP/subjective/add_allergies_widget.dart @@ -183,7 +183,7 @@ class _AddAllergiesState extends State { heightFactor: 0.7, child: BaseView( onModelReady: (model) async { - if (model.listOfAllergies.length == 0) { + if (model.allergiesList.length == 0) { await model.getMasterLookup(MasterKeysService.Allergies); } if (model.allergySeverityList.length == 0) { @@ -216,7 +216,7 @@ class _AddAllergiesState extends State { Container( height: screenSize.height * 0.070, child: InkWell( - onTap: model.listOfAllergies != null + onTap: model.allergiesList != null ? () { setState(() { _selectedAllergy = null; @@ -227,7 +227,7 @@ class _AddAllergiesState extends State { decoration: textFieldSelectorDecoration("Select Allergy", _selectedAllergy != null ? _selectedAllergy.nameEn : null, true,icon: EvaIcons.search), itemSubmitted: (item) => setState(() => _selectedAllergy = item), key: key, - suggestions: model.listOfAllergies, + suggestions: model.allergiesList, itemBuilder: (context, suggestion) => new Padding( child:Texts( projectViewModel.isArabic? suggestion.nameAr: suggestion.nameEn), padding: EdgeInsets.all(8.0)), From 3578c82f629d04704f8a37eb44e2c37e8162e35e Mon Sep 17 00:00:00 2001 From: mosazaid Date: Thu, 31 Dec 2020 18:20:10 +0200 Subject: [PATCH 09/15] solve hacking patient screen --- lib/screens/patients/patient_search_screen.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/screens/patients/patient_search_screen.dart b/lib/screens/patients/patient_search_screen.dart index ba32fbe1..61eb5fcf 100644 --- a/lib/screens/patients/patient_search_screen.dart +++ b/lib/screens/patients/patient_search_screen.dart @@ -69,19 +69,19 @@ class _PatientSearchScreenState extends State { try { - Map profile = await sharedPref.getObj(DOCTOR_PROFILE); + /* Map profile = await sharedPref.getObj(DOCTOR_PROFILE); DoctorProfileModel doctorProfile = - new DoctorProfileModel.fromJson(profile); + new DoctorProfileModel.fromJson(profile)*/; if (_formKey.currentState.validate()) { _formKey.currentState.save(); - sharedPref.setString(SLECTED_PATIENT_TYPE, _selectedType); + /* sharedPref.setString(SLECTED_PATIENT_TYPE, _selectedType); String token = await sharedPref.getString(TOKEN); _patientSearchFormValues.TokenID = token; _patientSearchFormValues.ProjectID = doctorProfile.projectID; //15 _patientSearchFormValues.DoctorID = doctorProfile.doctorID; - _patientSearchFormValues.ClinicID = doctorProfile.clinicID; + _patientSearchFormValues.ClinicID = doctorProfile.clinicID;*/ if ((_patientSearchFormValues.From == "0" || _patientSearchFormValues.To == "0") && From c92a848851054f012c6b49902148445aa487e815 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Thu, 31 Dec 2020 18:57:15 +0200 Subject: [PATCH 10/15] Finish Update Subjective Page --- lib/core/service/SOAP_service.dart | 11 ++- lib/core/viewModel/SOAP_view_model.dart | 8 +- lib/models/SOAP/GetHistoryReqModel.dart | 18 +++++ lib/models/SOAP/GetHistoryResModel.dart | 40 ++++++++++ .../subjective/update_subjective_page.dart | 73 ++++++++++++++++++- 5 files changed, 142 insertions(+), 8 deletions(-) create mode 100644 lib/models/SOAP/GetHistoryReqModel.dart create mode 100644 lib/models/SOAP/GetHistoryResModel.dart diff --git a/lib/core/service/SOAP_service.dart b/lib/core/service/SOAP_service.dart index 8c7631a3..9679293b 100644 --- a/lib/core/service/SOAP_service.dart +++ b/lib/core/service/SOAP_service.dart @@ -2,6 +2,8 @@ import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/models/SOAP/ChiefComplaint/GetChiefComplaintResModel.dart'; import 'package:doctor_app_flutter/models/SOAP/GeneralGetReqForSOAP.dart'; import 'package:doctor_app_flutter/models/SOAP/GetAllergiesResModel.dart'; +import 'package:doctor_app_flutter/models/SOAP/GetHistoryReqModel.dart'; +import 'package:doctor_app_flutter/models/SOAP/GetHistoryResModel.dart'; import 'package:doctor_app_flutter/models/SOAP/get_Allergies_request_model.dart'; import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; import 'package:doctor_app_flutter/models/SOAP/post_allergy_request_model.dart'; @@ -17,6 +19,7 @@ import 'base/lookup-service.dart'; class SOAPService extends LookupService { List patientChiefComplaintList = []; List patientAllergiesList = []; + List patientHistoryList = []; Future getAllergies(GetAllergiesRequestModel getAllergiesRequestModel) async { await baseAppClient.post( @@ -199,15 +202,19 @@ class SOAPService extends LookupService { } Future getPatientHistories( - PostHistoriesRequestModel getPatientHistoriesRequestModel) async { + GetHistoryReqModel getHistoryReqModel) async { hasError = false; await baseAppClient.post (GET_HISTORY, onSuccess: (dynamic response, int statusCode) { print("Success"); + patientHistoryList.clear(); + response['List_History']['entityList'].forEach((v) { + patientHistoryList.add(GetHistoryResModel.fromJson(v)); + }); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; - }, body: getPatientHistoriesRequestModel.toJson()); + }, body: getHistoryReqModel.toJson()); } Future getPatientChiefComplaint( diff --git a/lib/core/viewModel/SOAP_view_model.dart b/lib/core/viewModel/SOAP_view_model.dart index bcc98a7b..8a3b787e 100644 --- a/lib/core/viewModel/SOAP_view_model.dart +++ b/lib/core/viewModel/SOAP_view_model.dart @@ -4,6 +4,8 @@ import 'package:doctor_app_flutter/core/service/SOAP_service.dart'; import 'package:doctor_app_flutter/models/SOAP/ChiefComplaint/GetChiefComplaintResModel.dart'; import 'package:doctor_app_flutter/models/SOAP/GeneralGetReqForSOAP.dart'; import 'package:doctor_app_flutter/models/SOAP/GetAllergiesResModel.dart'; +import 'package:doctor_app_flutter/models/SOAP/GetHistoryReqModel.dart'; +import 'package:doctor_app_flutter/models/SOAP/GetHistoryResModel.dart'; import 'package:doctor_app_flutter/models/SOAP/get_Allergies_request_model.dart'; import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; import 'package:doctor_app_flutter/models/SOAP/post_allergy_request_model.dart'; @@ -57,6 +59,8 @@ class SOAPViewModel extends BaseViewModel { List get patientAllergiesList => _SOAPService.patientAllergiesList; + List get patientHistoryList => + _SOAPService.patientHistoryList; Future getAllergies(GetAllergiesRequestModel getAllergiesRequestModel) async { setState(ViewState.Busy); @@ -210,9 +214,9 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getPatientHistories(PostHistoriesRequestModel getPatientHistoriesRequestModel) async { + Future getPatientHistories(GetHistoryReqModel getHistoryReqModel) async { setState(ViewState.Busy); - await _SOAPService.getPatientHistories(getPatientHistoriesRequestModel); + await _SOAPService.getPatientHistories(getHistoryReqModel); if (_SOAPService.hasError) { error = _SOAPService.error; setState(ViewState.Busy); diff --git a/lib/models/SOAP/GetHistoryReqModel.dart b/lib/models/SOAP/GetHistoryReqModel.dart new file mode 100644 index 00000000..9b852e9b --- /dev/null +++ b/lib/models/SOAP/GetHistoryReqModel.dart @@ -0,0 +1,18 @@ +class GetHistoryReqModel { + int patientMRN; + int historyType; + + GetHistoryReqModel({this.patientMRN, this.historyType}); + + GetHistoryReqModel.fromJson(Map json) { + patientMRN = json['PatientMRN']; + historyType = json['HistoryType']; + } + + Map toJson() { + final Map data = new Map(); + data['PatientMRN'] = this.patientMRN; + data['HistoryType'] = this.historyType; + return data; + } +} diff --git a/lib/models/SOAP/GetHistoryResModel.dart b/lib/models/SOAP/GetHistoryResModel.dart new file mode 100644 index 00000000..c4b4f129 --- /dev/null +++ b/lib/models/SOAP/GetHistoryResModel.dart @@ -0,0 +1,40 @@ +class GetHistoryResModel { + int appointmentNo; + int episodeId; + int historyId; + int historyType; + bool isChecked; + int patientMRN; + String remarks; + + GetHistoryResModel( + {this.appointmentNo, + this.episodeId, + this.historyId, + this.historyType, + this.isChecked, + this.patientMRN, + this.remarks}); + + GetHistoryResModel.fromJson(Map json) { + appointmentNo = json['appointmentNo']; + episodeId = json['episodeId']; + historyId = json['historyId']; + historyType = json['historyType']; + isChecked = json['isChecked']; + patientMRN = json['patientMRN']; + remarks = json['remarks']; + } + + Map toJson() { + final Map data = new Map(); + data['appointmentNo'] = this.appointmentNo; + data['episodeId'] = this.episodeId; + data['historyId'] = this.historyId; + data['historyType'] = this.historyType; + data['isChecked'] = this.isChecked; + data['patientMRN'] = this.patientMRN; + data['remarks'] = this.remarks; + return data; + } +} diff --git a/lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart b/lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart index 9fae8b21..33a691cb 100644 --- a/lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart +++ b/lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart @@ -4,6 +4,7 @@ import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; import 'package:doctor_app_flutter/models/SOAP/GeneralGetReqForSOAP.dart'; +import 'package:doctor_app_flutter/models/SOAP/GetHistoryReqModel.dart'; import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; import 'package:doctor_app_flutter/models/SOAP/my_selected_allergy.dart'; import 'package:doctor_app_flutter/models/SOAP/post_allergy_request_model.dart'; @@ -47,7 +48,67 @@ class _UpdateSubjectivePageState extends State { TextEditingController illnessController = TextEditingController(); TextEditingController complaintsController = TextEditingController(); final formKey = GlobalKey(); + getHistory(SOAPViewModel model) async{ + GetHistoryReqModel getHistoryMedicalReqModel = GetHistoryReqModel( + patientMRN: widget.patientInfo.patientMRN, + historyType: + MasterKeysService.HistoryMedical.getMasterKeyService()); + GetHistoryReqModel getHistorySportsReqModel = GetHistoryReqModel( + patientMRN: widget.patientInfo.patientMRN, + historyType: + MasterKeysService.HistorySports.getMasterKeyService()); + GetHistoryReqModel getHistorySurgicalReqModel = GetHistoryReqModel( + patientMRN: widget.patientInfo.patientMRN, + historyType: + MasterKeysService.HistorySurgical.getMasterKeyService()); + GetHistoryReqModel getHistoryFamilyReqModel = GetHistoryReqModel( + patientMRN: widget.patientInfo.patientMRN, + historyType: + MasterKeysService.HistoryFamily.getMasterKeyService()); + await model.getPatientHistories(getHistoryMedicalReqModel); + await model.getPatientHistories(getHistorySportsReqModel); + await model.getPatientHistories(getHistorySurgicalReqModel); + await model.getPatientHistories(getHistoryFamilyReqModel); + + if(model.patientHistoryList.isNotEmpty) { + if (model.historyFamilyList.isEmpty) { + await model.getMasterLookup(MasterKeysService.HistoryFamily); + } + if (model.historyMedicalList.isEmpty) { + await model.getMasterLookup(MasterKeysService.HistoryMedical); + } + if (model.historySurgicalList.length == 0) { + await model.getMasterLookup(MasterKeysService.HistorySurgical); + await model.getMasterLookup(MasterKeysService.HistorySports); + } + model.patientHistoryList.forEach((element) { + if (element.historyType == MasterKeysService.HistoryFamily.getMasterKeyService()) { + widget.myHistoryList.add( model.getOneMasterKey( + masterKeys: MasterKeysService.HistoryFamily, + id: element.historyId, + )); + }if (element.historyType == MasterKeysService.HistoryMedical.getMasterKeyService()) { + widget.myHistoryList.add( model.getOneMasterKey( + masterKeys: MasterKeysService.HistoryMedical, + id: element.historyId, + )); + }if (element.historyType == MasterKeysService.HistorySports.getMasterKeyService()) { + widget.myHistoryList.add( model.getOneMasterKey( + masterKeys: MasterKeysService.HistorySports, + id: element.historyId, + )); + } + if (element.historyType == + MasterKeysService.HistorySurgical.getMasterKeyService()) { + widget.myHistoryList.add(model.getOneMasterKey( + masterKeys: MasterKeysService.HistorySurgical, + id: element.historyId, + )); + } + }); + } + } @override Widget build(BuildContext context) { return BaseView( @@ -57,10 +118,6 @@ class _UpdateSubjectivePageState extends State { episodeId: widget.patientInfo.episodeNo, appointmentNo: widget.patientInfo.appointmentNo); - if (model.allergiesList.isEmpty) - await model.getMasterLookup(MasterKeysService.Allergies); - if (model.allergySeverityList.isEmpty) - await model.getMasterLookup(MasterKeysService.AllergySeverity); await model.getPatientChiefComplaint(generalGetReqForSOAP); if (model.chiefComplaintList.isNotEmpty) { complaintsController.text = @@ -69,6 +126,11 @@ class _UpdateSubjectivePageState extends State { } await model.getPatientAllergy(generalGetReqForSOAP); if (model.patientAllergiesList.isNotEmpty) { + if (model.allergiesList.isEmpty) + await model.getMasterLookup(MasterKeysService.Allergies); + if (model.allergySeverityList.isEmpty) + await model.getMasterLookup(MasterKeysService.AllergySeverity); + model.patientAllergiesList.forEach((element) { MasterKeyModel selectedAllergy = model.getOneMasterKey( masterKeys: MasterKeysService.Allergies, @@ -85,6 +147,9 @@ class _UpdateSubjectivePageState extends State { widget.myAllergiesList.add(mySelectedAllergy); }); } + + await getHistory(model); + }, builder: (_, model, w) => AppScaffold( isShowAppBar: false, From 46043efb42a37c4a6f2ed51e4ccae764c749998d Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Thu, 31 Dec 2020 22:28:02 +0200 Subject: [PATCH 11/15] Finish Update objective code Page --- lib/core/service/SOAP_service.dart | 12 ++- lib/core/viewModel/SOAP_view_model.dart | 10 +- .../GetChiefComplaintReqModel.dart | 25 +++++ .../SOAP/GetPhysicalExamListResModel.dart | 64 +++++++++++++ lib/models/SOAP/GetPhysicalExamReqModel.dart | 32 +++++++ .../subjective/update_subjective_page.dart | 38 ++++---- .../soap_update/update_objective_page.dart | 92 ++++++++++++------- 7 files changed, 218 insertions(+), 55 deletions(-) create mode 100644 lib/models/SOAP/ChiefComplaint/GetChiefComplaintReqModel.dart create mode 100644 lib/models/SOAP/GetPhysicalExamListResModel.dart create mode 100644 lib/models/SOAP/GetPhysicalExamReqModel.dart diff --git a/lib/core/service/SOAP_service.dart b/lib/core/service/SOAP_service.dart index 9679293b..a7cc33ce 100644 --- a/lib/core/service/SOAP_service.dart +++ b/lib/core/service/SOAP_service.dart @@ -4,6 +4,8 @@ import 'package:doctor_app_flutter/models/SOAP/GeneralGetReqForSOAP.dart'; import 'package:doctor_app_flutter/models/SOAP/GetAllergiesResModel.dart'; import 'package:doctor_app_flutter/models/SOAP/GetHistoryReqModel.dart'; import 'package:doctor_app_flutter/models/SOAP/GetHistoryResModel.dart'; +import 'package:doctor_app_flutter/models/SOAP/GetPhysicalExamListResModel.dart'; +import 'package:doctor_app_flutter/models/SOAP/GetPhysicalExamReqModel.dart'; import 'package:doctor_app_flutter/models/SOAP/get_Allergies_request_model.dart'; import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; import 'package:doctor_app_flutter/models/SOAP/post_allergy_request_model.dart'; @@ -20,6 +22,7 @@ class SOAPService extends LookupService { List patientChiefComplaintList = []; List patientAllergiesList = []; List patientHistoryList = []; + List patientPhysicalExamList = []; Future getAllergies(GetAllergiesRequestModel getAllergiesRequestModel) async { await baseAppClient.post( @@ -234,15 +237,18 @@ class SOAPService extends LookupService { } Future getPatientPhysicalExam( - PostPhysicalExamRequestModel getPatientPhysicalExamRequestModel) async { + GetPhysicalExamReqModel getPhysicalExamReqModel) async { hasError = false; await baseAppClient.post (GET_PHYSICAL_EXAM, onSuccess: (dynamic response, int statusCode) { - print("Success"); + patientPhysicalExamList.clear(); + response['PhysicalExamList']['entityList'].forEach((v) { + patientPhysicalExamList.add(GetPhysicalExamResModel.fromJson(v)); + }); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; - }, body: getPatientPhysicalExamRequestModel.toJson()); + }, body: getPhysicalExamReqModel.toJson()); } Future getPatientProgressNote( diff --git a/lib/core/viewModel/SOAP_view_model.dart b/lib/core/viewModel/SOAP_view_model.dart index 8a3b787e..849d2333 100644 --- a/lib/core/viewModel/SOAP_view_model.dart +++ b/lib/core/viewModel/SOAP_view_model.dart @@ -6,6 +6,8 @@ import 'package:doctor_app_flutter/models/SOAP/GeneralGetReqForSOAP.dart'; import 'package:doctor_app_flutter/models/SOAP/GetAllergiesResModel.dart'; import 'package:doctor_app_flutter/models/SOAP/GetHistoryReqModel.dart'; import 'package:doctor_app_flutter/models/SOAP/GetHistoryResModel.dart'; +import 'package:doctor_app_flutter/models/SOAP/GetPhysicalExamListResModel.dart'; +import 'package:doctor_app_flutter/models/SOAP/GetPhysicalExamReqModel.dart'; import 'package:doctor_app_flutter/models/SOAP/get_Allergies_request_model.dart'; import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; import 'package:doctor_app_flutter/models/SOAP/post_allergy_request_model.dart'; @@ -54,13 +56,15 @@ class SOAPViewModel extends BaseViewModel { List get listOfICD10 => _SOAPService.listOfICD10; - List get chiefComplaintList => + List get patientChiefComplaintList => _SOAPService.patientChiefComplaintList; List get patientAllergiesList => _SOAPService.patientAllergiesList; List get patientHistoryList => _SOAPService.patientHistoryList; + List get patientPhysicalExamList => + _SOAPService.patientPhysicalExamList; Future getAllergies(GetAllergiesRequestModel getAllergiesRequestModel) async { setState(ViewState.Busy); @@ -235,9 +239,9 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getPatientPhysicalExam(PostPhysicalExamRequestModel getPatientPhysicalExamRequestModel) async { + Future getPatientPhysicalExam(GetPhysicalExamReqModel getPhysicalExamReqModel) async { setState(ViewState.Busy); - await _SOAPService.getPatientPhysicalExam(getPatientPhysicalExamRequestModel); + await _SOAPService.getPatientPhysicalExam(getPhysicalExamReqModel); if (_SOAPService.hasError) { error = _SOAPService.error; setState(ViewState.Busy); diff --git a/lib/models/SOAP/ChiefComplaint/GetChiefComplaintReqModel.dart b/lib/models/SOAP/ChiefComplaint/GetChiefComplaintReqModel.dart new file mode 100644 index 00000000..68ab6c40 --- /dev/null +++ b/lib/models/SOAP/ChiefComplaint/GetChiefComplaintReqModel.dart @@ -0,0 +1,25 @@ +class GetChiefComplaintReqModel { + int patientMRN; + int appointmentNo; + int episodeId; + int episodeID; + + GetChiefComplaintReqModel( + {this.patientMRN, this.appointmentNo, this.episodeId, this.episodeID}); + + GetChiefComplaintReqModel.fromJson(Map json) { + patientMRN = json['PatientMRN']; + appointmentNo = json['AppointmentNo']; + episodeId = json['EpisodeId']; + episodeID = json['EpisodeID']; + } + + Map toJson() { + final Map data = new Map(); + data['PatientMRN'] = this.patientMRN; + data['AppointmentNo'] = this.appointmentNo; + data['EpisodeId'] = this.episodeId; + data['EpisodeID'] = this.episodeID; + return data; + } +} diff --git a/lib/models/SOAP/GetPhysicalExamListResModel.dart b/lib/models/SOAP/GetPhysicalExamListResModel.dart new file mode 100644 index 00000000..f9b2f44f --- /dev/null +++ b/lib/models/SOAP/GetPhysicalExamListResModel.dart @@ -0,0 +1,64 @@ +class GetPhysicalExamResModel { + int appointmentNo; + int createdBy; + String createdOn; + int editedBy; + String editedOn; + int episodeId; + int examId; + int examType; + bool isAbnormal; + bool isNormal; + bool notExamined; + int patientMRN; + String remarks; + + GetPhysicalExamResModel( + {this.appointmentNo, + this.createdBy, + this.createdOn, + this.editedBy, + this.editedOn, + this.episodeId, + this.examId, + this.examType, + this.isAbnormal, + this.isNormal, + this.notExamined, + this.patientMRN, + this.remarks}); + + GetPhysicalExamResModel.fromJson(Map json) { + appointmentNo = json['appointmentNo']; + createdBy = json['createdBy']; + createdOn = json['createdOn']; + editedBy = json['editedBy']; + editedOn = json['editedOn']; + episodeId = json['episodeId']; + examId = json['examId']; + examType = json['examType']; + isAbnormal = json['isAbnormal']; + isNormal = json['isNormal']; + notExamined = json['notExamined']; + patientMRN = json['patientMRN']; + remarks = json['remarks']; + } + + Map toJson() { + final Map data = new Map(); + data['appointmentNo'] = this.appointmentNo; + data['createdBy'] = this.createdBy; + data['createdOn'] = this.createdOn; + data['editedBy'] = this.editedBy; + data['editedOn'] = this.editedOn; + data['episodeId'] = this.episodeId; + data['examId'] = this.examId; + data['examType'] = this.examType; + data['isAbnormal'] = this.isAbnormal; + data['isNormal'] = this.isNormal; + data['notExamined'] = this.notExamined; + data['patientMRN'] = this.patientMRN; + data['remarks'] = this.remarks; + return data; + } +} diff --git a/lib/models/SOAP/GetPhysicalExamReqModel.dart b/lib/models/SOAP/GetPhysicalExamReqModel.dart new file mode 100644 index 00000000..ce045c22 --- /dev/null +++ b/lib/models/SOAP/GetPhysicalExamReqModel.dart @@ -0,0 +1,32 @@ +class GetPhysicalExamReqModel { + int patientMRN; + int appointmentNo; + String episodeID; + String from; + String to; + + GetPhysicalExamReqModel( + {this.patientMRN, + this.appointmentNo, + this.episodeID, + this.from, + this.to}); + + GetPhysicalExamReqModel.fromJson(Map json) { + patientMRN = json['PatientMRN']; + appointmentNo = json['AppointmentNo']; + episodeID = json['EpisodeID']; + from = json['From']; + to = json['To']; + } + + Map toJson() { + final Map data = new Map(); + data['PatientMRN'] = this.patientMRN; + data['AppointmentNo'] = this.appointmentNo; + data['EpisodeID'] = this.episodeID; + data['From'] = this.from; + data['To'] = this.to; + return data; + } +} diff --git a/lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart b/lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart index 33a691cb..cbdc12b0 100644 --- a/lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart +++ b/lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart @@ -3,6 +3,7 @@ import 'package:doctor_app_flutter/config/config.dart'; 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/viewModel/SOAP_view_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/ChiefComplaint/GetChiefComplaintReqModel.dart'; import 'package:doctor_app_flutter/models/SOAP/GeneralGetReqForSOAP.dart'; import 'package:doctor_app_flutter/models/SOAP/GetHistoryReqModel.dart'; import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; @@ -117,12 +118,12 @@ class _UpdateSubjectivePageState extends State { patientMRN: widget.patientInfo.patientMRN, episodeId: widget.patientInfo.episodeNo, appointmentNo: widget.patientInfo.appointmentNo); - + GetChiefComplaintReqModel getChiefComplaintReqModel = GetChiefComplaintReqModel(); await model.getPatientChiefComplaint(generalGetReqForSOAP); - if (model.chiefComplaintList.isNotEmpty) { + if (model.patientChiefComplaintList.isNotEmpty) { complaintsController.text = - model.chiefComplaintList[0].chiefComplaint; - illnessController.text = model.chiefComplaintList[0].hopi; + model.patientChiefComplaintList[0].chiefComplaint; + illnessController.text = model.patientChiefComplaintList[0].hopi; } await model.getPatientAllergy(generalGetReqForSOAP); if (model.patientAllergiesList.isNotEmpty) { @@ -499,19 +500,22 @@ class _UpdateSubjectivePageState extends State { if(formKey.currentState.validate()){ PostChiefComplaintRequestModel postChiefComplaintRequestModel = //TODO: make static value dynamic - new PostChiefComplaintRequestModel( - patientMRN: widget.patientInfo.patientMRN, - episodeID: widget.patientInfo.episodeNo, - appointmentNo: widget.patientInfo.appointmentNo, - chiefComplaint: complaintsController.text, - currentMedication: " currentMedication ", - hopi: illnessController.text, - isLactation: false, - ispregnant: false, - numberOfWeeks: 22); - - await model.patchChiefComplaint(postChiefComplaintRequestModel); - + new PostChiefComplaintRequestModel( + patientMRN: widget.patientInfo.patientMRN, + episodeID: widget.patientInfo.episodeNo, + appointmentNo: widget.patientInfo.appointmentNo, + chiefComplaint: complaintsController.text, + currentMedication: " currentMedication ", + hopi: illnessController.text, + isLactation: false, + ispregnant: true, + numberOfWeeks: 22); + if (model.patientChiefComplaintList.isEmpty) { + // TODO: make it postChiefComplaint after it start to work + await model.postChiefComplaint(postChiefComplaintRequestModel); + } else { + await model.patchChiefComplaint(postChiefComplaintRequestModel); + } } } diff --git a/lib/widgets/patients/profile/soap_update/update_objective_page.dart b/lib/widgets/patients/profile/soap_update/update_objective_page.dart index a073c578..d7123678 100644 --- a/lib/widgets/patients/profile/soap_update/update_objective_page.dart +++ b/lib/widgets/patients/profile/soap_update/update_objective_page.dart @@ -3,6 +3,7 @@ import 'package:doctor_app_flutter/config/config.dart'; 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/viewModel/SOAP_view_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/GetPhysicalExamReqModel.dart'; import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; import 'package:doctor_app_flutter/models/SOAP/my_selected_examination.dart'; import 'package:doctor_app_flutter/models/SOAP/post_physical_exam_request_model.dart'; @@ -53,40 +54,67 @@ class _UpdateObjectivePageState extends State { final screenSize = MediaQuery.of(context).size; return BaseView( - // onModelReady: (model) => model.getMasterLookup(MasterKeysService.Allergies), + onModelReady: (model) async { + GetPhysicalExamReqModel getPhysicalExamReqModel = + GetPhysicalExamReqModel( + patientMRN: widget.patientInfo.patientMRN, + episodeID: widget.patientInfo.episodeNo.toString(), + appointmentNo: widget.patientInfo.appointmentNo); + + await model.getPatientPhysicalExam(getPhysicalExamReqModel); + if (model.patientPhysicalExamList.isNotEmpty) { + if (model.physicalExaminationList.length == 0) { + await model + .getMasterLookup(MasterKeysService.PhysicalExamination); + } + model.patientPhysicalExamList.forEach((element) { + MasterKeyModel examMaster = model.getOneMasterKey( + masterKeys: MasterKeysService.PhysicalExamination, + id: element.examId, + ); + MySelectedExamination tempEam = MySelectedExamination( + selectedExamination: examMaster, + remark: element.remarks, + isNormal: element.isNormal, + isAbnormal: element.isAbnormal); + widget.mySelectedExamination.add(tempEam); + }); + } + }, builder: (_, model, w) => AppScaffold( - isShowAppBar: false, - body: SingleChildScrollView( - physics: ScrollPhysics(), - child: Center( - child: FractionallySizedBox( - widthFactor: 0.9, - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - SizedBox( - height: 30, - ), - HeaderBodyExpandableNotifier( - headerWidget: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( + isShowAppBar: false, + body: SingleChildScrollView( + physics: ScrollPhysics(), + child: Center( + child: FractionallySizedBox( + widthFactor: 0.9, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + SizedBox( + height: 30, + ), + HeaderBodyExpandableNotifier( + headerWidget: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Texts('Physical/System Examination', - variant: - isSysExaminationExpand ? "bodyText" : '', - bold: isSysExaminationExpand ? true : false, - color: Colors.black), - Icon( - FontAwesomeIcons.asterisk, - color: AppGlobal.appPrimaryColor, - size: 12, - ) - ], - ), - InkWell( - onTap: () { + Row( + children: [ + Texts('Physical/System Examination', + variant: isSysExaminationExpand + ? "bodyText" + : '', + bold: isSysExaminationExpand ? true : false, + color: Colors.black), + Icon( + FontAwesomeIcons.asterisk, + color: AppGlobal.appPrimaryColor, + size: 12, + ) + ], + ), + InkWell( + onTap: () { setState(() { isSysExaminationExpand = !isSysExaminationExpand; From 311bee5136b97af425fd7468827fa01dfadb4c86 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Thu, 31 Dec 2020 22:38:46 +0200 Subject: [PATCH 12/15] try to fix get --- lib/core/service/SOAP_service.dart | 5 +++-- lib/core/viewModel/SOAP_view_model.dart | 5 +++-- .../soap_update/subjective/update_subjective_page.dart | 9 +++++++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/core/service/SOAP_service.dart b/lib/core/service/SOAP_service.dart index a7cc33ce..65b6d0cc 100644 --- a/lib/core/service/SOAP_service.dart +++ b/lib/core/service/SOAP_service.dart @@ -1,4 +1,5 @@ import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/models/SOAP/ChiefComplaint/GetChiefComplaintReqModel.dart'; import 'package:doctor_app_flutter/models/SOAP/ChiefComplaint/GetChiefComplaintResModel.dart'; import 'package:doctor_app_flutter/models/SOAP/GeneralGetReqForSOAP.dart'; import 'package:doctor_app_flutter/models/SOAP/GetAllergiesResModel.dart'; @@ -221,7 +222,7 @@ class SOAPService extends LookupService { } Future getPatientChiefComplaint( - GeneralGetReqForSOAP generalGetReqForSOAP) async { + GetChiefComplaintReqModel getChiefComplaintReqModel) async { hasError = false; await baseAppClient.post (GET_CHIEF_COMPLAINT, onSuccess: (dynamic response, int statusCode) { @@ -233,7 +234,7 @@ class SOAPService extends LookupService { }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; - }, body: generalGetReqForSOAP.toJson()); + }, body: getChiefComplaintReqModel.toJson()); } Future getPatientPhysicalExam( diff --git a/lib/core/viewModel/SOAP_view_model.dart b/lib/core/viewModel/SOAP_view_model.dart index 849d2333..4226643a 100644 --- a/lib/core/viewModel/SOAP_view_model.dart +++ b/lib/core/viewModel/SOAP_view_model.dart @@ -1,6 +1,7 @@ import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/service/SOAP_service.dart'; +import 'package:doctor_app_flutter/models/SOAP/ChiefComplaint/GetChiefComplaintReqModel.dart'; import 'package:doctor_app_flutter/models/SOAP/ChiefComplaint/GetChiefComplaintResModel.dart'; import 'package:doctor_app_flutter/models/SOAP/GeneralGetReqForSOAP.dart'; import 'package:doctor_app_flutter/models/SOAP/GetAllergiesResModel.dart'; @@ -229,9 +230,9 @@ class SOAPViewModel extends BaseViewModel { } Future getPatientChiefComplaint( - GeneralGetReqForSOAP generalGetReqForSOAP) async { + GetChiefComplaintReqModel getChiefComplaintReqModel) async { setState(ViewState.Busy); - await _SOAPService.getPatientChiefComplaint(generalGetReqForSOAP); + await _SOAPService.getPatientChiefComplaint(getChiefComplaintReqModel); if (_SOAPService.hasError) { error = _SOAPService.error; setState(ViewState.Busy); diff --git a/lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart b/lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart index cbdc12b0..1339c2f2 100644 --- a/lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart +++ b/lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart @@ -118,8 +118,13 @@ class _UpdateSubjectivePageState extends State { patientMRN: widget.patientInfo.patientMRN, episodeId: widget.patientInfo.episodeNo, appointmentNo: widget.patientInfo.appointmentNo); - GetChiefComplaintReqModel getChiefComplaintReqModel = GetChiefComplaintReqModel(); - await model.getPatientChiefComplaint(generalGetReqForSOAP); + GetChiefComplaintReqModel getChiefComplaintReqModel = + GetChiefComplaintReqModel( + patientMRN: widget.patientInfo.patientMRN, + appointmentNo: widget.patientInfo.appointmentNo, + episodeId: widget.patientInfo.episodeNo, + episodeID: widget.patientInfo.episodeNo); + await model.getPatientChiefComplaint(getChiefComplaintReqModel); if (model.patientChiefComplaintList.isNotEmpty) { complaintsController.text = model.patientChiefComplaintList[0].chiefComplaint; From d5bde6228a53969d3a7f3f93ecb04234fc7047b2 Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Thu, 31 Dec 2020 23:29:31 +0200 Subject: [PATCH 13/15] add search in update assessment page --- .../soap_update/update_assessment_page.dart | 65 ++++++++----------- 1 file changed, 26 insertions(+), 39 deletions(-) diff --git a/lib/widgets/patients/profile/soap_update/update_assessment_page.dart b/lib/widgets/patients/profile/soap_update/update_assessment_page.dart index 556949e8..61c7f20b 100644 --- a/lib/widgets/patients/profile/soap_update/update_assessment_page.dart +++ b/lib/widgets/patients/profile/soap_update/update_assessment_page.dart @@ -1,3 +1,4 @@ +import 'package:autocomplete_textfield/autocomplete_textfield.dart'; import 'package:doctor_app_flutter/client/base_app_client.dart'; import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; @@ -377,6 +378,7 @@ class _AddAssessmentDetailsState extends State { TextEditingController remarkController = TextEditingController(); TextEditingController appointmentIdController = TextEditingController( text: "234567"); + GlobalKey key = new GlobalKey>(); @override Widget build(BuildContext context) { @@ -385,7 +387,7 @@ class _AddAssessmentDetailsState extends State { .of(context) .size; InputDecoration textFieldSelectorDecoration(String hintText, - String selectedText, bool isDropDown) { + String selectedText, bool isDropDown,{IconData icon}) { //TODO: make one Input InputDecoration for all return InputDecoration( focusedBorder: OutlineInputBorder( @@ -401,7 +403,7 @@ class _AddAssessmentDetailsState extends State { borderRadius: BorderRadius.circular(8), ), hintText: selectedText != null ? selectedText : hintText, - suffixIcon: isDropDown ? Icon(Icons.arrow_drop_down) : null, + suffixIcon: isDropDown ? Icon(icon??Icons.arrow_drop_down) : null, hintStyle: TextStyle( fontSize: 14, color: Colors.grey.shade600, @@ -418,9 +420,9 @@ class _AddAssessmentDetailsState extends State { if (model.listOfDiagnosisType.length == 0) { await model.getMasterLookup(MasterKeysService.DiagnosisType); } - // if (model.listOfICD10.length == 0) { - // await model.getMasterLookup(MasterKeysService.ICD10); - // } + if (model.listOfICD10.length == 0) { + await model.getMasterLookup(MasterKeysService.ICD10); + } }, builder: (_, model, w) => AppScaffold( @@ -472,43 +474,28 @@ class _AddAssessmentDetailsState extends State { child: InkWell( onTap: model.listOfDiagnosisType != null ? () { - MasterKeyDailog dialog = MasterKeyDailog( - isICD: true, - list: model.listOfDiagnosisType, - selectedValue: widget - .mySelectedAssessment - .selectedICD, - okText: TranslationBase - .of(context) - .ok, - okFunction: - (MasterKeyModel selectedValue) { - setState(() { - widget.mySelectedAssessment - .selectedICD = - selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); + setState(() { + widget.mySelectedAssessment.selectedICD = null; + }); } : null, - child: TextField( + child: widget.mySelectedAssessment.selectedICD == null ? AutoCompleteTextField( + decoration: textFieldSelectorDecoration("Name or ICD", widget.mySelectedAssessment.selectedICD != null ? widget.mySelectedAssessment.selectedICD.nameEn : null, true,icon: EvaIcons.search), + itemSubmitted: (item) => setState(() => widget.mySelectedAssessment.selectedICD = item), + key: key, + suggestions: model.listOfICD10, + itemBuilder: (context, suggestion) => new Padding( + child:Texts( suggestion.description +" / "+ suggestion.code.toString()), + padding: EdgeInsets.all(8.0)), + itemSorter: (a, b) => 1, + itemFilter: (suggestion, input) => + suggestion.description.toLowerCase().startsWith(input.toLowerCase()) ||suggestion.description.toLowerCase().startsWith(input.toLowerCase()) + ||suggestion.code.toLowerCase().startsWith(input.toLowerCase()) + , + ): TextField( decoration: textFieldSelectorDecoration( - "Name / ICD", - widget.mySelectedAssessment - .selectedICD != - null - ? widget.mySelectedAssessment - .selectedICD.nameEn - : null, - true), + widget.mySelectedAssessment.selectedICD != null ? widget.mySelectedAssessment.selectedICD.code :"Name or ICD", + widget.mySelectedAssessment.selectedICD != null ? widget.mySelectedAssessment.selectedICD.nameEn : null, true,icon: EvaIcons.search), enabled: false, ), ), From 1af5f1040fbeca3b36b6f4895e061af9270871d2 Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Thu, 31 Dec 2020 23:45:55 +0200 Subject: [PATCH 14/15] add search in soap update --- .../SOAP/subjective/add_allergies_widget.dart | 3 +- .../subjective/update_allergies_widget.dart | 53 ++- .../subjective/update_history_widget.dart | 317 +++--------------- .../soap_update/update_objective_page.dart | 110 ++---- 4 files changed, 102 insertions(+), 381 deletions(-) diff --git a/lib/widgets/patients/profile/SOAP/subjective/add_allergies_widget.dart b/lib/widgets/patients/profile/SOAP/subjective/add_allergies_widget.dart index 0a4ce08e..43748f3d 100644 --- a/lib/widgets/patients/profile/SOAP/subjective/add_allergies_widget.dart +++ b/lib/widgets/patients/profile/SOAP/subjective/add_allergies_widget.dart @@ -242,7 +242,8 @@ class _AddAllergiesState extends State { ), SizedBox( height: 10, - ), Container( + ), + Container( height: screenSize.height * 0.070, child: InkWell( onTap: model.allergySeverityList != null diff --git a/lib/widgets/patients/profile/soap_update/subjective/update_allergies_widget.dart b/lib/widgets/patients/profile/soap_update/subjective/update_allergies_widget.dart index d7bbd0af..fa6b8acb 100644 --- a/lib/widgets/patients/profile/soap_update/subjective/update_allergies_widget.dart +++ b/lib/widgets/patients/profile/soap_update/subjective/update_allergies_widget.dart @@ -1,6 +1,8 @@ +import 'package:autocomplete_textfield/autocomplete_textfield.dart'; import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; import 'package:doctor_app_flutter/models/SOAP/my_selected_allergy.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; @@ -14,6 +16,7 @@ import 'package:doctor_app_flutter/widgets/shared/dialogs/master_key_dailog.dart import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; class UpdateAllergiesWidget extends StatefulWidget { final List myAllergiesList; @@ -144,10 +147,11 @@ class _AddAllergiesState extends State { MasterKeyModel _selectedAllergySeverity; MasterKeyModel _selectedAllergy; TextEditingController remarkController = TextEditingController(); + GlobalKey key = new GlobalKey>(); InputDecoration textFieldSelectorDecoration(String hintText, - String selectedText, bool isDropDown) { + String selectedText, bool isDropDown,{IconData icon}) { return InputDecoration( focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), @@ -162,7 +166,7 @@ class _AddAllergiesState extends State { borderRadius: BorderRadius.circular(8), ), hintText: selectedText != null ? selectedText : hintText, - suffixIcon: isDropDown ? Icon(Icons.arrow_drop_down) : null, + suffixIcon: isDropDown ? Icon(icon ?? Icons.arrow_drop_down) : null, hintStyle: TextStyle( fontSize: 14, color: Colors.grey.shade600, @@ -172,6 +176,7 @@ class _AddAllergiesState extends State { @override Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); final screenSize = MediaQuery .of(context) .size; @@ -214,40 +219,32 @@ class _AddAllergiesState extends State { child: InkWell( onTap: model.allergiesList != null ? () { - MasterKeyDailog dialog = MasterKeyDailog( - list: model.allergiesList, - okText: TranslationBase - .of(context) - .ok, - okFunction: (MasterKeyModel selectedValue) { - setState(() { - _selectedAllergy = selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); + setState(() { + _selectedAllergy = null; + }); } : null, - child: TextField( - decoration: textFieldSelectorDecoration( - "Select Allergy", - _selectedAllergy != null - ? _selectedAllergy.nameEn - : null, - true), + child: _selectedAllergy==null? AutoCompleteTextField( + decoration: textFieldSelectorDecoration("Select Allergy", _selectedAllergy != null ? _selectedAllergy.nameEn : null, true,icon: EvaIcons.search), + itemSubmitted: (item) => setState(() => _selectedAllergy = item), + key: key, + suggestions: model.allergiesList, + itemBuilder: (context, suggestion) => new Padding( + child:Texts( projectViewModel.isArabic? suggestion.nameAr: suggestion.nameEn), + padding: EdgeInsets.all(8.0)), + itemSorter: (a, b) => 1, + itemFilter: (suggestion, input) => + suggestion.nameAr.toLowerCase().startsWith(input.toLowerCase()) ||suggestion.nameEn.toLowerCase().startsWith(input.toLowerCase()), + ):TextField( + decoration: textFieldSelectorDecoration("Select Allergy", _selectedAllergy != null ? _selectedAllergy.nameEn : null, true,icon: EvaIcons.search), enabled: false, ), ), ), SizedBox( height: 10, - ), Container( + ), + Container( height: screenSize.height * 0.070, child: InkWell( onTap: model.allergySeverityList != null diff --git a/lib/widgets/patients/profile/soap_update/subjective/update_history_widget.dart b/lib/widgets/patients/profile/soap_update/subjective/update_history_widget.dart index d8f2b888..5e033127 100644 --- a/lib/widgets/patients/profile/soap_update/subjective/update_history_widget.dart +++ b/lib/widgets/patients/profile/soap_update/subjective/update_history_widget.dart @@ -10,6 +10,7 @@ import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/divider_with_spaces_around.dart'; +import 'package:doctor_app_flutter/widgets/shared/master_key_checkbox_search_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:flutter/material.dart'; @@ -280,273 +281,59 @@ class _AddHistoryDialogState extends State { }, scrollDirection: Axis.horizontal, children: [ - Container( - child: Column( - children: [ - NetworkBaseView( - baseViewModel: model, - child: Container( - height: - MediaQuery.of(context).size.height * 0.5, - child: Center( - child: Container( - margin: EdgeInsets.only(top: 15), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - color: Colors.white), - child: ListView( - children: [ - Column( - children: model.historyFamilyList - .map((historyInfo) { - return Column( - children: [ - Row( - children: [ - Checkbox( - value: isServiceSelected( - historyInfo), - activeColor: - Colors.red[800], - onChanged: - (bool newValue) { - setState(() { - if (isServiceSelected( - historyInfo - )) { - widget - .removeHistory( - historyInfo - ); - } - else { - widget - .myHistoryList - .add( - historyInfo); - } - }); - }), - Expanded( - child: Padding( - padding: - const EdgeInsets - .symmetric( - horizontal: 10, - vertical: 0), - child: Texts( - historyInfo.nameEn, - variant: "bodyText", - bold: true, - color: - Colors.black), - ), - ), - ], - ), - DividerWithSpacesAround(), - ], - ); - }).toList(), - ), - ], - ), - )), - ), - ), - SizedBox( - height: 10, - ), - if (model.state == ViewState.Idle) - AppButton( - title: "Add SELECTED HISTORIES" - .toUpperCase(), - onPressed: () { - widget.addSelectedHistories(); - }, - ), - ], - ), + MasterKeyCheckboxSearchWidget( + model: model, + masterList: model.historyFamilyList, + removeHistory: (history){ + setState(() { + widget.removeHistory(history); + }); + }, + addHistory: (history){ + setState(() { + widget.myHistoryList.add(history); + }); + }, + addSelectedHistories: (){ + widget.addSelectedHistories(); + }, + isServiceSelected: (master) =>isServiceSelected(master), ), - Container( - child: Column( - children: [ - NetworkBaseView( - baseViewModel: model, - child: Container( - height: - MediaQuery.of(context).size.height * 0.5, - child: Center( - child: Container( - margin: EdgeInsets.only(top: 15), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - color: Colors.white), - child: ListView( - children: [ - Column( - children: model.mergeHistorySurgicalWithHistorySportList - .map((historyInfo) { - return Column( - children: [ - Row( - children: [ - Checkbox( - value: isServiceSelected( - historyInfo), - activeColor: - Colors.red[800], - onChanged: - ( - bool newValue) { - setState(() { - if (isServiceSelected( - historyInfo - )) { - widget - .removeHistory( - historyInfo - ); - } - else { - widget - .myHistoryList - .add( - historyInfo); - } - }); - }), - Expanded( - child: Padding( - padding: - const EdgeInsets - .symmetric( - horizontal: 10, - vertical: 0), - child: Texts( - historyInfo.nameEn, - variant: "bodyText", - bold: true, - color: - Colors.black), - ), - ), - ], - ), - DividerWithSpacesAround(), - ], - ); - }).toList(), - ), - ], - ), - )), - ), - ), - SizedBox( - height: 10, - ), - if (model.state == ViewState.Idle) - AppButton( - title: "Add SELECTED HISTORIES" - .toUpperCase(), - onPressed: () { - widget.addSelectedHistories(); - }, - ), - ], - ), + MasterKeyCheckboxSearchWidget( + model: model, + masterList: model.mergeHistorySurgicalWithHistorySportList, + removeHistory: (history){ + setState(() { + widget.removeHistory(history); + }); + }, + addHistory: (history){ + setState(() { + widget.myHistoryList.add(history); + }); + }, + addSelectedHistories: (){ + widget.addSelectedHistories(); + }, + isServiceSelected: (master) =>isServiceSelected(master), ), - Container( - child: Column( - children: [ - NetworkBaseView( - baseViewModel: model, - child: Container( - height: - MediaQuery.of(context).size.height * 0.5, - child: Center( - child: Container( - margin: EdgeInsets.only(top: 15), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - color: Colors.white), - child: ListView( - children: [ - Column( - children: model.historyMedicalList - .map((historyInfo) { - return Column( - children: [ - Row( - children: [ - Checkbox( - value: isServiceSelected( - historyInfo), - activeColor: - Colors.red[800], - onChanged: - ( - bool newValue) { - setState(() { - if (isServiceSelected( - historyInfo - )) { - widget - .removeHistory( - historyInfo - ); - } - else { - widget - .myHistoryList - .add( - historyInfo); - } - }); - }), - Expanded( - child: Padding( - padding: - const EdgeInsets - .symmetric( - horizontal: 10, - vertical: 0), - child: Texts( - historyInfo.nameEn, - variant: "bodyText", - bold: true, - color: - Colors.black), - ), - ), - ], - ), - DividerWithSpacesAround(), - ], - ); - }).toList(), - ), - ], - ), - )), - ), - ), - SizedBox( - height: 10, - ), - if (model.state == ViewState.Idle) - AppButton( - title: "Add SELECTED HISTORIES" - .toUpperCase(), - onPressed: () { - setState(() { - widget.addSelectedHistories(); - }); - }, - ), - ], - ), + MasterKeyCheckboxSearchWidget( + model: model, + masterList: model.historyMedicalList, + removeHistory: (history){ + setState(() { + widget.removeHistory(history); + }); + }, + addHistory: (history){ + setState(() { + widget.myHistoryList.add(history); + }); + }, + addSelectedHistories: (){ + widget.addSelectedHistories(); + }, + isServiceSelected: (master) =>isServiceSelected(master), ), ], ), diff --git a/lib/widgets/patients/profile/soap_update/update_objective_page.dart b/lib/widgets/patients/profile/soap_update/update_objective_page.dart index d7123678..b43db98d 100644 --- a/lib/widgets/patients/profile/soap_update/update_objective_page.dart +++ b/lib/widgets/patients/profile/soap_update/update_objective_page.dart @@ -17,6 +17,7 @@ import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/divider_with_spaces_around.dart'; import 'package:doctor_app_flutter/widgets/shared/expandable-widget-header-body.dart'; +import 'package:doctor_app_flutter/widgets/shared/master_key_checkbox_search_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:flutter/material.dart'; @@ -497,96 +498,31 @@ class _AddExaminationDailogState extends State { ), NetworkBaseView( baseViewModel: model, - child: Container( - height: - MediaQuery - .of(context) - .size - .height * 0.5, - child: Center( - child: Container( - margin: EdgeInsets.only(top: 15), - decoration: BoxDecoration( - borderRadius: BorderRadius - .circular(12), - color: Colors.white), - child: ListView( - children: [ - Column( - children: model - .physicalExaminationList - .map((examinationInfo) { - return Column( - children: [ - Row( - children: [ - Checkbox( - value: isServiceSelected( - examinationInfo), - activeColor: - Colors.red[800], - onChanged: - ( - bool newValue) { - setState(() { - if (isServiceSelected( - examinationInfo - )) { - widget - .removeExamination( - examinationInfo - ); - } - else { - MySelectedExamination mySelectedExamination = new MySelectedExamination( - selectedExamination: examinationInfo - ); - widget - .mySelectedExamination - .add( - mySelectedExamination); - } - }); - }), - Expanded( - child: Padding( - padding: - const EdgeInsets - .symmetric( - horizontal: 10, - vertical: 0), - child: Texts( - examinationInfo - .nameEn, - variant: "bodyText", - bold: true, - color: - Colors.black), - ), - ), - ], - ), - DividerWithSpacesAround(), - ], - ); - }).toList(), - ), - ], - ), - )), - ), - ), - SizedBox( - height: 10, - ), - if (model.state == ViewState.Idle) - AppButton( - title: "Add SELECTED Examinations" - .toUpperCase(), - onPressed: () { + child: MasterKeyCheckboxSearchWidget( + model: model, + masterList: model.physicalExaminationList, + removeHistory: (history){ + setState(() { + widget.removeExamination(history); + }); + }, + addHistory: (history){ + setState(() { + MySelectedExamination mySelectedExamination = new MySelectedExamination( + selectedExamination: history + ); + widget + .mySelectedExamination + .add( + mySelectedExamination); + }); + }, + addSelectedHistories: (){ widget.addSelectedExamination(); }, + isServiceSelected: (master) =>isServiceSelected(master), ), + ), ]), ))), )), From 4caf40a2ab4f368e00b39a5ca3f98b715bcb237c Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Thu, 31 Dec 2020 23:49:18 +0200 Subject: [PATCH 15/15] finish plan page --- lib/core/service/SOAP_service.dart | 12 ++- lib/core/viewModel/SOAP_view_model.dart | 13 ++- .../SOAP/GetGetProgressNoteReqModel.dart | 40 ++++++++++ .../SOAP/GetGetProgressNoteResModel.dart | 25 ++++++ .../soap_update/update_objective_page.dart | 2 + .../profile/soap_update/update_plan_page.dart | 79 +++++++++++-------- 6 files changed, 133 insertions(+), 38 deletions(-) create mode 100644 lib/models/SOAP/GetGetProgressNoteReqModel.dart create mode 100644 lib/models/SOAP/GetGetProgressNoteResModel.dart diff --git a/lib/core/service/SOAP_service.dart b/lib/core/service/SOAP_service.dart index 65b6d0cc..09530d50 100644 --- a/lib/core/service/SOAP_service.dart +++ b/lib/core/service/SOAP_service.dart @@ -3,6 +3,8 @@ import 'package:doctor_app_flutter/models/SOAP/ChiefComplaint/GetChiefComplaintR import 'package:doctor_app_flutter/models/SOAP/ChiefComplaint/GetChiefComplaintResModel.dart'; import 'package:doctor_app_flutter/models/SOAP/GeneralGetReqForSOAP.dart'; import 'package:doctor_app_flutter/models/SOAP/GetAllergiesResModel.dart'; +import 'package:doctor_app_flutter/models/SOAP/GetGetProgressNoteReqModel.dart'; +import 'package:doctor_app_flutter/models/SOAP/GetGetProgressNoteResModel.dart'; import 'package:doctor_app_flutter/models/SOAP/GetHistoryReqModel.dart'; import 'package:doctor_app_flutter/models/SOAP/GetHistoryResModel.dart'; import 'package:doctor_app_flutter/models/SOAP/GetPhysicalExamListResModel.dart'; @@ -24,6 +26,7 @@ class SOAPService extends LookupService { List patientAllergiesList = []; List patientHistoryList = []; List patientPhysicalExamList = []; + List patientProgressNoteList = []; Future getAllergies(GetAllergiesRequestModel getAllergiesRequestModel) async { await baseAppClient.post( @@ -246,6 +249,7 @@ class SOAPService extends LookupService { response['PhysicalExamList']['entityList'].forEach((v) { patientPhysicalExamList.add(GetPhysicalExamResModel.fromJson(v)); }); + }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; @@ -253,15 +257,19 @@ class SOAPService extends LookupService { } Future getPatientProgressNote( - PostProgressNoteRequestModel getPatientProgressNoteRequestModel) async { + GetGetProgressNoteReqModel getGetProgressNoteReqModel) async { hasError = false; await baseAppClient.post (GET_PROGRESS_NOTE, onSuccess: (dynamic response, int statusCode) { print("Success"); + patientProgressNoteList.clear(); + response['ProgressNoteList']['entityList'].forEach((v) { + patientProgressNoteList.add(GetGetProgressNoteResModel.fromJson(v)); + }); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; - }, body: getPatientProgressNoteRequestModel.toJson()); + }, body: getGetProgressNoteReqModel.toJson()); } Future getPatientAssessment( diff --git a/lib/core/viewModel/SOAP_view_model.dart b/lib/core/viewModel/SOAP_view_model.dart index 4226643a..8d03a04e 100644 --- a/lib/core/viewModel/SOAP_view_model.dart +++ b/lib/core/viewModel/SOAP_view_model.dart @@ -5,6 +5,8 @@ import 'package:doctor_app_flutter/models/SOAP/ChiefComplaint/GetChiefComplaintR import 'package:doctor_app_flutter/models/SOAP/ChiefComplaint/GetChiefComplaintResModel.dart'; import 'package:doctor_app_flutter/models/SOAP/GeneralGetReqForSOAP.dart'; import 'package:doctor_app_flutter/models/SOAP/GetAllergiesResModel.dart'; +import 'package:doctor_app_flutter/models/SOAP/GetGetProgressNoteReqModel.dart'; +import 'package:doctor_app_flutter/models/SOAP/GetGetProgressNoteResModel.dart'; import 'package:doctor_app_flutter/models/SOAP/GetHistoryReqModel.dart'; import 'package:doctor_app_flutter/models/SOAP/GetHistoryResModel.dart'; import 'package:doctor_app_flutter/models/SOAP/GetPhysicalExamListResModel.dart'; @@ -67,6 +69,9 @@ class SOAPViewModel extends BaseViewModel { List get patientPhysicalExamList => _SOAPService.patientPhysicalExamList; + List get patientProgressNoteList => + _SOAPService.patientProgressNoteList; + Future getAllergies(GetAllergiesRequestModel getAllergiesRequestModel) async { setState(ViewState.Busy); await _SOAPService.getAllergies(getAllergiesRequestModel); @@ -245,17 +250,17 @@ class SOAPViewModel extends BaseViewModel { await _SOAPService.getPatientPhysicalExam(getPhysicalExamReqModel); if (_SOAPService.hasError) { error = _SOAPService.error; - setState(ViewState.Busy); + setState(ViewState.Error); } else setState(ViewState.Idle); } - Future getPatientProgressNote(PostProgressNoteRequestModel getPatientProgressNoteRequestModel) async { + Future getPatientProgressNote(GetGetProgressNoteReqModel getGetProgressNoteReqModel) async { setState(ViewState.Busy); - await _SOAPService.getPatientProgressNote(getPatientProgressNoteRequestModel); + await _SOAPService.getPatientProgressNote(getGetProgressNoteReqModel); if (_SOAPService.hasError) { error = _SOAPService.error; - setState(ViewState.Busy); + setState(ViewState.Error); } else setState(ViewState.Idle); } diff --git a/lib/models/SOAP/GetGetProgressNoteReqModel.dart b/lib/models/SOAP/GetGetProgressNoteReqModel.dart new file mode 100644 index 00000000..936c6f65 --- /dev/null +++ b/lib/models/SOAP/GetGetProgressNoteReqModel.dart @@ -0,0 +1,40 @@ +class GetGetProgressNoteReqModel { + int patientMRN; + int appointmentNo; + String episodeID; + String from; + String to; + int clinicID; + int doctorID; + + GetGetProgressNoteReqModel( + {this.patientMRN, + this.appointmentNo, + this.episodeID, + this.from, + this.to, + this.clinicID, + this.doctorID}); + + GetGetProgressNoteReqModel.fromJson(Map json) { + patientMRN = json['PatientMRN']; + appointmentNo = json['AppointmentNo']; + episodeID = json['EpisodeID']; + from = json['From']; + to = json['To']; + clinicID = json['ClinicID']; + doctorID = json['DoctorID']; + } + + Map toJson() { + final Map data = new Map(); + data['PatientMRN'] = this.patientMRN; + data['AppointmentNo'] = this.appointmentNo; + data['EpisodeID'] = this.episodeID; + data['From'] = this.from; + data['To'] = this.to; + data['ClinicID'] = this.clinicID; + data['DoctorID'] = this.doctorID; + return data; + } +} diff --git a/lib/models/SOAP/GetGetProgressNoteResModel.dart b/lib/models/SOAP/GetGetProgressNoteResModel.dart new file mode 100644 index 00000000..bbc184f1 --- /dev/null +++ b/lib/models/SOAP/GetGetProgressNoteResModel.dart @@ -0,0 +1,25 @@ +class GetGetProgressNoteResModel { + int appointmentNo; + int episodeId; + int patientMRN; + String planNote; + + GetGetProgressNoteResModel( + {this.appointmentNo, this.episodeId, this.patientMRN, this.planNote}); + + GetGetProgressNoteResModel.fromJson(Map json) { + appointmentNo = json['appointmentNo']; + episodeId = json['episodeId']; + patientMRN = json['patientMRN']; + planNote = json['planNote']; + } + + Map toJson() { + final Map data = new Map(); + data['appointmentNo'] = this.appointmentNo; + data['episodeId'] = this.episodeId; + data['patientMRN'] = this.patientMRN; + data['planNote'] = this.planNote; + return data; + } +} diff --git a/lib/widgets/patients/profile/soap_update/update_objective_page.dart b/lib/widgets/patients/profile/soap_update/update_objective_page.dart index d7123678..4884422c 100644 --- a/lib/widgets/patients/profile/soap_update/update_objective_page.dart +++ b/lib/widgets/patients/profile/soap_update/update_objective_page.dart @@ -83,6 +83,8 @@ class _UpdateObjectivePageState extends State { }, builder: (_, model, w) => AppScaffold( isShowAppBar: false, + //TODO: retrun it back + // baseViewModel: model, body: SingleChildScrollView( physics: ScrollPhysics(), child: Center( diff --git a/lib/widgets/patients/profile/soap_update/update_plan_page.dart b/lib/widgets/patients/profile/soap_update/update_plan_page.dart index a6ce8fad..506ff103 100644 --- a/lib/widgets/patients/profile/soap_update/update_plan_page.dart +++ b/lib/widgets/patients/profile/soap_update/update_plan_page.dart @@ -2,6 +2,7 @@ import 'package:doctor_app_flutter/client/base_app_client.dart'; import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/GetGetProgressNoteReqModel.dart'; import 'package:doctor_app_flutter/models/SOAP/post_progress_note_request_model.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; @@ -53,8 +54,21 @@ class _UpdatePlanPageState extends State { final screenSize = MediaQuery.of(context).size; return BaseView( - // onModelReady: (model) => model.getMasterLookup(MasterKeysService.Allergies), + onModelReady: (model) async { + GetGetProgressNoteReqModel getGetProgressNoteReqModel = + GetGetProgressNoteReqModel( + appointmentNo: widget.patientInfo.appointmentNo, + patientMRN: widget.patientInfo.patientMRN, + episodeID: widget.patientInfo.episodeNo.toString()); + await model.getPatientProgressNote(getGetProgressNoteReqModel); + + if (model.patientProgressNoteList.isNotEmpty) { + progressNoteController.text = + model.patientProgressNoteList[0].planNote; + } + }, builder: (_, model, w) => AppScaffold( + baseViewModel: model, isShowAppBar: false, body: SingleChildScrollView( physics: ScrollPhysics(), @@ -74,8 +88,7 @@ class _UpdatePlanPageState extends State { Row( children: [ Texts('Progress Note', - variant: - isProgressNoteExpand ? "bodyText" : '', + variant: isProgressNoteExpand ? "bodyText" : '', bold: isProgressNoteExpand ? true : false, color: Colors.black), Icon( @@ -88,8 +101,7 @@ class _UpdatePlanPageState extends State { InkWell( onTap: () { setState(() { - isProgressNoteExpand = - !isProgressNoteExpand; + isProgressNoteExpand = !isProgressNoteExpand; }); }, child: Icon(isProgressNoteExpand @@ -105,7 +117,7 @@ class _UpdatePlanPageState extends State { children: [ Container( margin: - EdgeInsets.only(left: 10, right: 10, top: 15), + EdgeInsets.only(left: 10, right: 10, top: 15), child: TextFields( hintText: "Add Progress Note", fontSize: 13.5, @@ -120,8 +132,7 @@ class _UpdatePlanPageState extends State { // controller: messageController, validator: (value) { if (value == null) - return TranslationBase - .of(context) + return TranslationBase.of(context) .emptyMessage; else return null; @@ -133,10 +144,10 @@ class _UpdatePlanPageState extends State { if (progressNoteController.text.isNotEmpty) Container( margin: - EdgeInsets.only(left: 5, right: 5, top: 15), + EdgeInsets.only(left: 5, right: 5, top: 15), child: Row( mainAxisAlignment: - MainAxisAlignment.spaceBetween, + MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ Column( @@ -144,9 +155,9 @@ class _UpdatePlanPageState extends State { children: [ Column( mainAxisAlignment: - MainAxisAlignment.start, + MainAxisAlignment.start, crossAxisAlignment: - CrossAxisAlignment.start, + CrossAxisAlignment.start, children: [ AppText( "12".toUpperCase(), @@ -163,13 +174,12 @@ class _UpdatePlanPageState extends State { ], ), Column( - crossAxisAlignment: CrossAxisAlignment - .start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ - Row( mainAxisAlignment: - MainAxisAlignment.start, + MainAxisAlignment.start, children: [ SizedBox( height: 6, @@ -177,25 +187,25 @@ class _UpdatePlanPageState extends State { Padding( padding: const EdgeInsets.all(0.0), child: Container( - width: MediaQuery - .of(context) - .size - .width * 0.6, + width: MediaQuery.of(context) + .size + .width * + 0.6, child: AppText( progressNoteController.text, fontSize: 10, - color: Colors.grey, ), ), ), ], - ), SizedBox( + ), + SizedBox( height: 8, ), Row( mainAxisAlignment: - MainAxisAlignment.start, + MainAxisAlignment.start, children: [ AppText( "Created By : ", @@ -211,7 +221,7 @@ class _UpdatePlanPageState extends State { ), Row( mainAxisAlignment: - MainAxisAlignment.start, + MainAxisAlignment.start, children: [ AppText( "Edited By : ", @@ -225,7 +235,6 @@ class _UpdatePlanPageState extends State { ), ], ), - ], ), Column( @@ -246,14 +255,13 @@ class _UpdatePlanPageState extends State { ]), isExpand: isProgressNoteExpand, ), - DividerWithSpacesAround(height: 30,), + DividerWithSpacesAround( + height: 30, + ), AppButton( - title: TranslationBase - .of(context) - .next, + title: TranslationBase.of(context).next, loading: model.state == ViewState.BusyLocal, onPressed: () { - submitPlan(model); // widget.changePageViewIndex(2); }, @@ -265,7 +273,9 @@ class _UpdatePlanPageState extends State { ), ), ), - ),),); + ), + ), + ); } submitPlan(SOAPViewModel model) async { @@ -276,8 +286,13 @@ class _UpdatePlanPageState extends State { appointmentNo: widget.patientInfo.appointmentNo, planNote: progressNoteController.text); + if(model.patientProgressNoteList.isEmpty){ + await model.postProgressNote(postProgressNoteRequestModel); + + }else { + await model.patchProgressNote(postProgressNoteRequestModel); - await model.patchProgressNote(postProgressNoteRequestModel); + } if (model.state == ViewState.ErrorLocal) { helpers.showErrorToast(model.error);