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

Add Age field in patient registration #7411

Merged
merged 27 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a8207d8
Add age field in patient registration form
rash-27 Mar 13, 2024
027efa5
Add test for age input in user registration
rash-27 Mar 13, 2024
6e87d92
Merge branch 'develop' into i#7383
rithviknishad Mar 14, 2024
3be630a
fixes based on code review
rithviknishad Mar 14, 2024
d115c07
use updated patient age formatting
rithviknishad Mar 14, 2024
7f3d3bf
calculate age from FE
rithviknishad Mar 14, 2024
4daf19a
fix year_of_birth to be non readonly
rithviknishad Mar 14, 2024
0348710
Merge branch 'develop' into i#7383
rithviknishad Mar 19, 2024
b542555
update cypress so that it works every year
rithviknishad Mar 19, 2024
268a457
Merge branch 'develop' into i#7383
rithviknishad Mar 19, 2024
8768cbf
changes according to review
rash-27 Mar 20, 2024
49f3f1e
modify cypress tests
rash-27 Mar 20, 2024
574ae22
update cypress tests
rash-27 Mar 20, 2024
38c34ce
modify trailing text
rash-27 Mar 20, 2024
154e910
update cypress tests
rash-27 Mar 20, 2024
c891f40
update age format in Patientinfocard
rash-27 Mar 22, 2024
56f4e11
changes according to review
rash-27 Mar 23, 2024
ed07099
update cypress tests
rash-27 Mar 23, 2024
694702f
Merge branch 'develop' into i#7383
nihal467 Mar 26, 2024
33e0688
fix cypress issues
nihal467 Mar 26, 2024
8343865
Merge branch 'develop' into i#7383
nihal467 Mar 26, 2024
042c2c1
fix error in the shift details page
nihal467 Mar 26, 2024
f66cf7f
fix type errors in shift details
rithviknishad Mar 27, 2024
f1f69b8
fix
rithviknishad Mar 27, 2024
2182ad3
Merge branch 'develop' into i#7383
rithviknishad Apr 2, 2024
38cbb48
fix type errors
rithviknishad Apr 2, 2024
4387e75
fix cypress
nihal467 Apr 2, 2024
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
15 changes: 10 additions & 5 deletions cypress/e2e/patient_spec/patient_registration.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ describe("Patient Creation with consultation", () => {
const patientExternal = new PatientExternal();
const patientInsurance = new PatientInsurance();
const patientMedicalHistory = new PatientMedicalHistory();
const phone_number = generatePhoneNumber();
const emergency_phone_number = generateEmergencyPhoneNumber();
let phone_number = generatePhoneNumber();
let emergency_phone_number = generateEmergencyPhoneNumber();
const age = calculateAge();
const patientFacility = "Dummy Facility 40";
const patientDateOfBirth = "01012001";
Expand Down Expand Up @@ -74,13 +74,15 @@ describe("Patient Creation with consultation", () => {

it("Create a new patient with all field in registration form and no consultation", () => {
// patient details with all the available fields except covid
phone_number = generatePhoneNumber();
emergency_phone_number = generateEmergencyPhoneNumber();
patientPage.createPatient();
patientPage.selectFacility(patientFacility);
patientPage.patientformvisibility();
// Patient Details page
patientPage.typePatientPhoneNumber(phone_number);
patientPage.typePatientEmergencyNumber(emergency_phone_number);
patientPage.typePatientDateOfBirth(patientDateOfBirth);
patientPage.typePatientAge(age);
patientPage.typePatientName(patientOneName);
patientPage.selectPatientGender(patientOneGender);
patientPage.typePatientAddress(patientOneAddress);
Expand Down Expand Up @@ -118,7 +120,8 @@ describe("Patient Creation with consultation", () => {
emergency_phone_number,
yearOfBirth,
patientOneBloodGroup,
patientOccupation
patientOccupation,
"Year of Birth"
);
patientMedicalHistory.verifyPatientMedicalDetails(
patientOnePresentHealth,
Expand Down Expand Up @@ -146,6 +149,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
Expand Down Expand Up @@ -206,7 +210,8 @@ describe("Patient Creation with consultation", () => {
emergency_phone_number,
yearOfBirth,
patientOneUpdatedBloodGroup,
patientOccupation
patientOccupation,
"Date of Birth"
);
// Verify No medical history
patientMedicalHistory.verifyNoSymptosPresent("Diabetes");
Expand Down
10 changes: 9 additions & 1 deletion cypress/pageobject/Patient/PatientCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,16 @@ export class PatientPage {
}

typePatientDateOfBirth(dateOfBirth: string) {
cy.clickAndSelectOption("#ageOrDob-selector", "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: number) {
cy.clickAndSelectOption("#ageOrDob-selector", "Age");
cy.submitButton("Confirm");
cy.get("#age").clear().type(age);
}

typePatientName(patientName: string) {
cy.get("[data-testid=name] input").click().type(patientName);
Expand Down Expand Up @@ -138,7 +144,8 @@ export class PatientPage {
emergencyPhoneNumber,
yearOfBirth,
bloodGroup,
occupation
occupation,
DobOrAge
) {
cy.url().should("include", "/facility/");
cy.get("[data-testid=patient-dashboard]").then(($dashboard) => {
Expand All @@ -150,6 +157,7 @@ export class PatientPage {
expect($dashboard).to.contain(yearOfBirth);
expect($dashboard).to.contain(bloodGroup);
expect($dashboard).to.contain(occupation);
expect($dashboard).to.contain(DobOrAge);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import useVitalsAspectRatioConfig from "../../VitalsMonitor/useVitalsAspectRatio
import { DISCHARGE_REASONS, SYMPTOM_CHOICES } 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";
Expand Down Expand Up @@ -629,12 +633,7 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => {
<div>
Age {" - "}
<span className="font-semibold">
{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)}
</span>
</div>
<div id="patient-weight">
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Facility/DischargedPatientsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -100,7 +100,7 @@ const PatientListItem = ({ patient }: { patient: PatientModel }) => {
<h2 className="text-lg font-bold text-black">{patient.name}</h2>
<span className="text-sm font-medium text-gray-800">
{GENDER_TYPES.find((g) => g.id === patient.gender)?.text} -{" "}
{formatAge(patient.age, patient.date_of_birth)}
{formatPatientAge(patient)}
</span>
<div className="flex-1" />
<RecordMeta
Expand Down
14 changes: 3 additions & 11 deletions src/Components/Facility/Investigations/Reports/ReportTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getColorIndex, rowColor, transformData } from "./utils";

import ButtonV2 from "../../../Common/components/ButtonV2";
import { InvestigationResponse } from "./types";
import { formatAge, formatDateTime } from "../../../../Utils/utils";
import { formatDateTime } from "../../../../Utils/utils";
import { FC } from "react";

const ReportRow = ({ data, name, min, max }: any) => {
Expand Down Expand Up @@ -52,8 +52,7 @@ interface ReportTableProps {
title?: string;
patientDetails?: {
name: string;
age: number;
date_of_birth: string;
age: string;
hospitalName: string;
};
investigationData: InvestigationResponse;
Expand Down Expand Up @@ -84,14 +83,7 @@ const ReportTable: FC<ReportTableProps> = ({
{patientDetails && (
<div className="flex flex-col gap-1 p-1">
<p>Name: {patientDetails.name}</p>
<p>
Age:{" "}
{formatAge(
patientDetails.age,
patientDetails.date_of_birth,
true
)}
</p>
<p>Age: {patientDetails.age}</p>
<p>Hospital: {patientDetails.hospitalName}</p>
</div>
)}
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Facility/Investigations/Reports/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 || "",
}}
/>
Expand Down
12 changes: 6 additions & 6 deletions src/Components/Facility/TreatmentSummary.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -66,11 +70,7 @@ const TreatmentSummary = (props: any) => {
<div className="col-span-1 grid print:grid-cols-2 sm:grid-cols-2 ">
<div className="col-span-1 border-b-2 border-gray-800 px-3 py-2 print:border-b-0 print:border-r-2 sm:border-b-0 sm:border-r-2">
<b>Age :</b>{" "}
{formatAge(
patientData?.age ?? 0,
patientData?.date_of_birth ?? "",
true
)}
{patientData ? formatPatientAge(patientData, true) : ""}
</div>
<div className="col-span-1 border-b-2 border-gray-800 px-3 py-2 print:border-b-0 print:border-r-2 sm:border-b-0 sm:border-r-2">
<b>OP :</b> {consultationData?.patient_no ?? ""}
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Patient/ManagePatients.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -531,7 +531,7 @@ export const PatientManager = () => {
>
<span className="text-xl capitalize">{patient.name}</span>
<span className="text-gray-800">
{formatAge(patient.age, patient.date_of_birth, true)}
{formatPatientAge(patient, true)}
</span>
</div>
</div>
Expand Down
17 changes: 8 additions & 9 deletions src/Components/Patient/PatientHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -342,12 +342,7 @@ export const PatientHome = (props: any) => {
<div>
<div className="flex flex-row gap-4">
<h1 className="flex flex-row pb-3 text-2xl font-bold">
{patientData.name} -{" "}
{formatAge(
patientData.age,
patientData.date_of_birth,
true
)}
{patientData.name} - {formatPatientAge(patientData, true)}
</h1>
<div className="ml-auto mr-9 flex flex-wrap gap-3">
{patientData.is_vaccinated ? (
Expand Down Expand Up @@ -427,10 +422,14 @@ export const PatientHome = (props: any) => {
<div className="mb-8 mt-2 grid grid-cols-1 gap-x-4 gap-y-2 md:grid-cols-2 md:gap-y-8 lg:grid-cols-4">
<div className="sm:col-span-1">
<div className="text-sm font-semibold leading-5 text-zinc-400">
Date of Birth
{patientData.date_of_birth
? "Date of Birth"
: "Year of Birth"}
</div>
<div className="mt-1 text-sm font-medium leading-5">
{formatDate(patientData?.date_of_birth)}
{patientData.date_of_birth
? formatDate(patientData.date_of_birth)
: patientData.year_of_birth}
</div>
</div>
<div className="sm:col-span-1">
Expand Down
11 changes: 8 additions & 3 deletions src/Components/Patient/PatientInfoCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -217,7 +222,7 @@ export default function PatientInfoCard(props: {
>
{patient.name}
<div className="ml-3 mr-2 mt-[6px] text-sm font-semibold text-gray-600">
{patient.age} years • {patient.gender}
{formatPatientAge(patient, true)} • {patient.gender}
</div>
<div className="mr-3 flex flex-col items-center">
<Link
Expand Down Expand Up @@ -262,7 +267,7 @@ export default function PatientInfoCard(props: {
>
{patient.name}
<div className="ml-3 mr-2 mt-[6px] text-sm font-semibold text-gray-600">
{patient.age} years • {patient.gender}
{formatPatientAge(patient, true)} • {patient.gender}
</div>
</div>
<div className="flex flex-wrap items-center gap-2 text-sm sm:flex-row">
Expand Down
Loading
Loading