Skip to content

Commit

Permalink
(feat) PMTCT form hides depending on patient age or gender
Browse files Browse the repository at this point in the history
  • Loading branch information
aman-icap committed Jan 3, 2024
1 parent d28ca51 commit a73ee9b
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 87 deletions.
4 changes: 4 additions & 0 deletions src/ethiohri-dashboard.meta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,22 @@ export const HIV_CARE_AND_TREATMENT = {
export const PMTCT_META = {
title: "PMTCT",
slotName: "ethio-pmtct-slot",
patientExpression:
"calculateAge(patient.birthDate) <= 3 || patient.gender === 'female'",
};

export const CHILD_HEALTH_SUMMARY = {
title: "Child Health Summary",
slot: "child-health-slot",
path: "child-health",
patientExpression: "calculateAge(patient.birthDate) <= 3",
};

export const MOTHER_HEALTH_SUMMARY = {
title: "Mother Health Summary",
slot: "mother-health-slot",
path: "mother-health",
patientExpression: "patient.gender === 'female'",
};

export const PREP_META = {
Expand Down
11 changes: 8 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ import {
getGender,
getIdentifier,
} from "./custom-expressions";
import {
createConditionalDashboardGroup,
createConditionalDashboardLink,
} from "@ohri/openmrs-esm-ohri-commons-lib";

export const moduleName = "@icap-ethiopia/esm-ethiohri-app";
export const options = { featureName: "ethiohri", moduleName };
Expand Down Expand Up @@ -118,12 +122,13 @@ export const clinicalVisitsChart = getAsyncLifecycle(
() => import("./pages/visits/visits-summary.component"),
options
);

export const pmtctMenu = getSyncLifecycle(
createDashboardGroup(PMTCT_META),
createConditionalDashboardGroup(PMTCT_META),
options
);
export const childHealthMenu = getSyncLifecycle(
createDashboardLink({
createConditionalDashboardLink({
...CHILD_HEALTH_SUMMARY,
moduleName,
}),
Expand All @@ -134,7 +139,7 @@ export const childHealthChart = getAsyncLifecycle(
options
);
export const motherHealthMenu = getSyncLifecycle(
createDashboardLink({
createConditionalDashboardLink({
...MOTHER_HEALTH_SUMMARY,
moduleName,
}),
Expand Down
67 changes: 25 additions & 42 deletions src/pages/pmtct/child/pmtct-child.component.tsx
Original file line number Diff line number Diff line change
@@ -1,55 +1,38 @@
import { Tab, Tabs, TabList, TabPanels, TabPanel } from "@carbon/react";
import React, { useEffect, useState } from "react";
import React from "react";
import styles from "../../program-management/program-management.scss";
import style from "../../../root.scss";
import PMTCTRegistrationEncounterList from "./tabs/pmtct-child-registration.component";
import PMTCTImmunizationEncounterList from "./tabs/pmtct-child-immunization.component";
import PMTCTFollowupEncounterList from "./tabs/pmtct-child-followup.component";
import PMTCTChildFinalOutcomeEncounterList from "./tabs/pmtct-child-final-outcome";
import { fetchPatientInfo } from "../../../api/api";
import { AGE_ABOVE_THREE_WARNING } from "../../../constants";

const ChildHealth: React.FC<{ patientUuid: string }> = ({ patientUuid }) => {
const [showTabs, setShowTabs] = useState(false);
useEffect(() => {
(async () => {
const patientInfo = await fetchPatientInfo(patientUuid);
setShowTabs(patientInfo.data.age <= 3);
})();
}, []);

return (
<>
{showTabs ? (
<div className={styles.tabContainer}>
<Tabs>
<TabList contained aria-label={""}>
<Tab>HEI Enrollment</Tab>
<Tab>HEI Immunization</Tab>
<Tab>HEI Followup</Tab>
<Tab>HEI Final Outcome</Tab>
</TabList>
<TabPanels>
<TabPanel>
<PMTCTRegistrationEncounterList patientUuid={patientUuid} />
</TabPanel>
<TabPanel>
<PMTCTImmunizationEncounterList patientUuid={patientUuid} />
</TabPanel>
<TabPanel>
<PMTCTFollowupEncounterList patientUuid={patientUuid} />
</TabPanel>
<TabPanel>
<PMTCTChildFinalOutcomeEncounterList
patientUuid={patientUuid}
/>
</TabPanel>
</TabPanels>
</Tabs>
</div>
) : (
<p className={style.patientName}>{AGE_ABOVE_THREE_WARNING}</p>
)}
<div className={styles.tabContainer}>
<Tabs>
<TabList contained aria-label={""}>
<Tab>HEI Enrollment</Tab>
<Tab>HEI Immunization</Tab>
<Tab>HEI Followup</Tab>
<Tab>HEI Final Outcome</Tab>
</TabList>
<TabPanels>
<TabPanel>
<PMTCTRegistrationEncounterList patientUuid={patientUuid} />
</TabPanel>
<TabPanel>
<PMTCTImmunizationEncounterList patientUuid={patientUuid} />
</TabPanel>
<TabPanel>
<PMTCTFollowupEncounterList patientUuid={patientUuid} />
</TabPanel>
<TabPanel>
<PMTCTChildFinalOutcomeEncounterList patientUuid={patientUuid} />
</TabPanel>
</TabPanels>
</Tabs>
</div>
</>
);
};
Expand Down
51 changes: 17 additions & 34 deletions src/pages/pmtct/mother/pmtct-mother.component.tsx
Original file line number Diff line number Diff line change
@@ -1,45 +1,28 @@
import { Tab, Tabs, TabList, TabPanels, TabPanel } from "@carbon/react";
import React, { useEffect, useState } from "react";
import React from "react";
import styles from "../../program-management/program-management.scss";
import style from "../../../root.scss";
import PMTCTMotherFinalOutcomeEncounterList from "./tabs/pmtct-mother-final-outcome";
import PMTCTMotherEnrollmentEncounterList from "./tabs/pmtct-mother-enrollment";
import { fetchPatientInfo } from "../../../api/api";
import { GENDER_PMTCT_WARNING } from "../../../constants";

const ChildHealth: React.FC<{ patientUuid: string }> = ({ patientUuid }) => {
const [showTabs, setShowTabs] = useState(null);
useEffect(() => {
(async () => {
const patientInfo = await fetchPatientInfo(patientUuid);
setShowTabs(patientInfo.data.gender === "F");
})();
}, []);

return (
<>
{showTabs ? (
<div className={styles.tabContainer}>
<Tabs>
<TabList contained aria-label={""}>
<Tab>Mother's Initial Registration</Tab>
<Tab>Mother's Final Outcome</Tab>
</TabList>
<TabPanels>
<TabPanel>
<PMTCTMotherEnrollmentEncounterList patientUuid={patientUuid} />
</TabPanel>
<TabPanel>
<PMTCTMotherFinalOutcomeEncounterList
patientUuid={patientUuid}
/>
</TabPanel>
</TabPanels>
</Tabs>
</div>
) : (
<p className={style.patientName}>{GENDER_PMTCT_WARNING}</p>
)}
<div className={styles.tabContainer}>
<Tabs>
<TabList contained aria-label={""}>
<Tab>Mother's Initial Registration</Tab>
<Tab>Mother's Final Outcome</Tab>
</TabList>
<TabPanels>
<TabPanel>
<PMTCTMotherEnrollmentEncounterList patientUuid={patientUuid} />
</TabPanel>
<TabPanel>
<PMTCTMotherFinalOutcomeEncounterList patientUuid={patientUuid} />
</TabPanel>
</TabPanels>
</Tabs>
</div>
</>
);
};
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3129,8 +3129,8 @@ __metadata:
linkType: hard

"@openmrs/openmrs-form-engine-lib@npm:next":
version: 1.0.0-pre.498
resolution: "@openmrs/openmrs-form-engine-lib@npm:1.0.0-pre.498"
version: 1.0.0-pre.514
resolution: "@openmrs/openmrs-form-engine-lib@npm:1.0.0-pre.514"
dependencies:
ace-builds: ^1.4.12
enzyme: ^3.11.0
Expand All @@ -3139,7 +3139,7 @@ __metadata:
jest-coverage-badges: ^1.0.0
lodash-es: ^4.17.15
react-anchor-link-smooth-scroll: ^1.0.12
react-error-boundary: 4.0.10
react-error-boundary: ^4.0.11
react-markdown: ^7.1.0
react-scroll: ^1.8.2
react-test-renderer: ^16.9.0
Expand All @@ -3153,7 +3153,7 @@ __metadata:
react: 18.x
react-i18next: 11.x
rxjs: 6.x
checksum: 08abb7abe2dd337e429950ab85c71378512ed97da4f216801eb1b661df89b88811b1d0ecc9f36c8a5990ec333fbb2653a372265e60194742e02fe0177667f845
checksum: 709635fcea90ebb2671ebaffa6954ce684fb2814c08555c7fbe88be060a065a5050f526bb006f50117a234da47402ac1bc7bc703cf81820f6f16f206dd0acc24
languageName: node
linkType: hard

Expand Down Expand Up @@ -16506,14 +16506,14 @@ __metadata:
languageName: node
linkType: hard

"react-error-boundary@npm:4.0.10":
version: 4.0.10
resolution: "react-error-boundary@npm:4.0.10"
"react-error-boundary@npm:^4.0.11":
version: 4.0.12
resolution: "react-error-boundary@npm:4.0.12"
dependencies:
"@babel/runtime": ^7.12.5
peerDependencies:
react: ">=16.13.1"
checksum: 4ad4864d2a5fc2264a24d03e83176e6a70d7adbe3c1edbdc5b0bd452a695104bc59456e23b5aea1b9729220672fe46614221daa8b3bd59327968d4aa7eb8bc71
checksum: c4a14c2b609037baba394d8871fb021a7c16fb1abfd8d23b2d2aa331bdcc420e5cff4b3d48f2f2ac7fa64ac90c322d0bcf358d706995b30df5a8d5fcb0c27b1e
languageName: node
linkType: hard

Expand Down

0 comments on commit a73ee9b

Please sign in to comment.