Skip to content

Commit

Permalink
feat: added admitted bed type filter (#3963)
Browse files Browse the repository at this point in the history
* feat(patient): added admitted bed type filter

* fix(patient): modified bed type options for user friendly

* fix(patient): removed unwated bed types

* fix(patient): fixed applied filter badges not visible

* Update src/Components/Patient/ManagePatients.tsx

Co-authored-by: Khavin Shankar <khavinshankar@gmail.com>
  • Loading branch information
aeswibon and khavinshankar authored Dec 7, 2022
1 parent 1e413e2 commit cecd205
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 44 deletions.
18 changes: 3 additions & 15 deletions src/Common/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,22 +258,10 @@ export const CONSULTATION_SUGGESTION = [
];

export const ADMITTED_TO = [
"Home Isolation",
"Isolation Room",
"Bed with Oxygen Support",
"ICU",
"ICU with Oxygen Support",
"ICU with Non Invasive Ventilator",
"ICU with Invasive Ventilator",
"Gynaecology Ward",
"Paediatric Ward",
];

export const PATIENT_FILTER_ADMITTED_TO = [
{ id: "0", text: "Not admitted" },
{ id: "1", text: "Isolation Room" },
{ id: "6", text: "Bed with Oxygen Support" },
{ id: "1", text: "Isolation" },
{ id: "2", text: "ICU" },
{ id: "6", text: "Bed with oxygen support" },
{ id: "7", text: "Regular" },
];

export const PATIENT_CATEGORIES = [
Expand Down
22 changes: 9 additions & 13 deletions src/Components/Patient/ManagePatients.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
ADMITTED_TO,
GENDER_TYPES,
TELEMEDICINE_ACTIONS,
PATIENT_FILTER_ADMITTED_TO,
PatientCategoryTailwindClass,
} from "../../Common/constants";
import { make as SlideOver } from "../Common/SlideOver.gen";
Expand Down Expand Up @@ -141,8 +140,8 @@ export const PatientManager = (props: any) => {
qParams.last_consultation_discharge_date_before || undefined,
last_consultation_discharge_date_after:
qParams.last_consultation_discharge_date_after || undefined,
last_consultation_admitted_to_list:
qParams.last_consultation_admitted_to_list || undefined,
last_consultation_admitted_bed_type_list:
qParams.last_consultation_admitted_bed_type_list || undefined,
srf_id: qParams.srf_id || undefined,
number_of_doses: qParams.number_of_doses || undefined,
covin_id: qParams.covin_id || undefined,
Expand Down Expand Up @@ -251,7 +250,7 @@ export const PatientManager = (props: any) => {
qParams.last_consultation_discharge_date_after,
qParams.age_max,
qParams.age_min,
qParams.last_consultation_admitted_to_list,
qParams.last_consultation_admitted_bed_type_list,
qParams.facility,
qParams.facility_type,
qParams.district,
Expand Down Expand Up @@ -355,32 +354,29 @@ export const PatientManager = (props: any) => {
<i
className="fas fa-times ml-2 rounded-full cursor-pointer hover:bg-gray-500 px-1 py-0.5"
onClick={(_) => {
const lcat = qParams.last_consultation_admitted_to_list
const lcat = qParams.last_consultation_admitted_bed_type_list
.split(",")
.filter((x: string) => x != id)
.join(",");
updateQuery({
...qParams,
last_consultation_admitted_to_list: lcat,
last_consultation_admitted_bed_type_list: lcat,
});
}}
></i>
</span>
)
);
};

return qParams.last_consultation_admitted_to_list
return qParams.last_consultation_admitted_bed_type_list
.split(",")
.map((id: string) => {
const text = PATIENT_FILTER_ADMITTED_TO.find(
(obj) => obj.id == id
)?.text;
const text = ADMITTED_TO.find((obj) => obj.id == id)?.text;
return badge("Bed Type", text, id);
});
};

let patientList: any[] = [];
let patientList: React.ReactNode[] = [];
if (data && data.length) {
patientList = data.map((patient: any) => {
let patientUrl = "";
Expand Down Expand Up @@ -855,7 +851,7 @@ export const PatientManager = (props: any) => {
},
]}
/>
{qParams.last_consultation_admitted_to_list &&
{qParams.last_consultation_admitted_bed_type_list &&
LastAdmittedToTypeBadges()}
</div>
<div>
Expand Down
26 changes: 12 additions & 14 deletions src/Components/Patient/PatientFilterV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
FACILITY_TYPES,
DISEASE_STATUS,
PATIENT_FILTER_CATEGORIES,
PATIENT_FILTER_ADMITTED_TO,
KASP_STRING,
KASP_ENABLED,
ADMITTED_TO,
} from "../../Common/constants";
import moment from "moment";
import {
Expand Down Expand Up @@ -78,9 +78,9 @@ export default function PatientFilterV2(props: any) {
filter.last_consultation_discharge_date_before || null,
last_consultation_discharge_date_after:
filter.last_consultation_discharge_date_after || null,
last_consultation_admitted_to_list:
filter.last_consultation_admitted_to_list
? filter.last_consultation_admitted_to_list.split(",")
last_consultation_admitted_bed_type_list:
filter.last_consultation_admitted_bed_type_list
? filter.last_consultation_admitted_bed_type_list.split(",")
: [],
srf_id: filter.srf_id || null,
number_of_doses: filter.number_of_doses || null,
Expand Down Expand Up @@ -228,7 +228,7 @@ export default function PatientFilterV2(props: any) {
last_consultation_admission_date_after,
last_consultation_discharge_date_before,
last_consultation_discharge_date_after,
last_consultation_admitted_to_list,
last_consultation_admitted_bed_type_list,
number_of_doses,
covin_id,
srf_id,
Expand Down Expand Up @@ -311,8 +311,8 @@ export default function PatientFilterV2(props: any) {
(disease_status == "Show All" ? "" : disease_status) || "",
age_min: age_min || "",
age_max: age_max || "",
last_consultation_admitted_to_list:
last_consultation_admitted_to_list || [],
last_consultation_admitted_bed_type_list:
last_consultation_admitted_bed_type_list || [],
srf_id: srf_id || "",
number_of_doses: number_of_doses || "",
covin_id: covin_id || "",
Expand Down Expand Up @@ -592,20 +592,18 @@ export default function PatientFilterV2(props: any) {
/>
</div>
<div className="w-full flex-none">
<FieldLabel className="text-sm">
Last Admitted to (Bed Type)
</FieldLabel>
<FieldLabel className="text-sm">Admitted to (Bed Types)</FieldLabel>
<MultiSelectMenuV2
id="last_consultation_admitted_to_list"
id="last_consultation_admitted_bed_type_list"
placeholder="Select bed types"
options={PATIENT_FILTER_ADMITTED_TO}
value={filterState.last_consultation_admitted_to_list}
options={ADMITTED_TO}
value={filterState.last_consultation_admitted_bed_type_list}
optionValue={(o) => o.id}
optionLabel={(o) => o.text}
onChange={(o) =>
setFilterState({
...filterState,
last_consultation_admitted_to_list: o,
last_consultation_admitted_bed_type_list: o,
})
}
/>
Expand Down
4 changes: 2 additions & 2 deletions src/stories/care_ui/MultiSelectMenu.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ComponentStory } from "@storybook/react";
import { useState } from "react";
import { PATIENT_FILTER_ADMITTED_TO } from "../../Common/constants";
import { ADMITTED_TO } from "../../Common/constants";
import MultiSelectMenuV2 from "../../Components/Form/MultiSelectMenuV2";

export default {
Expand All @@ -24,7 +24,7 @@ export const MultiSelectMenu = Template.bind({});
MultiSelectMenu.args = {
placeholder: "Show all",
className: "w-72",
options: PATIENT_FILTER_ADMITTED_TO,
options: ADMITTED_TO,
optionLabel: (option: any) => option.text,
optionIcon: (option: any) => <i className="text-base">{option.icon}</i>,
optionValue: (option: any) => option.id,
Expand Down

0 comments on commit cecd205

Please sign in to comment.