generated from openmrs/openmrs-esm-template-app
-
Notifications
You must be signed in to change notification settings - Fork 32
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
(feat)O3-4206-Add ability to view patient diagnoses and active conditions #123
Open
Omoshlawi
wants to merge
8
commits into
openmrs:main
Choose a base branch
from
Omoshlawi:O3-4206-add-ability-to-view-patient-diagnoses-alongside-prescribed-drugs-and-allergies
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
01c7fec
added patient diagnoses to dispensing app
Omoshlawi 1b50388
Added free texts to to translations
Omoshlawi 5815f00
Displaying nothing if no diagnoses are recorded for the visit
Omoshlawi 1d930fc
(fix) Fix exhaustive-deps and rules-of-hooks warnings (#124)
denniskigen 0e92207
Made viewing of visit diagnoses configurable
Omoshlawi 982dbc1
Added configurable extra-patient info slot, plugged in patient diagno…
Omoshlawi bf5c2e6
Added empty state component and handle empty state in diagnoses and c…
Omoshlawi 9c2e293
Handle loading and error in conditions component
Omoshlawi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React from 'react'; | ||
import { usePatientDiagnosis } from './diagnoses.resource'; | ||
import { InlineLoading, InlineNotification, Tile, Tag } from '@carbon/react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
type PatientDiagnosesProps = { | ||
patientUuid: string; | ||
encounterUuid: string; | ||
}; | ||
|
||
const PatientDiagnoses: React.FC<PatientDiagnosesProps> = ({ encounterUuid, patientUuid }) => { | ||
const { diagnoses, isLoading, error } = usePatientDiagnosis(encounterUuid); | ||
const { t } = useTranslation(); | ||
|
||
if (isLoading) | ||
return ( | ||
<InlineLoading | ||
iconDescription="Loading" | ||
description={t('loadingDiagnoses', 'Loading Diagnoses ...')} | ||
status="active" | ||
/> | ||
); | ||
|
||
if (error) | ||
return <InlineNotification kind="error" subtitle={t('diagnosesError', 'Error loading diagnoses')} lowContrast />; | ||
return ( | ||
<Tile> | ||
<strong> | ||
{t('diagnoses', 'Diagnoses')} {diagnoses.length ? `(${diagnoses.length})` : ''} | ||
</strong> | ||
<br /> | ||
{diagnoses.length ? ( | ||
<> | ||
{diagnoses.map(({ text }, index) => ( | ||
<Tag key={index}>{text}</Tag> | ||
))} | ||
</> | ||
) : ( | ||
<>{t('noDiagnoses', 'No diagnoses found')}</> | ||
)} | ||
</Tile> | ||
); | ||
}; | ||
|
||
export default PatientDiagnoses; |
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,30 @@ | ||
import { type FetchResponse, openmrsFetch, restBaseUrl, type Visit } from '@openmrs/esm-framework'; | ||
import { useMemo } from 'react'; | ||
import useSWR from 'swr'; | ||
|
||
export const usePatientDiagnosis = (encounterUuid: string) => { | ||
const customRepresentation = | ||
'custom:(uuid,display,visit:(uuid,patient,encounters:(uuid,diagnoses:(uuid,display,certainty,diagnosis:(coded:(uuid,display))),encounterDatetime,encounterType:(uuid,display),encounterProviders:(uuid,display,provider:(uuid,person:(uuid,display)))),location:(uuid,name,display),visitType:(uuid,name,display),startDatetime,stopDatetime))'; | ||
const url = `${restBaseUrl}/encounter/${encounterUuid}?v=${customRepresentation}`; | ||
|
||
const { data, error, isLoading } = useSWR<FetchResponse<{ visit: Visit }>>(url, openmrsFetch); | ||
|
||
const diagnoses = useMemo(() => { | ||
return ( | ||
data?.data?.visit?.encounters?.flatMap( | ||
(encounter) => | ||
encounter.diagnoses.map((diagnosis) => ({ | ||
id: diagnosis.diagnosis.coded.uuid, | ||
text: diagnosis.display, | ||
certainty: diagnosis.certainty, | ||
})) || [], | ||
) || [] | ||
); | ||
}, [data]); | ||
|
||
const confirmedDiagnoses = useMemo(() => { | ||
return diagnoses.filter((diagnosis) => diagnosis.certainty === 'CONFIRMED'); | ||
}, [diagnoses]); | ||
|
||
return { error, isLoading, diagnoses: confirmedDiagnoses as Array<{ id: string; text: string; certainty: string }> }; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,13 @@ | |
"online": true, | ||
"offline": true | ||
}, | ||
{ | ||
"name": "patient-diagnoses", | ||
"slot": "prescription-diagnoses-slot", | ||
"component": "patientDiagnoses", | ||
"online": true, | ||
"offline": true | ||
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. Also, I'd probably just leave |
||
}, | ||
{ | ||
"name": "dispensing-dashboard", | ||
"slot": "dispensing-dashboard-slot", | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I would go with just displaying nothing at all if no diagnoses are found? This is would make it more somewhat more compatible with implementations that are not yet storing diagnoses using the "encounter diagnosis" module?
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 @mogoodrich , fixed to display nothing if there are no diagnoses for the visit, for the UI I'll wait for the UX team output.