From 591b60b5b86492c2f1caebed359fd789d22d5e78 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Tue, 6 Feb 2024 13:53:42 +0530 Subject: [PATCH 01/18] enable hcx (#7176) --- public/config.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/config.json b/public/config.json index 9398e28c410..fdb18c8001e 100644 --- a/public/config.json +++ b/public/config.json @@ -21,5 +21,6 @@ "kasp_full_string": "Karunya Arogya Suraksha Padhathi", "sample_format_asset_import": "https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=11JaEhNHdyCHth4YQs_44YaRlP77Rrqe81VSEfg1glko&exportFormat=xlsx", "sample_format_external_result_import": "/External-Results-Template.csv", - "enable_abdm": true + "enable_abdm": true, + "enable_hcx": true } From 4a79ff252601d9ff21a6b1d91a7cf9bff85d7f0e Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Tue, 6 Feb 2024 14:07:14 +0530 Subject: [PATCH 02/18] revert hcx configuration (#7177) --- public/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/config.json b/public/config.json index fdb18c8001e..69d898af544 100644 --- a/public/config.json +++ b/public/config.json @@ -22,5 +22,5 @@ "sample_format_asset_import": "https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=11JaEhNHdyCHth4YQs_44YaRlP77Rrqe81VSEfg1glko&exportFormat=xlsx", "sample_format_external_result_import": "/External-Results-Template.csv", "enable_abdm": true, - "enable_hcx": true + "enable_hcx": false } From 24491373be15e465fa35166107b5989bdb85fb50 Mon Sep 17 00:00:00 2001 From: Onkar Jadhav <56870381+Omkar76@users.noreply.github.com> Date: Wed, 7 Feb 2024 01:02:59 +0530 Subject: [PATCH 03/18] Improve resolution images uploaded via camera (#7160) * Improve resolution of webcam images * replicate changes in cover image * revert: replicate changes in cover image --------- Co-authored-by: Ashesh <3626859+Ashesh3@users.noreply.github.com> Co-authored-by: rithviknishad --- src/Components/Patient/FileUpload.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Components/Patient/FileUpload.tsx b/src/Components/Patient/FileUpload.tsx index d4b8b0387dc..77c67abeadd 100644 --- a/src/Components/Patient/FileUpload.tsx +++ b/src/Components/Patient/FileUpload.tsx @@ -172,8 +172,8 @@ export const FileUpload = (props: FileUploadProps) => { const [previewImage, setPreviewImage] = useState(null); const [facingMode, setFacingMode] = useState(FACING_MODE_USER); const videoConstraints = { - width: 1280, - height: 720, + width: { ideal: 4096 }, + height: { ideal: 2160 }, facingMode: "user", }; const { width } = useWindowDimensions(); @@ -1164,10 +1164,10 @@ export const FileUpload = (props: FileUploadProps) => { {!previewImage ? (
From eeb4359ceb96eebe52b2ebc36bd704a9c9384991 Mon Sep 17 00:00:00 2001 From: Ashesh <3626859+Ashesh3@users.noreply.github.com> Date: Wed, 7 Feb 2024 01:03:45 +0530 Subject: [PATCH 04/18] Show Facility Notify button for District/State Admins only (#7117) --- src/Components/Facility/FacilityCard.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Components/Facility/FacilityCard.tsx b/src/Components/Facility/FacilityCard.tsx index 1424a657de4..080e7992950 100644 --- a/src/Components/Facility/FacilityCard.tsx +++ b/src/Components/Facility/FacilityCard.tsx @@ -225,7 +225,7 @@ export const FacilityCard = (props: { facility: any; userType: any }) => {
- {userType !== "Staff" ? ( + {["DistrictAdmin", "StateAdmin"].includes(userType) && ( { Notify - ) : ( - <> )} Date: Tue, 6 Feb 2024 20:37:16 +0100 Subject: [PATCH 05/18] fix: disable add counsultations button (#7133) --- src/Components/Facility/ConsultationCard.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Components/Facility/ConsultationCard.tsx b/src/Components/Facility/ConsultationCard.tsx index c402853f366..1c6ec77afde 100644 --- a/src/Components/Facility/ConsultationCard.tsx +++ b/src/Components/Facility/ConsultationCard.tsx @@ -163,6 +163,7 @@ export const ConsultationCard = (props: ConsultationProps) => { `/facility/${itemData.facility}/patient/${itemData.patient}/consultation/${itemData.id}/daily-rounds` ) } + disabled={itemData.discharge_date} authorizeFor={NonReadOnlyUsers} > Add Consultation Updates From f70b827ad8e9329501c0dcb2ff866813b81ce018 Mon Sep 17 00:00:00 2001 From: Ashraf Mohammed <98876115+AshrafMd-1@users.noreply.github.com> Date: Wed, 7 Feb 2024 01:07:37 +0530 Subject: [PATCH 06/18] Redesign the facility card image to 1:1 (#7137) * redesign the facility card * add rounded corners for images --- src/Components/Facility/FacilityCard.tsx | 166 ++++++++++++----------- 1 file changed, 84 insertions(+), 82 deletions(-) diff --git a/src/Components/Facility/FacilityCard.tsx b/src/Components/Facility/FacilityCard.tsx index 080e7992950..8e8dd6da601 100644 --- a/src/Components/Facility/FacilityCard.tsx +++ b/src/Components/Facility/FacilityCard.tsx @@ -49,24 +49,10 @@ export const FacilityCard = (props: { facility: any; userType: any }) => {
- - {(facility.read_cover_image_url && ( - {facility.name} - )) || ( - - )} -
{(facility.read_cover_image_url && ( {
-
- {facility.kasp_empanelled && ( -
- {kasp_string} -
- )} -
+ - - {facility.name} - - - - View CNS - -
-
- - {facility.features?.map( - (feature: number) => - FACILITY_FEATURE_TYPES.some( - (f) => f.id === feature - ) && ( - f.id === feature - )[0]?.name - } - size="small" - startIcon={ - FACILITY_FEATURE_TYPES.filter( - (f) => f.id === feature - )[0]?.icon - } - /> - ) + {(facility.read_cover_image_url && ( + {facility.name} + )) || ( + )} -
+ +
+ {facility.kasp_empanelled && ( +
+ {kasp_string} +
+ )} +
+ + {facility.name} + + + + View CNS + +
+
+ + {facility.features?.map( + (feature: number) => + FACILITY_FEATURE_TYPES.some( + (f) => f.id === feature + ) && ( + f.id === feature + )[0]?.name + } + size="small" + startIcon={ + FACILITY_FEATURE_TYPES.filter( + (f) => f.id === feature + )[0]?.icon + } + /> + ) + )} +
-
From db35822a6d30a7c9af85fea0f55083a110729226 Mon Sep 17 00:00:00 2001 From: Gampa Sri Harsh <114745442+sriharsh05@users.noreply.github.com> Date: Wed, 7 Feb 2024 01:07:55 +0530 Subject: [PATCH 07/18] Add max validation for doctor experience years in add user form (#7161) * Add validation for doctor experience * add auto scroll function to error * add max validation for doctor experience in user profile page --- src/Components/Users/UserAdd.tsx | 18 +++++++++++++++++- src/Components/Users/UserProfile.tsx | 13 ++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/Components/Users/UserAdd.tsx b/src/Components/Users/UserAdd.tsx index 2c5319e67f3..b3fc9b830f8 100644 --- a/src/Components/Users/UserAdd.tsx +++ b/src/Components/Users/UserAdd.tsx @@ -19,6 +19,7 @@ import { classNames, dateQueryString, parsePhoneNumber, + scrollTo, } from "../../Utils/utils"; import { Cancel, Submit } from "../Common/components/ButtonV2"; import PhoneNumberFormField from "../Form/FormFields/PhoneNumberFormField"; @@ -357,8 +358,19 @@ export const UserAdd = (props: UserProps) => { invalidForm = true; } return; - case "doctor_qualification": case "doctor_experience_commenced_on": + if (state.form.user_type === "Doctor" && !state.form[field]) { + errors[field] = "Field is required"; + invalidForm = true; + } else if ( + state.form.user_type === "Doctor" && + Number(state.form.doctor_experience_commenced_on) > 100 + ) { + errors[field] = "Doctor experience should be less than 100 years"; + invalidForm = true; + } + return; + case "doctor_qualification": case "doctor_medical_council_registration": if (state.form.user_type === "Doctor" && !state.form[field]) { errors[field] = "Field is required"; @@ -491,6 +503,10 @@ export const UserAdd = (props: UserProps) => { }); if (invalidForm) { dispatch({ type: "set_errors", errors }); + const firstError = Object.keys(errors).find((e) => errors[e]); + if (firstError) { + scrollTo(firstError); + } return false; } dispatch({ type: "set_errors", errors }); diff --git a/src/Components/Users/UserProfile.tsx b/src/Components/Users/UserProfile.tsx index 170de558e41..767fc9b73b8 100644 --- a/src/Components/Users/UserProfile.tsx +++ b/src/Components/Users/UserProfile.tsx @@ -244,8 +244,19 @@ export default function UserProfile() { invalidForm = true; } return; - case "doctor_qualification": case "doctor_experience_commenced_on": + if (states.form.user_type === "Doctor" && !states.form[field]) { + errors[field] = "Field is required"; + invalidForm = true; + } else if ( + states.form.user_type === "Doctor" && + Number(states.form.doctor_experience_commenced_on) > 100 + ) { + errors[field] = "Doctor experience should be less than 100 years"; + invalidForm = true; + } + return; + case "doctor_qualification": case "doctor_medical_council_registration": if (states.form.user_type === "Doctor" && !states.form[field]) { errors[field] = "Field is required"; From 1773a15a5c5aa85b522f41727a1bacb7eb60b739 Mon Sep 17 00:00:00 2001 From: Gampa Sri Harsh <114745442+sriharsh05@users.noreply.github.com> Date: Wed, 7 Feb 2024 01:08:13 +0530 Subject: [PATCH 08/18] Replaced useDispatch with useQuery/request in Treatment Summary and Transfer Patient. (#7084) * replace useDispatch with useQuery/request in TreatmentSummary page * replace useDispatch with useQuery/request in TransferPatientDialog * remove unused fire request --------- Co-authored-by: Rithvik Nishad --- .../Facility/TransferPatientDialog.tsx | 27 +- src/Components/Facility/TreatmentSummary.tsx | 622 ++++++++---------- src/Components/Facility/models.tsx | 7 + src/Redux/actions.tsx | 4 +- src/Redux/api.tsx | 4 + 5 files changed, 302 insertions(+), 362 deletions(-) diff --git a/src/Components/Facility/TransferPatientDialog.tsx b/src/Components/Facility/TransferPatientDialog.tsx index 259d497f684..4c38965c235 100644 --- a/src/Components/Facility/TransferPatientDialog.tsx +++ b/src/Components/Facility/TransferPatientDialog.tsx @@ -9,10 +9,10 @@ import { FieldLabel } from "../Form/FormFields/FormField"; import { OptionsType } from "../../Common/constants"; import { SelectFormField } from "../Form/FormFields/SelectFormField"; import { navigate } from "raviger"; -import { transferPatient } from "../../Redux/actions"; -import { useDispatch } from "react-redux"; import { dateQueryString } from "../../Utils/utils.js"; import dayjs from "dayjs"; +import request from "../../Utils/request/request.js"; +import routes from "../../Redux/api.js"; interface Props { patientList: Array; @@ -60,7 +60,6 @@ const patientFormReducer = (state = initialState, action: any) => { const TransferPatientDialog = (props: Props) => { const { patientList, handleOk, handleCancel, facilityId } = props; - const dispatchAction: any = useDispatch(); const [isLoading, setIsLoading] = useState(false); const [state, dispatch] = useReducer(patientFormReducer, initialState); const patientOptions: Array = patientList.map((patient) => { @@ -114,15 +113,17 @@ const TransferPatientDialog = (props: Props) => { const validForm = validateForm(); if (validForm) { setIsLoading(true); - const data = { - date_of_birth: dateQueryString(state.form.date_of_birth), - facility: facilityId, - }; - const res = await dispatchAction( - transferPatient(data, { id: state.form.patient }) - ); + const { res, data } = await request(routes.transferPatient, { + body: { + facility: facilityId, + date_of_birth: dateQueryString(state.form.date_of_birth), + }, + pathParams: { + id: state.form.patient, + }, + }); setIsLoading(false); - if (res && res.data && res.status === 200) { + if (res?.ok && data) { dispatch({ type: "set_form", form: initForm }); handleOk(); @@ -132,10 +133,10 @@ const TransferPatientDialog = (props: Props) => { msg: `Patient ${patientName} transferred successfully`, }); const newFacilityId = - res.data && res.data.facility_object && res.data.facility_object.id; + data && data.facility_object && data.facility_object.id; if (newFacilityId) { navigate( - `/facility/${newFacilityId}/patient/${res.data.patient}/consultation` + `/facility/${newFacilityId}/patient/${data.patient}/consultation` ); } else { navigate("/facility"); diff --git a/src/Components/Facility/TreatmentSummary.tsx b/src/Components/Facility/TreatmentSummary.tsx index f41f540a12d..b6caebc750e 100644 --- a/src/Components/Facility/TreatmentSummary.tsx +++ b/src/Components/Facility/TreatmentSummary.tsx @@ -1,402 +1,332 @@ -import { lazy, useCallback, useState } from "react"; -import { useDispatch } from "react-redux"; -import { - getPatient, - getInvestigation, - getConsultation, -} from "../../Redux/actions"; -import { ConsultationModel } from "./models"; -import { statusType, useAbortableEffect } from "../../Common/utils"; -import { PatientModel } from "../Patient/models"; - import { GENDER_TYPES } from "../../Common/constants"; import { formatAge, formatDate, formatDateTime } from "../../Utils/utils"; import useSlug from "../../Common/hooks/useSlug"; import useAppHistory from "../../Common/hooks/useAppHistory"; - -const Loading = lazy(() => import("../Common/Loading")); +import routes from "../../Redux/api"; +import useQuery from "../../Utils/request/useQuery"; const TreatmentSummary = (props: any) => { const { consultationId, patientId } = props; const date = new Date(); - const dispatch: any = useDispatch(); - const [patientData, setPatientData] = useState({}); - const [consultationData, setConsultationData] = useState( - {} - ); - const [isLoading, setIsLoading] = useState(false); - const [investigations, setInvestigations] = useState>([]); - const [dailyRounds, setDailyRounds] = useState({}); const facilityId = useSlug("facility"); const { goBack } = useAppHistory(); const url = `/facility/${facilityId}/patient/${patientId}/consultation/${consultationId}`; - const fetchPatientData = useCallback( - async (status: statusType) => { - setIsLoading(true); - const res = await dispatch(getPatient({ id: patientId })); - if (!status.aborted) { - if (res?.data) { - setPatientData(res.data); - } else { - setPatientData({}); - } - } - setIsLoading(false); - }, - [patientId, dispatch] - ); - - const fetchInvestigationData = useCallback( - async (status: statusType) => { - setIsLoading(true); - const res = await dispatch(getInvestigation({}, consultationId)); - - if (!status.aborted) { - if (res?.data?.results) { - const valueMap = res.data.results.reduce( - (acc: any, cur: { id: any }) => ({ ...acc, [cur.id]: cur }), - {} - ); - setInvestigations(valueMap); - } else { - setInvestigations([]); - } - } - setIsLoading(false); - }, - [consultationId, dispatch] - ); - - const fetchConsultation = useCallback( - async (status: statusType) => { - setIsLoading(true); - const [res] = await Promise.all([ - dispatch(getConsultation(consultationId)), - ]); - if (!status.aborted) { - if (res?.data) { - setConsultationData(res.data); - if (res.data.last_daily_round) { - setDailyRounds(res.data.last_daily_round); - } - } else { - setConsultationData({}); - } - } - setIsLoading(false); - }, - [consultationId, dispatch] - ); + const { data: patientData } = useQuery(routes.getPatient, { + pathParams: { id: patientId }, + prefetch: patientId !== undefined, + }); - useAbortableEffect((status: statusType) => { - fetchPatientData(status); - fetchInvestigationData(status); + const { data: investigations } = useQuery(routes.getInvestigation, { + pathParams: { consultation_external_id: consultationId }, + prefetch: consultationId !== undefined, + }); - fetchConsultation(status); - }, []); + const { data: consultationData } = useQuery(routes.getConsultation, { + pathParams: { id: consultationId }, + prefetch: consultationId !== undefined, + }); return (
- {isLoading ? ( - - ) : ( -
-
- - -
+
+
+ + +
+ +
+

+ {consultationData?.facility_name ?? ""} +

-
-

- {consultationData.facility_name} -

+

INTERIM TREATMENT SUMMARY

-

INTERIM TREATMENT SUMMARY

+
{formatDate(date)}
-
{formatDate(date)}
+
+
+
+ Name : {patientData?.name ?? ""} +
+
+ Address : {patientData?.address ?? ""} +
+
-
-
+
+
- Name : {patientData.name} + Age :{" "} + {formatAge( + patientData?.age ?? 0, + patientData?.date_of_birth ?? "", + true + )}
-
- Address : {patientData.address} +
+ OP : {consultationData?.patient_no ?? ""}
-
-
-
- Age :{" "} - {formatAge( - patientData.age, - patientData.date_of_birth, - true - )} -
-
- OP : {consultationData.patient_no} -
-
- -
- Date of admission : - - {consultationData.admitted - ? formatDateTime(consultationData.encounter_date) - : " --/--/----"} - -
+
+ Date of admission : + + {consultationData?.admitted + ? formatDateTime(consultationData.encounter_date) + : " --/--/----"} +
+
-
-
- Gender : - {GENDER_TYPES.find((i) => i.id === patientData.gender)?.text} -
+
+
+ Gender : + {GENDER_TYPES.find((i) => i.id === patientData?.gender)?.text} +
-
- Contact person : - - {" "} - {patientData.emergency_phone_number - ? patientData.emergency_phone_number - : " -"} - -
+
+ Contact person : + + {" "} + {patientData?.emergency_phone_number + ? patientData.emergency_phone_number + : " -"} +
+
-
- Comorbidities : -
- - +
+ Comorbidities : +
+
+ + + + + + + + {patientData?.medical_history && + patientData.medical_history.length > 0 ? ( + patientData.medical_history.map( + (obj: any, index: number) => { + return ( + + + + + ); + } + ) + ) : ( - - + + - - - {patientData.medical_history && - patientData.medical_history.length > 0 ? ( - patientData.medical_history.map( - (obj: any, index: number) => { - return ( - - - - - ); - } - ) - ) : ( - - - - - )} - -
DiseaseDetails
+ {obj["disease"]} + + {obj["details"] ? obj["details"] : "---"} +
DiseaseDetails + --- + + --- +
- {obj["disease"]} - - {obj["details"] ? obj["details"] : "---"} -
- --- - - --- -
-
+ )} + +
+
-
- Diagnosis : -
-
- History of present illness : - {consultationData.history_of_present_illness - ? consultationData.history_of_present_illness - : " ---"} -
+
+ Diagnosis : +
+
+ History of present illness : + {consultationData?.history_of_present_illness + ? consultationData.history_of_present_illness + : " ---"} +
-
- Examination details and clinical conditions : - {consultationData.examination_details - ? consultationData.examination_details - : " ---"} -
+
+ Examination details and clinical conditions : + {consultationData?.examination_details + ? consultationData.examination_details + : " ---"} +
-
- Physical Examination info : - {dailyRounds.physical_examination_info - ? dailyRounds.physical_examination_info - : " ---"} -
+
+ Physical Examination info : + {consultationData?.last_daily_round?.physical_examination_info + ? consultationData.last_daily_round + ?.physical_examination_info + : " ---"}
+
-
- General Instructions : - {patientData?.last_consultation?.consultation_notes ? ( -
- {patientData.last_consultation.consultation_notes} -
- ) : ( - " ---" - )} -
+
+ General Instructions : + {patientData?.last_consultation?.consultation_notes ? ( +
+ {patientData.last_consultation.consultation_notes} +
+ ) : ( + " ---" + )} +
+ +
+ Relevant investigations : -
- Relevant investigations : +
+ + + + + + + + + + + -
-
+ Date + + Name + + Result + + Ideal value + + values range + + unit +
- + + {investigations && investigations.results.length > 0 ? ( + investigations.results.map( + (value: any, index: number) => { + return ( + + + + + + + + + ); + } + ) + ) : ( - - - - - - + + + + + + - - - - {Object.values(investigations).length > 0 ? ( - Object.values(investigations).map( - (value: any, index: number) => { - return ( - - - - - - - - - ); - } - ) - ) : ( - - - - - - - - - )} - -
+ {formatDate( + value["session_object"][ + "session_created_date" + ] + )} + + {value["investigation_object"]["name"]} + + {value["notes"] || value["value"]} + + {value["investigation_object"]["ideal_value"] || + "-"} + + {value["investigation_object"]["min_value"]} -{" "} + {value["investigation_object"]["max_value"]} + + {value["investigation_object"]["unit"] || "-"} +
- Date - - Name - - Result - - Ideal value - - values range - - unit - + --- + + --- + + --- + + --- + + --- + + --- +
- {formatDate( - value["session_object"][ - "session_created_date" - ] - )} - - {value["investigation_object"]["name"]} - - {value["notes"] || value["value"]} - - {value["investigation_object"][ - "ideal_value" - ] || "-"} - - {value["investigation_object"]["min_value"]} -{" "} - {value["investigation_object"]["max_value"]} - - {value["investigation_object"]["unit"] || "-"} -
- --- - - --- - - --- - - --- - - --- - - --- -
-
+ )} + +
+
-
- Treatment : - {consultationData.treatment_plan ? ( -

{consultationData.treatment_plan}

- ) : ( -

---

- )} - Treatment summary/Treament Plan : +
+ Treatment : + {consultationData?.treatment_plan ? ( +

{consultationData.treatment_plan}

+ ) : ( +

---

+ )} + Treatment summary/Treament Plan : -
- - +
+
+ + + + + + + + + + {consultationData?.last_daily_round ? ( - - - + + + - - - - {dailyRounds ? ( - - - - - - ) : ( - - - - - - )} - -
DateSpo2Temperature
DateSpo2Temperature + {formatDateTime( + consultationData.last_daily_round.modified_date + )} + + {consultationData.last_daily_round.ventilator_spo2 || + "-"} + + {consultationData.last_daily_round.temperature || "-"} +
- {formatDateTime(dailyRounds.modified_date)} - - {dailyRounds.ventilator_spo2 || "-"} - - {dailyRounds.temperature || "-"} -
- --- - - --- - - --- -
-
+ ) : ( + + + --- + + + --- + + + --- + + + )} + +
- )} +
); }; diff --git a/src/Components/Facility/models.tsx b/src/Components/Facility/models.tsx index 999c54a2e3a..de035f9ffea 100644 --- a/src/Components/Facility/models.tsx +++ b/src/Components/Facility/models.tsx @@ -572,3 +572,10 @@ export type InventoryLogResponse = InventorySummaryResponse & { unit: number; created_by: number; }; + +export type PatientTransferResponse = { + id: string; + patient: string; + date_of_birth: string; + facility_object: BaseFacilityModel; +}; diff --git a/src/Redux/actions.tsx b/src/Redux/actions.tsx index 8e3ae382547..280abbce5cc 100644 --- a/src/Redux/actions.tsx +++ b/src/Redux/actions.tsx @@ -102,9 +102,7 @@ export const updatePatient = (params: object, pathParam: object) => { export const patchPatient = (params: object, pathParam: object) => { return fireRequest("patchPatient", [], params, pathParam); }; -export const transferPatient = (params: object, pathParam: object) => { - return fireRequest("transferPatient", [], params, pathParam); -}; + export const getStates = () => { return fireRequest("statesList", []); }; diff --git a/src/Redux/api.tsx b/src/Redux/api.tsx index 6425ff8eab0..eed17ad3b4b 100644 --- a/src/Redux/api.tsx +++ b/src/Redux/api.tsx @@ -55,6 +55,7 @@ import { InventorySummaryResponse, InventoryLogResponse, InventoryItemsModel, + PatientTransferResponse, } from "../Components/Facility/models"; import { IDeleteBedCapacity, @@ -86,6 +87,7 @@ import { InvestigationGroup, InvestigationType, } from "../Components/Facility/Investigations"; +import { Investigation } from "../Components/Facility/Investigations/Reports/types"; import { ICD11DiagnosisModel } from "../Components/Diagnosis/types"; /** @@ -657,6 +659,7 @@ const routes = { transferPatient: { path: "/api/v1/patient/{id}/transfer/", method: "POST", + TRes: Type(), }, getPatientNotes: { path: "/api/v1/patient/{patientId}/notes/", @@ -998,6 +1001,7 @@ const routes = { getInvestigation: { path: "/api/v1/consultation/{consultation_external_id}/investigation/", method: "GET", + TRes: Type>(), }, getPatientInvestigation: { path: "/api/v1/patient/{patient_external_id}/investigation/", From 1dd0ada4312dd3c4d443e6907c2e239dfa39b84b Mon Sep 17 00:00:00 2001 From: Kshitij Verma <101321276+kshitijv256@users.noreply.github.com> Date: Wed, 7 Feb 2024 01:08:37 +0530 Subject: [PATCH 09/18] only loading discontinued prescriptions instead of all prescriptions (#7071) * only loading discontinued prescriptions instead of all prescriptions * removed useEffect hook --- .../MedicineAdministrationSheet/index.tsx | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Components/Medicine/MedicineAdministrationSheet/index.tsx b/src/Components/Medicine/MedicineAdministrationSheet/index.tsx index e94d740c0db..dba0943db20 100644 --- a/src/Components/Medicine/MedicineAdministrationSheet/index.tsx +++ b/src/Components/Medicine/MedicineAdministrationSheet/index.tsx @@ -33,7 +33,7 @@ const MedicineAdministrationSheet = ({ readonly, is_prn }: Props) => { MedicineRoutes.listPrescriptions, { pathParams: { consultation }, - query: { ...filters, discontinued: showDiscontinued ? undefined : false }, + query: { ...filters, discontinued: false }, } ); @@ -41,7 +41,7 @@ const MedicineAdministrationSheet = ({ readonly, is_prn }: Props) => { pathParams: { consultation }, query: { ...filters, - limit: showDiscontinued ? 100 : 1, + limit: 100, discontinued: true, }, prefetch: !showDiscontinued, @@ -49,16 +49,21 @@ const MedicineAdministrationSheet = ({ readonly, is_prn }: Props) => { const discontinuedCount = discontinuedPrescriptions.data?.count; + const prescriptionList = [ + ...(data?.results ?? []), + ...(showDiscontinued ? discontinuedPrescriptions.data?.results ?? [] : []), + ]; + const { activityTimelineBounds, prescriptions } = useMemo( () => ({ - prescriptions: data?.results?.sort( + prescriptions: prescriptionList.sort( (a, b) => +a.discontinued - +b.discontinued ), - activityTimelineBounds: data - ? computeActivityBounds(data.results) + activityTimelineBounds: prescriptionList + ? computeActivityBounds(prescriptionList) : undefined, }), - [data] + [prescriptionList] ); const daysPerPage = useBreakpoints({ default: 1, "2xl": 2 }); From e9f3cc5c1dc6e9447eead50e0d006c6ced231673 Mon Sep 17 00:00:00 2001 From: Ashesh <3626859+Ashesh3@users.noreply.github.com> Date: Wed, 7 Feb 2024 11:13:26 +0530 Subject: [PATCH 10/18] Redesign Patient Info Card (#7077) * Redesign Patient Info Card * Responsive view * Fix null reference exception in LegacyDiagnosesList.tsx * Fix Cypress * Update click selector for "Edit Consultation Details" button * Remove unnecessary center alignment in PatientInfoCard * Refactor LegacyDiagnosesList component and remove unused imports * Redesign diagnosis list * Refactor to use tailwind classes * Make hide diagnoses less intrusive * Add "Manage Patient" button click in clickEditConsultationButton method --- .../pageobject/Patient/PatientConsultation.ts | 1 + .../Common/RelativeDateUserMention.tsx | 5 +- .../Common/components/AccordionV2.tsx | 12 +- .../Diagnosis/DiagnosesListAccordion.tsx | 102 ++++ .../Diagnosis/LegacyDiagnosesList.tsx | 87 ---- .../ConsultationUpdatesTab.tsx | 107 ++-- .../Facility/ConsultationDetails/index.tsx | 87 +--- .../Facility/Consultations/Mews.tsx | 66 ++- src/Components/Patient/PatientInfoCard.tsx | 490 ++++++++++-------- src/Utils/utils.ts | 6 +- 10 files changed, 508 insertions(+), 455 deletions(-) create mode 100644 src/Components/Diagnosis/DiagnosesListAccordion.tsx delete mode 100644 src/Components/Diagnosis/LegacyDiagnosesList.tsx diff --git a/cypress/pageobject/Patient/PatientConsultation.ts b/cypress/pageobject/Patient/PatientConsultation.ts index 76724d85017..bc2e8f330a3 100644 --- a/cypress/pageobject/Patient/PatientConsultation.ts +++ b/cypress/pageobject/Patient/PatientConsultation.ts @@ -151,6 +151,7 @@ export class PatientConsultationPage { clickEditConsultationButton() { cy.get("#consultation-buttons").scrollIntoView(); + cy.get("button").contains("Manage Patient").click(); cy.get("#consultation-buttons") .contains("Edit Consultation Details") .click(); diff --git a/src/Components/Common/RelativeDateUserMention.tsx b/src/Components/Common/RelativeDateUserMention.tsx index 18fb431574f..6c5a78c7f09 100644 --- a/src/Components/Common/RelativeDateUserMention.tsx +++ b/src/Components/Common/RelativeDateUserMention.tsx @@ -6,6 +6,7 @@ function RelativeDateUserMention(props: { actionDate?: string; user?: PerformedByModel; tooltipPosition?: "top" | "bottom" | "left" | "right"; + withoutSuffix?: boolean; }) { return (
@@ -15,7 +16,9 @@ function RelativeDateUserMention(props: { > {props.actionDate ? formatDateTime(props.actionDate) : "--:--"} - {props.actionDate ? relativeDate(props.actionDate) : "--:--"} + {props.actionDate + ? relativeDate(props.actionDate, props.withoutSuffix ?? false) + : "--:--"}
{props.user && (
diff --git a/src/Components/Common/components/AccordionV2.tsx b/src/Components/Common/components/AccordionV2.tsx index ef4948d8ae3..b8fa441d277 100644 --- a/src/Components/Common/components/AccordionV2.tsx +++ b/src/Components/Common/components/AccordionV2.tsx @@ -1,5 +1,4 @@ import { useRef, useState } from "react"; -import { classNames } from "../../../Utils/utils"; export default function AccordionV2(props: { children: JSX.Element | JSX.Element[]; @@ -55,15 +54,10 @@ export default function AccordionV2(props: {
{props.children}
diff --git a/src/Components/Diagnosis/DiagnosesListAccordion.tsx b/src/Components/Diagnosis/DiagnosesListAccordion.tsx new file mode 100644 index 00000000000..5f339cabc16 --- /dev/null +++ b/src/Components/Diagnosis/DiagnosesListAccordion.tsx @@ -0,0 +1,102 @@ +import { + ActiveConditionVerificationStatuses, + ConditionVerificationStatus, + ConsultationDiagnosis, +} from "./types"; +import { useTranslation } from "react-i18next"; +import { compareBy } from "../../Utils/utils"; +import { useState } from "react"; +import CareIcon from "../../CAREUI/icons/CareIcon"; +import ButtonV2 from "../Common/components/ButtonV2"; + +interface Props { + diagnoses: ConsultationDiagnosis[]; +} + +type GroupedDiagnoses = Record< + ConditionVerificationStatus, + ConsultationDiagnosis[] +>; + +function groupDiagnoses(diagnoses: ConsultationDiagnosis[]) { + const groupedDiagnoses = {} as GroupedDiagnoses; + + for (const status of ActiveConditionVerificationStatuses) { + groupedDiagnoses[status] = diagnoses + .filter((d) => d.verification_status === status) + .sort(compareBy("is_principal")); + } + + return groupedDiagnoses; +} + +export default function DiagnosesListAccordion(props: Props) { + const [isVisible, setIsVisible] = useState(true); + const diagnoses = groupDiagnoses(props.diagnoses); + + return ( +
+
+ {!isVisible && ( + { + setIsVisible((prev) => !prev); + }} + > + + Expand Diagnoses + + )} +
+
+

+ Diagnoses +

+
+ {Object.entries(diagnoses).map( + ([status, diagnoses]) => + !!diagnoses.length && ( + + ) + )} +
+ { + setIsVisible(false); + }} + > + + Hide Diagnoses + +
+
+ ); +} + +const DiagnosesOfStatus = ({ diagnoses }: Props) => { + const { t } = useTranslation(); + + return ( +
+

+ {t(diagnoses[0].verification_status)} {t("diagnoses")}{" "} + ({t("icd11_as_recommended")}) +

+
    + {diagnoses.map((diagnosis) => ( +
  • + {diagnosis.diagnosis_object?.label} +
  • + ))} +
+
+ ); +}; diff --git a/src/Components/Diagnosis/LegacyDiagnosesList.tsx b/src/Components/Diagnosis/LegacyDiagnosesList.tsx deleted file mode 100644 index 408bee7b52a..00000000000 --- a/src/Components/Diagnosis/LegacyDiagnosesList.tsx +++ /dev/null @@ -1,87 +0,0 @@ -import { useState } from "react"; -import { - ActiveConditionVerificationStatuses, - ConditionVerificationStatus, - ConsultationDiagnosis, -} from "./types"; -import { useTranslation } from "react-i18next"; -import CareIcon from "../../CAREUI/icons/CareIcon"; -import { compareBy } from "../../Utils/utils"; - -interface Props { - diagnoses: ConsultationDiagnosis[]; -} - -type GroupedDiagnoses = Record< - ConditionVerificationStatus, - ConsultationDiagnosis[] ->; - -function groupDiagnoses(diagnoses: ConsultationDiagnosis[]) { - const groupedDiagnoses = {} as GroupedDiagnoses; - - for (const status of ActiveConditionVerificationStatuses) { - groupedDiagnoses[status] = diagnoses - .filter((d) => d.verification_status === status) - .sort(compareBy("is_principal")); - } - - return groupedDiagnoses; -} - -export default function LegacyDiagnosesList(props: Props) { - const diagnoses = groupDiagnoses(props.diagnoses); - - return ( -
- {Object.entries(diagnoses).map( - ([status, diagnoses]) => - !!diagnoses.length && ( - - ) - )} -
- ); -} - -const DefaultShowLimit = 3; - -const DiagnosesOfStatus = ({ diagnoses }: Props) => { - const { t } = useTranslation(); - const [showMore, setShowMore] = useState(false); - - const queryset = showMore ? diagnoses : diagnoses.slice(0, DefaultShowLimit); - - return ( -
-

- {t(queryset[0].verification_status)} {t("diagnoses")}{" "} - ({t("icd11_as_recommended")}) -

-
    - {queryset.map((diagnosis) => ( -
  • - {diagnosis.diagnosis_object.label} - {diagnosis.is_principal && ( - - - {t("principal")} - - )} -
  • - ))} -
- - {diagnoses.length > DefaultShowLimit && ( - setShowMore(!showMore)} - className="cursor-pointer text-sm text-blue-600 hover:text-blue-300" - > - {showMore - ? t("hide") - : `... and ${diagnoses.length - queryset.length} more.`} - - )} -
- ); -}; diff --git a/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx b/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx index 4158d7f6609..323715ccfb0 100644 --- a/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx +++ b/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx @@ -342,7 +342,7 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => { from{" "} {formatDate( - props.consultationData.last_daily_round.created_at + props.consultationData.last_daily_round.taken_at )} @@ -602,58 +602,59 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => {
)} - -
-
-

- Body Details -

-
-
- Gender {" - "} - - {props.patientData.gender ?? "-"} - -
-
- Age {" - "} - - {props.patientData.age !== undefined // 0 is a valid age, so we need to check for undefined - ? formatAge( - props.patientData.age, - props.patientData.date_of_birth - ) - : "-"} - -
-
- Weight {" - "} - - {props.consultationData.weight ?? "-"} Kg - -
-
- Height {" - "} - - {props.consultationData.height ?? "-"} cm - -
-
- Body Surface Area {" - "} - - {Math.sqrt( - (Number(props.consultationData.weight) * - Number(props.consultationData.height)) / - 3600 - ).toFixed(2)}{" "} - m2 - -
-
- Blood Group {" - "} - - {props.patientData.blood_group ?? "-"} - +
+
+
+

+ Body Details +

+
+
+ Gender {" - "} + + {props.patientData.gender ?? "-"} + +
+
+ Age {" - "} + + {props.patientData.age !== undefined // 0 is a valid age, so we need to check for undefined + ? formatAge( + props.patientData.age, + props.patientData.date_of_birth + ) + : "-"} + +
+
+ Weight {" - "} + + {props.consultationData.weight ?? "-"} Kg + +
+
+ Height {" - "} + + {props.consultationData.height ?? "-"} cm + +
+
+ Body Surface Area {" - "} + + {Math.sqrt( + (Number(props.consultationData.weight) * + Number(props.consultationData.height)) / + 3600 + ).toFixed(2)}{" "} + m2 + +
+
+ Blood Group {" - "} + + {props.patientData.blood_group ?? "-"} + +
diff --git a/src/Components/Facility/ConsultationDetails/index.tsx b/src/Components/Facility/ConsultationDetails/index.tsx index c6cc9e02275..071e7bfc1af 100644 --- a/src/Components/Facility/ConsultationDetails/index.tsx +++ b/src/Components/Facility/ConsultationDetails/index.tsx @@ -15,7 +15,6 @@ import { statusType, useAbortableEffect } from "../../../Common/utils"; import { lazy, useCallback, useState } from "react"; import DoctorVideoSlideover from "../DoctorVideoSlideover"; import { make as Link } from "../../Common/components/Link.bs"; -import PatientInfoCard from "../../Patient/PatientInfoCard"; import { PatientModel } from "../../Patient/models"; import { formatDateTime, relativeTime } from "../../../Utils/utils"; @@ -37,8 +36,10 @@ import { ConsultationDialysisTab } from "./ConsultationDialysisTab"; import { ConsultationNeurologicalMonitoringTab } from "./ConsultationNeurologicalMonitoringTab"; import { ConsultationNutritionTab } from "./ConsultationNutritionTab"; import PatientNotesSlideover from "../PatientNotesSlideover"; -import LegacyDiagnosesList from "../../Diagnosis/LegacyDiagnosesList"; import { AssetBedModel } from "../../Assets/AssetTypes"; +import PatientInfoCard from "../../Patient/PatientInfoCard"; +import RelativeDateUserMention from "../../Common/RelativeDateUserMention"; +import DiagnosesListAccordion from "../../Diagnosis/DiagnosesListAccordion"; const Loading = lazy(() => import("../../Common/Loading")); const PageTitle = lazy(() => import("../../Common/PageTitle")); @@ -343,7 +344,7 @@ export const ConsultationDetails = (props: any) => { showAbhaProfile={qParams["show-abha-profile"] === "true"} /> -
+
{consultationData.admitted_to && (
@@ -374,71 +375,39 @@ export const ConsultationDetails = (props: any) => {
)}
- -
-
- {/*consultationData.other_symptoms && ( -
- - Other Symptoms:{" "} - - {consultationData.other_symptoms} -
- )*/} - - - - {(consultationData.treating_physician_object || - consultationData.deprecated_verified_by) && ( -
- - Treating Physician:{" "} - - {consultationData.treating_physician_object - ? `${consultationData.treating_physician_object.first_name} ${consultationData.treating_physician_object.last_name}` - : consultationData.deprecated_verified_by} - -
- )} -
-
-
+
-
- Created: - {consultationData.created_date - ? formatDateTime(consultationData.created_date) - : "--:--"}{" "} - | +
+ Created:   +
- {consultationData.created_by && ( -
- {` ${consultationData.created_by.first_name} ${consultationData.created_by.last_name} `} - {`@${consultationData.created_by.username} (${consultationData.created_by.user_type})`} -
- )}
-
- Last Modified: - {consultationData.modified_date - ? formatDateTime(consultationData.modified_date) - : "--:--"}{" "} - | +
+ Last Modified:   +
- {consultationData.last_edited_by && ( -
- {` ${consultationData.last_edited_by.first_name} ${consultationData.last_edited_by.last_name} `} - {`@${consultationData.last_edited_by.username} (${consultationData.last_edited_by.user_type})`} -
- )}
- +
+
+ +
+
diff --git a/src/Components/Facility/Consultations/Mews.tsx b/src/Components/Facility/Consultations/Mews.tsx index 14e7d7f9e63..8e109410958 100644 --- a/src/Components/Facility/Consultations/Mews.tsx +++ b/src/Components/Facility/Consultations/Mews.tsx @@ -1,6 +1,5 @@ import { DailyRoundsModel } from "../../Patient/models"; -import RecordMeta from "../../../CAREUI/display/RecordMeta"; -import { classNames } from "../../../Utils/utils"; +import { formatDateTime } from "../../../Utils/utils"; const getRespScore = (value?: number) => { if (typeof value !== "number") return; @@ -60,35 +59,45 @@ const getLOCRange = (value?: DailyRoundsModel["consciousness_level"]) => { }[value]; }; +const getBorderColor = (score: number) => { + if (score === undefined) return "border-gray-700"; + if (score <= 2) return "border-primary-500"; + if (score <= 3) return "border-yellow-300"; + if (score <= 5) return "border-warning-600"; + return "border-danger-500"; +}; + export const Mews = ({ dailyRound }: { dailyRound: DailyRoundsModel }) => { const mewsCard = (isMissing: boolean, data: string[] | number) => { if (isMissing) { return ( <> -
-

N/A

+
+
+ - +
+ MEWS
{(data as string[]).join(", ")}{" "} data is missing from the last log update. +
Last Updated: {formatDateTime(dailyRound.modified_date)}
-
- -
-
+
); } else { - const value = Number(data); return ( <> -
-

{data}

+
+
+ {data} +
+ MEWS

Resp. Rate: {dailyRound.resp} @@ -113,25 +122,10 @@ export const Mews = ({ dailyRound }: { dailyRound: DailyRoundsModel }) => { .toLowerCase()}

+ Last Updated: {formatDateTime(dailyRound.modified_date)}
-
- -
6 && "bg-danger-500" - )} - >
-
+
); } @@ -149,8 +143,7 @@ export const Mews = ({ dailyRound }: { dailyRound: DailyRoundsModel }) => { if (Object.values(scores).some((value) => value === undefined)) { return ( -
-

MEWS Score

+
{mewsCard( true, Object.entries(scores) @@ -162,8 +155,7 @@ export const Mews = ({ dailyRound }: { dailyRound: DailyRoundsModel }) => { } return ( -
-

MEWS Score

+
{mewsCard( false, Object.values(scores as Record).reduce((p, v) => p + v) diff --git a/src/Components/Patient/PatientInfoCard.tsx b/src/Components/Patient/PatientInfoCard.tsx index c9d4aac916d..8cbb24c61a9 100644 --- a/src/Components/Patient/PatientInfoCard.tsx +++ b/src/Components/Patient/PatientInfoCard.tsx @@ -6,29 +6,29 @@ import { PATIENT_CATEGORIES, RESPIRATORY_SUPPORT, TELEMEDICINE_ACTIONS, -} from "../../Common/constants"; -import { ConsultationModel, PatientCategory } from "../Facility/models"; +} from "../../Common/constants.js"; +import { ConsultationModel, PatientCategory } from "../Facility/models.js"; import { Switch, Menu } from "@headlessui/react"; import { Link, navigate } from "raviger"; import { useState } from "react"; -import CareIcon from "../../CAREUI/icons/CareIcon"; -import useConfig from "../../Common/hooks/useConfig"; -import dayjs from "../../Utils/dayjs"; +import CareIcon from "../../CAREUI/icons/CareIcon.js"; +import useConfig from "../../Common/hooks/useConfig.js"; +import dayjs from "../../Utils/dayjs.js"; import { classNames, formatDate, formatDateTime } from "../../Utils/utils.js"; -import ABHAProfileModal from "../ABDM/ABHAProfileModal"; -import LinkABHANumberModal from "../ABDM/LinkABHANumberModal"; -import LinkCareContextModal from "../ABDM/LinkCareContextModal"; -import DialogModal from "../Common/Dialog"; -import ButtonV2 from "../Common/components/ButtonV2"; -import Beds from "../Facility/Consultations/Beds"; -import { PatientModel } from "./models"; +import ABHAProfileModal from "../ABDM/ABHAProfileModal.js"; +import LinkABHANumberModal from "../ABDM/LinkABHANumberModal.js"; +import LinkCareContextModal from "../ABDM/LinkCareContextModal.js"; +import DialogModal from "../Common/Dialog.js"; +import ButtonV2 from "../Common/components/ButtonV2.js"; +import Beds from "../Facility/Consultations/Beds.js"; +import { PatientModel } from "./models.js"; import request from "../../Utils/request/request.js"; import routes from "../../Redux/api.js"; import DropdownMenu from "../Common/components/Menu.js"; import { triggerGoal } from "../../Integrations/Plausible.js"; -import useAuthUser from "../../Common/hooks/useAuthUser"; +import useAuthUser from "../../Common/hooks/useAuthUser.js"; import { Mews } from "../Facility/Consultations/Mews.js"; import DischargeSummaryModal from "../Facility/DischargeSummaryModal.js"; import DischargeModal from "../Facility/DischargeModal.js"; @@ -153,83 +153,86 @@ export default function PatientInfoCard(props: { )} -
-
+
+
{/* Can support for patient picture in the future */} -
-
- {consultation?.current_bed && - consultation?.discharge_date === null ? ( -
-

- { - consultation?.current_bed?.bed_object?.location_object - ?.name - } -

-

- {consultation?.current_bed?.bed_object.name} -

-
- +
+
+
+ {consultation?.current_bed && + consultation?.discharge_date === null ? ( +
+

{ consultation?.current_bed?.bed_object?.location_object ?.name } - - {consultation?.current_bed?.bed_object.name} +

+

+ {consultation?.current_bed?.bed_object.name} +

+
+ + { + consultation?.current_bed?.bed_object?.location_object + ?.name + } + + {consultation?.current_bed?.bed_object.name} +
-
- ) : ( -
- + ) : ( +
+ +
+ )} +
+ {category && ( +
+ {category.toUpperCase()}
)} + setOpen(true)} + className="mt-1 px-[10px] py-1" + > + {bedDialogTitle} +
- {category && ( +
- {category.toUpperCase()} -
- )} - setOpen(true)} className="mt-1"> - {bedDialogTitle} - -
-
-
- {patient.name} -
-
- {patient.review_time && - !consultation?.discharge_date && - Number(consultation?.review_interval) > 0 && ( -
+ {patient.age} years • {patient.gender} +
+
+ - - {(dayjs().isBefore(patient.review_time) - ? "Review before: " - : "Review Missed: ") + - formatDateTime(patient.review_time)} -
- )} + + {consultation?.facility_name} + +
+
-
+
+
+
- {consultation?.patient_no && ( - - - {`${consultation?.suggestion === "A" ? "IP" : "OP"}: ${ - consultation?.patient_no - }`} - - - )} {medicoLegalCase && ( - + MLC )}
- {!!consultation?.discharge_date && ( -

- Discharged from CARE -

- )} -
-
- {patient.action && patient.action != 10 && ( -
-
- - {" "} - { - TELEMEDICINE_ACTIONS.find( - (i) => i.id === patient.action - )?.desc - } - -
-
- )} -
-
- Age: {patient.age} years -
-
-
-
- Gender: {patient.gender} -
+
+
+ {patient.name} +
+ {patient.age} years • {patient.gender}
- {consultation?.suggestion === "DC" && ( -
+
+
+
+ {consultation?.patient_no && ( + + + {`${consultation?.suggestion === "A" ? "IP" : "OP"}: ${ + consultation?.patient_no + }`} + + + )} + {patient.action && patient.action != 10 && (
-
- Domiciliary Care - +
+ + {" "} + { + TELEMEDICINE_ACTIONS.find( + (i) => i.id === patient.action + )?.desc + } +
+ )} +
+ {patient.blood_group && ( +
+ Blood Group: {patient.blood_group} +
+ )}
- )} -
-
-
- {[ - [ - "Respiratory Support", - RESPIRATORY_SUPPORT.find( - (resp) => - resp.text === - consultation?.last_daily_round?.ventilator_interface - )?.id ?? "UNKNOWN", - consultation?.last_daily_round?.ventilator_interface, - ], - ].map((stat, i) => { - return stat[2] && stat[1] !== "NONE" ? ( -
- {stat[0]} : {stat[1]} -
- ) : ( - "" - ); - })} -
- {consultation?.discharge_date ? ( -
-
- - { - CONSULTATION_SUGGESTION.find( - (suggestion) => - suggestion.id === consultation?.suggestion - )?.text - }{" "} - on {formatDateTime(consultation.encounter_date)}, - {consultation?.new_discharge_reason === - DISCHARGE_REASONS.find((i) => i.text == "Expired")?.id ? ( - - {" "} - Expired on {formatDate(consultation?.death_datetime)} - - ) : ( - - {" "} - Discharged on{" "} - {formatDateTime(consultation?.discharge_date)} - + {patient.review_time && + !consultation?.discharge_date && + Number(consultation?.review_interval) > 0 && ( +
+
+ + {dayjs().isBefore(patient.review_time) + ? "Review before: " + : "Review Missed: "} + {formatDateTime(patient.review_time)} +
+
)} -
-
-
- ) : ( -
- - {consultation?.encounter_date && ( + {consultation?.suggestion === "DC" && (
- Admission on{" "} - {formatDateTime(consultation?.encounter_date)} +
+
+ + Domiciliary Care +
+
)} - {consultation?.icu_admission_date && ( -
- , ICU Admission on{" "} - {formatDateTime(consultation?.icu_admission_date)} + {!!consultation?.discharge_date && ( +

+ Discharged from CARE +

+ )} + {[ + [ + "Respiratory Support", + RESPIRATORY_SUPPORT.find( + (resp) => + resp.text === + consultation?.last_daily_round?.ventilator_interface + )?.id ?? "UNKNOWN", + consultation?.last_daily_round?.ventilator_interface, + ], + ].map((stat, i) => { + return stat[2] && stat[1] !== "NONE" ? ( +
+
+ {stat[0]} : {stat[1]} +
+
+ ) : ( + "" + ); + })} + {consultation?.discharge_date ? ( +
+
+ + + { + CONSULTATION_SUGGESTION.find( + (suggestion) => + suggestion.id === consultation?.suggestion + )?.text + } + {" "} + on {formatDateTime(consultation.encounter_date)}, + {consultation?.new_discharge_reason === "EXP" ? ( + + {" "} + Expired on{" "} + {formatDate(consultation?.death_datetime)} + + ) : ( + + {" "} + Discharged on{" "} + {formatDateTime(consultation?.discharge_date)} + + )} + +
+
+ ) : ( +
+ + {consultation?.encounter_date && ( +
+ Admission on:{" "} + {formatDateTime(consultation?.encounter_date)} +
+ )} + {consultation?.icu_admission_date && ( +
+ , ICU Admission on:{" "} + {formatDateTime(consultation?.icu_admission_date)} +
+ )} +
)} - +
+
+
+
+
+ {consultation?.diagnoses?.length + ? (() => { + const principal_diagnosis = consultation.diagnoses.find( + (diagnosis) => diagnosis.is_principal + ); + return principal_diagnosis ? ( +
+
+ Principal Diagnosis: +
+
+ {principal_diagnosis.diagnosis_object.label}{" "} + + +

+ {principal_diagnosis.verification_status} +

+
+
+
+ ) : null; + })() + : null} + {(consultation?.treating_physician_object || + consultation?.deprecated_verified_by) && ( +
+ + Treating Physician:{" "} + + {consultation?.treating_physician_object + ? `${consultation?.treating_physician_object.first_name} ${consultation?.treating_physician_object.last_name}` + : consultation?.deprecated_verified_by} + +
+ )}
- )} +
- {consultation?.last_daily_round && ( -
- -
- )} -
+ {consultation?.last_daily_round && ( +
+ +
+ )} {!!consultation?.discharge_date && ( -
+
Discharge Reason
-
+
{!consultation?.new_discharge_reason ? ( {consultation.suggestion === "OP" @@ -401,14 +472,6 @@ export default function PatientInfoCard(props: {
)} {[ - [ - `/facility/${patient.facility}/patient/${patient.id}/consultation/${consultation?.id}/update`, - "Edit Consultation Details", - "pen", - patient.is_active && - consultation?.id && - !consultation?.discharge_date, - ], [ `/facility/${patient.facility}/patient/${patient.id}/consultation/${consultation?.id}/daily-rounds`, "Log Update", @@ -431,7 +494,10 @@ export default function PatientInfoCard(props: { ].map( (action: any, i) => action[3] && ( -
+
- +

{action[1]}

{action?.[4]?.[0] && ( <> -

+

{action[4][1]}

@@ -474,11 +540,20 @@ export default function PatientInfoCard(props: { } + title={"Manage Patient"} + icon={} + containerClassName="w-full lg:w-auto mt-2 2xl:mt-0" >
{[ + [ + `/facility/${patient.facility}/patient/${patient.id}/consultation/${consultation?.id}/update`, + "Edit Consultation Details", + "pen", + patient.is_active && + consultation?.id && + !consultation?.discharge_date, + ], [ `/patient/${patient.id}/investigation_reports`, "Investigation Summary", @@ -554,6 +629,7 @@ export default function PatientInfoCard(props: { ) )}
+
{enable_abdm && (patient.abha_number ? ( diff --git a/src/Utils/utils.ts b/src/Utils/utils.ts index b890672a6c1..916d32f5ba3 100644 --- a/src/Utils/utils.ts +++ b/src/Utils/utils.ts @@ -99,9 +99,11 @@ export const formatDate = (date: DateLike, format = DATE_FORMAT) => export const formatTime = (date: DateLike, format = TIME_FORMAT) => formatDateTime(date, format); -export const relativeDate = (date: DateLike) => { +export const relativeDate = (date: DateLike, withoutSuffix = false) => { const obj = dayjs(date); - return `${obj.fromNow()} at ${obj.format(TIME_FORMAT)}`; + return `${obj.fromNow(withoutSuffix)} ${ + withoutSuffix && "ago" + } at ${obj.format(TIME_FORMAT)}`; }; export const formatName = (user: { first_name: string; last_name: string }) => { From 8fb7d5946230f5b1ae563af70dce07eaffac6468 Mon Sep 17 00:00:00 2001 From: Gampa Sri Harsh <114745442+sriharsh05@users.noreply.github.com> Date: Wed, 7 Feb 2024 11:17:30 +0530 Subject: [PATCH 11/18] limited the decimal point of location picker to 7 (#7162) --- src/Components/Facility/FacilityCreate.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Components/Facility/FacilityCreate.tsx b/src/Components/Facility/FacilityCreate.tsx index 9fbe89035c4..69f02aa91ee 100644 --- a/src/Components/Facility/FacilityCreate.tsx +++ b/src/Components/Facility/FacilityCreate.tsx @@ -252,8 +252,10 @@ export const FacilityCreate = (props: FacilityProps) => { ? "+91" + data.phone_number : data.phone_number : "", - latitude: data.latitude ? String(data.latitude) : "", - longitude: data.longitude ? String(data.longitude) : "", + latitude: data.latitude ? parseFloat(data.latitude).toFixed(7) : "", + longitude: data.longitude + ? parseFloat(data.longitude).toFixed(7) + : "", type_b_cylinders: data.type_b_cylinders, type_c_cylinders: data.type_c_cylinders, type_d_cylinders: data.type_d_cylinders, @@ -292,8 +294,8 @@ export const FacilityCreate = (props: FacilityProps) => { type: "set_form", form: { ...state.form, - latitude: location.lat().toString(), - longitude: location.lng().toString(), + latitude: location.lat().toFixed(7), + longitude: location.lng().toFixed(7), }, }); } From fd53e5e3918c033d4d6717931b0e3b5244961d5b Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Wed, 7 Feb 2024 11:19:06 +0530 Subject: [PATCH 12/18] fixes #7145; live refresh cns on middleware hostname change (#7149) --- src/Components/Assets/AssetType/HL7Monitor.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Components/Assets/AssetType/HL7Monitor.tsx b/src/Components/Assets/AssetType/HL7Monitor.tsx index 86b9565e536..a7be23baad8 100644 --- a/src/Components/Assets/AssetType/HL7Monitor.tsx +++ b/src/Components/Assets/AssetType/HL7Monitor.tsx @@ -69,6 +69,11 @@ const HL7Monitor = (props: HL7MonitorProps) => { }; if (isLoading) return ; + + const socketUrl = `wss://${ + middlewareHostname || resolvedMiddleware?.hostname + }/observations/${localipAddress}`; + return (
@@ -126,13 +131,12 @@ const HL7Monitor = (props: HL7MonitorProps) => { )} {assetType === "HL7MONITOR" && ( - + )} {assetType === "VENTILATOR" && ( )}
From cab3e97bac2d327894e1b8afa66d4a559608ca20 Mon Sep 17 00:00:00 2001 From: konavivekramakrishna Date: Wed, 7 Feb 2024 11:27:49 +0530 Subject: [PATCH 13/18] Removed 0 in Link Facility sidebar (#7144) * minor fix * draft * Revert "draft" This reverts commit 4ed54c2672a8f470c55fec4032ae653e31cfb457. --- src/Components/Users/ManageUsers.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Users/ManageUsers.tsx b/src/Components/Users/ManageUsers.tsx index 597ddefba19..6f5de125600 100644 --- a/src/Components/Users/ManageUsers.tsx +++ b/src/Components/Users/ManageUsers.tsx @@ -715,7 +715,7 @@ function UserFacilities(props: { user: any }) { )} {/* Linked Facilities section */} - {userFacilities?.length && ( + {!!userFacilities?.length && (
Linked Facilities From d4ac20460b4c83b38114c96cf0e6375a682cd5da Mon Sep 17 00:00:00 2001 From: konavivekramakrishna Date: Wed, 7 Feb 2024 16:11:13 +0530 Subject: [PATCH 14/18] Fixes responsiveness in Facilty Home (#6960) * fixed styling in faciltyhome * added flex-wrap * fix ui in sm * fix ui in sm * rm un-necessary classname * Update src/Components/Facility/FacilityHome.tsx --------- Co-authored-by: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Co-authored-by: Rithvik Nishad --- src/Components/Facility/FacilityHome.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Components/Facility/FacilityHome.tsx b/src/Components/Facility/FacilityHome.tsx index 6f42dab00a6..4b4754b894c 100644 --- a/src/Components/Facility/FacilityHome.tsx +++ b/src/Components/Facility/FacilityHome.tsx @@ -222,7 +222,7 @@ export const FacilityHome = (props: any) => {
-
+

@@ -242,7 +242,7 @@ export const FacilityHome = (props: any) => {

-
+

Local Body @@ -251,7 +251,7 @@ export const FacilityHome = (props: any) => { {facilityData?.local_body_object?.name}

-
+

Ward @@ -392,7 +392,7 @@ export const FacilityHome = (props: any) => { )}

-
+
Date: Wed, 7 Feb 2024 17:11:27 +0530 Subject: [PATCH 15/18] Make Update Log buttons responsive (#7185) --- .../Facility/ConsultationDetails/ConsultationUpdatesTab.tsx | 6 +++++- .../Consultations/DailyRounds/DefaultLogUpdateCard.tsx | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx b/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx index 323715ccfb0..56aadcadbdb 100644 --- a/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx +++ b/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx @@ -126,7 +126,11 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => { )}
- +
{!props.consultationData.discharge_date && ((hl7SocketUrl && !ventilatorSocketUrl) || diff --git a/src/Components/Facility/Consultations/DailyRounds/DefaultLogUpdateCard.tsx b/src/Components/Facility/Consultations/DailyRounds/DefaultLogUpdateCard.tsx index 34518afcb9b..bb080d43179 100644 --- a/src/Components/Facility/Consultations/DailyRounds/DefaultLogUpdateCard.tsx +++ b/src/Components/Facility/Consultations/DailyRounds/DefaultLogUpdateCard.tsx @@ -32,7 +32,7 @@ const DefaultLogUpdateCard = ({ round, ...props }: Props) => { attributeKey="other_details" attributeValue={round.other_details} /> -
+
Date: Wed, 7 Feb 2024 22:17:43 +0530 Subject: [PATCH 16/18] Make log update button responsive (#7191) * Make log update button responsive * Update PatientInfoCard component styling --- src/Components/Patient/PatientInfoCard.tsx | 603 +++++++++++---------- 1 file changed, 303 insertions(+), 300 deletions(-) diff --git a/src/Components/Patient/PatientInfoCard.tsx b/src/Components/Patient/PatientInfoCard.tsx index 8cbb24c61a9..c954438e6c2 100644 --- a/src/Components/Patient/PatientInfoCard.tsx +++ b/src/Components/Patient/PatientInfoCard.tsx @@ -471,347 +471,350 @@ export default function PatientInfoCard(props: {
)} - {[ - [ - `/facility/${patient.facility}/patient/${patient.id}/consultation/${consultation?.id}/daily-rounds`, - "Log Update", - "plus", - patient.is_active && - consultation?.id && - !consultation?.discharge_date, +
+ {[ [ - !(consultation?.facility !== patient.facility) && - !(consultation?.discharge_date ?? !patient.is_active) && - dayjs(consultation?.modified_date).isBefore( - dayjs().subtract(1, "day") - ), -
- No update - filed in the last 24 hours -
, + `/facility/${patient.facility}/patient/${patient.id}/consultation/${consultation?.id}/daily-rounds`, + "Log Update", + "plus", + patient.is_active && + consultation?.id && + !consultation?.discharge_date, + [ + !(consultation?.facility !== patient.facility) && + !(consultation?.discharge_date ?? !patient.is_active) && + dayjs(consultation?.modified_date).isBefore( + dayjs().subtract(1, "day") + ), +
+ No + update filed in the last 24 hours +
, + ], ], - ], - ].map( - (action: any, i) => - action[3] && ( -
- + action[3] && ( +
{ - if ( + > + - - -

{action[1]}

-
-
- {action?.[4]?.[0] && ( - <> -

- {action[4][1]} -

- - )} -
- ) - )} - } - containerClassName="w-full lg:w-auto mt-2 2xl:mt-0" - > -
- {[ - [ - `/facility/${patient.facility}/patient/${patient.id}/consultation/${consultation?.id}/update`, - "Edit Consultation Details", - "pen", - patient.is_active && - consultation?.id && - !consultation?.discharge_date, - ], - [ - `/patient/${patient.id}/investigation_reports`, - "Investigation Summary", - "align-alt", - true, - ], - [ - `/facility/${patient.facility}/patient/${patient.id}/consultation/${consultation?.id}/treatment-summary`, - "Treatment Summary", - "file-medical", - consultation?.id, - ], - ] - .concat( - enable_hcx - ? [ - [ - `/facility/${patient.facility}/patient/${patient.id}/consultation/${consultation?.id}/claims`, - "Claims", - "copy-landscape", - consultation?.id, - ], - ] - : [] + onClick={() => { + if ( + consultation?.admitted && + !consultation?.current_bed && + i === 1 + ) { + Notification.Error({ + msg: "Please assign a bed to the patient", + }); + setOpen(true); + } + }} + className="w-full" + > + + +

{action[1]}

+
+ + {action?.[4]?.[0] && ( + <> +

+ {action[4][1]} +

+ + )} +
) - .map( - (action: any, i) => - action[3] && ( -
- { - if ( + )} + } + className="xl:justify-center" + containerClassName="w-full lg:w-auto mt-2 2xl:mt-0 flex justify-center" + > +
+ {[ + [ + `/facility/${patient.facility}/patient/${patient.id}/consultation/${consultation?.id}/update`, + "Edit Consultation Details", + "pen", + patient.is_active && + consultation?.id && + !consultation?.discharge_date, + ], + [ + `/patient/${patient.id}/investigation_reports`, + "Investigation Summary", + "align-alt", + true, + ], + [ + `/facility/${patient.facility}/patient/${patient.id}/consultation/${consultation?.id}/treatment-summary`, + "Treatment Summary", + "file-medical", + consultation?.id, + ], + ] + .concat( + enable_hcx + ? [ + [ + `/facility/${patient.facility}/patient/${patient.id}/consultation/${consultation?.id}/claims`, + "Claims", + "copy-landscape", + consultation?.id, + ], + ] + : [] + ) + .map( + (action: any, i) => + action[3] && ( +
+ - - {action[1]} - - {action?.[4]?.[0] && ( + onClick={() => { + if ( + action[1] !== "Treatment Summary" && + consultation?.admitted && + !consultation?.current_bed && + i === 1 + ) { + Notification.Error({ + msg: "Please assign a bed to the patient", + }); + setOpen(true); + } + triggerGoal("Patient Card Button Clicked", { + buttonName: action[1], + consultationId: consultation?.id, + userId: authUser?.id, + }); + }} + > + + {action[1]} + + {action?.[4]?.[0] && ( + <> +

+ {action[4][1]} +

+ + )} +
+ ) + )} +
+ +
+ {enable_abdm && + (patient.abha_number ? ( + <> + + {({ close }) => ( <> -

- {action[4][1]} -

+
{ + close(); + setShowABHAProfile(true); + triggerGoal("Patient Card Button Clicked", { + buttonName: "Show ABHA Profile", + consultationId: consultation?.id, + userId: authUser?.id, + }); + }} + > + + Show ABHA Profile +
+
{ + triggerGoal("Patient Card Button Clicked", { + buttonName: "Link Care Context", + consultationId: consultation?.id, + userId: authUser?.id, + }); + close(); + setShowLinkCareContext(true); + }} + > + + Link Care Context +
)} -
- ) - )} -
- -
- {enable_abdm && - (patient.abha_number ? ( - <> + + + ) : ( {({ close }) => ( - <> +
{ + close(); + setShowLinkABHANumber(true); + }} + > + + +

Link ABHA Number

+
+
+ )} +
+ ))} +
+
+ {!consultation?.discharge_date && ( + + {({ close }) => ( + <> + {hasActiveShiftingRequest() ? (
{ close(); - setShowABHAProfile(true); - triggerGoal("Patient Card Button Clicked", { - buttonName: "Show ABHA Profile", - consultationId: consultation?.id, - userId: authUser?.id, - }); + navigate( + `/shifting/${ + activeShiftingData[ + activeShiftingData.length - 1 + ].id + }` + ); }} > - - Show ABHA Profile + + +

Track Shifting

+
+ ) : (
{ - triggerGoal("Patient Card Button Clicked", { - buttonName: "Link Care Context", - consultationId: consultation?.id, - userId: authUser?.id, - }); close(); - setShowLinkCareContext(true); + navigate( + `/facility/${patient.facility}/patient/${patient.id}/shift/new` + ); }} > - - Link Care Context + + +

Shift Patient

+
- - )} -
- - ) : ( - - {({ close }) => ( -
{ - close(); - setShowLinkABHANumber(true); - }} - > - - -

Link ABHA Number

-
-
+ )} + )}
- ))} -
-
- {!consultation?.discharge_date && ( + )} {({ close }) => ( - <> - {hasActiveShiftingRequest() ? ( -
{ - close(); - navigate( - `/shifting/${ - activeShiftingData[ - activeShiftingData.length - 1 - ].id - }` - ); - }} - > - - -

Track Shifting

-
-
- ) : ( -
{ - close(); - navigate( - `/facility/${patient.facility}/patient/${patient.id}/shift/new` - ); - }} - > - - -

Shift Patient

-
-
- )} - +
{ + close(); + setOpenDischargeSummaryDialog(true); + }} + > + + +

{t("discharge_summary")}

+
+
)}
- )} - - {({ close }) => ( -
{ - close(); - setOpenDischargeSummaryDialog(true); - }} - > - - -

{t("discharge_summary")}

-
-
- )} -
- - {({ close }) => ( -
{ - if (!consultation?.discharge_date) { - close(); - setOpenDischargeDialog(true); - } - }} - > - - -

{t("discharge_from_care")}

-
-
- )} -
-
-
- - { - triggerGoal("Patient Card Button Clicked", { - buttonName: "Medico Legal Case", - consultationId: consultation?.id, - userId: authUser?.id, - }); - setMedicoLegalCase(checked); - switchMedicoLegalCase(checked); - }} - className={classNames( - medicoLegalCase ? "bg-primary" : "bg-gray-200", - "relative inline-flex h-4 w-8 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none " + + {({ close }) => ( +
{ + if (!consultation?.discharge_date) { + close(); + setOpenDischargeDialog(true); + } + }} + > + + +

{t("discharge_from_care")}

+
+
)} - > -
+
+ + { + triggerGoal("Patient Card Button Clicked", { + buttonName: "Medico Legal Case", + consultationId: consultation?.id, + userId: authUser?.id, + }); + setMedicoLegalCase(checked); + switchMedicoLegalCase(checked); + }} className={classNames( - medicoLegalCase ? "translate-x-4" : "translate-x-0", - "pointer-events-none inline-block h-3 w-3 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out" + medicoLegalCase ? "bg-primary" : "bg-gray-200", + "relative inline-flex h-4 w-8 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none " )} - /> - - - - Medico-Legal Case - {" "} - - -
-
+ > +
+ +
Date: Wed, 7 Feb 2024 22:23:18 +0530 Subject: [PATCH 17/18] fixes improper string interpolation in relative dates causing 'false' to be present when withoutSuffix is disabled (#7189) * fixes improper string interpolation in realtive dates causing 'false' to be present when withoutSuffix is disabled * Update src/Utils/utils.ts --------- Co-authored-by: Ashesh <3626859+Ashesh3@users.noreply.github.com> --- src/Utils/utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Utils/utils.ts b/src/Utils/utils.ts index 916d32f5ba3..4e1d1626a59 100644 --- a/src/Utils/utils.ts +++ b/src/Utils/utils.ts @@ -101,8 +101,8 @@ export const formatTime = (date: DateLike, format = TIME_FORMAT) => export const relativeDate = (date: DateLike, withoutSuffix = false) => { const obj = dayjs(date); - return `${obj.fromNow(withoutSuffix)} ${ - withoutSuffix && "ago" + return `${obj.fromNow(withoutSuffix)}${ + withoutSuffix ? " ago " : "" } at ${obj.format(TIME_FORMAT)}`; }; From 4fa053384bb97b626ed46c9bc40289ce84404b3a Mon Sep 17 00:00:00 2001 From: Khavin Shankar Date: Thu, 8 Feb 2024 19:07:58 +0530 Subject: [PATCH 18/18] show notification when health id registration fails (#7114) --- .../e2e/facility_spec/facility_manage.cy.ts | 27 +++++----- cypress/pageobject/Facility/FacilityManage.ts | 10 ++-- .../ABDM/ConfigureHealthFacility.tsx | 49 ++++++------------- 3 files changed, 37 insertions(+), 49 deletions(-) diff --git a/cypress/e2e/facility_spec/facility_manage.cy.ts b/cypress/e2e/facility_spec/facility_manage.cy.ts index 11c75949af1..612a95001d6 100644 --- a/cypress/e2e/facility_spec/facility_manage.cy.ts +++ b/cypress/e2e/facility_spec/facility_manage.cy.ts @@ -13,11 +13,11 @@ describe("Facility Manage Functions", () => { const facilityUpdatedMiddleware = "updated.coronasafe.live"; const facilityMiddlewareSuccessfullNotification = "Facility updated successfully"; - const facilityHrfidUpdateButton = "Link Health Facility"; - const facilityHrfidSuccessfullNotification = - "Health Facility config updated successfully"; - const facilityHrfId = uuidv4(); - const facilityUpdatedHrfId = uuidv4(); + const facilityHfridUpdateButton = "Link Health Facility"; + const facilityHfridToastNotificationText = + /Health Facility config updated successfully|Health ID registration failed/; + const facilityHfrId = "IN180000018"; + const facilityUpdatedHfrId = uuidv4(); const doctorCapacity = "5"; const doctorModifiedCapacity = "7"; const totalCapacity = "100"; @@ -80,28 +80,29 @@ describe("Facility Manage Functions", () => { facilityPage.clickManageFacilityDropdown(); facilityManage.clickFacilityConfigureButton(); // verify mandatory field error message - facilityManage.clickButtonWithText(facilityHrfidUpdateButton); + facilityManage.clearHfrId(); + facilityManage.clickButtonWithText(facilityHfridUpdateButton); facilityManage.checkErrorMessageVisibility( "Health Facility Id is required" ); // add facility health ID and verify notification - facilityManage.typeHrfId(facilityHrfId); - facilityManage.clickButtonWithText(facilityHrfidUpdateButton); + facilityManage.typeHfrId(facilityHfrId); + facilityManage.clickButtonWithText(facilityHfridUpdateButton); facilityManage.verifySuccessMessageVisibilityAndContent( - facilityHrfidSuccessfullNotification + facilityHfridToastNotificationText ); // update the existing middleware facilityPage.clickManageFacilityDropdown(); facilityManage.clickFacilityConfigureButton(); - facilityManage.typeHrfId(facilityUpdatedHrfId); - facilityManage.clickButtonWithText(facilityHrfidUpdateButton); + facilityManage.typeHfrId(facilityUpdatedHfrId); + facilityManage.clickButtonWithText(facilityHfridUpdateButton); facilityManage.verifySuccessMessageVisibilityAndContent( - facilityHrfidSuccessfullNotification + facilityHfridToastNotificationText ); // verify its reflection facilityPage.clickManageFacilityDropdown(); facilityManage.clickFacilityConfigureButton(); - facilityManage.verifyHrfIdValue(facilityUpdatedHrfId); + facilityManage.verifyHfrIdValue(facilityUpdatedHfrId); }); it("Modify doctor capacity in Facility detail page", () => { diff --git a/cypress/pageobject/Facility/FacilityManage.ts b/cypress/pageobject/Facility/FacilityManage.ts index 69cdaf669e2..df379a53012 100644 --- a/cypress/pageobject/Facility/FacilityManage.ts +++ b/cypress/pageobject/Facility/FacilityManage.ts @@ -63,19 +63,23 @@ class FacilityManage { cy.get("#middleware_address").click().clear().click().type(address); } - typeHrfId(address) { + clearHfrId() { + cy.get("#hf_id").click().clear(); + } + + typeHfrId(address) { cy.get("#hf_id").click().clear().click().type(address); } verifySuccessMessageVisibilityAndContent(text) { - cy.get(".pnotify-text").should("be.visible").and("contain", text); + cy.get(".pnotify-text").should("be.visible").contains(text); } verifyMiddlewareAddressValue(expectedValue) { cy.get("#middleware_address").should("have.value", expectedValue); } - verifyHrfIdValue(expectedValue) { + verifyHfrIdValue(expectedValue) { cy.get("#hf_id").should("have.value", expectedValue); } diff --git a/src/Components/ABDM/ConfigureHealthFacility.tsx b/src/Components/ABDM/ConfigureHealthFacility.tsx index bccf58e47c2..e64841464a1 100644 --- a/src/Components/ABDM/ConfigureHealthFacility.tsx +++ b/src/Components/ABDM/ConfigureHealthFacility.tsx @@ -75,53 +75,31 @@ export const ConfigureHealthFacility = (props: any) => { let response = null; let responseData = null; - if (state.form.health_facility) { + if (state.form.hf_id === state.form.health_facility?.hf_id) { const { res, data } = await request( - routes.abha.partialUpdateHealthFacility, + routes.abha.registerHealthFacilityAsService, { pathParams: { facility_id: facilityId, }, - body: { - hf_id: state.form.hf_id, - }, } ); response = res; responseData = data; - } else if (state.form.hf_id === state.form.health_facility?.hf_id) { + } else if (state.form.health_facility) { const { res, data } = await request( - routes.abha.registerHealthFacilityAsService, + routes.abha.partialUpdateHealthFacility, { pathParams: { facility_id: facilityId, }, + body: { + hf_id: state.form.hf_id, + }, } ); response = res; responseData = data; - - if (response?.status === 200 && responseData) { - if (responseData?.registered) { - dispatch({ - type: "set_form", - form: { - ...state.form, - health_facility: { - ...state.form?.health_facility, - registered: responseData.registered, - }, - }, - }); - - return; - } - } - - Notification.Error({ - msg: "Service registration failed, please try again later", - }); - return; } else { const { res, data } = await request(routes.abha.createHealthFacility, { body: { @@ -133,17 +111,22 @@ export const ConfigureHealthFacility = (props: any) => { responseData = data; } - setIsLoading(false); - if (response && responseData) { + if (response?.ok && responseData?.registered) { Notification.Success({ msg: "Health Facility config updated successfully", }); navigate(`/facility/${facilityId}`); } else { - if (responseData) + if (responseData?.registered === false) { + Notification.Warn({ + msg: responseData?.detail || "Health ID registration failed", + }); + navigate(`/facility/${facilityId}`); + } else { Notification.Error({ - msg: "Something went wrong: " + (responseData.detail || ""), + msg: responseData?.detail || "Health Facility config update failed", }); + } } setIsLoading(false); };