Skip to content

Commit

Permalink
Patient Registration: Adds social profile section (#8570)
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad authored and khavinshankar committed Sep 23, 2024
1 parent d44d891 commit 92acdc9
Show file tree
Hide file tree
Showing 10 changed files with 196 additions and 39 deletions.
4 changes: 4 additions & 0 deletions cypress/e2e/patient_spec/PatientRegistration.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ describe("Patient Creation with consultation", () => {
facilityPage.selectLocalBody(patientOneLocalbody);
facilityPage.selectWard(patientOneWard);
patientPage.selectPatientOccupation(patientOccupation);
patientPage.selectSocioeconomicStatus("MIDDLE_CLASS");
patientPage.selectDomesticHealthcareSupport("FAMILY_MEMBER");
// Patient Medical History
patientMedicalHistory.typePatientPresentHealth(patientOnePresentHealth);
patientMedicalHistory.typePatientOngoingMedication(
Expand Down Expand Up @@ -131,6 +133,8 @@ describe("Patient Creation with consultation", () => {
yearOfBirth,
patientOneBloodGroup,
patientOccupation,
"Middle Class",
"Family member",
);
patientMedicalHistory.verifyPatientMedicalDetails(
patientOnePresentHealth,
Expand Down
13 changes: 13 additions & 0 deletions cypress/pageobject/Patient/PatientCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ export class PatientPage {
cy.searchAndSelectOption("#occupation", occupation);
}

selectSocioeconomicStatus(value: string) {
cy.selectRadioOption("socioeconomic_status", value);
}

selectDomesticHealthcareSupport(value: string) {
cy.selectRadioOption("domestic_healthcare_support", value);
}

clickCreatePatient() {
cy.intercept("POST", "**/api/v1/patient/").as("createPatient");
cy.get("button[data-testid='submit-button']").click();
Expand Down Expand Up @@ -165,6 +173,8 @@ export class PatientPage {
yearOfBirth,
bloodGroup,
occupation,
socioeconomicStatus = null,
domesticHealthcareSupport = null,
isAntenatal = false,
isPostPartum = false,
) {
Expand All @@ -178,6 +188,9 @@ export class PatientPage {
expect($dashboard).to.contain(yearOfBirth);
expect($dashboard).to.contain(bloodGroup);
expect($dashboard).to.contain(occupation);
socioeconomicStatus && expect($dashboard).to.contain(socioeconomicStatus);
domesticHealthcareSupport &&
expect($dashboard).to.contain(domesticHealthcareSupport);

if (isAntenatal) {
expect($dashboard).to.contain("Antenatal");
Expand Down
4 changes: 4 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ Cypress.Commands.add(
},
);

Cypress.Commands.add("selectRadioOption", (name: string, value: string) => {
cy.get(`input[type='radio'][name='${name}'][value=${value}]`).click();
});

Cypress.Commands.add("clickAndTypeDate", (selector: string, date: string) => {
cy.get(selector).scrollIntoView();
cy.get(selector).click();
Expand Down
1 change: 1 addition & 0 deletions cypress/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ declare global {
selector: string,
symptoms: string | string[],
): Chainable<Element>;
selectRadioOption(name: string, value: string): Chainable<Element>;
typeAndMultiSelectOption(
selector: string,
input: string,
Expand Down
14 changes: 14 additions & 0 deletions src/Common/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1415,6 +1415,20 @@ export const CONSENT_PATIENT_CODE_STATUS_CHOICES = [
{ id: 3, text: "Comfort Care Only" },
{ id: 4, text: "Active treatment" },
];

export const SOCIOECONOMIC_STATUS_CHOICES = [
"MIDDLE_CLASS",
"POOR",
"VERY_POOR",
"WELL_OFF",
] as const;

export const DOMESTIC_HEALTHCARE_SUPPORT_CHOICES = [
"FAMILY_MEMBER",
"PAID_CAREGIVER",
"NO_SUPPORT",
] as const;

export const OCCUPATION_TYPES = [
{
id: 27,
Expand Down
54 changes: 40 additions & 14 deletions src/Components/Patient/PatientHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -515,24 +515,50 @@ export const PatientHome = (props: any) => {
</div>
</div>
)}
<div className="sm:col-span-1">
<div className="text-sm font-semibold leading-5 text-zinc-400">
Occupation
{patientData.meta_info?.occupation && (
<div className="sm:col-span-1">
<div className="text-sm font-semibold leading-5 text-zinc-400">
{t("occupation")}
</div>
<div className="mt-1 text-sm font-medium leading-5">
{parseOccupation(patientData.meta_info.occupation)}
</div>
</div>
<div className="mt-1 text-sm font-medium leading-5">
{parseOccupation(patientData.meta_info?.occupation) || "-"}
)}
{patientData.ration_card_category && (
<div className="sm:col-span-1">
<div className="text-sm font-semibold leading-5 text-zinc-400">
{t("ration_card_category")}
</div>
<div className="mt-1 text-sm font-medium leading-5">
{t(`ration_card__${patientData.ration_card_category}`)}
</div>
</div>
</div>
<div className="sm:col-span-1">
<div className="text-sm font-semibold leading-5 text-zinc-400">
Ration Card Category
)}
{patientData.meta_info?.socioeconomic_status && (
<div className="sm:col-span-1">
<div className="text-sm font-semibold leading-5 text-zinc-400">
{t("socioeconomic_status")}
</div>
<div className="mt-1 text-sm font-medium leading-5">
{t(
`SOCIOECONOMIC_STATUS__${patientData.meta_info.socioeconomic_status}`,
)}
</div>
</div>
<div className="mt-1 text-sm font-medium leading-5">
{patientData.ration_card_category
? t(`ration_card__${patientData.ration_card_category}`)
: "-"}
)}
{patientData.meta_info?.domestic_healthcare_support && (
<div className="sm:col-span-1">
<div className="text-sm font-semibold leading-5 text-zinc-400">
{t("domestic_healthcare_support")}
</div>
<div className="mt-1 text-sm font-medium leading-5">
{t(
`DOMESTIC_HEALTHCARE_SUPPORT__${patientData.meta_info.domestic_healthcare_support}`,
)}
</div>
</div>
</div>
)}
</div>
</div>
</div>
Expand Down
114 changes: 94 additions & 20 deletions src/Components/Patient/PatientRegister.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import * as Notification from "../../Utils/Notifications.js";

import {
BLOOD_GROUPS,
DOMESTIC_HEALTHCARE_SUPPORT_CHOICES,
GENDER_TYPES,
MEDICAL_HISTORY_CHOICES,
OCCUPATION_TYPES,
RATION_CARD_CATEGORY,
SOCIOECONOMIC_STATUS_CHOICES,
VACCINES,
} from "../../Common/constants";
import { DistrictModel, DupPatientModel, WardModel } from "../Facility/models";
Expand All @@ -15,7 +17,6 @@ import {
RequiredFieldValidator,
} from "../Form/FieldValidators";
import { FieldErrorText, FieldLabel } from "../Form/FormFields/FormField";
import { Occupation, PatientModel } from "./models";
import {
compareBy,
dateQueryString,
Expand Down Expand Up @@ -53,6 +54,7 @@ import HCXPolicyValidator from "../HCX/validators";
import { ILocalBodies } from "../ExternalResult/models.js";
import InsuranceDetailsBuilder from "../HCX/InsuranceDetailsBuilder";
import LinkABHANumberModal from "../ABDM/LinkABHANumberModal";
import { PatientModel, Occupation, PatientMeta } from "./models";
import PhoneNumberFormField from "../Form/FormFields/PhoneNumberFormField";
import RadioFormField from "../Form/FormFields/RadioFormField";
import { SelectFormField } from "../Form/FormFields/SelectFormField";
Expand All @@ -76,6 +78,9 @@ import careConfig from "@careConfig";
const Loading = lazy(() => import("../Common/Loading"));
const PageTitle = lazy(() => import("../Common/PageTitle"));

type PatientForm = PatientModel &
PatientMeta & { age?: number; is_postpartum?: boolean };

interface PatientRegisterProps extends PatientModel {
facilityId: string;
}
Expand Down Expand Up @@ -190,7 +195,7 @@ export const PatientRegister = (props: PatientRegisterProps) => {
const [isLoading, setIsLoading] = useState(false);
const [showImport, setShowImport] = useState<{
show?: boolean;
field?: FormContextValue<PatientModel> | null;
field?: FormContextValue<PatientForm> | null;
}>({
show: false,
field: null,
Expand Down Expand Up @@ -429,6 +434,7 @@ export const PatientRegister = (props: PatientRegisterProps) => {
occupation: data.meta_info?.occupation
? parseOccupationFromExt(data.meta_info.occupation)
: null,

is_vaccinated: String(data.is_vaccinated),
number_of_doses: data.number_of_doses
? String(data.number_of_doses)
Expand Down Expand Up @@ -748,7 +754,7 @@ export const PatientRegister = (props: PatientRegisterProps) => {
formData.nationality === "India" ? formData.local_body : undefined,
ward: formData.ward,
meta_info: {
...state.form?.meta_info,
...formData.meta_info,
occupation: formData.occupation ?? null,
},
village: formData.village,
Expand Down Expand Up @@ -1145,7 +1151,7 @@ export const PatientRegister = (props: PatientRegisterProps) => {
)}
<>
<div className={`${showImport.show && "hidden"}`}>
<Form<PatientModel & { age?: number; is_postpartum?: boolean }>
<Form<PatientForm>
defaults={id ? state.form : initForm}
validate={validateForm}
onSubmit={handleSubmit}
Expand Down Expand Up @@ -1738,22 +1744,6 @@ export const PatientRegister = (props: PatientRegisterProps) => {
/>
)}
</div>
<AutocompleteFormField
{...field("occupation")}
label="Occupation"
placeholder="Select Occupation"
options={occupationTypes}
optionLabel={(o) => o.text}
optionValue={(o) => o.id}
/>
<SelectFormField
{...field("ration_card_category")}
label="Ration Card Category"
placeholder="Select"
options={RATION_CARD_CATEGORY}
optionLabel={(o) => t(`ration_card__${o}`)}
optionValue={(o) => o}
/>
</>
) : (
<div id="passport_no-div">
Expand All @@ -1766,6 +1756,90 @@ export const PatientRegister = (props: PatientRegisterProps) => {
)}
</div>
</div>
{field("nationality").value === "India" && (
<div className="mb-8 rounded border border-secondary-200 p-4">
<AccordionV2
className="mt-2 shadow-none md:mt-0 lg:mt-0"
expandIcon={
<CareIcon
icon="l-angle-down"
className="text-2xl font-bold"
/>
}
title={
<h1 className="text-left text-xl font-bold text-purple-500">
Social Profile
</h1>
}
expanded
>
<div>
<div className="mt-5 grid grid-cols-1 gap-4 md:grid-cols-2 xl:gap-x-20 xl:gap-y-6">
<AutocompleteFormField
{...field("occupation")}
label="Occupation"
placeholder="Select Occupation"
options={occupationTypes}
optionLabel={(o) => o.text}
optionValue={(o) => o.id}
/>
<SelectFormField
{...field("ration_card_category")}
label="Ration Card Category"
placeholder="Select"
options={RATION_CARD_CATEGORY}
optionLabel={(o) => t(`ration_card__${o}`)}
optionValue={(o) => o}
/>
<RadioFormField
name="socioeconomic_status"
label={t("socioeconomic_status")}
options={SOCIOECONOMIC_STATUS_CHOICES}
optionLabel={(o) =>
t(`SOCIOECONOMIC_STATUS__${o}`)
}
optionValue={(o) => o}
value={
field("meta_info").value
?.socioeconomic_status
}
onChange={({ name, value }) =>
field("meta_info").onChange({
name: "meta_info",
value: {
...(field("meta_info").value ?? {}),
[name]: value,
},
})
}
/>
<RadioFormField
name="domestic_healthcare_support"
label={t("has_domestic_healthcare_support")}
options={DOMESTIC_HEALTHCARE_SUPPORT_CHOICES}
optionLabel={(o) =>
t(`DOMESTIC_HEALTHCARE_SUPPORT__${o}`)
}
optionValue={(o) => o}
value={
field("meta_info").value
?.domestic_healthcare_support
}
onChange={({ name, value }) =>
field("meta_info").onChange({
name: "meta_info",
value: {
...(field("meta_info").value ?? {}),
[name]: value,
},
})
}
/>
</div>
</div>
</AccordionV2>
</div>
)}
<div className="mb-8 rounded border border-secondary-200 p-4">
<AccordionV2
className="mt-2 shadow-none md:mt-0 lg:mt-0"
Expand Down
15 changes: 10 additions & 5 deletions src/Components/Patient/models.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
BLADDER_ISSUE_CHOICES,
BOWEL_ISSUE_CHOICES,
CONSCIOUSNESS_LEVEL,
DOMESTIC_HEALTHCARE_SUPPORT_CHOICES,
HEARTBEAT_RHYTHM_CHOICES,
HumanBodyRegion,
INSULIN_INTAKE_FREQUENCY_OPTIONS,
Expand All @@ -20,6 +21,7 @@ import {
RATION_CARD_CATEGORY,
RESPIRATORY_SUPPORT,
SLEEP_CHOICES,
SOCIOECONOMIC_STATUS_CHOICES,
URINATION_FREQUENCY_CHOICES,
VENTILATOR_MODE_OPTIONS,
} from "../../Common/constants";
Expand Down Expand Up @@ -47,6 +49,13 @@ export interface AssignedToObjectModel {
user_type: string;
}

export interface PatientMeta {
readonly id: number;
occupation?: Occupation;
socioeconomic_status?: (typeof SOCIOECONOMIC_STATUS_CHOICES)[number];
domestic_healthcare_support?: (typeof DOMESTIC_HEALTHCARE_SUPPORT_CHOICES)[number];
}

export interface PatientModel {
id?: string;
action?: number;
Expand Down Expand Up @@ -125,11 +134,7 @@ export interface PatientModel {
created_by?: PerformedByModel;
assigned_to?: { first_name?: string; username?: string; last_name?: string };
assigned_to_object?: AssignedToObjectModel;
occupation?: Occupation;
meta_info?: {
id: number;
occupation: Occupation;
};
meta_info?: PatientMeta;
}

export interface SampleTestModel {
Expand Down
Loading

0 comments on commit 92acdc9

Please sign in to comment.