-
Notifications
You must be signed in to change notification settings - Fork 40
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
(Refactor) Ensure that Infant status outcomes show for infants on the infant banner #1935
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How come There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Other outcomes have spaces, so wrapping them in quotes makes them valid string I have updated the |
||
'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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @lucyjemutai , you can also add in other props and see if the values will be validated