From 450316e3cfc4d0b444e93990b128957859e2dd35 Mon Sep 17 00:00:00 2001 From: Shivank Kacker Date: Tue, 4 Jun 2024 02:33:09 +0530 Subject: [PATCH 1/4] added patient code status descriptions for ICU beds --- src/Common/constants.tsx | 29 ++++++++++++++++--- src/Components/Facility/ConsultationForm.tsx | 4 +++ .../Form/FormFields/SelectFormField.tsx | 2 +- .../Patient/PatientCategorySelect.tsx | 5 +++- 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/Common/constants.tsx b/src/Common/constants.tsx index f0d0ab08f0..1287fdb999 100644 --- a/src/Common/constants.tsx +++ b/src/Common/constants.tsx @@ -392,12 +392,33 @@ export type PatientCategoryID = "Comfort" | "Stable" | "Moderate" | "Critical"; export const PATIENT_CATEGORIES: { id: PatientCategoryID; text: PatientCategory; + description: string; twClass: string; }[] = [ - { id: "Comfort", text: "Comfort Care", twClass: "patient-comfort" }, - { id: "Stable", text: "Mild", twClass: "patient-stable" }, - { id: "Moderate", text: "Moderate", twClass: "patient-abnormal" }, - { id: "Critical", text: "Critical", twClass: "patient-critical" }, + { + id: "Comfort", + text: "Comfort Care", + twClass: "patient-comfort", + description: "End of life care", + }, + { + id: "Stable", + text: "Mild", + twClass: "patient-stable", + description: "Urgent: not life-threatening", + }, + { + id: "Moderate", + text: "Moderate", + twClass: "patient-abnormal", + description: "Emergency: could be life-threatening", + }, + { + id: "Critical", + text: "Critical", + twClass: "patient-critical", + description: "Immediate: life-threatening", + }, ]; export const PATIENT_FILTER_CATEGORIES = PATIENT_CATEGORIES; diff --git a/src/Components/Facility/ConsultationForm.tsx b/src/Components/Facility/ConsultationForm.tsx index a5e333e43c..b9883b8acf 100644 --- a/src/Components/Facility/ConsultationForm.tsx +++ b/src/Components/Facility/ConsultationForm.tsx @@ -244,6 +244,7 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => { const [isLoading, setIsLoading] = useState(false); const [patientName, setPatientName] = useState(""); const [facilityName, setFacilityName] = useState(""); + const [patientBed, setPatientBed] = useState(null); const isUpdate = !!id; const [currentSection, setCurrentSection] = useState( @@ -353,6 +354,8 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => { prefetch: !!(id && ((patientId && patientName) || !patientId)), onResponse: ({ data }) => { if (!data) return; + data.current_bed?.bed_object && + setPatientBed(data.current_bed?.bed_object); handleFormFieldChange({ name: "InvestigationAdvice", value: @@ -1134,6 +1137,7 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => {

) } + hideDescription={patientBed?.bed_type !== "ICU"} required label="Category" {...field("category")} diff --git a/src/Components/Form/FormFields/SelectFormField.tsx b/src/Components/Form/FormFields/SelectFormField.tsx index 47c2877736..3e0d4efdec 100644 --- a/src/Components/Form/FormFields/SelectFormField.tsx +++ b/src/Components/Form/FormFields/SelectFormField.tsx @@ -5,7 +5,7 @@ import { FormFieldBaseProps, useFormFieldPropsResolver } from "./Utils"; type OptionCallback = (option: T) => R; -type SelectFormFieldProps = FormFieldBaseProps & { +export type SelectFormFieldProps = FormFieldBaseProps & { placeholder?: React.ReactNode; options: readonly T[]; position?: "above" | "below"; diff --git a/src/Components/Patient/PatientCategorySelect.tsx b/src/Components/Patient/PatientCategorySelect.tsx index 4d159529f4..85a479e071 100644 --- a/src/Components/Patient/PatientCategorySelect.tsx +++ b/src/Components/Patient/PatientCategorySelect.tsx @@ -8,7 +8,7 @@ import { FormFieldBaseProps } from "../Form/FormFields/Utils"; * field. */ export default function PatientCategorySelect( - props: FormFieldBaseProps, + props: FormFieldBaseProps & { hideDescription?: boolean }, ) { return ( option.id} optionLabel={(option) => option.text} + optionDescription={ + props.hideDescription ? undefined : (option) => option.description + } optionSelectedLabel={(option) => (
Date: Tue, 4 Jun 2024 02:45:12 +0530 Subject: [PATCH 2/4] remove unused export --- src/Components/Form/FormFields/SelectFormField.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Form/FormFields/SelectFormField.tsx b/src/Components/Form/FormFields/SelectFormField.tsx index 3e0d4efdec..47c2877736 100644 --- a/src/Components/Form/FormFields/SelectFormField.tsx +++ b/src/Components/Form/FormFields/SelectFormField.tsx @@ -5,7 +5,7 @@ import { FormFieldBaseProps, useFormFieldPropsResolver } from "./Utils"; type OptionCallback = (option: T) => R; -export type SelectFormFieldProps = FormFieldBaseProps & { +type SelectFormFieldProps = FormFieldBaseProps & { placeholder?: React.ReactNode; options: readonly T[]; position?: "above" | "below"; From 0a65cebb1822bfb44f4dab2469f3b95d51d363d5 Mon Sep 17 00:00:00 2001 From: Shivank Kacker Date: Wed, 5 Jun 2024 16:32:19 +0530 Subject: [PATCH 3/4] brought category select below bed --- src/Components/Facility/ConsultationForm.tsx | 34 +++++++++----------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/Components/Facility/ConsultationForm.tsx b/src/Components/Facility/ConsultationForm.tsx index b9883b8acf..dbfd05f1e1 100644 --- a/src/Components/Facility/ConsultationForm.tsx +++ b/src/Components/Facility/ConsultationForm.tsx @@ -1127,23 +1127,6 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => { />
- -
- - A daily round already exists. -

- ) - } - hideDescription={patientBed?.bed_type !== "ICU"} - required - label="Category" - {...field("category")} - /> -
-
{
)} -
+
{ required={state.form.suggestion === "A"} />
+
+ + A daily round already exists. +

+ ) + } + hideDescription={patientBed?.bed_type !== "ICU"} + required + label="Category" + {...field("category")} + /> +
From b31fcc2c9c219c3c3ea27b7671e2fa3de3e0ab5d Mon Sep 17 00:00:00 2001 From: Shivank Kacker Date: Wed, 5 Jun 2024 23:25:01 +0530 Subject: [PATCH 4/4] fixes everywhere else --- src/Components/Facility/ConsultationForm.tsx | 9 +++++---- src/Components/Patient/DailyRounds.tsx | 6 ++++++ src/Components/Patient/ShiftCreate.tsx | 5 +++++ src/Components/Shifting/ShiftDetailsUpdate.tsx | 3 +++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/Components/Facility/ConsultationForm.tsx b/src/Components/Facility/ConsultationForm.tsx index dbfd05f1e1..780f572d20 100644 --- a/src/Components/Facility/ConsultationForm.tsx +++ b/src/Components/Facility/ConsultationForm.tsx @@ -244,7 +244,6 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => { const [isLoading, setIsLoading] = useState(false); const [patientName, setPatientName] = useState(""); const [facilityName, setFacilityName] = useState(""); - const [patientBed, setPatientBed] = useState(null); const isUpdate = !!id; const [currentSection, setCurrentSection] = useState( @@ -354,8 +353,6 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => { prefetch: !!(id && ((patientId && patientName) || !patientId)), onResponse: ({ data }) => { if (!data) return; - data.current_bed?.bed_object && - setPatientBed(data.current_bed?.bed_object); handleFormFieldChange({ name: "InvestigationAdvice", value: @@ -1300,7 +1297,11 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => {

) } - hideDescription={patientBed?.bed_type !== "ICU"} + hideDescription={ + (Array.isArray(bed) + ? bed[0].bed_type + : bed?.bed_type) !== "ICU" + } required label="Category" {...field("category")} diff --git a/src/Components/Patient/DailyRounds.tsx b/src/Components/Patient/DailyRounds.tsx index 35e9828f9d..88c2c820ff 100644 --- a/src/Components/Patient/DailyRounds.tsx +++ b/src/Components/Patient/DailyRounds.tsx @@ -121,6 +121,7 @@ export const DailyRounds = (props: any) => { const [isLoading, setIsLoading] = useState(false); const [facilityName, setFacilityName] = useState(""); const [patientName, setPatientName] = useState(""); + const [bedType, setBedType] = useState(""); const [consultationSuggestion, setConsultationSuggestion] = useState(""); const [prevReviewInterval, setPreviousReviewInterval] = useState(-1); const [prevAction, setPreviousAction] = useState("NO_ACTION"); @@ -180,6 +181,9 @@ export const DailyRounds = (props: any) => { if (data) { setPatientName(data.name!); setFacilityName(data.facility_object!.name); + setBedType( + data.last_consultation?.current_bed?.bed_object?.bed_type || "", + ); setConsultationSuggestion(data.last_consultation?.suggestion); setDiagnoses( data.last_consultation?.diagnoses?.sort( @@ -206,6 +210,7 @@ export const DailyRounds = (props: any) => { }; } } else { + setBedType(""); setPatientName(""); setFacilityName(""); } @@ -495,6 +500,7 @@ export const DailyRounds = (props: any) => {
diff --git a/src/Components/Patient/ShiftCreate.tsx b/src/Components/Patient/ShiftCreate.tsx index 7307727d37..cc3a8d6063 100644 --- a/src/Components/Patient/ShiftCreate.tsx +++ b/src/Components/Patient/ShiftCreate.tsx @@ -43,6 +43,7 @@ export const ShiftCreate = (props: patientShiftProps) => { const { facilityId, patientId } = props; const [isLoading, setIsLoading] = useState(false); const [patientCategory, setPatientCategory] = useState(); + const [bedType, setBedType] = useState(""); const { t } = useTranslation(); const { wartime_shifting } = useConfig(); @@ -120,6 +121,9 @@ export const ShiftCreate = (props: patientShiftProps) => { setPatientCategory( PATIENT_CATEGORIES.find((c) => c.text === patient_category)?.id, ); + setBedType( + data.last_consultation?.current_bed?.bed_object.bed_type || "", + ); } }, }); @@ -331,6 +335,7 @@ export const ShiftCreate = (props: patientShiftProps) => { setPatientCategory(e.value)} label="Patient Category" diff --git a/src/Components/Shifting/ShiftDetailsUpdate.tsx b/src/Components/Shifting/ShiftDetailsUpdate.tsx index d327e40288..b27a4f6d8f 100644 --- a/src/Components/Shifting/ShiftDetailsUpdate.tsx +++ b/src/Components/Shifting/ShiftDetailsUpdate.tsx @@ -399,6 +399,9 @@ export const ShiftDetailsUpdate = (props: patientShiftProps) => { required={true} name="patient_category" value={state.form.patient_category} + hideDescription={ + consultationData.current_bed?.bed_object.bed_type !== "ICU" + } onChange={handleFormFieldChange} label="Patient Category" className="md:col-span-2"