diff --git a/cypress/e2e/patient_spec/patient_registration.cy.ts b/cypress/e2e/patient_spec/patient_registration.cy.ts index d0ec3d7548..76c3e2b719 100644 --- a/cypress/e2e/patient_spec/patient_registration.cy.ts +++ b/cypress/e2e/patient_spec/patient_registration.cy.ts @@ -80,7 +80,7 @@ describe("Patient Creation with consultation", () => { // Patient Details page patientPage.typePatientPhoneNumber(phone_number); patientPage.typePatientEmergencyNumber(emergency_phone_number); - patientPage.typePatientDateOfBirth(patientDateOfBirth); + patientPage.typePatientAge(age.toString()); patientPage.typePatientName(patientOneName); patientPage.selectPatientGender(patientOneGender); patientPage.typePatientAddress(patientOneAddress); @@ -146,6 +146,7 @@ describe("Patient Creation with consultation", () => { // change the gender to female and input data to related changed field cy.wait(3000); patientPage.selectPatientGender(patientOneUpdatedGender); + patientPage.typePatientDateOfBirth(patientDateOfBirth); patientPage.clickPatientAntenatalStatusYes(); patientPage.selectPatientBloodGroup(patientOneUpdatedBloodGroup); // Edit the patient consultation , select none medical history and multiple health ID diff --git a/cypress/pageobject/Patient/PatientCreation.ts b/cypress/pageobject/Patient/PatientCreation.ts index 833cd95a3f..919b16c7c2 100644 --- a/cypress/pageobject/Patient/PatientCreation.ts +++ b/cypress/pageobject/Patient/PatientCreation.ts @@ -46,11 +46,18 @@ export class PatientPage { } typePatientDateOfBirth(dateOfBirth: string) { + cy.clickAndSelectOption("#patientAge", "D.O.B"); cy.get("#date_of_birth").scrollIntoView(); cy.get("#date_of_birth").should("be.visible").click(); cy.get("#date-input").click().type(dateOfBirth); } + typePatientAge(age: string) { + cy.clickAndSelectOption("#patientAge", "Age"); + cy.submitButton("Confirm"); + cy.get("#age").clear().type(age); + } + typePatientName(patientName: string) { cy.get("[data-testid=name] input").click().type(patientName); } diff --git a/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx b/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx index ecbe157a8a..2d673a37f7 100644 --- a/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx +++ b/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx @@ -15,7 +15,11 @@ import { } from "../../../Common/constants"; import PrescriptionsTable from "../../Medicine/PrescriptionsTable"; import Chip from "../../../CAREUI/display/Chip"; -import { formatAge, formatDate, formatDateTime } from "../../../Utils/utils"; +import { + formatDate, + formatDateTime, + formatPatientAge, +} from "../../../Utils/utils"; import ReadMore from "../../Common/components/Readmore"; import DailyRoundsList from "../Consultations/DailyRoundsList"; import EventsList from "./Events/EventsList"; @@ -635,12 +639,7 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => {
Age {" - "} - {props.patientData.age !== undefined // 0 is a valid age, so we need to check for undefined - ? formatAge( - props.patientData.age, - props.patientData.date_of_birth - ) - : "-"} + {formatPatientAge(props.patientData)}
diff --git a/src/Components/Facility/DischargedPatientsList.tsx b/src/Components/Facility/DischargedPatientsList.tsx index e313717c2a..af5f79cf4c 100644 --- a/src/Components/Facility/DischargedPatientsList.tsx +++ b/src/Components/Facility/DischargedPatientsList.tsx @@ -7,10 +7,10 @@ import { PatientModel } from "../Patient/models"; import useQuery from "../../Utils/request/useQuery"; import { debounce } from "lodash-es"; import SearchInput from "../Form/SearchInput"; -import { formatAge } from "../../Utils/utils"; import { GENDER_TYPES } from "../../Common/constants"; import CareIcon from "../../CAREUI/icons/CareIcon"; import RecordMeta from "../../CAREUI/display/RecordMeta"; +import { formatPatientAge } from "../../Utils/utils"; import { useTranslation } from "react-i18next"; import SwitchTabs from "../Common/components/SwitchTabs"; @@ -100,7 +100,7 @@ const PatientListItem = ({ patient }: { patient: PatientModel }) => {

{patient.name}

{GENDER_TYPES.find((g) => g.id === patient.gender)?.text} -{" "} - {formatAge(patient.age, patient.date_of_birth)} + {formatPatientAge(patient)}
{ @@ -52,8 +52,7 @@ interface ReportTableProps { title?: string; patientDetails?: { name: string; - age: number; - date_of_birth: string; + age: string; hospitalName: string; }; investigationData: InvestigationResponse; @@ -84,14 +83,7 @@ const ReportTable: FC = ({ {patientDetails && (

Name: {patientDetails.name}

-

- Age:{" "} - {formatAge( - patientDetails.age, - patientDetails.date_of_birth, - true - )} -

+

Age: {patientDetails.age}

Hospital: {patientDetails.hospitalName}

)} diff --git a/src/Components/Facility/Investigations/Reports/index.tsx b/src/Components/Facility/Investigations/Reports/index.tsx index 36a553f9f5..68b3f533b6 100644 --- a/src/Components/Facility/Investigations/Reports/index.tsx +++ b/src/Components/Facility/Investigations/Reports/index.tsx @@ -16,6 +16,7 @@ import AutocompleteMultiSelectFormField from "../../../Form/FormFields/Autocompl import { FieldChangeEvent } from "../../../Form/FormFields/Utils"; import ReportTable from "./ReportTable"; import { Investigation, InvestigationResponse } from "./types"; +import { formatPatientAge } from "../../../../Utils/utils"; const RESULT_PER_PAGE = 14; interface InitialState { @@ -386,8 +387,7 @@ const InvestigationReports = ({ id }: any) => { title={t("report")} patientDetails={{ name: patientData?.name || "", - age: patientData?.age || -1, - date_of_birth: patientData?.date_of_birth || "", + age: patientData ? formatPatientAge(patientData, true) : "", hospitalName: patientData?.facility_object?.name || "", }} /> diff --git a/src/Components/Facility/TreatmentSummary.tsx b/src/Components/Facility/TreatmentSummary.tsx index f3c59791d6..e33a5e3c4f 100644 --- a/src/Components/Facility/TreatmentSummary.tsx +++ b/src/Components/Facility/TreatmentSummary.tsx @@ -1,5 +1,9 @@ import { GENDER_TYPES } from "../../Common/constants"; -import { formatAge, formatDate, formatDateTime } from "../../Utils/utils"; +import { + formatDate, + formatDateTime, + formatPatientAge, +} from "../../Utils/utils"; import useSlug from "../../Common/hooks/useSlug"; import useAppHistory from "../../Common/hooks/useAppHistory"; import routes from "../../Redux/api"; @@ -66,11 +70,7 @@ const TreatmentSummary = (props: any) => {
Age :{" "} - {formatAge( - patientData?.age ?? 0, - patientData?.date_of_birth ?? "", - true - )} + {patientData ? formatPatientAge(patientData, true) : ""}
OP : {consultationData?.patient_no ?? ""} diff --git a/src/Components/Patient/ManagePatients.tsx b/src/Components/Patient/ManagePatients.tsx index aacad50dc1..ed9c358b9b 100644 --- a/src/Components/Patient/ManagePatients.tsx +++ b/src/Components/Patient/ManagePatients.tsx @@ -31,7 +31,7 @@ import RecordMeta from "../../CAREUI/display/RecordMeta"; import SearchInput from "../Form/SearchInput"; import SortDropdownMenu from "../Common/SortDropdown"; import SwitchTabs from "../Common/components/SwitchTabs"; -import { formatAge, parsePhoneNumber } from "../../Utils/utils.js"; +import { formatPatientAge, parsePhoneNumber } from "../../Utils/utils.js"; import useFilters from "../../Common/hooks/useFilters"; import { useTranslation } from "react-i18next"; import Page from "../Common/components/Page.js"; @@ -531,7 +531,7 @@ export const PatientManager = () => { > {patient.name} - {formatAge(patient.age, patient.date_of_birth, true)} + {formatPatientAge(patient, true)}
diff --git a/src/Components/Patient/PatientHome.tsx b/src/Components/Patient/PatientHome.tsx index 5c15155337..919a0048e2 100644 --- a/src/Components/Patient/PatientHome.tsx +++ b/src/Components/Patient/PatientHome.tsx @@ -16,9 +16,9 @@ import { SampleTestCard } from "./SampleTestCard"; import Chip from "../../CAREUI/display/Chip"; import { classNames, - formatAge, formatDate, formatDateTime, + formatPatientAge, } from "../../Utils/utils"; import ButtonV2 from "../Common/components/ButtonV2"; import { NonReadOnlyUsers } from "../../Utils/AuthorizeFor"; @@ -342,12 +342,7 @@ export const PatientHome = (props: any) => {

- {patientData.name} -{" "} - {formatAge( - patientData.age, - patientData.date_of_birth, - true - )} + {patientData.name} - {formatPatientAge(patientData, true)}

{patientData.is_vaccinated ? ( @@ -427,10 +422,14 @@ export const PatientHome = (props: any) => {
- Date of Birth + {patientData.date_of_birth + ? "Date of Birth" + : "Year of Birth"}
- {formatDate(patientData?.date_of_birth)} + {patientData.date_of_birth + ? formatDate(patientData.date_of_birth) + : patientData.year_of_birth}
diff --git a/src/Components/Patient/PatientInfoCard.tsx b/src/Components/Patient/PatientInfoCard.tsx index 284341b746..4a934d3283 100644 --- a/src/Components/Patient/PatientInfoCard.tsx +++ b/src/Components/Patient/PatientInfoCard.tsx @@ -15,7 +15,12 @@ import { useState } from "react"; import CareIcon from "../../CAREUI/icons/CareIcon.js"; import useConfig from "../../Common/hooks/useConfig.js"; import dayjs from "../../Utils/dayjs.js"; -import { classNames, formatDate, formatDateTime } from "../../Utils/utils.js"; +import { + classNames, + formatDate, + formatDateTime, + formatPatientAge, +} from "../../Utils/utils.js"; import ABHAProfileModal from "../ABDM/ABHAProfileModal.js"; import LinkABHANumberModal from "../ABDM/LinkABHANumberModal.js"; import LinkCareContextModal from "../ABDM/LinkCareContextModal.js"; @@ -217,7 +222,7 @@ export default function PatientInfoCard(props: { > {patient.name}
- {patient.age} years • {patient.gender} + {formatPatientAge(patient, true)} • {patient.gender}
{patient.name}
- {patient.age} years • {patient.gender} + {formatPatientAge(patient, true)} • {patient.gender}
diff --git a/src/Components/Patient/PatientRegister.tsx b/src/Components/Patient/PatientRegister.tsx index 4d022b85af..2a7a42279b 100644 --- a/src/Components/Patient/PatientRegister.tsx +++ b/src/Components/Patient/PatientRegister.tsx @@ -61,6 +61,7 @@ import useAuthUser from "../../Common/hooks/useAuthUser.js"; import useQuery from "../../Utils/request/useQuery.js"; import routes from "../../Redux/api.js"; import request from "../../Utils/request/request.js"; +import SelectMenuV2 from "../Form/SelectMenuV2.js"; const Loading = lazy(() => import("../Common/Loading")); const PageTitle = lazy(() => import("../Common/PageTitle")); @@ -92,6 +93,7 @@ const vaccines = ["Select", ...VACCINES]; const initForm: any = { name: "", age: "", + year_of_birth: "", gender: "", phone_number: "+91", emergency_phone_number: "+91", @@ -204,6 +206,9 @@ export const PatientRegister = (props: PatientRegisterProps) => { const [districts, setDistricts] = useState([]); const [localBody, setLocalBody] = useState([]); const [ward, setWard] = useState([]); + const [ageInputType, setAgeInputType] = useState< + "date_of_birth" | "age" | "alert_for_age" + >("date_of_birth"); const [statusDialog, setStatusDialog] = useState<{ show?: boolean; transfer?: boolean; @@ -392,8 +397,14 @@ export const PatientRegister = (props: PatientRegisterProps) => { if (!status.aborted) { if (res?.ok && data) { setPatientName(data.name || ""); + if (!data.date_of_birth) { + setAgeInputType("age"); + } const formData = { ...data, + age: data.year_of_birth + ? new Date().getFullYear() - data.year_of_birth + : "", health_id_number: data.abha_number_object?.abha_number || "", health_id: data.abha_number_object?.health_id || "", nationality: data.nationality ? data.nationality : "India", @@ -464,9 +475,8 @@ export const PatientRegister = (props: PatientRegisterProps) => { ); if (medicalHistory) { formData.medical_history.push(Number(medicalHistory.id)); - (formData as any)[ - `medical_history_${String(medicalHistory.id)}` - ] = i.details; + (formData as any)[`medical_history_${medicalHistory.id}`] = + i.details; } } ); @@ -534,9 +544,34 @@ export const PatientRegister = (props: PatientRegisterProps) => { case "address": case "name": case "gender": - case "date_of_birth": errors[field] = RequiredFieldValidator()(form[field]); return; + case "age": + case "date_of_birth": { + const field = ageInputType === "age" ? "age" : "date_of_birth"; + + errors[field] = RequiredFieldValidator()(form[field]); + if (errors[field]) { + return; + } + + if (field === "age") { + if (form.age < 0) { + errors.age = "Age cannot be less than 0"; + return; + } + + form.date_of_birth = null; + form.year_of_birth = new Date().getFullYear() - form.age; + } + + if (field === "date_of_birth") { + form.age = null; + form.year_of_birth = null; + } + + return; + } case "permanent_address": if (!form.sameAddress) { errors[field] = RequiredFieldValidator()(form[field]); @@ -711,7 +746,11 @@ export const PatientRegister = (props: PatientRegisterProps) => { abha_number: state.form.abha_number, phone_number: parsePhoneNumber(formData.phone_number), emergency_phone_number: parsePhoneNumber(formData.emergency_phone_number), - date_of_birth: dateQueryString(formData.date_of_birth), + date_of_birth: + ageInputType === "date_of_birth" + ? dateQueryString(formData.date_of_birth) + : null, + year_of_birth: ageInputType === "age" ? formData.year_of_birth : null, disease_status: formData.disease_status, date_of_test: formData.date_of_test ? formData.date_of_test : undefined, date_of_result: formData.date_of_result @@ -1138,7 +1177,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { )} <>
- + defaults={id ? state.form : initForm} validate={validateForm} onSubmit={handleSubmit} @@ -1284,18 +1323,116 @@ export const PatientRegister = (props: PatientRegisterProps) => { label={"Name"} />
-
- + + {ageInputType === "age" ? "Age" : "Date of Birth"} + +
+ o.text} + optionValue={(o) => + o.value === "date_of_birth" + ? "date_of_birth" + : "age" + } + value={ageInputType} + onChange={(v) => { + if ( + v === "age" && + ageInputType === "date_of_birth" + ) { + setAgeInputType("alert_for_age"); + return; + } + setAgeInputType(v); + }} + /> +
+ {ageInputType !== "age" ? ( +
+ +
+ ) : ( +
+ +

+ {field("age").value !== "" && + "Year_of_Birth:"} +

+ + {field("age").value !== "" && + new Date().getFullYear() - + field("age").value} + +

+ } + placeholder="Enter the age" + className="col-span-6 sm:col-span-3" + type="number" + min={0} + /> +
+ )} +
+
+ +
+ +
+ While entering a patient's age is an + option, please note that only the year of + birth will be captured from this + information. +
+ + Recommended only when the patient's date + of birth is unknown + +
+ } + action="Confirm" + variant="warning" + show={ageInputType == "alert_for_age"} + onClose={() => setAgeInputType("date_of_birth")} + onConfirm={() => setAgeInputType("age")} + /> +
{ ) : (
Age: - {formatAge(patientData?.age, patientData?.date_of_birth)} + {formatPatientAge(patientData)}
)}
diff --git a/src/Components/Patient/models.tsx b/src/Components/Patient/models.tsx index d62a66dbfc..0ce23f68c2 100644 --- a/src/Components/Patient/models.tsx +++ b/src/Components/Patient/models.tsx @@ -49,7 +49,6 @@ export interface PatientModel { id?: string; action?: number; name?: string; - age?: number; allow_transfer?: boolean; discharge?: boolean; gender?: number; @@ -113,6 +112,8 @@ export interface PatientModel { number_of_doses?: number; last_vaccinated_date?: string; date_of_birth?: string; + year_of_birth?: number; + readonly death_datetime?: string; blood_group?: string; review_interval?: number; review_time?: string; diff --git a/src/Components/Shifting/ListView.tsx b/src/Components/Shifting/ListView.tsx index e1f0a0545e..5ad0dfa8b3 100644 --- a/src/Components/Shifting/ListView.tsx +++ b/src/Components/Shifting/ListView.tsx @@ -8,7 +8,7 @@ import { ExportButton } from "../Common/Export"; import ListFilter from "./ListFilter"; import Page from "../Common/components/Page"; import SearchInput from "../Form/SearchInput"; -import { formatAge, formatDateTime } from "../../Utils/utils"; +import { formatDateTime, formatPatientAge } from "../../Utils/utils"; import { formatFilter } from "./Commons"; import { navigate } from "raviger"; @@ -90,11 +90,7 @@ export default function ListView() {
{shift.patient_object.name} -{" "} - {formatAge( - shift.patient_object.age, - shift.patient_object.date_of_birth, - true - )} + {formatPatientAge(shift.patient_object, true)}
{shift.emergency && ( diff --git a/src/Components/Shifting/ShiftDetails.tsx b/src/Components/Shifting/ShiftDetails.tsx index acc3565487..c3f42456f6 100644 --- a/src/Components/Shifting/ShiftDetails.tsx +++ b/src/Components/Shifting/ShiftDetails.tsx @@ -15,7 +15,7 @@ import { CopyToClipboard } from "react-copy-to-clipboard"; import Page from "../Common/components/Page"; import QRCode from "qrcode.react"; import RecordMeta from "../../CAREUI/display/RecordMeta"; -import { formatAge, formatDateTime } from "../../Utils/utils"; +import { formatDateTime, formatPatientAge } from "../../Utils/utils"; import useConfig from "../../Common/hooks/useConfig"; import { useTranslation } from "react-i18next"; @@ -24,6 +24,7 @@ import routes from "../../Redux/api.js"; import request from "../../Utils/request/request.js"; import { ConsultationModel } from "../Facility/models.js"; import CareIcon from "../../CAREUI/icons/CareIcon.js"; +import { PatientModel } from "../Patient/models.js"; const Loading = lazy(() => import("../Common/Loading")); @@ -94,13 +95,9 @@ export default function ShiftDetails(props: { id: string }) { "\n" + t("age") + ":" + - +( - formatAge( - data?.patient_object?.age, - data?.patient_object?.date_of_birth, - true - ) ?? "-" - ) + + +(data?.patient_object + ? formatPatientAge(data.patient_object, true) + : "") + "\n" + t("origin_facility") + ":" + @@ -128,7 +125,7 @@ export default function ShiftDetails(props: { id: string }) { setIsCopied(false); }, 5000); - const showPatientCard = (patientData: any) => { + const showPatientCard = (patientData: PatientModel) => { const patientGender = GENDER_TYPES.find( (i) => i.id === patientData?.gender )?.text; @@ -185,7 +182,7 @@ export default function ShiftDetails(props: { id: string }) { {t("age")}:{" "} - {formatAge(patientData?.age, patientData?.date_of_birth, true)} + {patientData ? formatPatientAge(patientData, true) : ""}
)} {patientData?.gender === 2 && patientData?.is_antenatal && ( @@ -370,7 +367,7 @@ export default function ShiftDetails(props: { id: string }) { {t("age")}:{" "} - {formatAge(patientData.age, patientData.date_of_birth, true)} + {patientData ? formatPatientAge(patientData, true) : ""}
@@ -794,7 +791,7 @@ export default function ShiftDetails(props: { id: string }) {

{t("details_of_patient")} {showCopyToclipBoard(data)}

- {showPatientCard(data?.patient_object)} + {data?.patient_object && showPatientCard(data?.patient_object)}

{t("comments")}

diff --git a/src/Components/Shifting/ShiftingBoard.tsx b/src/Components/Shifting/ShiftingBoard.tsx index ae94514e6e..e07fb5d96e 100644 --- a/src/Components/Shifting/ShiftingBoard.tsx +++ b/src/Components/Shifting/ShiftingBoard.tsx @@ -6,7 +6,11 @@ import { useRef, useState, } from "react"; -import { classNames, formatAge, formatDateTime } from "../../Utils/utils"; +import { + classNames, + formatDateTime, + formatPatientAge, +} from "../../Utils/utils"; import { downloadShiftRequests } from "../../Redux/actions"; import { useDrag, useDrop } from "react-dnd"; @@ -88,11 +92,7 @@ const ShiftCard = ({ shift, filter }: any) => {
{shift.patient_object.name} -{" "} - {formatAge( - shift.patient_object?.age, - shift.patient_object?.age.date_of_birth, - true - )} + {formatPatientAge(shift.patient_object, true)}
{shift.emergency && ( diff --git a/src/Components/VitalsMonitor/VitalsMonitorHeader.tsx b/src/Components/VitalsMonitor/VitalsMonitorHeader.tsx index 8fa272d405..c3b2888c2f 100644 --- a/src/Components/VitalsMonitor/VitalsMonitorHeader.tsx +++ b/src/Components/VitalsMonitor/VitalsMonitorHeader.tsx @@ -2,6 +2,7 @@ import { PatientAssetBed } from "../Assets/AssetTypes"; import { Link } from "raviger"; import CareIcon from "../../CAREUI/icons/CareIcon"; import { GENDER_TYPES } from "../../Common/constants"; +import { formatPatientAge } from "../../Utils/utils"; interface VitalsMonitorHeaderProps { patientAssetBed?: PatientAssetBed; @@ -27,7 +28,7 @@ const VitalsMonitorHeader = ({ patientAssetBed }: VitalsMonitorHeaderProps) => { )} {patient && ( - {patient.age}y;{" "} + {`${formatPatientAge(patient)}; `} {GENDER_TYPES.find((g) => g.id === patient.gender)?.icon} )} diff --git a/src/Utils/utils.ts b/src/Utils/utils.ts index 4bbc6317d2..0d350267d1 100644 --- a/src/Utils/utils.ts +++ b/src/Utils/utils.ts @@ -6,6 +6,7 @@ import { import phoneCodesJson from "../Common/static/countryPhoneAndFlags.json"; import dayjs from "./dayjs"; import { UserModel } from "../Components/Users/models"; +import { PatientModel } from "../Components/Patient/models"; interface ApacheParams { age: number; @@ -396,31 +397,46 @@ export const getCountryCode = (phoneNumber: string) => { return undefined; }; -export const formatAge = ( - age?: number, - date_of_birth?: string, - abbreviated = false -) => { - if (!age && !date_of_birth) return undefined; - if (!age) age = 0; - - const daySuffix = abbreviated ? "d" : "days"; - const monthSuffix = abbreviated ? "mo" : "months"; - const yearSuffix = abbreviated ? "yr" : "years"; - - if (age < 1 && date_of_birth) { - const dob = new Date(date_of_birth); - const today = new Date(); - const diffTime = Math.abs(today.getTime() - dob.getTime()); - const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)); - const months = Math.floor(diffDays / 30); - const days = diffDays % 30; - if (months === 0) { - return `${days} ${daySuffix}`; - } - return `${months} ${monthSuffix} ${days} ${daySuffix}`; +const getRelativeDateSuffix = (abbreviated: boolean) => { + return { + day: abbreviated ? "d" : "days", + month: abbreviated ? "mo" : "months", + year: abbreviated ? "yr" : "years", + }; +}; + +export const formatPatientAge = (obj: PatientModel, abbreviated = false) => { + const suffixes = getRelativeDateSuffix(abbreviated); + + 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() + ); + + const years = end.diff(start, "years"); + if (years) { + return `${years}${suffixes.year}`; + } + + // Skip representing as no. of months/days if we don't know the date of birth + // since it would anyways be inaccurate. + if (!obj.date_of_birth) { + return abbreviated + ? `Born ${obj.year_of_birth}` + : `Born on ${obj.year_of_birth}`; + } + + const month = end.diff(start, "month"); + const day = end.diff(start.add(month, "month"), "day"); + if (month) { + return `${month}${suffixes.month} ${day}${suffixes.day}`; } - return `${age} ${yearSuffix}`; + return `${day}${suffixes.day}`; }; export const scrollTo = (id: string | boolean) => {