Skip to content

Commit

Permalink
Merge branch 'UCSF-IGHS:dev' into OHRI-2053-CaCx-update-metadata-to-u…
Browse files Browse the repository at this point in the history
…se-config-instead-of-constants
  • Loading branch information
arodidev authored Jan 10, 2024
2 parents c691d0d + d610f9e commit 61a2fd2
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 165 deletions.
33 changes: 16 additions & 17 deletions packages/esm-covid-app/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { defineConfigSchema, getAsyncLifecycle, getSyncLifecycle } from '@openmrs/esm-framework';
import CovidVaccinations from './views/covid-vaccinations.encounter-list';
import CovidLabResults from './views/lab-results.encounter-list';
import CovidAssessment from './views/case-assessment.encounter-lists';
import CovidHomePatientTabs from './views/dashboard/patient-list-tabs/covid-patient-list-tabs.component';
import CovidSummaryTiles from './views/dashboard/summary-tiles/covid-summary-tiles.component';
import {
covidAssessmentsDashboardMeta,
covidLabTestsDashboardMeta,
Expand Down Expand Up @@ -48,29 +53,23 @@ export const covidDashboardHeader = getSyncLifecycle(OHRIWelcomeSection, {
featureName: 'covid-home-header',
moduleName,
});
export const covidDashboardTiles = getAsyncLifecycle(
() => import('./views/dashboard/summary-tiles/covid-summary-tiles.component'),
{
featureName: 'covid-home-tiles',
moduleName,
},
);
export const covidDashboardTabs = getAsyncLifecycle(
() => import('./views/dashboard/patient-list-tabs/covid-patient-list-tabs.component'),
{
featureName: 'covid-home-tabs',
moduleName,
},
);
export const covidAssessmentsDashboard = getAsyncLifecycle(() => import('./views/case-assessment.encounter-lists'), {
export const covidDashboardTiles = getSyncLifecycle(CovidSummaryTiles, {
featureName: 'covid-home-tiles',
moduleName,
});
export const covidDashboardTabs = getSyncLifecycle(CovidHomePatientTabs, {
featureName: 'covid-home-tabs',
moduleName,
});
export const covidAssessmentsDashboard = getSyncLifecycle(CovidAssessment, {
featureName: 'covid-assessment',
moduleName,
});
export const covidLabResultsDashboard = getAsyncLifecycle(() => import('./views/lab-results.encounter-list'), {
export const covidLabResultsDashboard = getSyncLifecycle(CovidLabResults, {
featureName: 'covid-lab-results',
moduleName,
});
export const covidVaccinationsDashboard = getAsyncLifecycle(() => import('./views/covid-vaccinations.encounter-list'), {
export const covidVaccinationsDashboard = getSyncLifecycle(CovidVaccinations, {
featureName: 'covid-vaccinations',
moduleName,
});
Expand Down
66 changes: 1 addition & 65 deletions packages/esm-ohri-pmtct-app/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,68 +118,4 @@ export function fetchChildLatestFinalOutcome(childUuid: string, conceptUuid: str
// Get family relationships from patient uuid
export async function getFamilyRelationships(patientUuid: string) {
return await fetchPatientRelationships(patientUuid);
}

// Get count of pregnant women attending first ANC
export async function getTotalPregnantWomen() {
try {
const response = await openmrsFetch('ws/rest/v1/mamba/report?report_id=total_pregnant_women');
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_pregnant_women') {
return parseInt(item.value);
}
}
}
return 0;
} catch (error) {
console.error('Error fetching data: ', 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
@@ -1,53 +1,58 @@
import React, { useEffect, useState } from 'react';
import React, { useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { OHRIProgrammeSummaryTiles } from '@ohri/openmrs-esm-ohri-commons-lib';
import { getTotalDeliveries, getHivExposedInfants, getTotalPregnantWomen } from '../../api/api';
import { OHRIProgrammeSummaryTiles, fetchMambaReportData } from '@ohri/openmrs-esm-ohri-commons-lib';

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);
const [activeClientsCount, setActiveClientsCount] = useState(null);
const [totalPregnantWomen, setTotalPregnantWomen] = useState(null);
const [totalDeliveries, setTotalDeliveries] = useState(null);
const [hivExposedInfants, setHivExposedInfants] = useState(null);

useEffect(() => {
getTotalPregnantWomen().then((count) => {
setTotalPregnantWomen(count);
});
}, []);
const fetchData = async () => {
try {
const [totalPregnantWomenCount, totalDeliveriesCount, hivExposedInfantsCount] = await Promise.all([
fetchMambaReportData('total_pregnant_women'),
fetchMambaReportData('total_deliveries'),
fetchMambaReportData('total_hiv_exposed_infants'),
]);

useEffect(() => {
getTotalDeliveries().then((count) => {
setTotalDeliveries(count);
});
}, []);
setTotalPregnantWomen(totalPregnantWomenCount);
setTotalDeliveries(totalDeliveriesCount);
setHivExposedInfants(hivExposedInfantsCount);
} catch (error) {
console.error('Error fetching data:', error);
throw new Error('Error fetching data. Please try again.');
}
};

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

const tiles = [
{
title: t('anc', 'ANC'),
linkAddress: '#',
subTitle: t('pregnantWomenAttendingFirstANC', '# Pregnant women attending first ANC'),
value: totalPregnantWomen,
},
{
title: t('labourDelivery', 'Labour & Delivery'),
linkAddress: '#',
subTitle: t('totalDeliveries', '# Total deliveries'),
value: totalDeliveries,
},
{
title: t('children', 'Children'),
linkAddress: '#',
subTitle: t('hivExposedChildrenEnrolledInFollowUpCare', '# HIV Exposed children enrolled in follow up care'),
value: hivExposedInfants,
},
];
const tiles = useMemo(
() => [
{
title: t('anc', 'ANC'),
linkAddress: '#',
subTitle: t('pregnantWomenAttendingFirstANC', '# Pregnant women attending first ANC'),
value: totalPregnantWomen,
},
{
title: t('labourDelivery', 'Labour & Delivery'),
linkAddress: '#',
subTitle: t('totalDeliveries', '# Total deliveries'),
value: totalDeliveries,
},
{
title: t('children', 'Children'),
linkAddress: '#',
subTitle: t('hivExposedChildrenEnrolledInFollowUpCare', '# HIV Exposed children enrolled in follow up care'),
value: hivExposedInfants,
},
],
[t, totalPregnantWomen, totalDeliveries, hivExposedInfants],
);
return <OHRIProgrammeSummaryTiles tiles={tiles} />;
}

Expand Down
74 changes: 31 additions & 43 deletions packages/esm-tb-app/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfigSchema, getAsyncLifecycle, getSyncLifecycle } from '@openmrs/esm-framework';
import { defineConfigSchema, getSyncLifecycle } from '@openmrs/esm-framework';
import { createOHRIDashboardLink, OHRIHome, OHRIWelcomeSection } from '@ohri/openmrs-esm-ohri-commons-lib';
import { createDashboardGroup, createDashboardLink } from '@openmrs/esm-patient-common-lib';
import {
Expand All @@ -11,6 +11,12 @@ import {
tbCasesDashboardMeta,
} from './dashboard.meta';
import { configSchema } from './config-schema';
import TBSummaryOverviewList from './views/patient-summary/tb-patient-summary.component';
import ProgramManagementSummary from './views/program-management/maternal-health.component';
import TbTreatmentFollowUpList from './views/treatment-and-follow-up/tb-treatment-follow-up.component';
import TbContactTracingList from './views/tb-contact-listing/tb-contact-list.component';
import TbSummaryTiles from './views/dashboard/summary-tiles/tb-summary-tiles.component';
import TbHomePatientTabs from './views/dashboard/patient-list-tabs/tb-patient-list-tabs.component';

export const importTranslation = require.context('../translations', false, /.json$/, 'lazy');

Expand All @@ -33,68 +39,50 @@ export const tbPatientSummaryDashboardLink = getSyncLifecycle(
createDashboardLink({ ...tbPatientSummaryDashboardMeta, moduleName }),
options,
);
export const tbPatientSummaryList = getAsyncLifecycle(
() => import('./views/patient-summary/tb-patient-summary.component'),
{
featureName: 'hts-service-summary-list',
moduleName,
},
);
export const tbPatientSummaryList = getSyncLifecycle(TBSummaryOverviewList, {
featureName: 'hts-service-summary-list',
moduleName,
});

export const tbProgramManagementDashboardLink = getSyncLifecycle(
createDashboardLink({ ...tbProgramManagementDashboardMeta, moduleName }),
options,
);
export const tbProgramManagementDashboard = getAsyncLifecycle(
() => import('./views/program-management/maternal-health.component'),
{
featureName: 'tb-program-management-summary',
moduleName,
},
);
export const tbProgramManagementDashboard = getSyncLifecycle(ProgramManagementSummary, {
featureName: 'tb-program-management-summary',
moduleName,
});

export const tbTreatmentFollowUpDashboardLink = getSyncLifecycle(
createDashboardLink({ ...tbTreatmentFollowUpDashboardMeta, moduleName }),
options,
);
export const tbTreatmentFollowUpDashboard = getAsyncLifecycle(
() => import('./views/treatment-and-follow-up/tb-treatment-follow-up.component'),
{
featureName: 'tb-treatment-follow-up-summary',
moduleName,
},
);
export const tbTreatmentFollowUpDashboard = getSyncLifecycle(TbTreatmentFollowUpList, {
featureName: 'tb-treatment-follow-up-summary',
moduleName,
});

export const tbContactListingDashboardLink = getSyncLifecycle(
createDashboardLink({ ...tbContactListingDashboardMeta, moduleName }),
options,
);
export const tbContactListingDashboard = getAsyncLifecycle(
() => import('./views/tb-contact-listing/tb-contact-list.component'),
{
featureName: 'tb-contact-listing-summary',
moduleName,
},
);
export const tbContactListingDashboard = getSyncLifecycle(TbContactTracingList, {
featureName: 'tb-contact-listing-summary',
moduleName,
});
export const tbDashboardHeader = getSyncLifecycle(OHRIWelcomeSection, {
featureName: 'tb-home-header',
moduleName,
});

export const tbDashboardTiles = getAsyncLifecycle(
() => import('./views/dashboard/summary-tiles/tb-summary-tiles.component'),
{
featureName: 'tb-home-tiles',
moduleName,
},
);
export const tbDashboardTabs = getAsyncLifecycle(
() => import('./views/dashboard/patient-list-tabs/tb-patient-list-tabs.component'),
{
featureName: 'tb-home-tabs',
moduleName,
},
);
export const tbDashboardTiles = getSyncLifecycle(TbSummaryTiles, {
featureName: 'tb-home-tiles',
moduleName,
});
export const tbDashboardTabs = getSyncLifecycle(TbHomePatientTabs, {
featureName: 'tb-home-tabs',
moduleName,
});

// OHRI HOME
export const tbClinicalViewDashboardLink = getSyncLifecycle(
Expand Down

0 comments on commit 61a2fd2

Please sign in to comment.