diff --git a/packages/esm-commons-lib/src/index.ts b/packages/esm-commons-lib/src/index.ts index e6d215f8b..4d176a365 100644 --- a/packages/esm-commons-lib/src/index.ts +++ b/packages/esm-commons-lib/src/index.ts @@ -51,7 +51,7 @@ export * from './components/extension-conditional-renderer/patient-based-extensi export * from './components/patient-table/patient-table.component'; export * from './hooks/useLastEncounter'; export * from './utils/encounter-list-config-builder'; - +export * from './utils/summary-card-config-builder'; // Workspace registration moved to the index.ts and routes.json const options = { featureName: 'ohri-forms-workspace-item', 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 9fd483494..680202a64 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 @@ -3,6 +3,7 @@ import { getMultipleObsFromEncounter, resolveValueUsingMappings, getConceptFromMappings, + getConditionalConceptValue, } from './encounter-list-utils'; import { renderTag } from './encounter-list-component-util'; import { extractSchemaValues, replaceWithConfigDefaults } from './schema-manipulation'; @@ -49,6 +50,8 @@ interface ColumnDefinition { valueMappings?: Record; conceptMappings?: Array; statusColorMappings?: Record; + isConditionalConcept?: boolean; + conditionalConceptMappings?: Record; } interface LaunchOptions { @@ -109,6 +112,8 @@ export const getTabColumns = (columnsDefinition: Array) => { return [...baseActions, ...conditionalActions]; } else if (column.statusColorMappings) { return renderTag(encounter, column.concept, column.statusColorMappings); + } else if (column.isConditionalConcept) { + return getConditionalConceptValue(encounter, column.conditionalConceptMappings, column.isDate); } else if (column.useMultipleObs === true) { return getMultipleObsFromEncounter(encounter, column.multipleConcepts); } else if (column.valueMappings) { diff --git a/packages/esm-commons-lib/src/utils/encounter-list-utils.ts b/packages/esm-commons-lib/src/utils/encounter-list-utils.ts index 09f696714..7f96866c7 100644 --- a/packages/esm-commons-lib/src/utils/encounter-list-utils.ts +++ b/packages/esm-commons-lib/src/utils/encounter-list-utils.ts @@ -39,6 +39,13 @@ export function resolveValueUsingMappings(encounter, concept, mappings) { return '--'; } +export function getConditionalConceptValue(encounter: any, conditionalConceptMappings, isDate) { + const { trueConcept, nonTrueConcept, dependantConcept, conditionalConcept } = conditionalConceptMappings; + const dependantUuid = findObs(encounter, dependantConcept)?.value?.uuid; + const finalConcept = dependantUuid === conditionalConcept ? trueConcept : nonTrueConcept; + return getObsFromEncounter(encounter, finalConcept, isDate); +} + export function getConceptFromMappings(encounter, concepts) { for (const concept of concepts) { const obs = findObs(encounter, concept); diff --git a/packages/esm-commons-lib/src/utils/summary-card-config-builder.ts b/packages/esm-commons-lib/src/utils/summary-card-config-builder.ts new file mode 100644 index 000000000..c0d2ac72c --- /dev/null +++ b/packages/esm-commons-lib/src/utils/summary-card-config-builder.ts @@ -0,0 +1,35 @@ +import { getObsFromEncounter, getConditionalConceptValue } from './encounter-list-utils'; + +export const getSummaryCardProps = (schemaConfig) => { + const columns = schemaConfig.columns?.map((column) => ({ + key: column.id, + header: column.title, + concept: column.concept, + encounterTypes: column.encounterTypes, + getObsValue: async ([encounter]) => { + if (column.isConditionalConcept) { + return getConditionalConceptValue(encounter, column.conditionalConceptMappings, column.isDate); + } + return getObsFromEncounter( + encounter, + column.concept, + column.isDate, + column.isTrueFalseConcept, + column.type, + column.fallbackConcepts, + ); + }, + getObsSummary: async (encounters) => { + const summaryValues = encounters.map((encounter) => { + if (encounter && encounter.observation && encounter.observation.value) { + return encounter.observation.value.join(', '); + } else { + return ''; + } + }); + return summaryValues.join(' | '); + }, + })); + + return columns; +}; diff --git a/packages/esm-tb-app/src/index.ts b/packages/esm-tb-app/src/index.ts index 43c24f3f2..8acc62399 100644 --- a/packages/esm-tb-app/src/index.ts +++ b/packages/esm-tb-app/src/index.ts @@ -16,7 +16,7 @@ import { } from './dashboard.meta'; import { configSchema } from './config-schema'; import TBSummaryOverviewList from './views/patient-summary/tb-patient-summary.component'; -import ProgramManagementSummary from './views/program-management/maternal-health.component'; +import ProgramManagementSummary from './views/program-management/tb-program-management'; import TbTreatmentFollowUpList from './views/treatment-and-follow-up/tb-treatment-follow-up.component'; import TbContactTracingList from './views/tb-contact-listing/tb-contact-list.component'; import tptProgramManagementSummary from './views/tpt/program-management/tpt-program-management'; diff --git a/packages/esm-tb-app/src/views/patient-summary/previous-cases-config.json b/packages/esm-tb-app/src/views/patient-summary/previous-cases-config.json new file mode 100644 index 000000000..e8e3a6abc --- /dev/null +++ b/packages/esm-tb-app/src/views/patient-summary/previous-cases-config.json @@ -0,0 +1,61 @@ +{ + "menuId": "previousCases", + "tabDefinitions": [ + { + "tabName": "Previous Cases", + "headerTitle": "Previous Cases", + "displayText": "Previous Cases", + "encounterType": "9a199b59-b185-485b-b9b3-a9754e65ae57", + "columns": [ + { + "id": "caseID", + "title": "Case ID", + "concept": "162576AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "enrollmentDate", + "isDate": true, + "title": "Enrollment Date", + "concept": "161552AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "type", + "title": "Type", + "concept": "159990AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "site", + "title": "Site", + "concept": "160040AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "regimen", + "title": "Regimen", + "isConditionalConcept": true, + "conditionalConceptMappings": { + "trueConcept": "16fd7307-0b26-4c8b-afa3-8362baff4042", + "nonTrueConcept": "159909AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", + "dependantConcept": "163775AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", + "conditionalConcept": "160541AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + } + }, + { + "id": "outcome", + "title": "Outcome", + "concept": "159786AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + } + ], + "launchOptions": { + "hideFormLauncher": true, + "displayText": "Add", + "moduleName": "@ohri/openmrs-esm-ohri-tb-app" + }, + "formList": [ + { + "name": "TB Case Enrollment Form", + "uuid": "554b2017-e512-3fc8-9c6e-7baf9e69db9d" + } + ] + } + ] +} \ No newline at end of file diff --git a/packages/esm-tb-app/src/views/patient-summary/recent-tb-config.json b/packages/esm-tb-app/src/views/patient-summary/recent-tb-config.json new file mode 100644 index 000000000..74bea31a3 --- /dev/null +++ b/packages/esm-tb-app/src/views/patient-summary/recent-tb-config.json @@ -0,0 +1,77 @@ +{ + "menuId": "recentTuberculosis", + "cardTitle": "Recent Tuberculosis", + "columns": [ + { + "id": "caseID", + "title": "Case ID", + "encounterTypes": [ + "9a199b59-b185-485b-b9b3-a9754e65ae57" + ], + "concept": "162576AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "enrollmentDate", + "isDate": true, + "title": "Enrollment Date", + "encounterTypes": [ + "9a199b59-b185-485b-b9b3-a9754e65ae57" + ], + "concept": "161552AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "type", + "title": "Type", + "encounterTypes": [ + "9a199b59-b185-485b-b9b3-a9754e65ae57" + ], + "concept": "159990AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "site", + "title": "Site", + "encounterTypes": [ + "9a199b59-b185-485b-b9b3-a9754e65ae57" + ], + "concept": "160040AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "drugSensitivity", + "title": "Drug Sensitivity", + "encounterTypes": [ + "9a199b59-b185-485b-b9b3-a9754e65ae57" + ], + "concept": "164368AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "regimen", + "title": "Regimen", + "encounterTypes": [ + "9a199b59-b185-485b-b9b3-a9754e65ae57" + ], + "isConditionalConcept": true, + "conditionalConceptMappings": { + "trueConcept": "16fd7307-0b26-4c8b-afa3-8362baff4042", + "nonTrueConcept": "159909AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", + "dependantConcept": "163775AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", + "conditionalConcept": "160541AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + } + }, + { + "id": "hivStatus", + "title": "HIV Status", + "encounterTypes": [ + "9a199b59-b185-485b-b9b3-a9754e65ae57" + ], + "concept": "159576AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "outcome", + "title": "Outcome", + "encounterTypes": [ + "9a199b59-b185-485b-b9b3-a9754e65ae57" + ], + "concept": "159786AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + } + ] +} \ No newline at end of file diff --git a/packages/esm-tb-app/src/views/patient-summary/tb-patient-summary.component.tsx b/packages/esm-tb-app/src/views/patient-summary/tb-patient-summary.component.tsx index b9f14b966..ff5920860 100644 --- a/packages/esm-tb-app/src/views/patient-summary/tb-patient-summary.component.tsx +++ b/packages/esm-tb-app/src/views/patient-summary/tb-patient-summary.component.tsx @@ -1,231 +1,57 @@ import { - EmptyStateComingSoon, EncounterList, - EncounterListColumn, - PatientChartProps, SummaryCard, - SummaryCardColumn, - getObsFromEncounter, - findObs, + getMenuItemTabConfiguration, + getSummaryCardProps, } from '@ohri/openmrs-esm-ohri-commons-lib'; -import { useConfig } from '@openmrs/esm-framework'; -import React, { useMemo } from 'react'; -import { useTranslation } from 'react-i18next'; -import { moduleName } from '../..'; -import { getTbRegimen } from '../../tb-helper'; +import React from 'react'; +import previousCasesConfigSchema from './previous-cases-config.json'; +import tbVisitsConfigSchema from './visits-config.json'; +import recentTuberculosisConfigSchema from './recent-tb-config.json'; -const TBSummaryOverviewList: React.FC = ({ patientUuid }) => { - const { t } = useTranslation(); +interface OverviewListProps { + patientUuid: string; +} - const headerRecentTB = t('recentTuberculosis', 'Recent Tuberculosis'); - const headerPreviousCases = t('previousCases', 'Previous Cases'); - const headerVisit = t('visits', 'Visits'); - const { formNames, formUuids, encounterTypes, obsConcepts } = useConfig(); - - const recentTuberclosisColumns: SummaryCardColumn[] = useMemo( - () => [ - { - key: 'caseID', - header: t('caseID', 'Case ID'), - encounterTypes: [encounterTypes.tbProgramEnrollment], - getObsValue: async ([encounter]) => { - return getObsFromEncounter(encounter, obsConcepts.caseID); - }, - }, - { - key: 'enrollmentDate', - header: t('enrollmentDate', 'Enrollment Date'), - encounterTypes: [encounterTypes.tbProgramEnrollment], - getObsValue: async ([encounter]) => { - return getObsFromEncounter(encounter, obsConcepts.enrollmentDate, true); - }, - }, - { - key: 'type', - header: t('type', 'Type'), - encounterTypes: [encounterTypes.tbProgramEnrollment], - getObsValue: ([encounter]) => { - return getObsFromEncounter(encounter, obsConcepts.type); - }, - }, - { - key: 'site', - header: t('site', 'Site'), - encounterTypes: [encounterTypes.tbProgramEnrollment], - getObsValue: ([encounter]) => { - return getObsFromEncounter(encounter, obsConcepts.site); - }, - }, - { - key: 'drugSensitivity', - header: t('drugSensitivity', 'Drug Sensitivity'), - encounterTypes: [encounterTypes.tbProgramEnrollment], - getObsValue: ([encounter]) => { - return getObsFromEncounter(encounter, obsConcepts.drugSensitivity); - }, - }, - { - key: 'regimen', - header: t('regimen', 'Regimen'), - encounterTypes: [encounterTypes.tbProgramEnrollment], - getObsValue: ([encounter]) => { - const tBEnrollmentType = findObs(encounter, obsConcepts.tBEnrollmentType)?.value?.uuid; - return getTbRegimen(encounter, tBEnrollmentType); - }, - }, - { - key: 'hivStatus', - header: t('hivStatus', 'HIV Status'), - encounterTypes: [encounterTypes.tbProgramEnrollment], - getObsValue: ([encounter]) => { - return getObsFromEncounter(encounter, obsConcepts.hivStatus); - }, - }, - { - key: 'outcome', - header: t('outcome', 'Outcome'), - encounterTypes: [encounterTypes.tbProgramEnrollment], - getObsValue: ([encounter]) => { - return getObsFromEncounter(encounter, obsConcepts.outcome); - }, - }, - ], - [], - ); - - const previousCasesColumns: EncounterListColumn[] = useMemo( - () => [ - { - key: 'caseID', - header: t('caseID', 'Case ID'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.caseID); - }, - }, - { - key: 'enrollmentDate', - header: t('enrollmentDate', 'Enrollment Date'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.enrollmentDate, true); - }, - }, - { - key: 'type', - header: t('type', 'Type'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.type); - }, - }, - { - key: 'site', - header: t('site', 'Site'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.site); - }, - }, - { - key: 'regimen', - header: t('regimen', 'Regimen'), - getValue: (encounter) => { - const tBEnrollmentType = findObs(encounter, obsConcepts.tBEnrollmentType)?.value?.uuid; - return getTbRegimen(encounter, tBEnrollmentType); - }, - }, - { - key: 'outcome', - header: t('outcome', 'Outcome'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.outcome); - }, - }, - ], - [], - ); - - const tbVisitsColumns: EncounterListColumn[] = useMemo( - () => [ - { - key: 'caseID', - header: t('caseID', 'Case ID'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.caseID); - }, - }, - { - key: 'dateOfVisit', - header: t('dateOfVisit', 'Date of Visit'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.visitDate, true); - }, - }, - { - key: 'monthOfVisit', - header: t('monthOfVisit', 'Month of Visit'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.monthOfTreatment); - }, - }, - { - key: 'adherence', - header: t('adherence', 'Adherence'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.adherenceAssessment); - }, - }, - { - key: 'adverseDrugReaction', - header: t('adverseDrugReaction', 'Adverse Drug Reaction'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.ADR); - }, - }, - { - key: 'nextAppointment', - header: t('nextAppointment', 'Next Appointment'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.nextAppointmentDate, true); - }, - }, - ], - [], - ); +const TBSummaryOverviewList: React.FC = ({ patientUuid }) => { + const previousCaseTabs = getMenuItemTabConfiguration(previousCasesConfigSchema); + const tbVisitsTabs = getMenuItemTabConfiguration(tbVisitsConfigSchema); + const summaryCardColumns = getSummaryCardProps(recentTuberculosisConfigSchema); return ( <> - - - + {previousCaseTabs.map((tab) => ( + + ))} + + {tbVisitsTabs.map((tab) => ( + + ))} ); }; diff --git a/packages/esm-tb-app/src/views/patient-summary/visits-config.json b/packages/esm-tb-app/src/views/patient-summary/visits-config.json new file mode 100644 index 000000000..e7347e2d5 --- /dev/null +++ b/packages/esm-tb-app/src/views/patient-summary/visits-config.json @@ -0,0 +1,56 @@ +{ + "menuId": "visits", + "tabDefinitions": [ + { + "tabName": "Visits", + "headerTitle": "Visits", + "displayText": "Visits", + "encounterType": "1881304a-4854-4927-b0b1-a6231d61e43c", + "columns": [ + { + "id": "caseID", + "title": "Case ID", + "concept": "162576AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "dateOfVisit", + "isDate": true, + "title": "Date of Visit", + "concept": "160753AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "monthOfVisit", + "title": "Month of Visit", + "concept": "1418AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "adherence", + "title": "Adherence", + "concept": "164075AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "adverseDrugReaction", + "title": "Adverse Drug Reaction", + "concept": "160646AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "nextAppointment", + "isDate": true, + "title": "Next Appointment", + "concept": "5096AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + } + ], + "launchOptions": { + "hideFormLauncher": true, + "displayText": "Add", + "moduleName": "@ohri/openmrs-esm-ohri-tb-app" + }, + "formList": [ + { + "name": "TPT Followup & Treatment form", + "uuid": "6212bb87-766e-33d0-b37b-79f019008492" + } + ] + } + ] +} \ No newline at end of file diff --git a/packages/esm-tb-app/src/views/program-management/maternal-health.component.tsx b/packages/esm-tb-app/src/views/program-management/maternal-health.component.tsx deleted file mode 100644 index 98615bd73..000000000 --- a/packages/esm-tb-app/src/views/program-management/maternal-health.component.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import React from 'react'; -import { Tabs, Tab, TabList, TabPanels, TabPanel } from '@carbon/react'; -import styles from '../common.scss'; -import { useTranslation } from 'react-i18next'; -import MdrTbList from './tabs/mdr-tb.component'; -import TbPatientTracing from './tabs/tb-patient-tracing.component'; -import { PatientChartProps } from '@ohri/openmrs-esm-ohri-commons-lib'; - -const ProgramManagementSummary: React.FC = ({ patientUuid }) => { - const { t } = useTranslation(); - return ( -
- - - {t('MdrTbEnrolment', 'TB/MDR TB Enrolment')} - {t('PatientTracing', 'Patient Tracing')} - - - - - - - - - - -
- ); -}; - -export default ProgramManagementSummary; diff --git a/packages/esm-tb-app/src/views/program-management/tabs/mdr-tb.component.tsx b/packages/esm-tb-app/src/views/program-management/tabs/mdr-tb.component.tsx deleted file mode 100644 index cc3454917..000000000 --- a/packages/esm-tb-app/src/views/program-management/tabs/mdr-tb.component.tsx +++ /dev/null @@ -1,125 +0,0 @@ -import React, { useEffect, useMemo, useState } from 'react'; -import { useTranslation } from 'react-i18next'; -import { - EncounterList, - EncounterListColumn, - PatientChartProps, - fetchPatientLastEncounter, - findObs, - getObsFromEncounter, -} from '@ohri/openmrs-esm-ohri-commons-lib'; -import { moduleName } from '../../..'; -import { useConfig } from '@openmrs/esm-framework'; -import { getTbRegimen, getTbTreatmentId, getTbTreatmentStartDate } from '../../../tb-helper'; - -const MdrTbList: React.FC = ({ patientUuid }) => { - const { t } = useTranslation(); - const headerTitle = t('MdrTbEnrolment', 'TB/MDR TB Enrolment'); - const [isEmptyOutcome, setIsEmptyOutcome] = useState(false); - const { formNames, formUuids, encounterTypes, obsConcepts } = useConfig(); - - useEffect(() => { - fetchPatientLastEncounter(patientUuid, encounterTypes.tbProgramEnrollment).then((encounter) => { - const result = encounter?.obs?.filter((ob) => ob?.concept?.uuid === obsConcepts.outcome); - if (result?.length === 0) { - setIsEmptyOutcome(true); - } - }); - }, []); - - const columns: EncounterListColumn[] = useMemo( - () => [ - { - key: 'enrollmentDate', - header: t('enrollmentDate', 'Enrollment Date'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.enrollmentDate, true); - }, - }, - { - key: 'caseID', - header: t('caseID', 'Case ID'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.caseID); - }, - }, - { - key: 'tbTreatmentId', - header: t('tbTreatmentId', 'TB Treatement ID'), - getValue: (encounter) => { - const tBEnrollmentType = findObs(encounter, obsConcepts.tBEnrollmentType)?.value?.uuid; - return getTbTreatmentId(encounter, tBEnrollmentType); - }, - }, - { - key: 'treatmentStartDate', - header: t('treatmentStartDate', 'Treatment Start Date'), - getValue: (encounter) => { - const tBEnrollmentType = findObs(encounter, obsConcepts.tBEnrollmentType)?.value?.uuid; - return getTbTreatmentStartDate(encounter, tBEnrollmentType); - }, - }, - { - key: 'regimen', - header: t('regimen', 'Regimen'), - getValue: (encounter) => { - const tBEnrollmentType = findObs(encounter, obsConcepts.tBEnrollmentType)?.value?.uuid; - return getTbRegimen(encounter, tBEnrollmentType); - }, - }, - { - key: 'treatmentOutcome', - header: t('treatmentOutcome', 'Treatment outcome'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.outcome); - }, - }, - { - key: 'dateOfTreatmentOutcome', - header: t('dateOfTreatmentOutcome', 'Date of Treatment Outcome'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.DateOfTreatmentOutcome, true); - }, - }, - { - key: 'actions', - header: t('actions', 'Actions'), - getValue: (encounter) => [ - { - form: { name: 'TB Case Enrollment Form' }, - encounterUuid: encounter.uuid, - intent: '*', - label: t('viewDetails', 'View Details'), - mode: 'view', - }, - { - form: { name: 'TB Case Enrollment Form' }, - encounterUuid: encounter.uuid, - intent: '*', - label: t('editForm', 'Edit Form'), - mode: 'edit', - }, - ], - }, - ], - [], - ); - - return ( - - ); -}; - -export default MdrTbList; diff --git a/packages/esm-tb-app/src/views/program-management/tabs/tb-patient-tracing.component.tsx b/packages/esm-tb-app/src/views/program-management/tabs/tb-patient-tracing.component.tsx deleted file mode 100644 index fb7de4728..000000000 --- a/packages/esm-tb-app/src/views/program-management/tabs/tb-patient-tracing.component.tsx +++ /dev/null @@ -1,72 +0,0 @@ -import React, { useMemo } from 'react'; -import { useTranslation } from 'react-i18next'; -import { - EncounterList, - EncounterListColumn, - PatientChartProps, - getObsFromEncounter, -} from '@ohri/openmrs-esm-ohri-commons-lib'; -import { moduleName } from '../../..'; -import { useConfig } from '@openmrs/esm-framework'; - -const TbPatientTracing: React.FC = ({ patientUuid }) => { - const { t } = useTranslation(); - const { formNames, formUuids, encounterTypes, obsConcepts } = useConfig(); - const headerTitle = t('PatientTracing', 'Patient Tracing'); - const columns: EncounterListColumn[] = useMemo( - () => [ - { - key: 'contactDate', - header: t('contactDate', 'Contact Date'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.dateContacted, true); - }, - }, - { - key: 'contactMethod', - header: t('contactMethod', 'Contact Method'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.modeOfContact); - }, - }, - { - key: 'actions', - header: t('actions', 'Actions'), - getValue: (encounter) => [ - { - form: { name: 'TB Patient Tracing Form' }, - encounterUuid: encounter.uuid, - intent: '*', - label: t('viewDetails', 'View Details'), - mode: 'view', - }, - { - form: { name: 'TB Patient Tracing Form' }, - encounterUuid: encounter.uuid, - intent: '*', - label: t('editForm', 'Edit Form'), - mode: 'edit', - }, - ], - }, - ], - [], - ); - - return ( - - ); -}; - -export default TbPatientTracing; diff --git a/packages/esm-tb-app/src/views/program-management/tb-program-management-config.json b/packages/esm-tb-app/src/views/program-management/tb-program-management-config.json new file mode 100644 index 000000000..e06c9fb74 --- /dev/null +++ b/packages/esm-tb-app/src/views/program-management/tb-program-management-config.json @@ -0,0 +1,145 @@ +{ + "menuId": "programManagement", + "tabDefinitions": [ + { + "tabName": "TB/MDR TB Enrolment", + "headerTitle": "TB/MDR TB Enrolment", + "displayText": "TB/MDR TB Enrolment", + "encounterType": "9a199b59-b185-485b-b9b3-a9754e65ae57", + "columns": [ + { + "id": "enrollmentDate", + "isDate": true, + "title": "Enrollment Date", + "concept": "161552AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "caseID", + "title": "Case ID", + "concept": "162576AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "tbTreatmentId", + "title": "TB Treatment ID", + "isConditionalConcept": true, + "conditionalConceptMappings": { + "trueConcept": "161654AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", + "nonTrueConcept": "164415AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", + "dependantConcept": "163775AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", + "conditionalConcept": "160541AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + } + }, + { + "id": "treatmentStartDate", + "isDate": true, + "title": "Treatment Start Date", + "isConditionalConcept": true, + "conditionalConceptMappings": { + "trueConcept": "1113AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", + "nonTrueConcept": "164416AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", + "dependantConcept": "163775AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", + "conditionalConcept": "160541AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + } + }, + { + "id": "regimen", + "title": "Regimen", + "isConditionalConcept": true, + "conditionalConceptMappings": { + "trueConcept": "16fd7307-0b26-4c8b-afa3-8362baff4042", + "nonTrueConcept": "159909AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", + "dependantConcept": "163775AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", + "conditionalConcept": "160541AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + } + }, + { + "id": "treatmentOutcome", + "title": "Treatment Outcome", + "concept": "159786AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "dateOfTreatmentOutcome", + "isDate": true, + "title": "Date of Treatment Outcome", + "concept": "159787AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "actions", + "title": "Actions", + "actionOptions": [ + { + "formName": "TB Case Enrollment Form", + "package": "tb", + "label": "View Details", + "mode": "view" + }, + { + "formName": "TB Case Enrollment Form", + "package": "tb", + "label": "Edit Form", + "mode": "edit" + } + ] + } + ], + "launchOptions": { + "displayText": "Add", + "moduleName": "@ohri/openmrs-esm-ohri-tb-app" + }, + "formList": [ + { + "name": "TB Case Enrollment Form", + "uuid": "554b2017-e512-3fc8-9c6e-7baf9e69db9d" + } + ] + }, + { + "tabName": "Patient Tracing", + "headerTitle": "Patient Tracing", + "displayText": "Patient Tracing", + "encounterType": "98c938e9-fb3e-4982-ae22-0305cbd12f8c", + "columns": [ + { + "id": "contactDate", + "isDate": true, + "title": "Contact Date", + "concept": "160753AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "contactMethod", + "title": "Contact Method", + "concept": "166456AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "actions", + "title": "Actions", + "actionOptions": [ + { + "formName": "TB Patient Tracing Form", + "package": "tpt", + "label": "View Details", + "mode": "view" + }, + { + "formName": "TB Patient Tracing Form", + "package": "tpt", + "label": "Edit Forms", + "mode": "edit" + } + ] + } + ], + "launchOptions": { + "displayText": "Add", + "moduleName": "@ohri/openmrs-esm-ohri-tb-app" + }, + "formList": [ + { + "name": "TB Patient Tracing Form", + "uuid": "ac3cbd10-1939-3797-9de6-2a39dfb68441" + } + ] + } + ] + } + \ No newline at end of file diff --git a/packages/esm-tb-app/src/views/program-management/tb-program-management.tsx b/packages/esm-tb-app/src/views/program-management/tb-program-management.tsx new file mode 100644 index 000000000..5b8d02bcc --- /dev/null +++ b/packages/esm-tb-app/src/views/program-management/tb-program-management.tsx @@ -0,0 +1,41 @@ +import React from 'react'; +import { Tabs, Tab, TabList, TabPanels, TabPanel } from '@carbon/react'; +import styles from '../common.scss'; +import { PatientChartProps, getMenuItemTabConfiguration, EncounterList } from '@ohri/openmrs-esm-ohri-commons-lib'; +import tptProgramManagemetConfigSchema from './tb-program-management-config.json'; +interface OverviewListProps { + patientUuid: string; +} + +const ProgramManagementSummary: React.FC = ({ patientUuid }) => { + const tabs = getMenuItemTabConfiguration(tptProgramManagemetConfigSchema); + + return ( +
+ + + {tabs.map((tab) => ( + {tab.name} + ))} + + + {tabs.map((tab) => ( + + + + ))} + + +
+ ); +}; + +export default ProgramManagementSummary; diff --git a/packages/esm-tb-app/src/views/tb-contact-listing/tb-contact-list.component.tsx b/packages/esm-tb-app/src/views/tb-contact-listing/tb-contact-list.component.tsx index 2aab38fc4..c2f235210 100644 --- a/packages/esm-tb-app/src/views/tb-contact-listing/tb-contact-list.component.tsx +++ b/packages/esm-tb-app/src/views/tb-contact-listing/tb-contact-list.component.tsx @@ -1,79 +1,28 @@ -import React, { useMemo } from 'react'; -import { useTranslation } from 'react-i18next'; -import { - EncounterList, - EncounterListColumn, - PatientChartProps, - getObsFromEncounter, -} from '@ohri/openmrs-esm-ohri-commons-lib'; -import { moduleName } from '../../index'; -import { useConfig } from '@openmrs/esm-framework'; +import React from 'react'; +import { EncounterList, getMenuItemTabConfiguration } from '@ohri/openmrs-esm-ohri-commons-lib'; +import tbFollowupConfigSchema from './tb-contact-listing-config.json'; -const TbContactTracingList: React.FC = ({ patientUuid }) => { - const { t } = useTranslation(); - const { formNames, formUuids, encounterTypes, obsConcepts } = useConfig(); - const headerTitle = t('TbContactListing', 'TB Contact Listing'); +interface OverviewListProps { + patientUuid: string; +} - const columns: EncounterListColumn[] = useMemo( - () => [ - { - key: 'caseID', - header: t('caseId', 'TB Case ID'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.caseID); - }, - }, - { - key: 'dateContactListed', - header: t('dateContactListed', 'Date Contact Listed'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.dateContacted, true); - }, - }, - { - key: 'location', - header: t('loction', 'Location'), - getValue: (encounter) => { - return encounter.location.name; - }, - }, - { - key: 'actions', - header: t('actions', 'Actions'), - getValue: (encounter) => [ - { - form: { name: 'TB Contact Listing' }, - encounterUuid: encounter.uuid, - intent: '*', - label: t('viewDetails', 'View Details'), - mode: 'view', - }, - { - form: { name: 'TB Contact Listing' }, - encounterUuid: encounter.uuid, - intent: '*', - label: t('editForm', 'Edit Form'), - mode: 'edit', - }, - ], - }, - ], - [], - ); +const TbContactTracingList: React.FC = ({ patientUuid }) => { + const tabs = getMenuItemTabConfiguration(tbFollowupConfigSchema); return ( - + <> + {tabs.map((tab) => ( + + ))} + ); }; diff --git a/packages/esm-tb-app/src/views/tb-contact-listing/tb-contact-listing-config.json b/packages/esm-tb-app/src/views/tb-contact-listing/tb-contact-listing-config.json new file mode 100644 index 000000000..5635e2e99 --- /dev/null +++ b/packages/esm-tb-app/src/views/tb-contact-listing/tb-contact-listing-config.json @@ -0,0 +1,58 @@ +{ + "menuId": "tbContactListing", + "tabDefinitions": [ + { + "tabName": "TB Contact Listing", + "headerTitle": "TB Contact Listing", + "displayText": "TB Contact Listing", + "encounterType": "70d2b2f6-860b-438c-994b-c28e863dca34", + "columns": [ + { + "id": "caseID", + "title": "Case ID", + "concept": "162576AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "dateContactListed", + "isDate": true, + "title": "Date Contact Listed", + "concept": "160753AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "location", + "title": "Location", + "type": "location" + }, + { + "id": "actions", + "title": "Actions", + "actionOptions": [ + { + "formName": "TB Contact Listing", + "package": "tb", + "label": "View Details", + "mode": "view" + }, + { + "formName": "TB Contact Listing", + "package": "tb", + "label": "Edit Form", + "mode": "edit" + } + ] + } + ], + "launchOptions": { + "displayText": "Add", + "moduleName": "@ohri/openmrs-esm-ohri-tb-app" + }, + "formList": [ + { + "name": "TB Contact Listing", + "uuid": "cb16d920-62f1-3696-b781-e6a4f5e80de1" + } + ] + } + ] + } + \ No newline at end of file diff --git a/packages/esm-tb-app/src/views/tpt/patient-summary/patient-summary.component.tsx b/packages/esm-tb-app/src/views/tpt/patient-summary/patient-summary.component.tsx index d54af7c7e..619ad30d5 100644 --- a/packages/esm-tb-app/src/views/tpt/patient-summary/patient-summary.component.tsx +++ b/packages/esm-tb-app/src/views/tpt/patient-summary/patient-summary.component.tsx @@ -1,221 +1,57 @@ import { - EmptyStateComingSoon, EncounterList, - EncounterListColumn, - PatientChartProps, SummaryCard, - SummaryCardColumn, - getObsFromEncounter, + getMenuItemTabConfiguration, + getSummaryCardProps, } from '@ohri/openmrs-esm-ohri-commons-lib'; -import { useConfig } from '@openmrs/esm-framework'; -import React, { useMemo } from 'react'; -import { useTranslation } from 'react-i18next'; -import { moduleName } from '../../..'; +import React from 'react'; +import tptPreviousCasesConfigSchema from './tpt-previous-cases-config.json'; +import tptVisitsConfigSchema from './tpt-visits-config.json'; +import recentTptConfigSchema from './recent-tpt-config.json'; -const TptPatientSummary: React.FC = ({ patientUuid }) => { - const { t } = useTranslation(); - const { formNames, formUuids, encounterTypes, obsConcepts } = useConfig(); +interface OverviewListProps { + patientUuid: string; +} - const headerRecentTPT = t('recentTptCases', 'Recent TPT Cases'); - const headerPreviousTptCases = t('previousTptCases', 'Previous TPT Cases'); - const headerVisit = t('visits', 'Visits'); - - const recentTbPreventionColumns: SummaryCardColumn[] = useMemo( - () => [ - { - key: 'tptTreatmentId', - header: t('tptTreatmentId', 'TPT Treatment ID'), - encounterTypes: [encounterTypes.tptCaseEnrollment], - getObsValue: async ([encounter]) => { - return getObsFromEncounter(encounter, obsConcepts.tptTreatmentId); - }, - }, - { - key: 'tptEnrollmentDate', - header: t('enrollmentDate', 'Enrollment Date'), - encounterTypes: [encounterTypes.tptCaseEnrollment], - getObsValue: async ([encounter]) => { - return getObsFromEncounter(encounter, obsConcepts.tptEnrollmentDate, true); - }, - }, - { - key: 'tptIndication', - header: t('indication', 'Indication'), - encounterTypes: [encounterTypes.tptCaseEnrollment], - getObsValue: ([encounter]) => { - return getObsFromEncounter(encounter, obsConcepts.tptIndication); - }, - }, - { - key: 'tptRegimen', - header: t('regimen', 'Regimen'), - encounterTypes: [encounterTypes.tptCaseEnrollment], - getObsValue: ([encounter]) => { - return getObsFromEncounter(encounter, obsConcepts.tptRegimen); - }, - }, - { - key: 'tptAdherence', - header: t('tptAdherence', 'Adherence'), - encounterTypes: [encounterTypes.tptTreatmentAndFollowUp], - getObsValue: ([encounter]) => { - return getObsFromEncounter(encounter, obsConcepts.tptAdherence); - }, - }, - { - key: 'tptAppointmentDate', - header: t('nextAppointmentDate', 'Next Appointment Date'), - encounterTypes: [encounterTypes.tptTreatmentAndFollowUp], - getObsValue: ([encounter]) => { - return getObsFromEncounter(encounter, obsConcepts.tptAppointmentDate, true); - }, - }, - ], - [], - ); - - const previousTptCasesColumns: EncounterListColumn[] = useMemo( - () => [ - { - key: 'tptTreatmentId', - header: t('tptTreatmentId', 'TPT Treatment ID'), - encounterTypes: [encounterTypes.tptCaseEnrollment], - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.tptTreatmentId); - }, - }, - { - key: 'tptEnrollmentDate', - header: t('enrollmentDate', 'Enrollment Date'), - encounterTypes: [encounterTypes.tptCaseEnrollment], - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.tptEnrollmentDate, true); - }, - }, - { - key: 'indication', - header: t('indication', 'Indication'), - encounterTypes: [encounterTypes.tptCaseEnrollment], - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.tptIndication); - }, - }, - { - key: 'tptRegimen', - header: t('regimen', 'Regimen'), - encounterTypes: [encounterTypes.tptCaseEnrollment], - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.tptRegimen); - }, - }, - { - key: 'tptOutcome', - header: t('outcome', 'Outcome'), - encounterTypes: [encounterTypes.tptCaseEnrollment], - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.tptOutcome); - }, - }, - { - key: 'tptDateOutcome', - header: t('dateOutcome', 'Date of Outcome'), - encounterTypes: [encounterTypes.tptCaseEnrollment], - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.tptDateOutcome, true); - }, - }, - ], - [], - ); - - const TptVisitsColumns: EncounterListColumn[] = useMemo( - () => [ - { - key: 'caseID', - header: t('caseID', 'Case ID'), - encounterTypes: [encounterTypes.tptCaseEnrollment], - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.tptTreatmentId); - }, - }, - { - key: 'visitDate', - header: t('visitDate', 'Visit Date'), - encounterTypes: [encounterTypes.tptCaseEnrollment], - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.tptEnrollmentDate, true); - }, - }, - { - key: 'tptIndication', - header: t('indication', 'Indication'), - encounterTypes: [encounterTypes.tptCaseEnrollment], - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.tptIndication); - }, - }, - { - key: 'regimen', - header: t('regimen', 'Regimen'), - encounterTypes: [encounterTypes.tptCaseEnrollment], - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.tptRegimen); - }, - }, - { - key: 'adherence', - header: t('adherence', 'Adherence'), - encounterTypes: [encounterTypes.tptTreatmentAndFollowUp], - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.tptAdherence); - }, - }, - { - key: 'nextAppointmentDate', - header: t('nextAppointmentDate', 'Next Appointment Date'), - encounterTypes: [encounterTypes.tptTreatmentAndFollowUp], - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.tptAppointmentDate, true); - }, - }, - ], - [], - ); +const TptPatientSummary: React.FC = ({ patientUuid }) => { + const previousCaseTabs = getMenuItemTabConfiguration(tptPreviousCasesConfigSchema); + const tbVisitsTabs = getMenuItemTabConfiguration(tptVisitsConfigSchema); + const summaryCardColumns = getSummaryCardProps(recentTptConfigSchema); return ( <> - - + + {previousCaseTabs.map((tab) => ( + + ))} + + {tbVisitsTabs.map((tab) => ( + + ))} ); }; diff --git a/packages/esm-tb-app/src/views/tpt/patient-summary/recent-tpt-config.json b/packages/esm-tb-app/src/views/tpt/patient-summary/recent-tpt-config.json new file mode 100644 index 000000000..09db5ec0e --- /dev/null +++ b/packages/esm-tb-app/src/views/tpt/patient-summary/recent-tpt-config.json @@ -0,0 +1,57 @@ +{ + "menuId": "recentTpt", + "cardTitle": "Recent Tuberculosis", + "columns": [ + { + "id": "tptTreatmentId", + "title": "TPT Treatment ID", + "encounterTypes": [ + "dc6ce80c-83f8-4ace-a638-21df78542551" + ], + "concept": "162727AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "tptEnrollmentDate", + "isDate": true, + "title": "Enrollment Date", + "encounterTypes": [ + "dc6ce80c-83f8-4ace-a638-21df78542551" + ], + "concept": "164852AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "tptIndication", + "title": "Indication", + "encounterTypes": [ + "dc6ce80c-83f8-4ace-a638-21df78542551" + ], + "concept": "162276AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "tptRegimen", + "title": "Regimen", + "encounterTypes": [ + "dc6ce80c-83f8-4ace-a638-21df78542551" + ], + "concept": "1264AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "tptAdherence", + "title": "Adherence", + "encounterTypes": [ + "1ac3de3f-8fc2-43a7-addb-e805c393ecae" + ], + "concept": "164075AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "tptAppointmentDate", + "isDate": true, + "title": "Next Appointment Date", + "encounterTypes": [ + "1ac3de3f-8fc2-43a7-addb-e805c393ecae" + ], + "concept": "5096AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + } + ] +} + diff --git a/packages/esm-tb-app/src/views/tpt/patient-summary/tpt-previous-cases-config.json b/packages/esm-tb-app/src/views/tpt/patient-summary/tpt-previous-cases-config.json new file mode 100644 index 000000000..376bdb030 --- /dev/null +++ b/packages/esm-tb-app/src/views/tpt/patient-summary/tpt-previous-cases-config.json @@ -0,0 +1,56 @@ +{ + "menuId": "previousTptCases", + "tabDefinitions": [ + { + "tabName": "Previous TPT Cases", + "headerTitle": "Previous TPT Cases", + "displayText": "Previous TPT Cases", + "encounterType": "dc6ce80c-83f8-4ace-a638-21df78542551", + "columns": [ + { + "id": "tptTreatmentId", + "title": "TPT Treatment ID", + "concept": "162727AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "tptEnrollmentDate", + "isDate": true, + "title": "Enrollment Date", + "concept": "164852AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "indication", + "title": "Indication", + "concept": "162276AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "tptRegimen", + "title": "Regimen", + "concept": "1264AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "tptOutcome", + "title": "Outcome", + "concept": "1266AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "tptDateOutcome", + "isDate": true, + "title": "Date of Outcome", + "concept": "163284AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + } + ], + "launchOptions": { + "hideFormLauncher": true, + "displayText": "Add", + "moduleName": "@ohri/openmrs-esm-ohri-tb-app" + }, + "formList": [ + { + "name": "TPT Case Enrolment form", + "uuid": "71080512-07e6-345f-864f-93e892420258" + } + ] + } + ] +} diff --git a/packages/esm-tb-app/src/views/tpt/patient-summary/tpt-visits-config.json b/packages/esm-tb-app/src/views/tpt/patient-summary/tpt-visits-config.json new file mode 100644 index 000000000..a87f57de9 --- /dev/null +++ b/packages/esm-tb-app/src/views/tpt/patient-summary/tpt-visits-config.json @@ -0,0 +1,52 @@ +{ + "menuId": "tptVisits", + "tabDefinitions": [ + { + "tabName": "Visits", + "headerTitle": "Visits", + "displayText": "Visits", + "encounterType": "dc6ce80c-83f8-4ace-a638-21df78542551", + "columns": [ + { + "id": "tptTreatmentId", + "title": "TPT Treatment ID", + "concept": "162727AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "dateOfVisit", + "isDate": true, + "title": "Date of Visit", + "concept": "164852AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "tptIndication", + "title": "Indication", + "concept": "162276AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "adherence", + "title": "Adherence", + "concept": "164075AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "nextAppointmentDate", + "isDate": true, + "title": "Next Appointment Date", + "concept": "5096AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + } + ], + "launchOptions": { + "hideFormLauncher": true, + "displayText": "Add", + "moduleName": "@ohri/openmrs-esm-ohri-tb-app" + }, + "formList": [ + { + "name": "TPT Case Enrolment form", + "uuid": "71080512-07e6-345f-864f-93e892420258" + } + ] + } + ] +} + diff --git a/packages/esm-tb-app/src/views/tpt/program-management/tabs/tpt-enrolment.component.tsx b/packages/esm-tb-app/src/views/tpt/program-management/tabs/tpt-enrolment.component.tsx deleted file mode 100644 index 74fe248db..000000000 --- a/packages/esm-tb-app/src/views/tpt/program-management/tabs/tpt-enrolment.component.tsx +++ /dev/null @@ -1,118 +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 '../../../..'; -import { useConfig } from '@openmrs/esm-framework'; - -interface TptEnrolmentListProps { - patientUuid: string; -} - -const TptEnrolmentList: React.FC = ({ patientUuid }) => { - const { t } = useTranslation(); - const { obsConcepts, encounterTypes, formNames, formUuids } = useConfig(); - - const headerTitle = t('tptEnrolment', 'TPT Enrolment'); - - const columns: EncounterListColumn[] = useMemo( - () => [ - { - key: 'enrollmentDate', - header: t('enrollmentDate', 'Enrollment Date'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.tptEnrollmentDate, true); - }, - }, - { - key: 'tptTreatmentID', - header: t('tptTreatmentID', 'TPT Treatment ID'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.tptTreatmentId); - }, - }, - { - key: 'indication', - header: t('indication', 'Indication'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.tptIndication); - }, - }, - { - key: 'treatmentStartDate', - header: t('treatmentStartDate', 'Treatment start date'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.tptTreatmentStartDate, true); - }, - }, - { - key: 'regimen', - header: t('regimen', 'Regimen'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.tptRegimen); - }, - }, - { - key: 'tptOutcome', - header: t('tptOutcome', 'Outcome'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.tptOutcome); - }, - }, - { - key: 'dateOfOutcome', - header: t('dateOfOutcome', 'Date of Outcome'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.tptOutcomeDate, true); - }, - }, - { - key: 'actions', - header: t('actions', 'Actions'), - getValue: (encounter) => [ - { - form: { name: formNames.TptCaseEnrolmentFormName }, - encounterUuid: encounter.uuid, - intent: '*', - label: t('viewDetails', 'View Details'), - mode: 'view', - }, - { - form: { name: formNames.TptCaseEnrolmentFormName }, - encounterUuid: encounter.uuid, - intent: '*', - label: t('editForm', 'Edit Form'), - mode: 'edit', - }, - { - form: { name: formNames.TptOutcomeFormName }, - encounterUuid: encounter.uuid, - intent: '*', - label: t('editForm', 'Add/Edit Outcome'), - mode: 'edit', - }, - ], - }, - ], - [], - ); - - return ( - - ); -}; - -export default TptEnrolmentList; diff --git a/packages/esm-tb-app/src/views/tpt/program-management/tabs/tpt-treatment.component.tsx b/packages/esm-tb-app/src/views/tpt/program-management/tabs/tpt-treatment.component.tsx deleted file mode 100644 index 2e8888e3b..000000000 --- a/packages/esm-tb-app/src/views/tpt/program-management/tabs/tpt-treatment.component.tsx +++ /dev/null @@ -1,85 +0,0 @@ -import React, { useMemo } from 'react'; -import { useTranslation } from 'react-i18next'; -import { useConfig } from '@openmrs/esm-framework'; -import { EncounterList, EncounterListColumn, getObsFromEncounter } from '@ohri/openmrs-esm-ohri-commons-lib'; -import { moduleName } from '../../../..'; - -interface TptTreatmentListProps { - patientUuid: string; -} - -const TptTreatmentList: React.FC = ({ patientUuid }) => { - const { t } = useTranslation(); - const { obsConcepts, encounterTypes, formNames, formUuids } = useConfig(); - const headerTitle = t('tptTreatment', 'TPT Treatment'); - const columns: EncounterListColumn[] = useMemo( - () => [ - { - key: 'caseId', - header: t('caseId', 'Case Id'), - getValue: (encounter: any) => { - return getObsFromEncounter(encounter, obsConcepts.caseID); - }, - }, - { - key: 'Adherence', - header: t('Adherence', 'Adherence'), - getValue: (encounter: any) => { - return getObsFromEncounter(encounter, obsConcepts.tptAdherence); - }, - }, - { - key: 'treatmentPlan', - header: t('treatmentPlan', 'Treatment Plan'), - getValue: (encounter: any) => { - return getObsFromEncounter(encounter, obsConcepts.treatmentPlan); - }, - }, - { - key: 'nextAppointment', - header: t('nextAppointment', 'Next Appointment'), - getValue: (encounter: any) => { - return getObsFromEncounter(encounter, obsConcepts.tptAppointmentDate, true); - }, - }, - { - key: 'actions', - header: t('actions', 'Actions'), - getValue: (encounter) => [ - { - form: { name: formNames.TptTreatmentFormName }, - encounterUuid: encounter.uuid, - intent: '*', - label: t('viewDetails', 'View Details'), - mode: 'view', - }, - { - form: { name: formNames.TptTreatmentFormName }, - encounterUuid: encounter.uuid, - intent: '*', - label: t('editForm', 'Edit Form'), - mode: 'edit', - }, - ], - }, - ], - [], - ); - - return ( - - ); -}; - -export default TptTreatmentList; diff --git a/packages/esm-tb-app/src/views/tpt/program-management/tpt-program-management-config.json b/packages/esm-tb-app/src/views/tpt/program-management/tpt-program-management-config.json new file mode 100644 index 000000000..14a486add --- /dev/null +++ b/packages/esm-tb-app/src/views/tpt/program-management/tpt-program-management-config.json @@ -0,0 +1,137 @@ +{ + "menuId": "programManagement", + "tabDefinitions": [ + { + "tabName": "TPT Enrolment", + "headerTitle": "TPT Enrolment", + "displayText": "TPT Enrolment", + "encounterType": "dc6ce80c-83f8-4ace-a638-21df78542551", + "columns": [ + { + "id": "enrollmentDate", + "isDate": true, + "title": "Enrollment Date", + "concept": "164852AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "tptTreatmentID", + "title": "TPT Treatment ID", + "concept": "162727AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "indication", + "title": "Indication", + "concept": "162276AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "treatmentStartDate", + "isDate": true, + "title": "Treatment start Date", + "concept": "162320AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "regimen", + "title": "Regimen", + "concept": "1264AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "tptOutcome", + "title": "Outcome", + "concept": "1266AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "dateOfOutcome", + "isDate": true, + "title": "Date of Outcome", + "concept": "163284AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "actions", + "title": "Actions", + "actionOptions": [ + { + "formName": "TPT Case Enrolment form", + "package": "tpt", + "label": "View Details", + "mode": "view" + }, + { + "formName": "TPT Case Enrolment form", + "package": "tpt", + "label": "Edit Form", + "mode": "edit" + } + ] + } + ], + "launchOptions": { + "displayText": "Add", + "moduleName": "@ohri/openmrs-esm-ohri-tb-app" + }, + "formList": [ + { + "name": "TPT Case Enrolment form", + "uuid": "1ac3de3f-8fc2-43a7-addb-e805c393ecae" + } + ] + }, + { + "tabName": "TPT Treatment", + "headerTitle": "TPT Treatment", + "displayText": "TPT Treatment", + "encounterType": "1ac3de3f-8fc2-43a7-addb-e805c393ecae", + "columns": [ + { + "id": "caseId", + "title": "Case ID", + "concept": "162576AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "Adherence", + "title": "Adherence", + "concept": "164075AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "treatmentPlan", + "title": "Treatment Plan", + "concept": "1265AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "nextAppointment", + "isDate": true, + "title": "Next Appointment", + "concept": "5096AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "actions", + "title": "Actions", + "actionOptions": [ + { + "formName": "TPT Followup & Treatment form", + "package": "tpt", + "label": "View Details", + "mode": "view" + }, + { + "formName": "TPT Followup & Treatment form", + "package": "tpt", + "label": "Edit Forms", + "mode": "edit" + } + ] + } + ], + "launchOptions": { + "displayText": "Add", + "moduleName": "@ohri/openmrs-esm-ohri-tb-app" + }, + "formList": [ + { + "name": "TPT Followup & Treatment form", + "uuid": "6212bb87-766e-33d0-b37b-79f019008492" + } + ] + } + ] + } + \ No newline at end of file diff --git a/packages/esm-tb-app/src/views/tpt/program-management/tpt-program-management.tsx b/packages/esm-tb-app/src/views/tpt/program-management/tpt-program-management.tsx index 8e391916c..b5e9a32e9 100644 --- a/packages/esm-tb-app/src/views/tpt/program-management/tpt-program-management.tsx +++ b/packages/esm-tb-app/src/views/tpt/program-management/tpt-program-management.tsx @@ -1,27 +1,37 @@ import React from 'react'; import { Tabs, Tab, TabList, TabPanels, TabPanel } from '@carbon/react'; import styles from '../../common.scss'; -import { useTranslation } from 'react-i18next'; -import TptTreatmentList from './tabs/tpt-treatment.component'; -import TptEnrolmentList from './tabs/tpt-enrolment.component'; -import { PatientChartProps } from '@ohri/openmrs-esm-ohri-commons-lib'; +import { EncounterList, getMenuItemTabConfiguration } from '@ohri/openmrs-esm-ohri-commons-lib'; +import tptProgramManagemetConfigSchema from './tpt-program-management-config.json'; +interface OverviewListProps { + patientUuid: string; +} + +const TptProgramManagementSummary: React.FC = ({ patientUuid }) => { + const tabs = getMenuItemTabConfiguration(tptProgramManagemetConfigSchema); -const TptProgramManagementSummary: React.FC = ({ patientUuid }) => { - const { t } = useTranslation(); return (
- {t('tptEnrolment', 'TPT Enrolment')} - {t('tptTreatment', 'TPT Treatment')} + {tabs.map((tab) => ( + {tab.name} + ))} - - - - - - + {tabs.map((tab) => ( + + + + ))}
diff --git a/packages/esm-tb-app/src/views/treatment-and-follow-up/tb-treatment-follow-up.component.tsx b/packages/esm-tb-app/src/views/treatment-and-follow-up/tb-treatment-follow-up.component.tsx index d3b7d7900..ef3097596 100644 --- a/packages/esm-tb-app/src/views/treatment-and-follow-up/tb-treatment-follow-up.component.tsx +++ b/packages/esm-tb-app/src/views/treatment-and-follow-up/tb-treatment-follow-up.component.tsx @@ -1,93 +1,28 @@ -import React, { useMemo } from 'react'; -import { useTranslation } from 'react-i18next'; -import { - EncounterList, - EncounterListColumn, - PatientChartProps, - getObsFromEncounter, -} from '@ohri/openmrs-esm-ohri-commons-lib'; -import { moduleName } from '../..'; -import { useConfig } from '@openmrs/esm-framework'; +import React from 'react'; +import { EncounterList, getMenuItemTabConfiguration } from '@ohri/openmrs-esm-ohri-commons-lib'; +import tbFollowupConfigSchema from './tb-treatment-followup-config.json'; -const TbTreatmentFollowUpList: React.FC = ({ patientUuid }) => { - const { t } = useTranslation(); - const { obsConcepts, encounterTypes, formNames, formUuids } = useConfig(); +interface OverviewListProps { + patientUuid: string; +} - const headerTitle = t('TbTreatmentFollowUp', 'TB Follow-up'); - const columns: EncounterListColumn[] = useMemo( - () => [ - { - key: 'visitDate', - header: t('visitDate', 'Visit Date'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.visitDate, true); - }, - }, - { - key: 'caseId', - header: t('caseId', 'Case ID'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.followUpCaseId); - }, - }, - { - key: 'monthOfTreatment', - header: t('monthOfTreatment', 'Month of Rx'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.monthOfTreatment); - }, - }, - { - key: 'adherenceAssessment', - header: t('adherenceAssessment', 'Adherence'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.adherenceAssessment); - }, - }, - { - key: 'nextAppointment', - header: t('nextAppointment', 'Next Appointment'), - getValue: (encounter) => { - return getObsFromEncounter(encounter, obsConcepts.nextAppointmentDate, true); - }, - }, - { - key: 'actions', - header: t('actions', 'Actions'), - getValue: (encounter) => [ - { - form: { name: 'TB Follow-up Form' }, - encounterUuid: encounter.uuid, - intent: '*', - label: t('viewDetails', 'View Details'), - mode: 'view', - }, - { - form: { name: 'TB Follow-up Form' }, - encounterUuid: encounter.uuid, - intent: '*', - label: t('editForm', 'Edit Form'), - mode: 'edit', - }, - ], - }, - ], - [], - ); +const TbTreatmentFollowUpList: React.FC = ({ patientUuid }) => { + const tabs = getMenuItemTabConfiguration(tbFollowupConfigSchema); return ( - + <> + {tabs.map((tab) => ( + + ))} + ); }; diff --git a/packages/esm-tb-app/src/views/treatment-and-follow-up/tb-treatment-followup-config.json b/packages/esm-tb-app/src/views/treatment-and-follow-up/tb-treatment-followup-config.json new file mode 100644 index 000000000..a09e1d47c --- /dev/null +++ b/packages/esm-tb-app/src/views/treatment-and-follow-up/tb-treatment-followup-config.json @@ -0,0 +1,69 @@ +{ + "menuId": "tbFollowup", + "tabDefinitions": [ + { + "tabName": "TB Follow-up", + "headerTitle": "TB Follow-up", + "displayText": "TB Follow-up", + "encounterType": "1881304a-4854-4927-b0b1-a6231d61e43c", + "columns": [ + { + "id": "visitDate", + "isDate": true, + "title": "Visit Date", + "concept": "160753AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "caseID", + "title": "Case ID", + "concept": "162576AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "monthOfTreatment", + "title": "Month of Rx", + "concept": "1418AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "adherenceAssessment", + "title": "Adherence", + "concept": "164075AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "nextAppointment", + "isDate": true, + "title": "Next Appointment", + "concept": "5096AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + { + "id": "actions", + "title": "Actions", + "actionOptions": [ + { + "formName": "TB Follow-up Form", + "package": "tb", + "label": "View Details", + "mode": "view" + }, + { + "formName": "TB Follow-up Form", + "package": "tb", + "label": "Edit Form", + "mode": "edit" + } + ] + } + ], + "launchOptions": { + "displayText": "Add", + "moduleName": "@ohri/openmrs-esm-ohri-tb-app" + }, + "formList": [ + { + "name": "TB Follow-up Form", + "uuid": "79b05c37-0def-4482-a345-c63b99fbd565" + } + ] + } + ] + } + \ No newline at end of file