Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PMTCT MNCH Summary Reports #1627

Merged
merged 4 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 47 additions & 5 deletions packages/esm-ohri-pmtct-app/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,58 @@ export async function getTotalPregnantWomen() {

if (data && data.results && data.results.length > 0) {
const record = data.results[0].record;

for (const item of record) {
if (item.column === 'total_pregnant_women') {
return parseInt(item.value); // Convert value to an integer
return parseInt(item.value);
}
}
}
return 0; // Return 0 if the "total_pregnant_women" value is not present/empty
return 0;
} catch (error) {
console.error('Error fetching data: ', error);
return null; // Return null in case of an error
return null;
}
}
// Count the number of unique women who delivered from the start of the fiscal year up to the current date
export async function getTotalDeliveries() {
try {
const response = await openmrsFetch('ws/rest/v1/mamba/report?report_id=total_deliveries');
const data = await response.json();

if (data && data.results && data.results.length > 0) {
const record = data.results[0].record;

for (const item of record) {
if (item.column === 'total_deliveries') {
return parseInt(item.value);
}
}
}
return 0;
} catch (error) {
console.error('Error fetching data: ', error);
return null;
}
}
}
// Total number of HIV Exposed Children Enrolled in Follow Up Care

export async function getHivExposedInfants() {
try {
const response = await openmrsFetch('ws/rest/v1/mamba/report?report_id=hiv_exposed_infants');
const data = await response.json();

if (data && data.results && data.results.length > 0) {
const record = data.results[0].record;
for (const item of record) {
if (item.column === 'total_hiv_exposed_infants') {
return parseInt(item.value);
}
}
}
return 0;
} catch (error) {
console.error('Error fetching data: ', error);
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,34 @@ import { useTranslation } from 'react-i18next';
import { OHRIProgrammeSummaryTiles, getReportingCohort } from '@ohri/openmrs-esm-ohri-commons-lib';
import { clientsEnrolledToCare } from '../../constants';
import { getTotalPregnantWomen } from '../../api/api';
import { getTotalDeliveries } from '../../api/api';
import { getHivExposedInfants } from '../../api/api';

function MaternalChildSummaryTiles({ launchWorkSpace }) {
const { t } = useTranslation();
const [activeClientsCount, setActiveClientsCount] = useState(0);
const [totalPregnantWomen, setTotalPregnantWomen] = useState(0);
const [totalDeliveries, setTotalDeliveries] = useState(0);
const [hivExposedInfants, setHivExposedInfants] = useState(0);

// useEffect(() => {
// getReportingCohort(clientsEnrolledToCare).then((data) => {
// setActiveClientsCount(data.members.length);
// });
// }, []);
useEffect(() => {
useEffect(() => {
getTotalPregnantWomen().then(count => {
setTotalPregnantWomen(count);
});
}, []);

useEffect(() => {
getTotalDeliveries().then(count => {
setTotalDeliveries(count);
});
}, []);

useEffect(() => {
getHivExposedInfants().then(count => {
setHivExposedInfants(count);
});
}, []);

const tiles = [
{
title: t('anc', 'ANC'),
Expand All @@ -31,13 +42,13 @@ function MaternalChildSummaryTiles({ launchWorkSpace }) {
title: t('labourDelivery', 'Labour & Delivery'),
linkAddress: '#',
subTitle: t('totalDeliveries', '# Total deliveries'),
value: 'N/A'
value: totalDeliveries,
},
{
title: t('children', 'Children'),
linkAddress: '#',
subTitle: t('hivExposedChildrenEnrolledInFollowUpCare', '# HIV Exposed children enrolled in follow up care'),
value: 'N/A',
value: hivExposedInfants,
},
];
return <OHRIProgrammeSummaryTiles tiles={tiles} />;
Expand Down