From 5e31c9cf985a45fabe9569366b995d079f83f59b Mon Sep 17 00:00:00 2001 From: "taha.alam" Date: Mon, 25 Nov 2024 09:14:47 +0300 Subject: [PATCH] WD: general speciality --- lib/config/config.dart | 4 + .../SOAP/physical_exam/GeneralSpeciality.dart | 24 + .../soap/SOAP_service.dart | 705 ++++++++++-------- lib/core/viewModel/SOAP_view_model.dart | 60 +- .../add_details_to_examination_vida_plus.dart | 48 +- .../add_examination_page_vida_plus.dart | 85 ++- .../add_examination_vida_plus_widget.dart | 258 +------ ...inations_list_search_vida_plus_widget.dart | 36 +- .../objective/list_of_examination.dart | 28 +- .../update_objective_page_vida_plus.dart | 316 ++++---- 10 files changed, 696 insertions(+), 868 deletions(-) create mode 100644 lib/core/model/SOAP/physical_exam/GeneralSpeciality.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index b7dd3ee2..70c60788 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -328,6 +328,10 @@ const ADD_TO_FAVORITE_DIAGNOSIS = 'Services/DoctorApplication.svc/REST/Diagnosis const MAKE_PREVIOUS_AS_CURRENT_DIAGNOSIS = 'Services/DoctorApplication.svc/REST/ContinuePreviousEpisode'; +const SEARCH_PHYSICAL_EXAMINATION = 'Services/DoctorApplication.svc/REST/SearchPhysicalExam'; + +const GET_GENERAL_SPECIALITY = 'Services/DoctorApplication.svc/REST/GetGeneralSpeciality'; + var selectedPatientType = 1; diff --git a/lib/core/model/SOAP/physical_exam/GeneralSpeciality.dart b/lib/core/model/SOAP/physical_exam/GeneralSpeciality.dart new file mode 100644 index 00000000..7428f6a2 --- /dev/null +++ b/lib/core/model/SOAP/physical_exam/GeneralSpeciality.dart @@ -0,0 +1,24 @@ +class GeneralSpeciality { + int? id; + bool? isActive; + String? name; + int? rowVersion; + bool isSelected = false; + + GeneralSpeciality(); + + GeneralSpeciality.fromJson(Map json) { + id = json['id']; + isActive = json['isActive']; + name = json['name']; + rowVersion = json['rowVersion']; + } + Map toJson() { + return { + 'id': id, + 'isActive': isActive, + 'name': name, + 'rowVersion': rowVersion, + }; + } +} diff --git a/lib/core/service/patient_medical_file/soap/SOAP_service.dart b/lib/core/service/patient_medical_file/soap/SOAP_service.dart index 7fc58e7a..c7d74ce0 100644 --- a/lib/core/service/patient_medical_file/soap/SOAP_service.dart +++ b/lib/core/service/patient_medical_file/soap/SOAP_service.dart @@ -12,7 +12,9 @@ import 'package:doctor_app_flutter/core/model/SOAP/chief_complaint/search_chief_ import 'package:doctor_app_flutter/core/model/SOAP/general_get_req_for_SOAP.dart'; import 'package:doctor_app_flutter/core/model/SOAP/Assessment/get_assessment_req_model.dart'; import 'package:doctor_app_flutter/core/model/SOAP/get_hopi_details.dart'; +import 'package:doctor_app_flutter/core/model/SOAP/physical_exam/GeneralSpeciality.dart'; import 'package:doctor_app_flutter/core/model/SOAP/physical_exam/patient_physical_examination.dart'; +import 'package:doctor_app_flutter/core/model/SOAP/physical_exam/post_physical_examination_model.dart'; import 'package:doctor_app_flutter/core/model/SOAP/post_episode_req_model.dart'; import 'package:doctor_app_flutter/core/model/SOAP/chief_complaint/get_chief_complaint_req_model.dart'; import 'package:doctor_app_flutter/core/model/SOAP/chief_complaint/get_chief_complaint_res_model.dart'; @@ -55,6 +57,7 @@ class SOAPService extends LookupService { List auditDiagnosislist = []; List searchDiagnosisList = []; List patientPhysicalExaminationList = []; + List generalSpeciality = []; Map diagnosisTypeList = {}; Map conditionTypeList = {}; List icdVersionList = []; @@ -69,26 +72,25 @@ class SOAPService extends LookupService { await baseAppClient.post(POST_EPISODE, onSuccess: (dynamic response, int statusCode) { - print("Success"); - episodeID = response['EpisodeID']; - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: postEpisodeReqModel.toJson()); + print("Success"); + episodeID = response['EpisodeID']; + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: postEpisodeReqModel.toJson()); } - Future postEpisodeForInPatient( - PostEpisodeForInpatientRequestModel - postEpisodeForInpatientRequestModel) async { + Future postEpisodeForInPatient(PostEpisodeForInpatientRequestModel + postEpisodeForInpatientRequestModel) async { hasError = false; await baseAppClient.post(POST_EPISODE_FOR_IN_PATIENT, onSuccess: (dynamic response, int statusCode) { - episodeID = response['EpisodeID']; - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: postEpisodeForInpatientRequestModel.toJson()); + episodeID = response['EpisodeID']; + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: postEpisodeForInpatientRequestModel.toJson()); } Future postAllergy(PostAllergyRequestModel postAllergyRequestModel) async { @@ -96,11 +98,11 @@ class SOAPService extends LookupService { await baseAppClient.post(POST_ALLERGY, onSuccess: (dynamic response, int statusCode) { - print("Success"); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = super.error! + "\n" + error; - }, body: postAllergyRequestModel.toJson()); + print("Success"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = super.error! + "\n" + error; + }, body: postAllergyRequestModel.toJson()); } Future postHistories( @@ -108,11 +110,11 @@ class SOAPService extends LookupService { hasError = false; await baseAppClient.post(POST_HISTORY, onSuccess: (dynamic response, int statusCode) { - print("Success"); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = super.error! + "\n" + error; - }, body: postHistoriesRequestModel.toJson()); + print("Success"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = super.error! + "\n" + error; + }, body: postHistoriesRequestModel.toJson()); } Future postChiefComplaint( @@ -121,11 +123,11 @@ class SOAPService extends LookupService { super.error = ""; 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()); + print("Success"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: postChiefComplaintRequestModel.toJson()); } Future postPhysicalExam( @@ -133,11 +135,11 @@ class SOAPService extends LookupService { hasError = false; await baseAppClient.post(POST_PHYSICAL_EXAM, onSuccess: (dynamic response, int statusCode) { - print("Success"); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: postPhysicalExamRequestModel.toJson()); + print("Success"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: postPhysicalExamRequestModel.toJson()); } Future postProgressNote( @@ -145,11 +147,11 @@ class SOAPService extends LookupService { hasError = false; await baseAppClient.post(POST_PROGRESS_NOTE, onSuccess: (dynamic response, int statusCode) { - print("Success"); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: postProgressNoteRequestModel.toJson()); + print("Success"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: postProgressNoteRequestModel.toJson()); } Future postAssessment( @@ -157,11 +159,11 @@ class SOAPService extends LookupService { hasError = false; await baseAppClient.post(POST_ASSESSMENT, onSuccess: (dynamic response, int statusCode) { - print("Success"); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: postAssessmentRequestModel.toJson()); + print("Success"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: postAssessmentRequestModel.toJson()); } Future patchAllergy(PostAllergyRequestModel patchAllergyRequestModel) async { @@ -169,11 +171,11 @@ class SOAPService extends LookupService { await baseAppClient.post(PATCH_ALLERGY, onSuccess: (dynamic response, int statusCode) { - print("Success"); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = "\n" + error; - }, body: patchAllergyRequestModel.toJson()); + print("Success"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = "\n" + error; + }, body: patchAllergyRequestModel.toJson()); } Future patchHistories( @@ -181,11 +183,11 @@ class SOAPService extends LookupService { hasError = false; await baseAppClient.post(PATCH_HISTORY, onSuccess: (dynamic response, int statusCode) { - print("Success"); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = super.error! + "\n" + error; - }, body: patchHistoriesRequestModel.toJson()); + print("Success"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = super.error! + "\n" + error; + }, body: patchHistoriesRequestModel.toJson()); } Future patchChiefComplaint( @@ -194,11 +196,11 @@ class SOAPService extends LookupService { super.error = ""; 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()); + print("Success"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: patchChiefComplaintRequestModel.toJson()); } Future patchPhysicalExam( @@ -206,11 +208,11 @@ class SOAPService extends LookupService { 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()); + print("Success"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: patchPhysicalExamRequestModel.toJson()); } Future patchProgressNote( @@ -218,11 +220,11 @@ class SOAPService extends LookupService { 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()); + print("Success"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: patchProgressNoteRequestModel.toJson()); } Future patchAssessment( @@ -230,11 +232,11 @@ class SOAPService extends LookupService { hasError = false; await baseAppClient.post(POST_ASSESSMENT, onSuccess: (dynamic response, int statusCode) { - print("Success"); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: patchAssessmentRequestModel.toJson()); + print("Success"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: patchAssessmentRequestModel.toJson()); } Future getPatientAllergy(GeneralGetReqForSOAP generalGetReqForSOAP) async { @@ -243,16 +245,16 @@ class SOAPService extends LookupService { ///TODO Elham* change the url constant to get getPatientAllergy await baseAppClient.post(GET_ALLERGIES, onSuccess: (dynamic response, int statusCode) { - print("Success"); - patientAllergiesList.clear(); + 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: generalGetReqForSOAP.toJson()); + response['List_Allergies']['entityList'].forEach((v) { + patientAllergiesList.add(GetAllergiesResModel.fromJson(v)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: generalGetReqForSOAP.toJson()); } Future getPatientHistories(GetHistoryReqModel getHistoryReqModel, @@ -260,15 +262,15 @@ class SOAPService extends LookupService { hasError = false; await baseAppClient.post(GET_HISTORY, onSuccess: (dynamic response, int statusCode) { - print("Success"); - if (isFirst) patientHistoryList.clear(); - response['List_History']['entityList'].forEach((v) { - patientHistoryList.add(GetHistoryResModel.fromJson(v)); - }); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: getHistoryReqModel.toJson()); + print("Success"); + if (isFirst) patientHistoryList.clear(); + response['List_History']['entityList'].forEach((v) { + patientHistoryList.add(GetHistoryResModel.fromJson(v)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: getHistoryReqModel.toJson()); } Future getPatientChiefComplaint( @@ -276,15 +278,16 @@ class SOAPService extends LookupService { hasError = false; await baseAppClient.post(GET_CHIEF_COMPLAINT, onSuccess: (dynamic response, int statusCode) { - print("Success"); - patientChiefComplaintList.clear(); - response['List_ChiefComplaint']['entityList'].forEach((v) { - patientChiefComplaintList.add(GetChiefComplaintResModel.fromJson(v)); - }); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: getChiefComplaintReqModel.toJson()); + print("Success"); + patientChiefComplaintList.clear(); + response['List_ChiefComplaint']['entityList'].forEach((v) { + patientChiefComplaintList.add( + GetChiefComplaintResModel.fromJson(v)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: getChiefComplaintReqModel.toJson()); } Future getPatientPhysicalExam( @@ -292,14 +295,14 @@ class SOAPService extends LookupService { hasError = false; await baseAppClient.post(GET_PHYSICAL_EXAM, onSuccess: (dynamic response, int statusCode) { - patientPhysicalExamList.clear(); - response['PhysicalExamList']['entityList'].forEach((v) { - patientPhysicalExamList.add(GetPhysicalExamResModel.fromJson(v)); - }); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: getPhysicalExamReqModel.toJson()); + patientPhysicalExamList.clear(); + response['PhysicalExamList']['entityList'].forEach((v) { + patientPhysicalExamList.add(GetPhysicalExamResModel.fromJson(v)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: getPhysicalExamReqModel.toJson()); } Future getPatientProgressNote( @@ -307,15 +310,16 @@ class SOAPService extends LookupService { hasError = false; await baseAppClient.post(GET_PROGRESS_NOTE, onSuccess: (dynamic response, int statusCode) { - print("Success"); - patientProgressNoteList.clear(); - response['ProgressNoteList']['entityList'].forEach((v) { - patientProgressNoteList.add(GetPatientProgressNoteResModel.fromJson(v)); - }); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: getGetProgressNoteReqModel.toJson()); + print("Success"); + patientProgressNoteList.clear(); + response['ProgressNoteList']['entityList'].forEach((v) { + patientProgressNoteList.add( + GetPatientProgressNoteResModel.fromJson(v)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: getGetProgressNoteReqModel.toJson()); } Future getPatientAssessment( @@ -323,15 +327,15 @@ class SOAPService extends LookupService { hasError = false; await baseAppClient.post(GET_ASSESSMENT, onSuccess: (dynamic response, int statusCode) { - print("Success"); - patientAssessmentList.clear(); - response['AssessmentList']['entityList'].forEach((v) { - patientAssessmentList.add(GetAssessmentResModel.fromJson(v)); - }); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: getAssessmentReqModel.toJson()); + print("Success"); + patientAssessmentList.clear(); + response['AssessmentList']['entityList'].forEach((v) { + patientAssessmentList.add(GetAssessmentResModel.fromJson(v)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: getAssessmentReqModel.toJson()); } Future getEpisodeForInpatient( @@ -339,31 +343,31 @@ class SOAPService extends LookupService { hasError = false; await baseAppClient.post(GET_EPISODE_FOR_INPATIENT, onSuccess: (dynamic response, int statusCode) { - print("Success"); + print("Success"); - episodeID = response["GetEpisodeNo"]; - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: getEpisodeForInpatientReqModel.toJson()); + episodeID = response["GetEpisodeNo"]; + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: getEpisodeForInpatientReqModel.toJson()); } Future isPrescriptionOrderCreated(PatiantInformtion patientInfo) async { hasError = false; await baseAppClient.post(IS_PRESCRIPTION_ORDER_CREATED, onSuccess: (dynamic response, int statusCode) { - print("Success"); - - isPrescriptionOrder = response['IsPrescriptionCreated']; - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: { - "PatientMRN": patientInfo.patientMRN, - "EncounterNo": patientInfo.appointmentNo, - "EncounterType": patientInfo.appointmentTypeId, - "DoctorID": patientInfo.doctorId, - }); + print("Success"); + + isPrescriptionOrder = response['IsPrescriptionCreated']; + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: { + "PatientMRN": patientInfo.patientMRN, + "EncounterNo": patientInfo.appointmentNo, + "EncounterType": patientInfo.appointmentTypeId, + "DoctorID": patientInfo.doctorId, + }); } /* vida plus API allergies */ @@ -376,16 +380,16 @@ class SOAPService extends LookupService { hasError = false; await baseAppClient.post(PATIENT_ALLERGIES, onSuccess: (dynamic response, int statusCode) { - print("Success"); - patientAllergiesVidaPlus.clear(); + print("Success"); + patientAllergiesVidaPlus.clear(); - response['List_PatientAllergies']['resultData'].forEach((v) { - patientAllergiesVidaPlus.add(PatientAllergiesVidaPlus.fromJson(v)); - }); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: request); + response['List_PatientAllergies']['resultData'].forEach((v) { + patientAllergiesVidaPlus.add(PatientAllergiesVidaPlus.fromJson(v)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: request); } Future searchAllergies(String searchKey) async { @@ -393,20 +397,20 @@ class SOAPService extends LookupService { await baseAppClient.post(SEARCH_ALLERGIES, onSuccess: (dynamic response, int statusCode) { - print("Success"); - searchAllergiesList.clear(); + print("Success"); + searchAllergiesList.clear(); - response['List_SearchAllergies']['resultData'].forEach((v) { - searchAllergiesList.add(AllergiesListVidaPlus.fromJson(v)); - }); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: {"AllergyName": searchKey}); + response['List_SearchAllergies']['resultData'].forEach((v) { + searchAllergiesList.add(AllergiesListVidaPlus.fromJson(v)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: {"AllergyName": searchKey}); } - Future addAllergies( - AllergiesListVidaPlus allergy, PatiantInformtion patientInfo) async { + Future addAllergies(AllergiesListVidaPlus allergy, + PatiantInformtion patientInfo) async { allergy.allergyReactionDTOs!.forEach((value) { value.patientID = patientInfo.patientMRN; value.pomrid = int.parse(patientInfo.pomrId!); @@ -438,22 +442,22 @@ class SOAPService extends LookupService { await baseAppClient.post(POST_ALLERGIES, onSuccess: (dynamic response, int statusCode) { - DrAppToastMsg.showSuccesToast("Allergies Saved Successfully"); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: { - "listProgNotePatientAllergyDiseaseVM": [request] - }); + DrAppToastMsg.showSuccesToast("Allergies Saved Successfully"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: { + "listProgNotePatientAllergyDiseaseVM": [request] + }); } - Future resolveAllergies( - PatientAllergiesVidaPlus allergy, PatiantInformtion patientInfo) async { + Future resolveAllergies(PatientAllergiesVidaPlus allergy, + PatiantInformtion patientInfo) async { /*changed request parameters based on the vida plus requested */ var doctorProfile = await sharedPref.getObj(LOGGED_IN_USER); List? reaction = - allergy.patientsAllergyReactionsDTOs!; + allergy.patientsAllergyReactionsDTOs!; List? reactionRequest = []; reaction.forEach((value) { reactionRequest.add(AllergyReactionDTOs( @@ -487,17 +491,17 @@ class SOAPService extends LookupService { hasError = false; await baseAppClient.post(RESOLVE_ALLERGIES, onSuccess: (dynamic response, int statusCode) { - DrAppToastMsg.showSuccesToast("Resolved Successfully"); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: { - "listProgNotePatientAllergyDiseaseVM": [request] - }); + DrAppToastMsg.showSuccesToast("Resolved Successfully"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: { + "listProgNotePatientAllergyDiseaseVM": [request] + }); } - Future updateAllergies( - AllergiesListVidaPlus allergy, PatiantInformtion patientInfo) async { + Future updateAllergies(AllergiesListVidaPlus allergy, + PatiantInformtion patientInfo) async { allergy.allergyReactionDTOs!.forEach((value) { value.patientID = patientInfo.patientMRN; value.pomrid = patientInfo.episodeNo; @@ -529,13 +533,13 @@ class SOAPService extends LookupService { await baseAppClient.post(UPDATE_ALLERGIES, onSuccess: (dynamic response, int statusCode) { - DrAppToastMsg.showSuccesToast("Allergies Saved Successfully"); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: { - "listProgNotePatientAllergyDiseaseVM": [request] - }); + DrAppToastMsg.showSuccesToast("Allergies Saved Successfully"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: { + "listProgNotePatientAllergyDiseaseVM": [request] + }); } saveHopi(Map req, PatiantInformtion patient) async { @@ -548,17 +552,15 @@ class SOAPService extends LookupService { "patientId": patient.patientMRN, "patientPomrId": patient.pomrId, }; - Map finalRequest = {} - ..addAll(request) - ..addAll(req); + Map finalRequest = {}..addAll(request)..addAll(req); hasError = false; await baseAppClient.post(CREATE_HOPI, onSuccess: (dynamic response, int statusCode) { - DrAppToastMsg.showSuccesToast("History Saved Successfully"); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: finalRequest); + DrAppToastMsg.showSuccesToast("History Saved Successfully"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: finalRequest); } getHopi(PatiantInformtion patient) async { @@ -569,15 +571,15 @@ class SOAPService extends LookupService { hasError = false; await baseAppClient.post(HOPI_DETAILS, onSuccess: (dynamic response, int statusCode) { - hopiDetails.clear(); + hopiDetails.clear(); - response['DetailHOPI']['resultData'].forEach((v) { - hopiDetails.add(GetHopiDetails.fromJson(v)); - }); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: request); + response['DetailHOPI']['resultData'].forEach((v) { + hopiDetails.add(GetHopiDetails.fromJson(v)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: request); } getChiefComplaint(PatiantInformtion patient) async { @@ -588,20 +590,20 @@ class SOAPService extends LookupService { hasError = false; await baseAppClient.post(GET_CHIEF_COMPLAINT_VP, onSuccess: (dynamic response, int statusCode) { - patientChiefComplaintListVidaPlus.clear(); + patientChiefComplaintListVidaPlus.clear(); - response['ListChiefComplaintDetails']['resultData'].forEach((v) { - patientChiefComplaintListVidaPlus - .add(GetChiefComplaintVidaPlus.fromJson(v)); - }); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: request); + response['ListChiefComplaintDetails']['resultData'].forEach((v) { + patientChiefComplaintListVidaPlus + .add(GetChiefComplaintVidaPlus.fromJson(v)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: request); } - postChiefComplaintVidaPlus( - PatiantInformtion patient, String cheifComplaint) async { + postChiefComplaintVidaPlus(PatiantInformtion patient, + String cheifComplaint) async { Map request = { "ListCreateChiefComplaint": [ { @@ -615,11 +617,11 @@ class SOAPService extends LookupService { hasError = false; await baseAppClient.post(POST_CHIEF_COMPLAINT_VP, onSuccess: (dynamic response, int statusCode) { - print("Success"); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: request); + print("Success"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: request); } searchChiefComplaintVidaPlus(PatiantInformtion patient, String CC) async { @@ -631,16 +633,17 @@ class SOAPService extends LookupService { searchChiefComplaintListVidaPlus.clear(); await baseAppClient.post(SEARCH_CHIEF_COMPLAINT_VP, onSuccess: (dynamic response, int statusCode) { - searchChiefComplaintListVidaPlus.clear(); - // - response['List_SearchChiefComplaint']['resultData'].forEach((v) { - searchChiefComplaintListVidaPlus.add(SearchChiefComplaint.fromJson(v)); - }); - }, onFailure: (String error, int statusCode) { - searchChiefComplaintListVidaPlus.clear(); - hasError = true; - super.error = error; - }, body: request); + searchChiefComplaintListVidaPlus.clear(); + // + response['List_SearchChiefComplaint']['resultData'].forEach((v) { + searchChiefComplaintListVidaPlus.add( + SearchChiefComplaint.fromJson(v)); + }); + }, onFailure: (String error, int statusCode) { + searchChiefComplaintListVidaPlus.clear(); + hasError = true; + super.error = error; + }, body: request); } searchDiagnosis(PatiantInformtion patient, String diagnosis) async { @@ -652,14 +655,15 @@ class SOAPService extends LookupService { await baseAppClient.post(SEARCH_DIAGNOSIS, onSuccess: (dynamic response, int statusCode) { - response['List_Diagnosis']['resultData'] - .forEach((v) => searchDiagnosisList.add(SearchDiagnosis.fromJson(v))); - _processData(); - }, onFailure: (String error, int statusCode) { - searchChiefComplaintListVidaPlus.clear(); - hasError = true; - super.error = error; - }, body: request); + response['List_Diagnosis']['resultData'] + .forEach((v) => + searchDiagnosisList.add(SearchDiagnosis.fromJson(v))); + _processData(); + }, onFailure: (String error, int statusCode) { + searchChiefComplaintListVidaPlus.clear(); + hasError = true; + super.error = error; + }, body: request); } void _processData() { @@ -688,13 +692,14 @@ class SOAPService extends LookupService { diagnosisTypeList.clear(); await baseAppClient.post(DIAGNOSIS_TYPE, onSuccess: (dynamic response, int statusCode) { - response['ListDiagnosisTypeModel']['resultData'] - .forEach((v) => diagnosisTypeList[v['name']] = v['diagnosisType']); - }, onFailure: (String error, int statusCode) { - searchChiefComplaintListVidaPlus.clear(); - hasError = true; - super.error = error; - }, body: request); + response['ListDiagnosisTypeModel']['resultData'] + .forEach((v) => + diagnosisTypeList[v['name']] = v['diagnosisType']); + }, onFailure: (String error, int statusCode) { + searchChiefComplaintListVidaPlus.clear(); + hasError = true; + super.error = error; + }, body: request); } getConditionType(PatiantInformtion patient) async { @@ -703,20 +708,18 @@ class SOAPService extends LookupService { conditionTypeList.clear(); await baseAppClient.post(CONDITION_TYPE, onSuccess: (dynamic response, int statusCode) { - response['ListDiagnosisCondition']['resultData'] - .forEach((v) => conditionTypeList[v['itemName']] = v['id']); - ; - }, onFailure: (String error, int statusCode) { - searchChiefComplaintListVidaPlus.clear(); - hasError = true; - super.error = error; - }, body: request); + response['ListDiagnosisCondition']['resultData'] + .forEach((v) => conditionTypeList[v['itemName']] = v['id']); + ; + }, onFailure: (String error, int statusCode) { + searchChiefComplaintListVidaPlus.clear(); + hasError = true; + super.error = error; + }, body: request); } - auditDiagnosis( - PatiantInformtion patient, - String patientProblemRevisionID, - ) async { + auditDiagnosis(PatiantInformtion patient, + String patientProblemRevisionID,) async { Map request = { "patientProblemRevisionId": patientProblemRevisionID, "ProjectID": patient.projectId @@ -725,14 +728,15 @@ class SOAPService extends LookupService { auditDiagnosislist.clear(); await baseAppClient.post(AUDIT_DIAGNOSIS, onSuccess: (dynamic response, int statusCode) { - response['ListDaignosisAudit']['resultData'] - .forEach((v) => auditDiagnosislist.add(AuditDiagnosis.fromJson(v))); - showAuditBottomSheet = auditDiagnosislist.isNotEmpty; - }, onFailure: (String error, int statusCode) { - auditDiagnosislist.clear(); - hasError = true; - super.error = error; - }, body: request); + response['ListDaignosisAudit']['resultData'] + .forEach((v) => + auditDiagnosislist.add(AuditDiagnosis.fromJson(v))); + showAuditBottomSheet = auditDiagnosislist.isNotEmpty; + }, onFailure: (String error, int statusCode) { + auditDiagnosislist.clear(); + hasError = true; + super.error = error; + }, body: request); } getPreviousDiagnosis(PatiantInformtion patient) async { @@ -757,14 +761,14 @@ class SOAPService extends LookupService { patientPreviousDiagnosisList.clear(); await baseAppClient.post(PREVIOUS_DIAGNOSIS, onSuccess: (dynamic response, int statusCode) { - response['ListDiagnosisPrviousDetials']['resultData'].forEach((v) => - patientPreviousDiagnosisList - .add(PatientPreviousDiagnosis.fromJson(v))); - }, onFailure: (String error, int statusCode) { - patientPreviousDiagnosisList.clear(); - hasError = true; - super.error = error; - }, body: request); + response['ListDiagnosisPrviousDetials']['resultData'].forEach((v) => + patientPreviousDiagnosisList + .add(PatientPreviousDiagnosis.fromJson(v))); + }, onFailure: (String error, int statusCode) { + patientPreviousDiagnosisList.clear(); + hasError = true; + super.error = error; + }, body: request); } removeDiagnosis(PatiantInformtion patientInfo, String? patientProblemId, @@ -786,18 +790,17 @@ class SOAPService extends LookupService { patientPreviousDiagnosisList.clear(); await baseAppClient.post(REMOVE_DIAGNOSIS, onSuccess: (dynamic response, int statusCode) { - DrAppToastMsg.showSuccesToast(response['ListDiagnosisRemove']['message']); - //todo get the current diagnosis after the delete if it is successful - }, onFailure: (String error, int statusCode) { - patientPreviousDiagnosisList.clear(); - hasError = true; - super.error = error; - }, body: request); + DrAppToastMsg.showSuccesToast( + response['ListDiagnosisRemove']['message']); + //todo get the current diagnosis after the delete if it is successful + }, onFailure: (String error, int statusCode) { + patientPreviousDiagnosisList.clear(); + hasError = true; + super.error = error; + }, body: request); } - favoriteDiagnosis( - PatiantInformtion patientInfo, - ) async { + favoriteDiagnosis(PatiantInformtion patientInfo,) async { Map? user = await sharedPref.getObj(LOGGED_IN_USER); Map request = { @@ -812,18 +815,17 @@ class SOAPService extends LookupService { favoriteDiagnosisDetailsList.clear(); await baseAppClient.post(FAVORITE_DIAGNOSIS, onSuccess: (dynamic response, int statusCode) { - response['ListDiagnosisGetFavourite']['resultData'].forEach((v) => - favoriteDiagnosisDetailsList.add(FavoriteDiseaseDetails.fromJson(v))); - }, onFailure: (String error, int statusCode) { - favoriteDiagnosisDetailsList.clear(); - hasError = true; - super.error = error; - }, body: request); + response['ListDiagnosisGetFavourite']['resultData'].forEach((v) => + favoriteDiagnosisDetailsList.add( + FavoriteDiseaseDetails.fromJson(v))); + }, onFailure: (String error, int statusCode) { + favoriteDiagnosisDetailsList.clear(); + hasError = true; + super.error = error; + }, body: request); } - getPhysicalExamination( - PatiantInformtion patientInfo, - ) async { + getPhysicalExamination(PatiantInformtion patientInfo,) async { Map? user = await sharedPref.getObj(LOGGED_IN_USER); Map request = { @@ -831,19 +833,59 @@ class SOAPService extends LookupService { "pomrId": patientInfo.pomrId, "hospitalId": patientInfo.projectId, "hospitalGroupId": await sharedPref.getString(DOCTOR_SETUP_ID), - "ProjectID":patientInfo.projectId + "ProjectID": patientInfo.projectId }; hasError = false; patientPhysicalExaminationList.clear(); - await baseAppClient.post(FAVORITE_DIAGNOSIS, + await baseAppClient.post(SEARCH_PHYSICAL_EXAMINATION, onSuccess: (dynamic response, int statusCode) { - response['ListPhysicalExam']['resultData'].forEach((v) => - patientPhysicalExaminationList.add(PatientPhysicalExamination.fromJson(v))); - }, onFailure: (String error, int statusCode) { + response['ListPhysicalExam']['resultData'].forEach((v) => + patientPhysicalExaminationList.add( + PatientPhysicalExamination.fromJson(v))); + }, onFailure: (String error, int statusCode) { physicalExaminationList.clear(); - hasError = true; - super.error = error; - }, body: request); + hasError = true; + super.error = error; + }, body: request); + } + + postPhysicalExamination(PatiantInformtion patientInfo,List physicalExamination) async { + var jsonListOfPhysicalExamination = []; + physicalExamination.forEach((value)=>jsonListOfPhysicalExamination.add(value.toJson())); + + Map request = { + "ProjectID": patientInfo.patientId, + "listCreatPhysicalExam": jsonListOfPhysicalExamination + }; + hasError = false; + await baseAppClient.post(SEARCH_PHYSICAL_EXAMINATION, + onSuccess: (dynamic response, int statusCode) { + DrAppToastMsg.showSuccesToast( + response['ListPhysicalExam']['message']); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: request); + } + + + getGeneralSpeciality(PatiantInformtion patientInfo) async { + + Map request = { + "ProjectID": patientInfo.patientId, + }; + hasError = false; + generalSpeciality.clear(); + await baseAppClient.post(GET_GENERAL_SPECIALITY, + onSuccess: (dynamic response, int statusCode) { + response['ListGeneralSpeciality']['resultData'].forEach((v) => + generalSpeciality.add( + GeneralSpeciality.fromJson(v))); + }, onFailure: (String error, int statusCode) { + hasError = true; + generalSpeciality.clear(); + super.error = error; + }, body: request); } addToFavoriteDiagnosis(PatiantInformtion paitientInfo, String doctorName, @@ -866,23 +908,24 @@ class SOAPService extends LookupService { favoriteDiagnosisDetailsList.clear(); await baseAppClient.post(ADD_TO_FAVORITE_DIAGNOSIS, onSuccess: (dynamic response, int statusCode) { - var result = response['ListDiagnosisAddFavourite']['resultData']; - if ((result as List).isEmpty) { - addedToFavorite = false; - DrAppToastMsg.showErrorToast( - response['ListDiagnosisAddFavourite']['message']); - } else { - addedToFavorite = true; - DrAppToastMsg.showSuccesToast("Added To Favorite"); - } - }, onFailure: (String error, int statusCode) { - favoriteDiagnosisDetailsList.clear(); - hasError = true; - super.error = error; - }, body: request); - } - - convertPreviousDiagnosisCurrent(PatiantInformtion paitientInfo, PatientPreviousDiagnosis diagnosis) async { + var result = response['ListDiagnosisAddFavourite']['resultData']; + if ((result as List).isEmpty) { + addedToFavorite = false; + DrAppToastMsg.showErrorToast( + response['ListDiagnosisAddFavourite']['message']); + } else { + addedToFavorite = true; + DrAppToastMsg.showSuccesToast("Added To Favorite"); + } + }, onFailure: (String error, int statusCode) { + favoriteDiagnosisDetailsList.clear(); + hasError = true; + super.error = error; + }, body: request); + } + + convertPreviousDiagnosisCurrent(PatiantInformtion paitientInfo, + PatientPreviousDiagnosis diagnosis) async { Map request = { "patientProblemRevisionId": diagnosis.patientProblemRevisionId, "patientId": paitientInfo.patientId, @@ -895,21 +938,21 @@ class SOAPService extends LookupService { "clinicGroupId": diagnosis.clinicGroupId, "clinicId": diagnosis.clinicId, "isSelected": true, - "ProjectID":paitientInfo.projectId + "ProjectID": paitientInfo.projectId }; hasError = false; addedToFavorite = false; await baseAppClient.post(MAKE_PREVIOUS_AS_CURRENT_DIAGNOSIS, onSuccess: (dynamic response, int statusCode) { - var result = response['ContinuePreviousEpisode']['resultData']; - if ((result as List).isEmpty) { - DrAppToastMsg.showErrorToast( - response['ContinuePreviousEpisode']['message']); - } - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: request); + var result = response['ContinuePreviousEpisode']['resultData']; + if ((result as List).isEmpty) { + DrAppToastMsg.showErrorToast( + response['ContinuePreviousEpisode']['message']); + } + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: request); } createDiagnosis(PatiantInformtion patient, SearchDiagnosis searchDiagnosis, diff --git a/lib/core/viewModel/SOAP_view_model.dart b/lib/core/viewModel/SOAP_view_model.dart index 7b431a04..1b1e3bf7 100644 --- a/lib/core/viewModel/SOAP_view_model.dart +++ b/lib/core/viewModel/SOAP_view_model.dart @@ -29,6 +29,7 @@ import 'package:doctor_app_flutter/core/model/SOAP/physical_exam/get_physical_ex import 'package:doctor_app_flutter/core/model/SOAP/physical_exam/get_physical_exam_req_model.dart'; import 'package:doctor_app_flutter/core/model/SOAP/physical_exam/patient_physical_examination.dart'; import 'package:doctor_app_flutter/core/model/SOAP/physical_exam/post_physical_exam_request_model.dart'; +import 'package:doctor_app_flutter/core/model/SOAP/physical_exam/post_physical_examination_model.dart'; import 'package:doctor_app_flutter/core/model/SOAP/post_episode_req_model.dart'; import 'package:doctor_app_flutter/core/model/SOAP/progress_note/GetGetProgressNoteResModel.dart'; import 'package:doctor_app_flutter/core/model/SOAP/progress_note/get_progress_note_req_model.dart'; @@ -48,6 +49,7 @@ import 'package:doctor_app_flutter/screens/patients/profile/soap_update/subjecti import '../../locator.dart'; import '../model/SOAP/allergy/get_patient_allergies_list_vida_plus.dart'; import '../model/SOAP/assessment/patch_assessment_req_model.dart'; +import '../model/SOAP/physical_exam/GeneralSpeciality.dart'; import 'base_view_model.dart'; class SOAPViewModel extends BaseViewModel { @@ -142,8 +144,13 @@ class SOAPViewModel extends BaseViewModel { List get auditDiagnosislist => _SOAPService.auditDiagnosislist; + List get speciality => + _SOAPService.generalSpeciality; + int? get episodeID => _SOAPService.episodeID; + bool get isFavorite => _SOAPService.addedToFavorite; + bool get showAudit => _SOAPService.showAuditBottomSheet; bool get isPrescriptionOrder => _SOAPService.isPrescriptionOrder; @@ -1128,24 +1135,27 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.Idle); } - void addToFavoriteDiagnosis( - PatiantInformtion patientInfo, { - SearchDiagnosis? diagnosis - }) async { + void addToFavoriteDiagnosis(PatiantInformtion patientInfo, + {SearchDiagnosis? diagnosis}) async { setState(ViewState.BusyLocal); Map? profile = await sharedPref.getObj(DOCTOR_PROFILE); Map? user = await sharedPref.getObj(LOGGED_IN_USER); - await _SOAPService.addToFavoriteDiagnosis(patientInfo,profile?['DoctorName'] ??'',diagnosis?.diseasesBCode ?? '',user?['List_MemberInformation'][0]['MemberID'] ??''); + await _SOAPService.addToFavoriteDiagnosis( + patientInfo, + profile?['DoctorName'] ?? '', + diagnosis?.diseasesBCode ?? '', + user?['List_MemberInformation'][0]['MemberID'] ?? ''); if (_SOAPService.hasError) { error = _SOAPService.error; setState(ViewState.ErrorLocal); } else setState(ViewState.Idle); } - void convertPreviousDiagnosisCurrent( - PatiantInformtion paitientInfo, PatientPreviousDiagnosis diagnosis) async { + + void convertPreviousDiagnosisCurrent(PatiantInformtion paitientInfo, + PatientPreviousDiagnosis diagnosis) async { setState(ViewState.BusyLocal); - await _SOAPService.convertPreviousDiagnosisCurrent(paitientInfo,diagnosis); + await _SOAPService.convertPreviousDiagnosisCurrent(paitientInfo, diagnosis); if (_SOAPService.hasError) { error = _SOAPService.error; setState(ViewState.ErrorLocal); @@ -1153,8 +1163,7 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.Idle); } - void getPhysicalExamination( - PatiantInformtion paitientInfo) async { + void getPhysicalExamination(PatiantInformtion paitientInfo) async { setState(ViewState.BusyLocal); await _SOAPService.getPhysicalExamination(paitientInfo); if (_SOAPService.hasError) { @@ -1164,14 +1173,33 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.Idle); } - void toggleFavorite(bool status ){ - _SOAPService.addedToFavorite - = status; + void postPhysicalExamination(PatiantInformtion patientInfo, + List physicalExamination) async { + setState(ViewState.BusyLocal); + await _SOAPService.postPhysicalExamination( + patientInfo, physicalExamination); + if (_SOAPService.hasError) { + error = _SOAPService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } + void getGeneralSpeciality(PatiantInformtion patientInfo) async { + setState(ViewState.BusyLocal); + await _SOAPService.getGeneralSpeciality( + patientInfo); + if (_SOAPService.hasError) { + error = _SOAPService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); } - void toggleShowBottomSheetValue(bool status){ - _SOAPService.showAuditBottomSheet - = status; + void toggleFavorite(bool status) { + _SOAPService.addedToFavorite = status; } + void toggleShowBottomSheetValue(bool status) { + _SOAPService.showAuditBottomSheet = status; + } } diff --git a/lib/screens/patients/profile/soap_update_vida_plus/objective/add_details_to_examination_vida_plus.dart b/lib/screens/patients/profile/soap_update_vida_plus/objective/add_details_to_examination_vida_plus.dart index c310ddc7..07e6443e 100644 --- a/lib/screens/patients/profile/soap_update_vida_plus/objective/add_details_to_examination_vida_plus.dart +++ b/lib/screens/patients/profile/soap_update_vida_plus/objective/add_details_to_examination_vida_plus.dart @@ -1,4 +1,5 @@ import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; +import 'package:doctor_app_flutter/core/model/SOAP/physical_exam/GeneralSpeciality.dart'; import 'package:doctor_app_flutter/core/model/SOAP/selected_items/my_selected_examination.dart'; import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; @@ -15,7 +16,7 @@ import 'package:provider/provider.dart'; import '../../../../../core/viewModel/project_view_model.dart'; class AddDetailsToExaminationVidaPlus extends StatefulWidget { - final List? mySelectedExamination; + final List? mySelectedExamination; const AddDetailsToExaminationVidaPlus({super.key, this.mySelectedExamination}); @@ -43,31 +44,26 @@ class _AddDetailsToExaminationVidaPlusState extends State? mySelectedExamination; - final Function(List) addSelectedExamination; - final Function(MasterKeyModel) removeExamination; + final PatiantInformtion patientInfo; + final List? examination; - AddExaminationPageVidaPlus( - {this.mySelectedExamination, - required this.addSelectedExamination, - required this.removeExamination}); + ///todo handle the data if edit is added + AddExaminationPageVidaPlus({required this.patientInfo, this.examination}); @override _AddExaminationPageVidaPlusState createState() => @@ -28,12 +34,11 @@ class AddExaminationPageVidaPlus extends StatefulWidget { class _AddExaminationPageVidaPlusState extends State { - List mySelectedExaminationLocal = []; + List mySelectedExaminationLocal = []; @override initState() { super.initState(); - mySelectedExaminationLocal = widget.mySelectedExamination!; } @override @@ -42,15 +47,16 @@ class _AddExaminationPageVidaPlusState onModelReady: (model) async { if (model.physicalExaminationList.length == 0) { WidgetsBinding.instance.addPostFrameCallback((_) async { - await model.getMasterLookup( - MasterKeysService.PostPhysicalExaminationModel, - ); + if (model.speciality.isEmpty) { + await model.getGeneralSpeciality(widget.patientInfo); + } }); } }, builder: (_, model, w) => AppScaffold( baseViewModel: model, isShowAppBar: true, + isLoading: model.state == ViewState.Busy, appBar: PatientSearchHeader( title: TranslationBase.of(context).examinationPart), backgroundColor: Colors.white, @@ -76,19 +82,42 @@ class _AddExaminationPageVidaPlusState mainAxisSize: MainAxisSize.max, children: [ ExaminationsListSearchVidaPlusWidget( - mySelectedExamination: widget.mySelectedExamination, - masterList: model.patientPhysicalExaminationList, - isServiceSelected: (master) => - isServiceSelected(master), + masterList: model.speciality, removeExamination: (selectedExamination) { + if(selectedExamination == null ) return; + setState(() { mySelectedExaminationLocal .remove(selectedExamination); + // Find the object by its ID + try { + final speciality = + model.speciality.firstWhere( + (speciality) => + speciality.id == selectedExamination.id, + orElse: () => throw Exception( + 'Speciality with ID ${selectedExamination.id} not found!'), + ); + + speciality.isSelected = false; + } catch (e) {} }); }, addExamination: (selectedExamination) { + if(selectedExamination == null ) return; + mySelectedExaminationLocal.insert( 0, selectedExamination); + + try { + final speciality = model.speciality.firstWhere( + (speciality) => + speciality.id == selectedExamination.id, + orElse: () => throw Exception( + 'Speciality with ID ${selectedExamination.id} not found!'), + ); + speciality.isSelected = true; + } catch (e) {} //setState(() {}); }, ), @@ -128,10 +157,7 @@ class _AddExaminationPageVidaPlusState fontColor: Colors.white, fontWeight: FontWeight.w600, onPressed: () async { - Navigator.pop(context); - widget.addSelectedExamination(mySelectedExaminationLocal); - - + pushAddExamination(mySelectedExaminationLocal); }, ), ), @@ -141,14 +167,15 @@ class _AddExaminationPageVidaPlusState ); } - isServiceSelected(MasterKeyModel masterKey) { - Iterable exam = mySelectedExaminationLocal.where( - (element) => - masterKey.id == element.selectedExamination!.id && - masterKey.typeId == element.selectedExamination!.typeId); - if (exam.length > 0) { - return true; - } - return false; + void pushAddExamination( + List mySelectedExaminationLocal) { + Navigator.push( + context, + FadePage( + page: AddDetailsToExaminationVidaPlus( + mySelectedExamination: mySelectedExaminationLocal, + ), + ), + ); } } diff --git a/lib/screens/patients/profile/soap_update_vida_plus/objective/add_examination_vida_plus_widget.dart b/lib/screens/patients/profile/soap_update_vida_plus/objective/add_examination_vida_plus_widget.dart index a4510410..90fec299 100644 --- a/lib/screens/patients/profile/soap_update_vida_plus/objective/add_examination_vida_plus_widget.dart +++ b/lib/screens/patients/profile/soap_update_vida_plus/objective/add_examination_vida_plus_widget.dart @@ -1,6 +1,7 @@ // ignore: must_be_immutable import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/model/SOAP/master_key_model.dart'; +import 'package:doctor_app_flutter/core/model/SOAP/physical_exam/GeneralSpeciality.dart'; import 'package:doctor_app_flutter/core/model/SOAP/selected_items/my_selected_examination.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; @@ -13,22 +14,16 @@ import 'package:provider/provider.dart'; // ignore: must_be_immutable class AddExaminationVidaPlusWidget extends StatefulWidget { - MasterKeyModel? item; - final Function(MySelectedExamination) removeExamination; - final Function(MySelectedExamination) addExamination; - final bool Function(MasterKeyModel) isServiceSelected; - bool isExpand; + GeneralSpeciality? item; + final Function(GeneralSpeciality?) removeExamination; + final Function(GeneralSpeciality?) addExamination; - final Function() expandClick; - final List? mySelectedExamination; + final List? mySelectedExamination; AddExaminationVidaPlusWidget({ this.item, required this.removeExamination, required this.addExamination, - required this.isServiceSelected, - this.isExpand = false, - required this.expandClick, this.mySelectedExamination, }); @@ -43,17 +38,7 @@ class _AddExaminationVidaPlusWidgetState extends State exam = widget.mySelectedExamination!.where((element) => masterKey.id == element.selectedExamination!.id && masterKey.typeId == element.selectedExamination!.typeId); - if (exam.length > 0) { - return exam.first; + } } - return null; } + } diff --git a/lib/screens/patients/profile/soap_update_vida_plus/objective/examinations_list_search_vida_plus_widget.dart b/lib/screens/patients/profile/soap_update_vida_plus/objective/examinations_list_search_vida_plus_widget.dart index 502114c9..f3baebfc 100644 --- a/lib/screens/patients/profile/soap_update_vida_plus/objective/examinations_list_search_vida_plus_widget.dart +++ b/lib/screens/patients/profile/soap_update_vida_plus/objective/examinations_list_search_vida_plus_widget.dart @@ -1,4 +1,5 @@ import 'package:doctor_app_flutter/core/model/SOAP/master_key_model.dart'; +import 'package:doctor_app_flutter/core/model/SOAP/physical_exam/GeneralSpeciality.dart'; import 'package:doctor_app_flutter/core/model/SOAP/physical_exam/patient_physical_examination.dart'; import 'package:doctor_app_flutter/core/model/SOAP/selected_items/my_selected_examination.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update_vida_plus/objective/add_examination_vida_plus_widget.dart'; @@ -8,23 +9,25 @@ import 'package:doctor_app_flutter/widgets/shared/divider_with_spaces_around.dar import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; import 'package:flutter/material.dart'; - class ExaminationsListSearchVidaPlusWidget extends StatefulWidget { - final Function(MySelectedExamination) removeExamination; - final Function(MySelectedExamination) addExamination; - final bool Function(MasterKeyModel) isServiceSelected; - final List? masterList; - final List? mySelectedExamination; + final Function(GeneralSpeciality?) removeExamination; + final Function(GeneralSpeciality?) addExamination; + final List? masterList; - ExaminationsListSearchVidaPlusWidget({required this.removeExamination, required this.addExamination, required this.isServiceSelected, this.masterList, this.mySelectedExamination}); + ExaminationsListSearchVidaPlusWidget( + {required this.removeExamination, + required this.addExamination, + this.masterList}); @override - _ExaminationsListSearchVidaPlusWidgetState createState() => _ExaminationsListSearchVidaPlusWidgetState(); + _ExaminationsListSearchVidaPlusWidgetState createState() => + _ExaminationsListSearchVidaPlusWidgetState(); } -class _ExaminationsListSearchVidaPlusWidgetState extends State { +class _ExaminationsListSearchVidaPlusWidgetState + extends State { int expandedIndex = -1; - List? items = []; + List? items = []; TextEditingController filteredSearchController = TextEditingController(); @override @@ -44,7 +47,8 @@ class _ExaminationsListSearchVidaPlusWidgetState extends State AddExaminationVidaPlusWidget( + item: items![index], + addExamination: widget.addExamination, + removeExamination: widget.removeExamination, + ), + separatorBuilder: (_, __) => Divider(), + ) // ...items!.mapIndexed((index, item) { // return Column( // children: [ diff --git a/lib/screens/patients/profile/soap_update_vida_plus/objective/list_of_examination.dart b/lib/screens/patients/profile/soap_update_vida_plus/objective/list_of_examination.dart index a9b246e2..01f4ce6d 100644 --- a/lib/screens/patients/profile/soap_update_vida_plus/objective/list_of_examination.dart +++ b/lib/screens/patients/profile/soap_update_vida_plus/objective/list_of_examination.dart @@ -1,3 +1,4 @@ +import 'package:doctor_app_flutter/core/model/SOAP/physical_exam/patient_physical_examination.dart'; import 'package:doctor_app_flutter/core/model/SOAP/selected_items/my_selected_examination.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update_vida_plus/widgets/SoapDetailItem.dart'; @@ -8,7 +9,7 @@ import 'package:provider/provider.dart'; import '../../../../../utils/translations_delegate_base_utils.dart'; class ListOfExamination extends StatelessWidget { - final List listOfSelection; + final List listOfSelection; const ListOfExamination({super.key, required this.listOfSelection}); @@ -20,25 +21,8 @@ class ListOfExamination extends StatelessWidget { physics: NeverScrollableScrollPhysics(), shrinkWrap: true, itemBuilder: (_, index) => SoapDetailItem( - title: projectViewModel.isArabic - ? listOfSelection[index] - .selectedExamination! - .nameAr != - null && - listOfSelection[index] - .selectedExamination! - .nameAr != - "" - ? listOfSelection[index] - .selectedExamination! - .nameAr! - : listOfSelection[index] - .selectedExamination! - .nameEn! - : listOfSelection[index] - .selectedExamination! - .nameEn!, - condition: getCondition(listOfSelection[index], context)??TranslationBase.of(context).notExamined, + title: "${listOfSelection[index].physicalExaminationDescription}", + condition: getCondition(listOfSelection[index].physicalExaminationCondition ?? 3, context)??TranslationBase.of(context).notExamined, remarks: listOfSelection[index].remark??'', onSoapDetailActionClicked: (action) { ///todo handle the event as per the actiion @@ -51,9 +35,9 @@ class ListOfExamination extends StatelessWidget { ); } - String? getCondition(MySelectedExamination examination, BuildContext context) => examination.isNormal + String? getCondition(int condition, BuildContext context) => condition ==0 ? TranslationBase.of(context).normal - : examination.isAbnormal + : condition == 1 ? TranslationBase.of(context).abnormal : TranslationBase.of(context).notExamined; } diff --git a/lib/screens/patients/profile/soap_update_vida_plus/objective/update_objective_page_vida_plus.dart b/lib/screens/patients/profile/soap_update_vida_plus/objective/update_objective_page_vida_plus.dart index 7f5805c5..008ec26e 100644 --- a/lib/screens/patients/profile/soap_update_vida_plus/objective/update_objective_page_vida_plus.dart +++ b/lib/screens/patients/profile/soap_update_vida_plus/objective/update_objective_page_vida_plus.dart @@ -4,6 +4,7 @@ import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; import 'package:doctor_app_flutter/core/enum/view_state.dart'; import 'package:doctor_app_flutter/core/model/SOAP/master_key_model.dart'; +import 'package:doctor_app_flutter/core/model/SOAP/physical_exam/patient_physical_examination.dart'; import 'package:doctor_app_flutter/core/model/SOAP/physical_exam/post_physical_exam_request_model.dart'; import 'package:doctor_app_flutter/core/model/SOAP/selected_items/my_selected_examination.dart'; import 'package:doctor_app_flutter/core/model/doctor/doctor_profile_model.dart'; @@ -51,7 +52,7 @@ class UpdateObjectivePageVidaPlus extends StatefulWidget { class _UpdateObjectivePageVidaPlusState extends State implements ObjectiveCallBack { bool isSysExaminationExpand = false; - List mySelectedExamination = []; + List mySelectedExamination = []; BoxDecoration containerBorderDecoration( Color containerColor, Color borderColor) { @@ -74,37 +75,6 @@ class _UpdateObjectivePageVidaPlusState if (model.patientPhysicalExaminationList == 0) { model.getPhysicalExamination(widget.patientInfo); } - // model.getPatientPhysicalExam(widget.patientInfo); - model.setObjectiveCallBack(this); - mySelectedExamination.clear(); - model.isAddExamInProgress = true; - await model.getPatientPhysicalExam(widget.patientInfo); - if (model.patientPhysicalExamList.isNotEmpty) { - if (model.physicalExaminationList.length == 0) { - await model - .getMasterLookup(MasterKeysService.PostPhysicalExaminationModel); - } - model.patientPhysicalExamList.forEach((element) { - MasterKeyModel? examMaster = model.getOneMasterKey( - masterKeys: MasterKeysService.PostPhysicalExaminationModel, - id: element.examId, - ); - MySelectedExamination tempEam = - SoapUtils.generateMySelectedExamination( - examination: examMaster, - remark: element.remarks, - isNormal: element.isNormal, - createdBy: element.createdBy, - createdOn: element.createdOn, - editedOn: element.editedOn, - notExamined: element.notExamined, - isNew: element.isNew, - isLocal: false, - isAbnormal: element.isAbnormal, - ); - mySelectedExamination.add(tempEam); - }); - } widget.changeLoadingState(false); }); }, @@ -220,177 +190,143 @@ class _UpdateObjectivePageVidaPlusState ); } - submitUpdateObjectivePage(SOAPViewModel model) async { - if (mySelectedExamination.isNotEmpty) { - if (!model.isAddExamInProgress && - widget.patientInfo.admissionNo != null && - widget.patientInfo.admissionNo!.isNotEmpty) { - Navigator.of(context).pop(); - } else { - widget.changeLoadingState(true); - Map profile = await sharedPref.getObj(DOCTOR_PROFILE); - - DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(profile); - PostPhysicalExamRequestModel postPhysicalExamRequestModel = - new PostPhysicalExamRequestModel(); - mySelectedExamination.forEach((exam) { - if (postPhysicalExamRequestModel - .listHisProgNotePhysicalExaminationVM == - null) - postPhysicalExamRequestModel.listHisProgNotePhysicalExaminationVM = - []; - ListHisProgNotePhysicalExaminationVM - listHisProgNotePhysicalExaminationVM = - ListHisProgNotePhysicalExaminationVM( - patientMRN: widget.patientInfo.patientMRN, - episodeId: widget.patientInfo.episodeNo == null - ? 0 - : widget.patientInfo.episodeNo, - appointmentNo: widget.patientInfo.appointmentNo == null - ? 0 - : widget.patientInfo.appointmentNo, - remarks: exam.remark ?? '', - createdBy: exam.createdBy ?? doctorProfile.doctorID, - createdOn: exam.createdOn ?? DateTime.now().toIso8601String(), - editedBy: doctorProfile.doctorID, - editedOn: DateTime.now().toIso8601String(), - examId: exam.selectedExamination!.id, - examType: exam.selectedExamination!.typeId, - isAbnormal: exam.isAbnormal, - isNormal: exam.isNormal, - notExamined: exam.notExamined, - examinationType: exam.isNormal - ? 1 - : exam.isAbnormal - ? 2 - : 3, - examinationTypeName: exam.isNormal - ? "Normal" - : exam.isAbnormal - ? 'AbNormal' - : "Not Examined", - isNew: exam.isNew, - ); - if (widget.patientInfo.admissionNo != null && - widget.patientInfo.admissionNo!.isNotEmpty) { - listHisProgNotePhysicalExaminationVM.admissionNo = - int.parse(widget.patientInfo.admissionNo!); - } else { - listHisProgNotePhysicalExaminationVM.admissionNo = 0; - } - postPhysicalExamRequestModel.listHisProgNotePhysicalExaminationVM! - .add(listHisProgNotePhysicalExaminationVM); - }); - - if (model.patientPhysicalExamList.isEmpty) { - await model.postPhysicalExam(postPhysicalExamRequestModel); - } else { - await model.patchPhysicalExam(postPhysicalExamRequestModel); - } - - if (model.state == ViewState.ErrorLocal) { - widget.changeLoadingState(false); - Utils.showErrorToast(model.error); - if (widget.patientInfo.admissionNo != null && - widget.patientInfo.admissionNo!.isNotEmpty) { - // Navigator.of(context).pop(); - model.isAddExamInProgress = false; - } - } else { - if (widget.patientInfo.admissionNo != null && - widget.patientInfo.admissionNo!.isNotEmpty) { - // Navigator.of(context).pop(); - widget.changeLoadingState(false); - model.isAddExamInProgress = false; - } else { - widget.changeLoadingState(true); - widget.changePageViewIndex(2); - } - } - } - } else { - Utils.showErrorToast(TranslationBase.of(context).examinationErrorMsg); - } - } - - removeExamination(MasterKeyModel masterKey) { - Iterable history = mySelectedExamination.where( - (element) => - masterKey.id == element.selectedExamination!.id && - masterKey.typeId == element.selectedExamination!.typeId); + // submitUpdateObjectivePage(SOAPViewModel model) async { + // if (mySelectedExamination.isNotEmpty) { + // if (!model.isAddExamInProgress && + // widget.patientInfo.admissionNo != null && + // widget.patientInfo.admissionNo!.isNotEmpty) { + // Navigator.of(context).pop(); + // } else { + // widget.changeLoadingState(true); + // Map profile = await sharedPref.getObj(DOCTOR_PROFILE); + // + // DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(profile); + // PostPhysicalExamRequestModel postPhysicalExamRequestModel = + // new PostPhysicalExamRequestModel(); + // mySelectedExamination.forEach((exam) { + // if (postPhysicalExamRequestModel + // .listHisProgNotePhysicalExaminationVM == + // null) + // postPhysicalExamRequestModel.listHisProgNotePhysicalExaminationVM = + // []; + // ListHisProgNotePhysicalExaminationVM + // listHisProgNotePhysicalExaminationVM = + // ListHisProgNotePhysicalExaminationVM( + // patientMRN: widget.patientInfo.patientMRN, + // episodeId: widget.patientInfo.episodeNo == null + // ? 0 + // : widget.patientInfo.episodeNo, + // appointmentNo: widget.patientInfo.appointmentNo == null + // ? 0 + // : widget.patientInfo.appointmentNo, + // remarks: exam.remark ?? '', + // createdBy: exam.createdBy ?? doctorProfile.doctorID, + // createdOn: exam.createdOn ?? DateTime.now().toIso8601String(), + // editedBy: doctorProfile.doctorID, + // editedOn: DateTime.now().toIso8601String(), + // examId: exam.selectedExamination!.id, + // examType: exam.selectedExamination!.typeId, + // isAbnormal: exam.isAbnormal, + // isNormal: exam.isNormal, + // notExamined: exam.notExamined, + // examinationType: exam.isNormal + // ? 1 + // : exam.isAbnormal + // ? 2 + // : 3, + // examinationTypeName: exam.isNormal + // ? "Normal" + // : exam.isAbnormal + // ? 'AbNormal' + // : "Not Examined", + // isNew: exam.isNew, + // ); + // if (widget.patientInfo.admissionNo != null && + // widget.patientInfo.admissionNo!.isNotEmpty) { + // listHisProgNotePhysicalExaminationVM.admissionNo = + // int.parse(widget.patientInfo.admissionNo!); + // } else { + // listHisProgNotePhysicalExaminationVM.admissionNo = 0; + // } + // postPhysicalExamRequestModel.listHisProgNotePhysicalExaminationVM! + // .add(listHisProgNotePhysicalExaminationVM); + // }); + // + // if (model.patientPhysicalExamList.isEmpty) { + // await model.postPhysicalExam(postPhysicalExamRequestModel); + // } else { + // await model.patchPhysicalExam(postPhysicalExamRequestModel); + // } + // + // if (model.state == ViewState.ErrorLocal) { + // widget.changeLoadingState(false); + // Utils.showErrorToast(model.error); + // if (widget.patientInfo.admissionNo != null && + // widget.patientInfo.admissionNo!.isNotEmpty) { + // // Navigator.of(context).pop(); + // model.isAddExamInProgress = false; + // } + // } else { + // if (widget.patientInfo.admissionNo != null && + // widget.patientInfo.admissionNo!.isNotEmpty) { + // // Navigator.of(context).pop(); + // widget.changeLoadingState(false); + // model.isAddExamInProgress = false; + // } else { + // widget.changeLoadingState(true); + // widget.changePageViewIndex(2); + // } + // } + // } + // } else { + // Utils.showErrorToast(TranslationBase.of(context).examinationErrorMsg); + // } + // } - if (history.length > 0) { - setState(() { - if (history.first.isLocal) { - mySelectedExamination.remove(history.first); - } else { - history.first.notExamined = true; - history.first.isNormal = false; - history.first.isAbnormal = false; - } - }); - } - } + // removeExamination(MasterKeyModel masterKey) { + // Iterable history = mySelectedExamination.where( + // (element) => + // masterKey.id == element.selectedExamination!.id && + // masterKey.typeId == element.selectedExamination!.typeId); + // + // if (history.length > 0) { + // setState(() { + // if (history.first.isLocal) { + // mySelectedExamination.remove(history.first); + // } else { + // history.first.notExamined = true; + // history.first.isNormal = false; + // history.first.isAbnormal = false; + // } + // }); + // } + // } openExaminationList(BuildContext context) { Navigator.push( context, FadePage( page: AddExaminationPageVidaPlus( - mySelectedExamination: mySelectedExamination, - addSelectedExamination: - (List mySelectedExaminationLocal) { - pushAddExamination(mySelectedExaminationLocal); - - // mySelectedExaminationLocal.forEach((element) { - // if (mySelectedExamination.singleWhere( - // (it) => - // it.selectedExamination!.id == - // element.selectedExamination!.id, - // orElse: () => MySelectedExamination()) == - // MySelectedExamination()) { - // mySelectedExamination.insert(0, element); - // } - // }); - - /// remove items. - // List removedList = []; - // mySelectedExamination.forEach((element) { - // if (mySelectedExaminationLocal.singleWhere( - // (it) => - // it.selectedExamination!.id == - // element.selectedExamination!.id, - // orElse: () => MySelectedExamination()) == - // MySelectedExamination()) { - // removedList.add(element); - // } - // }); - - // removedList.forEach((element) { - // removeExamination(element.selectedExamination!); - // }); - // Navigator.of(context).pop(); - // setState(() {}); - }, - removeExamination: (masterKey) => removeExamination(masterKey)), + patientInfo: widget.patientInfo, + ), ), ); } @override nextFunction(model) async { - await submitUpdateObjectivePage(model); + // await submitUpdateObjectivePage(model); } - void pushAddExamination( - List mySelectedExaminationLocal) { - Navigator.push( - context, - FadePage( - page: AddDetailsToExaminationVidaPlus( - mySelectedExamination: mySelectedExamination, - ), - ), - ); - } + // void pushAddExamination( + // List mySelectedExaminationLocal) { + // Navigator.push( + // context, + // FadePage( + // page: AddDetailsToExaminationVidaPlus( + // mySelectedExamination: mySelectedExamination, + // ), + // ), + // ); + // } }