From 36f8ed9606c03194349093cdb977eb8114394142 Mon Sep 17 00:00:00 2001 From: kajambiya Date: Thu, 9 Nov 2023 08:58:57 +0300 Subject: [PATCH 1/2] Add functionality to fetch multiple observations from an encounter --- .../esm-cervical-cancer-app/src/constants.ts | 3 +++ .../Tabs/cacx-treatment.component.tsx | 21 +++++++++++++++---- .../src/utils/encounter-list-utils.ts | 12 +++++++++++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/packages/esm-cervical-cancer-app/src/constants.ts b/packages/esm-cervical-cancer-app/src/constants.ts index 5e22d09f7..440626deb 100644 --- a/packages/esm-cervical-cancer-app/src/constants.ts +++ b/packages/esm-cervical-cancer-app/src/constants.ts @@ -10,3 +10,6 @@ export const cacxEncounterDateConcept = '163137AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'; export const screeningMethodConcept = '53ff5cd0-0f37-4190-87b1-9eb439a15e94'; export const cacxTreatmentConcept = '3a8bb4b4-7496-415d-a327-57ae3711d4eb'; export const colopsyResultsConcept = '9096a18e-c009-4f4c-b0ba-0605e0f16578'; +export const humanPapilomaVirusResultsConcept = '159859AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'; +export const papanicolaouSmearResultsConcept = '28bab50e-7ff7-4216-81be-3f7ad05c6547'; +export const VIAProcedureResultsConcept = 'cc647244-0826-4d8e-8c5a-d7a371267bf4'; diff --git a/packages/esm-cervical-cancer-app/src/views/cacx-visits/Tabs/cacx-treatment.component.tsx b/packages/esm-cervical-cancer-app/src/views/cacx-visits/Tabs/cacx-treatment.component.tsx index 9f2114912..65724357a 100644 --- a/packages/esm-cervical-cancer-app/src/views/cacx-visits/Tabs/cacx-treatment.component.tsx +++ b/packages/esm-cervical-cancer-app/src/views/cacx-visits/Tabs/cacx-treatment.component.tsx @@ -1,12 +1,20 @@ import React, { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; -import { EncounterList, EncounterListColumn, getObsFromEncounter } from '@ohri/openmrs-esm-ohri-commons-lib'; +import { + EncounterList, + EncounterListColumn, + getMultipleObsFromEncounter, + getObsFromEncounter, +} from '@ohri/openmrs-esm-ohri-commons-lib'; import { cacxEncounterDateConcept, screeningMethodConcept, cacxTreatmentConcept, cacxTreatmentEncounterType_UUID, colopsyResultsConcept, + humanPapilomaVirusResultsConcept, + papanicolaouSmearResultsConcept, + VIAProcedureResultsConcept, } from '../../../constants'; import { moduleName } from '../../../index'; @@ -34,10 +42,15 @@ const CacxTreatmentList: React.FC = ({ patientUuid }) => }, }, { - key: 'colopsyResult', - header: t('colopsyResult', 'Screening Results'), + key: 'screeningResult', + header: t('screeningResult', 'Screening Results'), getValue: (encounter) => { - return getObsFromEncounter(encounter, colopsyResultsConcept); + return getMultipleObsFromEncounter(encounter, [ + colopsyResultsConcept, + humanPapilomaVirusResultsConcept, + papanicolaouSmearResultsConcept, + VIAProcedureResultsConcept, + ]); }, }, { diff --git a/packages/esm-commons-lib/src/utils/encounter-list-utils.ts b/packages/esm-commons-lib/src/utils/encounter-list-utils.ts index 1ca51bfe0..100364e79 100644 --- a/packages/esm-commons-lib/src/utils/encounter-list-utils.ts +++ b/packages/esm-commons-lib/src/utils/encounter-list-utils.ts @@ -29,6 +29,18 @@ export function getObsFromEncounters(encounters, obsConcept) { return getObsFromEncounter(filteredEnc, obsConcept); } +export function getMultipleObsFromEncounter(encounter, obsConcepts: Array){ + let observations = []; + obsConcepts.map(concept => { + const obs = getObsFromEncounter(encounter, concept); + if(obs !== '--'){ + observations.push(obs); + } + }) + + return observations.length? observations.join(','): '--' +} + export function getObsFromEncounter(encounter, obsConcept, isDate?: Boolean, isTrueFalseConcept?: Boolean) { const obs = findObs(encounter, obsConcept); From eb74a69828af2151e87a877003fd34a5bcfe79e3 Mon Sep 17 00:00:00 2001 From: kajambiya Date: Thu, 9 Nov 2023 11:47:52 +0300 Subject: [PATCH 2/2] add space after comma --- packages/esm-commons-lib/src/utils/encounter-list-utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/esm-commons-lib/src/utils/encounter-list-utils.ts b/packages/esm-commons-lib/src/utils/encounter-list-utils.ts index 100364e79..9c57bc730 100644 --- a/packages/esm-commons-lib/src/utils/encounter-list-utils.ts +++ b/packages/esm-commons-lib/src/utils/encounter-list-utils.ts @@ -38,7 +38,7 @@ export function getMultipleObsFromEncounter(encounter, obsConcepts: Array