From 8197f29b3109b653d09cd131614ebd7f442becdb Mon Sep 17 00:00:00 2001 From: Ashesh <3626859+Ashesh3@users.noreply.github.com> Date: Fri, 29 Dec 2023 17:57:03 +0530 Subject: [PATCH 1/5] Fix empty state in LocationManagement and BedManagement (#6937) * Fix empty state in LocationManagement * Refactor BedManagement component --- src/CAREUI/misc/PaginatedList.tsx | 2 +- src/Components/Facility/BedManagement.tsx | 24 +++++++++---------- .../Facility/LocationManagement.tsx | 14 +++++------ 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/CAREUI/misc/PaginatedList.tsx b/src/CAREUI/misc/PaginatedList.tsx index 61c67f97ae2..1487d69e4fa 100644 --- a/src/CAREUI/misc/PaginatedList.tsx +++ b/src/CAREUI/misc/PaginatedList.tsx @@ -130,7 +130,7 @@ interface ItemsProps { const Items = (props: ItemsProps) => { const { loading, items } = useContextualized(); - if (loading) { + if (loading || items.length === 0) { return null; } diff --git a/src/Components/Facility/BedManagement.tsx b/src/Components/Facility/BedManagement.tsx index 68e9fade43d..d8799f1fbc5 100644 --- a/src/Components/Facility/BedManagement.tsx +++ b/src/Components/Facility/BedManagement.tsx @@ -182,24 +182,22 @@ export const BedManagement = (props: BedManagementProps) => { )); } else if (data?.results.length === 0) { BedList = ( -

+

No beds available in this location

); } - if (data?.results.length) { - bed = ( - <> -
{BedList}
- {data.count && ( -
- -
- )} - - ); - } + bed = ( + <> +
{BedList}
+ {Boolean(data?.count && data.count > 0) && ( +
+ +
+ )} + + ); if (loading) { return ; diff --git a/src/Components/Facility/LocationManagement.tsx b/src/Components/Facility/LocationManagement.tsx index b7a758c5055..93a08794c82 100644 --- a/src/Components/Facility/LocationManagement.tsx +++ b/src/Components/Facility/LocationManagement.tsx @@ -46,14 +46,14 @@ export default function LocationManagement({ facilityId }: Props) { Add New Location - - No locations available - - - - -
+ + No locations available + + + + + className="my-8 grid gap-3 @4xl:grid-cols-2 @6xl:grid-cols-3 @[100rem]:grid-cols-4 lg:mx-8"> {(item) => } From 096905d645fa4c0b4fef9e14537961f1639e1502 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Fri, 29 Dec 2023 23:20:27 +0530 Subject: [PATCH 2/5] 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 3/5] 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 4/5] 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 5/5] 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] );