-
Notifications
You must be signed in to change notification settings - Fork 262
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-4443 Add ability to create a visit that ended in the past #2240
base: main
Are you sure you want to change the base?
Conversation
Size Change: -26.5 kB (-0.16%) Total Size: 16.4 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...
], | ||
}); | ||
|
||
const hasStartTime = ['ongoing', 'past'].includes(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.
A "new" visit status is just an ongoing visit that has not be saved?
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.
A new visit is one where the start time defaults to now
onSubmit, and we don't need to show the DatePicker / TimePicker for the start time.
I guess I don't actually need this boolean because we return an empty component when visitStatus == 'new'
)} | ||
</section> | ||
); | ||
}; |
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.
Tangential rabbit-hole... are we validating start and end times so that you can't have overlapping visitings at the same visit location? (We need to figure this out but this could be a separate ticket).
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.
No, we are not validating that currently. Looks like zod support asynchronous validation, so it shouldn't be difficult. Filed ticket: https://openmrs.atlassian.net/browse/O3-4447.
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.
Great, thanks @chibongho !
disabled={disabled} | ||
> | ||
<SelectItem value="AM" text="AM" /> | ||
<SelectItem value="PM" text="PM" /> |
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 localize these display strings, I think. Also, we will need to (eventually) have a configuration parameter to switch between a 12-hour AM/PM selector and a 24 hour selector (could be a follow-on ticket)
interface DateTimeFieldProps { | ||
dateField: Field; | ||
timeField: Field; | ||
timeFormatField: Field; |
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.
what is this used for?
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.
It's for the VisitDateTimeField
component below. I'll rename it VisitDateTimeFieldProps
.
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.
Not a big deal, re: the name, I was more just wondering how it worked!
|
||
interface StartVisitFormProps extends DefaultPatientWorkspaceProps { | ||
interface VisitFormProps extends DefaultPatientWorkspaceProps { |
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.
+1 to this rename!
return defaultValues; | ||
}, [visitToEdit, defaultVisitLocation, emrConfiguration]); | ||
const { visitFormSchema, defaultValues, firstEncounterDateTime, lastEncounterDateTime } = | ||
useVisitFormSchemaAndDefaultValues(visitToEdit); |
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.
Great to clean this up and get it out of the form.
0eda32e
to
5994e50
Compare
5cf3101
to
a0c2424
Compare
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