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

Fix patient category selection #3741

Merged
merged 6 commits into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
8 changes: 4 additions & 4 deletions src/Common/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,10 @@ export const PATIENT_FILTER_ADMITTED_TO = [
];

export const PATIENT_CATEGORIES = [
"Comfort Care",
"Stable",
"Slightly Abnormal",
"Critical",
{ id: "Comfort", text: "Comfort Care" },
{ id: "Stable", text: "Stable" },
{ id: "Moderate", text: "Slightly Abnormal" },
{ id: "Critical", text: "Critical" },
];

export const PATIENT_FILTER_CATEGORIES = PATIENT_CATEGORIES;
Expand Down
17 changes: 8 additions & 9 deletions src/Components/Facility/ConsultationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const initForm: FormDetails = {
facility: "",
admitted: "false",
admitted_to: "",
category: "Comfort Care",
category: "Comfort",
admission_date: new Date().toISOString(),
discharge_date: null,
referred_to: "",
Expand Down Expand Up @@ -264,7 +264,9 @@ export const ConsultationForm = (props: any) => {
!!res.data.symptoms.filter((i: number) => i === 9).length,
admitted: res.data.admitted ? String(res.data.admitted) : "false",
admitted_to: res.data.admitted_to ? res.data.admitted_to : "",
category: res.data.category || "Comfort Care",
category: res.data.category
? PATIENT_CATEGORIES.find((i) => i.text === res.data.category)?.id
khavinshankar marked this conversation as resolved.
Show resolved Hide resolved
: "Comfort",
ip_no: res.data.ip_no ? res.data.ip_no : "",
verified_by: res.data.verified_by ? res.data.verified_by : "",
OPconsultation: res.data.consultation_notes,
Expand Down Expand Up @@ -313,7 +315,9 @@ export const ConsultationForm = (props: any) => {
case "category":
if (
!state.form[field] ||
!PATIENT_CATEGORIES.includes(state.form[field])
!PATIENT_CATEGORIES.map((category) => category.id).includes(
state.form[field]
)
) {
errors[field] = "Please select a category";
if (!error_div) error_div = field;
Expand Down Expand Up @@ -773,12 +777,7 @@ export const ConsultationForm = (props: any) => {
name="category"
variant="standard"
value={state.form.category}
options={PATIENT_CATEGORIES.map((c) => {
return {
id: c,
text: c,
};
})}
options={PATIENT_CATEGORIES}
onChange={handleChange}
errors={state.errors.category}
/>
Expand Down
16 changes: 12 additions & 4 deletions src/Components/Patient/DailyRounds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const initForm: any = {
other_symptoms: "",
physical_examination_info: "",
other_details: "",
patient_category: "Comfort Care",
patient_category: "Comfort",
current_health: 0,
recommend_discharge: false,
actions: null,
Expand Down Expand Up @@ -122,6 +122,11 @@ export const DailyRounds = (props: any) => {
if (res && res.data) {
const data = {
...res.data,
patient_category: res.data.patient_category
? PATIENT_CATEGORIES.find(
(i) => i.text === res.data.patient_category
)?.id
khavinshankar marked this conversation as resolved.
Show resolved Hide resolved
: "Comfort",
admitted_to: res.data.admitted_to ? res.data.admitted_to : "Select",
};
dispatch({ type: "set_form", form: data });
Expand Down Expand Up @@ -171,6 +176,11 @@ export const DailyRounds = (props: any) => {
type: "set_form",
form: {
...state.form,
patient_category: res.data.patient_category
? PATIENT_CATEGORIES.find(
(i) => i.text === res.data.patient_category
)?.id
khavinshankar marked this conversation as resolved.
Show resolved Hide resolved
: "Comfort",
clone_last: res.data.count > 0 ? "true" : "false",
},
});
Expand Down Expand Up @@ -534,9 +544,7 @@ export const DailyRounds = (props: any) => {
variant="standard"
margin="dense"
value={state.form.patient_category}
options={PATIENT_CATEGORIES.map((c) => {
return { id: c, text: c };
})}
options={PATIENT_CATEGORIES}
onChange={handleChange}
errors={state.errors.patient_category}
/>
Expand Down
4 changes: 1 addition & 3 deletions src/Components/Patient/PatientFilterV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,7 @@ export default function PatientFilterV2(props: any) {
value={filterState.category}
options={[
{ id: "", text: "Show All" },
...PATIENT_FILTER_CATEGORIES.map((o) => {
return { id: o, text: o };
}),
...PATIENT_FILTER_CATEGORIES,
]}
onChange={handleChange}
className="bg-white h-10 shadow-sm md:text-sm md:leading-5 md:h-9"
Expand Down