Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

feat(imaging): link image with visit #2309

Merged
merged 15 commits into from
Aug 26, 2020

Conversation

AlexTan331
Copy link
Contributor

Fixes #2291 .

Changes proposed in this pull request:

  • create a dropdown list for visits
  • render a list of visits for the selected patient when requesting a new imaging

@gitpod-io
Copy link

gitpod-io bot commented Aug 15, 2020

@morrme morrme requested review from blestab and fox1t August 16, 2020 10:40
@@ -146,7 +146,7 @@ export default {
label: 'Visits',
startDateTime: 'Start Date',
endDateTime: 'End Date',
type: 'Type',
type: 'Visit Type',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious why we decide to add Visit here? Aren't we already looking at Visit* fields? if we have to do it for one should we maybe not also do it for all of them? i.e. Visit Start Date, Visit End Date etc for consistency? Also not sure if this is related to the issue that this PR is meant to be addressing? I stand corrected should it be.

Copy link
Contributor Author

@AlexTan331 AlexTan331 Aug 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I was originally thinking is to create a translation key for the visit type so that it can be used in the new request imaging page
<div className="visits"> {newImagingRequest.patient && visitOption ? ( <SelectWithLabelFormGroup name="visit" label={t('patient.visits.type')}
image

Maybe it will make more sense to create a new translation key in the imaging locale index.ts file to prevent some confusion. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can keep the translation key in patients since visits are part of the patients module. Maybe just call it Visit rather than Visit Type because visit type makes me think (outpatient/inpatient/emergency etc) where here we are giving the user a list of all visits for this patient regardless of the type of visit it is, what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On it

@vercel
Copy link

vercel bot commented Aug 17, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/hospitalrun/hospitalrun-frontend/8a7sca0e8
✅ Preview: https://hospitalrun-frontend-git-fork-alextan331-link-image-with-visit.hospitalrun.vercel.app

if (patient) {
setNewImagingRequest((previousNewImagingRequest) => ({
...previousNewImagingRequest,
patient: patient.fullName as string,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should store patient id rather than the patient full name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this store as patient id, the patient field on the table in requested imagings page would display its patient id instead of full name
image

}))

const visits = patient.visits?.map((v) => ({ label: v.type, value: v.id }))
setVisitOption(visits)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do the visits need to be a state variable? seems like we could just reference patient.visits wherever we use the visits.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we need the visits to be a state variable. Because we can only fetch the visits data inside the onPatientChange method using the patient parameter (as we fetch the patient using this line onSearch={async (query: string) => PatientRepository.search(query)}). Using state variable ensures that the visits data will be re-rendered whenever the patient field value is changed.

Comment on lines 137 to 160
{newImagingRequest.patient && visitOption ? (
<SelectWithLabelFormGroup
name="visit"
label={t('imagings.imaging.visit')}
isRequired
isEditable
options={visitOption}
defaultSelected={visitOption.filter(
({ value }) => value === newImagingRequest.visitId,
)}
onChange={(values) => {
onVisitChange(values[0])
}}
/>
) : (
<SelectWithLabelFormGroup
name="visit"
label={t('imagings.imaging.visit')}
isRequired
isEditable={false}
options={[]}
onChange={(values) => {
onVisitChange(values[0])
}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since defaultSelected takes an undefined, I think we can simplify this logic to the following (or something similar to this):

<SelectWithLabelFormGroup
  name="visit"
  label={t('imagings.imaging.visit')}
  isRequired
  isEditable={patient !== undefined}
  options={patient.visits?.map((v) => ({ label: v.type, value: v.id })) || []}
  onChange={(values) => {
 onVisitChange(values[0])
}}
          />

patient: patient.fullName as string,
}))

const visits = patient.visits?.map((v) => ({ label: v.type, value: v.id }))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the label should be something like ${visitType} at ${startDateTime}or${visitType} (${startDateTime)}`

@jackcmeyer jackcmeyer changed the title Link image with visit feat(imaging): link image with visit Aug 26, 2020
@jackcmeyer jackcmeyer merged commit c0ee742 into HospitalRun:master Aug 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Link imaging request with visit
5 participants