From 8f05d526f6c878b501f8b894978c33bc260db1e9 Mon Sep 17 00:00:00 2001 From: "taha.alam" Date: Thu, 12 Dec 2024 17:02:26 +0300 Subject: [PATCH] WD: Changes of apis and flows performed. 1. diagnosis restricted for operation after the resolution or deletion of diagnosis. 2. pomrid in episode api. --- lib/client/base_app_client.dart | 12 +- lib/config/config.dart | 2 +- .../soap/SOAP_service.dart | 150 +++++++++++------- lib/core/viewModel/SOAP_view_model.dart | 5 +- .../assessment/widget/current_diagnosis.dart | 21 +++ .../widgets/ComplaintSelection.dart | 2 + 6 files changed, 128 insertions(+), 64 deletions(-) diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index 6794d92d..cdf2db2d 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -8,6 +8,7 @@ import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/core/service/NavigationService.dart'; import 'package:doctor_app_flutter/core/viewModel/authentication_view_model.dart'; import 'package:doctor_app_flutter/utils/dr_app_shared_pref.dart'; +import 'package:doctor_app_flutter/utils/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/utils/exception_report.dart'; import 'package:doctor_app_flutter/utils/utils.dart'; import 'package:flutter/cupertino.dart'; @@ -165,8 +166,15 @@ class BaseAppClient { } else onSuccess(parsed, statusCode); } else { - if(body['DoctorID'] !=null ) - postFailureResponse(doctorId:body['DoctorID'], url:url , request: json.encode(body), response: response.body, exception: getError(parsed)); + if(body['DoctorID'] !=null ) { + + postFailureResponse( + doctorId: body['DoctorID'], + url: url, + request: json.encode(body), + response: response.body, + exception: getError(parsed)); + } onFailure(getError(parsed), statusCode); } } diff --git a/lib/config/config.dart b/lib/config/config.dart index fe7d9b43..2b86c78d 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -326,7 +326,7 @@ const FAVORITE_DIAGNOSIS = 'Services/DoctorApplication.svc/REST/DiagnosisGetFavo const ADD_TO_FAVORITE_DIAGNOSIS = 'Services/DoctorApplication.svc/REST/DiagnosisAddFavourite'; -const MAKE_PREVIOUS_AS_CURRENT_DIAGNOSIS = 'Services/DoctorApplication.svc/REST/ContinuePreviousEpisode'; +const MAKE_PREVIOUS_AS_CURRENT_DIAGNOSIS = 'Services/DoctorApplication.svc/REST/CreateDiagnosis'; const SEARCH_PHYSICAL_EXAMINATION = 'Services/DoctorApplication.svc/REST/SearchPhysicalExam'; 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 1c40631e..bd51681b 100644 --- a/lib/core/service/patient_medical_file/soap/SOAP_service.dart +++ b/lib/core/service/patient_medical_file/soap/SOAP_service.dart @@ -458,17 +458,16 @@ class SOAPService extends LookupService { }); } - Future addAllergies( - AllergiesListVidaPlus allergy, PatiantInformtion patientInfo, bool isNoKnown) async { - if(!isNoKnown){ - allergy.allergyReactionDTOs!.forEach((value) { - value.patientID = patientInfo.patientMRN; - value.pomrid = int.parse(patientInfo.pomrId!); - value.allergyReactionMappingID = 1; - value.severity = value.severity ?? 1; - }); - -} + Future addAllergies(AllergiesListVidaPlus allergy, + PatiantInformtion patientInfo, bool isNoKnown) async { + if (!isNoKnown) { + allergy.allergyReactionDTOs!.forEach((value) { + value.patientID = patientInfo.patientMRN; + value.pomrid = int.parse(patientInfo.pomrId!); + value.allergyReactionMappingID = 1; + value.severity = value.severity ?? 1; + }); + } var request = { "patientsAllergyRevisionID": allergy.allergyRevisionID, "patientMRN": patientInfo.patientMRN, @@ -490,15 +489,15 @@ class SOAPService extends LookupService { "allergyTypeID": allergy.allergyTypeID, }; - if(isNoKnown){ - request['isAllergy'] ='NO_KNOWN_ALLERGIES'; + if (isNoKnown) { + request['isAllergy'] = 'NO_KNOWN_ALLERGIES'; request['allergyName'] = "No Known Allergies"; - request['userType'] ='DOCTOR'; - request['allergyTypeID'] = request['allergyID'] = 0; + request['userType'] = 'DOCTOR'; + request['allergyTypeID'] = request['allergyID'] = 0; request['isActive'] = true; - request['remarks'] =""; - request['isActivePatientsAllergy'] =true; - request['patientsAllergyReactionsDTOs'] =[]; + request['remarks'] = ""; + request['isActivePatientsAllergy'] = true; + request['patientsAllergyReactionsDTOs'] = []; } hasError = false; @@ -688,10 +687,9 @@ class SOAPService extends LookupService { "pomrId": patient.pomrId, "patientMRN": patient.patientMRN, "chiefComplaint": cheifComplaint, - } ], - "setupId":await sharedPref.getString(DOCTOR_SETUP_ID) + "setupId": await sharedPref.getString(DOCTOR_SETUP_ID) }; hasError = false; await baseAppClient.post(POST_CHIEF_COMPLAINT_VP, @@ -737,13 +735,13 @@ class SOAPService extends LookupService { .forEach((v) => searchDiagnosisList.add(SearchDiagnosis.fromJson(v))); _processData(); }, onFailure: (String error, int statusCode) { - clearSearchResult(); + clearSearchResult(); hasError = true; super.error = error; }, body: request); } - clearSearchResult(){ + clearSearchResult() { searchDiagnosisList.clear(); icdVersionList.clear(); } @@ -865,7 +863,7 @@ class SOAPService extends LookupService { // "endRow": 10, // "isSelected": true, // "ProjectID": 313 - "hospitalGroupId": await sharedPref.getString(DOCTOR_SETUP_ID), + "hospitalGroupId": await sharedPref.getString(DOCTOR_SETUP_ID), "hospitalId": patient.projectId, "patientId": patient.patientId, "patientPomrId": patient.pomrId, @@ -1046,11 +1044,17 @@ class SOAPService extends LookupService { var result = response['ListDiagnosisAddFavourite']['resultData']; isFavoriteAdded = true; if ((result is List) && (result as List).isEmpty) { + if(response['ListDiagnosisAddFavourite']['message'] != null) DrAppToastMsg.showErrorToast( response['ListDiagnosisAddFavourite']['message']); + + else DrAppToastMsg.showErrorToast("Unable to Add"); } else { + if(response['ListDiagnosisAddFavourite']['message'] != null) DrAppToastMsg.showSuccesToast( response['ListDiagnosisAddFavourite']['message']); + else DrAppToastMsg.showErrorToast("Diagnosis Added To Favorite"); + } }, onFailure: (String error, int statusCode) { hasError = true; @@ -1061,33 +1065,45 @@ class SOAPService extends LookupService { return isFavoriteAdded; } - Future convertPreviousDiagnosisCurrent(PatiantInformtion paitientInfo, - PatientPreviousDiagnosis diagnosis) async { + Future convertPreviousDiagnosisCurrent( + PatiantInformtion patient, PatientPreviousDiagnosis diagnosis) async { + Map? user = await sharedPref.getObj(LOGGED_IN_USER); Map request = { - "patientProblemRevisionId": diagnosis.patientProblemRevisionId, - "patientId": paitientInfo.patientId, - "doctorId": paitientInfo.doctorId, - "pomrId": paitientInfo.pomrId, - "appointmentId": paitientInfo.appointmentNo, - "createdBy": diagnosis.createdBy, - "hospitalId": diagnosis.hospitalId, - "hospitalGroupId": diagnosis.hospitalGroupId, - "clinicGroupId": diagnosis.clinicGroupId, - "clinicId": diagnosis.clinicId, - "isSelected": true, - "ProjectID": paitientInfo.projectId + "pomrId": patient.pomrId, + "appointmentId": patient.appointmentNo, + "clinicGroupId": patient.clinicGroupId, + "clinicId": patient.clinicId, + "patientId": patient.patientId, + "hospitalId": patient.projectId, + "hospitalGroupId": await sharedPref.getString(DOCTOR_SETUP_ID), + "diagnosisType": diagnosis.diagnosisType, + "condition": diagnosis.condition, + "remarks": diagnosis.remarks, + "icdType": diagnosis.icdType, + // "icdVersion": searchDiagnosis.icdVersion, + "icdSubVersion": diagnosis.icdSubVersion, + "isNew": false, + "specificationId": diagnosis.problemId, + "selectedDisease": diagnosis.selectedDisease, + // "diseasesCode": diagnosis.visitWisePatientDiagnoses?.last.diseasesCode, + // "diseasesId": searchDiagnosis.diseasesId, + "selectedIcdCode": diagnosis.selectedIcdCode, + "selectedCategoryCode": diagnosis.selectedCategoryCode, + "selectedSectionCode": diagnosis.selectedSectionCode, + "selectedChapterCode": diagnosis.selectedChapterCode, + // "selectedNandaCode": diagnosis.selectedNandaCode, + "isResolved": false, + "doctorId": patient.doctorId, + "doctorCode": user?['List_MemberInformation'][0]['MemberID'], + "ProjectID": patient.projectId, + // "codeRange": searchDiagnosis.codeRange }; hasError = false; var success = false; await baseAppClient.post(MAKE_PREVIOUS_AS_CURRENT_DIAGNOSIS, onSuccess: (dynamic response, int statusCode) async { - var result = response['ContinuePreviousEpisode']['resultData']; - if ((result as List).isEmpty) { - DrAppToastMsg.showErrorToast( - response['ContinuePreviousEpisode']['message']); - } else { - success = true; - } + DrAppToastMsg.showSuccesToast(response['CreatDiagnosis']['message']); + success = true; }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; @@ -1163,12 +1179,12 @@ class SOAPService extends LookupService { "clinicGroupId": patient.clinicGroupId, "clinicId": patient.clinicId, "patientId": patient.patientId, - "hospitalId": searchDiagnosis!.hospitalId, - "hospitalGroupId": searchDiagnosis.hospitalGroupId, + "hospitalId": patient.projectId, + "hospitalGroupId": await sharedPref.getString(DOCTOR_SETUP_ID), "diagnosisType": diagnosisType, "condition": conditionType, "remarks": remarks, - "icdType": searchDiagnosis.icdType, + "icdType": searchDiagnosis!.icdType, // "icdVersion": searchDiagnosis.icdVersion, "icdSubVersion": searchDiagnosis.icdSubVersion, "isNew": isNew, @@ -1215,12 +1231,12 @@ class SOAPService extends LookupService { "clinicGroupId": patient.clinicGroupId, "clinicId": patient.clinicId, "patientId": patient.patientId, - "hospitalId": searchDiagnosis!.hospitalId, - "hospitalGroupId": searchDiagnosis.hospitalGroupId, + "hospitalId": patient.projectId, + "hospitalGroupId": await sharedPref.getString(DOCTOR_SETUP_ID), "diagnosisType": diagnosisType, "condition": conditionType, "remarks": remarks, - "icdType": searchDiagnosis.icdType, + "icdType": searchDiagnosis!.icdType, // "icdVersion": searchDiagnosis.icdVersion, "icdSubVersion": searchDiagnosis.icdSubVersion, "isNew": isNew, @@ -1253,8 +1269,12 @@ class SOAPService extends LookupService { return success; } - Future createProgressNote(PatiantInformtion patient, String? clinicID, - String conditionType, String note, ) async { + Future createProgressNote( + PatiantInformtion patient, + String? clinicID, + String conditionType, + String note, + ) async { Map request = { "planNote": note, "PatientMRN": patient.patientMRN, @@ -1326,6 +1346,14 @@ class SOAPService extends LookupService { success = true; return; } + if(response['ValidatinErrorsCSI']!= null){ + if(response['ValidatinErrorsCSI']['errors']!= null && (response['ValidatinErrorsCSI']['errors'] as List).isNotEmpty ){ + if(response['ValidatinErrorsCSI']['errors']['Validations']!= null && (response['ValidatinErrorsCSI']['errors']['Validations'] as List).isNotEmpty ) { + if((response['ValidatinErrorsCSI']['errors']['Validations'] as List).first!['Error'] != null ) + DrAppToastMsg.showErrorToast((response['ValidatinErrorsCSI']['errors']['Validations'] as List).first!['Error']); + + }} + } success = false; }, onFailure: (String error, int statusCode) { success = false; @@ -1358,8 +1386,9 @@ class SOAPService extends LookupService { var success = false; await baseAppClient.post(GET_PATIENT_CLINIC, onSuccess: (dynamic response, int statusCode) { - response['ListPatientConditionProgress']['resultData'].forEach((v) => v['PATIENT_CONDITION'].forEach( - (item) => patientConditionList.add(PatientCondition.fromJson(item)))); + response['ListPatientConditionProgress']['resultData'].forEach((v) => + v['PATIENT_CONDITION'].forEach((item) => + patientConditionList.add(PatientCondition.fromJson(item)))); success = false; }, onFailure: (String error, int statusCode) { success = false; @@ -1398,18 +1427,18 @@ class SOAPService extends LookupService { }, body: request); } - continueEpisodeVidaPlusFromPrevious( - PatiantInformtion patient, ChiefComplains chiefComplaint, String chiefComplainTemplateId) async { + continueEpisodeVidaPlusFromPrevious(PatiantInformtion patient, + ChiefComplains chiefComplaint, String chiefComplainTemplateId) async { List> chiefComplaintList = []; var listofComplain = { - chiefComplaint.chiefComplain :chiefComplainTemplateId + chiefComplaint.chiefComplain: chiefComplainTemplateId }; Map request = { "appointmentId": patient.appointmentNo, "projectId": patient.projectId, "setupId": await sharedPref.getString(DOCTOR_SETUP_ID), - "chiefComplain":listofComplain + "chiefComplain": listofComplain }; hasError = false; await baseAppClient.post(CONTINUE_EPISODE_VP, @@ -1430,7 +1459,7 @@ class SOAPService extends LookupService { "PatientName": patient.firstName! + ' ' + patient.lastName!, "addedChiefComplaintCreateDtos": [], "removedChiefComplaintIds": [chiefComplaint.chiefComplainId], - "setupId": await sharedPref.getString(DOCTOR_SETUP_ID), + "setupId": await sharedPref.getString(DOCTOR_SETUP_ID), }; hasError = false; await baseAppClient.post(UPDATE_CHIEF_COMPLAINT, @@ -1448,7 +1477,8 @@ class SOAPService extends LookupService { Map request = { "patientId": patient.patientId, "clinicId": patient.clinicId, - "setupId": await sharedPref.getString(DOCTOR_SETUP_ID), + "setupId": await sharedPref.getString(DOCTOR_SETUP_ID), + "pomrId":patient.pomrId }; hasError = false; await baseAppClient.post(EPISODE_BY_CHIEF_COMPLAINT, diff --git a/lib/core/viewModel/SOAP_view_model.dart b/lib/core/viewModel/SOAP_view_model.dart index 7a6baa46..46100664 100644 --- a/lib/core/viewModel/SOAP_view_model.dart +++ b/lib/core/viewModel/SOAP_view_model.dart @@ -1335,7 +1335,10 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.BusyLocal); var result = await _SOAPService.convertPreviousDiagnosisCurrent( paitientInfo, diagnosis); - if (result) await getPreviousPatientDetails(paitientInfo); + if (result) { + await getPreviousPatientDetails(paitientInfo); + await getCurrentDiagnosisList(paitientInfo); + } if (_SOAPService.hasError) { error = _SOAPService.error; setState(ViewState.ErrorLocal); diff --git a/lib/screens/patients/profile/soap_update_vida_plus/assessment/widget/current_diagnosis.dart b/lib/screens/patients/profile/soap_update_vida_plus/assessment/widget/current_diagnosis.dart index 59a171b8..8e04c292 100644 --- a/lib/screens/patients/profile/soap_update_vida_plus/assessment/widget/current_diagnosis.dart +++ b/lib/screens/patients/profile/soap_update_vida_plus/assessment/widget/current_diagnosis.dart @@ -110,6 +110,21 @@ class _CurrentDiagnosisState extends State { ''); break; case SoapDetailItemActions.EDIT: + if (widget.currentDiagnosisItems[index] + .status == + "Deleted") { + DrAppToastMsg.showErrorToast(TranslationBase.of(context).diagnosisAlreadyDeleted); + return; + } + + if (widget.currentDiagnosisItems[index] + .resolved == + true) { + DrAppToastMsg.showErrorToast( + TranslationBase.of(context) + .diagnosisAlreadyResolved); + } + bool result = await Navigator.push( context, FadePage( @@ -124,6 +139,12 @@ class _CurrentDiagnosisState extends State { } break; case SoapDetailItemActions.RESOLVE: + if (widget.currentDiagnosisItems[index] + .status == + "Deleted") { + DrAppToastMsg.showErrorToast(TranslationBase.of(context).diagnosisAlreadyDeleted); + return; + } if (widget.currentDiagnosisItems[index] .resolved == true) { 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 6c0a8690..871537d5 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 @@ -291,6 +291,7 @@ class _ComplaintSelectionState extends State { onPressed: () { if(searchController.text.isNotEmpty) { widget.onSave?.call(searchController.text); + searchController.text =''; } }): SizedBox.shrink(), ), @@ -298,6 +299,7 @@ class _ComplaintSelectionState extends State { onEditingComplete: (){ if(searchController.text.isNotEmpty) { widget.onSave?.call(searchController.text); + searchController.text =''; } }, )),