From cd89502efb4e8f3c5dab680b720e7d7d86e0c1bb Mon Sep 17 00:00:00 2001 From: hadijahkyampeire Date: Wed, 17 Jul 2024 16:34:09 +0300 Subject: [PATCH] Add pTracker Id to the mamba report endpoint --- packages/esm-commons-lib/src/api.resource.ts | 2 +- .../src/utils/summary-card-config-builder.ts | 17 +++++++++++++---- .../tabs/recent-pregnancy-config.json | 8 ++++---- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/packages/esm-commons-lib/src/api.resource.ts b/packages/esm-commons-lib/src/api.resource.ts index 0cacbd838..0db1dfb6f 100644 --- a/packages/esm-commons-lib/src/api.resource.ts +++ b/packages/esm-commons-lib/src/api.resource.ts @@ -285,7 +285,7 @@ export function fetchEtlData( let endpoint = ''; switch (reportType) { case 'fetchMambaAncData': - endpoint = `/ws/rest/v1/mamba/report?report_id=${reportId}&person_uuid=${patientUuid}`; + endpoint = `/ws/rest/v1/mamba/report?report_id=${reportId}&ptracker_id=${pTrackerId}&person_uuid=${patientUuid}`; break; case 'MotherHivStatus': endpoint = `/ws/rest/v1/mamba/report?report_id=${reportId}&ptracker_id=${pTrackerId}&person_uuid=${patientUuid}`; diff --git a/packages/esm-commons-lib/src/utils/summary-card-config-builder.ts b/packages/esm-commons-lib/src/utils/summary-card-config-builder.ts index e72552c0a..57a49cbd8 100644 --- a/packages/esm-commons-lib/src/utils/summary-card-config-builder.ts +++ b/packages/esm-commons-lib/src/utils/summary-card-config-builder.ts @@ -16,23 +16,32 @@ export const getSummaryCardProps = (schemaConfig, config = null) => { return getConditionalConceptValue(encounter, column.conditionalConceptMappings, column.isDate); } + const pTrackerId = encounter?.patient?.identifiers.find( + (id) => id?.identifierType?.uuid === config?.identifiersTypes?.ptrackerIdentifierType, + )?.identifier; + if (column?.mambaEtlData === 'ancVisits') { - const response = fetchEtlData('fetchMambaAncData', 'no_of_anc_visits', encounter?.patient?.uuid); + const response = fetchEtlData('fetchMambaAncData', 'no_of_anc_visits', encounter?.patient?.uuid, pTrackerId); return response?.data; } if (column?.mambaEtlData === 'motherStatus') { - const response = fetchEtlData('fetchMambaAncData', 'mother_status', encounter?.patient?.uuid); + const response = fetchEtlData('fetchMambaAncData', 'mother_status', encounter?.patient?.uuid, pTrackerId); return response?.data; } if (column?.mambaEtlData === 'deliveryDate') { - const response = fetchEtlData('fetchMambaAncData', 'estimated_date_of_delivery', encounter?.patient?.uuid); + const response = fetchEtlData( + 'fetchMambaAncData', + 'estimated_date_of_delivery', + encounter?.patient?.uuid, + pTrackerId, + ); return response?.data; } if (column?.mambaEtlData === 'motherHivStatus') { - const response = fetchEtlData('fetchMambaAncData', 'mother_hiv_status', encounter?.patient?.uuid); + const response = fetchEtlData('fetchMambaAncData', 'mother_hiv_status', encounter?.patient?.uuid, pTrackerId); return response?.data; } diff --git a/packages/esm-ohri-pmtct-app/src/pmtct/patient-chart/mch-summary/tabs/recent-pregnancy-config.json b/packages/esm-ohri-pmtct-app/src/pmtct/patient-chart/mch-summary/tabs/recent-pregnancy-config.json index 8666e38fb..deabc9e74 100644 --- a/packages/esm-ohri-pmtct-app/src/pmtct/patient-chart/mch-summary/tabs/recent-pregnancy-config.json +++ b/packages/esm-ohri-pmtct-app/src/pmtct/patient-chart/mch-summary/tabs/recent-pregnancy-config.json @@ -5,20 +5,20 @@ { "id": "motherHIVStatus", "title": "Mother HIV Status", - "encounterTypes": [], + "encounterTypes": ["antenatalEncounterType", "laborAndDeliveryEncounterType", "motherPostnatalEncounterType"], "mambaEtlData": "motherHivStatus" }, { "id": "expectedDeliveryDate", "title": "Expected Delivery Date", - "encounterTypes": [], + "encounterTypes": ["antenatalEncounterType", "laborAndDeliveryEncounterType", "motherPostnatalEncounterType"], "mambaEtlData": "deliveryDate" }, { "id": "motherStatus", "title": "Mother Status", - "encounterTypes": [], + "encounterTypes": ["antenatalEncounterType", "laborAndDeliveryEncounterType", "motherPostnatalEncounterType"], "mambaEtlData": "motherStatus" } ] -} \ No newline at end of file +}