Skip to content

Commit

Permalink
Updates on the All TB Clients Table in the Tuberculosis Treatment das…
Browse files Browse the repository at this point in the history
…hboard (UCSF-IGHS#1723)

Co-authored-by: lucyjemutai <[email protected]>
  • Loading branch information
lucyjemutai and lucyjemutai authored Dec 14, 2023
1 parent eb3e2c1 commit 798e94c
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface CohortPatientListProps {
excludeColumns?: Array<string>;
queryParams?: Array<string>;
associatedEncounterType?: string;
viewPatientProgramSummary?: boolean;
addPatientToListOptions?: { isEnabled: boolean; excludeCohorts?: Array<string> };
launchableForm?: {
name: string;
Expand Down Expand Up @@ -52,6 +53,7 @@ export const CohortPatientList: React.FC<CohortPatientListProps> = ({
addPatientToListOptions,
extraAssociatedEncounterTypes,
moduleName,
viewPatientProgramSummary,
}) => {
const [isLoading, setIsLoading] = useState(true);
const [hasLoadedPatients, setHasLoadedPatients] = useState(false);
Expand Down Expand Up @@ -145,6 +147,7 @@ export const CohortPatientList: React.FC<CohortPatientListProps> = ({
...addPatientToListOptions,
displayText: t('moveToListSideNav', 'Move to list'),
},
viewPatientProgramSummary
}),
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface PatientMetaConfig {
launchableFormProps: Record<string, any>;
moduleName: string;
addPatientToListOptions: { isEnabled: boolean; excludeCohorts?: Array<string>; displayText: string };
viewPatientProgramSummary?: boolean;
}

export interface PatientListColumn {
Expand Down Expand Up @@ -71,8 +72,51 @@ export const LaunchableFormMenuItem = ({
);
};

export const ViewSummaryMenuItem = ({
patientUuid,
ViewSummary,
encounterType,
}) => {
const [actionText, setActionText] = useState(ViewSummary.actionText);
const [encounterUuid, setEncounterUuid] = useState(null);
const [isLoading, setIsLoading] = useState(false);
const viewSummaryActionText = ViewSummary.actionText || 'View Summary ';

useEffect(() => {
if (ViewSummary.editLatestEncounter && encounterType && !encounterUuid) {
setIsLoading(true);
fetchPatientLastEncounter(patientUuid, encounterType).then((latestEncounter) => {
if (latestEncounter) {
setActionText(viewSummaryActionText);
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/tb-patient-summary`,
});
}}
/>
)}
</>
);
};

export function consolidatatePatientMeta(rawPatientMeta, form, config: PatientMetaConfig) {
const { isDynamicCohort, location, encounterType, launchableFormProps, moduleName, addPatientToListOptions } = config;
const { isDynamicCohort, location, encounterType, launchableFormProps, moduleName, addPatientToListOptions,viewPatientProgramSummary } = config;
const patientUuid = !isDynamicCohort ? rawPatientMeta.patient.uuid : rawPatientMeta.person.uuid;
return {
timeAddedToList: !isDynamicCohort ? moment(rawPatientMeta.startDate).format('LL') : null,
Expand Down Expand Up @@ -102,6 +146,16 @@ export function consolidatatePatientMeta(rawPatientMeta, form, config: PatientMe
excludeCohorts={addPatientToListOptions?.excludeCohorts || []}
/>
)}
{viewPatientProgramSummary ? (
<ViewSummaryMenuItem
patientUuid={patientUuid}
ViewSummary={launchableFormProps}
encounterType={launchableFormProps.encounterType || encounterType}
key={patientUuid}
/>
) : (
<></>
)}
</OverflowMenu>
),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export function OHRIPatientListTabs({ patientListConfigs, moduleName }) {
launchableForm={config.launchableForm}
extraAssociatedEncounterTypes={config.extraAssociatedEncounterTypes}
moduleName={moduleName}
viewPatientProgramSummary={config.viewPatientProgramSummary}
/>
</TabPanel>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
getObsFromEncounter,
OHRIPatientListTabs,
} from '@ohri/openmrs-esm-ohri-commons-lib';
import moment from 'moment';
import { moduleName } from '../../../index';
import { useConfig } from '@openmrs/esm-framework';

Expand All @@ -20,11 +19,12 @@ function TbHomePatientTabs() {
isReportingCohort: true,
cohortSlotName: 'clients-assessed-for-covid-tb',
launchableForm: {
editActionText: t('editAssessmentForm', 'Edit TB case assessment form'),
editActionText: t('editFollowUpForm', 'Edit TB Follow-up Form'),
editLatestEncounter: true,
targetDashboard: 'tb-assessments',
name: 'TB Case Enrollment Form',
name: 'TB Follow-up Form',
},
associatedEncounterType: config.encounterTypes.tbProgramEnrollment,
excludeColumns: ['timeAddedToList', 'waitingTime', 'location', 'phoneNumber', 'hivResult'],
otherColumns: [
{
Expand Down Expand Up @@ -64,6 +64,7 @@ function TbHomePatientTabs() {
},
},
],
viewPatientProgramSummary:true
},
],
[],
Expand Down
3 changes: 2 additions & 1 deletion packages/esm-tb-app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@
"adherenceAssessment": "Adherence",
"nextAppointment": "Next Appointment",
"siteOfTb": "Site of TB",
"appointmentDate": "Appointment Date"
"appointmentDate": "Appointment Date",
"editFollowUpForm": "Edit TB Follow-up Form"
}

0 comments on commit 798e94c

Please sign in to comment.