Skip to content

Commit

Permalink
OHRI-2011: Add a table of all enrolled clients in TPT Program (#1789)
Browse files Browse the repository at this point in the history
* Add TB Prevention link under Tuberculosis program in the clinical perspectives

* Add a table of all enrolled clients in TPT Program

* Add a table of all enrolled clients in TPT Program
  • Loading branch information
lucyjemutai authored Jan 26, 2024
1 parent 7edc0fe commit bec22f3
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ interface CohortPatientListProps {
queryParams?: Array<string>;
associatedEncounterType?: string;
viewPatientProgramSummary?: boolean;
viewTptPatientProgramSummary?: boolean;
addPatientToListOptions?: { isEnabled: boolean; excludeCohorts?: Array<string> };
launchableForm?: {
name: string;
Expand Down Expand Up @@ -54,6 +55,7 @@ export const CohortPatientList: React.FC<CohortPatientListProps> = ({
extraAssociatedEncounterTypes,
moduleName,
viewPatientProgramSummary,
viewTptPatientProgramSummary,
}) => {
const [isLoading, setIsLoading] = useState(true);
const [hasLoadedPatients, setHasLoadedPatients] = useState(false);
Expand Down Expand Up @@ -147,6 +149,7 @@ export const CohortPatientList: React.FC<CohortPatientListProps> = ({
...addPatientToListOptions,
displayText: t('moveToListSideNav', 'Move to list'),
},
viewTptPatientProgramSummary,
viewPatientProgramSummary,
}),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface PatientMetaConfig {
moduleName: string;
addPatientToListOptions: { isEnabled: boolean; excludeCohorts?: Array<string>; displayText: string };
viewPatientProgramSummary?: boolean;
viewTptPatientProgramSummary?: boolean;
}

export interface PatientListColumn {
Expand Down Expand Up @@ -112,7 +113,44 @@ export const ViewSummaryMenuItem = ({ patientUuid, ViewSummary, encounterType })
</>
);
};
export const ViewTptSummaryMenuItem = ({ patientUuid, ViewTptSummary, encounterType }) => {
const [actionText, setActionText] = useState(ViewTptSummary.actionText);
const [encounterUuid, setEncounterUuid] = useState(null);
const [isLoading, setIsLoading] = useState(false);
const viewTptSummaryActionText = ViewTptSummary.actionText || 'View Summary ';

useEffect(() => {
if (ViewTptSummary.editLatestEncounter && encounterType && !encounterUuid) {
setIsLoading(true);
fetchPatientLastEncounter(patientUuid, encounterType).then((latestEncounter) => {
if (latestEncounter) {
setActionText(viewTptSummaryActionText);
setEncounterUuid(latestEncounter.uuid);
}
setIsLoading(false);
});
} else {
setIsLoading(false);
}
}, []);

return (
<>
{isLoading ? (
<InlineLoading style={{ margin: '0 auto', width: '16px' }} />
) : (
<OverflowMenuItem
itemText={actionText}
onClick={() => {
navigate({
to: `/openmrs/spa/patient/${patientUuid}/chart/tpt-patient-summary`,
});
}}
/>
)}
</>
);
};
export function consolidatatePatientMeta(rawPatientMeta, form, config: PatientMetaConfig) {
const {
isDynamicCohort,
Expand All @@ -122,6 +160,7 @@ export function consolidatatePatientMeta(rawPatientMeta, form, config: PatientMe
moduleName,
addPatientToListOptions,
viewPatientProgramSummary,
viewTptPatientProgramSummary,
} = config;
const patientUuid = !isDynamicCohort ? rawPatientMeta.patient.uuid : rawPatientMeta.person.uuid;
dayjs.extend(localizedFormat);
Expand Down Expand Up @@ -155,6 +194,16 @@ export function consolidatatePatientMeta(rawPatientMeta, form, config: PatientMe
excludeCohorts={addPatientToListOptions?.excludeCohorts || []}
/>
)}
{viewTptPatientProgramSummary ? (
<ViewTptSummaryMenuItem
patientUuid={patientUuid}
ViewTptSummary={launchableFormProps}
encounterType={launchableFormProps.encounterType || encounterType}
key={patientUuid}
/>
) : (
<></>
)}
{viewPatientProgramSummary ? (
<ViewSummaryMenuItem
patientUuid={patientUuid}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export function OHRIPatientListTabs({ patientListConfigs, moduleName }) {
extraAssociatedEncounterTypes={config.extraAssociatedEncounterTypes}
moduleName={moduleName}
viewPatientProgramSummary={config.viewPatientProgramSummary}
viewTptPatientProgramSummary={config.viewTptPatientProgramSummary}
/>
</TabPanel>
);
Expand Down
1 change: 1 addition & 0 deletions packages/esm-tb-app/src/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const configSchema = {
_description: 'TB Cohort uuid.',
_default: {
clientsEnrolledForTb: '98fd11ba-cb4d-46f7-9b82-40d49949c7ef',
clientsEnrolledForTpt: '5f28254f-0a80-4d15-ad91-68c6cf5ea715',
},
},
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,58 @@
import React from 'react';
import { Tabs, Tab, TabPanels, TabPanel, TabList } from '@carbon/react';
import React, { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { getObsFromEncounter, OHRIPatientListTabs } from '@ohri/openmrs-esm-ohri-commons-lib';
import { moduleName } from '../../../index';
import { useConfig } from '@openmrs/esm-framework';

interface OverviewListProps {
patientUuid: string;
}

const TptPatientListTabs: React.FC<OverviewListProps> = ({ }) => {
function TptPatientListTabs() {
const { t } = useTranslation();
return (
<Tabs>
<TabList contained>
<Tab>{t('allTptClients', 'All TPT Clients')}</Tab>
</TabList>
<TabPanels>
<TabPanel></TabPanel>
</TabPanels>
</Tabs>
const { obsConcepts, encounterTypes, cohorts } = useConfig();

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,
},
],
[],
);
};
return <OHRIPatientListTabs patientListConfigs={tabsConfigs} moduleName={moduleName} />;
}

export default TptPatientListTabs;
4 changes: 2 additions & 2 deletions packages/esm-tb-app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@
"tptAdherence": "Adherence",
"nextAppointmentDate": "Next Appointment Date",
"previousTptCases": "Previous TPT Cases",
"recentTptCases": "Recent TPT Cases"

"recentTptCases": "Recent TPT Cases",
"editTptFollowUpForm": "Edit TPT Follow-up form"
}

0 comments on commit bec22f3

Please sign in to comment.