Skip to content

Commit

Permalink
remove age restriction on displaying the MOther/infant name on the ba…
Browse files Browse the repository at this point in the history
…nner
  • Loading branch information
lucyjemutai committed Oct 22, 2024
1 parent e431761 commit dba2156
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ export function PatientStatusBannerTag({ patientUuid }) {
outcomeTagColor = 'red';
}

const { childrenNames, motherName, patientAge, patientGender, isLoading, isError } =
usePatientFamilyNames(patientUuid);
const { childrenNames, motherName, patientGender, isLoading, isError } = usePatientFamilyNames(patientUuid);

if (isLoading) {
return null;
Expand All @@ -32,16 +31,17 @@ export function PatientStatusBannerTag({ patientUuid }) {
if (isError) {
return <div>Error fetching family information</div>;
}

return (
<>
{hivStatus === 'positive' && <Tag type="red">{t('hivPositive', 'HIV Positive')}</Tag>}
{hivStatus === 'negative' && <Tag type="green">{t('hivNegative', 'HIV Negative')}</Tag>}

{patientOutcome && outcomeTagColor && <Tag type={outcomeTagColor}>{patientOutcome}</Tag>}

{patientAge !== null && patientAge <= 14 && motherName && <Tag type="purple">Mother: {motherName}</Tag>}
{motherName && <Tag type="purple">Mother: {motherName}</Tag>}

{patientAge !== null && patientAge > 14 && patientGender === 'F' && childrenNames.length > 0 && (
{patientGender === 'F' && childrenNames.length > 0 && (
<Tag type="purple">Children: {childrenNames.join(' || ')}</Tag>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export const usePatientFamilyNames = (patientUuid: string) => {

const fetchFamilyData = useCallback(async () => {
try {
// Fetch patient demographics (age and gender)
const response = await fetch(`/openmrs/ws/rest/v1/patient/${patientUuid}?v=full`);
const patient = await response.json();
setPatientAge(patient.person.age);
Expand All @@ -36,11 +35,12 @@ export const usePatientFamilyNames = (patientUuid: string) => {

const motherRelationship = relationships.find(
(relationship) =>
relationship.relationshipType?.displayAIsToB === 'Mother' ||
relationship.relationshipType?.displayBIsToA === 'Child',
(relationship.relationshipType?.displayAIsToB === 'Mother' ||
relationship.relationshipType?.displayBIsToA === 'Child') &&
relationship.personA?.uuid !== patientUuid,
);

setMotherName(motherRelationship?.personA?.display || 'Mother not found');
setMotherName(motherRelationship?.personA?.display || null);

setIsLoading(false);
} catch (error) {
Expand Down

0 comments on commit dba2156

Please sign in to comment.