Skip to content

Commit

Permalink
OHRI-2223: Implement the TB app schema based workflow (#1861)
Browse files Browse the repository at this point in the history
* Implement the TB app schema based workflow

* Ensure TB Treatement ID, Treatment Start Date and Regimen columns dispaly  correct data

* update

* ..

* proper date format, cleanup and indentation fix

* update the tb

* Update summary-card-config-builder.ts

* update Tpt and fix indents
  • Loading branch information
lucyjemutai authored Jun 13, 2024
1 parent 82ff232 commit 07c4bce
Show file tree
Hide file tree
Showing 26 changed files with 1,005 additions and 1,024 deletions.
2 changes: 1 addition & 1 deletion packages/esm-commons-lib/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export * from './components/extension-conditional-renderer/patient-based-extensi
export * from './components/patient-table/patient-table.component';
export * from './hooks/useLastEncounter';
export * from './utils/encounter-list-config-builder';

export * from './utils/summary-card-config-builder';
// Workspace registration moved to the index.ts and routes.json
const options = {
featureName: 'ohri-forms-workspace-item',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
getMultipleObsFromEncounter,
resolveValueUsingMappings,
getConceptFromMappings,
getConditionalConceptValue,
} from './encounter-list-utils';
import { renderTag } from './encounter-list-component-util';
import { extractSchemaValues, replaceWithConfigDefaults } from './schema-manipulation';
Expand Down Expand Up @@ -49,6 +50,8 @@ interface ColumnDefinition {
valueMappings?: Record<string, string>;
conceptMappings?: Array<string>;
statusColorMappings?: Record<string, string>;
isConditionalConcept?: boolean;
conditionalConceptMappings?: Record<string, string>;
}

interface LaunchOptions {
Expand Down Expand Up @@ -109,6 +112,8 @@ export const getTabColumns = (columnsDefinition: Array<ColumnDefinition>) => {
return [...baseActions, ...conditionalActions];
} else if (column.statusColorMappings) {
return renderTag(encounter, column.concept, column.statusColorMappings);
} else if (column.isConditionalConcept) {
return getConditionalConceptValue(encounter, column.conditionalConceptMappings, column.isDate);
} else if (column.useMultipleObs === true) {
return getMultipleObsFromEncounter(encounter, column.multipleConcepts);
} else if (column.valueMappings) {
Expand Down
7 changes: 7 additions & 0 deletions packages/esm-commons-lib/src/utils/encounter-list-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ export function resolveValueUsingMappings(encounter, concept, mappings) {
return '--';
}

export function getConditionalConceptValue(encounter: any, conditionalConceptMappings, isDate) {
const { trueConcept, nonTrueConcept, dependantConcept, conditionalConcept } = conditionalConceptMappings;
const dependantUuid = findObs(encounter, dependantConcept)?.value?.uuid;
const finalConcept = dependantUuid === conditionalConcept ? trueConcept : nonTrueConcept;
return getObsFromEncounter(encounter, finalConcept, isDate);
}

export function getConceptFromMappings(encounter, concepts) {
for (const concept of concepts) {
const obs = findObs(encounter, concept);
Expand Down
35 changes: 35 additions & 0 deletions packages/esm-commons-lib/src/utils/summary-card-config-builder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { getObsFromEncounter, getConditionalConceptValue } from './encounter-list-utils';

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);
}
return getObsFromEncounter(
encounter,
column.concept,
column.isDate,
column.isTrueFalseConcept,
column.type,
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(' | ');
},
}));

return columns;
};
2 changes: 1 addition & 1 deletion packages/esm-tb-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from './dashboard.meta';
import { configSchema } from './config-schema';
import TBSummaryOverviewList from './views/patient-summary/tb-patient-summary.component';
import ProgramManagementSummary from './views/program-management/maternal-health.component';
import ProgramManagementSummary from './views/program-management/tb-program-management';
import TbTreatmentFollowUpList from './views/treatment-and-follow-up/tb-treatment-follow-up.component';
import TbContactTracingList from './views/tb-contact-listing/tb-contact-list.component';
import tptProgramManagementSummary from './views/tpt/program-management/tpt-program-management';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"menuId": "previousCases",
"tabDefinitions": [
{
"tabName": "Previous Cases",
"headerTitle": "Previous Cases",
"displayText": "Previous Cases",
"encounterType": "9a199b59-b185-485b-b9b3-a9754e65ae57",
"columns": [
{
"id": "caseID",
"title": "Case ID",
"concept": "162576AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
},
{
"id": "enrollmentDate",
"isDate": true,
"title": "Enrollment Date",
"concept": "161552AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
},
{
"id": "type",
"title": "Type",
"concept": "159990AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
},
{
"id": "site",
"title": "Site",
"concept": "160040AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
},
{
"id": "regimen",
"title": "Regimen",
"isConditionalConcept": true,
"conditionalConceptMappings": {
"trueConcept": "16fd7307-0b26-4c8b-afa3-8362baff4042",
"nonTrueConcept": "159909AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"dependantConcept": "163775AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"conditionalConcept": "160541AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
}
},
{
"id": "outcome",
"title": "Outcome",
"concept": "159786AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
}
],
"launchOptions": {
"hideFormLauncher": true,
"displayText": "Add",
"moduleName": "@ohri/openmrs-esm-ohri-tb-app"
},
"formList": [
{
"name": "TB Case Enrollment Form",
"uuid": "554b2017-e512-3fc8-9c6e-7baf9e69db9d"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"menuId": "recentTuberculosis",
"cardTitle": "Recent Tuberculosis",
"columns": [
{
"id": "caseID",
"title": "Case ID",
"encounterTypes": [
"9a199b59-b185-485b-b9b3-a9754e65ae57"
],
"concept": "162576AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
},
{
"id": "enrollmentDate",
"isDate": true,
"title": "Enrollment Date",
"encounterTypes": [
"9a199b59-b185-485b-b9b3-a9754e65ae57"
],
"concept": "161552AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
},
{
"id": "type",
"title": "Type",
"encounterTypes": [
"9a199b59-b185-485b-b9b3-a9754e65ae57"
],
"concept": "159990AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
},
{
"id": "site",
"title": "Site",
"encounterTypes": [
"9a199b59-b185-485b-b9b3-a9754e65ae57"
],
"concept": "160040AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
},
{
"id": "drugSensitivity",
"title": "Drug Sensitivity",
"encounterTypes": [
"9a199b59-b185-485b-b9b3-a9754e65ae57"
],
"concept": "164368AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
},
{
"id": "regimen",
"title": "Regimen",
"encounterTypes": [
"9a199b59-b185-485b-b9b3-a9754e65ae57"
],
"isConditionalConcept": true,
"conditionalConceptMappings": {
"trueConcept": "16fd7307-0b26-4c8b-afa3-8362baff4042",
"nonTrueConcept": "159909AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"dependantConcept": "163775AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"conditionalConcept": "160541AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
}
},
{
"id": "hivStatus",
"title": "HIV Status",
"encounterTypes": [
"9a199b59-b185-485b-b9b3-a9754e65ae57"
],
"concept": "159576AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
},
{
"id": "outcome",
"title": "Outcome",
"encounterTypes": [
"9a199b59-b185-485b-b9b3-a9754e65ae57"
],
"concept": "159786AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
}
]
}
Loading

0 comments on commit 07c4bce

Please sign in to comment.