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

moved final outcome from pregnacy outcome to family, fixed the issue … #1610

Merged
merged 1 commit into from
Aug 10, 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
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