-
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.
OHRI-2295 Update OHRI endpoints to use SWR
- Loading branch information
1 parent
41f1f66
commit 6249d39
Showing
21 changed files
with
374 additions
and
544 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
36 changes: 0 additions & 36 deletions
36
packages/esm-commons-lib/src/components/banner-tags/.patient-status-tag.test.tsx
This file was deleted.
Oops, something went wrong.
25 changes: 16 additions & 9 deletions
25
packages/esm-commons-lib/src/components/banner-tags/patient-status-tag.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 |
---|---|---|
@@ -1,18 +1,25 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import React from 'react'; | ||
import { Tag } from '@carbon/react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { isPatientHivPositive } from './patientHivStatus'; | ||
import { usePatientsFinalHIVStatus } from './usePatientHivStatus'; | ||
import { useConfig } from '@openmrs/esm-framework'; | ||
|
||
export function PatientStatusBannerTag({ patientUuid }) { | ||
const { t } = useTranslation(); | ||
const [hivPositive, setHivPositive] = useState(false); | ||
const { obsConcepts } = useConfig(); | ||
const { isLoading, hivStatus, error } = usePatientsFinalHIVStatus( | ||
patientUuid, | ||
obsConcepts.finalHIVCodeConcept, | ||
obsConcepts.finalPositiveHIVValueConcept, | ||
); | ||
|
||
useEffect(() => { | ||
isPatientHivPositive(patientUuid).then((result) => setHivPositive(result)); | ||
}, [hivPositive, patientUuid]); | ||
if (isLoading) { | ||
return <p>{t('loading', 'Loading...')}</p>; | ||
} | ||
|
||
//TODO: Improve refresh time | ||
// forceRerender(); | ||
if (error) { | ||
return <p>{t('error', 'Error...')}</p>; | ||
} | ||
|
||
return <>{hivPositive && <Tag type="red">{t('hivPositive', 'HIV Positive')}</Tag>}</>; | ||
return <>{hivStatus && <Tag type="red">{t('hivPositive', 'HIV Positive')}</Tag>}</>; | ||
} |
Oops, something went wrong.