From 92acdc9d59cf2ec3cdfe4b63b4ee0186368daf2a Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Thu, 19 Sep 2024 19:19:14 +0530 Subject: [PATCH] Patient Registration: Adds social profile section (#8570) --- .../patient_spec/PatientRegistration.cy.ts | 4 + cypress/pageobject/Patient/PatientCreation.ts | 13 ++ cypress/support/commands.ts | 4 + cypress/support/index.ts | 1 + src/Common/constants.tsx | 14 +++ src/Components/Patient/PatientHome.tsx | 54 ++++++--- src/Components/Patient/PatientRegister.tsx | 114 +++++++++++++++--- src/Components/Patient/models.tsx | 15 ++- src/Locale/en/Patient.json | 14 +++ src/Locale/en/index.js | 2 + 10 files changed, 196 insertions(+), 39 deletions(-) create mode 100644 src/Locale/en/Patient.json diff --git a/cypress/e2e/patient_spec/PatientRegistration.cy.ts b/cypress/e2e/patient_spec/PatientRegistration.cy.ts index b9ef2b8736b..589b60f1830 100644 --- a/cypress/e2e/patient_spec/PatientRegistration.cy.ts +++ b/cypress/e2e/patient_spec/PatientRegistration.cy.ts @@ -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( @@ -131,6 +133,8 @@ describe("Patient Creation with consultation", () => { yearOfBirth, patientOneBloodGroup, patientOccupation, + "Middle Class", + "Family member", ); patientMedicalHistory.verifyPatientMedicalDetails( patientOnePresentHealth, diff --git a/cypress/pageobject/Patient/PatientCreation.ts b/cypress/pageobject/Patient/PatientCreation.ts index db3c10fdcb5..e037f0888f0 100644 --- a/cypress/pageobject/Patient/PatientCreation.ts +++ b/cypress/pageobject/Patient/PatientCreation.ts @@ -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(); @@ -165,6 +173,8 @@ export class PatientPage { yearOfBirth, bloodGroup, occupation, + socioeconomicStatus = null, + domesticHealthcareSupport = null, isAntenatal = false, isPostPartum = false, ) { @@ -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"); diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index c6437505349..86d048e5f41 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -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(); diff --git a/cypress/support/index.ts b/cypress/support/index.ts index 9ddfd0c819a..d660246324f 100644 --- a/cypress/support/index.ts +++ b/cypress/support/index.ts @@ -23,6 +23,7 @@ declare global { selector: string, symptoms: string | string[], ): Chainable; + selectRadioOption(name: string, value: string): Chainable; typeAndMultiSelectOption( selector: string, input: string, diff --git a/src/Common/constants.tsx b/src/Common/constants.tsx index 9998762cc05..8149a144ed9 100644 --- a/src/Common/constants.tsx +++ b/src/Common/constants.tsx @@ -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, diff --git a/src/Components/Patient/PatientHome.tsx b/src/Components/Patient/PatientHome.tsx index e80708d8783..956cd9a40fd 100644 --- a/src/Components/Patient/PatientHome.tsx +++ b/src/Components/Patient/PatientHome.tsx @@ -515,24 +515,50 @@ export const PatientHome = (props: any) => { )} -
-
- Occupation + {patientData.meta_info?.occupation && ( +
+
+ {t("occupation")} +
+
+ {parseOccupation(patientData.meta_info.occupation)} +
-
- {parseOccupation(patientData.meta_info?.occupation) || "-"} + )} + {patientData.ration_card_category && ( +
+
+ {t("ration_card_category")} +
+
+ {t(`ration_card__${patientData.ration_card_category}`)} +
-
-
-
- Ration Card Category + )} + {patientData.meta_info?.socioeconomic_status && ( +
+
+ {t("socioeconomic_status")} +
+
+ {t( + `SOCIOECONOMIC_STATUS__${patientData.meta_info.socioeconomic_status}`, + )} +
-
- {patientData.ration_card_category - ? t(`ration_card__${patientData.ration_card_category}`) - : "-"} + )} + {patientData.meta_info?.domestic_healthcare_support && ( +
+
+ {t("domestic_healthcare_support")} +
+
+ {t( + `DOMESTIC_HEALTHCARE_SUPPORT__${patientData.meta_info.domestic_healthcare_support}`, + )} +
-
+ )}
diff --git a/src/Components/Patient/PatientRegister.tsx b/src/Components/Patient/PatientRegister.tsx index 938531c5590..9a9715ba081 100644 --- a/src/Components/Patient/PatientRegister.tsx +++ b/src/Components/Patient/PatientRegister.tsx @@ -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"; @@ -15,7 +17,6 @@ import { RequiredFieldValidator, } from "../Form/FieldValidators"; import { FieldErrorText, FieldLabel } from "../Form/FormFields/FormField"; -import { Occupation, PatientModel } from "./models"; import { compareBy, dateQueryString, @@ -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"; @@ -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; } @@ -190,7 +195,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { const [isLoading, setIsLoading] = useState(false); const [showImport, setShowImport] = useState<{ show?: boolean; - field?: FormContextValue | null; + field?: FormContextValue | null; }>({ show: false, field: null, @@ -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) @@ -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, @@ -1145,7 +1151,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { )} <>
- + defaults={id ? state.form : initForm} validate={validateForm} onSubmit={handleSubmit} @@ -1738,22 +1744,6 @@ export const PatientRegister = (props: PatientRegisterProps) => { /> )}
- o.text} - optionValue={(o) => o.id} - /> - t(`ration_card__${o}`)} - optionValue={(o) => o} - /> ) : (
@@ -1766,6 +1756,90 @@ export const PatientRegister = (props: PatientRegisterProps) => { )}
+ {field("nationality").value === "India" && ( +
+ + } + title={ +

+ Social Profile +

+ } + expanded + > +
+
+ o.text} + optionValue={(o) => o.id} + /> + t(`ration_card__${o}`)} + optionValue={(o) => 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, + }, + }) + } + /> + + 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, + }, + }) + } + /> +
+
+
+
+ )}