From 096905d645fa4c0b4fef9e14537961f1639e1502 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Fri, 29 Dec 2023 23:20:27 +0530 Subject: [PATCH 1/6] fixes not found errors in investigation and other type errors (#6948) --- src/Components/Facility/ConsultationDetails/index.tsx | 4 ++++ src/Components/Facility/models.tsx | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Components/Facility/ConsultationDetails/index.tsx b/src/Components/Facility/ConsultationDetails/index.tsx index abc7305a00b..c6cc9e02275 100644 --- a/src/Components/Facility/ConsultationDetails/index.tsx +++ b/src/Components/Facility/ConsultationDetails/index.tsx @@ -46,6 +46,8 @@ const symptomChoices = [...SYMPTOM_CHOICES]; export interface ConsultationTabProps { consultationId: string; + facilityId: string; + patientId: string; consultationData: ConsultationModel; patientData: PatientModel; } @@ -189,6 +191,8 @@ export const ConsultationDetails = (props: any) => { const consultationTabProps: ConsultationTabProps = { consultationId, consultationData, + patientId: consultationData.patient, + facilityId: consultationData.facility, patientData, }; diff --git a/src/Components/Facility/models.tsx b/src/Components/Facility/models.tsx index 90191e3321f..c3ac910970c 100644 --- a/src/Components/Facility/models.tsx +++ b/src/Components/Facility/models.tsx @@ -109,12 +109,12 @@ export interface ConsultationModel { discharge_notes?: string; examination_details?: string; history_of_present_illness?: string; - facility?: number; + facility: string; facility_name?: string; id: string; modified_date?: string; other_symptoms?: string; - patient?: string; + patient: string; treatment_plan?: string; referred_to?: FacilityModel["id"]; referred_to_object?: FacilityModel; From 06a2afdbc875ab63e691900c23f039e8d64cc759 Mon Sep 17 00:00:00 2001 From: Ashesh <3626859+Ashesh3@users.noreply.github.com> Date: Fri, 29 Dec 2023 23:20:57 +0530 Subject: [PATCH 2/6] Update consciousness level constants (#6947) --- src/Common/constants.tsx | 2 +- src/Components/Patient/DailyRounds.tsx | 103 +++++++++++-------------- 2 files changed, 45 insertions(+), 60 deletions(-) diff --git a/src/Common/constants.tsx b/src/Common/constants.tsx index f472e8b193c..647c77ecf57 100644 --- a/src/Common/constants.tsx +++ b/src/Common/constants.tsx @@ -307,7 +307,7 @@ export const CONSCIOUSNESS_LEVEL = [ { id: "ALERT", text: "Alert" }, { id: "AGITATED_OR_CONFUSED", text: "Agitated or Confused" }, { - id: "Onset of Agitation and Confusion", + id: "ONSET_OF_AGITATION_AND_CONFUSION", text: "Onset of Agitation and Confusion", }, { id: "UNKNOWN", text: "Unknown" }, diff --git a/src/Components/Patient/DailyRounds.tsx b/src/Components/Patient/DailyRounds.tsx index 2b8bec1a75f..4def8ed74eb 100644 --- a/src/Components/Patient/DailyRounds.tsx +++ b/src/Components/Patient/DailyRounds.tsx @@ -1,7 +1,7 @@ import { navigate } from "raviger"; import dayjs from "dayjs"; -import { lazy, useCallback, useEffect, useState } from "react"; +import { lazy, useCallback, useState } from "react"; import { useDispatch } from "react-redux"; import { CONSCIOUSNESS_LEVEL, @@ -61,7 +61,7 @@ const initForm: any = { rhythm: "0", rhythm_detail: "", ventilator_spo2: null, - consciousness_level: "Unknown", + consciousness_level: "UNKNOWN", // bed: null, }; @@ -135,40 +135,6 @@ export const DailyRounds = (props: any) => { "consciousness_level", ]; - useEffect(() => { - (async () => { - if (patientId) { - const res = await dispatchAction(getPatient({ id: patientId })); - if (res.data) { - setPatientName(res.data.name); - setFacilityName(res.data.facility_object.name); - setConsultationSuggestion(res.data.last_consultation?.suggestion); - setPreviousReviewInterval( - Number(res.data.last_consultation.review_interval) - ); - const getAction = - TELEMEDICINE_ACTIONS.find((action) => action.id === res.data.action) - ?.text || "NO_ACTION"; - setPreviousAction(getAction); - setInitialData({ - ...initialData, - action: getAction, - }); - dispatch({ - type: "set_form", - form: { - ...state.form, - action: getAction, - }, - }); - } - } else { - setPatientName(""); - setFacilityName(""); - } - })(); - }, [dispatchAction, patientId]); - const fetchRoundDetails = useCallback( async (status: statusType) => { setIsLoading(true); @@ -176,6 +142,8 @@ export const DailyRounds = (props: any) => { getConsultationDailyRoundsDetails({ consultationId, id }) ); + let formData: any = {}; + if (!status.aborted) { if (res?.data) { const data = { @@ -191,34 +159,41 @@ export const DailyRounds = (props: any) => { "0", admitted_to: res.data.admitted_to ? res.data.admitted_to : "Select", }; - dispatch({ type: "set_form", form: data }); - setInitialData(data); + formData = { ...formData, ...data }; } setIsLoading(false); } - }, - [consultationId, id, dispatchAction] - ); - useAbortableEffect( - (status: statusType) => { - if (id) { - fetchRoundDetails(status); + if (patientId) { + const res = await dispatchAction(getPatient({ id: patientId })); + if (res.data) { + setPatientName(res.data.name); + setFacilityName(res.data.facility_object.name); + setConsultationSuggestion(res.data.last_consultation?.suggestion); + setPreviousReviewInterval( + Number(res.data.last_consultation.review_interval) + ); + const getAction = + TELEMEDICINE_ACTIONS.find((action) => action.id === res.data.action) + ?.text || "NO_ACTION"; + setPreviousAction(getAction); + setInitialData({ + ...initialData, + action: getAction, + }); + formData = { ...formData, ...{ action: getAction } }; + } + } else { + setPatientName(""); + setFacilityName(""); } - }, - [dispatchAction, fetchRoundDetails] - ); - - useEffect(() => { - (async () => { if (consultationId && !id) { const res = await dispatchAction( getDailyReport({ limit: 1, offset: 0 }, { consultationId }) ); setHasPreviousLog(res.data.count > 0); - dispatch({ - type: "set_form", - form: { - ...state.form, + formData = { + ...formData, + ...{ patient_category: res.data.patient_category ? PATIENT_CATEGORIES.find( (i) => i.text === res.data.patient_category @@ -229,12 +204,22 @@ export const DailyRounds = (props: any) => { RHYTHM_CHOICES.find((i) => i.text === res.data.rhythm)?.id) || "0", temperature: parseFloat(res.data.temperature), - // clone_last: res.data.count > 0 ? true : false, }, - }); + }; + } + dispatch({ type: "set_form", form: formData }); + setInitialData(formData); + }, + [consultationId, id, dispatchAction, patientId] + ); + useAbortableEffect( + (status: statusType) => { + if (id) { + fetchRoundDetails(status); } - })(); - }, [dispatchAction, consultationId, id]); + }, + [dispatchAction, fetchRoundDetails] + ); const validateForm = () => { const errors = { ...initError }; From 1085e0f083125a466170df5470eb3ad33d2e4285 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Fri, 29 Dec 2023 23:47:55 +0530 Subject: [PATCH 3/6] fix resp. rate from being 0 instead of null when unset (#6949) * fix resp. rate from being 0 instead of null * fix relative time alignment --- src/CAREUI/display/RecordMeta.tsx | 8 +++++--- src/Components/Patient/DailyRounds.tsx | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/CAREUI/display/RecordMeta.tsx b/src/CAREUI/display/RecordMeta.tsx index d4d32e437c8..5e1e117f9d6 100644 --- a/src/CAREUI/display/RecordMeta.tsx +++ b/src/CAREUI/display/RecordMeta.tsx @@ -1,7 +1,8 @@ import CareIcon from "../icons/CareIcon"; import { - formatDateTime, + formatDate, formatName, + formatTime, isUserOnline, relativeTime, } from "../../Utils/utils"; @@ -37,8 +38,9 @@ const RecordMeta = ({ let child = (
{relativeTime(time)} - - {formatDateTime(time)} + + {formatTime(time)}
+ {formatDate(time)} {user && !inlineUser && ( by diff --git a/src/Components/Patient/DailyRounds.tsx b/src/Components/Patient/DailyRounds.tsx index 4def8ed74eb..06431457b0e 100644 --- a/src/Components/Patient/DailyRounds.tsx +++ b/src/Components/Patient/DailyRounds.tsx @@ -296,9 +296,9 @@ export const DailyRounds = (props: any) => { } : undefined, pulse: state.form.pulse, - resp: Number(state.form.resp), + resp: state.form.resp, temperature: state.form.temperature, - rhythm: Number(state.form.rhythm) || 0, + rhythm: state.form.rhythm || 0, rhythm_detail: state.form.rhythm_detail, ventilator_spo2: state.form.ventilator_spo2, consciousness_level: state.form.consciousness_level, From 8aea0cc9139c507b83784986d9d2c4eec7a7baf6 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Sat, 30 Dec 2023 15:41:36 +0530 Subject: [PATCH 4/6] fix has previous log update not being filled (#6951) --- src/Components/Patient/DailyRounds.tsx | 51 +++++++++++++------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/src/Components/Patient/DailyRounds.tsx b/src/Components/Patient/DailyRounds.tsx index 06431457b0e..ec2f070aa20 100644 --- a/src/Components/Patient/DailyRounds.tsx +++ b/src/Components/Patient/DailyRounds.tsx @@ -138,31 +138,34 @@ export const DailyRounds = (props: any) => { const fetchRoundDetails = useCallback( async (status: statusType) => { setIsLoading(true); - const res = await dispatchAction( - getConsultationDailyRoundsDetails({ consultationId, id }) - ); - - let formData: any = {}; + let formData: any = initialData; + if (id) { + const res = await dispatchAction( + getConsultationDailyRoundsDetails({ consultationId, id }) + ); - if (!status.aborted) { - if (res?.data) { - const data = { - ...res.data, - patient_category: res.data.patient_category - ? PATIENT_CATEGORIES.find( - (i) => i.text === res.data.patient_category - )?.id ?? "" - : "", - rhythm: - (res.data.rhythm && - RHYTHM_CHOICES.find((i) => i.text === res.data.rhythm)?.id) || - "0", - admitted_to: res.data.admitted_to ? res.data.admitted_to : "Select", - }; - formData = { ...formData, ...data }; + if (!status.aborted) { + if (res?.data) { + const data = { + ...res.data, + patient_category: res.data.patient_category + ? PATIENT_CATEGORIES.find( + (i) => i.text === res.data.patient_category + )?.id ?? "" + : "", + rhythm: + (res.data.rhythm && + RHYTHM_CHOICES.find((i) => i.text === res.data.rhythm)?.id) || + "0", + admitted_to: res.data.admitted_to + ? res.data.admitted_to + : "Select", + }; + formData = { ...formData, ...data }; + } } - setIsLoading(false); } + setIsLoading(false); if (patientId) { const res = await dispatchAction(getPatient({ id: patientId })); if (res.data) { @@ -214,9 +217,7 @@ export const DailyRounds = (props: any) => { ); useAbortableEffect( (status: statusType) => { - if (id) { - fetchRoundDetails(status); - } + fetchRoundDetails(status); }, [dispatchAction, fetchRoundDetails] ); From c5c86aa594e11e832b18cc6fa906ce04d7e041f7 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Sat, 30 Dec 2023 22:41:29 +0530 Subject: [PATCH 5/6] fix daily rounds vital fields not clearing (#6954) * fix daily rounds vital fields not clearing * Fix blood pressure form field and daily rounds component * Fix default blood pressure values in DailyRounds component * Fix handling of negative values in blood pressure --------- Co-authored-by: Ashesh3 <3626859+Ashesh3@users.noreply.github.com> --- .../Common/BloodPressureFormField.tsx | 9 ++-- .../Facility/Consultations/Mews.tsx | 1 + .../Patient/DailyRoundListDetails.tsx | 10 +++- src/Components/Patient/DailyRounds.tsx | 50 +++++++++++++++---- 4 files changed, 53 insertions(+), 17 deletions(-) diff --git a/src/Components/Common/BloodPressureFormField.tsx b/src/Components/Common/BloodPressureFormField.tsx index ed0557ae8e3..3ff2774b900 100644 --- a/src/Components/Common/BloodPressureFormField.tsx +++ b/src/Components/Common/BloodPressureFormField.tsx @@ -21,7 +21,7 @@ export default function BloodPressureFormField(props: Props) { name: field.name, value: { ...field.value, - [event.name]: event.value, + [event.name]: event.value ?? -1, }, }); }; @@ -35,9 +35,10 @@ export default function BloodPressureFormField(props: Props) { MAP: {map.toFixed(1)} - ) : undefined, + labelSuffix: + map && map !== -1 ? ( + MAP: {map.toFixed(1)} + ) : undefined, }} >
diff --git a/src/Components/Facility/Consultations/Mews.tsx b/src/Components/Facility/Consultations/Mews.tsx index 6b8e7de806e..5160e42f9f2 100644 --- a/src/Components/Facility/Consultations/Mews.tsx +++ b/src/Components/Facility/Consultations/Mews.tsx @@ -26,6 +26,7 @@ const getHeartRateScore = (value?: number) => { const getSystolicBPScore = (value?: number) => { if (typeof value !== "number") return; + if (value === -1) return; if (value <= 70) return 3; if (value <= 80) return 2; diff --git a/src/Components/Patient/DailyRoundListDetails.tsx b/src/Components/Patient/DailyRoundListDetails.tsx index 8f313c0a51d..0a73607d688 100644 --- a/src/Components/Patient/DailyRoundListDetails.tsx +++ b/src/Components/Patient/DailyRoundListDetails.tsx @@ -158,14 +158,20 @@ export const DailyRoundListDetails = (props: any) => { Systolic:{" "} - {dailyRoundListDetailsData.bp?.systolic ?? "-"} + {dailyRoundListDetailsData.bp?.systolic && + dailyRoundListDetailsData.bp?.systolic !== -1 + ? dailyRoundListDetailsData.bp?.systolic + : "-"}
{" "} Diastolic: - {dailyRoundListDetailsData.bp?.diastolic ?? "-"} + {dailyRoundListDetailsData.bp?.diastolic && + dailyRoundListDetailsData.bp?.diastolic !== -1 + ? dailyRoundListDetailsData.bp?.diastolic + : "-"}
diff --git a/src/Components/Patient/DailyRounds.tsx b/src/Components/Patient/DailyRounds.tsx index ec2f070aa20..c12aea42bee 100644 --- a/src/Components/Patient/DailyRounds.tsx +++ b/src/Components/Patient/DailyRounds.tsx @@ -62,6 +62,11 @@ const initForm: any = { rhythm_detail: "", ventilator_spo2: null, consciousness_level: "UNKNOWN", + bp: { + systolic: -1, + diastolic: -1, + mean: -1, + }, // bed: null, }; @@ -242,6 +247,18 @@ export const DailyRounds = (props: any) => { invalidForm = true; } return; + case "bp": + if ( + (state.form.bp?.systolic && + state.form.bp?.diastolic && + state.form.bp.systolic !== -1 && + state.form.bp.diastolic === -1) || + (state.form.bp.systolic === -1 && state.form.bp.diastolic !== -1) + ) { + errors.bp = "Please enter both systolic and diastolic values"; + invalidForm = true; + } + return; default: return; } @@ -287,21 +304,32 @@ export const DailyRounds = (props: any) => { data = { ...data, bp: - state.form.bp && state.form.bp.systolic && state.form.bp.diastolic + state.form.bp?.systolic !== -1 && state.form.bp?.diastolic !== -1 ? { - systolic: Number(state.form.bp.systolic), - diastolic: Number(state.form.bp.diastolic), - mean: parseFloat( - meanArterialPressure(state.form.bp).toFixed(2) - ), + systolic: state.form.bp?.systolic + ? Number(state.form.bp?.systolic) + : -1, + diastolic: state.form.bp?.diastolic + ? Number(state.form.bp?.diastolic) + : -1, + mean: + state.form.bp?.systolic && state.form.bp?.diastolic + ? parseFloat( + meanArterialPressure(state.form.bp).toFixed(2) + ) + : -1, } - : undefined, - pulse: state.form.pulse, - resp: state.form.resp, - temperature: state.form.temperature, + : { + systolic: -1, + diastolic: -1, + mean: -1, + }, + pulse: state.form.pulse ?? null, + resp: state.form.resp ?? null, + temperature: state.form.temperature ?? null, rhythm: state.form.rhythm || 0, rhythm_detail: state.form.rhythm_detail, - ventilator_spo2: state.form.ventilator_spo2, + ventilator_spo2: state.form.ventilator_spo2 ?? null, consciousness_level: state.form.consciousness_level, }; } From f066a3659beb2ba899a226a465b06922b2207d69 Mon Sep 17 00:00:00 2001 From: Ashesh <3626859+Ashesh3@users.noreply.github.com> Date: Sat, 30 Dec 2023 22:57:23 +0530 Subject: [PATCH 6/6] Fix conditional logic in PatientInfoCard (#6955) --- src/Components/Patient/PatientInfoCard.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Components/Patient/PatientInfoCard.tsx b/src/Components/Patient/PatientInfoCard.tsx index c5087f13dda..eb589667ece 100644 --- a/src/Components/Patient/PatientInfoCard.tsx +++ b/src/Components/Patient/PatientInfoCard.tsx @@ -490,6 +490,7 @@ export default function PatientInfoCard(props: { key={i} className="dropdown-item-primary pointer-events-auto m-2 flex cursor-pointer items-center justify-start gap-2 rounded border-0 p-2 text-sm font-normal transition-all duration-200 ease-in-out" href={ + action[1] !== "Treatment Summary" && consultation?.admitted && !consultation?.current_bed && i === 1 @@ -498,6 +499,7 @@ export default function PatientInfoCard(props: { } onClick={() => { if ( + action[1] !== "Treatment Summary" && consultation?.admitted && !consultation?.current_bed && i === 1