Skip to content

Commit

Permalink
update Tpt and fix indents
Browse files Browse the repository at this point in the history
  • Loading branch information
lucyjemutai committed Jun 13, 2024
1 parent d3a58e4 commit 59bf205
Show file tree
Hide file tree
Showing 6 changed files with 227 additions and 217 deletions.
24 changes: 17 additions & 7 deletions packages/esm-commons-lib/src/utils/summary-card-config-builder.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
import { getObsFromEncounter, getConditionalConceptValue } from "./encounter-list-utils";
import { getObsFromEncounter, getConditionalConceptValue } from './encounter-list-utils';

export const getSummarryCardProps = (schemaConfig) => {
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); }
if (column.isConditionalConcept) {
return getConditionalConceptValue(encounter, column.conditionalConceptMappings, column.isDate);
}
return getObsFromEncounter(
encounter,
column.concept,
column.isDate,
column.isTrueFalseConcept,
column.type,
column.fallbackConcepts,);
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(' | ');
},
getObsSummary: () => { }

}));

return columns;
};

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
EncounterList,
SummaryCard,
getMenuItemTabConfiguration,
getSummarryCardProps,
getSummaryCardProps,
} from '@ohri/openmrs-esm-ohri-commons-lib';
import React from 'react';
import previousCasesConfigSchema from './previous-cases-config.json';
Expand All @@ -14,10 +14,9 @@ interface OverviewListProps {
}

const TBSummaryOverviewList: React.FC<OverviewListProps> = ({ patientUuid }) => {

const previousCaseTabs = getMenuItemTabConfiguration(previousCasesConfigSchema);
const tbVisistsTabs = getMenuItemTabConfiguration(tbVisitsConfigSchema);
const summaryCardColumns = getSummarryCardProps(recentTuberculosisConfigSchema);
const tbVisitsTabs = getMenuItemTabConfiguration(tbVisitsConfigSchema);
const summaryCardColumns = getSummaryCardProps(recentTuberculosisConfigSchema);

return (
<>
Expand All @@ -41,7 +40,7 @@ const TBSummaryOverviewList: React.FC<OverviewListProps> = ({ patientUuid }) =>
/>
))}

{tbVisistsTabs.map((tab) => (
{tbVisitsTabs.map((tab) => (
<EncounterList
key={tab.encounterType}
patientUuid={patientUuid}
Expand Down
Original file line number Diff line number Diff line change
@@ -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<PatientChartProps> = ({ 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<OverviewListProps> = ({ patientUuid }) => {
const previousCaseTabs = getMenuItemTabConfiguration(tptPreviousCasesConfigSchema);
const tbVisitsTabs = getMenuItemTabConfiguration(tptVisitsConfigSchema);
const summaryCardColumns = getSummaryCardProps(recentTptConfigSchema);

return (
<>
<SummaryCard
patientUuid={patientUuid}
headerTitle={headerRecentTPT}
columns={recentTbPreventionColumns}
headerTitle={'Recent TPT Cases'}
columns={summaryCardColumns}
maxRowItems={4}
/>
<EncounterList
patientUuid={patientUuid}
encounterType={encounterTypes.tptCaseEnrollment}
columns={previousTptCasesColumns}
description={headerPreviousTptCases}
headerTitle={headerPreviousTptCases}
formList={[{ name: formNames.TptCaseEnrolmentFormName, uuid: formUuids.tptCaseEnrolmentFormUuid }]}
launchOptions={{
hideFormLauncher: true,
displayText: '',
moduleName: moduleName,
}}
/>
<EncounterList
patientUuid={patientUuid}
encounterType={encounterTypes.tptCaseEnrollment}
columns={TptVisitsColumns}
description={headerVisit}
headerTitle={headerVisit}
formList={[{ name: formNames.TptCaseEnrolmentFormName, uuid: formUuids.tptCaseEnrolmentFormUuid }]}
launchOptions={{
hideFormLauncher: true,
displayText: '',
moduleName: moduleName,
}}
/>

{previousCaseTabs.map((tab) => (
<EncounterList
key={tab.encounterType}
patientUuid={patientUuid}
encounterType={tab.encounterType}
formList={tab.formList}
columns={tab.columns}
description={tab.description}
headerTitle={tab.headerTitle}
launchOptions={tab.launchOptions}
/>
))}

{tbVisitsTabs.map((tab) => (
<EncounterList
key={tab.encounterType}
patientUuid={patientUuid}
encounterType={tab.encounterType}
formList={tab.formList}
columns={tab.columns}
description={tab.description}
headerTitle={tab.headerTitle}
launchOptions={tab.launchOptions}
/>
))}
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
}
]
}

Loading

0 comments on commit 59bf205

Please sign in to comment.