From bb651478a06bb088760af22bb9c99ad65df38ea2 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Sat, 26 Dec 2020 20:05:30 +0200 Subject: [PATCH 1/5] Finish subjective --- lib/client/base_app_client.dart | 25 +- lib/config/config.dart | 2 + lib/config/localized_values.dart | 7 +- lib/core/service/SOAP_service.dart | 32 ++- lib/core/service/base/lookup-service.dart | 1 + lib/core/viewModel/SOAP_view_model.dart | 22 ++ .../post_chief_complaint_request_model.dart | 48 ++++ .../SOAP/post_histories_request_model.dart | 64 +++++ lib/util/translations_delegate_base.dart | 1 + .../SOAP/subjective/subjective_page.dart | 246 +++++++++++------- lib/widgets/shared/TextFields.dart | 2 +- lib/widgets/shared/app_buttons_widget.dart | 98 ++++--- 12 files changed, 407 insertions(+), 141 deletions(-) create mode 100644 lib/models/SOAP/post_chief_complaint_request_model.dart create mode 100644 lib/models/SOAP/post_histories_request_model.dart diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index 9d621755..d9abcd5e 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -61,7 +61,8 @@ class BaseAppClient { body['SessionID'] = SESSION_ID; body['IsLoginForDoctorApp'] = IS_LOGIN_FOR_DOCTOR_APP; body['PatientOutSA'] = 0; // PATIENT_OUT_SA; - body['VidaAuthTokenID'] = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMDAyIiwianRpIjoiZjcwMTUyYzktMjAwNy00Y2FjLTkzMWUtOGI0MDlhMWFkNjc4IiwiZW1haWwiOiIiLCJpZCI6IjEwMDIiLCJOYW1lIjoiVEVNUCAtIERPQ1RPUiIsIkVtcGxveWVlSWQiOiI0NzA5IiwiRmFjaWxpdHlHcm91cElkIjoiMDEwMjY2IiwiRmFjaWxpdHlJZCI6IjE1IiwiUGhhcmFtY3lGYWNpbGl0eUlkIjoiNTUiLCJJU19QSEFSTUFDWV9DT05ORUNURUQiOiJUcnVlIiwiRG9jdG9ySWQiOiI0NzA5IiwiU0VTU0lPTklEIjoiMjE1ODU1MzAiLCJDbGluaWNJZCI6IjE3Iiwicm9sZSI6IkRPQ1RPUlMiLCJuYmYiOjE2MDg1NTMxMDAsImV4cCI6MTYwOTQxNzEwMCwiaWF0IjoxNjA4NTUzMTAwfQ.lydDI-nsHlmb4Z4vesnckCU1i3hnNayoWVacc3E5_XM"; + body['VidaAuthTokenID'] = + "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMDAyIiwianRpIjoiOGUxMWI1ZGItNTE5Mi00NmIzLWIzMDAtNDMwYjZmNDI4YWExIiwiZW1haWwiOiIiLCJpZCI6IjEwMDIiLCJOYW1lIjoiVEVNUCAtIERPQ1RPUiIsIkVtcGxveWVlSWQiOiI0NzA5IiwiRmFjaWxpdHlHcm91cElkIjoiMDEwMjY2IiwiRmFjaWxpdHlJZCI6IjE1IiwiUGhhcmFtY3lGYWNpbGl0eUlkIjoiNTUiLCJJU19QSEFSTUFDWV9DT05ORUNURUQiOiJUcnVlIiwiRG9jdG9ySWQiOiI0NzA5IiwiU0VTU0lPTklEIjoiMjE1OTU3MjgiLCJDbGluaWNJZCI6IjEiLCJyb2xlIjpbIkRPQ1RPUlMiLCJIRUFEIERPQ1RPUlMiLCJBRE1JTklTVFJBVE9SUyIsIlJFQ0VQVElPTklTVCIsIkVSIE5VUlNFIiwiRVIgUkVDRVBUSU9OSVNUIiwiUEhBUk1BQ1kgQUNDT1VOVCBTVEFGRiIsIlBIQVJNQUNZIE5VUlNFIiwiSU5QQVRJRU5UIFBIQVJNQUNJU1QiLCJBRE1JU1NJT04gU1RBRkYiLCJBUFBST1ZBTCBTVEFGRiIsIkNPTlNFTlQgIiwiTUVESUNBTCBSRVBPUlQgLSBTSUNLIExFQVZFIE1BTkFHRVIiXSwibmJmIjoxNjA4ODE0MDcyLCJleHAiOjE2MDk2NzgwNzIsImlhdCI6MTYwODgxNDA3Mn0.u23f3ifrNMQrK0ReTZWs9olaZCEYuf06ZZZJsBWJ5LI"; print("URL : $url"); print("Body : ${json.encode(body)}"); @@ -78,25 +79,27 @@ class BaseAppClient { onFailure('Error While Fetching data', statusCode); } else { var parsed = json.decode(response.body.toString()); - if (!parsed['IsAuthenticated']) { - await helpers.logout(); - - helpers.showErrorToast('Your session expired Please login agian'); - } else - if (parsed['MessageStatus'] == 1) { + // if (!parsed['IsAuthenticated']) { + // await helpers.logout(); + // + // helpers.showErrorToast('Your session expired Please login agian'); + // } else + if (parsed['MessageStatus'] == 1) { onSuccess(parsed, statusCode); } else { String error = parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']; if (parsed["ValidationErrors"] != null) { + error = + parsed["ValidationErrors"]["StatusMessage"].toString() + "\n"; + if (parsed["ValidationErrors"]["ValidationErrors"] != null && parsed["ValidationErrors"]["ValidationErrors"].length != 0) { - error =''; for (var i = 0; - i < parsed["ValidationErrors"]["ValidationErrors"].length; - i++) { - error = error +parsed["ValidationErrors"]["ValidationErrors"][i]["Messages"][0] +"\n"; + i < parsed["ValidationErrors"]["ValidationErrors"].length; + i++) { + error = error +parsed["ValidationErrors"]["ValidationErrors"][i]["Messages"][0] +"\n"; } } } diff --git a/lib/config/config.dart b/lib/config/config.dart index 783cf811..a79daa45 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -86,6 +86,8 @@ const END_CALL_WITH_CHARGE = 'LiveCareApi/DoctorApp/CompleteCallWithCharge'; const GET_ALLERGIES = 'Services/DoctorApplication.svc/REST/GetAllergies'; const GET_MASTER_LOOKUP_LIST = 'Services/DoctorApplication.svc/REST/GetMasterLookUpList'; 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'; var selectedPatientType = 1; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index e205bb4e..ffd3c822 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -280,7 +280,10 @@ const Map> localizedValues = { 'clinicSelect': {'en': "Select Clinic", 'ar': 'اختار عيادة'}, 'doctorSelect': {'en': "Select Doctor", 'ar': 'اختار طبيب'}, "empty-message": { - "en": "Please enter message", - "ar": "يرجى ادخال الموضوع" + "en": "Please enter Value", + "ar": "يرجى ادخال القيمه" + },"chiefComplaintLength": { + "en": "Chief Complaint length should be greater than 25", + "ar": "يجب أن يكون طول شكوى الرئيس أكبر من 25" }, }; diff --git a/lib/core/service/SOAP_service.dart b/lib/core/service/SOAP_service.dart index 56645184..1a8c91a1 100644 --- a/lib/core/service/SOAP_service.dart +++ b/lib/core/service/SOAP_service.dart @@ -1,14 +1,13 @@ 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/service/base/base_service.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'; +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 'base/lookup-service.dart'; class SOAPService extends LookupService { - Future getAllergies(GetAllergiesRequestModel getAllergiesRequestModel) async { await baseAppClient.post( GET_ALLERGIES, @@ -27,13 +26,38 @@ class SOAPService extends LookupService { } Future postAllergy(PostAllergyRequestModel postAllergyRequestModel) async { + hasError = false; await baseAppClient.post(POST_ALLERGY, onSuccess: (dynamic response, int statusCode) { - print("Success"); + print("Success"); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: postAllergyRequestModel.toJson()); } + + Future postHistories( + PostHistoriesRequestModel postHistoriesRequestModel) async { + hasError = false; + await baseAppClient.post(POST_HISTORY, + onSuccess: (dynamic response, int statusCode) { + print("Success"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: postHistoriesRequestModel.toJson()); + } + + Future postChiefComplaint( + PostChiefComplaintRequestModel postChiefComplaintRequestModel) async { + hasError = false; + await baseAppClient.post(POST_CHIEF_COMPLAINT, + onSuccess: (dynamic response, int statusCode) { + print("Success"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: postChiefComplaintRequestModel.toJson()); + } } diff --git a/lib/core/service/base/lookup-service.dart b/lib/core/service/base/lookup-service.dart index 1e46d13a..18353c82 100644 --- a/lib/core/service/base/lookup-service.dart +++ b/lib/core/service/base/lookup-service.dart @@ -27,6 +27,7 @@ class LookupService extends BaseService { List _historySurgicalList = []; Future getMasterLookup(MasterKeysService masterKeys) async { + hasError = false; Map body = { "MasterInput": masterKeys.getMasterKeyService() }; diff --git a/lib/core/viewModel/SOAP_view_model.dart b/lib/core/viewModel/SOAP_view_model.dart index 608b2e3d..5131e086 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/Allergy_model.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'; +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 '../../locator.dart'; import 'base_view_model.dart'; @@ -60,5 +62,25 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.Idle); } + Future postHistories(PostHistoriesRequestModel postHistoriesRequestModel) async { + setState(ViewState.BusyLocal); + await _SOAPService.postHistories(postHistoriesRequestModel); + if (_SOAPService.hasError) { + error = _SOAPService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } + + Future postChiefComplaint(PostChiefComplaintRequestModel postChiefComplaintRequestModel) async { + setState(ViewState.BusyLocal); + await _SOAPService.postChiefComplaint(postChiefComplaintRequestModel); + if (_SOAPService.hasError) { + error = _SOAPService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } + } diff --git a/lib/models/SOAP/post_chief_complaint_request_model.dart b/lib/models/SOAP/post_chief_complaint_request_model.dart new file mode 100644 index 00000000..bedf2978 --- /dev/null +++ b/lib/models/SOAP/post_chief_complaint_request_model.dart @@ -0,0 +1,48 @@ +class PostChiefComplaintRequestModel { + int appointmentNo; + int episodeID; + int patientMRN; + String chiefComplaint; + String hopi; + String currentMedication; + bool ispregnant; + bool isLactation; + int numberOfWeeks; + + PostChiefComplaintRequestModel( + {this.appointmentNo, + this.episodeID, + this.patientMRN, + this.chiefComplaint, + this.hopi, + this.currentMedication, + this.ispregnant, + this.isLactation, + this.numberOfWeeks}); + + PostChiefComplaintRequestModel.fromJson(Map json) { + appointmentNo = json['AppointmentNo']; + episodeID = json['EpisodeID']; + patientMRN = json['PatientMRN']; + chiefComplaint = json['chiefComplaint']; + hopi = json['Hopi']; + currentMedication = json['CurrentMedication']; + ispregnant = json['ispregnant']; + isLactation = json['isLactation']; + numberOfWeeks = json['numberOfWeeks']; + } + + Map toJson() { + final Map data = new Map(); + data['AppointmentNo'] = this.appointmentNo; + data['EpisodeID'] = this.episodeID; + data['PatientMRN'] = this.patientMRN; + data['chiefComplaint'] = this.chiefComplaint; + data['Hopi'] = this.hopi; + data['CurrentMedication'] = this.currentMedication; + data['ispregnant'] = this.ispregnant; + data['isLactation'] = this.isLactation; + data['numberOfWeeks'] = this.numberOfWeeks; + return data; + } +} diff --git a/lib/models/SOAP/post_histories_request_model.dart b/lib/models/SOAP/post_histories_request_model.dart new file mode 100644 index 00000000..baa428fd --- /dev/null +++ b/lib/models/SOAP/post_histories_request_model.dart @@ -0,0 +1,64 @@ +class PostHistoriesRequestModel { + List listMedicalHistoryVM; + + PostHistoriesRequestModel({this.listMedicalHistoryVM}); + + PostHistoriesRequestModel.fromJson(Map json) { + if (json['listMedicalHistoryVM'] != null) { + listMedicalHistoryVM = new List(); + json['listMedicalHistoryVM'].forEach((v) { + listMedicalHistoryVM.add(new ListMedicalHistoryVM.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = new Map(); + if (this.listMedicalHistoryVM != null) { + data['listMedicalHistoryVM'] = + this.listMedicalHistoryVM.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class ListMedicalHistoryVM { + int patientMRN; + int historyType; + int historyId; + int episodeId; + int appointmentNo; + bool isChecked; + String remarks; + + ListMedicalHistoryVM( + {this.patientMRN, + this.historyType, + this.historyId, + this.episodeId, + this.appointmentNo, + this.isChecked, + this.remarks}); + + ListMedicalHistoryVM.fromJson(Map json) { + patientMRN = json['patientMRN']; + historyType = json['historyType']; + historyId = json['historyId']; + episodeId = json['episodeId']; + appointmentNo = json['appointmentNo']; + isChecked = json['isChecked']; + remarks = json['remarks']; + } + + Map toJson() { + final Map data = new Map(); + data['patientMRN'] = this.patientMRN; + data['historyType'] = this.historyType; + data['historyId'] = this.historyId; + data['episodeId'] = this.episodeId; + data['appointmentNo'] = this.appointmentNo; + data['isChecked'] = this.isChecked; + data['remarks'] = this.remarks; + return data; + } +} diff --git a/lib/util/translations_delegate_base.dart b/lib/util/translations_delegate_base.dart index 7292492d..3f483480 100644 --- a/lib/util/translations_delegate_base.dart +++ b/lib/util/translations_delegate_base.dart @@ -300,6 +300,7 @@ class TranslationBase { String get next => localizedValues['next'][locale.languageCode]; String get healthRecordInformation => localizedValues['healthRecordInformation'][locale.languageCode]; String get emptyMessage => localizedValues['empty-message'][locale.languageCode]; + String get chiefComplaintLength => localizedValues['chiefComplaintLength'][locale.languageCode]; } diff --git a/lib/widgets/patients/profile/SOAP/subjective/subjective_page.dart b/lib/widgets/patients/profile/SOAP/subjective/subjective_page.dart index a78f6d0b..ae024b10 100644 --- a/lib/widgets/patients/profile/SOAP/subjective/subjective_page.dart +++ b/lib/widgets/patients/profile/SOAP/subjective/subjective_page.dart @@ -5,6 +5,8 @@ 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/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'; @@ -34,9 +36,9 @@ class _SubjectivePageState extends State { bool isChiefExpand = false; bool isHistoryExpand = false; bool isAllergiesExpand = false; - List myHistoryList = List(); TextEditingController illnessController = TextEditingController(); TextEditingController complaintsController = TextEditingController(); + final formKey = GlobalKey(); @override Widget build(BuildContext context) { @@ -83,56 +85,64 @@ class _SubjectivePageState extends State { isChiefExpand ? EvaIcons.minus : EvaIcons.plus)) ], ), - bodyWidget: 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) - return TranslationBase - .of(context) - .emptyMessage; - 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) - return TranslationBase - .of(context) - .emptyMessage; - else - return null; - }), - ), - SizedBox( - height: 20, - ), - AddMedication(), - ]), + 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, + ), + AddMedication(), + ]), + ), isExpand: isChiefExpand, ), @@ -177,7 +187,7 @@ class _SubjectivePageState extends State { ), bodyWidget: Column( children: [ - AddHistoryWidget(myHistoryList: myHistoryList) + AddHistoryWidget(myHistoryList: widget.myHistoryList) ], ), isExpand: isHistoryExpand, @@ -243,58 +253,118 @@ class _SubjectivePageState extends State { SizedBox( height: 30, ), - AppButton( - title: TranslationBase - .of(context) - .next, - - onPressed: () async { - addSubjectiveInfo(model: model, - myAllergiesList: widget.myAllergiesList, - myHistoryList: myHistoryList); - - }, - ), + 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< - MasterKeyModel> myHistoryList }) async { - PostAllergyRequestModel postAllergyRequestModel = new PostAllergyRequestModel(); + {SOAPViewModel model, + List myAllergiesList, + List myHistoryList}) async { + await postChiefComplaint(model: model); + if (myHistoryList.length != 0) + await postHistories(model: model, myHistoryList: myHistoryList); + if (myAllergiesList.length != 0) + await postAllergy(myAllergiesList: myAllergiesList, model: model); + + widget.changePageViewIndex(1); + } + + postAllergy( + {List myAllergiesList, SOAPViewModel model}) async { + PostAllergyRequestModel postAllergyRequestModel = + new PostAllergyRequestModel(); widget.myAllergiesList.forEach((allergy) { - if(postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM ==null) + if (postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM == + null) postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM = []; - postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM.add( - ListHisProgNotePatientAllergyDiseaseVM( - allergyDiseaseId: allergy.selectedAllergy.id, - allergyDiseaseType: allergy.selectedAllergy.typeId, - patientMRN: 2500477, - episodeId: 200011502, - appointmentNo: 2016053271, - severity: allergy.selectedAllergySeverity.id, - remarks: allergy.remark, - createdBy: 1485, - createdOn: "2020-08-14T20:37:22.780Z", - editedBy: 1485, - editedOn: "2020-08-14T20:37:22.780Z", - isChecked: false, - isUpdatedByNurse: false - )); + //TODO: make static value dynamic + postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM + .add(ListHisProgNotePatientAllergyDiseaseVM( + allergyDiseaseId: allergy.selectedAllergy.id, + allergyDiseaseType: allergy.selectedAllergy.typeId, + patientMRN: 3120690, + episodeId: 200012117, + appointmentNo: 2016054573, + severity: allergy.selectedAllergySeverity.id, + remarks: allergy.remark, + createdBy: 1485, + // + createdOn: "2020-08-14T20:37:22.780Z", + editedBy: 1485, + editedOn: "2020-08-14T20:37:22.780Z", + isChecked: false, + isUpdatedByNurse: false)); }); await model.postAllergy(postAllergyRequestModel); - if(model.state == ViewState.ErrorLocal) { + if (model.state == ViewState.ErrorLocal) { helpers.showErrorToast(model.error); } - widget.changePageViewIndex(1); + } - print(postAllergyRequestModel); + 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: 3120690, + episodeId: 200012117, + appointmentNo: 2016054573, + remarks: "", + historyId: history.id, + historyType: history.typeId, + isChecked: false, + )); + }); + await model.postHistories(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: 3120690, + episodeID: 200012117, + appointmentNo: 2016054573, + chiefComplaint: complaintsController.text, + currentMedication: "currentMedication", + hopi: illnessController.text, + isLactation: false, + ispregnant: false, + numberOfWeeks: 22); + + await model.postChiefComplaint(postChiefComplaintRequestModel); + + if (model.state == ViewState.ErrorLocal) { + helpers.showErrorToast(model.error); + } + } + + } } diff --git a/lib/widgets/shared/TextFields.dart b/lib/widgets/shared/TextFields.dart index e41b4379..fec58e89 100644 --- a/lib/widgets/shared/TextFields.dart +++ b/lib/widgets/shared/TextFields.dart @@ -157,7 +157,7 @@ class _TextFieldsState extends State { : Icon(EvaIcons.search, size: 20.0, color: Colors.grey[500]), - errorStyle: TextStyle(fontSize: 14.0, fontWeight: widget.fontWeight, height: widget.borderOnlyError ? 0.0 : null), + errorStyle: TextStyle(fontSize: 12.0, fontWeight: widget.fontWeight, height: widget.borderOnlyError ? 0.0 : null), errorBorder: OutlineInputBorder( borderSide: BorderSide(color: Theme.of(context).errorColor.withOpacity(widget.bare ? 0.0 : 0.5 ), width: 2.0), borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0) diff --git a/lib/widgets/shared/app_buttons_widget.dart b/lib/widgets/shared/app_buttons_widget.dart index d01fe5af..85b0483d 100644 --- a/lib/widgets/shared/app_buttons_widget.dart +++ b/lib/widgets/shared/app_buttons_widget.dart @@ -14,50 +14,78 @@ class AppButton extends StatefulWidget { final Color color; final double fontSize; final double padding; + final bool loading; + final bool disabled; - AppButton({@required this.onPressed, this.title, this.icon, this.color, this.fontSize = 2, this.padding = 13}); + AppButton( + {@required this.onPressed, + this.title, + this.icon, + this.color, + this.fontSize = 2, + this.padding = 13, + this.loading = false, + this.disabled = false}); _AppButtonState createState() => _AppButtonState(); - } class _AppButtonState extends State{ @override Widget build(BuildContext context) { - return - RawMaterialButton( - fillColor: widget.color != null ? widget.color : HexColor("#B8382C"), - splashColor: widget.color, - child: Padding( - padding: EdgeInsets.only( - top: widget.padding, - bottom: widget.padding, - //right: SizeConfig.widthMultiplier * widget.padding, - //left: SizeConfig.widthMultiplier * widget.padding - ), - child: Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - if (widget.icon != null) - Icon( - widget.icon, - color: Colors.white, - ), - if (widget.icon != null) - SizedBox( - width: 5.0, - ), - AppText( - widget.title.toUpperCase(), - color: Colors.white, - fontSize: SizeConfig.textMultiplier * widget.fontSize , - ), - ], + return + IgnorePointer( + ignoring: widget.loading, + child: RawMaterialButton( + fillColor: widget.color != null ? widget.color : HexColor("#B8382C"), + splashColor: widget.color, + child: Padding( + padding: EdgeInsets.only( + top: widget.padding, + bottom: widget.padding, + //right: SizeConfig.widthMultiplier * widget.padding, + //left: SizeConfig.widthMultiplier * widget.padding + ), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + if (widget.icon != null) + Icon( + widget.icon, + color: Colors.white, + ), + if (widget.icon != null) + SizedBox( + width: 5.0, + ), + widget.loading + ? Padding( + padding: EdgeInsets.all(2.6), + child: SizedBox( + height: 19.0, + width: 19.0, + child: CircularProgressIndicator( + backgroundColor: Colors.white, + valueColor: + AlwaysStoppedAnimation( + Colors.grey[300], + ), + ), + ), + ) + : AppText( + widget.title.toUpperCase(), + color: Colors.white, + fontSize: SizeConfig.textMultiplier * widget.fontSize, + ), + ], + ), ), + onPressed: widget.onPressed, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(6))), ), - onPressed: widget.onPressed, - shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(6))), - ); + ); } } \ No newline at end of file From e96d38454c9c78db18c1e1a054eb406e0725fd40 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Sat, 26 Dec 2020 20:53:27 +0200 Subject: [PATCH 2/5] First step from examination --- lib/core/service/base/lookup-service.dart | 10 +- lib/core/viewModel/SOAP_view_model.dart | 1 + .../patients/profile/SOAP/add_SOAP_index.dart | 3 +- .../patients/profile/SOAP/objective_page.dart | 624 +++++++++--------- 4 files changed, 317 insertions(+), 321 deletions(-) diff --git a/lib/core/service/base/lookup-service.dart b/lib/core/service/base/lookup-service.dart index 18353c82..11623880 100644 --- a/lib/core/service/base/lookup-service.dart +++ b/lib/core/service/base/lookup-service.dart @@ -26,6 +26,10 @@ class LookupService extends BaseService { List get historySurgicalList => _historySurgicalList; List _historySurgicalList = []; + + List get physicalExaminationList => _physicalExaminationList; + List _physicalExaminationList = []; + Future getMasterLookup(MasterKeysService masterKeys) async { hasError = false; Map body = { @@ -85,7 +89,11 @@ class LookupService extends BaseService { }); break; case MasterKeysService.PhysicalExamination: - return 59; + _physicalExaminationList.clear(); + entryList.forEach((v) { + _physicalExaminationList + .add(MasterKeyModel.fromJson(v)); + }); break; case MasterKeysService.AllergySeverity: _allergySeverityList.clear(); diff --git a/lib/core/viewModel/SOAP_view_model.dart b/lib/core/viewModel/SOAP_view_model.dart index 5131e086..3ff33389 100644 --- a/lib/core/viewModel/SOAP_view_model.dart +++ b/lib/core/viewModel/SOAP_view_model.dart @@ -29,6 +29,7 @@ class SOAPViewModel extends BaseViewModel { List get historySocialList => _SOAPService.historySocialList; List get historySurgicalList => _SOAPService.historySurgicalList; List get mergeHistorySurgicalWithHistorySportList => [...historySurgicalList,...historySportList]; + List get physicalExaminationList => _SOAPService.physicalExaminationList; diff --git a/lib/widgets/patients/profile/SOAP/add_SOAP_index.dart b/lib/widgets/patients/profile/SOAP/add_SOAP_index.dart index 9d75b22c..4e8c0873 100644 --- a/lib/widgets/patients/profile/SOAP/add_SOAP_index.dart +++ b/lib/widgets/patients/profile/SOAP/add_SOAP_index.dart @@ -30,6 +30,7 @@ class _AddSOAPIndexState extends State int _currentIndex = 0; List myAllergiesList= List(); List myHistoryList = List(); + List myExaminationList = List(); changePageViewIndex(pageIndex) { _controller.jumpToPage(pageIndex); } @@ -153,7 +154,7 @@ class _AddSOAPIndexState extends State scrollDirection: Axis.horizontal, children: [ SubjectivePage(changePageViewIndex: changePageViewIndex,myAllergiesList: myAllergiesList,myHistoryList: myHistoryList,), - ObjectivePage(changePageViewIndex: changePageViewIndex,), + ObjectivePage(changePageViewIndex: changePageViewIndex,myExaminationList:myExaminationList), AssessmentPage(changePageViewIndex: changePageViewIndex,), PlanPage(changePageViewIndex: changePageViewIndex,) ], diff --git a/lib/widgets/patients/profile/SOAP/objective_page.dart b/lib/widgets/patients/profile/SOAP/objective_page.dart index b2cd920f..c3e8d5db 100644 --- a/lib/widgets/patients/profile/SOAP/objective_page.dart +++ b/lib/widgets/patients/profile/SOAP/objective_page.dart @@ -1,4 +1,9 @@ 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'; @@ -7,15 +12,16 @@ 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'; -import 'package:hexcolor/hexcolor.dart'; class ObjectivePage extends StatefulWidget { final Function changePageViewIndex; + final List myExaminationList; - ObjectivePage({Key key, this.changePageViewIndex}); + ObjectivePage({Key key, this.changePageViewIndex, this.myExaminationList}); @override _ObjectivePageState createState() => _ObjectivePageState(); @@ -117,115 +123,136 @@ class _ObjectivePageState extends State { SizedBox( height: 20, ), - Container( - margin: - EdgeInsets.only(left: 15, right: 15, top: 15), - child: Column( - children: [ - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Texts('Abdomen'.toUpperCase(), - variant: "bodyText", - bold: true, - color: Colors.black) - ], - ), - SizedBox( - height: 8, - ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ + Column( + children: widget.myExaminationList.map((examination) { + return Container( + margin: EdgeInsets.only( + left: 15, right: 15, top: 15), + child: Column(children: [ Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ - InkWell( - child: Center( - child: Container( - height: screenSize.height * 0.070, - decoration: containerBorderDecoration( - Colors.white,Colors.grey - ), - child: Center( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Text( - "Normal", - style: TextStyle( - fontSize: 12, - color: - Colors.black, //Colors.black, - fontWeight: FontWeight.bold, + Texts(examination.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( + Colors.white, + Colors.grey), + child: Center( + child: Padding( + padding: + const EdgeInsets + .all(8.0), + child: Text( + "Normal", + style: TextStyle( + fontSize: 12, + color: + Colors.black, + //Colors.black, + fontWeight: + FontWeight + .bold, + ), + ), ), - ), - ), - )), + )), + ), + onTap: () {}), + SizedBox( + width: 12, ), - onTap: () { - - }), - SizedBox(width: 12,), - InkWell( - child: Center( - child: Container( - height: screenSize.height * 0.070, - decoration: containerBorderDecoration( - Color(0xFF515A5D), Colors.black - ), - child: Center( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Text( - "Abnormal", - style: TextStyle( - fontSize: 12, - color: - Colors.white, //Colors.black, - fontWeight: FontWeight.bold, + InkWell( + child: Center( + child: Container( + height: + screenSize.height * + 0.070, + decoration: + containerBorderDecoration( + Color(0xFF515A5D), + Colors.black), + child: Center( + child: Padding( + padding: + const EdgeInsets + .all(8.0), + child: Text( + "Abnormal", + style: TextStyle( + fontSize: 12, + color: + Colors.white, + //Colors.black, + fontWeight: + FontWeight + .bold, + ), + ), ), - ), - ), - )), - ), - onTap: () { - - }), + )), + ), + onTap: () {}), + ], + ), + InkWell( + + child: Icon( + FontAwesomeIcons.trash, + color: Colors.grey, + size: 20, + ), + onTap: ()=>removeExamination(examination), + ) ], ), - Icon( - FontAwesomeIcons.trash, - color: Colors.grey, - size: 20, - ) - ], - ), - 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, - ), - ], - ), + 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(), ) ], ) @@ -249,10 +276,23 @@ class _ObjectivePageState extends State { )); } + removeExamination(MasterKeyModel masterKey) { + Iterable history = widget.myExaminationList.where( + (element) => + masterKey.id == element.id && masterKey.typeId == element.typeId); + + if (history.length > 0) + setState(() { + widget.myExaminationList.remove(history.first); + }); + } + openExaminationList(BuildContext context) { - final screenSize = MediaQuery.of(context).size; - InputDecoration textFieldSelectorDecoration( - String hintText, String selectedText, bool isDropDown) { + 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), @@ -275,228 +315,174 @@ class _ObjectivePageState extends State { ); } - ; showModalBottomSheet( backgroundColor: Colors.white, isScrollControlled: true, context: context, builder: (context) { - return FractionallySizedBox( - heightFactor: 0.7, - 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, - ), - 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( + return AddExaminationDailog( + myExaminationList: widget.myExaminationList, + addSelectedExamination: () { + setState(() { + Navigator.of(context).pop(); + }); + }, + removeExamination: (masterKey) => removeExamination(masterKey),); + }); + } +} + +class AddExaminationDailog extends StatefulWidget { + final List myExaminationList; + final Function addSelectedExamination; + final Function (MasterKeyModel) removeExamination; + + const AddExaminationDailog( + {Key key, this.myExaminationList, 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: [ - Row( - children: [ - Checkbox( - value: true, - activeColor: Colors.red[800], - onChanged: (bool newValue) { - setState(() {}); - }), - Expanded( - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 10, vertical: 0), - child: Texts('Examinations', - variant: "bodyText", - bold: true, - color: Colors.black), - ), - ), - ], - ), - DividerWithSpacesAround(), - Row( - children: [ - Checkbox( - value: true, - activeColor: Colors.red[800], - onChanged: (bool newValue) { - setState(() {}); - }), - Expanded( - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 10, vertical: 0), - child: Texts('Examinations', - variant: "bodyText", - bold: true, - color: Colors.black), - ), - ), - ], - ), - DividerWithSpacesAround(), - Row( - children: [ - Checkbox( - value: true, - activeColor: Colors.red[800], - onChanged: (bool newValue) { - setState(() {}); - }), - Expanded( - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 10, vertical: 0), - child: Texts('Examinations', - variant: "bodyText", - bold: true, - color: Colors.black), - ), - ), - ], - ), - DividerWithSpacesAround(), - Row( - children: [ - Checkbox( - value: true, - activeColor: Colors.red[800], - onChanged: (bool newValue) { - setState(() {}); - }), - Expanded( - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 10, vertical: 0), - child: Texts('Examinations', - variant: "bodyText", - bold: true, - color: Colors.black), - ), - ), - ], + SizedBox( + height: 16, ), - DividerWithSpacesAround(), - Row( - children: [ - Checkbox( - value: true, - activeColor: Colors.red[800], - onChanged: (bool newValue) { - setState(() {}); - }), - Expanded( - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 10, vertical: 0), - child: Texts('Examinations', - variant: "bodyText", - bold: true, - color: Colors.black), - ), - ), - ], + AppText( + "Examinations", + fontWeight: FontWeight.bold, + fontSize: 16, ), - DividerWithSpacesAround(), - Row( - children: [ - Checkbox( - value: true, - activeColor: Colors.red[800], - onChanged: (bool newValue) { - setState(() {}); - }), - Expanded( - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 10, vertical: 0), - child: Texts('Examinations', - variant: "bodyText", - bold: true, - color: Colors.black), - ), - ), - ], + SizedBox( + height: 16, ), - DividerWithSpacesAround(), - Row( - children: [ - Checkbox( - value: true, - activeColor: Colors.red[800], - onChanged: (bool newValue) { - setState(() {}); - }), - Expanded( - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 10, vertical: 0), - child: Texts('Examinations', - variant: "bodyText", - bold: true, - color: Colors.black), - ), - ), - ], + 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 { + widget + .myExaminationList + .add( + examinationInfo); + } + }); + }), + Expanded( + child: Padding( + padding: + const EdgeInsets + .symmetric( + horizontal: 10, + vertical: 0), + child: Texts( + examinationInfo + .nameEn, + variant: "bodyText", + bold: true, + color: + Colors.black), + ), + ), + ], + ), + DividerWithSpacesAround(), + ], + ); + }).toList(), + ), + ], + ), + )), + ), ), - DividerWithSpacesAround(), - Row( - children: [ - Checkbox( - value: true, - activeColor: Colors.red[800], - onChanged: (bool newValue) { - setState(() {}); - }), - Expanded( - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 10, vertical: 0), - child: Texts('Examinations', - variant: "bodyText", - bold: true, - color: Colors.black), - ), - ), - ], + SizedBox( + height: 10, ), - DividerWithSpacesAround(), - ], - ), - ], - ), - )), - ), - SizedBox( - height: 10, - ), - AppButton( - title: "Add SELECTED Examinations".toUpperCase(), - onPressed: () {}, - ), - ]), - )), - ); - }); + if (model.state == ViewState.Idle) + AppButton( + title: "Add SELECTED Examinations" + .toUpperCase(), + onPressed: () { + widget.addSelectedExamination(); + }, + ), + ]), + ))), + )), + ); } -} + isServiceSelected(MasterKeyModel masterKey) { + Iterable history = + widget + .myExaminationList + .where((element) => + masterKey.id == element.id && masterKey.typeId == element.typeId); + if (history.length > 0) { + return true; + } + return false; + } +} From 4560706d552160d5a26e469202d5630574ab614c Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Sun, 27 Dec 2020 15:46:29 +0200 Subject: [PATCH 3/5] improve code inside my eam --- lib/client/base_app_client.dart | 11 ++- lib/models/SOAP/my_selected_examination.dart | 33 +++++++ .../post_physical_exam_request_model.dart | 99 +++++++++++++++++++ .../patients/profile/SOAP/add_SOAP_index.dart | 5 +- .../patients/profile/SOAP/objective_page.dart | 50 ++++++---- 5 files changed, 172 insertions(+), 26 deletions(-) create mode 100644 lib/models/SOAP/my_selected_examination.dart create mode 100644 lib/models/SOAP/post_physical_exam_request_model.dart diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index d9abcd5e..043753b2 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -79,11 +79,12 @@ class BaseAppClient { onFailure('Error While Fetching data', statusCode); } else { var parsed = json.decode(response.body.toString()); - // if (!parsed['IsAuthenticated']) { - // await helpers.logout(); - // - // helpers.showErrorToast('Your session expired Please login agian'); - // } else + if (!parsed['IsAuthenticated']) { + // TODO: return it back when IsAuthenticated work fine in all service + // await helpers.logout(); + + helpers.showErrorToast('Your session expired Please login agian'); + } else if (parsed['MessageStatus'] == 1) { onSuccess(parsed, statusCode); } else { diff --git a/lib/models/SOAP/my_selected_examination.dart b/lib/models/SOAP/my_selected_examination.dart new file mode 100644 index 00000000..3b6685c8 --- /dev/null +++ b/lib/models/SOAP/my_selected_examination.dart @@ -0,0 +1,33 @@ +import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; + +class MySelectedExamination { + MasterKeyModel selectedExamination; + String remark; + bool isNormal; + bool isAbnormal; + + MySelectedExamination( + {this.selectedExamination, this.remark, this.isNormal = true, this.isAbnormal = false}); + + MySelectedExamination.fromJson(Map json) { + + selectedExamination = json['selectedExamination'] != null + ? new MasterKeyModel.fromJson(json['selectedExamination']) + : null; + remark = json['remark']; + remark = json['isNormal']; + remark = json['isAbnormal']; + } + + Map toJson() { + final Map data = new Map(); + + if (this.selectedExamination != null) { + data['selectedExamination'] = this.selectedExamination.toJson(); + } + data['remark'] = this.remark; + data['isNormal'] = this.isNormal; + data['isAbnormal'] = this.isAbnormal; + return data; + } +} diff --git a/lib/models/SOAP/post_physical_exam_request_model.dart b/lib/models/SOAP/post_physical_exam_request_model.dart new file mode 100644 index 00000000..f9f23897 --- /dev/null +++ b/lib/models/SOAP/post_physical_exam_request_model.dart @@ -0,0 +1,99 @@ +import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; + +class PostPhysicalExamRequestModel { + List listHisProgNotePhysicalVM; + + PostPhysicalExamRequestModel({this.listHisProgNotePhysicalVM}); + + PostPhysicalExamRequestModel.fromJson(Map json) { + if (json['listHisProgNotePhysicalVM'] != null) { + listHisProgNotePhysicalVM = new List(); + json['listHisProgNotePhysicalVM'].forEach((v) { + listHisProgNotePhysicalVM + .add(new ListHisProgNotePhysicalVM.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = new Map(); + if (this.listHisProgNotePhysicalVM != null) { + data['listHisProgNotePhysicalVM'] = + this.listHisProgNotePhysicalVM.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class ListHisProgNotePhysicalVM { + int episodeId; + int appointmentNo; + int examType; + int examId; + int patientMRN; + bool isNormal; + bool isAbnormal; + String remarks; + int createdBy; + String createdOn; + int editedBy; + String editedOn; + bool notExamined; + MasterKeyModel masterDescription; + + ListHisProgNotePhysicalVM( + {this.episodeId, + this.appointmentNo, + this.examType, + this.examId, + this.patientMRN, + this.isNormal, + this.isAbnormal, + this.remarks, + this.createdBy, + this.createdOn, + this.editedBy, + this.editedOn, + this.notExamined, + this.masterDescription}); + + ListHisProgNotePhysicalVM.fromJson(Map json) { + episodeId = json['episodeId']; + appointmentNo = json['appointmentNo']; + examType = json['examType']; + examId = json['examId']; + patientMRN = json['patientMRN']; + isNormal = json['isNormal']; + isAbnormal = json['isAbnormal']; + remarks = json['remarks']; + createdBy = json['createdBy']; + createdOn = json['createdOn']; + editedBy = json['editedBy']; + editedOn = json['editedOn']; + notExamined = json['notExamined']; + masterDescription = json['masterDescription'] != null + ? new MasterKeyModel.fromJson(json['masterDescription']) + : null; + } + + Map toJson() { + final Map data = new Map(); + data['episodeId'] = this.episodeId; + data['appointmentNo'] = this.appointmentNo; + data['examType'] = this.examType; + data['examId'] = this.examId; + data['patientMRN'] = this.patientMRN; + data['isNormal'] = this.isNormal; + data['isAbnormal'] = this.isAbnormal; + data['remarks'] = this.remarks; + data['createdBy'] = this.createdBy; + data['createdOn'] = this.createdOn; + data['editedBy'] = this.editedBy; + data['editedOn'] = this.editedOn; + data['notExamined'] = this.notExamined; + if (this.masterDescription != null) { + data['masterDescription'] = this.masterDescription.toJson(); + } + return data; + } +} \ No newline at end of file diff --git a/lib/widgets/patients/profile/SOAP/add_SOAP_index.dart b/lib/widgets/patients/profile/SOAP/add_SOAP_index.dart index 4e8c0873..705bc85f 100644 --- a/lib/widgets/patients/profile/SOAP/add_SOAP_index.dart +++ b/lib/widgets/patients/profile/SOAP/add_SOAP_index.dart @@ -2,6 +2,7 @@ import 'package:doctor_app_flutter/core/viewModel/doctor_replay_view_model.dart' import 'package:doctor_app_flutter/icons_app/doctor_app_icons.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_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'; @@ -30,7 +31,7 @@ class _AddSOAPIndexState extends State int _currentIndex = 0; List myAllergiesList= List(); List myHistoryList = List(); - List myExaminationList = List(); + List mySelectedExamination = List(); changePageViewIndex(pageIndex) { _controller.jumpToPage(pageIndex); } @@ -154,7 +155,7 @@ class _AddSOAPIndexState extends State scrollDirection: Axis.horizontal, children: [ SubjectivePage(changePageViewIndex: changePageViewIndex,myAllergiesList: myAllergiesList,myHistoryList: myHistoryList,), - ObjectivePage(changePageViewIndex: changePageViewIndex,myExaminationList:myExaminationList), + ObjectivePage(changePageViewIndex: changePageViewIndex,mySelectedExamination:mySelectedExamination), AssessmentPage(changePageViewIndex: changePageViewIndex,), PlanPage(changePageViewIndex: changePageViewIndex,) ], diff --git a/lib/widgets/patients/profile/SOAP/objective_page.dart b/lib/widgets/patients/profile/SOAP/objective_page.dart index c3e8d5db..a1b91864 100644 --- a/lib/widgets/patients/profile/SOAP/objective_page.dart +++ b/lib/widgets/patients/profile/SOAP/objective_page.dart @@ -3,6 +3,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/master_key_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/my_selected_examination.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'; @@ -19,9 +20,10 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart'; class ObjectivePage extends StatefulWidget { final Function changePageViewIndex; - final List myExaminationList; + final List mySelectedExamination; - ObjectivePage({Key key, this.changePageViewIndex, this.myExaminationList}); + ObjectivePage( + {Key key, this.changePageViewIndex, this.mySelectedExamination}); @override _ObjectivePageState createState() => _ObjectivePageState(); @@ -29,7 +31,6 @@ class ObjectivePage extends StatefulWidget { class _ObjectivePageState extends State { bool isSysExaminationExpand = false; - List examinationsList; TextEditingController remarksController = TextEditingController(); BoxDecoration containerBorderDecoration( @@ -124,7 +125,8 @@ class _ObjectivePageState extends State { height: 20, ), Column( - children: widget.myExaminationList.map((examination) { + children: + widget.mySelectedExamination.map((examination) { return Container( margin: EdgeInsets.only( left: 15, right: 15, top: 15), @@ -133,7 +135,10 @@ class _ObjectivePageState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Texts(examination.nameEn.toUpperCase(), + Texts( + examination + .selectedExamination.nameEn + .toUpperCase(), variant: "bodyText", bold: true, color: Colors.black) @@ -216,13 +221,14 @@ class _ObjectivePageState extends State { ], ), InkWell( - + child: Icon( FontAwesomeIcons.trash, color: Colors.grey, size: 20, ), - onTap: ()=>removeExamination(examination), + onTap: () => removeExamination( + examination.selectedExamination), ) ], ), @@ -277,13 +283,15 @@ class _ObjectivePageState extends State { } removeExamination(MasterKeyModel masterKey) { - Iterable history = widget.myExaminationList.where( + Iterable history = widget.mySelectedExamination + .where( (element) => - masterKey.id == element.id && masterKey.typeId == element.typeId); + masterKey.id == element.selectedExamination.id && + masterKey.typeId == element.selectedExamination.typeId); if (history.length > 0) setState(() { - widget.myExaminationList.remove(history.first); + widget.mySelectedExamination.remove(history.first); }); } @@ -321,7 +329,7 @@ class _ObjectivePageState extends State { context: context, builder: (context) { return AddExaminationDailog( - myExaminationList: widget.myExaminationList, + mySelectedExamination: widget.mySelectedExamination, addSelectedExamination: () { setState(() { Navigator.of(context).pop(); @@ -333,12 +341,12 @@ class _ObjectivePageState extends State { } class AddExaminationDailog extends StatefulWidget { - final List myExaminationList; + final List mySelectedExamination; final Function addSelectedExamination; final Function (MasterKeyModel) removeExamination; const AddExaminationDailog( - {Key key, this.myExaminationList, this.addSelectedExamination, this.removeExamination}) + {Key key, this.mySelectedExamination, this.addSelectedExamination, this.removeExamination}) : super(key: key); @override @@ -422,10 +430,13 @@ class _AddExaminationDailogState extends State { ); } else { + MySelectedExamination mySelectedExamination = new MySelectedExamination( + selectedExamination: examinationInfo + ); widget - .myExaminationList + .mySelectedExamination .add( - examinationInfo); + mySelectedExamination); } }); }), @@ -475,12 +486,13 @@ class _AddExaminationDailogState extends State { } isServiceSelected(MasterKeyModel masterKey) { - Iterable history = + Iterable exam = widget - .myExaminationList + .mySelectedExamination .where((element) => - masterKey.id == element.id && masterKey.typeId == element.typeId); - if (history.length > 0) { + masterKey.id == element.selectedExamination.id && + masterKey.typeId == element.selectedExamination.typeId); + if (exam.length > 0) { return true; } return false; From 26a25f44e09a41c7cf73a98f25018e1064a8866c Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Mon, 28 Dec 2020 10:42:24 +0200 Subject: [PATCH 4/5] fix error null thing --- lib/client/base_app_client.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index 7aeeba29..2fda496a 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -93,8 +93,9 @@ class BaseAppClient { parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']; if (parsed["ValidationErrors"] != null) { - error = - parsed["ValidationErrors"]["StatusMessage"].toString() + "\n"; + // TODO : return it back after check the StatusMessage it not null + // error = + // parsed["ValidationErrors"]["StatusMessage"].toString() + "\n"; if (parsed["ValidationErrors"]["ValidationErrors"] != null && parsed["ValidationErrors"]["ValidationErrors"].length != 0) { From 18d58e70378f7d1e972756e7d23ac3d47aba6de5 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Mon, 28 Dec 2020 11:07:52 +0200 Subject: [PATCH 5/5] remove is Auth for test target --- lib/client/base_app_client.dart | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index 2fda496a..597de3b4 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -80,12 +80,12 @@ class BaseAppClient { onFailure('Error While Fetching data', statusCode); } else { var parsed = json.decode(response.body.toString()); - if (!parsed['IsAuthenticated']) { - // TODO: return it back when IsAuthenticated work fine in all service - // await helpers.logout(); - - helpers.showErrorToast('Your session expired Please login agian'); - } else + // if (!parsed['IsAuthenticated']) { + // // TODO: return it back when IsAuthenticated work fine in all service + // // await helpers.logout(); + // + // helpers.showErrorToast('Your session expired Please login agian'); + // } else if (parsed['MessageStatus'] == 1) { onSuccess(parsed, statusCode); } else { @@ -93,9 +93,8 @@ class BaseAppClient { parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']; if (parsed["ValidationErrors"] != null) { - // TODO : return it back after check the StatusMessage it not null - // error = - // parsed["ValidationErrors"]["StatusMessage"].toString() + "\n"; + error = + parsed["ValidationErrors"]["StatusMessage"].toString() + "\n"; if (parsed["ValidationErrors"]["ValidationErrors"] != null && parsed["ValidationErrors"]["ValidationErrors"].length != 0) {