diff --git a/packages/esm-cervical-cancer-app/src/views/cacx-visits/cacx-config.json b/packages/esm-cervical-cancer-app/src/views/cacx-visits/cacx-config.json new file mode 100644 index 000000000..00ae5de36 --- /dev/null +++ b/packages/esm-cervical-cancer-app/src/views/cacx-visits/cacx-config.json @@ -0,0 +1,115 @@ +{ + "menuId": "cervicalCancer", + "tabDefinitions": [ + { + "tabName": "CaCx Registration", + "headerTitle": "CaCx Registration", + "displayText": "CaCx Registration", + "encounterType": "3eb24129-9f7d-4372-a14e-c2cf577e5db1", + "columns": [ + { + "id": "screeningDate", + "isDate": true, + "title": "Visit Date", + "concept": "2f256b46-395b-40f8-b93e-3ea68e5531bc" + }, + { + "id": "previouslyScreened", + "title": "Previously Screened for CaCx", + "concept": "7cf4c96a-3e68-4ca5-9b49-9148adc6263d" + }, + { + "id": "eligibleforScreening", + "title": "Eligible for CaCx Screening", + "concept": "b77ef6d3-4895-4e88-8b17-fa4aff6eba59" + }, + { + "id": "actions", + "title": "Actions", + "actionOptions": [ + { + "formName": "Cervical Cancer Registration Form", + "package": "cervical-cancer", + "label": "View Details", + "mode": "view" + }, + { + "formName": "Cervical Cancer Registration Form", + "package": "cervical-cancer", + "label": "Edit Form", + "mode": "edit" + } + ] + } + ], + "launchOptions": { + "displayText": "Add", + "moduleName": "@ohri/openmrs-esm-ohri-cervical-cancer-app" + }, + "formList": [ + { + "name": "Cervical Cancer Registration Form", + "uuid": "12f41bfe-6430-3d8c-9edf-2d1b7c904f0f" + } + ] + }, + { + "tabName": "CaCx Treatment", + "headerTitle": "CaCx Treatment", + "displayText": "CaCx Treatment", + "encounterType": "60c80941-c3dc-45c6-9b78-c150e0470cbd", + "columns": [ + { + "id": "encounterDate", + "isDate": true, + "title": "Visit Date", + "concept": "163137AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "screeningMethod", + "title": "Screening Method", + "concept": "53ff5cd0-0f37-4190-87b1-9eb439a15e94" + }, + { + "id": "screeningResult", + "title": "Screening Results", + "multipleConcepts": ["9096a18e-c009-4f4c-b0ba-0605e0f16578", "159859AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA","28bab50e-7ff7-4216-81be-3f7ad05c6547", "cc647244-0826-4d8e-8c5a-d7a371267bf4"], + "useMultipleObs": true + }, + { + "id": "cacxTreatment", + "title": "CaCx Treatment", + "concept": "3a8bb4b4-7496-415d-a327-57ae3711d4eb" + }, + { + "id": "actions", + "title": "Actions", + "actionOptions": [ + { + "formName": "Screening and Cancer Treatment Form", + "package": "cervical-cancer", + "label": "View Details", + "mode": "view" + }, + { + "formName": "Screening and Cancer Treatment Form", + "package": "cervical-cancer", + "label": "Edit Forms", + "mode": "edit" + } + ] + } + ], + "launchOptions": { + "displayText": "Add", + "moduleName": "@ohri/openmrs-esm-ohri-cervical-cancer-app" + }, + "formList": [ + { + "name": "Screening and Cancer Treatment Form", + "uuid": "9e3ec2a7-ad26-3f43-9677-82e318996eec" + } + ] + } + ] +} diff --git a/packages/esm-cervical-cancer-app/src/views/cacx-visits/cacx-visits-services.component.tsx b/packages/esm-cervical-cancer-app/src/views/cacx-visits/cacx-visits-services.component.tsx index 2e5060371..df5a0c7cf 100644 --- a/packages/esm-cervical-cancer-app/src/views/cacx-visits/cacx-visits-services.component.tsx +++ b/packages/esm-cervical-cancer-app/src/views/cacx-visits/cacx-visits-services.component.tsx @@ -1,31 +1,39 @@ import React from 'react'; import { Tabs, Tab, TabList, TabPanels, TabPanel } from '@carbon/react'; +import { EncounterList, getMenuItemTabConfiguration } from '@ohri/openmrs-esm-ohri-commons-lib'; +import cacxConfigSchema from './cacx-config.json'; + import styles from '../common.scss'; -import { useTranslation } from 'react-i18next'; -import { CacxTreatment } from './tabs/cacx-treatment.component'; -import { CacxRegistration } from './tabs/cacx-registration.component'; interface OverviewListProps { patientUuid: string; } const CaCxCervicalCancerServices: React.FC = ({ patientUuid }) => { - const { t } = useTranslation(); + const tabs = getMenuItemTabConfiguration(cacxConfigSchema); return (
- {t('cacxRegistration', 'CaCx Registration')} - {t('cacxTreatment', 'CaCx Treatment')} + {tabs.map((tab) => ( + {tab.name} + ))} - - - - - - + {tabs.map((tab) => ( + + + + ))}
diff --git a/packages/esm-cervical-cancer-app/src/views/cacx-visits/tabs/cacx-registration.component.tsx b/packages/esm-cervical-cancer-app/src/views/cacx-visits/tabs/cacx-registration.component.tsx deleted file mode 100644 index db64f392c..000000000 --- a/packages/esm-cervical-cancer-app/src/views/cacx-visits/tabs/cacx-registration.component.tsx +++ /dev/null @@ -1,92 +0,0 @@ -import React, { useMemo } from 'react'; -import { useTranslation } from 'react-i18next'; -import { EncounterList, EncounterListColumn, getObsFromEncounter } from '@ohri/openmrs-esm-ohri-commons-lib'; -import { moduleName } from '../../../index'; -import { useConfig } from '@openmrs/esm-framework'; - -interface CacxRegistrationProps { - patientUuid: string; -} - -export const CacxRegistration: React.FC = ({ patientUuid }) => { - const { t } = useTranslation(); - - const config = useConfig(); - - const { cervicalCancerScreeningDateConcept, eligibleForScreeningConcept, previouslyScreenedConcept } = - config.obsConcepts; - - const { cacxRegistrationEncounterType_UUID } = config.encounterTypes; - - const { cervicalCancerRegistrationForm } = config.formNames; - - const { cervicalCancerRegistrationFormUuid } = config.formUuids; - - const columnsLab: EncounterListColumn[] = useMemo( - () => [ - { - key: 'screeningDate', - header: t('visitDate', 'Visit Date'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, cervicalCancerScreeningDateConcept, true); - }, - }, - { - key: 'previouslyScreened', - header: t('previouslyScreened', 'Previously Screened for CaCx'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, previouslyScreenedConcept); - }, - }, - { - key: 'eligibleforScreening', - header: t('eligibleforScreening', 'Eligible for CaCx Screening'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, eligibleForScreeningConcept); - }, - }, - - { - key: 'actions', - header: t('actions', 'Actions'), - getValue: (encounter) => { - const baseActions = [ - { - form: { name: cervicalCancerRegistrationForm, package: 'cacx' }, - encounterUuid: encounter.uuid, - intent: '*', - label: t('viewDetails', 'View Details'), - mode: 'view', - }, - { - form: { name: cervicalCancerRegistrationForm, package: 'cacx' }, - encounterUuid: encounter.uuid, - intent: '*', - label: t('editForm', 'Edit Form'), - mode: 'edit', - }, - ]; - return baseActions; - }, - }, - ], - [], - ); - - const headerTitle = t('cacxRegistration', 'CaCx Registration'); - - return ( - - ); -}; diff --git a/packages/esm-cervical-cancer-app/src/views/cacx-visits/tabs/cacx-treatment.component.tsx b/packages/esm-cervical-cancer-app/src/views/cacx-visits/tabs/cacx-treatment.component.tsx deleted file mode 100644 index 0288a077d..000000000 --- a/packages/esm-cervical-cancer-app/src/views/cacx-visits/tabs/cacx-treatment.component.tsx +++ /dev/null @@ -1,115 +0,0 @@ -import React, { useMemo } from 'react'; -import { useTranslation } from 'react-i18next'; -import { - EncounterList, - EncounterListColumn, - getMultipleObsFromEncounter, - getObsFromEncounter, -} from '@ohri/openmrs-esm-ohri-commons-lib'; -import { moduleName } from '../../../index'; -import { useConfig } from '@openmrs/esm-framework'; - -interface CacxTreatmentProps { - patientUuid: string; -} - -export const CacxTreatment: React.FC = ({ patientUuid }) => { - const { t } = useTranslation(); - const config = useConfig(); - - const { - cacxEncounterDateConcept, - screeningMethodConcept, - cacxTreatmentConcept, - colopsyResultsConcept, - humanPapilomaVirusResultsConcept, - papanicolaouSmearResultsConcept, - VIAProcedureResultsConcept, - } = config.obsConcepts; - - const { cacxTreatmentEncounterType_UUID } = config.encounterTypes; - - const { screeningAndCancerTreatmentForm } = config.formNames; - - const { screeningAndCancerTreatmentFormUuid } = config.formUuids; - - const columnsLab: EncounterListColumn[] = useMemo( - () => [ - { - key: 'encounterDate', - header: t('visitDate', 'Visit Date'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, cacxEncounterDateConcept, true); - }, - }, - { - key: 'screeningMethod', - header: t('screeningMethod', 'Screening Method'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, screeningMethodConcept); - }, - }, - { - key: 'screeningResult', - header: t('screeningResult', 'Screening Results'), - getValue: (encounter) => { - return getMultipleObsFromEncounter(encounter, [ - colopsyResultsConcept, - humanPapilomaVirusResultsConcept, - papanicolaouSmearResultsConcept, - VIAProcedureResultsConcept, - ]); - }, - }, - { - key: 'cacxTreatment', - header: t('cacxTreatment', 'Cacx Treatment'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, cacxTreatmentConcept); - }, - }, - - { - key: 'actions', - header: 'Actions', - getValue: (encounter) => { - const baseActions = [ - { - form: { name: screeningAndCancerTreatmentForm, package: 'cacx' }, - encounterUuid: encounter.uuid, - intent: '*', - label: t('viewDetails', 'View Details'), - mode: 'view', - }, - { - form: { name: screeningAndCancerTreatmentForm, package: 'cacx' }, - encounterUuid: encounter.uuid, - intent: '*', - label: t('editForm', 'Edit Form'), - mode: 'edit', - }, - ]; - return baseActions; - }, - }, - ], - [], - ); - - const headerTitle = t('cacxTreatment', 'CaCx Treatment'); - - return ( - - ); -}; diff --git a/packages/esm-cervical-cancer-app/translations/en.json b/packages/esm-cervical-cancer-app/translations/en.json index 23d869f6e..cf4b69117 100644 --- a/packages/esm-cervical-cancer-app/translations/en.json +++ b/packages/esm-cervical-cancer-app/translations/en.json @@ -1,13 +1,4 @@ { - "actions": "Actions", - "cacxRegistration": "CaCx Registration", - "cacxSummary": "CaCx Summary", - "cacxTreatment": "CaCx Treatment", - "editForm": "Edit Form", - "eligibleforScreening": "Eligible for CaCx Screening", - "previouslyScreened": "Previously Screened for CaCx", - "screeningMethod": "Screening Method", - "screeningResult": "Screening Results", - "viewDetails": "View details", - "visitDate": "Visit Date" + "cacxSummary": "CaCx Summary" + } diff --git a/packages/esm-commons-lib/src/utils/encounter-list-config-builder.ts b/packages/esm-commons-lib/src/utils/encounter-list-config-builder.ts index 69e260e3d..cd174f410 100644 --- a/packages/esm-commons-lib/src/utils/encounter-list-config-builder.ts +++ b/packages/esm-commons-lib/src/utils/encounter-list-config-builder.ts @@ -1,4 +1,4 @@ -import { getObsFromEncounter, findObs } from './encounter-list-utils'; +import { getObsFromEncounter, findObs, getMultipleObsFromEncounter } from './encounter-list-utils'; interface MenuProps { menuId: string; @@ -15,12 +15,14 @@ interface ColumnDefinition { title: string; isComplex?: boolean; concept?: string; + multipleConcepts?: Array; fallbackConcepts?: Array; actionOptions?: Array; isDate?: boolean; isTrueFalseConcept?: boolean; type?: string; isLink?: boolean; + useMultipleObs?: boolean; } interface LaunchOptions { @@ -44,6 +46,7 @@ interface FormattedColumn { getValue: (encounter: any) => string; link?: any; } + export const getTabColumns = (columnsDefinition: Array) => { const columns: Array = columnsDefinition.map((column: ColumnDefinition) => ({ key: column.id, @@ -57,6 +60,8 @@ export const getTabColumns = (columnsDefinition: Array) => { label: action.label, mode: action.mode, })); + } else if (column.useMultipleObs === true) { + return getMultipleObsFromEncounter(encounter, column.multipleConcepts); } else { return getObsFromEncounter( encounter, diff --git a/packages/esm-ohri-pmtct-app/src/api/api.ts b/packages/esm-ohri-pmtct-app/src/api/api.ts index bbbebb25f..13c87b7ba 100644 --- a/packages/esm-ohri-pmtct-app/src/api/api.ts +++ b/packages/esm-ohri-pmtct-app/src/api/api.ts @@ -118,4 +118,4 @@ export function fetchChildLatestFinalOutcome(childUuid: string, conceptUuid: str // Get family relationships from patient uuid export async function getFamilyRelationships(patientUuid: string) { return await fetchPatientRelationships(patientUuid); -} \ No newline at end of file +}