-
Notifications
You must be signed in to change notification settings - Fork 95
Create unified slots service for CC Hybrid scheduling #27602
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
30d8775
VAOS: model VAProvider as a clinic with from_facility_and_clinic
JunTaoLuo 9bbc0cd
VAOS: expand unified VA search to clinics via SystemsService
JunTaoLuo 762942d
VAOS: add AvailabilityAdapter
JunTaoLuo 836c310
Implement eligibility check
JunTaoLuo 7a6c052
Remove unused attribute
JunTaoLuo 4c2a17f
Cleanup eligibility service
JunTaoLuo df3ed6c
PR feedback: renames and base provider fields
JunTaoLuo 7b6d00d
Update method signature
JunTaoLuo eff8e60
Extract appointment_type_id from provider
JunTaoLuo 77defde
Fix lint
JunTaoLuo aa5a76a
Update modules/vaos/app/services/vaos/v2/unified/slots_service.rb
JunTaoLuo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,9 +16,9 @@ def initialize(current_user) | |
| end | ||
|
|
||
| ## | ||
| # Searches for both VA facilities and EPS CC providers near the user's address, | ||
| # filtered by the referral's category of care. Pins the referral's matched CC | ||
| # provider at the top, then sorts remaining results by distance. | ||
| # Searches for VA clinics (via Lighthouse facilities + VAOS clinics) and EPS CC providers | ||
| # near the user's address, filtered by the referral's category of care. Pins the referral's | ||
| # matched CC provider at the top, then sorts remaining results by distance. | ||
| # | ||
| # @param referral [Object] A CCRA referral object with category_of_care, provider NPI, etc. | ||
| # @param radius [Integer] Search radius in miles (default: 25) | ||
|
|
@@ -69,9 +69,7 @@ def fetch_va_providers(user_address, referral, radius, lh_client:) | |
| per_page: 50 | ||
| ) | ||
|
|
||
| providers = facilities.map { |f| VAOS::V2::Unified::VAProvider.from_lighthouse_facility(f) } | ||
| providers.each { |p| assign_distance(p, user_address) } | ||
| filter_va_by_category_of_care(providers, referral.category_of_care) | ||
| fetch_providers_for_facilities(facilities, referral, user_address) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at the UX flow and guessing at how this service is to be used, we'll want to produce a list of VA providers which are clinics not facilities. There really isn't any use for raw VA facilities so I'm updating the logic here to:
|
||
| rescue => e | ||
| Rails.logger.error("#{log_prefix}: VA facility search failed", | ||
| { | ||
|
|
@@ -84,6 +82,19 @@ def fetch_va_providers(user_address, referral, radius, lh_client:) | |
| [] | ||
| end | ||
|
|
||
| def fetch_providers_for_facilities(facilities, referral, user_address) | ||
| matching_facilities = filter_supported_facilities(facilities, referral.category_of_care) | ||
| clinical_service = ServiceTypeMapper.to_vaos(referral.category_of_care) | ||
|
|
||
| matching_facilities.flat_map do |facility| | ||
| fetch_clinics_for_facility(facility, clinical_service).map do |clinic| | ||
| provider = VAProvider.from_facility_and_clinic(facility, clinic) | ||
| assign_distance(provider, user_address) | ||
| provider | ||
| end | ||
| end | ||
|
JunTaoLuo marked this conversation as resolved.
|
||
| end | ||
|
|
||
| def fetch_eps_providers(user_address, referral, radius, eps_client:) | ||
| providers = eps_client.search_by_location( | ||
| latitude: user_address.latitude, | ||
|
|
@@ -127,16 +138,33 @@ def assign_distance(provider, user_address) | |
| ) | ||
| end | ||
|
|
||
| def filter_va_by_category_of_care(providers, category_of_care) | ||
| return providers if category_of_care.blank? | ||
| def filter_supported_facilities(facilities, category_of_care) | ||
| return facilities if category_of_care.blank? | ||
|
|
||
| normalized = category_of_care.to_s.downcase.gsub(/[\s_-]+/, '') | ||
| # We'll need to filter based on category of care and eligibility | ||
|
|
||
| providers.select do |provider| | ||
| provider.schedulable_services.any? do |svc| | ||
| svc.to_s.downcase.gsub(/[\s_-]+/, '') == normalized | ||
| end | ||
| end | ||
| facilities | ||
| end | ||
|
|
||
| def fetch_clinics_for_facility(facility, clinical_service) | ||
| systems_service.get_facility_clinics( | ||
| location_id: facility.unique_id, | ||
| clinical_service: | ||
| ) | ||
| rescue => e | ||
| Rails.logger.warn( | ||
| "#{log_prefix}: Clinic fetch failed for facility #{facility.unique_id}", | ||
| { | ||
| error_class: e.class.name, | ||
| clinical_service:, | ||
| user_uuid: @cached_user_uuid | ||
| }.compact | ||
| ) | ||
| [] | ||
| end | ||
|
|
||
| def systems_service | ||
| @systems_service ||= VAOS::V2::SystemsService.new(current_user) | ||
| end | ||
|
|
||
| def combine_and_sort(va_providers, eps_providers, referral) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.