diff --git a/cypress/pageobject/Patient/PatientCreation.ts b/cypress/pageobject/Patient/PatientCreation.ts index 919b16c7c20..a708f754964 100644 --- a/cypress/pageobject/Patient/PatientCreation.ts +++ b/cypress/pageobject/Patient/PatientCreation.ts @@ -46,7 +46,7 @@ export class PatientPage { } typePatientDateOfBirth(dateOfBirth: string) { - cy.clickAndSelectOption("#patientAge", "D.O.B"); + cy.clickAndSelectOption("#patientAge", "DOB"); cy.get("#date_of_birth").scrollIntoView(); cy.get("#date_of_birth").should("be.visible").click(); cy.get("#date-input").click().type(dateOfBirth); diff --git a/src/Components/DeathReport/DeathReport.tsx b/src/Components/DeathReport/DeathReport.tsx index 9c30fbea429..e25a59c8732 100644 --- a/src/Components/DeathReport/DeathReport.tsx +++ b/src/Components/DeathReport/DeathReport.tsx @@ -6,7 +6,7 @@ import TextFormField from "../Form/FormFields/TextFormField"; import TextAreaFormField from "../Form/FormFields/TextAreaFormField"; import DateFormField from "../Form/FormFields/DateFormField"; import PhoneNumberFormField from "../Form/FormFields/PhoneNumberFormField"; -import { formatDateTime } from "../../Utils/utils"; +import { formatDateTime, patientAgeInYears } from "../../Utils/utils"; import Page from "../Common/components/Page"; import Form from "../Form/Form"; import { useTranslation } from "react-i18next"; @@ -106,6 +106,7 @@ export default function PrintDeathReport(props: { id: string }) { const patientComorbidities = getPatientComorbidities(res.data); const data = { ...res.data, + age: patientAgeInYears(res.data!), gender: patientGender, address: patientAddress, comorbidities: patientComorbidities, diff --git a/src/Components/Form/SelectMenuV2.tsx b/src/Components/Form/SelectMenuV2.tsx index 2c22510cef1..dc2c57f4592 100644 --- a/src/Components/Form/SelectMenuV2.tsx +++ b/src/Components/Form/SelectMenuV2.tsx @@ -102,7 +102,7 @@ const SelectMenuV2 = (props: SelectMenuProps) => { {value.icon} )} -

+

{value.selectedLabel}

diff --git a/src/Components/Patient/PatientRegister.tsx b/src/Components/Patient/PatientRegister.tsx index 2a7a42279bb..0ab72370178 100644 --- a/src/Components/Patient/PatientRegister.tsx +++ b/src/Components/Patient/PatientRegister.tsx @@ -1335,7 +1335,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { [ { value: "date_of_birth", - text: "D.O.B.", + text: "DOB", }, { value: "age", text: "Age" }, ] as const diff --git a/src/Utils/utils.ts b/src/Utils/utils.ts index 0d350267d1a..3178ef311f0 100644 --- a/src/Utils/utils.ts +++ b/src/Utils/utils.ts @@ -405,6 +405,20 @@ const getRelativeDateSuffix = (abbreviated: boolean) => { }; }; +export const patientAgeInYears = (obj: PatientModel) => { + const start = dayjs( + obj.date_of_birth + ? new Date(obj.date_of_birth) + : new Date(obj.year_of_birth!, 0, 1) + ); + + const end = dayjs( + obj.death_datetime ? new Date(obj.death_datetime) : new Date() + ); + + return end.diff(start, "years"); +}; + export const formatPatientAge = (obj: PatientModel, abbreviated = false) => { const suffixes = getRelativeDateSuffix(abbreviated);