Skip to content
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

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

lee-delarm6
Copy link
Contributor

@lee-delarm6 lee-delarm6 commented Dec 5, 2024

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

  • This work is behind a param
  • This change introduces EPS (Electronic Prescribing System) appointment integration into the VAOS (VA Online Scheduling) system.
  • Implementing EPS appointment normalization and merging functionality
  • Modifying appointment handling logic to incorporate EPS appointments
  • Cleaning up some code formatting and rubocop issues
  • The solution integrates EPS appointments with existing VAOS appointments by normalizing the EPS appointment data structure to match VAOS format and merging them while avoiding duplicates. This unified approach allows for consistent appointment handling across both systems.
  • Based on the code patterns and feature toggles present, this appears to be a gradual integration approach allowing for controlled rollout and testing.

Testing done

  • New code is covered by unit tests
  • New behavior: Both VAOS and EPS appointments are merged and displayed when the EPS include flag is present
  • Run this function with an without EPS appointments

What areas of the site does it impact?

  • VAOS (VA Online Scheduling) system, specifically:

Appointment retrieval and display
Configuration settings
Appointment service layer

Acceptance criteria

  • I fixed|updated|added unit tests and integration tests for each feature (if applicable).
  • No error nor warning in the console.
  • Events are being sent to the appropriate logging solution
  • Documentation has been updated (link to documentation)
  • No sensitive information (i.e. PII/credentials/internal URLs/etc.) is captured in logging, hardcoded, or specs
  • Feature/bug has a monitor built into Datadog (if applicable)
  • If app impacted requires authentication, did you login to a local build and verify all authenticated routes work as expected
  • I added a screenshot of the developed feature

adding merge functionality for eps to regular appointments
@va-vfs-bot va-vfs-bot temporarily deployed to 96412_merge_eps_appointments/main/main December 5, 2024 21:49 Inactive
rubocop fixes
@va-vfs-bot va-vfs-bot temporarily deployed to 96412_merge_eps_appointments/main/main December 5, 2024 22:07 Inactive
Copy link
Member

@randomsync randomsync left a 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.

modules/vaos/app/services/vaos/v2/appointments_service.rb Outdated Show resolved Hide resolved
modules/vaos/app/services/vaos/v2/appointments_service.rb Outdated Show resolved Hide resolved
def calculate_end_time(start_time)
return nil unless start_time

Time.zone.parse(start_time) + 60.minutes
Copy link
Member

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.

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'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))

Copy link
Contributor Author

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/services/vaos/v2/appointments_service.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]) }
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Contributor

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?

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
@va-vfs-bot va-vfs-bot temporarily deployed to 96412_merge_eps_appointments/main/main December 12, 2024 19:32 Inactive
update to master
fixes
more fixes
last fix
maybe last fix
Updated fix?
@va-vfs-bot va-vfs-bot temporarily deployed to 96412_merge_eps_appointments/main/main December 12, 2024 21:21 Inactive
@lee-delarm6 lee-delarm6 marked this pull request as ready for review December 16, 2024 16:30
@lee-delarm6 lee-delarm6 requested review from a team as code owners December 16, 2024 16:30
@randomsync
Copy link
Member

@lee-delarm6 is this ready for review? there are no specs, and some of the other feedback is also un-addressed

Comment on lines 212 to 228
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
Copy link
Contributor

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

modules/vaos/app/services/vaos/v2/appointments_service.rb Outdated Show resolved Hide resolved
modules/vaos/app/services/vaos/v2/appointments_service.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]) }
Copy link
Contributor

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/services/vaos/v2/appointments_service.rb Outdated Show resolved Hide resolved
Fixed linting issues
Changing naming, removing empty line
Lint fixes again
Remove line
@va-vfs-bot va-vfs-bot temporarily deployed to 96412_merge_eps_appointments/main/main December 20, 2024 11:08 Inactive
eps serializer
rubocop fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants