-
Notifications
You must be signed in to change notification settings - Fork 241
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
(feat) O3-3502 - ward app - add REST calls and datatypes for inpatient endpoints in EMR API #1219
Conversation
Size Change: -9.09 kB (-0.26%) Total Size: 3.49 MB ℹ️ View Unchanged
|
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.
LGTM, made a few comments.
export function useInpatientRequest(locationUuid: string) { | ||
const apiUrl = `${restBaseUrl}/emrapi/inpatient/admissionRequests?admissionLocation=${locationUuid}`; | ||
const apiUrl = `/ws/rest/emrapi/inpatient/admissionRequests?admissionLocation=${locationUuid}`; |
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.
Does this imply that we have a bug in emrapi endpoint that it is not using the appropriate base url prefix? If so, we should fix it there and put this back.
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.
Yes. Just filed https://openmrs.atlassian.net/browse/EA-194. Most (all?) emrapi endpoints have the same problem so this could be relatively disruptive to fix.
import OccupiedBed from '../beds/occupied-bed.component'; | ||
export interface WardBedProps { | ||
patientInfos: Array<{ patient: Patient; visit: Visit }>; | ||
patientInfos: Array<WardPatient>; |
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 wonder if we can rename this from patientInfos
-> wardPatients
const patientInfos = patients.map((patient) => ({ patient, visit: null })); | ||
if (admittedPatient) { | ||
// ideally, we can just use the patient object within admittedPatient | ||
// and not need the one from bedLayouts, however, the emr api |
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.
This has been fixed and committed in bedmanagement 6.0.0-SNAPSHOT, so you should be able to use admittedPatient now with an appropriate REST call.
const bedLayouts = filterBeds(admissionLocation); | ||
|
||
return ( | ||
<> | ||
{bedLayouts.map((bedLayout, i) => { | ||
const { patients } = bedLayout; | ||
const bed = bedLayoutToBed(bedLayout); | ||
const patientInfos: WardPatient[] = patients.map((patient) => { |
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.
This is not a blocker but it would be much more idiomatic to put all this (from bedLayouts.map(
to return <WardBed
) into a useMemo
block and just render the result of that in this return block. This keeps computation logic and rendering logic separate, which makes for more idiomatic and readable React code.
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 can't easily do useMemo
as this is in an if statement, but I can store this in a variable instead of inlining it in the JSX.
kind="error" | ||
lowContrast={true} | ||
title={t('errorLoadingWardLocation', 'Error loading admitted patients')} | ||
subtitle={errorLoadingPatients?.message} |
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.
subtitle={errorLoadingPatients?.message} | |
subtitle={errorLoadingPatients.message} |
If errorLoadingPatients
is falsy at this point then we are in trouble.
Co-authored-by: Brandon Istenes <bistenes@gmail.com>
Requirements
Summary
No real functional changes. This PR adds calls to endpoints that are now available in EMR API to retrieve admitted patients and admission requests in a ward location.
Screenshots
Related Issue
Other