Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup bed types #8456

Merged
merged 6 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cypress/e2e/facility_spec/FacilityCreation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ describe("Facility Creation", () => {
facilityPage.submitForm();
cy.closeNotification();
// create multiple bed capacity and verify card reflection
facilityPage.selectBedType("Oxygen beds");
facilityPage.selectBedType("Oxygen Supported Bed");
facilityPage.fillTotalCapacity(bedCapacity);
facilityPage.fillCurrentlyOccupied(bedOccupancy);
facilityPage.clickbedcapcityaddmore();
Expand Down Expand Up @@ -216,7 +216,7 @@ describe("Facility Creation", () => {
facilityPage.fillPhoneNumber(facilityNumber);
facilityPage.submitForm();
// add the bed capacity
facilityPage.selectBedType("Oxygen beds");
facilityPage.selectBedType("Oxygen Supported Bed");
facilityPage.fillTotalCapacity(oxygenCapacity);
facilityPage.fillCurrentlyOccupied(oxygenExpected);
facilityPage.saveAndExitBedCapacityForm();
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/facility_spec/FacilityManage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ describe("Facility Manage Functions", () => {
it("Modify bed capacity in Facility detail page", () => {
// add multiple new bed capacity
facilityManage.clickFacilityAddBedTypeButton();
facilityPage.selectBedType("Oxygen beds");
facilityPage.selectBedType("Isolation Bed");
facilityPage.fillTotalCapacity(totalCapacity);
facilityPage.fillCurrentlyOccupied(currentOccupied);
facilityPage.saveAndExitBedCapacityForm();
Expand Down
26 changes: 1 addition & 25 deletions src/Common/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
ConsentHIType,
ConsentPurpose,
} from "../Components/ABDM/types/consent";
import careConfig from "@careConfig";

export const RESULTS_PER_PAGE_LIMIT = 14;
export const PAGINATION_LIMIT = 36;
Expand Down Expand Up @@ -217,30 +216,7 @@ export const DISCHARGED_PATIENT_SORT_OPTIONS: SortOption[] = [
{ isAscending: false, value: "-name" },
];

const { kasp } = careConfig;

const KASP_BED_TYPES = kasp.enabled
? [
{ id: 40, text: kasp.string + " Ordinary Beds" },
{ id: 60, text: kasp.string + " Oxygen beds" },
{ id: 50, text: kasp.string + " ICU (ICU without ventilator)" },
{ id: 70, text: kasp.string + " ICU (ICU with ventilator)" },
]
: [];

export const BED_TYPES: OptionsType[] = [
{ id: 1, text: "Ordinary Beds" },
{ id: 150, text: "Oxygen beds" },
{ id: 10, text: "ICU (ICU without ventilator)" },
{ id: 20, text: "Ventilator (ICU with ventilator)" },
{ id: 30, text: "Covid Ordinary Beds" },
{ id: 120, text: "Covid Oxygen beds" },
{ id: 110, text: "Covid ICU (ICU without ventilator)" },
{ id: 100, text: "Covid Ventilators (ICU with ventilator)" },
...KASP_BED_TYPES,
{ id: 2, text: "Hostel" },
{ id: 3, text: "Single Room with Attached Bathroom" },
];
export const BED_TYPES = [100, 200, 300, 400, 500];

export const DOCTOR_SPECIALIZATION: Array<OptionsType> = [
{ id: 1, text: "General Medicine" },
Expand Down
16 changes: 10 additions & 6 deletions src/Components/Facility/BedCapacity.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { useEffect, useReducer, useState } from "react";
import * as Notification from "../../Utils/Notifications.js";
import { CapacityModal } from "./models";
import { CapacityModal, OptionsType } from "./models";
import TextFormField from "../Form/FormFields/TextFormField";
import { Cancel, Submit } from "../Common/components/ButtonV2";
import { SelectFormField } from "../Form/FormFields/SelectFormField";
import { FieldChangeEvent } from "../Form/FormFields/Utils";
import { BED_TYPES } from "../../Common/constants";
import routes from "../../Redux/api";
import request from "../../Utils/request/request";
import { useTranslation } from "react-i18next";
import { BED_TYPES } from "../../Common/constants.js";

interface BedCapacityProps extends CapacityModal {
facilityId: string;
Expand Down Expand Up @@ -52,8 +52,10 @@ export const BedCapacity = (props: BedCapacityProps) => {
const { t } = useTranslation();
const { facilityId, handleClose, handleUpdate, className, id } = props;
const [state, dispatch] = useReducer(bedCountReducer, initialState);
const [bedTypes, setBedTypes] = useState(BED_TYPES);
const [isLastOptionType, setIsLastOptionType] = useState(false);
const [bedTypes, setBedTypes] = useState<OptionsType[]>(
BED_TYPES.map((o) => ({ id: o, text: t(`bed_type__${o}`) })),
);
const [isLoading, setIsLoading] = useState(false);

const headerText = !id ? "Add Bed Capacity" : "Edit Bed Capacity";
Expand All @@ -77,10 +79,11 @@ export const BedCapacity = (props: BedCapacityProps) => {
// disable existing bed types
const updatedBedTypes = BED_TYPES.map((type) => {
const isExisting = existingData.find(
(i: CapacityModal) => i.room_type === type.id,
(i: CapacityModal) => i.room_type === type,
);
return {
...type,
id: type,
text: t(`bed_type__${type}`),
disabled: !!isExisting,
};
});
Expand Down Expand Up @@ -111,7 +114,8 @@ export const BedCapacity = (props: BedCapacityProps) => {

useEffect(() => {
const lastBedType =
bedTypes.filter((i) => i.disabled).length === BED_TYPES.length - 1;
bedTypes.filter((i: OptionsType) => i.disabled).length ===
BED_TYPES.length - 1;
setIsLastOptionType(lastBedType);
}, [bedTypes]);

Expand Down
9 changes: 6 additions & 3 deletions src/Components/Facility/FacilityBedCapacity.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useState } from "react";
import { BED_TYPES } from "../../Common/constants";
import routes from "../../Redux/api";
import { NonReadOnlyUsers } from "../../Utils/AuthorizeFor";
import useQuery from "../../Utils/request/useQuery";
Expand All @@ -7,9 +8,11 @@ import ButtonV2 from "../Common/components/ButtonV2";
import { BedCapacity } from "./BedCapacity";
import BedTypeCard from "./BedTypeCard";
import CareIcon from "../../CAREUI/icons/CareIcon";
import { BED_TYPES } from "../../Common/constants";
import { useTranslation } from "react-i18next";

export const FacilityBedCapacity = (props: any) => {
const { t } = useTranslation();

const [bedCapacityModalOpen, setBedCapacityModalOpen] = useState(false);

const capacityQuery = useQuery(routes.getCapacity, {
Expand Down Expand Up @@ -45,7 +48,7 @@ export const FacilityBedCapacity = (props: any) => {
/>
{BED_TYPES.map((x) => {
const res = capacityQuery.data?.results.find((data) => {
return data.room_type === x.id;
return data.room_type === x;
});
if (
res &&
Expand All @@ -64,7 +67,7 @@ export const FacilityBedCapacity = (props: any) => {
bedCapacityId={res.id}
key={`bed_${res.id}`}
room_type={res.room_type}
label={x.text}
label={t(`bed_type__${x}`)}
used={res.current_capacity}
total={res.total_capacity}
lastUpdated={res.modified_date}
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Facility/FacilityCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ export const FacilityCreate = (props: FacilityProps) => {
/>
{BED_TYPES.map((x) => {
const res = capacityData.find((data) => {
return data.room_type === x.id;
return data.room_type === x;
});
if (res) {
const removeCurrentBedType = (bedTypeId: number | undefined) => {
Expand All @@ -579,7 +579,7 @@ export const FacilityCreate = (props: FacilityProps) => {
bedCapacityId={res.id}
key={`bed_${res.id}`}
room_type={res.room_type}
label={x.text}
label={t(`bed_type__${x}`)}
used={res.current_capacity || 0}
total={res.total_capacity || 0}
lastUpdated={res.modified_date}
Expand Down
5 changes: 5 additions & 0 deletions src/Locale/en/Facility.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@
"duplicate_patient_record_birth_unknown": "Please contact your district care coordinator, the shifting facility or the patient themselves if you are not sure about the patient's year of birth.",
"patient_transfer_birth_match_note": "Note: Year of birth must match the patient to process the transfer request.",
"cover_image_updated_note": "It could take a while to see the updated cover image",
"bed_type__100": "ICU Bed",
"bed_type__200": "Ordinary Bed",
"bed_type__300": "Oxygen Supported Bed",
"bed_type__400": "Isolation Bed",
"bed_type__500": "Others",
"available_features": "Available Features",
"update_facility": "Update Facility",
"configure_facility": "Configure Facility",
Expand Down
Loading