Skip to content

Commit

Permalink
Hide locations with no monitors in CNS page (#8812)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacobjeevan authored Oct 23, 2024
1 parent 160f745 commit 594c0d8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
2 changes: 2 additions & 0 deletions src/Locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,7 @@
"no_tests_taken": "No tests taken",
"no_treating_physicians_available": "This facility does not have any home facility doctors. Please contact your admin.",
"no_users_found": "No Users Found",
"no_vitals_present": "No Vitals Monitor present in this location or facility",
"none": "None",
"normal": "Normal",
"not_eligible": "Not Eligible",
Expand Down Expand Up @@ -1243,6 +1244,7 @@
"virtual_nursing_assistant": "Virtual Nursing Assistant",
"vitals": "Vitals",
"vitals_monitor": "Vitals Monitor",
"vitals_present": "Vitals Monitor present",
"ward": "Ward",
"warranty_amc_expiry": "Warranty / AMC Expiry",
"what_facility_assign_the_patient_to": "What facility would you like to assign the patient to",
Expand Down
8 changes: 8 additions & 0 deletions src/components/Common/LocationSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ interface LocationSelectProps {
selected: string | string[] | null;
setSelected: (selected: string | string[] | null) => void;
errorClassName?: string;
bedIsOccupied?: boolean;
disableOnOneOrFewer?: boolean;
}

export const LocationSelect = (props: LocationSelectProps) => {
Expand All @@ -23,6 +25,8 @@ export const LocationSelect = (props: LocationSelectProps) => {
{
query: {
limit: 14,
bed_is_occupied:
props.bedIsOccupied === undefined ? undefined : !props.bedIsOccupied,
},
pathParams: {
facility_external_id: props.facilityId,
Expand All @@ -31,6 +35,10 @@ export const LocationSelect = (props: LocationSelectProps) => {
},
);

if (props.disableOnOneOrFewer && data && data.count <= 1) {
props = { ...props, disabled: true };
}

return props.multiple ? (
<AutocompleteMultiSelectFormField
name={props.name}
Expand Down
29 changes: 17 additions & 12 deletions src/components/Facility/CentralNursingStation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ export default function CentralNursingStation({ facilityId }: Props) {
collapseSidebar
options={
<div className="flex flex-row-reverse items-center gap-4 md:flex-row">
<Pagination
className=""
cPage={qParams.page}
defaultPerPage={PER_PAGE_LIMIT}
data={{ totalCount }}
onChange={(page) => updatePage(page)}
/>
<Popover className="relative">
<PopoverButton>
<ButtonV2
Expand Down Expand Up @@ -109,8 +116,8 @@ export default function CentralNursingStation({ facilityId }: Props) {
<div className="rounded-t-lg bg-secondary-100 px-6 py-4">
<div className="flow-root rounded-md">
<span className="block text-sm text-secondary-800">
<span className="font-bold">{totalCount}</span> Vitals
Monitor present
<span className="font-bold">{totalCount}</span>{" "}
{t("vitals_present")}
</span>
</div>
</div>
Expand All @@ -134,6 +141,10 @@ export default function CentralNursingStation({ facilityId }: Props) {
facilityId={facilityId}
errors=""
errorClassName="hidden"
bedIsOccupied={JSON.parse(
qParams.monitors_without_patient ?? "false",
)}
disableOnOneOrFewer
/>
</div>
</div>
Expand Down Expand Up @@ -164,7 +175,9 @@ export default function CentralNursingStation({ facilityId }: Props) {
value={JSON.parse(
qParams.monitors_without_patient ?? "false",
)}
onChange={(e) => updateQuery({ [e.name]: `${e.value}` })}
onChange={(e) =>
updateQuery({ [e.name]: `${e.value}`, location: "" })
}
labelClassName="text-sm"
errorClassName="hidden"
/>
Expand All @@ -189,22 +202,14 @@ export default function CentralNursingStation({ facilityId }: Props) {
</PopoverPanel>
</Transition>
</Popover>

<Pagination
className=""
cPage={qParams.page}
defaultPerPage={PER_PAGE_LIMIT}
data={{ totalCount }}
onChange={(page) => updatePage(page)}
/>
</div>
}
>
{data === undefined || query.loading ? (
<Loading />
) : data.length === 0 ? (
<div className="flex h-[80vh] w-full items-center justify-center text-center text-black">
No Vitals Monitor present in this location or facility.
{t("no_vitals_present")}
</div>
) : (
<div className="3xl:grid-cols-3 mt-1 grid grid-cols-1 gap-1 lg:grid-cols-2">
Expand Down

0 comments on commit 594c0d8

Please sign in to comment.