diff --git a/packages/esm-tb-app/src/tb/dashboard/patient-list-tabs/tb-patient-list-tabs.component.tsx b/packages/esm-tb-app/src/tb/dashboard/patient-list-tabs/tb-patient-list-tabs.component.tsx index c938acc5e..6d0252709 100644 --- a/packages/esm-tb-app/src/tb/dashboard/patient-list-tabs/tb-patient-list-tabs.component.tsx +++ b/packages/esm-tb-app/src/tb/dashboard/patient-list-tabs/tb-patient-list-tabs.component.tsx @@ -1,93 +1,16 @@ -import React, { useMemo } from 'react'; +import React from 'react'; import { useTranslation } from 'react-i18next'; -import { getObsFromEncounter, OHRIPatientListTabs } from '@ohri/openmrs-esm-ohri-commons-lib'; +import { getPatientListTabsData, OHRIPatientListTabs } from '@ohri/openmrs-esm-ohri-commons-lib'; import { moduleName } from '../../../index'; import { useConfig } from '@openmrs/esm-framework'; +import tbPatientListTabsConfig from './tb-patient-list.config.json'; function TbHomePatientTabs() { const { t } = useTranslation(); const config = useConfig(); + const patientListTabs = getPatientListTabsData(tbPatientListTabsConfig, config); - const tabsConfigs = useMemo( - () => [ - { - label: t('allTbClients', 'All TB Clients'), - cohortId: config.cohorts.clientsEnrolledForTb, - isReportingCohort: true, - cohortSlotName: 'clients-assessed-for-covid-tb', - launchableForm: { - editActionText: t('editFollowUpForm', 'Edit TB Follow-up Form'), - editLatestEncounter: true, - targetDashboard: 'tb-assessments', - name: 'TB Follow-up Form', - }, - associatedEncounterType: config.encounterTypes.tbProgramEnrollment, - excludeColumns: ['timeAddedToList', 'waitingTime', 'location', 'phoneNumber', 'hivResult'], - extraAssociatedEncounterTypes: [config.encounterTypes.tbTreatmentAndFollowUp], - otherColumns: [ - { - key: 'caseID', - header: t('caseID', 'Case ID'), - getValue: ({ latestEncounter }) => { - return getObsFromEncounter(latestEncounter, config.obsConcepts.caseID); - }, - index: 1, - }, - { - key: 'drugSensitivity', - header: t('drugSensitivity', 'Drug Sensitivity'), - getValue: ({ latestEncounter }) => { - return getObsFromEncounter(latestEncounter, config.obsConcepts.drugSensitivity); - }, - }, - { - key: 'site', - header: t('siteOfTb,', 'Site of TB'), - getValue: ({ latestEncounter }) => { - return getObsFromEncounter(latestEncounter, config.obsConcepts.site); - }, - }, - { - key: 'nextAppointmentDate', - header: t('appointmentDate', 'Appointment Date'), - getValue: (patient) => { - const patientLatestExtraEncounters = patient.latestExtraEncounters; - if (patientLatestExtraEncounters && patientLatestExtraEncounters.length) { - const latestFollowUpEncounter = patientLatestExtraEncounters.find( - (encounter) => encounter.encounterType.uuid === config.encounterTypes.tbTreatmentAndFollowUp, - ); - return latestFollowUpEncounter - ? getObsFromEncounter(latestFollowUpEncounter, config.obsConcepts.nextAppointmentDate, true) - : '--'; - } else { - return '--'; - } - }, - }, - { - key: 'outcome', - header: t('outcome', 'Outcome'), - getValue: ({ latestEncounter }) => { - return getObsFromEncounter(latestEncounter, config.obsConcepts.outcome); - }, - }, - ], - viewPatientProgramSummary: true, - }, - ], - [ - config.cohorts.clientsEnrolledForTb, - config.encounterTypes.tbProgramEnrollment, - config.encounterTypes.tbTreatmentAndFollowUp, - config.obsConcepts.caseID, - config.obsConcepts.drugSensitivity, - config.obsConcepts.nextAppointmentDate, - config.obsConcepts.outcome, - config.obsConcepts.site, - t, - ], - ); - return ; + return ; } export default TbHomePatientTabs; diff --git a/packages/esm-tb-app/src/tb/dashboard/patient-list-tabs/tb-patient-list.config.json b/packages/esm-tb-app/src/tb/dashboard/patient-list-tabs/tb-patient-list.config.json new file mode 100644 index 000000000..6b4d448d7 --- /dev/null +++ b/packages/esm-tb-app/src/tb/dashboard/patient-list-tabs/tb-patient-list.config.json @@ -0,0 +1,49 @@ +{ + "menuId": "tbClients", + "tabDefinitions": [ + { + "tabName": "All Tb Clients", + "cohortId": "clientsEnrolledForTb", + "isReportingCohort": true, + "cohortSlotName": "clients-assessed-for-covid-tb", + "launchableForm": { + "package": "tb", + "name": "TB Follow-up Form", + "actionText": "Edit TB follow-up form", + "targetDashboard": "tb-assessments" + }, + "associatedEncounterType": "tbProgramEnrollment", + "extraAssociatedEncounterTypes": ["tbTreatmentAndFollowUp"], + "excludeColumns": ["timeAddedToList", "waitingTime", "location", "phoneNumber", "hivResult"], + "otherColumns": [ + { + "id": "caseID", + "title": "Case ID", + "concept": "caseID", + "index": 1 + }, + { + "id": "drugSensitivity", + "title": "Drug sensitivity", + "concept": "drugSensitivity" + }, + { + "id": "site", + "title": "Site of TB", + "concept": "site" + }, + { + "id": "nextAppointmentDate", + "isDate": true, + "title": "Site of TB", + "concept": "nextAppointmentDate" + }, + { + "id": "outcome", + "title": "Outcome", + "concept": "outcome" + } + ] + } + ] +} \ No newline at end of file diff --git a/packages/esm-tb-app/src/tb/dashboard/patient-list-tabs/tpt-patient-list-tabs.component.tsx b/packages/esm-tb-app/src/tb/dashboard/patient-list-tabs/tpt-patient-list-tabs.component.tsx index af17d923f..1951cda69 100644 --- a/packages/esm-tb-app/src/tb/dashboard/patient-list-tabs/tpt-patient-list-tabs.component.tsx +++ b/packages/esm-tb-app/src/tb/dashboard/patient-list-tabs/tpt-patient-list-tabs.component.tsx @@ -1,65 +1,16 @@ -import React, { useMemo } from 'react'; +import React from 'react'; import { useTranslation } from 'react-i18next'; -import { getObsFromEncounter, OHRIPatientListTabs } from '@ohri/openmrs-esm-ohri-commons-lib'; +import { getPatientListTabsData, OHRIPatientListTabs } from '@ohri/openmrs-esm-ohri-commons-lib'; import { moduleName } from '../../../index'; import { useConfig } from '@openmrs/esm-framework'; +import tptPatientListTabsConfig from './tpt-patient-list.config.json'; function TptPatientListTabs() { const { t } = useTranslation(); - const { obsConcepts, encounterTypes, cohorts } = useConfig(); + const config = useConfig(); + const patientListTabs = getPatientListTabsData(tptPatientListTabsConfig, config); - const tabsConfigs = useMemo( - () => [ - { - label: t('allTptClients', 'All TPT Clients'), - cohortId: cohorts.clientsEnrolledForTpt, - isReportingCohort: true, - cohortSlotName: 'clients-assessed-for-tpt', - launchableForm: { - editActionText: t('editTptFollowUpForm', 'Edit TPT Follow-up form'), - editLatestEncounter: true, - targetDashboard: 'tb-assessments', - name: 'TPT Followup & Treatment form', - }, - associatedEncounterType: encounterTypes.tptCaseEnrollment, - excludeColumns: ['timeAddedToList', 'waitingTime', 'location', 'phoneNumber', 'hivResult'], - otherColumns: [ - { - key: 'tptTreatmentId', - header: t('tptTreatmentId', 'TPT Treatment ID'), - getValue: ({ latestEncounter }) => { - return getObsFromEncounter(latestEncounter, obsConcepts.tptTreatmentId); - }, - index: 1, - }, - { - key: 'EnrolmentDate', - header: t('EnrolmentDate', 'Enrolment Date'), - getValue: ({ latestEncounter }) => { - return getObsFromEncounter(latestEncounter, obsConcepts.tptEnrollmentDate, true); - }, - }, - { - key: 'indication', - header: t('indication', 'Indication'), - getValue: ({ latestEncounter }) => { - return getObsFromEncounter(latestEncounter, obsConcepts.tptIndication); - }, - }, - ], - viewTptPatientProgramSummary: true, - }, - ], - [ - cohorts.clientsEnrolledForTpt, - encounterTypes.tptCaseEnrollment, - obsConcepts.tptEnrollmentDate, - obsConcepts.tptIndication, - obsConcepts.tptTreatmentId, - t, - ], - ); - return ; + return ; } export default TptPatientListTabs; diff --git a/packages/esm-tb-app/src/tb/dashboard/patient-list-tabs/tpt-patient-list.config.json b/packages/esm-tb-app/src/tb/dashboard/patient-list-tabs/tpt-patient-list.config.json new file mode 100644 index 000000000..777a039cb --- /dev/null +++ b/packages/esm-tb-app/src/tb/dashboard/patient-list-tabs/tpt-patient-list.config.json @@ -0,0 +1,38 @@ +{ + "menuId": "tptClients", + "tabDefinitions": [ + { + "tabName": "All Tpt Clients", + "cohortId": "clientsEnrolledForTpt", + "isReportingCohort": true, + "cohortSlotName": "clients-assessed-for-covid-tpt", + "launchableForm": { + "package": "tpt", + "name": "TPT Followup & Treatment form", + "actionText": "Edit TPT Follow-up form", + "targetDashboard": "tb-assessments" + }, + "associatedEncounterType": "tptCaseEnrollment", + "excludeColumns": ["timeAddedToList", "waitingTime", "location", "phoneNumber", "hivResult"], + "otherColumns": [ + { + "id": "tptTreatmentId", + "title": "TPT Treatment ID", + "concept": "tptTreatmentId", + "index": 1 + }, + { + "id": "EnrolmentDate", + "isDate": true, + "title": "Enrolment date", + "concept": "tptEnrollmentDate" + }, + { + "id": "indication", + "title": "Indication", + "concept": "tptIndication" + } + ] + } + ] +} \ No newline at end of file