Skip to content

Commit

Permalink
Merge pull request #1858 from UCSF-IGHS/OHRI-2222
Browse files Browse the repository at this point in the history
(refactor) OHRI-2222 Implement the Maternal and Child Care package schema workflow
  • Loading branch information
hadijahkyampeire authored Jun 10, 2024
2 parents 92ffac5 + 96f92b7 commit 09ee0ea
Show file tree
Hide file tree
Showing 19 changed files with 366 additions and 478 deletions.
2 changes: 1 addition & 1 deletion frontend/ohri-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"src": "ohri_logo_light.svg"
}
},
"@ohri/openmrs-esm-ohri-pmtct": {
"@ohri/openmrs-esm-ohri-pmtct-app": {
"identifiers": {
"preferredIdentifierSource": "8549f706-7e85-4c1d-9424-217d50a2988b"
},
Expand Down
2 changes: 1 addition & 1 deletion frontend/spa-build-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@ohri/openmrs-esm-ohri-hiv-care-treatment-app": "next",
"@ohri/openmrs-esm-ohri-hiv-prevention-app": "next",
"@ohri/openmrs-esm-ohri-covid-app": "next",
"@ohri/openmrs-esm-ohri-pmtct": "next",
"@ohri/openmrs-esm-ohri-pmtct-app": "next",
"@ohri/openmrs-esm-ohri-tb-app": "next",
"@ohri/openmrs-esm-ohri-cervical-cancer-app": "next",
"@ohri/openmrs-esm-ohri-form-render-app": "next",
Expand Down
16 changes: 15 additions & 1 deletion packages/esm-commons-lib/src/utils/encounter-list-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import dayjs from 'dayjs';
import { formatDate, parseDate } from '@openmrs/esm-framework';
import { fetchPatientRelationships } from '../api/api';

export function getEncounterValues(encounter, param: string, isDate?: Boolean) {
if (isDate) return dayjs(encounter[param]).format('DD-MMM-YYYY');
Expand Down Expand Up @@ -55,6 +56,15 @@ export function getMultipleObsFromEncounter(encounter, obsConcepts: Array<string
return observations.length ? observations.join(', ') : '--';
}

async function fetchMotherName(patientUuid) {
let motherName = '--';
const response = await fetchPatientRelationships(patientUuid);
if (response.length) {
motherName = response[0].personA.display;
}
return motherName;
}

export function getObsFromEncounter(
encounter,
obsConcept,
Expand Down Expand Up @@ -82,6 +92,10 @@ export function getObsFromEncounter(
return encounter.encounterProviders.map((p) => p.provider.name).join(' | ');
}

if (type === 'mothersName') {
return fetchMotherName(encounter.patient.uuid);
}

if (secondaryConcept && typeof obs.value === 'object' && obs.value.names) {
const primaryValue =
obs.value.names.find((conceptName) => conceptName.conceptNameType === 'SHORT')?.name || obs.value.name.name;
Expand All @@ -91,7 +105,7 @@ export function getObsFromEncounter(
}
}

if (!obs && fallbackConcepts?.length >= 1) {
if (!obs && fallbackConcepts?.length) {
const concept = fallbackConcepts.find((c) => findObs(encounter, c) != null);
obs = findObs(encounter, concept);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-ohri-pmtct-app/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

## [1.0.9-alpha.1](https://github.com/UCSF-IGHS/openmrs-esm-ohri/compare/v1.0.9-alpha.0...v1.0.9-alpha.1) (2023-06-18)

**Note:** Version bump only for package @ohri/openmrs-esm-ohri-pmtct
**Note:** Version bump only for package @ohri/openmrs-esm-ohri-pmtct-app
2 changes: 1 addition & 1 deletion packages/esm-ohri-pmtct-app/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@ohri/openmrs-esm-ohri-pmtct",
"name": "@ohri/openmrs-esm-ohri-pmtct-app",
"version": "2.3.1",
"description": "PMTCT microfrontend for OpenMRS HIV Reference Implementation (OHRI)",
"browser": "dist/ohri-pmtct-app.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-ohri-pmtct-app/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import useSWR from 'swr';
import { fetchPatientRelationships } from '@ohri/openmrs-esm-ohri-commons-lib';

const BASE_WS_API_URL = '/ws/rest/v1/';
const config = await getConfig('@ohri/openmrs-esm-ohri-pmtct');
const config = await getConfig('@ohri/openmrs-esm-ohri-pmtct-app');

export function generateIdentifier(source: string) {
return openmrsFetch(`/ws/rest/v1/idgen/identifiersource/${source}/identifier`, {
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-ohri-pmtct-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { createDashboardLink } from '@openmrs/esm-patient-common-lib';

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

export const moduleName = '@ohri/openmrs-esm-ohri-pmtct';
export const moduleName = '@ohri/openmrs-esm-ohri-pmtct-app';

require('./root.scss');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { PatientIdentifier } from '../api/types';

const ArtSubmissionAction: PostSubmissionAction = {
applyAction: async function ({ patient, encounters, sessionMode }) {
const config = await getConfig('@ohri/openmrs-esm-ohri-pmtct');
const config = await getConfig('@ohri/openmrs-esm-ohri-pmtct-app');
const encounter = encounters[0];
const encounterLocation = encounter.location['uuid'];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const PTrackerSubmissionAction: PostSubmissionAction = {
};

export async function updatePatientPtracker(encounter, encounterLocation, patientUuid) {
const config = await getConfig('@ohri/openmrs-esm-ohri-pmtct');
const config = await getConfig('@ohri/openmrs-esm-ohri-pmtct-app');
const inComingPTrackerID = encounter.obs.find(
(observation) => observation.concept.uuid === config.obsConcepts.pTrackerIdConcept,
)?.value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const MotherToChildLinkageSubmissionAction: PostSubmissionAction = {
};

async function getPreferredIdentifierSource() {
const config = await getConfig('@ohri/openmrs-esm-ohri-pmtct');
const config = await getConfig('@ohri/openmrs-esm-ohri-pmtct-app');
return config.identifiers.preferredIdentifierSource;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"menuId": "childHealth",
"tabDefinitions": [
{
"tabName": "Infant Postnatal Visit",
"headerTitle": "Infant Postnatal Visit",
"displayText": "Infant Postnatal Visit",
"encounterType": "af1f1b24-d2e8-4282-b308-0bf79b365584",
"columns": [
{
"id": "pTrackerId",
"title": "PTracker Id",
"concept": "6c45421e-2566-47cb-bbb3-07586fffbfe2"
},
{
"id": "mothersName",
"title": "Mothers Name",
"type": "mothersName"
},
{
"id": "artProphylaxisStatus",
"title": "ART Prophylaxis Status",
"concept": "1148AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
},
{
"id": "linkedToArt",
"title": "Linked to ART",
"concept": "a40d8bc4-56b8-4f28-a1dd-412da5cf20ed"
},
{
"id": "breastfeedingStatus",
"title": "Breastfeeding status",
"concept": "1151AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
},
{
"id": "outcomeStatus",
"title": "Outcome Status",
"concept": "160433AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
},
{
"id": "nextVisitDate",
"isDate": true,
"title": "Next visit date",
"concept": "5096AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
},
{
"id": "actions",
"title": "Actions",
"actionOptions": [
{
"formName": "Antenatal Form",
"package": "pmtct",
"label": "View Details",
"mode": "view"
},
{
"formName": "Antenatal Form",
"package": "pmtct",
"label": "Edit Form",
"mode": "edit"
}
]
}
],
"launchOptions": {
"displayText": "Add",
"moduleName": "@ohri/openmrs-esm-ohri-pmtct-app"
},
"formList": [
{
"name": "Infant - Postanal Form",
"uuid": "5022c5d7-ea45-47ce-bd65-1ba1d8ad2467"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,41 @@
import React from 'react';
import { Tabs, Tab, TabList, TabPanels, TabPanel } from '@carbon/react';
import styles from '../common.scss';
import { useTranslation } from 'react-i18next';
import InfantPostnatalList from './tabs/infant-postnatal-care.component';
import { EncounterList, getMenuItemTabConfiguration } from '@ohri/openmrs-esm-ohri-commons-lib';
import childHealthTabConfigSchema from './child-health-config.json';

interface OverviewListProps {
patientUuid: string;
}

const ChildHealthList: React.FC<OverviewListProps> = ({ patientUuid }) => {
const { t } = useTranslation();
const ChildHealthSummary: React.FC<OverviewListProps> = ({ patientUuid }) => {
const tabs = getMenuItemTabConfiguration(childHealthTabConfigSchema);
return (
<div className={styles.tabContainer}>
<Tabs>
<TabList contained>
<Tab>{t('infantPostnatalVisit', 'Infant Postnatal Visit')}</Tab>
{tabs.map((tab) => (
<Tab key={tab.name}>{tab.name}</Tab>
))}
</TabList>
<TabPanels>
<TabPanel>
<InfantPostnatalList patientUuid={patientUuid} />
</TabPanel>
{tabs.map((tab) => (
<TabPanel>
<EncounterList
patientUuid={patientUuid}
formList={tab.formList}
columns={tab.columns}
encounterType={tab.encounterType}
launchOptions={tab.launchOptions}
headerTitle={tab.headerTitle}
description={tab.description}
/>
</TabPanel>
))}
</TabPanels>
</Tabs>
</div>
);
};

export default ChildHealthList;
export default ChildHealthSummary;

This file was deleted.

Loading

0 comments on commit 09ee0ea

Please sign in to comment.