-
Notifications
You must be signed in to change notification settings - Fork 66
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
adding merge functionality for eps to regular appointments #19754
base: master
Are you sure you want to change the base?
Conversation
adding merge functionality for eps to regular appointments
rubocop fixes
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 understand that this is a draft so just providing general feedback. There are other changes that would be needed to make sure the merged appointments are used in the rest of the controller method. Please add tests as well so it's easier to understand the changes and the desired effect.
def calculate_end_time(start_time) | ||
return nil unless start_time | ||
|
||
Time.zone.parse(start_time) + 60.minutes |
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 believe this is going to use the timezone of the runtime, which might be different from the patient's timezone. And if that's the case and we're showing the start time in patient's timezone, the end time could be incorrect.
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 using the start and end from the same data point though, shouldn't this match up? This is from where the method is entered:
start: appt.dig(:appointmentDetails, :start),
end: calculate_end_time(appt.dig(:appointmentDetails, :start))
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 timezone is in UTC we have found, so we will also inform the front end to change it to the user's time zone
modules/vaos/app/controllers/vaos/v2/appointments_controller.rb
Outdated
Show resolved
Hide resolved
modules/vaos/app/controllers/vaos/v2/appointments_controller.rb
Outdated
Show resolved
Hide resolved
normalized_new = new_appointments[:appointments].map { |appt| normalize_eps_appointment(appt) } | ||
basic_data = basic_appointments[:data].is_a?(Array) ? basic_appointments[:data] : [basic_appointments[:data]] | ||
existing_ids = basic_data.to_set { |a| a[:referralId] } | ||
merged_data = basic_data + normalized_new.reject { |a| existing_ids.include?(a[:referralId]) } |
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 deduping by referralId?
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 marking this as a confirmation
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.
Could you please see if the vaos appointment data have referralId
& is available under referralId
key?
modules/vaos/app/controllers/vaos/v2/appointments_controller.rb
Outdated
Show resolved
Hide resolved
modules/vaos/app/controllers/vaos/v2/appointments_controller.rb
Outdated
Show resolved
Hide resolved
revert controller, move logic to service
update test
moved controller logic to service
dropping and fixing a few items with test and removing patient_id
removing unused function
update to master
Updated fix?
@lee-delarm6 is this ready for review? there are no specs, and some of the other feedback is also un-addressed |
def normalize_eps_appointment(appt) | ||
{ | ||
id: appt[:id].to_s, | ||
status: appt[:state] == 'submitted' ? 'booked' : 'proposed', | ||
patientIcn: appt[:patientId], | ||
created: appt.dig(:appointmentDetails, :lastRetrieved), | ||
requestedPeriods: [ | ||
{ | ||
start: appt.dig(:appointmentDetails, :start), | ||
end: calculate_end_time(appt.dig(:appointmentDetails, :start)) | ||
} | ||
].compact, | ||
locationId: appt[:locationId], | ||
clinic: appt[:clinic], | ||
contact: appt[:contact] | ||
}.compact | ||
end |
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.
Please see if we can move this to a serializer for mapping the data to different fields for normalizing with vaos appointments
normalized_new = new_appointments[:appointments].map { |appt| normalize_eps_appointment(appt) } | ||
basic_data = basic_appointments[:data].is_a?(Array) ? basic_appointments[:data] : [basic_appointments[:data]] | ||
existing_ids = basic_data.to_set { |a| a[:referralId] } | ||
merged_data = basic_data + normalized_new.reject { |a| existing_ids.include?(a[:referralId]) } |
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.
Could you please see if the vaos appointment data have referralId
& is available under referralId
key?
Fixed linting issues
Changing naming, removing empty line
Lint fixes again
Remove line
eps serializer
rubocop fix
adding merge functionality for eps to regular appointments
Note: Delete the description statements, complete each step. None are optional, but can be justified as to why they cannot be completed as written. Provide known gaps to testing that may raise the risk of merging to production.
Summary
Testing done
What areas of the site does it impact?
Appointment retrieval and display
Configuration settings
Appointment service layer
Acceptance criteria