Skip to content

Commit

Permalink
OHRI-2040: Populate MNCH Summary data (#1840)
Browse files Browse the repository at this point in the history
* Populate MNCH Summary data

* Enure we return the latest Mother HIV status
  • Loading branch information
lucyjemutai authored May 15, 2024
1 parent e4b284e commit 65f2852
Showing 1 changed file with 44 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
fetchPatientLastEncounter,
SummaryCardColumn,
SummaryCard,
fetchMambaReportData,
} from '@ohri/openmrs-esm-ohri-commons-lib';
import dayjs from 'dayjs';
import { moduleName } from '../../..';
Expand Down Expand Up @@ -47,6 +48,22 @@ const CurrentPregnancy: React.FC<PatientChartProps> = ({ patientUuid }) => {
const [pregnancyOutcomes, setPregnancyOutcomes] = useState([]);
const [infantOutcomes, setInfantOutcomes] = useState([]);
const { formNames, encounterTypes, obsConcepts, formUuids } = useConfig();
const [totalAncCount, setTotalAncCount] = useState(null);

useEffect(() => {
const fetchData = async () => {
try {
const [totalAncCount] = await Promise.all([fetchMambaReportData('no_of_anc_visits')]);

setTotalAncCount(totalAncCount);
} catch (error) {
console.error('Error fetching data:', error);
throw new Error('Error fetching data. Please try again.');
}
};

fetchData();
}, []);

const headersFamily = [
{
Expand Down Expand Up @@ -220,12 +237,32 @@ const CurrentPregnancy: React.FC<PatientChartProps> = ({ patientUuid }) => {
{
key: 'motherHIVStatus',
header: t('motherHIVStatus', 'Mother HIV Status'),
encounterTypes: [encounterTypes.labourAndDelivery],
getObsValue: async ([encounter]) => {
const currentPTrackerId = getObsFromEncounter(encounter, obsConcepts.pTrackerIdConcept);
return '--';
encounterTypes: [encounterTypes.motherPostnatal, encounterTypes.labourAndDelivery, encounterTypes.antenatal],
getObsValue: (encounters) => {
const pncArtData = {
artInitiation: getObsFromEncounter(encounters[0], obsConcepts.artInitiationConcept),
motherHIVStatus: getObsFromEncounter(encounters[0], obsConcepts.hivTestResultConcept),
pTrackerId: getObsFromEncounter(encounters[0], obsConcepts.pTrackerIdConcept),
};
const lndArtData = {
artInitiation: getObsFromEncounter(encounters[1], obsConcepts.artInitiationConcept),
motherHIVStatus: getObsFromEncounter(encounters[1], obsConcepts.hivTestResultConcept),
pTrackerId: getObsFromEncounter(encounters[1], obsConcepts.pTrackerIdConcept),
};
const ancArtData = {
artInitiation: getObsFromEncounter(encounters[2], obsConcepts.artInitiationConcept),
motherHIVStatus: getObsFromEncounter(encounters[2], obsConcepts.hivTestResultConcept),
pTrackerId: getObsFromEncounter(encounters[2], obsConcepts.pTrackerIdConcept),
};
const latestArtData = getLatestArtDetails(pncArtData, lndArtData, ancArtData);
if (!latestArtData['motherHIVStatus']) {
return '--';
}

return latestArtData['motherHIVStatus'];
},
},

{
key: 'expectedDeliveryDate',
header: t('expectedDeliveryDate', 'Expected Delivery Date'),
Expand All @@ -246,7 +283,7 @@ const CurrentPregnancy: React.FC<PatientChartProps> = ({ patientUuid }) => {
key: 'motherStatus',
header: t('motherStatus', 'Mother Status'),
encounterTypes: [encounterTypes.labourAndDelivery],
getObsValue: (encounter) => {
getObsValue: async ([encounter]) => {
return getObsFromEncounter(encounter, obsConcepts.motherStatusConcept);
},
},
Expand Down Expand Up @@ -331,14 +368,11 @@ const CurrentPregnancy: React.FC<PatientChartProps> = ({ patientUuid }) => {
header: t('ancVisitsAttended', 'ANC visits attended'),
encounterTypes: [encounterTypes.antenatal],
getObsValue: async ([encounter]) => {
const currentPTrackerId = getObsFromEncounter(encounter, obsConcepts.pTrackerIdConcept);
// const totalVisits = await getAncVisitCount(currentPTrackerId, patientUuid);
// return totalVisits.rows.length ? totalVisits.rows[0].total : '0';
return '--';
return totalAncCount;
},
},
],
[],
[totalAncCount],
);

const columnsMotherPreviousVisit: EncounterListColumn[] = useMemo(
Expand Down

0 comments on commit 65f2852

Please sign in to comment.