From f3876e9ef1a25564eeb12a7553778e3d033cfdf6 Mon Sep 17 00:00:00 2001 From: Sultan khan <> Date: Sun, 17 Nov 2024 09:48:00 +0300 Subject: [PATCH] soap vida plus inprogress --- lib/config/config.dart | 16 + .../allergy/get_allergies_list_vida_plus.dart | 29 +- .../get_patient_allergies_list_vida_plus.dart | 10 +- .../get_chief_complaint_vida_plus.dart | 68 +++ .../search_chief_complaint_vidaplus.dart | 40 ++ lib/core/model/SOAP/get_hopi_details.dart | 60 +++ .../model/patient/patiant_info_model.dart | 9 +- .../soap/SOAP_service.dart | 331 ++++++++++-- lib/core/viewModel/SOAP_view_model.dart | 489 +++++++++++++----- .../subjective/allergies/add_allergies.dart | 21 +- ..._key_checkbox_search_allergies_widget.dart | 25 +- .../allergies/reactions_selection.dart | 244 +++++++-- .../allergies/update_allergies_widget.dart | 318 ++++++------ .../chief_complaint/AddChiefComplaints.dart | 23 +- .../chief_complaint/chief_complaints.dart | 47 +- .../widgets/ComplaintSelection.dart | 107 +++- .../widgets/complaint_items.dart | 51 +- .../update_present_illness.dart | 99 +++- .../update_subjective_page_vida_plus.dart | 13 +- .../update_soap_index_vida_plus.dart | 25 +- lib/widgets/auth/sms-popup.dart | 2 +- 21 files changed, 1536 insertions(+), 491 deletions(-) create mode 100644 lib/core/model/SOAP/chief_complaint/get_chief_complaint_vida_plus.dart create mode 100644 lib/core/model/SOAP/chief_complaint/search_chief_complaint_vidaplus.dart create mode 100644 lib/core/model/SOAP/get_hopi_details.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index f6eb8511..ad086d11 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -292,6 +292,22 @@ const PATIENT_ALLERGIES = 'Services/DoctorApplication.svc/REST/PatientAllergies' const SEARCH_ALLERGIES = 'Services/DoctorApplication.svc/REST/SearchAllergies'; +const POST_ALLERGIES = 'Services/DoctorApplication.svc/REST/PostAllergies'; + +const CREATE_HOPI = 'Services/DoctorApplication.svc/REST/CreateHOPI'; + +const HOPI_DETAILS = 'Services/DoctorApplication.svc/REST/DetailHOPI'; + +const POST_CHIEF_COMPLAINT_VP = 'Services/DoctorApplication.svc/REST/PostChiefcomplaint'; + +const SEARCH_CHIEF_COMPLAINT_VP = 'Services/DoctorApplication.svc/REST/SearchChiefcomplaint'; + +const RESOLVE_ALLERGIES = 'Services/DoctorApplication.svc/REST/ResolveAllergy'; + +const UPDATE_ALLERGIES = 'Services/DoctorApplication.svc/REST/UpdateAllergy'; + +const GET_CHIEF_COMPLAINT_VP = 'Services/DoctorApplication.svc/REST/ChiefComplaintDetails'; + var selectedPatientType = 1; diff --git a/lib/core/model/SOAP/allergy/get_allergies_list_vida_plus.dart b/lib/core/model/SOAP/allergy/get_allergies_list_vida_plus.dart index d0beffa0..5a7fedd2 100644 --- a/lib/core/model/SOAP/allergy/get_allergies_list_vida_plus.dart +++ b/lib/core/model/SOAP/allergy/get_allergies_list_vida_plus.dart @@ -11,7 +11,7 @@ class AllergiesListVidaPlus { bool? isActive; bool? isSnowMedAllergy; String? snowMedCode; - + String? remark; AllergiesListVidaPlus( {this.allergyID, this.allergyName, @@ -24,7 +24,9 @@ class AllergiesListVidaPlus { this.hospitalID, this.isActive, this.isSnowMedAllergy, - this.snowMedCode}); + this.snowMedCode, + this.remark + }); AllergiesListVidaPlus.fromJson(Map json) { allergyID = json['allergyID']; @@ -74,8 +76,12 @@ class AllergyReactionDTOs { int? hospitalGroupID; int? hospitalID; bool? isActive; - String? reactionSelection =""; bool? isSelected =false; + int? dbCRUDOperation =1; + int? pomrid; + int? patientID; + int? allergyReactionMappingID = 0; + int? severity =1; AllergyReactionDTOs( {this.allergyReactionID, this.allergyReactionName, @@ -83,8 +89,12 @@ class AllergyReactionDTOs { this.hospitalGroupID, this.hospitalID, this.isActive, - this.reactionSelection, this.isSelected, + this.dbCRUDOperation, + this.pomrid, + this.patientID, + this.allergyReactionMappingID, + this.severity }); AllergyReactionDTOs.fromJson(Map json) { @@ -94,6 +104,12 @@ class AllergyReactionDTOs { hospitalGroupID = json['hospitalGroupID']; hospitalID = json['hospitalID']; isActive = json['isActive']; + dbCRUDOperation = json["DbCRUDOperation"]; + pomrid = json['pomrid']; + patientID = json['patientID']; + allergyReactionMappingID = json['allergyReactionMappingID']; + severity = json['severity']; + } Map toJson() { @@ -104,6 +120,11 @@ class AllergyReactionDTOs { data['hospitalGroupID'] = this.hospitalGroupID; data['hospitalID'] = this.hospitalID; data['isActive'] = this.isActive; + data["DbCRUDOperation"] = this.dbCRUDOperation; + data['pomrid'] = this.pomrid; + data['patientID'] = patientID; + data['allergyReactionMappingID'] = this.allergyReactionMappingID; + data['severity'] = this.severity; return data; } } diff --git a/lib/core/model/SOAP/allergy/get_patient_allergies_list_vida_plus.dart b/lib/core/model/SOAP/allergy/get_patient_allergies_list_vida_plus.dart index 2da8fa58..d2e30e4e 100644 --- a/lib/core/model/SOAP/allergy/get_patient_allergies_list_vida_plus.dart +++ b/lib/core/model/SOAP/allergy/get_patient_allergies_list_vida_plus.dart @@ -78,8 +78,9 @@ class PatientsAllergyReactionsDTOs { int? patientID; int? patientsAllergyReactionRevisionID; int? pomrId; - int? severity; - + int? severity =1; + bool? isSelected =true; + String? reactionSelection =""; PatientsAllergyReactionsDTOs( {this.allergyReactionID, this.allergyReactionMappingID, @@ -90,7 +91,10 @@ class PatientsAllergyReactionsDTOs { this.patientID, this.patientsAllergyReactionRevisionID, this.pomrId, - this.severity}); + this.severity, + this.isSelected, + this.reactionSelection + }); PatientsAllergyReactionsDTOs.fromJson(Map json) { allergyReactionID = json['allergyReactionID']; diff --git a/lib/core/model/SOAP/chief_complaint/get_chief_complaint_vida_plus.dart b/lib/core/model/SOAP/chief_complaint/get_chief_complaint_vida_plus.dart new file mode 100644 index 00000000..cf2c5f7b --- /dev/null +++ b/lib/core/model/SOAP/chief_complaint/get_chief_complaint_vida_plus.dart @@ -0,0 +1,68 @@ +class GetChiefComplaintVidaPlus { + int? appointmentId; + String? chiefComplain; + int? chiefComplainId; + int? chiefComplainTemplateId; + int? clinicGroupId; + int? clinicId; + int? doctorId; + String? doctorName; + int? episodeId; + int? hospitalGroupId; + int? hospitalId; + String? loginUserId; + int? patientId; + int? patientPomrId; + + GetChiefComplaintVidaPlus( + {this.appointmentId, + this.chiefComplain, + this.chiefComplainId, + this.chiefComplainTemplateId, + this.clinicGroupId, + this.clinicId, + this.doctorId, + this.doctorName, + this.episodeId, + this.hospitalGroupId, + this.hospitalId, + this.loginUserId, + this.patientId, + this.patientPomrId}); + + GetChiefComplaintVidaPlus.fromJson(Map json) { + appointmentId = json['appointmentId']; + chiefComplain = json['chiefComplain']; + chiefComplainId = json['chiefComplainId']; + chiefComplainTemplateId = json['chiefComplainTemplateId']; + clinicGroupId = json['clinicGroupId']; + clinicId = json['clinicId']; + doctorId = json['doctorId']; + doctorName = json['doctorName']; + episodeId = json['episodeId']; + hospitalGroupId = json['hospitalGroupId']; + hospitalId = json['hospitalId']; + loginUserId = json['loginUserId']; + patientId = json['patientId']; + patientPomrId = json['patientPomrId']; + } + + Map toJson() { + final Map data = new Map(); + data['appointmentId'] = this.appointmentId; + data['chiefComplain'] = this.chiefComplain; + data['chiefComplainId'] = this.chiefComplainId; + data['chiefComplainTemplateId'] = this.chiefComplainTemplateId; + data['clinicGroupId'] = this.clinicGroupId; + data['clinicId'] = this.clinicId; + data['doctorId'] = this.doctorId; + data['doctorName'] = this.doctorName; + data['episodeId'] = this.episodeId; + data['hospitalGroupId'] = this.hospitalGroupId; + data['hospitalId'] = this.hospitalId; + data['loginUserId'] = this.loginUserId; + data['patientId'] = this.patientId; + data['patientPomrId'] = this.patientPomrId; + return data; + } +} diff --git a/lib/core/model/SOAP/chief_complaint/search_chief_complaint_vidaplus.dart b/lib/core/model/SOAP/chief_complaint/search_chief_complaint_vidaplus.dart new file mode 100644 index 00000000..389cd99f --- /dev/null +++ b/lib/core/model/SOAP/chief_complaint/search_chief_complaint_vidaplus.dart @@ -0,0 +1,40 @@ +class SearchChiefComplaint { + String? chiefComplain; + String? chiefComplainCode; + int? chiefComplainId; + String? clinic; + int? hospitalGroupId; + int? hospitalId; + String? nursingGroup; + + SearchChiefComplaint( + {this.chiefComplain, + this.chiefComplainCode, + this.chiefComplainId, + this.clinic, + this.hospitalGroupId, + this.hospitalId, + this.nursingGroup}); + + SearchChiefComplaint.fromJson(Map json) { + chiefComplain = json['chiefComplain']; + chiefComplainCode = json['chiefComplainCode']; + chiefComplainId = json['chiefComplainId']; + clinic = json['clinic']; + hospitalGroupId = json['hospitalGroupId']; + hospitalId = json['hospitalId']; + nursingGroup = json['nursingGroup']; + } + + Map toJson() { + final Map data = new Map(); + data['chiefComplain'] = this.chiefComplain; + data['chiefComplainCode'] = this.chiefComplainCode; + data['chiefComplainId'] = this.chiefComplainId; + data['clinic'] = this.clinic; + data['hospitalGroupId'] = this.hospitalGroupId; + data['hospitalId'] = this.hospitalId; + data['nursingGroup'] = this.nursingGroup; + return data; + } +} diff --git a/lib/core/model/SOAP/get_hopi_details.dart b/lib/core/model/SOAP/get_hopi_details.dart new file mode 100644 index 00000000..4783587e --- /dev/null +++ b/lib/core/model/SOAP/get_hopi_details.dart @@ -0,0 +1,60 @@ +class GetHopiDetails { + int? clinicId; + int? doctorId; + int? hospitalGroupId; + int? hospitalId; + String? hpi; + int? hpiId; + bool? isHpiTakenFamily; + bool? isHpiTakenOther; + bool? isHpiTakenPatient; + String? loginUserId; + int? patientId; + int? patientPomrId; + + GetHopiDetails( + {this.clinicId, + this.doctorId, + this.hospitalGroupId, + this.hospitalId, + this.hpi, + this.hpiId, + this.isHpiTakenFamily, + this.isHpiTakenOther, + this.isHpiTakenPatient, + this.loginUserId, + this.patientId, + this.patientPomrId}); + + GetHopiDetails.fromJson(Map json) { + clinicId = json['clinicId']; + doctorId = json['doctorId']; + hospitalGroupId = json['hospitalGroupId']; + hospitalId = json['hospitalId']; + hpi = json['hpi']; + hpiId = json['hpiId']; + isHpiTakenFamily = json['isHpiTakenFamily']; + isHpiTakenOther = json['isHpiTakenOther']; + isHpiTakenPatient = json['isHpiTakenPatient']; + loginUserId = json['loginUserId']; + patientId = json['patientId']; + patientPomrId = json['patientPomrId']; + } + + Map toJson() { + final Map data = new Map(); + data['clinicId'] = this.clinicId; + data['doctorId'] = this.doctorId; + data['hospitalGroupId'] = this.hospitalGroupId; + data['hospitalId'] = this.hospitalId; + data['hpi'] = this.hpi; + data['hpiId'] = this.hpiId; + data['isHpiTakenFamily'] = this.isHpiTakenFamily; + data['isHpiTakenOther'] = this.isHpiTakenOther; + data['isHpiTakenPatient'] = this.isHpiTakenPatient; + data['loginUserId'] = this.loginUserId; + data['patientId'] = this.patientId; + data['patientPomrId'] = this.patientPomrId; + return data; + } +} diff --git a/lib/core/model/patient/patiant_info_model.dart b/lib/core/model/patient/patiant_info_model.dart index af04e752..4fb49f80 100644 --- a/lib/core/model/patient/patiant_info_model.dart +++ b/lib/core/model/patient/patiant_info_model.dart @@ -79,7 +79,7 @@ class PatiantInformtion { int? status; int? vcId; String? voipToken; - + String? pomrId; PatiantInformtion( {this.patientDetails, this.projectId, @@ -155,7 +155,9 @@ class PatiantInformtion { this.vcId, this.voipToken, this.admissionDateWithDateTimeForm, - this.appointmentDateWithDateTimeForm}); + this.appointmentDateWithDateTimeForm, + this.pomrId + }); PatiantInformtion.fromJson(Map json) { { @@ -262,6 +264,7 @@ class PatiantInformtion { consultationNotes = json['ConsultationNotes']; patientStatus = json['PatientStatus']; voipToken = json['VoipToken']; + pomrId = json['pomrId']; admissionDateWithDateTimeForm = json["AdmissionDate"] != null ? AppDateUtils.convertStringToDate(json["AdmissionDate"]) : json["admissionDate"] != null @@ -340,7 +343,7 @@ class PatiantInformtion { data['ProjectID'] = this.projectId; data['VC_ID'] = this.vcId; data['VoipToken'] = this.voipToken; - + data['pomrId'] = this.pomrId; data["DateofBirth"] = this.dateofBirth; data["dob"] = this.dateofBirth; data['DateOfBirth'] = this.dateofBirth; 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 362a8273..e6321cd3 100644 --- a/lib/core/service/patient_medical_file/soap/SOAP_service.dart +++ b/lib/core/service/patient_medical_file/soap/SOAP_service.dart @@ -3,8 +3,11 @@ import 'package:doctor_app_flutter/core/model/SOAP/Allergy/get_allergies_res_mod import 'package:doctor_app_flutter/core/model/SOAP/Assessment/get_assessment_res_model.dart'; import 'package:doctor_app_flutter/core/model/SOAP/allergy/get_allergies_list_vida_plus.dart'; import 'package:doctor_app_flutter/core/model/SOAP/allergy/get_patient_allergies_list_vida_plus.dart'; +import 'package:doctor_app_flutter/core/model/SOAP/chief_complaint/get_chief_complaint_vida_plus.dart'; +import 'package:doctor_app_flutter/core/model/SOAP/chief_complaint/search_chief_complaint_vidaplus.dart'; 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/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'; @@ -22,7 +25,13 @@ import 'package:doctor_app_flutter/core/model/SOAP/physical_exam/post_physical_e 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'; import 'package:doctor_app_flutter/core/model/SOAP/progress_note/post_progress_note_request_model.dart'; - +import 'package:doctor_app_flutter/core/model/doctor/doctor_profile_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; +import 'package:doctor_app_flutter/utils/dr_app_toast_msg.dart'; +import 'package:doctor_app_flutter/utils/utils.dart'; +import 'package:http/http.dart'; +import '../../../../config/shared_pref_kay.dart'; +import '../../../../utils/date-utils.dart'; import '../../../model/SOAP/assessment/patch_assessment_req_model.dart'; import '../../../model/patient/patiant_info_model.dart'; import '../../base/lookup-service.dart'; @@ -34,10 +43,15 @@ class SOAPService extends LookupService { List patientPhysicalExamList = []; List patientProgressNoteList = []; List patientAssessmentList = []; - List searchAllergiesList =[]; - List patientAllergiesVidaPlus =[]; + List searchAllergiesList = []; + List patientAllergiesVidaPlus = []; + List hopiDetails = []; + List patientChiefComplaintListVidaPlus = []; + List searchChiefComplaintListVidaPlus = []; + int? episodeID; - bool isPrescriptionOrder =false; + bool isPrescriptionOrder = false; + Future postEpisode(PostEpisodeReqModel postEpisodeReqModel) async { hasError = false; @@ -321,41 +335,45 @@ class SOAPService extends LookupService { super.error = error; }, body: getEpisodeForInpatientReqModel.toJson()); } - Future isPrescriptionOrderCreated( - PatiantInformtion patientInfo) async { + + Future isPrescriptionOrderCreated(PatiantInformtion patientInfo) async { hasError = false; await baseAppClient.post(IS_PRESCRIPTION_ORDER_CREATED, onSuccess: (dynamic response, int statusCode) { - print("Success"); + 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, - }); + 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 */ - Future patientAllergies(GeneralGetReqForSOAP generalGetReqForSOAP) async { + Future patientAllergies(PatiantInformtion patientInfo) async { + Map request = { + "patientId": patientInfo.patientMRN, + "ProjectID": patientInfo.projectId + }; 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: generalGetReqForSOAP.toJson()); + 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 { @@ -363,15 +381,254 @@ 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}); + } + + Future addAllergies( + AllergiesListVidaPlus allergy, PatiantInformtion patientInfo) async { + allergy.allergyReactionDTOs!.forEach((value) { + value.patientID = patientInfo.patientMRN; + value.pomrid = int.parse(patientInfo.pomrId!); + value.allergyReactionMappingID = 1; + }); + + var request = { + "patientsAllergyRevisionID": allergy.allergyRevisionID, + "patientMRN": patientInfo.patientMRN, + "allergyDiseaseType": 0, + "allergyTypeName": allergy.allergyTypeName, + "episodeId": patientInfo.episodeNo, + "isUpdatedByNurse": false, + "remarks": allergy.remark, + "createdBy": patientInfo.doctorId, + "createdOn": AppDateUtils.convertDateToFormat( + DateTime.now(), "yyyy-MM-dd kk:mm:ss"), + "assessmentId": 0, + "isActive": allergy.isActive, + "isActivePatientsAllergy": true, + "patientsAllergyReactionsDTOs": allergy.allergyReactionDTOs, + "dbCRUDOperation": 1, + "allergyID": allergy.allergyID, + "allergyName": allergy.allergyName, + "allergyTypeID": allergy.allergyTypeID + }; + + hasError = false; + + 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] + }); + } + + 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!; + List? reactionRequest = []; + reaction.forEach((value) { + reactionRequest.add(AllergyReactionDTOs( + patientID: patientInfo.patientMRN, + pomrid: int.parse(patientInfo.pomrId!), + hospitalGroupID: value.hospitalGroupID, + allergyReactionMappingID: 0, + hospitalID: value.hospitalID, + isActive: value.isActive, + allergyReactionID: value.allergyReactionID, + allergyReactionName: value.allergyReactionName, + severity: value.severity)); + }); + + var request = { + "pomrId": patientInfo.pomrId, + "patientMRN": patientInfo.patientMRN, + "allergyTypeName": allergy.allergyTypeName, + "assessmentId": 0, + "isActive": allergy.isActivePatientsAllergy, + "patientsAllergyReactionsDTOs":reactionRequest, + "dbCRUDOperation": 2, + "allergyID": allergy.allergyID, + "allergyName": allergy.allergyName, + "allergyTypeID": allergy.allergyTypeID, + "remarks": allergy.remark, + "projectId": patientInfo.projectId, + "editedBy": doctorProfile['List_MemberInformation'][0]['MemberID'], + "setupId": await sharedPref.getString(DOCTOR_SETUP_ID) + }; + 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] + }); + } + + Future updateAllergies( + AllergiesListVidaPlus allergy, PatiantInformtion patientInfo) async { + allergy.allergyReactionDTOs!.forEach((value) { + value.patientID = patientInfo.patientMRN; + value.pomrid = patientInfo.episodeNo; + value.allergyReactionMappingID = 1; + }); + + var request = { + "patientsAllergyRevisionID": allergy.allergyRevisionID, + "patientMRN": patientInfo.patientMRN, + "allergyDiseaseType": 0, + "allergyTypeName": allergy.allergyTypeName, + "episodeId": patientInfo.episodeNo, + "isUpdatedByNurse": false, + "remarks": allergy.remark, + "createdBy": patientInfo.doctorId, + "createdOn": AppDateUtils.convertDateToFormat( + DateTime.now(), "yyyy-MM-dd kk:mm:ss"), + "assessmentId": 0, + "isActive": allergy.isActive, + "isActivePatientsAllergy": true, + "patientsAllergyReactionsDTOs": allergy.allergyReactionDTOs, + "dbCRUDOperation": 1, + "allergyID": allergy.allergyID, + "allergyName": allergy.allergyName, + "allergyTypeID": allergy.allergyTypeID + }; + + hasError = false; + + 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] + }); + } + + saveHopi(Map req, PatiantInformtion patient) async { + var request = { + "clinicGroupId": patient.clinicGroupId, // patient.clinicGroupId + "clinicId": patient.clinicId, + "doctorId": patient.doctorId, + "hospitalGroupId": await sharedPref.getString(DOCTOR_SETUP_ID), //setup + "hospitalId": patient.projectId, //projectid + "patientId": patient.patientMRN, + "patientPomrId": patient.pomrId, + }; + 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); + } - response['List_SearchAllergies']['resultData'].forEach((v) { - searchAllergiesList.add(AllergiesListVidaPlus.fromJson(v)); - }); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: {"AllergyName": searchKey}); + getHopi(PatiantInformtion patient) async { + Map request = { + "patientId": patient.patientMRN, + "pomrId": patient.pomrId, + }; + hasError = false; + await baseAppClient.post(HOPI_DETAILS, + onSuccess: (dynamic response, int statusCode) { + hopiDetails.clear(); + + 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 { + Map request = { + "ProjectID": patient.projectId, + "pomrId": patient.pomrId, + }; + hasError = false; + await baseAppClient.post(GET_CHIEF_COMPLAINT_VP, + onSuccess: (dynamic response, int statusCode) { + patientChiefComplaintListVidaPlus.clear(); + + 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 { + Map request = { + "ListCreateChiefComplaint": [ + { + "appointmentNo": patient.appointmentNo, + "pomrId": patient.pomrId, + "patientMRN": patient.patientMRN, + "chiefComplaint": cheifComplaint + } + ] + }; + 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); + } + + searchChiefComplaintVidaPlus(PatiantInformtion patient, String CC) async { + Map request = { + "doctorId": patient.doctorId, + "searchParam": CC, + }; + hasError = false; + 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); } } diff --git a/lib/core/viewModel/SOAP_view_model.dart b/lib/core/viewModel/SOAP_view_model.dart index 16002dfe..be098f49 100644 --- a/lib/core/viewModel/SOAP_view_model.dart +++ b/lib/core/viewModel/SOAP_view_model.dart @@ -8,8 +8,11 @@ import 'package:doctor_app_flutter/core/model/SOAP/Assessment/post_assessment_re import 'package:doctor_app_flutter/core/model/SOAP/allergy/get_allergies_list_vida_plus.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'; +import 'package:doctor_app_flutter/core/model/SOAP/chief_complaint/get_chief_complaint_vida_plus.dart'; import 'package:doctor_app_flutter/core/model/SOAP/chief_complaint/post_chief_complaint_request_model.dart'; +import 'package:doctor_app_flutter/core/model/SOAP/chief_complaint/search_chief_complaint_vidaplus.dart'; import 'package:doctor_app_flutter/core/model/SOAP/general_get_req_for_SOAP.dart'; +import 'package:doctor_app_flutter/core/model/SOAP/get_hopi_details.dart'; import 'package:doctor_app_flutter/core/model/SOAP/history/get_history_req_model.dart'; import 'package:doctor_app_flutter/core/model/SOAP/history/get_history_res_model.dart'; import 'package:doctor_app_flutter/core/model/SOAP/history/post_histories_request_model.dart'; @@ -42,52 +45,75 @@ import 'base_view_model.dart'; class SOAPViewModel extends BaseViewModel { SOAPService _SOAPService = locator(); + PrescriptionService _prescriptionService = locator(); List get allergiesList => _SOAPService.allergiesList; - List get allergySeverityList => _SOAPService.allergySeverityList; + List get allergySeverityList => + _SOAPService.allergySeverityList; List get historyFamilyList => _SOAPService.historyFamilyList; - List get historyMedicalList => _SOAPService.historyMedicalList; + List get historyMedicalList => + _SOAPService.historyMedicalList; List get historySportList => _SOAPService.historySportList; List get historySocialList => _SOAPService.historySocialList; - List get historySurgicalList => _SOAPService.historySurgicalList; + List get historySurgicalList => + _SOAPService.historySurgicalList; - List get mergeHistorySurgicalWithHistorySportList => [...historySurgicalList, ...historySportList]; + List get mergeHistorySurgicalWithHistorySportList => + [...historySurgicalList, ...historySportList]; - List get physicalExaminationList => _SOAPService.physicalExaminationList; + List get physicalExaminationList => + _SOAPService.physicalExaminationList; - List get listOfDiagnosisType => _SOAPService.listOfDiagnosisType; + List get listOfDiagnosisType => + _SOAPService.listOfDiagnosisType; - List get listOfDiagnosisCondition => _SOAPService.listOfDiagnosisCondition; + List get listOfDiagnosisCondition => + _SOAPService.listOfDiagnosisCondition; List get listOfICD10 => _SOAPService.listOfICD10; - List get patientChiefComplaintList => _SOAPService.patientChiefComplaintList; + List get patientChiefComplaintList => + _SOAPService.patientChiefComplaintList; + + List get patientAllergiesList => + _SOAPService.patientAllergiesList; - List get patientAllergiesList => _SOAPService.patientAllergiesList; + List get patientHistoryList => + _SOAPService.patientHistoryList; - List get patientHistoryList => _SOAPService.patientHistoryList; + List get patientPhysicalExamList => + _SOAPService.patientPhysicalExamList; - List get patientPhysicalExamList => _SOAPService.patientPhysicalExamList; + List get patientProgressNoteList => + _SOAPService.patientProgressNoteList; - List get patientProgressNoteList => _SOAPService.patientProgressNoteList; + List get patientAssessmentList => + _SOAPService.patientAssessmentList; - List get patientAssessmentList => _SOAPService.patientAssessmentList; + List get searchAllergiesVidaPlus => + _SOAPService.searchAllergiesList; + List get patientAllergiesVidaPlus => + _SOAPService.patientAllergiesVidaPlus; - List get searchAllergiesVidaPlus => _SOAPService.searchAllergiesList; + List get getHopiDetails => _SOAPService.hopiDetails; - List get patientAllergiesVidaPlus => _SOAPService.patientAllergiesVidaPlus; + List get searchChiefComplaintList => + _SOAPService.searchChiefComplaintListVidaPlus; + List get getChiefComplaintListVidaPlus => + _SOAPService.patientChiefComplaintListVidaPlus; int? get episodeID => _SOAPService.episodeID; - bool get isPrescriptionOrder => _SOAPService.isPrescriptionOrder; + + bool get isPrescriptionOrder => _SOAPService.isPrescriptionOrder; bool isAddProgress = true; bool isAddExamInProgress = true; String progressNoteText = ""; @@ -103,7 +129,8 @@ class SOAPViewModel extends BaseViewModel { get medicationFrequencyList => _SOAPService.medicationFrequencyListWithModel; - List? get allMedicationList => _prescriptionService.allMedicationList; + List? get allMedicationList => + _prescriptionService.allMedicationList; late SubjectiveCallBack subjectiveCallBack; @@ -145,7 +172,10 @@ class SOAPViewModel extends BaseViewModel { planCallBack.nextFunction(model); } - Future getMasterLookup(MasterKeysService masterKeys, {bool isBusyLocal = false, String searchKey = "", bool allowSetState = false}) async { + Future getMasterLookup(MasterKeysService masterKeys, + {bool isBusyLocal = false, + String searchKey = "", + bool allowSetState = false}) async { if (isBusyLocal) { setState(ViewState.Busy); } else @@ -168,9 +198,12 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future postEpisodeForInPatient(PostEpisodeForInpatientRequestModel postEpisodeForInpatientRequestModel) async { + Future postEpisodeForInPatient( + PostEpisodeForInpatientRequestModel + postEpisodeForInpatientRequestModel) async { setState(ViewState.BusyLocal); - await _SOAPService.postEpisodeForInPatient(postEpisodeForInpatientRequestModel); + await _SOAPService.postEpisodeForInPatient( + postEpisodeForInpatientRequestModel); if (_SOAPService.hasError) { error = _SOAPService.error; setState(ViewState.ErrorLocal); @@ -178,7 +211,8 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future postPhysicalExam(PostPhysicalExamRequestModel postPhysicalExamRequestModel) async { + Future postPhysicalExam( + PostPhysicalExamRequestModel postPhysicalExamRequestModel) async { setState(ViewState.BusyLocal); await _SOAPService.postPhysicalExam(postPhysicalExamRequestModel); if (_SOAPService.hasError) { @@ -188,7 +222,8 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future postProgressNote(PostProgressNoteRequestModel postProgressNoteRequestModel) async { + Future postProgressNote( + PostProgressNoteRequestModel postProgressNoteRequestModel) async { setState(ViewState.BusyLocal); await _SOAPService.postProgressNote(postProgressNoteRequestModel); if (_SOAPService.hasError) { @@ -198,7 +233,8 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future postAssessment(PostAssessmentRequestModel postAssessmentRequestModel) async { + Future postAssessment( + PostAssessmentRequestModel postAssessmentRequestModel) async { setState(ViewState.BusyLocal); await _SOAPService.postAssessment(postAssessmentRequestModel); if (_SOAPService.hasError) { @@ -208,7 +244,8 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future patchPhysicalExam(PostPhysicalExamRequestModel patchPhysicalExamRequestModel) async { + Future patchPhysicalExam( + PostPhysicalExamRequestModel patchPhysicalExamRequestModel) async { setState(ViewState.BusyLocal); await _SOAPService.patchPhysicalExam(patchPhysicalExamRequestModel); if (_SOAPService.hasError) { @@ -218,7 +255,8 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future patchProgressNote(PostProgressNoteRequestModel patchProgressNoteRequestModel) async { + Future patchProgressNote( + PostProgressNoteRequestModel patchProgressNoteRequestModel) async { setState(ViewState.BusyLocal); await _SOAPService.patchProgressNote(patchProgressNoteRequestModel); if (_SOAPService.hasError) { @@ -228,7 +266,8 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future patchAssessment(PostAssessmentRequestUpdateModel patchAssessmentRequestModel) async { + Future patchAssessment( + PostAssessmentRequestUpdateModel patchAssessmentRequestModel) async { setState(ViewState.BusyLocal); await _SOAPService.patchAssessment(patchAssessmentRequestModel!); if (_SOAPService.hasError) { @@ -238,7 +277,8 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getPatientAllergy(GeneralGetReqForSOAP generalGetReqForSOAP, {isLocalBusy = false}) async { + Future getPatientAllergy(GeneralGetReqForSOAP generalGetReqForSOAP, + {isLocalBusy = false}) async { if (isLocalBusy) { setState(ViewState.BusyLocal); } else @@ -257,8 +297,14 @@ class SOAPViewModel extends BaseViewModel { String getAllergicNames(isArabic) { String allergiesString = ''; patientAllergiesList.forEach((element) { - MasterKeyModel? selectedAllergy = getOneMasterKey(masterKeys: MasterKeysService.Allergies, id: element.allergyDiseaseId, typeId: element.allergyDiseaseType!); - if (selectedAllergy != null && element.isChecked!) allergiesString += ((isArabic ? selectedAllergy.nameAr : selectedAllergy.nameEn)! + ' , '); + MasterKeyModel? selectedAllergy = getOneMasterKey( + masterKeys: MasterKeysService.Allergies, + id: element.allergyDiseaseId, + typeId: element.allergyDiseaseType!); + if (selectedAllergy != null && element.isChecked!) + allergiesString += + ((isArabic ? selectedAllergy.nameAr : selectedAllergy.nameEn)! + + ' , '); }); return allergiesString; } @@ -266,7 +312,9 @@ class SOAPViewModel extends BaseViewModel { Future getPatientPhysicalExam(PatiantInformtion patientInfo) async { GetPhysicalExamReqModel getPhysicalExamReqModel = GetPhysicalExamReqModel( patientMRN: patientInfo.patientMRN, - episodeID: patientInfo.episodeNo == null ? "0" : patientInfo.episodeNo.toString(), + episodeID: patientInfo.episodeNo == null + ? "0" + : patientInfo.episodeNo.toString(), appointmentNo: patientInfo.appointmentNo == null ? 0 : int.parse( @@ -286,7 +334,8 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getPatientProgressNote(GetProgressNoteReqModel getGetProgressNoteReqModel) async { + Future getPatientProgressNote( + GetProgressNoteReqModel getGetProgressNoteReqModel) async { setState(ViewState.Busy); await _SOAPService.getPatientProgressNote(getGetProgressNoteReqModel); if (_SOAPService.hasError) { @@ -308,7 +357,11 @@ class SOAPViewModel extends BaseViewModel { Future getEpisodeForInpatient(PatiantInformtion patient) async { setState(ViewState.BusyLocal); - GetEpisodeForInpatientReqModel getEpisodeForInpatientReqModel = GetEpisodeForInpatientReqModel(patientID: patient.patientId, admissionNo: int.parse(patient.admissionNo!), patientTypeID: 1); + GetEpisodeForInpatientReqModel getEpisodeForInpatientReqModel = + GetEpisodeForInpatientReqModel( + patientID: patient.patientId, + admissionNo: int.parse(patient.admissionNo!), + patientTypeID: 1); await _SOAPService.getEpisodeForInpatient(getEpisodeForInpatientReqModel); if (_SOAPService.hasError) { error = _SOAPService.error; @@ -320,11 +373,13 @@ class SOAPViewModel extends BaseViewModel { } // ignore: missing_return - MasterKeyModel? getOneMasterKey({required MasterKeysService masterKeys, dynamic id, int? typeId}) { + MasterKeyModel? getOneMasterKey( + {required MasterKeysService masterKeys, dynamic id, int? typeId}) { switch (masterKeys) { case MasterKeysService.Allergies: List result = allergiesList.where((element) { - return element.id == id && element.typeId == masterKeys.getMasterKeyService(); + return element.id == id && + element.typeId == masterKeys.getMasterKeyService(); }).toList(); if (result.isNotEmpty) { return result.first; @@ -333,7 +388,8 @@ class SOAPViewModel extends BaseViewModel { case MasterKeysService.HistoryFamily: List result = historyFamilyList.where((element) { - return element.id == id && element.typeId == masterKeys.getMasterKeyService(); + return element.id == id && + element.typeId == masterKeys.getMasterKeyService(); }).toList(); if (result.isNotEmpty) { return result.first; @@ -341,7 +397,8 @@ class SOAPViewModel extends BaseViewModel { break; case MasterKeysService.HistoryMedical: List result = historyMedicalList.where((element) { - return element.id == id && element.typeId == masterKeys.getMasterKeyService(); + return element.id == id && + element.typeId == masterKeys.getMasterKeyService(); }).toList(); if (result.isNotEmpty) { return result.first; @@ -349,7 +406,8 @@ class SOAPViewModel extends BaseViewModel { break; case MasterKeysService.HistorySocial: List result = historySocialList.where((element) { - return element.id == id && element.typeId == masterKeys.getMasterKeyService(); + return element.id == id && + element.typeId == masterKeys.getMasterKeyService(); }).toList(); if (result.isNotEmpty) { return result.first; @@ -357,7 +415,8 @@ class SOAPViewModel extends BaseViewModel { break; case MasterKeysService.HistorySports: List result = historySocialList.where((element) { - return element.id == id && element.typeId == masterKeys.getMasterKeyService(); + return element.id == id && + element.typeId == masterKeys.getMasterKeyService(); }).toList(); if (result.isNotEmpty) { return result.first; @@ -373,7 +432,8 @@ class SOAPViewModel extends BaseViewModel { break; case MasterKeysService.PhysicalExamination: List result = physicalExaminationList.where((element) { - return element.id == id && element.typeId == masterKeys.getMasterKeyService(); + return element.id == id && + element.typeId == masterKeys.getMasterKeyService(); }).toList(); if (result.isNotEmpty) { return result.first; @@ -381,7 +441,8 @@ class SOAPViewModel extends BaseViewModel { break; case MasterKeysService.AllergySeverity: List result = allergySeverityList.where((element) { - return element.id == id && element.typeId == masterKeys.getMasterKeyService(); + return element.id == id && + element.typeId == masterKeys.getMasterKeyService(); }).toList(); if (result.isNotEmpty) { return result.first; @@ -389,7 +450,8 @@ class SOAPViewModel extends BaseViewModel { break; case MasterKeysService.DiagnosisType: List result = listOfDiagnosisType.where((element) { - return element.id == id && element.typeId == masterKeys.getMasterKeyService(); + return element.id == id && + element.typeId == masterKeys.getMasterKeyService(); }).toList(); if (result.isNotEmpty) { return result.first; @@ -397,7 +459,8 @@ class SOAPViewModel extends BaseViewModel { break; case MasterKeysService.DiagnosisCondition: List result = listOfDiagnosisCondition.where((element) { - return element.id == id && element.typeId == masterKeys.getMasterKeyService(); + return element.id == id && + element.typeId == masterKeys.getMasterKeyService(); }).toList(); if (result.isNotEmpty) { return result.first; @@ -436,8 +499,10 @@ class SOAPViewModel extends BaseViewModel { } } - int getFirstIndexForOldExamination(List mySelectedExamination) { - Iterable examList = mySelectedExamination.where((element) => !element.isLocal); + int getFirstIndexForOldExamination( + List mySelectedExamination) { + Iterable examList = + mySelectedExamination.where((element) => !element.isLocal); if (examList.length > 0) { return mySelectedExamination.indexOf(examList.first); @@ -446,25 +511,44 @@ class SOAPViewModel extends BaseViewModel { } onUpdateSubjectStepStart(PatiantInformtion patientInfo) async { - GetChiefComplaintReqModel getChiefComplaintReqModel = GetChiefComplaintReqModel( - admissionNo: patientInfo.admissionNo != null ? int.parse(patientInfo.admissionNo!) : null, - patientMRN: patientInfo.patientMRN, - appointmentNo: patientInfo.appointmentNo != null ? int.parse(patientInfo.appointmentNo.toString()) : null, - episodeId: patientInfo.episodeNo, - episodeID: patientInfo.episodeNo, - doctorID: ''); - var services = [await _SOAPService.getPatientChiefComplaint(getChiefComplaintReqModel)]; + GetChiefComplaintReqModel getChiefComplaintReqModel = + GetChiefComplaintReqModel( + admissionNo: + patientInfo + .admissionNo != + null + ? int.parse(patientInfo.admissionNo!) + : null, + patientMRN: patientInfo.patientMRN, + appointmentNo: patientInfo.appointmentNo != null + ? int.parse(patientInfo.appointmentNo.toString()) + : null, + episodeId: patientInfo.episodeNo, + episodeID: patientInfo.episodeNo, + doctorID: ''); + var services = [ + await _SOAPService.getPatientChiefComplaint(getChiefComplaintReqModel) + ]; if (patientInfo.admissionNo == null) { complaintsControllerError = ''; medicationControllerError = ''; illnessControllerError = ''; GetHistoryReqModel getHistoryReqModel = GetHistoryReqModel( - patientMRN: patientInfo.patientMRN, episodeID: patientInfo.episodeNo.toString(), appointmentNo: int.parse(patientInfo.appointmentNo.toString()), doctorID: '', editedBy: ''); - services.add(await _SOAPService.getPatientHistories(getHistoryReqModel, isFirst: true)); - - GeneralGetReqForSOAP generalGetReqForSOAP = - GeneralGetReqForSOAP(patientMRN: patientInfo.patientMRN, episodeId: patientInfo.episodeNo, appointmentNo: int.parse(patientInfo.appointmentNo.toString()), doctorID: '', editedBy: ''); + patientMRN: patientInfo.patientMRN, + episodeID: patientInfo.episodeNo.toString(), + appointmentNo: int.parse(patientInfo.appointmentNo.toString()), + doctorID: '', + editedBy: ''); + services.add(await _SOAPService.getPatientHistories(getHistoryReqModel, + isFirst: true)); + + GeneralGetReqForSOAP generalGetReqForSOAP = GeneralGetReqForSOAP( + patientMRN: patientInfo.patientMRN, + episodeId: patientInfo.episodeNo, + appointmentNo: int.parse(patientInfo.appointmentNo.toString()), + doctorID: '', + editedBy: ''); services.add(await _SOAPService.getPatientAllergy(generalGetReqForSOAP)); } @@ -478,41 +562,61 @@ class SOAPViewModel extends BaseViewModel { if (patientHistoryList.isNotEmpty) { if (historyFamilyList.isEmpty) { if (services.isEmpty) { - services = [await _SOAPService.getMasterLookup(MasterKeysService.HistoryFamily)]; + services = [ + await _SOAPService.getMasterLookup(MasterKeysService.HistoryFamily) + ]; } else { - services.add(await _SOAPService.getMasterLookup(MasterKeysService.HistoryFamily)); + services.add(await _SOAPService.getMasterLookup( + MasterKeysService.HistoryFamily)); } } if (historyMedicalList.isEmpty) { if (services.isEmpty) { - services = [await _SOAPService.getMasterLookup(MasterKeysService.HistoryMedical)]; + services = [ + await _SOAPService.getMasterLookup(MasterKeysService.HistoryMedical) + ]; } else - services.add(await _SOAPService.getMasterLookup(MasterKeysService.HistoryMedical)); + services.add(await _SOAPService.getMasterLookup( + MasterKeysService.HistoryMedical)); } if (historySurgicalList.length == 0) { if (services.isEmpty) { - services = [await _SOAPService.getMasterLookup(MasterKeysService.HistorySurgical)]; + services = [ + await _SOAPService.getMasterLookup( + MasterKeysService.HistorySurgical) + ]; } else - services.add(await _SOAPService.getMasterLookup(MasterKeysService.HistorySurgical)); + services.add(await _SOAPService.getMasterLookup( + MasterKeysService.HistorySurgical)); } if (historySportList.length == 0) { if (services.isEmpty) { - services = [await _SOAPService.getMasterLookup(MasterKeysService.HistorySports)]; + services = [ + await _SOAPService.getMasterLookup(MasterKeysService.HistorySports) + ]; } else - services.add(await _SOAPService.getMasterLookup(MasterKeysService.HistorySports)); + services.add(await _SOAPService.getMasterLookup( + MasterKeysService.HistorySports)); } } if (patientAllergiesList.isNotEmpty) { if (allergiesList.isEmpty) if (services.isEmpty) { - services = [await _SOAPService.getMasterLookup(MasterKeysService.Allergies)]; + services = [ + await _SOAPService.getMasterLookup(MasterKeysService.Allergies) + ]; } else - services.add(await _SOAPService.getMasterLookup(MasterKeysService.Allergies)); + services.add( + await _SOAPService.getMasterLookup(MasterKeysService.Allergies)); if (allergySeverityList.isEmpty) { if (services.isEmpty) { - services = [await _SOAPService.getMasterLookup(MasterKeysService.AllergySeverity)]; + services = [ + await _SOAPService.getMasterLookup( + MasterKeysService.AllergySeverity) + ]; } else - services.add(await _SOAPService.getMasterLookup(MasterKeysService.AllergySeverity)); + services.add(await _SOAPService.getMasterLookup( + MasterKeysService.AllergySeverity)); } } @@ -530,30 +634,45 @@ class SOAPViewModel extends BaseViewModel { List services = []; if (medicationStrengthList.length == 0) { if (services.isEmpty) { - services = [await _SOAPService.getMasterLookup(MasterKeysService.MedicationStrength)]; + services = [ + await _SOAPService.getMasterLookup( + MasterKeysService.MedicationStrength) + ]; } else { - services.add(await _SOAPService.getMasterLookup(MasterKeysService.MedicationStrength)); + services.add(await _SOAPService.getMasterLookup( + MasterKeysService.MedicationStrength)); } } if (medicationFrequencyList.length == 0) { if (services.isEmpty) { - services = [await _SOAPService.getMasterLookup(MasterKeysService.MedicationFrequency)]; + services = [ + await _SOAPService.getMasterLookup( + MasterKeysService.MedicationFrequency) + ]; } else { - services.add(await _SOAPService.getMasterLookup(MasterKeysService.MedicationFrequency)); + services.add(await _SOAPService.getMasterLookup( + MasterKeysService.MedicationFrequency)); } } if (medicationDoseTimeList.length == 0) { if (services.isEmpty) { - services = [await _SOAPService.getMasterLookup(MasterKeysService.MedicationDoseTime)]; + services = [ + await _SOAPService.getMasterLookup( + MasterKeysService.MedicationDoseTime) + ]; } else { - services.add(await _SOAPService.getMasterLookup(MasterKeysService.MedicationDoseTime)); + services.add(await _SOAPService.getMasterLookup( + MasterKeysService.MedicationDoseTime)); } } if (medicationRouteList.length == 0) { if (services.isEmpty) { - services = [await _SOAPService.getMasterLookup(MasterKeysService.MedicationRoute)]; + services = [ + await _SOAPService.getMasterLookup(MasterKeysService.MedicationRoute) + ]; } else { - services.add(await _SOAPService.getMasterLookup(MasterKeysService.MedicationRoute)); + services.add(await _SOAPService.getMasterLookup( + MasterKeysService.MedicationRoute)); } } if (allMedicationList!.isEmpty) { @@ -567,7 +686,8 @@ class SOAPViewModel extends BaseViewModel { final results = services; if (_SOAPService.hasError || _prescriptionService.hasError) { - error = _SOAPService.error.toString() + _prescriptionService.error.toString(); + error = + _SOAPService.error.toString() + _prescriptionService.error.toString(); setState(ViewState.ErrorLocal); } else { setState( @@ -576,28 +696,40 @@ class SOAPViewModel extends BaseViewModel { } } - callAddAssessmentLookupsServices({String searchKey = "", bool allowSetState = true}) async { + callAddAssessmentLookupsServices( + {String searchKey = "", bool allowSetState = true}) async { if (allowSetState) setState(ViewState.Busy); List services = []; if (listOfDiagnosisCondition.isEmpty) { if (services.isEmpty) { - services = [await _SOAPService.getMasterLookup(MasterKeysService.DiagnosisCondition)]; + services = [ + await _SOAPService.getMasterLookup( + MasterKeysService.DiagnosisCondition) + ]; } else { - services.add(await _SOAPService.getMasterLookup(MasterKeysService.DiagnosisCondition)); + services.add(await _SOAPService.getMasterLookup( + MasterKeysService.DiagnosisCondition)); } } if (listOfDiagnosisType.length == 0) { if (services.isEmpty) { - services = [await _SOAPService.getMasterLookup(MasterKeysService.DiagnosisType)]; + services = [ + await _SOAPService.getMasterLookup(MasterKeysService.DiagnosisType) + ]; } else { - services.add(await _SOAPService.getMasterLookup(MasterKeysService.DiagnosisType)); + services.add(await _SOAPService.getMasterLookup( + MasterKeysService.DiagnosisType)); } } if (listOfICD10.length == 0) { if (services.isEmpty) { - services = [await _SOAPService.getMasterLookup(MasterKeysService.ICD10, searchKey: searchKey)]; + services = [ + await _SOAPService.getMasterLookup(MasterKeysService.ICD10, + searchKey: searchKey) + ]; } else { - services.add(await _SOAPService.getMasterLookup(MasterKeysService.ICD10, searchKey: searchKey)); + services.add(await _SOAPService.getMasterLookup(MasterKeysService.ICD10, + searchKey: searchKey)); } } @@ -613,9 +745,15 @@ class SOAPViewModel extends BaseViewModel { onUpdateAssessmentStepStart(PatiantInformtion patientInfo) async { GetAssessmentReqModel getAssessmentReqModel = GetAssessmentReqModel( - patientMRN: patientInfo.patientMRN, episodeID: patientInfo.episodeNo.toString(), editedBy: '', doctorID: '', appointmentNo: int.parse(patientInfo.appointmentNo.toString())); + patientMRN: patientInfo.patientMRN, + episodeID: patientInfo.episodeNo.toString(), + editedBy: '', + doctorID: '', + appointmentNo: int.parse(patientInfo.appointmentNo.toString())); - var services = [await _SOAPService.getPatientAssessment(getAssessmentReqModel)]; + var services = [ + await _SOAPService.getPatientAssessment(getAssessmentReqModel) + ]; final results = services; @@ -630,8 +768,7 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.Idle); } - - Future isPrescriptionOrderCreated(PatiantInformtion patientInfo) async{ + Future isPrescriptionOrderCreated(PatiantInformtion patientInfo) async { setState(ViewState.BusyLocal); await _SOAPService.isPrescriptionOrderCreated(patientInfo); if (_SOAPService.hasError) { @@ -641,32 +778,51 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.Idle); } - - postSubjectServices({patientInfo, String? complaintsText, String? medicationText, String? illnessText, List? myHistoryList, List? myAllergiesList}) async { + postSubjectServices( + {patientInfo, + String? complaintsText, + String? medicationText, + String? illnessText, + List? myHistoryList, + List? myAllergiesList}) async { List services = []; PostChiefComplaintRequestModel postChiefComplaintRequestModel = - createPostChiefComplaintRequestModel(patientInfo: patientInfo, illnessText: illnessText!, medicationText: medicationText!, complaintsText: complaintsText!); + createPostChiefComplaintRequestModel( + patientInfo: patientInfo, + illnessText: illnessText!, + medicationText: medicationText!, + complaintsText: complaintsText!); if (patientChiefComplaintList.isEmpty) { postChiefComplaintRequestModel.editedBy = ''; - services = [await _SOAPService.postChiefComplaint(postChiefComplaintRequestModel)]; + services = [ + await _SOAPService.postChiefComplaint(postChiefComplaintRequestModel) + ]; } else { postChiefComplaintRequestModel.editedBy = ''; - services = [await _SOAPService.patchChiefComplaint(postChiefComplaintRequestModel)]; + services = [ + await _SOAPService.patchChiefComplaint(postChiefComplaintRequestModel) + ]; } if (myHistoryList!.length != 0) { - PostHistoriesRequestModel postHistoriesRequestModel = createPostHistoriesRequestModel(patientInfo: patientInfo, myHistoryList: myHistoryList); + PostHistoriesRequestModel postHistoriesRequestModel = + createPostHistoriesRequestModel( + patientInfo: patientInfo, myHistoryList: myHistoryList); if (patientHistoryList.isEmpty) { - services.add(await _SOAPService.postHistories(postHistoriesRequestModel)); + services + .add(await _SOAPService.postHistories(postHistoriesRequestModel)); } else { - services.add(await _SOAPService.patchHistories(postHistoriesRequestModel)); + services + .add(await _SOAPService.patchHistories(postHistoriesRequestModel)); } } if (myAllergiesList!.length != 0) { - PostAllergyRequestModel postAllergyRequestModel = createPostAllergyRequestModel(myAllergiesList: myAllergiesList, patientInfo: patientInfo); + PostAllergyRequestModel postAllergyRequestModel = + createPostAllergyRequestModel( + myAllergiesList: myAllergiesList, patientInfo: patientInfo); if (patientAllergiesList.isEmpty) { services.add(await _SOAPService.postAllergy(postAllergyRequestModel)); } else { @@ -683,9 +839,15 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.Idle); } - PostChiefComplaintRequestModel createPostChiefComplaintRequestModel({patientInfo, String? complaintsText, String? medicationText, String? illnessText}) { + PostChiefComplaintRequestModel createPostChiefComplaintRequestModel( + {patientInfo, + String? complaintsText, + String? medicationText, + String? illnessText}) { return PostChiefComplaintRequestModel( - admissionNo: patientInfo.admissionNo != null ? int.parse(patientInfo.admissionNo) : null, + admissionNo: patientInfo.admissionNo != null + ? int.parse(patientInfo.admissionNo) + : null, patientMRN: patientInfo.patientMRN, episodeID: patientInfo.episodeNo ?? 0, appointmentNo: patientInfo.appointmentNo ?? 0, @@ -698,10 +860,13 @@ class SOAPViewModel extends BaseViewModel { numberOfWeeks: 0); } - PostHistoriesRequestModel createPostHistoriesRequestModel({patientInfo, List? myHistoryList}) { - PostHistoriesRequestModel postHistoriesRequestModel = new PostHistoriesRequestModel(doctorID: ''); + PostHistoriesRequestModel createPostHistoriesRequestModel( + {patientInfo, List? myHistoryList}) { + PostHistoriesRequestModel postHistoriesRequestModel = + new PostHistoriesRequestModel(doctorID: ''); myHistoryList!.forEach((history) { - if (postHistoriesRequestModel.listMedicalHistoryVM == null) postHistoriesRequestModel.listMedicalHistoryVM = []; + if (postHistoriesRequestModel.listMedicalHistoryVM == null) + postHistoriesRequestModel.listMedicalHistoryVM = []; postHistoriesRequestModel.listMedicalHistoryVM!.add(ListMedicalHistoryVM( patientMRN: patientInfo.patientMRN, episodeId: patientInfo.episodeNo, @@ -716,24 +881,29 @@ class SOAPViewModel extends BaseViewModel { return postHistoriesRequestModel; } - PostAllergyRequestModel createPostAllergyRequestModel({myAllergiesList, patientInfo}) { - PostAllergyRequestModel postAllergyRequestModel = new PostAllergyRequestModel(); + PostAllergyRequestModel createPostAllergyRequestModel( + {myAllergiesList, patientInfo}) { + PostAllergyRequestModel postAllergyRequestModel = + new PostAllergyRequestModel(); myAllergiesList.forEach((allergy) { - if (postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM == null) postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM = []; - postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM!.add(ListHisProgNotePatientAllergyDiseaseVM( - allergyDiseaseId: allergy.selectedAllergy.id, - allergyDiseaseType: allergy.selectedAllergy.typeId, - patientMRN: patientInfo.patientMRN, - episodeId: patientInfo.episodeNo, - appointmentNo: patientInfo.appointmentNo, - severity: allergy.selectedAllergySeverity.id, - remarks: allergy.remark, - createdBy: allergy.createdBy ?? doctorProfile!.doctorID, - createdOn: DateTime.now().toIso8601String(), - editedBy: doctorProfile!.doctorID, - editedOn: DateTime.now().toIso8601String(), - isChecked: allergy.isChecked, - isUpdatedByNurse: false)); + if (postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM == + null) + postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM = []; + postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM!.add( + ListHisProgNotePatientAllergyDiseaseVM( + allergyDiseaseId: allergy.selectedAllergy.id, + allergyDiseaseType: allergy.selectedAllergy.typeId, + patientMRN: patientInfo.patientMRN, + episodeId: patientInfo.episodeNo, + appointmentNo: patientInfo.appointmentNo, + severity: allergy.selectedAllergySeverity.id, + remarks: allergy.remark, + createdBy: allergy.createdBy ?? doctorProfile!.doctorID, + createdOn: DateTime.now().toIso8601String(), + editedBy: doctorProfile!.doctorID, + editedOn: DateTime.now().toIso8601String(), + isChecked: allergy.isChecked, + isUpdatedByNurse: false)); }); return postAllergyRequestModel; @@ -741,13 +911,61 @@ class SOAPViewModel extends BaseViewModel { /*vida plus */ - getAllergiesVidaPlus(PatiantInformtion patientInfo) async{ + getAllergiesVidaPlus(PatiantInformtion patientInfo) async { + setState(ViewState.BusyLocal); + await _SOAPService.patientAllergies(patientInfo); + if (_SOAPService.hasError) { + error = _SOAPService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } + + searchAllergies(String searchKey) async { + setState(ViewState.BusyLocal); + await _SOAPService.searchAllergies(searchKey); + if (_SOAPService.hasError) { + error = _SOAPService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } + + addAllergies( + AllergiesListVidaPlus request, PatiantInformtion patientInfo) async { + setState(ViewState.BusyLocal); + await _SOAPService.addAllergies(request, patientInfo); + if (_SOAPService.hasError) { + error = _SOAPService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } + + resolveAllergies( + PatientAllergiesVidaPlus request, PatiantInformtion patientInfo) async { + setState(ViewState.BusyLocal); + await _SOAPService.resolveAllergies(request, patientInfo); + if (_SOAPService.hasError) { + error = _SOAPService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } - GeneralGetReqForSOAP generalGetReqForSOAP = - GeneralGetReqForSOAP(patientMRN: patientInfo.patientMRN, episodeId: patientInfo.episodeNo, appointmentNo: int.parse(patientInfo.appointmentNo.toString()), doctorID: '', editedBy: ''); + saveHopi(Map req, PatiantInformtion patientInfo) async { + setState(ViewState.BusyLocal); + await _SOAPService.saveHopi(req, patientInfo); + if (_SOAPService.hasError) { + error = _SOAPService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } + getHopi(PatiantInformtion patientInfo) async { setState(ViewState.BusyLocal); - await _SOAPService.patientAllergies(generalGetReqForSOAP); + await _SOAPService.getHopi(patientInfo); if (_SOAPService.hasError) { error = _SOAPService.error; setState(ViewState.ErrorLocal); @@ -755,10 +973,29 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.Idle); } + getChiefComplaint(PatiantInformtion patientInfo) async { + setState(ViewState.BusyLocal); + await _SOAPService.getChiefComplaint(patientInfo); + if (_SOAPService.hasError) { + error = _SOAPService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } - searchAllergies(String searchKey) async{ + searchChiefComplaint(PatiantInformtion patientInfo, String CC) async { setState(ViewState.BusyLocal); - await _SOAPService.searchAllergies(searchKey); + await _SOAPService.searchChiefComplaintVidaPlus(patientInfo, CC); + if (_SOAPService.hasError) { + error = _SOAPService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } + + saveChiefComplaint(PatiantInformtion patientInfo, String CC) async { + setState(ViewState.BusyLocal); + await _SOAPService.postChiefComplaintVidaPlus(patientInfo, CC); if (_SOAPService.hasError) { error = _SOAPService.error; setState(ViewState.ErrorLocal); diff --git a/lib/screens/patients/profile/soap_update_vida_plus/subjective/allergies/add_allergies.dart b/lib/screens/patients/profile/soap_update_vida_plus/subjective/allergies/add_allergies.dart index 6eadd40a..6b9f7b0b 100644 --- a/lib/screens/patients/profile/soap_update_vida_plus/subjective/allergies/add_allergies.dart +++ b/lib/screens/patients/profile/soap_update_vida_plus/subjective/allergies/add_allergies.dart @@ -1,25 +1,19 @@ -import 'package:autocomplete_textfield/autocomplete_textfield.dart'; -import 'package:doctor_app_flutter/core/model/SOAP/allergy/get_allergies_list_vida_plus.dart'; -import 'package:doctor_app_flutter/core/model/SOAP/master_key_model.dart'; -import 'package:doctor_app_flutter/core/model/SOAP/selected_items/my_selected_allergy.dart'; import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; -import 'package:doctor_app_flutter/utils/utils.dart'; import 'package:doctor_app_flutter/widgets/bottom_sheet/custom_bottom_sheet_container.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:flutter/material.dart'; +import '../../../../../../core/model/SOAP/allergy/get_patient_allergies_list_vida_plus.dart'; +import '../../../../../../core/model/patient/patiant_info_model.dart'; import '../../../../patient_search/patient_search_header.dart'; -import '../../../soap_update/shared_soap_widgets/bottom_sheet_title.dart'; import 'master_key_checkbox_search_allergies_widget.dart'; class AddAllergies extends StatefulWidget { - final Function? addAllergiesFun; - final AllergiesListVidaPlus? myAllergiesList; - - const AddAllergies({Key? key, this.addAllergiesFun, this.myAllergiesList}) + final PatientAllergiesVidaPlus? myAllergiesList; + final PatiantInformtion patientInfo; + const AddAllergies({Key? key, this.myAllergiesList, required this.patientInfo}) : super(key: key); @override @@ -53,9 +47,8 @@ class _AddAllergiesState extends State { title: TranslationBase.of(context).addAllergies), body: MasterKeyCheckboxSearchAllergiesWidget( model: model, - // addAllergy: (AllergiesListVidaPlus mySelectedAllergy) { - // widget.addAllergiesFun!(mySelectedAllergy); - // }, + myAllergiesList: widget.myAllergiesList, + patientInfo: widget.patientInfo ), bottomSheet: CustomBottomSheetContainer( widthFactor: .9, diff --git a/lib/screens/patients/profile/soap_update_vida_plus/subjective/allergies/master_key_checkbox_search_allergies_widget.dart b/lib/screens/patients/profile/soap_update_vida_plus/subjective/allergies/master_key_checkbox_search_allergies_widget.dart index fd42e837..b0dae525 100644 --- a/lib/screens/patients/profile/soap_update_vida_plus/subjective/allergies/master_key_checkbox_search_allergies_widget.dart +++ b/lib/screens/patients/profile/soap_update_vida_plus/subjective/allergies/master_key_checkbox_search_allergies_widget.dart @@ -10,6 +10,8 @@ import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-cust import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import '../../../../../../core/model/SOAP/allergy/get_patient_allergies_list_vida_plus.dart'; +import '../../../../../../core/model/patient/patiant_info_model.dart'; import '../../../../../../widgets/transitions/fade_page.dart'; import '../../objective/widget/EmptyExamination.dart'; @@ -18,13 +20,13 @@ class MasterKeyCheckboxSearchAllergiesWidget extends StatefulWidget { final SOAPViewModel model; final String? buttonName; final String? hintSearchText; - + final PatientAllergiesVidaPlus? myAllergiesList; + final PatiantInformtion patientInfo; MasterKeyCheckboxSearchAllergiesWidget( {Key? key, required this.model, - - // required this.addAllergy, - + this.myAllergiesList, + required this.patientInfo, this.buttonName, this.hintSearchText, @@ -42,7 +44,7 @@ bool loading =false; @override void initState() { - // items.addAll(widget.masterList); + super.initState(); } @@ -102,6 +104,7 @@ bool loading =false; itemBuilder: (context, index) { loading =false; return ListTile(title: AppText(widget.model.searchAllergiesVidaPlus[index].allergyName!), trailing: TextButton.icon(icon: SvgPicture.asset("assets/images/svgs/add-square.svg", color: Color(0xffD02127),), style: ButtonStyle(iconColor: WidgetStateProperty.all(Color(0xffD02127)), ), onPressed: (){ + openReaction(widget.model, widget.model.searchAllergiesVidaPlus[index]); }, label: AppText(TranslationBase.of(context).add, fontSize:12, color:Color(0xffD02127) ,), @@ -126,16 +129,20 @@ bool loading =false; ); } openReaction(model, AllergiesListVidaPlus mySelectedAllergy){ + Navigator.of(context).pop(); Navigator.push( context, FadePage( page:ReactionsSelectionAllergiesWidget( model:model, mySelectedAllergy: mySelectedAllergy, - addReactionFun: (AllergiesListVidaPlus mySelectedAllergy) { - Navigator.of(context).pop(); - - }) + patientInfo: widget.patientInfo + ) + // addReactionFun: (AllergiesListVidaPlus mySelectedAllergy) { + // + // Navigator.of(context).pop(); + // + // }) )); } diff --git a/lib/screens/patients/profile/soap_update_vida_plus/subjective/allergies/reactions_selection.dart b/lib/screens/patients/profile/soap_update_vida_plus/subjective/allergies/reactions_selection.dart index 48cb4f6c..938f4c6a 100644 --- a/lib/screens/patients/profile/soap_update_vida_plus/subjective/allergies/reactions_selection.dart +++ b/lib/screens/patients/profile/soap_update_vida_plus/subjective/allergies/reactions_selection.dart @@ -1,32 +1,36 @@ -import 'package:doctor_app_flutter/core/enum/view_state.dart'; import 'package:doctor_app_flutter/core/model/SOAP/allergy/get_allergies_list_vida_plus.dart'; +import 'package:doctor_app_flutter/core/model/SOAP/allergy/get_patient_allergies_list_vida_plus.dart'; import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; -import 'package:doctor_app_flutter/utils/utils.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_svg/flutter_svg.dart'; - +import 'package:provider/provider.dart'; import '../../../../../../config/config.dart'; -import '../../../../../../widgets/bottom_sheet/custom_bottom_sheet_container.dart'; +import '../../../../../../core/model/patient/patiant_info_model.dart'; +import '../../../../../../core/viewModel/project_view_model.dart'; import '../../../../../../widgets/shared/app_scaffold_widget.dart'; import '../../../../../../widgets/shared/buttons/app_buttons_widget.dart'; +import '../../../../../base/base_view.dart'; import '../../../../patient_search/patient_search_header.dart'; -import '../../../soap_update/shared_soap_widgets/bottom_sheet_title.dart'; + class ReactionsSelectionAllergiesWidget extends StatefulWidget { final SOAPViewModel? model; - final AllergiesListVidaPlus mySelectedAllergy; - final Function(AllergiesListVidaPlus mySelectedAllergy) addReactionFun; - + final AllergiesListVidaPlus? mySelectedAllergy; + final bool isEdit; + final PatientAllergiesVidaPlus? editSelectedAllergy; + final PatiantInformtion patientInfo; final String? buttonName; ReactionsSelectionAllergiesWidget({ Key? key, required this.model, - required this.addReactionFun, - required this.mySelectedAllergy, + required this.patientInfo, + this.mySelectedAllergy, + this.editSelectedAllergy, + this.isEdit = false, + this.buttonName, }) : super(key: key); @@ -37,11 +41,8 @@ class ReactionsSelectionAllergiesWidget extends StatefulWidget { class _ReactionsSelectionAllergiesWidgetState extends State { - // List items = []; bool loading = false; - // TextEditingController filteredSearchController = TextEditingController(); - @override void initState() { super.initState(); @@ -49,21 +50,23 @@ class _ReactionsSelectionAllergiesWidgetState @override Widget build(BuildContext context) { - return AppScaffold( - // isShowAppBar: true, + + return BaseView( + builder: (_, model, w) => AppScaffold( + isLoading:loading, appBar: PatientSearchHeader( - title: "Select Reaction" + title: widget.mySelectedAllergy !=null ?widget.mySelectedAllergy!.allergyName : widget.editSelectedAllergy!.allergyName ), body: Column( crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Expanded( + widget.mySelectedAllergy != null ? Expanded( child: RoundedContainer( margin: EdgeInsets.all(15), child: ListView.builder( itemCount: - widget.mySelectedAllergy.allergyReactionDTOs!.length, + widget.mySelectedAllergy!.allergyReactionDTOs!.length, itemBuilder: (context, index) { loading = false; return Column(children: [ @@ -74,17 +77,17 @@ class _ReactionsSelectionAllergiesWidgetState showTrailingIcon: false, initiallyExpanded: widget - .mySelectedAllergy + .mySelectedAllergy! .allergyReactionDTOs![index].isSelected!, leading: Checkbox( activeColor: Color(0xffD02127), value: widget - .mySelectedAllergy + .mySelectedAllergy! .allergyReactionDTOs![index].isSelected!, onChanged: (value) { widget - .mySelectedAllergy + .mySelectedAllergy! .allergyReactionDTOs![index].isSelected = value; setState(() { @@ -92,7 +95,7 @@ class _ReactionsSelectionAllergiesWidgetState }), title: AppText(widget - .mySelectedAllergy + .mySelectedAllergy! .allergyReactionDTOs![index] .allergyReactionName!), children: [ @@ -111,16 +114,16 @@ class _ReactionsSelectionAllergiesWidgetState MaterialTapTargetSize.shrinkWrap, // Reduces padding around checkbox visualDensity: VisualDensity.compact, - value: TranslationBase.of(context).mild, + value: 1, groupValue: widget - .mySelectedAllergy + .mySelectedAllergy! .allergyReactionDTOs![index] - .reactionSelection, + .severity, onChanged: (value) { widget - .mySelectedAllergy + .mySelectedAllergy! .allergyReactionDTOs![index] - .reactionSelection = value; + .severity = value; setState(() {}); }, ), @@ -140,16 +143,16 @@ class _ReactionsSelectionAllergiesWidgetState MaterialTapTargetSize.shrinkWrap, // Reduces padding around checkbox visualDensity: VisualDensity.compact, - value: TranslationBase.of(context).moderate, + value: 2, groupValue: widget - .mySelectedAllergy + .mySelectedAllergy! .allergyReactionDTOs![index] - .reactionSelection, + .severity, onChanged: (value) { widget - .mySelectedAllergy + .mySelectedAllergy! .allergyReactionDTOs![index] - .reactionSelection = value; + .severity = value; setState(() {}); }, ), @@ -169,16 +172,16 @@ class _ReactionsSelectionAllergiesWidgetState MaterialTapTargetSize.shrinkWrap, // Reduces padding around checkbox visualDensity: VisualDensity.compact, - value: TranslationBase.of(context).severe, + value: 3, groupValue: widget - .mySelectedAllergy + .mySelectedAllergy! .allergyReactionDTOs![index] - .reactionSelection, + .severity, onChanged: (value) { widget - .mySelectedAllergy + .mySelectedAllergy! .allergyReactionDTOs![index] - .reactionSelection = value; + .severity = value; setState(() {}); }, ), @@ -195,6 +198,127 @@ class _ReactionsSelectionAllergiesWidgetState Divider(), ]); }, + ))) : Expanded( + child: RoundedContainer( + margin: EdgeInsets.all(15), + child: ListView.builder( + itemCount: + widget.editSelectedAllergy!.patientsAllergyReactionsDTOs!.length, + itemBuilder: (context, index) { + loading = false; + return Column(children: [ + ExpansionTile( + key: Key(index.toString()), + dense: false, + enableFeedback: false, + showTrailingIcon: false, + + initiallyExpanded: widget.editSelectedAllergy!.patientsAllergyReactionsDTOs![index].isSelected!, + leading: + Checkbox( + activeColor: Color(0xffD02127), + value: widget.editSelectedAllergy!.patientsAllergyReactionsDTOs![index].isSelected!, onChanged: (value) { + + widget.editSelectedAllergy!.patientsAllergyReactionsDTOs![index].isSelected = value; + setState(() { + + }); + + }), + title: AppText( widget.editSelectedAllergy!.patientsAllergyReactionsDTOs![index] + .allergyReactionName!), + children: [ + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: ListTile( + title: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Radio( + activeColor: Color(0xffD02127), + materialTapTargetSize: + MaterialTapTargetSize.shrinkWrap, + // Reduces padding around checkbox + visualDensity: VisualDensity.compact, + value: TranslationBase.of(context).mild, + groupValue:getSeverityByID(widget.editSelectedAllergy!.patientsAllergyReactionsDTOs![index] + .severity!), + onChanged: (value) { + widget.editSelectedAllergy!.patientsAllergyReactionsDTOs![index] + .reactionSelection = getSeverityByID(widget.editSelectedAllergy!.patientsAllergyReactionsDTOs![index] + .severity!); + setState(() {}); + }, + ), + AppText( + TranslationBase.of(context).mild, + fontSize: 10, + ), + ], + ))), + Expanded( + child: ListTile( + title: Row( + children: [ + Radio( + activeColor: Color(0xffD02127), + materialTapTargetSize: + MaterialTapTargetSize.shrinkWrap, + // Reduces padding around checkbox + visualDensity: VisualDensity.compact, + value: TranslationBase.of(context).moderate, + groupValue: getSeverityByID(widget.editSelectedAllergy!.patientsAllergyReactionsDTOs![index] + .severity!), + onChanged: (value) { + widget.editSelectedAllergy!.patientsAllergyReactionsDTOs![index] + .reactionSelection =getSeverityByID(widget.editSelectedAllergy!.patientsAllergyReactionsDTOs![index] + .severity!); + setState(() {}); + }, + ), + AppText( + TranslationBase.of(context).moderate, + fontSize: 10, + ), + ], + ))), + Expanded( + child: ListTile( + title: Row( + children: [ + Radio( + activeColor: Color(0xffD02127), + materialTapTargetSize: + MaterialTapTargetSize.shrinkWrap, + // Reduces padding around checkbox + visualDensity: VisualDensity.compact, + value: TranslationBase.of(context).severe, + groupValue: getSeverityByID(widget.editSelectedAllergy!.patientsAllergyReactionsDTOs![index] + .severity!), + onChanged: (value) { + widget.editSelectedAllergy!.patientsAllergyReactionsDTOs![index] + .reactionSelection =getSeverityByID(widget.editSelectedAllergy!.patientsAllergyReactionsDTOs![index] + .severity!); + + setState(() {}); + }, + ), + AppText( + TranslationBase.of(context).severe, + fontSize: 10, + ), + ], + ))) + ], + ) + ], + ), + Divider(), + ]); + }, ))) ], ), @@ -224,15 +348,22 @@ class _ReactionsSelectionAllergiesWidgetState Expanded( child: Container( child: AppButton( + loading: loading, title: TranslationBase.of(context).save, vPadding: 8, hPadding: 8, color: AppGlobal.appGreenColor, fontColor: Colors.white, onPressed: () { - widget.addReactionFun(widget - .mySelectedAllergy - ); + if(widget.mySelectedAllergy ==null) { + + editAllergy(); + } + else{ + + addAllergy(); + + } }, ), ), @@ -251,6 +382,35 @@ class _ReactionsSelectionAllergiesWidgetState // }, // ) - ); + )); + } + getSeverityByID(int id){ + Map severity={ + 1:TranslationBase.of(context).mild, + 2:TranslationBase.of(context).moderate, + 3:TranslationBase.of(context).severe + + }; + return severity[id]; + } + addAllergy() async{ + setLoader(true); + AllergiesListVidaPlus request = widget + .mySelectedAllergy!; + request.allergyReactionDTOs = widget + .mySelectedAllergy!.allergyReactionDTOs!.where((i) => i.isSelected!).toList(); + await widget.model!.addAllergies(request, widget.patientInfo); + setLoader(false); + Navigator.of(context).pop(); + } + + editAllergy(){ + + } + setLoader(bool value) { + loading = value; + setState(() { + + }); } } diff --git a/lib/screens/patients/profile/soap_update_vida_plus/subjective/allergies/update_allergies_widget.dart b/lib/screens/patients/profile/soap_update_vida_plus/subjective/allergies/update_allergies_widget.dart index 0242bb46..ee4a3933 100644 --- a/lib/screens/patients/profile/soap_update_vida_plus/subjective/allergies/update_allergies_widget.dart +++ b/lib/screens/patients/profile/soap_update_vida_plus/subjective/allergies/update_allergies_widget.dart @@ -1,181 +1,207 @@ - import 'package:doctor_app_flutter/core/model/SOAP/allergy/get_patient_allergies_list_vida_plus.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/core/model/SOAP/selected_items/my_selected_allergy.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update_vida_plus/subjective/allergies/reactions_selection.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update_vida_plus/subjective/chief_complaint/widgets/add_soap_item.dart'; +import 'package:doctor_app_flutter/utils/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; +import 'package:doctor_app_flutter/utils/utils.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:provider/provider.dart'; +import '../../../../../../core/model/patient/patiant_info_model.dart'; import '../../../../../../widgets/transitions/fade_page.dart'; -import '../chief_complaint/widgets/add_soap_item.dart'; import 'add_allergies.dart'; import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; class UpdateAllergiesWidgetVidaPlus extends StatefulWidget { List? myAllergiesList; + final PatiantInformtion patientInfo; - UpdateAllergiesWidgetVidaPlus({Key? key, this.myAllergiesList}); + UpdateAllergiesWidgetVidaPlus( + {Key? key, this.myAllergiesList, required this.patientInfo}); @override _UpdateAllergiesWidgetState createState() => _UpdateAllergiesWidgetState(); } bool noKnownAllergies = false; -enum Severity {mild,moderate,severe } + +enum Severity { mild, moderate, severe } class _UpdateAllergiesWidgetState extends State { SOAPViewModel? model; @override Widget build(BuildContext context) { - ProjectViewModel projectViewModel = Provider.of(context); - changeAllState() { - setState(() { - print(widget.myAllergiesList); - }); - } - - return Column( - children: [ - SizedBox( - height: 20, - ), - AddSoapItem( - title: "${TranslationBase.of(context).addAllergies}", - onAddSoapItemClicked: () { - Navigator.push( - context, - FadePage( - page: AddAllergies(), - ), - ); - }, - ), - SizedBox( - height: 20, - ), - widget.myAllergiesList!.isEmpty - ? Row( - mainAxisSize: MainAxisSize.max, - children: [ - Checkbox( - value: noKnownAllergies, - checkColor: Colors.white, - activeColor: Colors.red, - onChanged: (value) { - noKnownAllergies = value!; - setState(() {}); - }, - materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, - // Reduces padding around checkbox - visualDensity: - VisualDensity.compact, // Minimizes size further - ), - AppText(TranslationBase.of(context).noKnownAllergies) - ], - ) - : Divider( - thickness: 1, - color: Color(0xffEFEFEF), - ), - ListView( - padding: EdgeInsets.all(10), - shrinkWrap: true, - children: widget.myAllergiesList!.map((selectedAllergy) { - return Column( - - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - selectedAllergy.allergyName!, - fontSize: 12, - fontWeight: FontWeight.w800, - letterSpacing: -0.48, - ), - - selectedAllergy.patientsAllergyReactionsDTOs!.isNotEmpty ? ListView( - shrinkWrap: true, - children: selectedAllergy.patientsAllergyReactionsDTOs!.map((PatientsAllergyReactionsDTOs reaction) => Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - -Row(children: [ AppText(reaction.allergyReactionName!, fontSize: 10,), - AppText(" - "), - AppText( - Severity.values[reaction.severity! -1].name, - - color: Color(0xFFCC9B14), - fontSize: 10, - fontWeight: FontWeight.w600, - letterSpacing: -0.48, - )],) - - ],)).toList()) : AppText("----"), - - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - SizedBox( - height: 10, - ), - TextButton.icon( - onPressed: () {}, - icon: SvgPicture.asset( - "assets/images/svgs/edit-icon.svg", - height: 16, - ), - label: AppText( - "Edit", - fontSize: 12, + return BaseView( + onModelReady: (model) {}, + builder: (_, model, w) => Column( + children: [ + SizedBox( + height: 20, + ), + AddSoapItem( + title: "${TranslationBase.of(context).addAllergies}", + onAddSoapItemClicked: () { + Navigator.push( + context, + FadePage( + page: AddAllergies( + patientInfo: widget.patientInfo, + // addAllergiesFun: (){ + // print("addAllergies save"); + // }, ), ), - TextButton.icon( - onPressed: () {}, - icon: SvgPicture.asset( - "assets/images/svgs/resolve.svg", - height: 18, + ); + }, + ), + SizedBox( + height: 20, + ), + widget.myAllergiesList!.isEmpty + ? Row( + mainAxisSize: MainAxisSize.max, + children: [ + Checkbox( + value: noKnownAllergies, + checkColor: Colors.white, + activeColor: Colors.red, + onChanged: (value) { + noKnownAllergies = value!; + setState(() {}); + }, + materialTapTargetSize: + MaterialTapTargetSize.shrinkWrap, + // Reduces padding around checkbox + visualDensity: + VisualDensity.compact, // Minimizes size further + ), + AppText(TranslationBase.of(context).noKnownAllergies) + ], + ) + : Divider( + thickness: 1, + color: Color(0xffEFEFEF), + ), + ListView( + padding: EdgeInsets.all(10), + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + children: widget.myAllergiesList!.map((selectedAllergy) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + selectedAllergy.allergyName!, + fontSize: 12, + fontWeight: FontWeight.w800, + letterSpacing: -0.48, ), - label: AppText("Resolve", - fontSize: 12, color: Color(0xff359846))) - ], - ) - ], - ); - }).toList()), - ], - ); + selectedAllergy + .patientsAllergyReactionsDTOs!.isNotEmpty + ? ListView( + shrinkWrap: true, + children: selectedAllergy + .patientsAllergyReactionsDTOs! + .map((PatientsAllergyReactionsDTOs + reaction) => + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Row( + children: [ + AppText( + reaction + .allergyReactionName!, + fontSize: 10, + ), + AppText(" - "), + AppText( + Severity + .values[ + reaction.severity! - + 1] + .name, + color:getColor(reaction.severity!), + fontSize: 10, + fontWeight: FontWeight.w600, + letterSpacing: -0.48, + ) + ], + ) + ], + )) + .toList()) + : AppText("----"), + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + SizedBox( + height: 10, + ), + TextButton.icon( + onPressed: () { + Navigator.push( + context, + FadePage( + page: + ReactionsSelectionAllergiesWidget( + model: model, + mySelectedAllergy: null, + editSelectedAllergy: selectedAllergy!, + patientInfo: widget.patientInfo, + ))); + }, + icon: SvgPicture.asset( + "assets/images/svgs/edit-icon.svg", + height: 16, + ), + label: AppText( + TranslationBase.of(context).edit, + fontSize: 12, + ), + ), + TextButton.icon( + onPressed: () { + resolveAllergy(model, selectedAllergy); + }, + icon: SvgPicture.asset( + "assets/images/svgs/resolve.svg", + height: 18, + ), + label: AppText( + TranslationBase.of(context).resolve, + fontSize: 12, + color: Color(0xff359846))) + ], + ) + ], + ); + }).toList()), + ], + )); } -// -// removeAllergy(MySelectedAllergy mySelectedAllergy) { -// List allergy = -// // ignore: missing_return -// widget.myAllergiesList! -// .where((element) => mySelectedAllergy.selectedAllergySeverity!.id == element.selectedAllergySeverity!.id && mySelectedAllergy.selectedAllergy!.id == element.selectedAllergy!.id) -// .toList(); -// -// if (allergy.length > 0) { -// if (allergy.first.isLocal) { -// setState(() { -// widget.myAllergiesList!.remove(allergy.first); -// }); -// } -// setState(() { -// allergy[0].isChecked = false; -// }); -// } -// } -// openAllergiesList(BuildContext context, Function changeParentState) { -// showModalBottomSheet( -// backgroundColor: Colors.white, -// isScrollControlled: true, -// isDismissible: false, -// context: context, -// builder: (context) { -// return AddAllergies(); -// }); -// } + resolveAllergy( + SOAPViewModel model, PatientAllergiesVidaPlus selectedAllergy) async{ + GifLoaderDialogUtils.showMyDialog(context); + + await model.resolveAllergies(selectedAllergy, widget.patientInfo); + GifLoaderDialogUtils.hideDialog(context); + + } + Color getColor(int severity){ + Map color ={ + 1:Color(0xff359846) , + 2:Color(0xFFCC9B14), + 3:Color(0xffD02127) + }; + return color[severity]; + } } diff --git a/lib/screens/patients/profile/soap_update_vida_plus/subjective/chief_complaint/AddChiefComplaints.dart b/lib/screens/patients/profile/soap_update_vida_plus/subjective/chief_complaint/AddChiefComplaints.dart index ef076dcf..f06810e9 100644 --- a/lib/screens/patients/profile/soap_update_vida_plus/subjective/chief_complaint/AddChiefComplaints.dart +++ b/lib/screens/patients/profile/soap_update_vida_plus/subjective/chief_complaint/AddChiefComplaints.dart @@ -1,3 +1,4 @@ +import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/patients/patient_search/patient_search_header.dart'; @@ -5,6 +6,7 @@ import 'package:doctor_app_flutter/screens/patients/profile/soap_update_vida_plu import 'package:doctor_app_flutter/screens/patients/profile/soap_update_vida_plus/subjective/chief_complaint/widgets/previous_cheif_complaints.dart'; import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; import 'package:flutter/material.dart'; class AddChiefComplaint extends StatelessWidget { @@ -13,6 +15,7 @@ class AddChiefComplaint extends StatelessWidget { final String? firstField; final String? secondField; final String? thirdField; + final PatiantInformtion patientInfo; const AddChiefComplaint( {super.key, @@ -20,7 +23,9 @@ class AddChiefComplaint extends StatelessWidget { required this.selectedType, this.firstField, this.secondField, - this.thirdField}); + this.thirdField, + required this.patientInfo + }); @override Widget build(BuildContext context) { @@ -43,6 +48,13 @@ class AddChiefComplaint extends StatelessWidget { firstField: firstField, secondField: secondField, thirdField: thirdField, + searchData: model.searchChiefComplaintList, + onSearch:(String value){ + searchChiefComplaint(model, value); + }, + onSave: (String chiefComplaint){ + addChiefComplaint(model, chiefComplaint); + }, ), SizedBox(height: 16,), PreviousCheifComplaints() @@ -53,4 +65,13 @@ class AddChiefComplaint extends StatelessWidget { ), ); } + addChiefComplaint(SOAPViewModel model, String CC) async{ + + await model.saveChiefComplaint(patientInfo, CC); + } + searchChiefComplaint(SOAPViewModel model, String CC) async{ + + await model.searchChiefComplaint(patientInfo, CC); + + } } diff --git a/lib/screens/patients/profile/soap_update_vida_plus/subjective/chief_complaint/chief_complaints.dart b/lib/screens/patients/profile/soap_update_vida_plus/subjective/chief_complaint/chief_complaints.dart index dc1d7e29..6bb0ddad 100644 --- a/lib/screens/patients/profile/soap_update_vida_plus/subjective/chief_complaint/chief_complaints.dart +++ b/lib/screens/patients/profile/soap_update_vida_plus/subjective/chief_complaint/chief_complaints.dart @@ -1,21 +1,27 @@ +import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update_vida_plus/subjective/chief_complaint/AddChiefComplaints.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update_vida_plus/subjective/chief_complaint/widgets/add_soap_item.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update_vida_plus/subjective/chief_complaint/widgets/complaint_items.dart'; -import 'package:doctor_app_flutter/screens/patients/profile/soap_update_vida_plus/subjective/chief_complaint/widgets/empty_complaints.dart'; -import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; -import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; class UpdateChiefComplaints extends StatelessWidget { final List complaints; - - const UpdateChiefComplaints({Key? key, required this.complaints}) + final PatiantInformtion patientInfo; + const UpdateChiefComplaints({Key? key, required this.complaints, required this.patientInfo}) : super(key: key); @override Widget build(BuildContext context) { - return Padding( + return BaseView( + onModelReady: (model){ + WidgetsBinding.instance.addPostFrameCallback((_) { + getChiefComplaints(model); + }); + }, + builder: (_, model, w) => Padding( padding: const EdgeInsets.all(12.0), child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ AddSoapItem( @@ -25,6 +31,8 @@ class UpdateChiefComplaints extends StatelessWidget { MaterialPageRoute( builder: (BuildContext context) => AddChiefComplaint( complaints: complaints, + patientInfo: patientInfo, + selectedType: '', firstField: '', secondField: '', @@ -34,15 +42,24 @@ class UpdateChiefComplaints extends StatelessWidget { title: "Add Chief Complaint", ), SizedBox(height: 16), - if (complaints.isEmpty) ...{ - Center(child: EmptyComplaints()) - } else ...{ + Container(width: MediaQuery.of(context).size.width, + height: 40, + child: ListView.builder( - itemBuilder: (_, index) => ComplaintItems( - complaint: complaints[index], - onCrossClicked: (complaints) {})) - } + shrinkWrap: true, + scrollDirection: Axis.horizontal, + itemCount: model.getChiefComplaintListVidaPlus.length, + itemBuilder: (_, index) => + ComplaintItems( + complaint: model.getChiefComplaintListVidaPlus[index].chiefComplain!, + onCrossClicked: (complaints) {}) + + )) + ]), - ); + )); + } + getChiefComplaints(SOAPViewModel model){ + model.getChiefComplaint(patientInfo); } } diff --git a/lib/screens/patients/profile/soap_update_vida_plus/subjective/chief_complaint/widgets/ComplaintSelection.dart b/lib/screens/patients/profile/soap_update_vida_plus/subjective/chief_complaint/widgets/ComplaintSelection.dart index fd83e263..c7d437c2 100644 --- a/lib/screens/patients/profile/soap_update_vida_plus/subjective/chief_complaint/widgets/ComplaintSelection.dart +++ b/lib/screens/patients/profile/soap_update_vida_plus/subjective/chief_complaint/widgets/ComplaintSelection.dart @@ -1,8 +1,12 @@ +import 'dart:async'; +import 'package:doctor_app_flutter/core/enum/view_state.dart'; +import 'package:doctor_app_flutter/core/model/SOAP/chief_complaint/search_chief_complaint_vidaplus.dart'; +import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update_vida_plus/subjective/chief_complaint/widgets/complaint_items.dart'; import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:flutter/material.dart'; -import 'package:hexcolor/hexcolor.dart'; class ComplaintSelection extends StatefulWidget { final List complaints; @@ -10,13 +14,20 @@ class ComplaintSelection extends StatefulWidget { final String? firstField; final String? secondField; final String? thirdField; + final Function(String cheifComplaint)? onSave; + final Function(String value)? onSearch; + final List? searchData; const ComplaintSelection({super.key, required this.complaints, required this.selectedType, this.firstField, this.secondField, - this.thirdField}); + this.thirdField, + this.onSave, + this.onSearch, + this.searchData + }); @override State createState() => _ComplaintSelectionState(); @@ -84,7 +95,11 @@ class _ComplaintSelectionState extends State { @override Widget build(BuildContext context) { - return Material( + return BaseView( + onModelReady: (model){ + + }, + builder: (_, model, w) => Material( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), side: BorderSide( @@ -194,16 +209,32 @@ class _ComplaintSelectionState extends State { ), ), ), - TextWithSelectedItems() + TextWithSelectedItems(model) ], ), ), - ); + )); } FocusNode _focus = FocusNode(); + Timer? _tTimer; + void _onStopped(String text) { + widget.onSearch!(text); + print(text); + } + + void _onTextChanged(String text) { + + if (_tTimer != null) { + _tTimer!.cancel(); + } + _tTimer = Timer(Duration(milliseconds: 500), (){ + _onStopped(text); + + }); + } - Widget TextWithSelectedItems() { + Widget TextWithSelectedItems(SOAPViewModel model) { return Material( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), @@ -227,33 +258,65 @@ class _ComplaintSelectionState extends State { ), ), SizedBox(height: 8,), + Row(children: [ + Expanded(child: Padding( + padding: EdgeInsets.only(left: 10,right: 10), + child: + + TextFormField( + autofocus: true, + + decoration: InputDecoration( + hintText: '', + border: InputBorder.none, + isCollapsed: true, + suffixIcon: model.state == ViewState.BusyLocal ?Transform.scale( + scale: 0.5, + child: CircularProgressIndicator(strokeWidth: 2,) ,): SizedBox() + ), + onChanged: _onTextChanged,) + + ),) + + ],), + Stack(children: [ + Positioned(child:Material( + elevation: 4.0, // Optional: for shadow effect + child: + ConstrainedBox( + constraints: BoxConstraints( + minHeight: 0, + maxHeight: 300), + child: + ListView.builder( + shrinkWrap: true, + itemCount: widget.searchData!.length, + itemBuilder: (context, index) { + return ListTile( + + title: InkWell(child:AppText(widget.searchData![index].chiefComplain!), onTap:(){ + var cc = widget.searchData![index].chiefComplain; + model.searchChiefComplaintList!.length =0; + setState((){}); + widget.onSave!(cc!); + })); + }))))]), + SizedBox( height: 43, child: Row( children: [ + Expanded( child: ListView.builder(scrollDirection: Axis.horizontal, - itemCount: widget.complaints.length + 1, + itemCount: widget.complaints.length, itemBuilder: (context, index) { - if (index == widget.complaints.length) { - return SizedBox( - width: MediaQuery - .sizeOf(context) - .width, - child: TextField( - decoration: InputDecoration.collapsed( - hintText: '', - ), - onChanged: (value) { - },), - ); - } else { return ComplaintItems( complaint: widget.complaints[index], onCrossClicked: (complaints) {}); - } - }), + }) + // }), ), ], ), diff --git a/lib/screens/patients/profile/soap_update_vida_plus/subjective/chief_complaint/widgets/complaint_items.dart b/lib/screens/patients/profile/soap_update_vida_plus/subjective/chief_complaint/widgets/complaint_items.dart index ff6a513a..814769de 100644 --- a/lib/screens/patients/profile/soap_update_vida_plus/subjective/chief_complaint/widgets/complaint_items.dart +++ b/lib/screens/patients/profile/soap_update_vida_plus/subjective/chief_complaint/widgets/complaint_items.dart @@ -10,38 +10,23 @@ class ComplaintItems extends StatelessWidget { @override Widget build(BuildContext context) { - return Padding( - padding: const EdgeInsets.all(8.0), - child: Material( - color: Color(0XAAA5A5A5), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(5),), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - SizedBox(width: 6,), - AppText( - complaint, - fontWeight: FontWeight.w400, - fontSize: 14, - color: Color(0xFF575757), - ), - SizedBox(width: 8,), - InkWell( - onTap: () { - onCrossClicked(complaint); - }, - child: Icon( - Icons.close, - size: 16, - color: Color(0xFFD02127), - ), - ), - SizedBox(width: 4,), - - ], - ), - ), - ); + return Container( + padding: const EdgeInsets.all(5.0), + width: 120, + height: 40, + alignment: Alignment.center, + decoration: BoxDecoration( + color: Color(0xffEAEAEA), + borderRadius: BorderRadius.circular( + 5, + )), + child: AppText( + textOverflow: TextOverflow.ellipsis, + complaint, + fontWeight: FontWeight.w400, + fontSize: 14, + color: Color(0xFF575757), + ), + ); } } diff --git a/lib/screens/patients/profile/soap_update_vida_plus/subjective/present_illness/update_present_illness.dart b/lib/screens/patients/profile/soap_update_vida_plus/subjective/present_illness/update_present_illness.dart index c40ec72b..a0333151 100644 --- a/lib/screens/patients/profile/soap_update_vida_plus/subjective/present_illness/update_present_illness.dart +++ b/lib/screens/patients/profile/soap_update_vida_plus/subjective/present_illness/update_present_illness.dart @@ -1,25 +1,48 @@ +import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/utils/dr_app_toast_msg.dart'; +import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; +import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; import 'package:flutter/material.dart'; -import '../../../../../../utils/translations_delegate_base_utils.dart'; -import '../../../../../../widgets/shared/app_texts_widget.dart'; -import '../../../../../../widgets/shared/text_fields/app-textfield-custom.dart'; class UpdatePresentIllness extends StatefulWidget { + PatiantInformtion? patientInfo; + UpdatePresentIllness(this.patientInfo, {Key? key}) : super(key: key); + @override - State createState() => _UpdatePresentIllnessState(); + State createState() => UpdatePresentIllnessState(); } -class _UpdatePresentIllnessState extends State { - bool isPatientSelected = false; +class UpdatePresentIllnessState extends State { + bool isPatientSelected = true; bool isFamilySelected = false; bool isOtherSelected = false; final TextEditingController familyController = TextEditingController(); final TextEditingController otherController = TextEditingController(); + final TextEditingController patientController = TextEditingController(); + @override + void initState() { + + super.initState(); + } @override Widget build(BuildContext context) { - return Column( + + return BaseView( + onModelReady: (model){ + WidgetsBinding.instance.addPostFrameCallback((_) { + getHopi(model); + }); + }, + builder: (_, model, w) => Column( + // key:UpdatePresentIllness.HopiKey, crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( @@ -36,7 +59,7 @@ class _UpdatePresentIllnessState extends State { ListTileTheme( horizontalTitleGap: 0, child: CheckboxListTile( - value: isPatientSelected, + value: this.isPatientSelected, activeColor: Color(0xFFD02127), checkColor: Colors.white, controlAffinity: ListTileControlAffinity.leading, @@ -174,27 +197,67 @@ class _UpdatePresentIllnessState extends State { height: 8, ), AppTextFieldCustom( + isTextFieldHasSuffix: true, hintText: TranslationBase.of(context).remarks, - controller: otherController, + controller: patientController, inputType: TextInputType.multiline, maxLines: 25, minLines: 3, hasBorder: true, onClick: () {}, - onChanged: (value) {}, - onFieldSubmitted: () {}, + onChanged: (value) { + print("On Field Changed.."); + }, + onFieldSubmitted: () { + print("---Submit....."); + }, + suffixIcon: IconButton(icon:Icon(Icons.save_as_outlined, color: Colors.red, size: 25,), onPressed: (){ + saveHopi(model); + },), ), SizedBox( height: 8, ), - AppText( - 'Last saved: 22-10-2024 08:07 am [3 hours ago]', - fontSize: 10, - fontWeight: FontWeight.normal, - textAlign: TextAlign.start, - color: Color(0XFF575757), - ), + + // AppText( + // 'Last saved: 22-10-2024 08:07 am [3 hours ago]', + // fontSize: 10, + // fontWeight: FontWeight.normal, + // textAlign: TextAlign.start, + // color: Color(0XFF575757), + // ), ], + ), + ); } + saveHopi(SOAPViewModel model) async{ + GifLoaderDialogUtils.showMyDialog(context); + if(patientController.text.isEmpty) { + DrAppToastMsg.showErrorToast("Please Enter Remarks"); + return; + } + Map request = { + "hpi": patientController.text, + "isHpiTakenPatient": isPatientSelected, + "isHpiTakenFamily": isFamilySelected, + "isHpiTakenOther": isOtherSelected, + "hpiTakenOtherText": otherController.text, + "hpiTakenFamilyText": familyController.text, + }; + await model!.saveHopi(request, widget.patientInfo!); + GifLoaderDialogUtils.hideDialog(context); + } + getHopi(SOAPViewModel model) async{ + await model!.getHopi(widget.patientInfo!); + setData(model); + } + setData(SOAPViewModel model){ + if(model.getHopiDetails.isNotEmpty) { + patientController.text = model.getHopiDetails[0].hpi!; + isOtherSelected = model.getHopiDetails[0].isHpiTakenOther!; + isFamilySelected = model.getHopiDetails[0].isHpiTakenFamily!; + isPatientSelected = model.getHopiDetails[0].isHpiTakenPatient!; + } + } } diff --git a/lib/screens/patients/profile/soap_update_vida_plus/subjective/update_subjective_page_vida_plus.dart b/lib/screens/patients/profile/soap_update_vida_plus/subjective/update_subjective_page_vida_plus.dart index 396c08ea..54b51c41 100644 --- a/lib/screens/patients/profile/soap_update_vida_plus/subjective/update_subjective_page_vida_plus.dart +++ b/lib/screens/patients/profile/soap_update_vida_plus/subjective/update_subjective_page_vida_plus.dart @@ -203,6 +203,7 @@ class _UpdateSubjectivePageVidaPlusState }, child: UpdateChiefComplaints( complaints: [], + patientInfo: widget.patientInfo, ), isExpanded: isChiefExpand, ), @@ -222,7 +223,7 @@ class _UpdateSubjectivePageVidaPlusState }); }, child: Column( - children: [UpdatePresentIllness()], + children: [UpdatePresentIllness(widget.patientInfo)], ), isExpanded: isHistoryExpand, ), @@ -245,6 +246,7 @@ class _UpdateSubjectivePageVidaPlusState children: [ UpdateAllergiesWidgetVidaPlus( myAllergiesList: myAllergiesList, + patientInfo: widget.patientInfo ), SizedBox( height: 30, @@ -321,11 +323,10 @@ class _UpdateSubjectivePageVidaPlusState } } - @override + Function nextFunction(model) { - // addSubjectiveInfo(model: model, - // // myAllergiesList: myAllergiesList.where((i) => i.isChecked).toList(), - // myHistoryList: myHistoryList); - return () {}; + //need to be implemented .. + return (){}; } + } diff --git a/lib/screens/patients/profile/soap_update_vida_plus/update_soap_index_vida_plus.dart b/lib/screens/patients/profile/soap_update_vida_plus/update_soap_index_vida_plus.dart index 1bcc942a..4608e1e0 100644 --- a/lib/screens/patients/profile/soap_update_vida_plus/update_soap_index_vida_plus.dart +++ b/lib/screens/patients/profile/soap_update_vida_plus/update_soap_index_vida_plus.dart @@ -32,7 +32,7 @@ class UpdateSoapIndexVidaPlus extends StatefulWidget { class _UpdateSoapIndexVidaPlusState extends State with TickerProviderStateMixin { PageController? _controller; - int _currentIndex = 2; + int _currentIndex = 0; List myAllergiesList = []; List myHistoryList = []; @@ -97,6 +97,18 @@ class _UpdateSoapIndexVidaPlusState extends State }, scrollDirection: Axis.horizontal, children: [ + + + UpdateSubjectivePageVidaPlus( + changePageViewIndex: changePageViewIndex, + currentIndex: _currentIndex, + patientInfo: patient, + changeLoadingState: changeLoadingState), + UpdateObjectivePageVidaPlus( + changePageViewIndex: changePageViewIndex, + currentIndex: _currentIndex, + patientInfo: patient, + changeLoadingState: changeLoadingState), UpdateAssessmentPage( changePageViewIndex: changePageViewIndex, currentIndex: _currentIndex, @@ -111,16 +123,6 @@ class _UpdateSoapIndexVidaPlusState extends State sOAPViewModel: model, changeStateFun: changeStateFun, ), - UpdateObjectivePageVidaPlus( - changePageViewIndex: changePageViewIndex, - currentIndex: _currentIndex, - patientInfo: patient, - changeLoadingState: changeLoadingState), - UpdateSubjectivePageVidaPlus( - changePageViewIndex: changePageViewIndex, - currentIndex: _currentIndex, - patientInfo: patient, - changeLoadingState: changeLoadingState), ], ), ) @@ -175,6 +177,7 @@ class _UpdateSoapIndexVidaPlusState extends State fontWeight: FontWeight.w600, color: Colors.red[700]!, onPressed: () async { + model.nextOnSubjectPage(model); }, ), diff --git a/lib/widgets/auth/sms-popup.dart b/lib/widgets/auth/sms-popup.dart index 049cc26e..87f341eb 100644 --- a/lib/widgets/auth/sms-popup.dart +++ b/lib/widgets/auth/sms-popup.dart @@ -344,7 +344,7 @@ class SMSOTP { } checkValue() async { - if (verifyAccountForm.currentState!.validate() && _token !=null) { + if (verifyAccountForm.currentState!.validate() ) { //&& _token !=null removed cloud flare for vida plus // if (digit1.text.isNotEmpty && digit2.text.isNotEmpty && digit3.text.isNotEmpty && digit4.text.isNotEmpty) { onSuccess(digit1.text.toString() + digit2.text.toString() + digit3.text.toString() + digit4.text.toString()); this.isClosed = true;