From e0fbc68d390676b5f6f9258a631c53d1d441ce96 Mon Sep 17 00:00:00 2001 From: CynthiaKamau Date: Sun, 14 Jul 2024 17:59:43 +0300 Subject: [PATCH] Add hiv care and treatment summary tabs --- .../care-and-treatment.component.tsx | 33 +++++--- .../tabs/allergies-config.json | 40 +++++++++ .../tabs/allergies.component.tsx | 26 ++++++ .../tabs/hospitalization-config.json | 39 +++++++++ .../tabs/hospitalization.component.tsx | 27 +++++++ src/care-and-treatment/tabs/image-config.json | 23 ++++++ .../tabs/image.component.tsx | 25 ++++++ src/care-and-treatment/tabs/oi-config.json | 39 +++++++++ src/care-and-treatment/tabs/oi.component.tsx | 25 ++++++ ...ne.component.tsx => problem.component.tsx} | 6 +- .../tabs/tab-three.component.tsx | 17 ---- .../tabs/tab-two.component.tsx | 17 ---- src/care-and-treatment/tabs/visit-config.json | 47 +++++++++++ .../tabs/visit.component.tsx | 25 ++++++ src/config-schema.ts | 81 ++++++++++++++----- 15 files changed, 405 insertions(+), 65 deletions(-) create mode 100644 src/care-and-treatment/tabs/allergies-config.json create mode 100644 src/care-and-treatment/tabs/allergies.component.tsx create mode 100644 src/care-and-treatment/tabs/hospitalization-config.json create mode 100644 src/care-and-treatment/tabs/hospitalization.component.tsx create mode 100644 src/care-and-treatment/tabs/image-config.json create mode 100644 src/care-and-treatment/tabs/image.component.tsx create mode 100644 src/care-and-treatment/tabs/oi-config.json create mode 100644 src/care-and-treatment/tabs/oi.component.tsx rename src/care-and-treatment/tabs/{tab-one.component.tsx => problem.component.tsx} (67%) delete mode 100644 src/care-and-treatment/tabs/tab-three.component.tsx delete mode 100644 src/care-and-treatment/tabs/tab-two.component.tsx create mode 100644 src/care-and-treatment/tabs/visit-config.json create mode 100644 src/care-and-treatment/tabs/visit.component.tsx diff --git a/src/care-and-treatment/care-and-treatment.component.tsx b/src/care-and-treatment/care-and-treatment.component.tsx index 1663ca2..e703c2b 100644 --- a/src/care-and-treatment/care-and-treatment.component.tsx +++ b/src/care-and-treatment/care-and-treatment.component.tsx @@ -2,9 +2,12 @@ import React from "react"; import { Tabs, Tab, TabList, TabPanels, TabPanel } from "@carbon/react"; import styles from "../common.scss"; import { useTranslation } from "react-i18next"; -import TabOne from "./tabs/tab-one.component"; -import TabThree from "./tabs/tab-three.component"; -import TabTwo from "./tabs/tab-two.component"; +import Problem from "./tabs/problem.component"; +import Visit from "./tabs/visit.component"; +import OI from "./tabs/oi.component"; +import Allergies from "./tabs/allergies.component"; +import Hospitalization from "./tabs/hospitalization.component"; +import Image from "./tabs/image.component"; interface OverviewListProps { patientUuid: string; @@ -16,19 +19,31 @@ const CareAndTreatment: React.FC = ({ patientUuid }) => {
- {t("tabOne", "Tab One")} - {t("tabTwo", "Tab Two")} - {t("tabThree", "Tab Three")} + {t("visit", "Visit")} + {t("problem", "Problem")} + {t("oi", "OI")} + {t("image", "Image")} + {t("allergies", "Allergies")} + {t("hospitalization", "Hospitalization")} - + - + - + + + + + + + + + + diff --git a/src/care-and-treatment/tabs/allergies-config.json b/src/care-and-treatment/tabs/allergies-config.json new file mode 100644 index 0000000..5a5a3fb --- /dev/null +++ b/src/care-and-treatment/tabs/allergies-config.json @@ -0,0 +1,40 @@ +{ + "menuId": "allergies", + "cardTitle": "Allergies", + "columns": [ + { + "id": "encounterDate", + "isDate": true, + "title": "Encounter Date", + "encounterTypes": [ + "allergyEncounterType" + ], + "concept": "encounterDate" + }, + { + "id": "suspectedDrug", + "title": "Suspected Drug", + "encounterTypes": [ + "allergyEncounterType" + ], + "concept": "suspectedDrugConcept" + }, + + { + "id": "drugEffect", + "title": "Drug Effect", + "encounterTypes": [ + "allergyEncounterType" + ], + "concept": "drugEffectConcept" + }, + { + "id": "actionTaken", + "title": "Action Taken", + "encounterTypes": [ + "allergyEncounterType" + ], + "concept": "actionTakenConcept" + } + ] +} \ No newline at end of file diff --git a/src/care-and-treatment/tabs/allergies.component.tsx b/src/care-and-treatment/tabs/allergies.component.tsx new file mode 100644 index 0000000..cf9caf1 --- /dev/null +++ b/src/care-and-treatment/tabs/allergies.component.tsx @@ -0,0 +1,26 @@ +import React from "react"; +import { + getSummaryCardProps, + SummaryCard, +} from "@ohri/openmrs-esm-ohri-commons-lib"; +import { useTranslation } from "react-i18next"; +import allergiesCongif from "./allergies-config.json"; +import { useConfig } from "@openmrs/esm-framework"; + +const Allergies: React.FC<{ patientUuid: string }> = ({ patientUuid }) => { + const { t } = useTranslation(); + const config = useConfig(); + const allergyCardColumns = getSummaryCardProps(allergiesCongif, config); + + const title = t("allergies", "Allergies"); + + return ( + + ); +}; + +export default Allergies; diff --git a/src/care-and-treatment/tabs/hospitalization-config.json b/src/care-and-treatment/tabs/hospitalization-config.json new file mode 100644 index 0000000..f938607 --- /dev/null +++ b/src/care-and-treatment/tabs/hospitalization-config.json @@ -0,0 +1,39 @@ +{ + "menuId": "hospitalization", + "cardTitle": "Hospitalization", + "columns": [ + { + "id": "encounterDate", + "isDate": true, + "title": "Encounter Date", + "encounterTypes": [ + "hospitalizationEncounterType" + ], + "concept": "encounterDate" + }, + { + "id": "reasonForHospitalization", + "title": "Reason For Hospitalization", + "encounterTypes": [ + "hospitalizationEncounterType" + ], + "concept": "reasonForHospitalizationConcept" + }, + { + "id": "duration", + "title": "Duration", + "encounterTypes": [ + "hospitalizationEncounterType" + ], + "concept": "durationConcept" + }, + { + "id": "durationUnit", + "title": "Duration Unit", + "encounterTypes": [ + "hospitalizationEncounterType" + ], + "concept": "durationUnitConcept" + } + ] +} \ No newline at end of file diff --git a/src/care-and-treatment/tabs/hospitalization.component.tsx b/src/care-and-treatment/tabs/hospitalization.component.tsx new file mode 100644 index 0000000..4b13b0b --- /dev/null +++ b/src/care-and-treatment/tabs/hospitalization.component.tsx @@ -0,0 +1,27 @@ +import React from "react"; +import { + getSummaryCardProps, + SummaryCard, +} from "@ohri/openmrs-esm-ohri-commons-lib"; +import { useTranslation } from "react-i18next"; +import hospitalizationConfig from "./hospitalization-config.json"; +import { useConfig } from "@openmrs/esm-framework"; + +const Hospitalization: React.FC<{ patientUuid: string }> = ({ + patientUuid, +}) => { + const { t } = useTranslation(); + const config = useConfig(); + const allergyCardColumns = getSummaryCardProps(hospitalizationConfig, config); + const title = t("hospitalization", "Hospitalization"); + + return ( + + ); +}; + +export default Hospitalization; diff --git a/src/care-and-treatment/tabs/image-config.json b/src/care-and-treatment/tabs/image-config.json new file mode 100644 index 0000000..47d7852 --- /dev/null +++ b/src/care-and-treatment/tabs/image-config.json @@ -0,0 +1,23 @@ +{ + "menuId": "opportunisticInfections", + "cardTitle": "Opportunistic Infections", + "columns": [ + { + "id": "encounterDate", + "isDate": true, + "title": "Encounter Date", + "encounterTypes": [ + "imageEncounterType" + ], + "concept": "encounterDate" + }, + { + "id": "imageOrdered", + "title": "Image ordered", + "encounterTypes": [ + "imageEncounterType" + ], + "concept": "imageOrderedConcept" + } + ] +} \ No newline at end of file diff --git a/src/care-and-treatment/tabs/image.component.tsx b/src/care-and-treatment/tabs/image.component.tsx new file mode 100644 index 0000000..7c90696 --- /dev/null +++ b/src/care-and-treatment/tabs/image.component.tsx @@ -0,0 +1,25 @@ +import React from "react"; +import { + getSummaryCardProps, + SummaryCard, +} from "@ohri/openmrs-esm-ohri-commons-lib"; +import { useTranslation } from "react-i18next"; +import imageConfig from "./image-config.json"; +import { useConfig } from "@openmrs/esm-framework"; + +const Image: React.FC<{ patientUuid: string }> = ({ patientUuid }) => { + const { t } = useTranslation(); + const config = useConfig(); + const imageCardColumns = getSummaryCardProps(imageConfig, config); + const title = t("image", "Image"); + + return ( + + ); +}; + +export default Image; diff --git a/src/care-and-treatment/tabs/oi-config.json b/src/care-and-treatment/tabs/oi-config.json new file mode 100644 index 0000000..7a05c46 --- /dev/null +++ b/src/care-and-treatment/tabs/oi-config.json @@ -0,0 +1,39 @@ +{ + "menuId": "opportunisticInfections", + "cardTitle": "Opportunistic Infections", + "columns": [ + { + "id": "encounterDate", + "isDate": true, + "title": "Encounter Date", + "encounterTypes": [ + "oiEncounterType" + ], + "concept": "encounterDate" + }, + { + "id": "chronicCareDx", + "title": "Suspected Drug", + "encounterTypes": [ + "oiEncounterType" + ], + "concept": "chronicCareDxConcept" + }, + { + "id": "whoStage", + "title": "WHO Stage", + "encounterTypes": [ + "oiEncounterType" + ], + "concept": "whoStageConcept" + }, + { + "id": "criteria", + "title": "Criteria", + "encounterTypes": [ + "oiEncounterType" + ], + "concept": "criteriaConcept" + } + ] +} \ No newline at end of file diff --git a/src/care-and-treatment/tabs/oi.component.tsx b/src/care-and-treatment/tabs/oi.component.tsx new file mode 100644 index 0000000..3d9e29e --- /dev/null +++ b/src/care-and-treatment/tabs/oi.component.tsx @@ -0,0 +1,25 @@ +import React from "react"; +import { + getSummaryCardProps, + SummaryCard, +} from "@ohri/openmrs-esm-ohri-commons-lib"; +import { useTranslation } from "react-i18next"; +import { useConfig } from "@openmrs/esm-framework"; +import oiConfig from "./oi-config.json"; + +const OI: React.FC<{ patientUuid: string }> = ({ patientUuid }) => { + const { t } = useTranslation(); + const config = useConfig(); + const oiCardColumns = getSummaryCardProps(oiConfig, config); + const title = t("opportunisticInfections", "Opportunistic Infections"); + + return ( + + ); +}; + +export default OI; diff --git a/src/care-and-treatment/tabs/tab-one.component.tsx b/src/care-and-treatment/tabs/problem.component.tsx similarity index 67% rename from src/care-and-treatment/tabs/tab-one.component.tsx rename to src/care-and-treatment/tabs/problem.component.tsx index 38c46ec..d19dc30 100644 --- a/src/care-and-treatment/tabs/tab-one.component.tsx +++ b/src/care-and-treatment/tabs/problem.component.tsx @@ -2,10 +2,10 @@ import React from "react"; import { useTranslation } from "react-i18next"; import { EmptyStateComingSoon } from "@ohri/openmrs-esm-ohri-commons-lib"; -const TabOne: React.FC<{ patientUuid: string }> = ({ patientUuid }) => { +const Problem: React.FC<{ patientUuid: string }> = ({ patientUuid }) => { const { t } = useTranslation(); - const title = t("tabOne", "Tab One"); + const title = t("problem", "Problem"); return ( <> @@ -14,4 +14,4 @@ const TabOne: React.FC<{ patientUuid: string }> = ({ patientUuid }) => { ); }; -export default TabOne; +export default Problem; diff --git a/src/care-and-treatment/tabs/tab-three.component.tsx b/src/care-and-treatment/tabs/tab-three.component.tsx deleted file mode 100644 index 3431ef0..0000000 --- a/src/care-and-treatment/tabs/tab-three.component.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import React from "react"; -import { EmptyStateComingSoon } from "@ohri/openmrs-esm-ohri-commons-lib"; -import { useTranslation } from "react-i18next"; - -const TabThree: React.FC<{ patientUuid: string }> = ({ patientUuid }) => { - const { t } = useTranslation(); - - const title = t("tabThree", "Tab Three"); - - return ( - <> - - - ); -}; - -export default TabThree; diff --git a/src/care-and-treatment/tabs/tab-two.component.tsx b/src/care-and-treatment/tabs/tab-two.component.tsx deleted file mode 100644 index 5d0f4d2..0000000 --- a/src/care-and-treatment/tabs/tab-two.component.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import React from "react"; -import { EmptyStateComingSoon } from "@ohri/openmrs-esm-ohri-commons-lib"; -import { useTranslation } from "react-i18next"; - -const TabTwo: React.FC<{ patientUuid: string }> = ({ patientUuid }) => { - const { t } = useTranslation(); - - const title = t("tabTwo", "Tab Two"); - - return ( - <> - - - ); -}; - -export default TabTwo; diff --git a/src/care-and-treatment/tabs/visit-config.json b/src/care-and-treatment/tabs/visit-config.json new file mode 100644 index 0000000..2995142 --- /dev/null +++ b/src/care-and-treatment/tabs/visit-config.json @@ -0,0 +1,47 @@ +{ + "menuId": "visit", + "cardTitle": "Visit", + "columns": [ + { + "id": "weight", + "title": "Weight", + "encounterTypes": [ + "visitEncounterType" + ], + "concept": "weightConcept" + }, + { + "id": "tbScreening", + "title": "Tb Screening", + "encounterTypes": [ + "visitEncounterType" + ], + "concept": "tbScreeningConcept" + }, + { + "id": "contraception", + "title": "Contraception", + "encounterTypes": [ + "visitEncounterType" + ], + "concept": "contraceptionConcept" + }, + { + "id": "pregnant", + "title": "Pregnant", + "encounterTypes": [ + "visitEncounterType" + ], + "concept": "pregnantConcept" + }, + { + "id": "nextVisit", + "isDate": true, + "title": "Next Visit", + "encounterTypes": [ + "visitEncounterType" + ], + "concept": "nextVisitConcept" + } + ] +} \ No newline at end of file diff --git a/src/care-and-treatment/tabs/visit.component.tsx b/src/care-and-treatment/tabs/visit.component.tsx new file mode 100644 index 0000000..b459689 --- /dev/null +++ b/src/care-and-treatment/tabs/visit.component.tsx @@ -0,0 +1,25 @@ +import React from "react"; +import { + getSummaryCardProps, + SummaryCard, +} from "@ohri/openmrs-esm-ohri-commons-lib"; +import { useTranslation } from "react-i18next"; +import { useConfig } from "@openmrs/esm-framework"; +import visitConfig from "./visit-config.json"; + +const Visit: React.FC<{ patientUuid: string }> = ({ patientUuid }) => { + const { t } = useTranslation(); + const config = useConfig(); + const visitCardColumns = getSummaryCardProps(visitConfig, config); + const title = t("visit", "Visit"); + + return ( + + ); +}; + +export default Visit; diff --git a/src/config-schema.ts b/src/config-schema.ts index 00f6c55..ef513d3 100644 --- a/src/config-schema.ts +++ b/src/config-schema.ts @@ -1,26 +1,69 @@ -import { Type, validator } from "@openmrs/esm-framework"; +import { Type } from "@openmrs/esm-framework"; export const configSchema = { - casualGreeting: { - _type: Type.Boolean, - _default: false, - _description: "Whether to use a casual greeting (or a formal one).", + encounterTypes: { + _type: Type.Object, + _description: "Encounter type UUIDs for HIV.", + _default: { + allergyEncounterType: "2dc31190-cf0e-4ab0-a5a1-6ad601d6ecc0", + visitEncounterType: "2dc31190-cf0e-4ab0-a5a1-6ad601d6ecc0", + hospitalizationEncounterType: "2dc31190-cf0e-4ab0-a5a1-6ad601d6ecc0", + oiEncounterType: "2dc31190-cf0e-4ab0-a5a1-6ad601d6ecc0", + imageEncounterType: "74bf4fe6-8fdb-4228-be39-680a93a9cf6d", + problemEncounterType: "2dc31190-cf0e-4ab0-a5a1-6ad601d6ecc0", + }, + }, + obsConcepts: { + _type: Type.Object, + _description: "List of observation concept UUIDs related to HIV.", + _default: { + suspectedDrugConcept: "3cd95ed6-26fe-102b-80cb-0017a47871b2", + drugEffectConcept: "3cd96052-26fe-102b-80cb-0017a47871b2", + actionTakenConcept: "3cdc7e2c-26fe-102b-80cb-0017a47871b2", + weightConcept: "3ce93b62-26fe-102b-80cb-0017a47871b2", + tbScreeningConcept: "3ce14c2c-26fe-102b-80cb-0017a47871b2", + contraceptionConcept: "3ccfbd0e-26fe-102b-80cb-0017a47871b2", + pregnantConcept: "3ceb4880-26fe-102b-80cb-0017a47871b2", + nextVisitConcept: "3ce94df0-26fe-102b-80cb-0017a47871b2", + reasonForHospitalizationConcept: "3ce1492a-26fe-102b-80cb-0017a47871b2", + durationConcept: "bd7a77ed-32ed-43cd-9719-e3ab09f22457", + durationUnitConcept: "f1904502-319d-4681-9030-e642111e7ce2", + chronicCareDxConcept: "0ae23a5a-15f5-102d-96e4-000c29c2a5d7", + whoStageConcept: "3cdb3b02-26fe-102b-80cb-0017a47871b2", + criteriaConcept: "3ce6d5fc-26fe-102b-80cb-0017a47871b2", + imageOrderedConcept: "3cd937e4-26fe-102b-80cb-0017a47871b2", + }, }, - whoToGreet: { - _type: Type.Array, - _default: ["World"], - _description: - "Who should be greeted. Names will be separated by a comma and space.", - _elements: { - _type: Type.String, + formNames: { + _type: Type.Object, + _description: "HIV Form Names", + _default: { + allergiesFormName: "A - HIV Visit - Allergy Form", + hospitalizationFormName: "POC Clinical Visit Form v2", + imageFormName: "A - HIV Visit - Imaging Form", + oiFormName: "A - HIV Visit - OI Form", + visitFormName: "A - HIV Visit - Visit Form", + problemFormName: "A - HIV Visit - Problem Form", + }, + }, + formUuids: { + _type: Type.Object, + _description: "HIV Form Uuids", + _default: { + allergiesFormUuid: "097eb43d-27bd-342a-9057-50fa0d90727d", + hospitalizationFormUuid: "b3abc4ce-c5ac-3c40-b8e7-442b163670f1", + imageFormUuid: "c0657c47-959b-3062-a88e-e3379ad09ced", + oiFormUuid: "f5ee42df-8f8b-3f89-98c3-235220ff4dbd", + visitFormUuid: "221e6a43-7ebd-3d3d-bca0-ffe7a7dcb158", + problemFormUuid: "3a1f6357-ed3e-3917-bdcc-7af720ac3813", }, - _validators: [ - validator((v) => v.length > 0, "At least one person must be greeted."), - ], }, }; -export type Config = { - casualGreeting: boolean; - whoToGreet: Array; -}; +export interface ConfigObject { + cohorts: object; + encounterTypes: object; + obsConcepts: object; + formNames: object; + formUuids: object; +}