diff --git a/packages/esm-commons-lib/src/components/cohort-patient-list/cohort-patient-list.component.tsx b/packages/esm-commons-lib/src/components/cohort-patient-list/cohort-patient-list.component.tsx index 85d7ae2ab..564c1096c 100644 --- a/packages/esm-commons-lib/src/components/cohort-patient-list/cohort-patient-list.component.tsx +++ b/packages/esm-commons-lib/src/components/cohort-patient-list/cohort-patient-list.component.tsx @@ -286,6 +286,7 @@ export const CohortPatientList: React.FC = ({ autoFocus: true, }; }, [ + loadedExtraEncounters, searchTerm, filteredResults, paginatedPatients, diff --git a/packages/esm-tb-app/src/views/dashboard/patient-list-tabs/tb-patient-list-tabs.component.tsx b/packages/esm-tb-app/src/views/dashboard/patient-list-tabs/tb-patient-list-tabs.component.tsx index d445945d3..81f9f6050 100644 --- a/packages/esm-tb-app/src/views/dashboard/patient-list-tabs/tb-patient-list-tabs.component.tsx +++ b/packages/esm-tb-app/src/views/dashboard/patient-list-tabs/tb-patient-list-tabs.component.tsx @@ -23,6 +23,7 @@ function TbHomePatientTabs() { }, associatedEncounterType: config.encounterTypes.tbProgramEnrollment, excludeColumns: ['timeAddedToList', 'waitingTime', 'location', 'phoneNumber', 'hivResult'], + extraAssociatedEncounterTypes: [config.encounterTypes.tbTreatmentAndFollowUp], otherColumns: [ { key: 'caseID', @@ -49,8 +50,18 @@ function TbHomePatientTabs() { { key: 'nextAppointmentDate', header: t('appointmentDate', 'Appointment Date'), - getValue: ({ latestEncounter }) => { - return getObsFromEncounter(latestEncounter, config.obsConcepts.nextAppointmentDate, true); + 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 '--'; + } }, }, {