-
Notifications
You must be signed in to change notification settings - Fork 283
(feat) O3-4443 Add ability to create a visit that ended in the past #2240
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
Conversation
Size Change: -4.08 MB (-19.31%) 👏 Total Size: 17 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.
Added some comments... a lot to review here, at the end of the day we will likely need to just get this tested thoroughly...
packages/esm-patient-chart-app/src/visit/visit-form/visit-date-time.component.tsx
Outdated
Show resolved
Hide resolved
packages/esm-patient-chart-app/src/visit/visit-form/visit-date-time.component.tsx
Show resolved
Hide resolved
packages/esm-patient-chart-app/src/visit/visit-form/visit-date-time.component.tsx
Outdated
Show resolved
Hide resolved
packages/esm-patient-chart-app/src/visit/visit-form/visit-date-time.component.tsx
Show resolved
Hide resolved
packages/esm-patient-chart-app/src/visit/visit-form/visit-form.workspace.tsx
Show resolved
Hide resolved
packages/esm-patient-chart-app/src/visit/visit-form/visit-form.workspace.tsx
Show resolved
Hide resolved
0eda32e
to
5994e50
Compare
5cf3101
to
a0c2424
Compare
} | ||
|
||
const abortController = new AbortController(); |
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.
Are we dispatching an abort signal incase the component unmounts?
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'm just keeping the existing implementation. I believe the proper way to implement this is to use useAbortController()
instead of creating a new AbortController(). This is a pattern that's in a lot of places, and we should probably address it in a separate PR.
packages/esm-patient-chart-app/src/visit/visit-form/visit-form.resource.ts
Outdated
Show resolved
Hide resolved
Could you fix up the conflicts, @chibongho? |
Fixed the conflict. One E2E test ( |
Yeah, the allergies failure spec is unrelated to your changes - I'm trying to figure out why it's happening. |
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'm not sure I love the "New" / "On-going" / "Past" distinction here; it's just that I don't necessarily think it's terribly intuitive. Since we already display a date and time, I think we can just collapse the "New" / "On-going" thing into one.
], | ||
}); | ||
|
||
const hasStopTime = 'past' == visitStatus; |
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.
const hasStopTime = 'past' == visitStatus; | |
const hasStopTime = 'past' === visitStatus; |
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.
And in general a few other places.
// await expect(chartPage.page.getByRole('textbox', { name: /start date/i })).toBeVisible(); | ||
// await expect(chartPage.page.getByRole('textbox', { name: /start time/i })).toBeVisible(); | ||
// await expect(chartPage.page.getByLabel(/start time format/i)).toBeVisible(); |
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.
We should probably just remove these?
import classNames from 'classnames'; | ||
import React, { useMemo } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { mapEncounters, type Encounter, type Note, type Order, type OrderItem } from '../visit.resource'; |
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.
nit (style): the typical preferred import order is what we had before where the React import is first, followed by other external dependencies, internal dependencies, and then components and functions, with the stylesheet import coming last. We've not enforced this yet via an ESLint plugin, but it's something that's on the horizon.
That might be tricky because whether or not overlapping visits are allowed is controlled by a GP, and we'd have to have all of the patient's visits (or at least their start and end dates) in context to be able to do the check (on the backend, we just create a SQL query to look for any overlap). That said, we definitely need to handle this error more gracefully than that! |
FWIW, here's what we do in O2: Screencast.from.2025-03-27.10-17-19.webm |
"New" hides the start date/time pickers altogether, and leaves the
|
Requirements
Summary
Currently, when creating a visit, the visit form only has fields for start date / time, and it is not possible to create a RDE visit with an end time. (We can’t work around it by first creating an RDE visit with no end time and edit it later, because it overlaps with any visits that's after it). This PR adds the ability to create a ended RDE visit.
Additional Refactoring:
onSubmit
on the start / end time fields. This PR combines theonSubmit
validation logic into the zod form schemavisit-form.resources.ts
DatePicker
,TimePicker
and a AM/PM Dropdown for inputting the datetime of the visit start and visit end. We store the value of those inputs respectively asDate
(with hours and minutes set to 0),hh:mm
string, and"AM" / "PM"
string. I found that confusing and changed theDatePicker
value to aYYYY-MM-DD
string instead. In hindsight, I don't feel as good about it as I hoped. It does make some things (like zod validation) simpler, but it also adds a transformation layer to get the value from / to the carbonDatePicker
DatePicker
andTimePicker
. One of the existing tests was disabled because of that. I managed to get that one test working, but when I tried adding more tests around date / time field validation I couldn't get those to work. I gave up and added unit tests around the zod form schema instead.Screenshots
When creating a visit:



When editing a visit:

Video:
https://github.com/user-attachments/assets/96fe2dfd-71a2-499b-ad16-e91784f0e522
Related Issue
https://openmrs.atlassian.net/browse/O3-4443
Other