Skip to content

Commit

Permalink
Merge pull request #1610 from Herobiam/update-on-OHRI-1687
Browse files Browse the repository at this point in the history
moved final outcome from pregnacy outcome to family, fixed the issue …
  • Loading branch information
ODORA0 authored Aug 10, 2023
2 parents 5132293 + 5d92eaa commit 90a03de
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ interface pregnancyOutcomeProps {
pTrackerId: string;
dateOfBirth: string;
infantStatus: string;
finalOutcome: string;
}
export interface familyItemProps {
id: string;
Expand All @@ -60,6 +59,7 @@ export interface familyItemProps {
relationship: string;
dateOfBirth: string;
hivStatus: string;
finalOutcome: string;
}
const CurrentPregnancy: React.FC<PatientChartProps> = ({ patientUuid }) => {
const { t } = useTranslation();
Expand All @@ -72,7 +72,7 @@ const CurrentPregnancy: React.FC<PatientChartProps> = ({ patientUuid }) => {
const [relatives, setRelatives] = useState([]);
const [relativeToIdentifierMap, setRelativeToIdentifierMap] = useState([]);
const [pregnancyOutcomes, setPregnancyOutcomes] = useState([]);
const [infantOutcomes, setInfantOutcomes] = useState({childUuid: '', finalOutcome: ''});
const [infantOutcomes, setInfantOutcomes] = useState([]);

const headersFamily = [
{
Expand All @@ -95,6 +95,10 @@ const CurrentPregnancy: React.FC<PatientChartProps> = ({ patientUuid }) => {
header: t('hivStatus', 'HIV Status'),
key: 'hivStatus',
},
{
header: t('finalOutcome', 'Final Outcome'),
key: 'finalOutcome',
},
];
const headersPregnancyOutcome = [
{
Expand All @@ -109,10 +113,7 @@ const CurrentPregnancy: React.FC<PatientChartProps> = ({ patientUuid }) => {
header: t('infantStatus', 'Infant Status at Birth'),
key: 'infantStatus',
},
{
header: t('finalOutcome', 'Final Outcome'),
key: 'finalOutcome',
},

];
useEffect(() => {
getParentCurrentLabourAndDeliveryEncounter();
Expand All @@ -136,7 +137,7 @@ const CurrentPregnancy: React.FC<PatientChartProps> = ({ patientUuid }) => {
patientUuid,
labourAndDeliveryEncounterType,
);
if (currentPregnancyLabourAndDeliveryEncounter.encounterDatetime > currentPregnancyANCEncounter.encounterDatetime) {
if (currentPregnancyLabourAndDeliveryEncounter?.encounterDatetime > currentPregnancyANCEncounter?.encounterDatetime) {
setPregnancyOutcomes(
currentPregnancyLabourAndDeliveryEncounter.obs.filter(
(obs) => obs.concept.uuid === infantDeliveryGroupingConcept,
Expand All @@ -152,13 +153,16 @@ const CurrentPregnancy: React.FC<PatientChartProps> = ({ patientUuid }) => {
getInfantOutcome();
}, [relatives]);


const getInfantOutcome = async () => {
relatives.forEach(async (relative) => {
const finalOutcome = await fetchChildLatestFinalOutcome(relative.personB.uuid, outcomeStatus, infantPostnatalEncounterType);
return setInfantOutcomes({finalOutcome: finalOutcome, childUuid: relative.personB.uuid});
});

const getInfantOutcome = () => {
const infantOutcomes = relatives.map(async (relative) =>{
const finalOutcome = await fetchChildLatestFinalOutcome(relative.personB.uuid, outcomeStatus, infantPostnatalEncounterType);
return {finalOutcome: finalOutcome, childUuid: relative.personB.uuid};
});

Promise.all(infantOutcomes).then((values) => {
setInfantOutcomes(values.map((value)=>({finalOutcome: value.finalOutcome, childUuid: value.childUuid})));
});
}


Expand Down Expand Up @@ -193,13 +197,14 @@ const CurrentPregnancy: React.FC<PatientChartProps> = ({ patientUuid }) => {
relationship: relative.relationshipType.displayBIsToA,
dateOfBirth: moment(relative.personB.birthdate).format('DD-MMM-YYYY'),
hivStatus: '',
finalOutcome: infantOutcomes.find((outcome) => outcome.childUuid === relative.personB.uuid)?.finalOutcome ?? '--',
};
items.push(relativeObject);
}
});

return items;
}, [relatives, relativeToIdentifierMap]);
}, [relatives, relativeToIdentifierMap, infantOutcomes]);

const childrenDetails: pregnancyOutcomeProps[] = useMemo(() => {
let items = [];
Expand All @@ -214,7 +219,6 @@ const CurrentPregnancy: React.FC<PatientChartProps> = ({ patientUuid }) => {
infantStatus:
infantStatusObs.value?.names?.find((conceptName) => conceptName.conceptNameType === 'SHORT')?.name ||
infantStatusObs.value.name.name,
finalOutcome: infantOutcomes.childUuid === child.uuid ? infantOutcomes.finalOutcome : '--',
};
items.push(childObject);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ const HivExposedInfant: React.FC<{
relationship: relative.relationshipType.displayAIsToB,
dateOfBirth: moment(relative.personA.birthdate).format('DD-MMM-YYYY'),
hivStatus: '',
finalOutcome: '',
};
items.push(relativeObject);
});
Expand Down

0 comments on commit 90a03de

Please sign in to comment.