Skip to content

Commit

Permalink
implement covid app schema workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
hadijahkyampeire committed Jun 6, 2024
1 parent e24f880 commit b51e99e
Show file tree
Hide file tree
Showing 14 changed files with 584 additions and 748 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ interface ActionProps {
package: string;
formName: string;
}

interface ConditionalActionProps {
mode: string;
label: string;
package: string;
formName: string;
dependsOn: string;
dependantConcept: string;
}

interface ColumnDefinition {
id: string;
title: string;
Expand All @@ -18,6 +28,7 @@ interface ColumnDefinition {
multipleConcepts?: Array<string>;
fallbackConcepts?: Array<string>;
actionOptions?: Array<ActionProps>;
conditionalActionOptions?: Array<ConditionalActionProps>;
isDate?: boolean;
isTrueFalseConcept?: boolean;
type?: string;
Expand Down Expand Up @@ -45,21 +56,41 @@ interface FormattedColumn {
header: string;
getValue: (encounter: any) => string;
link?: any;
concept?: string;
}

export const getTabColumns = (columnsDefinition: Array<ColumnDefinition>) => {
const columns: Array<FormattedColumn> = columnsDefinition.map((column: ColumnDefinition) => ({
key: column.id,
header: column.title,
concept: column.concept,
getValue: (encounter) => {
if (column.id === 'actions') {
return column.actionOptions.map((action: ActionProps) => ({
const conditionalActions = [];
const baseActions = column.actionOptions.map((action: ActionProps) => ({
form: { name: action.formName, package: action.package },
encounterUuid: encounter.uuid,
intent: '*',
label: action.label,
mode: action.mode,
}));

if (column?.conditionalActionOptions?.length) {
column?.conditionalActionOptions?.map((action) => {
const dependantObsValue = getObsFromEncounter(encounter, action.dependantConcept);

if (dependantObsValue === action.dependsOn) {
return conditionalActions.push({
form: { name: action.formName, package: action.package },
encounterUuid: encounter.uuid,
intent: '*',
label: action.label,
mode: action.mode,
});
}
});
}
return [...baseActions, ...conditionalActions];
} else if (column.useMultipleObs === true) {
return getMultipleObsFromEncounter(encounter, column.multipleConcepts);
} else {
Expand Down
118 changes: 3 additions & 115 deletions packages/esm-commons-lib/src/utils/encounter-list-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,128 +40,16 @@ export function getMultipleObsFromEncounter(encounter, obsConcepts: Array<string
return observations.length ? observations.join(', ') : '--';
}

const artDateConcepts = {
artTherapyDateTime_UUID: '159599AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
artStopDateUUID: '162572AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
switchDateUUID: '164516AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
substitutionDateUUID: '164431AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
dateRestartedUUID: '160738AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
};

export const getARTDateConcept = (encounter): string => {
let artStartDate = findObs(encounter, artDateConcepts.artTherapyDateTime_UUID);
let artSwitchDate = findObs(encounter, artDateConcepts.switchDateUUID);
let artSubstitutionDate = findObs(encounter, artDateConcepts.substitutionDateUUID);
let artStopDate = findObs(encounter, artDateConcepts.artStopDateUUID);
let artRestartDate = findObs(encounter, artDateConcepts.dateRestartedUUID);

artStartDate = artStartDate ? artStartDate.value : null;
artSubstitutionDate = artSubstitutionDate ? artSubstitutionDate.value : null;
artSwitchDate = artSwitchDate ? artSwitchDate.value : null;
artStopDate = artStopDate ? artStopDate.value : null;
artRestartDate = artRestartDate ? artRestartDate.value : null;

let latestDateConcept: string = artDateConcepts.artTherapyDateTime_UUID;
let latestDate = artStartDate;
if (artSubstitutionDate != null) {
latestDateConcept = artDateConcepts.substitutionDateUUID;
latestDate = artSubstitutionDate;
}
if (artSwitchDate != null) {
latestDate = artSwitchDate;
latestDateConcept = artDateConcepts.switchDateUUID;
}
if (artStopDate != null) {
latestDate = artStopDate;
latestDateConcept = artDateConcepts.artStopDateUUID;
}
if (artRestartDate != null) {
latestDate = artRestartDate;
latestDateConcept = artDateConcepts.dateRestartedUUID;
}

return latestDateConcept;
};

const artReasonConcepts = {
switchReasonUUID: '160568AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
substituteReasonUUID: '160562AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
stopReasonUUID: '163513AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
freeTextCommentConcept: '161011AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
};

const getARTReasonConcept = (encounter, startDate, switchDate, substitutionDate, stopDate, restartDate): string => {
const latestDateConcept: string = getARTDateConcept(encounter);

let artReasonConcept;
switch (latestDateConcept) {
case startDate:
artReasonConcept = '';
break;
case substitutionDate:
artReasonConcept = artReasonConcepts.substituteReasonUUID;
break;
case switchDate:
artReasonConcept = artReasonConcepts.switchReasonUUID;
break;
case restartDate:
artReasonConcept = artReasonConcepts.freeTextCommentConcept;
break;
case stopDate:
artReasonConcept = artReasonConcepts.stopReasonUUID;
default:
artReasonConcept = artReasonConcepts.stopReasonUUID;
}

return artReasonConcept;
};

const artConcepts: { [key: string]: string } = {
'1256AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA': 'Start ART',
'1258AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA': 'Substitute ART Regimen',
'1259AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA': 'Switch ART Regimen Line',
'1260AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA': 'Stop ART',
'3e69cb60-2943-410f-83d4-b359ae83fefd': 'Restart ART therapy',
};

export function getObsFromEncounter(
encounter,
obsConcept,
isDate?: Boolean,
isTrueFalseConcept?: Boolean,
type?: string,
fallBackConcepts?: Array<string>,
fallbackConcepts?: Array<string>,
) {
let obs = findObs(encounter, obsConcept);

// if (type === 'artDate') {
// const artDateConcept = getARTDateConcept(encounter);
// obs = findObs(encounter, artDateConcept);
// }

// if (type === 'artReason') {
// const reasonConcept = getARTReasonConcept(
// encounter,
// artDateConcepts.artTherapyDateTime_UUID,
// artDateConcepts.switchDateUUID,
// artDateConcepts.substitutionDateUUID,
// artDateConcepts.artStopDateUUID,
// artDateConcepts.dateRestartedUUID,
// );
// const artReasonConcept = reasonConcept;
// obs = findObs(encounter, artReasonConcept);
// }

// if (type === 'artTherapy') {
// const therapyObs = findObs(encounter, obsConcept);
// return therapyObs ? artConcepts[therapyObs.value.uuid] : '--';
// }

// if (type === 'transferVerified') {
// const obs = findObs(encounter, obsConcept);
// return obs?.value?.name?.name === 'FALSE' ? 'No' : obs?.value?.name?.name;
// }

if (isTrueFalseConcept) {
if (obs?.value?.uuid == 'cf82933b-3f3f-45e7-a5ab-5d31aaee3da3') {
return 'Yes';
Expand All @@ -178,8 +66,8 @@ export function getObsFromEncounter(
return encounter.encounterProviders.map((p) => p.provider.name).join(' | ');
}

if (!obs && fallBackConcepts?.length) {
const concept = fallBackConcepts.find((c) => findObs(encounter, c) != null);
if (!obs && fallbackConcepts?.length >= 1) {
const concept = fallbackConcepts.find((c) => findObs(encounter, c) != null);
obs = findObs(encounter, concept);
}

Expand Down
6 changes: 3 additions & 3 deletions packages/esm-covid-app/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfigSchema, getSyncLifecycle } from '@openmrs/esm-framework';
import CovidVaccinations from './views/covid-vaccinations.component';
import CovidLabResults from './views/lab-results.component';
import CovidAssessment from './views/case-assessment.component';
import CovidVaccinations from './views/patient chart/covid-vaccinations.component';
import CovidLabResults from './views/patient chart/lab-results.component';
import CovidAssessment from './views/patient chart/case-assessment.component';
import {
covidAssessmentsDashboardMeta,
covidLabTestsDashboardMeta,
Expand Down
132 changes: 0 additions & 132 deletions packages/esm-covid-app/src/views/case-assessment.component.tsx

This file was deleted.

Loading

0 comments on commit b51e99e

Please sign in to comment.