-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(Refactor) Ensure that Infant status outcomes show for infants on the…
… infant banner (#1935) * code refactor and ensure that Infant status outcomes showing on infant banner * update test * make 'dead' outcome a string --------- Co-authored-by: Lucy Jemutai <[email protected]>
- Loading branch information
1 parent
5313b4f
commit b05947d
Showing
9 changed files
with
103 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
packages/esm-ohri-pmtct-app/src/pmtct/patient-chart/banner-tags/banner-tags.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { usePatientOutcome } from './useInfantFinalOutcome'; | ||
import { usePatientFamilyNames } from './usePatientFamilyNames'; | ||
import { PatientStatusBannerTag } from '@ohri/openmrs-esm-ohri-commons-lib'; | ||
|
||
interface MotherChildTagProps { | ||
patientUuid: string; | ||
} | ||
|
||
const MotherChildTag: React.FC<MotherChildTagProps> = ({ patientUuid }) => { | ||
const { t } = useTranslation(); | ||
|
||
const { patientOutcome } = usePatientOutcome(patientUuid); | ||
const { childrenNames, motherName, patientGender, isLoading, isError } = usePatientFamilyNames(patientUuid); | ||
|
||
if (isLoading) { | ||
return null; | ||
} | ||
|
||
if (isError) { | ||
console.error('Error fetching family information'); | ||
return null; | ||
} | ||
|
||
const outcomeColorMapping: { [key: string]: string } = { | ||
'Still in Care': 'green', | ||
'HIV negative infant discharged from PMTCT': 'green', | ||
'Lost to followup': 'red', | ||
'Dead': 'red', | ||
'Transferred out': 'red', | ||
'Transfer in': 'red', | ||
'Confirmed HIV positive': 'red', | ||
}; | ||
|
||
const outcomeTagColor = outcomeColorMapping[patientOutcome] || 'gray'; | ||
//Not to future self -- transfer in shouldnt be confirmed HIV positive | ||
const mappedOutcome = | ||
patientOutcome === 'Transfer in' ? t('confirmedHivPositive', 'Confirmed HIV Positive') : patientOutcome; | ||
|
||
return ( | ||
<PatientStatusBannerTag | ||
patientUuid={patientUuid} | ||
outcomeTagColor={outcomeTagColor} | ||
mappedOutcome={mappedOutcome} | ||
motherName={motherName} | ||
childrenNames={childrenNames} | ||
patientGender={patientGender} | ||
/> | ||
); | ||
}; | ||
|
||
export default MotherChildTag; |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters