Skip to content

Commit

Permalink
added patient code status descriptions for ICU beds
Browse files Browse the repository at this point in the history
  • Loading branch information
shivankacker committed Jun 3, 2024
1 parent fa5e3e6 commit 450316e
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
29 changes: 25 additions & 4 deletions src/Common/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/Components/Facility/ConsultationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<BedModel | null>(null);
const isUpdate = !!id;

const [currentSection, setCurrentSection] = useState<ConsultationFormSection>(
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -1134,6 +1137,7 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => {
</p>
)
}
hideDescription={patientBed?.bed_type !== "ICU"}
required
label="Category"
{...field("category")}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Form/FormFields/SelectFormField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { FormFieldBaseProps, useFormFieldPropsResolver } from "./Utils";

type OptionCallback<T, R> = (option: T) => R;

type SelectFormFieldProps<T, V = T> = FormFieldBaseProps<V> & {
export type SelectFormFieldProps<T, V = T> = FormFieldBaseProps<V> & {
placeholder?: React.ReactNode;
options: readonly T[];
position?: "above" | "below";
Expand Down
5 changes: 4 additions & 1 deletion src/Components/Patient/PatientCategorySelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { FormFieldBaseProps } from "../Form/FormFields/Utils";
* field.
*/
export default function PatientCategorySelect(
props: FormFieldBaseProps<PatientCategoryID>,
props: FormFieldBaseProps<PatientCategoryID> & { hideDescription?: boolean },
) {
return (
<SelectFormField
Expand All @@ -17,6 +17,9 @@ export default function PatientCategorySelect(
options={PATIENT_CATEGORIES}
optionValue={(option) => option.id}
optionLabel={(option) => option.text}
optionDescription={
props.hideDescription ? undefined : (option) => option.description
}
optionSelectedLabel={(option) => (
<span className="flex items-center gap-3">
<div
Expand Down

0 comments on commit 450316e

Please sign in to comment.