From a6f17a8b806596434af64a004a09d82ea0305ce6 Mon Sep 17 00:00:00 2001 From: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Date: Fri, 7 Mar 2025 12:11:23 -0500 Subject: [PATCH 01/30] MHV-68159 Migration to new MHV API Gateway --- config/features.yml | 4 +++ .../client/concerns/mhv_jwt_session_client.rb | 9 +++++- lib/medical_records/client.rb | 19 ++++++++++-- lib/medical_records/configuration.rb | 6 +++- lib/medical_records/phr_mgr/client.rb | 6 ++-- lib/medical_records/phr_mgr/configuration.rb | 13 +++++++-- .../config/initializers/fhir_read_patch.rb | 29 +++++++++++++++++++ .../config/initializers/fhir_search_patch.rb | 5 ++-- 8 files changed, 78 insertions(+), 13 deletions(-) create mode 100644 modules/my_health/config/initializers/fhir_read_patch.rb diff --git a/config/features.yml b/config/features.yml index bec2a6e15e9..6050141d22a 100644 --- a/config/features.yml +++ b/config/features.yml @@ -1043,6 +1043,10 @@ features: actor_type: user description: Show/hide content related to Vitals in Medical Records enable_in_development: true + mhv_medical_records_migrate_to_api_gateway: + actor_type: user + description: Enables the switch to the new MHV API Gateway endpoints + enable_in_development: true mhv_medical_records_phr_refresh_on_login: actor_type: user description: Enables/disables the PHR refresh for MHV users when logging into VA.gov diff --git a/lib/common/client/concerns/mhv_jwt_session_client.rb b/lib/common/client/concerns/mhv_jwt_session_client.rb index f2683f31f2c..6c8e9b397c8 100644 --- a/lib/common/client/concerns/mhv_jwt_session_client.rb +++ b/lib/common/client/concerns/mhv_jwt_session_client.rb @@ -78,7 +78,11 @@ def validate_session_params def get_session_tagged Sentry.set_tags(error: 'mhv_session') - env = perform(:post, '/mhvapi/security/v1/login', auth_body, auth_headers) + env = if Flipper.enabled?(:mhv_medical_records_migrate_to_api_gateway) + perform(:post, '/v1/security/login', auth_body, auth_headers) + else + perform(:post, '/mhvapi/security/v1/login', auth_body, auth_headers) + end Sentry.get_current_scope.tags.delete(:error) env end @@ -93,6 +97,9 @@ def patient_fhir_id def auth_headers config.base_request_headers.merge('Content-Type' => 'application/json') + if Flipper.enabled?(:mhv_medical_records_migrate_to_api_gateway) + config.base_request_headers.merge('x-api-key' => Settings.mhv.medical_records.x_api_key) + end end def auth_body diff --git a/lib/medical_records/client.rb b/lib/medical_records/client.rb index c8dea6b5016..9ddfa08554b 100644 --- a/lib/medical_records/client.rb +++ b/lib/medical_records/client.rb @@ -14,7 +14,7 @@ class Client < Common::Client::Base include Common::Client::Concerns::MhvFhirSessionClient # Default number of records to request per call when searching - DEFAULT_COUNT = 9999 + DEFAULT_COUNT = 3000 # LOINC codes for clinical notes PHYSICIAN_PROCEDURE_NOTE = '11506-3' # Physician procedure note @@ -43,7 +43,11 @@ class Client < Common::Client::Base # @return [String] Base path for dependent URLs # def base_path - "#{Settings.mhv.medical_records.host}/fhir/" + if Flipper.enabled?(:mhv_medical_records_migrate_to_api_gateway) + "#{Settings.mhv.api_gateway.hosts.fhir}/fhir/" + else + "#{Settings.mhv.medical_records.host}/fhir/" + end end ## @@ -214,6 +218,10 @@ def fhir_search(fhir_model, params) # def fhir_search_query(fhir_model, params) default_headers = { 'Cache-Control': 'no-cache' } + if Flipper.enabled?(:mhv_medical_records_migrate_to_api_gateway) + default_headers.merge('x-api-key' => Settings.mhv.medical_records.x_api_key) + end + params[:headers] = default_headers.merge(params.fetch(:headers, {})) params[:search][:parameters].merge!(_count: DEFAULT_COUNT) @@ -224,7 +232,12 @@ def fhir_search_query(fhir_model, params) end def fhir_read(fhir_model, id) - result = fhir_client.read(fhir_model, id) + default_headers = {} + if Flipper.enabled?(:mhv_medical_records_migrate_to_api_gateway) + default_headers.merge!('x-api-key' => Settings.mhv.medical_records.x_api_key) + end + + result = fhir_client.read(fhir_model, id, nil, nil, { headers: default_headers }) handle_api_errors(result) if result.resource.nil? result.resource end diff --git a/lib/medical_records/configuration.rb b/lib/medical_records/configuration.rb index 46f5cbe4db6..a3ac7218bc2 100644 --- a/lib/medical_records/configuration.rb +++ b/lib/medical_records/configuration.rb @@ -26,7 +26,11 @@ def app_token # @return [String] Base path for dependent URLs # def base_path - Settings.mhv.medical_records.host + if Flipper.enabled?(:mhv_medical_records_migrate_to_api_gateway) + Settings.mhv.api_gateway.hosts.security + else + Settings.mhv.medical_records.host + end end ## diff --git a/lib/medical_records/phr_mgr/client.rb b/lib/medical_records/phr_mgr/client.rb index 2f4e8e49211..0f2ac00455f 100644 --- a/lib/medical_records/phr_mgr/client.rb +++ b/lib/medical_records/phr_mgr/client.rb @@ -28,7 +28,7 @@ def initialize(icn) # @return [Fixnum] Call status # def post_phrmgr_refresh - response = perform(:post, "refresh/#{@icn}", nil, self.class.configuration.x_auth_key_headers) + response = perform(:post, "refresh/#{@icn}", nil, self.class.configuration.phr_headers) # response_hash = JSON.parse(response.body) response&.status end @@ -39,7 +39,7 @@ def post_phrmgr_refresh # @return [Hash] Patient status # def get_phrmgr_status - response = perform(:get, "status/#{@icn}", nil, self.class.configuration.x_auth_key_headers) + response = perform(:get, "status/#{@icn}", nil, self.class.configuration.phr_headers) response.body end @@ -49,7 +49,7 @@ def get_phrmgr_status # @return - military service record in text format # def get_military_service(edipi) - headers = self.class.configuration.x_auth_key_headers.merge({ 'Accept' => 'text/plain' }) + headers = self.class.configuration.phr_headers.merge({ 'Accept' => 'text/plain' }) response = perform(:get, "dod/vaprofile/#{edipi}", nil, headers) response.body end diff --git a/lib/medical_records/phr_mgr/configuration.rb b/lib/medical_records/phr_mgr/configuration.rb index d13f0ceda91..1dfb6a1c675 100644 --- a/lib/medical_records/phr_mgr/configuration.rb +++ b/lib/medical_records/phr_mgr/configuration.rb @@ -19,14 +19,21 @@ class Configuration < Common::Client::Configuration::REST # @return [String] Base path for dependent URLs # def base_path - "#{Settings.mhv.medical_records.host}/mhvapi/v2/phrmgr/" + if Flipper.enabled?(:mhv_medical_records_migrate_to_api_gateway) + "#{Settings.mhv.api_gateway.hosts.phrmgr}/v2/phrmgr/" + else + "#{Settings.mhv.medical_records.host}/mhvapi/v2/phrmgr/" + end end ## - # @return [Hash] Headers with X-Authorization-Key header value for dependent URLs + # @return [Hash] Headers with X-Authorization-Key and x-api-key header values for dependent URLs # - def x_auth_key_headers + def phr_headers base_request_headers.merge('X-Authorization-Key' => Settings.mhv.medical_records.x_auth_key) + if Flipper.enabled?(:mhv_medical_records_migrate_to_api_gateway) + base_request_headers.merge('x-api-key' => Settings.mhv.medical_records.x_api_key) + end end ## diff --git a/modules/my_health/config/initializers/fhir_read_patch.rb b/modules/my_health/config/initializers/fhir_read_patch.rb new file mode 100644 index 00000000000..60fc8e3a953 --- /dev/null +++ b/modules/my_health/config/initializers/fhir_read_patch.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +# Monkeypatch to allow read to take custom headers. This allows us to inject the x-api-key header +# when accessing FHIR via the MHV API Gateway. +# Patched version: department-of-veterans-affairs/fhir_client (fork of 5.0.3) +module FHIR + module Sections + module Crud + def read(klass, id, format = nil, summary = nil, options = {}) + options = { resource: klass, id:, format: format || @default_format }.merge(options) + options[:summary] = summary if summary + + # Build the default headers (using the provided format if any) + base_headers = {} + base_headers[:accept] = format.to_s if format + + # Grab any custom headers provided in the options + extra_headers = options[:headers] || {} + + # Merge custom headers into the default FHIR headers + reply = get resource_url(options), fhir_headers(base_headers).merge(extra_headers) + + reply.resource = parse_reply(klass, format || @default_format, reply) + reply.resource_class = klass + reply + end + end + end +end diff --git a/modules/my_health/config/initializers/fhir_search_patch.rb b/modules/my_health/config/initializers/fhir_search_patch.rb index ca58841b649..ab04b6900e4 100644 --- a/modules/my_health/config/initializers/fhir_search_patch.rb +++ b/modules/my_health/config/initializers/fhir_search_patch.rb @@ -1,8 +1,9 @@ # frozen_string_literal: true # Monkeypatch to allow fhir_search to take custom headers. This is to allow us to bypass the FHIR -# server's cache when requesting a Patient resource. -# Patched version: fhir_client (5.0.3) +# server's cache when requesting a FHIR resource. It also allows us to inject the x-api-key header +# when accessing FHIR via the MHV API Gateway. +# Patched version: department-of-veterans-affairs/fhir_client (fork of 5.0.3) module FHIR module Sections module Search From d859e0cedbb3332c2ad42698c2acc719a5746b74 Mon Sep 17 00:00:00 2001 From: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Date: Tue, 18 Mar 2025 11:42:45 -0400 Subject: [PATCH 02/30] MHV-68159 Added custom base bath --- lib/medical_records/bb_internal/client.rb | 207 ++++++++++++------ .../bb_internal/configuration.rb | 20 +- 2 files changed, 156 insertions(+), 71 deletions(-) diff --git a/lib/medical_records/bb_internal/client.rb b/lib/medical_records/bb_internal/client.rb index 1b021390705..e09cf3947b8 100644 --- a/lib/medical_records/bb_internal/client.rb +++ b/lib/medical_records/bb_internal/client.rb @@ -17,6 +17,9 @@ class Client < Common::Client::Base configuration BBInternal::Configuration client_session BBInternal::ClientSession + USERMGMT_BASE_PATH = "#{Settings.mhv.api_gateway.hosts.usermgmt}/v1/".freeze + BLUEBUTTON_BASE_PATH = "#{Settings.mhv.api_gateway.hosts.bluebutton}/v1/".freeze + ################################################################################ # User Management APIs ################################################################################ @@ -25,12 +28,15 @@ class Client < Common::Client::Base # @return [Hash] A hash containing the patient's details # def get_patient - response = perform(:get, "usermgmt/patient/uid/#{@session.user_id}", nil, token_headers) - patient = response.body + with_custom_base_path(USERMGMT_BASE_PATH) do + configuration BBInternal::Configuration + response = perform(:get, "usermgmt/patient/uid/#{@session.user_id}", nil, token_headers) + patient = response.body - raise Common::Exceptions::ServiceError.new(detail: 'Patient not found') if patient.blank? + raise Common::Exceptions::ServiceError.new(detail: 'Patient not found') if patient.blank? - patient + patient + end end # Retrieves the BBMI notification setting for the user. @@ -38,8 +44,10 @@ def get_patient # - flag [Boolean]: Indicates whether the BBMI notification setting is enabled (true) or disabled (false) # def get_bbmi_notification_setting - response = perform(:get, 'usermgmt/notification/bbmi', nil, token_headers) - response.body + with_custom_base_path(USERMGMT_BASE_PATH) do + response = perform(:get, 'usermgmt/notification/bbmi', nil, token_headers) + response.body + end end ################################################################################ @@ -53,8 +61,10 @@ def get_bbmi_notification_setting # @return [Hash] The radiology report list from MHV # def list_radiology - response = perform(:get, "bluebutton/radiology/phrList/#{session.patient_id}", nil, token_headers) - response.body + with_custom_base_path(BLUEBUTTON_BASE_PATH) do + response = perform(:get, "bluebutton/radiology/phrList/#{session.patient_id}", nil, token_headers) + response.body + end end ## @@ -64,9 +74,11 @@ def list_radiology # @return [Hash] The radiology study list from MHV # def list_imaging_studies - response = perform(:get, "bluebutton/study/#{session.patient_id}", nil, token_headers) - data = response.body - map_study_ids(data) + with_custom_base_path(BLUEBUTTON_BASE_PATH) do + response = perform(:get, "bluebutton/study/#{session.patient_id}", nil, token_headers) + data = response.body + map_study_ids(data) + end end ## @@ -79,18 +91,20 @@ def list_imaging_studies # @return [Hash] The status of the image request, including percent complete # def request_study(id) - # Fetch the original studyIdUrn from the Redis cache - study_id = get_study_id_from_cache(id) + with_custom_base_path(BLUEBUTTON_BASE_PATH) do + # Fetch the original studyIdUrn from the Redis cache + study_id = get_study_id_from_cache(id) - # Perform the API call with the original studyIdUrn - response = perform(:get, "bluebutton/studyjob/#{session.patient_id}/icn/#{session.icn}/studyid/#{study_id}", nil, - token_headers) - data = response.body + # Perform the API call with the original studyIdUrn + response = perform(:get, "bluebutton/studyjob/#{session.patient_id}/icn/#{session.icn}/studyid/#{study_id}", nil, + token_headers) + data = response.body - # Transform the response to replace the studyIdUrn with the UUID - data['studyIdUrn'] = id if data.is_a?(Hash) && data['studyIdUrn'] == study_id + # Transform the response to replace the studyIdUrn with the UUID + data['studyIdUrn'] = id if data.is_a?(Hash) && data['studyIdUrn'] == study_id - data + data + end end ## @@ -101,10 +115,12 @@ def request_study(id) # @return [Hash] The list of images from MHV # def list_images(id) - study_id = get_study_id_from_cache(id) - response = perform(:get, "bluebutton/studyjob/zip/preview/list/#{session.patient_id}/studyidUrn/#{study_id}", nil, - token_headers) - response.body + with_custom_base_path(BLUEBUTTON_BASE_PATH) do + study_id = get_study_id_from_cache(id) + response = perform(:get, "bluebutton/studyjob/zip/preview/list/#{session.patient_id}/studyidUrn/#{study_id}", nil, + token_headers) + response.body + end end ## @@ -119,10 +135,12 @@ def list_images(id) # body via the provided yielder. # def get_image(id, series, image, header_callback, yielder) - study_id = get_study_id_from_cache(id) - uri = URI.join(config.base_path, - "bluebutton/external/studyjob/image/studyidUrn/#{study_id}/series/#{series}/image/#{image}") - streaming_get(uri, token_headers, header_callback, yielder) + with_custom_base_path(BLUEBUTTON_BASE_PATH) do + study_id = get_study_id_from_cache(id) + uri = URI.join(config.base_path, + "bluebutton/external/studyjob/image/studyidUrn/#{study_id}/series/#{series}/image/#{image}") + streaming_get(uri, token_headers, header_callback, yielder) + end end ## @@ -134,9 +152,12 @@ def get_image(id, series, image, header_callback, yielder) # body via the provided yielder. # def get_dicom(id, header_callback, yielder) - study_id = get_study_id_from_cache(id) - uri = URI.join(config.base_path, "bluebutton/studyjob/zip/stream/#{session.patient_id}/studyidUrn/#{study_id}") - streaming_get(uri, token_headers, header_callback, yielder) + with_custom_base_path(BLUEBUTTON_BASE_PATH) do + study_id = get_study_id_from_cache(id) + uri = URI.join(config.base_path, + "bluebutton/studyjob/zip/stream/#{session.patient_id}/studyidUrn/#{study_id}") + streaming_get(uri, token_headers, header_callback, yielder) + end end ## @@ -145,9 +166,11 @@ def get_dicom(id, header_callback, yielder) # @return JSON [{ dateGenerated, status, patientId }] # def get_generate_ccd(icn, last_name) - escaped_last_name = URI::DEFAULT_PARSER.escape(last_name) - response = perform(:get, "bluebutton/healthsummary/#{icn}/#{escaped_last_name}/xml", nil, token_headers) - response.body + with_custom_base_path(BLUEBUTTON_BASE_PATH) do + escaped_last_name = URI::DEFAULT_PARSER.escape(last_name) + response = perform(:get, "bluebutton/healthsummary/#{icn}/#{escaped_last_name}/xml", nil, token_headers) + response.body + end end ## @@ -155,10 +178,12 @@ def get_generate_ccd(icn, last_name) # @return - Continuity of Care Document in XML format # def get_download_ccd(date) - modified_headers = token_headers.dup - modified_headers['Accept'] = 'application/xml' - response = perform(:get, "bluebutton/healthsummary/#{date}/fileFormat/XML/ccdType/XML", nil, modified_headers) - response.body + with_custom_base_path(BLUEBUTTON_BASE_PATH) do + modified_headers = token_headers.dup + modified_headers['Accept'] = 'application/xml' + response = perform(:get, "bluebutton/healthsummary/#{date}/fileFormat/XML/ccdType/XML", nil, modified_headers) + response.body + end end ## @@ -167,9 +192,11 @@ def get_download_ccd(date) # startDate: 1729777818853, endDate}] # def get_study_status - response = perform(:get, "bluebutton/studyjob/#{session.patient_id}", nil, token_headers) - data = response.body - map_study_ids(data) + with_custom_base_path(BLUEBUTTON_BASE_PATH) do + response = perform(:get, "bluebutton/studyjob/#{session.patient_id}", nil, token_headers) + data = response.body + map_study_ids(data) + end end ################################################################################ @@ -177,80 +204,118 @@ def get_study_status ################################################################################ def get_sei_vital_signs_summary - response = perform(:get, "vitals/summary/#{@session.user_id}", nil, token_headers) - response.body + with_custom_base_path(BLUEBUTTON_BASE_PATH) do + response = perform(:get, "vitals/summary/#{@session.user_id}", nil, token_headers) + response.body + end end def get_sei_allergies - response = perform(:get, "healthhistory/allergy/#{@session.user_id}", nil, token_headers) - response.body + with_custom_base_path(BLUEBUTTON_BASE_PATH) do + response = perform(:get, "healthhistory/allergy/#{@session.user_id}", nil, token_headers) + response.body + end end def get_sei_family_health_history - response = perform(:get, "healthhistory/healthHistory/#{@session.user_id}", nil, token_headers) - response.body + with_custom_base_path(BLUEBUTTON_BASE_PATH) do + response = perform(:get, "healthhistory/healthHistory/#{@session.user_id}", nil, token_headers) + response.body + end end def get_sei_immunizations - response = perform(:get, "healthhistory/immunization/#{@session.user_id}", nil, token_headers) - response.body + with_custom_base_path(BLUEBUTTON_BASE_PATH) do + response = perform(:get, "healthhistory/immunization/#{@session.user_id}", nil, token_headers) + response.body + end end def get_sei_test_entries - response = perform(:get, "healthhistory/testEntry/#{@session.user_id}", nil, token_headers) - response.body + with_custom_base_path(BLUEBUTTON_BASE_PATH) do + response = perform(:get, "healthhistory/testEntry/#{@session.user_id}", nil, token_headers) + response.body + end end def get_sei_medical_events - response = perform(:get, "healthhistory/medicalEvent/#{@session.user_id}", nil, token_headers) - response.body + with_custom_base_path(BLUEBUTTON_BASE_PATH) do + response = perform(:get, "healthhistory/medicalEvent/#{@session.user_id}", nil, token_headers) + response.body + end end def get_sei_military_history - response = perform(:get, "healthhistory/militaryHistory/#{@session.user_id}", nil, token_headers) - response.body + with_custom_base_path(BLUEBUTTON_BASE_PATH) do + response = perform(:get, "healthhistory/militaryHistory/#{@session.user_id}", nil, token_headers) + response.body + end end def get_sei_healthcare_providers - response = perform(:get, "getcare/healthCareProvider/#{@session.user_id}", nil, token_headers) - response.body + with_custom_base_path(BLUEBUTTON_BASE_PATH) do + response = perform(:get, "getcare/healthCareProvider/#{@session.user_id}", nil, token_headers) + response.body + end end def get_sei_health_insurance - response = perform(:get, "getcare/healthInsurance/#{@session.user_id}", nil, token_headers) - response.body + with_custom_base_path(BLUEBUTTON_BASE_PATH) do + response = perform(:get, "getcare/healthInsurance/#{@session.user_id}", nil, token_headers) + response.body + end end def get_sei_treatment_facilities - response = perform(:get, "getcare/treatmentFacility/#{@session.user_id}", nil, token_headers) - response.body + with_custom_base_path(BLUEBUTTON_BASE_PATH) do + response = perform(:get, "getcare/treatmentFacility/#{@session.user_id}", nil, token_headers) + response.body + end end def get_sei_food_journal - response = perform(:get, "journal/journals/#{@session.user_id}", nil, token_headers) - response.body + with_custom_base_path(BLUEBUTTON_BASE_PATH) do + response = perform(:get, "journal/journals/#{@session.user_id}", nil, token_headers) + response.body + end end def get_sei_activity_journal - response = perform(:get, "journal/activityjournals/#{@session.user_id}", nil, token_headers) - response.body + with_custom_base_path(BLUEBUTTON_BASE_PATH) do + response = perform(:get, "journal/activityjournals/#{@session.user_id}", nil, token_headers) + response.body + end end def get_sei_medications - response = perform(:get, "pharmacy/medications/#{@session.user_id}", nil, token_headers) - response.body + with_custom_base_path(BLUEBUTTON_BASE_PATH) do + response = perform(:get, "pharmacy/medications/#{@session.user_id}", nil, token_headers) + response.body + end end # Retrieves the patient demographic information # @return [Hash] A hash containing the patient's demographic information # def get_demographic_info - response = perform(:get, 'bluebutton/external/phrdemographic', nil, token_headers) - response.body + with_custom_base_path(BLUEBUTTON_BASE_PATH) do + response = perform(:get, 'bluebutton/external/phrdemographic', nil, token_headers) + response.body + end end private + def with_custom_base_path(custom_base_path) + old_base = BBInternal::Configuration.base_path + if Flipper.enabled?(:mhv_medical_records_migrate_to_api_gateway) && custom_base_path + BBInternal::Configuration.custom_base_path = custom_base_path + end + yield + ensure + BBInternal::Configuration.custom_base_path = old_base + end + ## # Overriding this to ensure a unique namespace for the redis lock. # @@ -348,7 +413,9 @@ def get_session # Overriding MHVSessionBasedClient's method, because we need more control over the path. # def get_session_tagged - perform(:get, 'usermgmt/auth/session', nil, auth_headers) + with_custom_base_path(USERMGMT_BASE_PATH) do + perform(:get, 'usermgmt/auth/session', nil, auth_headers) + end end end end diff --git a/lib/medical_records/bb_internal/configuration.rb b/lib/medical_records/bb_internal/configuration.rb index 6a4278ceffa..1b9e941d8cc 100644 --- a/lib/medical_records/bb_internal/configuration.rb +++ b/lib/medical_records/bb_internal/configuration.rb @@ -15,6 +15,20 @@ module BBInternal # HTTP client configuration for {PHRMgr::Client} # class Configuration < Common::Client::Configuration::REST + ## + # Setter for thread-local variable custom_base_path + # + def self.custom_base_path=(value) + Thread.current[:custom_base_path] = value + end + + ## + # Getter for thread-local variable custom_base_path + # + def self.custom_base_path + Thread.current[:custom_base_path] + end + ## # BB Internal uses the same app token as Rx. # @return [String] Client token set in `settings.yml` via credstash @@ -28,7 +42,11 @@ def app_token # @return [String] Base path for dependent URLs # def base_path - "#{Settings.mhv.medical_records.host}/mhvapi/v1/" + if Flipper.enabled?(:mhv_medical_records_migrate_to_api_gateway) + self.class.custom_base_path || "#{Settings.mhv.api_gateway.hosts.bluebutton}/v1/" + else + "#{Settings.mhv.medical_records.host}/mhvapi/v1/" + end end ## From 863d026720805d85426b9e76a773e0c95a668158 Mon Sep 17 00:00:00 2001 From: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Date: Wed, 19 Mar 2025 11:59:32 -0400 Subject: [PATCH 03/30] MHV-68159 Fixes --- lib/medical_records/bb_internal/client.rb | 4 ---- lib/medical_records/phr_mgr/configuration.rb | 5 +++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/medical_records/bb_internal/client.rb b/lib/medical_records/bb_internal/client.rb index e09cf3947b8..b77c8981aa7 100644 --- a/lib/medical_records/bb_internal/client.rb +++ b/lib/medical_records/bb_internal/client.rb @@ -29,7 +29,6 @@ class Client < Common::Client::Base # def get_patient with_custom_base_path(USERMGMT_BASE_PATH) do - configuration BBInternal::Configuration response = perform(:get, "usermgmt/patient/uid/#{@session.user_id}", nil, token_headers) patient = response.body @@ -307,13 +306,10 @@ def get_demographic_info private def with_custom_base_path(custom_base_path) - old_base = BBInternal::Configuration.base_path if Flipper.enabled?(:mhv_medical_records_migrate_to_api_gateway) && custom_base_path BBInternal::Configuration.custom_base_path = custom_base_path end yield - ensure - BBInternal::Configuration.custom_base_path = old_base end ## diff --git a/lib/medical_records/phr_mgr/configuration.rb b/lib/medical_records/phr_mgr/configuration.rb index 1dfb6a1c675..236f8e405c2 100644 --- a/lib/medical_records/phr_mgr/configuration.rb +++ b/lib/medical_records/phr_mgr/configuration.rb @@ -30,10 +30,11 @@ def base_path # @return [Hash] Headers with X-Authorization-Key and x-api-key header values for dependent URLs # def phr_headers - base_request_headers.merge('X-Authorization-Key' => Settings.mhv.medical_records.x_auth_key) + headers = base_request_headers.merge('X-Authorization-Key' => Settings.mhv.medical_records.x_auth_key) if Flipper.enabled?(:mhv_medical_records_migrate_to_api_gateway) - base_request_headers.merge('x-api-key' => Settings.mhv.medical_records.x_api_key) + headers.merge!('x-api-key' => Settings.mhv.medical_records.x_api_key_v2) end + headers end ## From 01d58069498dd2a495b0a6d4716b8ac2d44d93b0 Mon Sep 17 00:00:00 2001 From: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Date: Thu, 20 Mar 2025 11:17:02 -0400 Subject: [PATCH 04/30] MHV-68159 Corrections to paths and headers --- lib/medical_records/bb_internal/client.rb | 8 ++++++++ lib/medical_records/bb_internal/configuration.rb | 4 ++++ lib/medical_records/client.rb | 8 ++++---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/medical_records/bb_internal/client.rb b/lib/medical_records/bb_internal/client.rb index b77c8981aa7..b17bc352e96 100644 --- a/lib/medical_records/bb_internal/client.rb +++ b/lib/medical_records/bb_internal/client.rb @@ -312,6 +312,14 @@ def with_custom_base_path(custom_base_path) yield end + def token_headers + super.merge('x-api-key' => config.x_api_key) + end + + def auth_headers + super.merge('x-api-key' => config.x_api_key) + end + ## # Overriding this to ensure a unique namespace for the redis lock. # diff --git a/lib/medical_records/bb_internal/configuration.rb b/lib/medical_records/bb_internal/configuration.rb index 1b9e941d8cc..4274a1730e4 100644 --- a/lib/medical_records/bb_internal/configuration.rb +++ b/lib/medical_records/bb_internal/configuration.rb @@ -37,6 +37,10 @@ def app_token Settings.mhv.rx.app_token end + def x_api_key + Settings.mhv.medical_records.x_api_key + end + ## # BB Internal uses the same domain as Medical Records FHIR. # @return [String] Base path for dependent URLs diff --git a/lib/medical_records/client.rb b/lib/medical_records/client.rb index 9ddfa08554b..146c3556dc5 100644 --- a/lib/medical_records/client.rb +++ b/lib/medical_records/client.rb @@ -44,7 +44,7 @@ class Client < Common::Client::Base # def base_path if Flipper.enabled?(:mhv_medical_records_migrate_to_api_gateway) - "#{Settings.mhv.api_gateway.hosts.fhir}/fhir/" + "#{Settings.mhv.api_gateway.hosts.fhir}/v1/fhir/" else "#{Settings.mhv.medical_records.host}/fhir/" end @@ -217,9 +217,9 @@ def fhir_search(fhir_model, params) # @return [FHIR::ClientReply] # def fhir_search_query(fhir_model, params) - default_headers = { 'Cache-Control': 'no-cache' } + default_headers = { 'Cache-Control' => 'no-cache' } if Flipper.enabled?(:mhv_medical_records_migrate_to_api_gateway) - default_headers.merge('x-api-key' => Settings.mhv.medical_records.x_api_key) + default_headers = default_headers.merge('x-api-key' => Settings.mhv.medical_records.x_api_key) end params[:headers] = default_headers.merge(params.fetch(:headers, {})) @@ -234,7 +234,7 @@ def fhir_search_query(fhir_model, params) def fhir_read(fhir_model, id) default_headers = {} if Flipper.enabled?(:mhv_medical_records_migrate_to_api_gateway) - default_headers.merge!('x-api-key' => Settings.mhv.medical_records.x_api_key) + default_headers = default_headers.merge('x-api-key' => Settings.mhv.medical_records.x_api_key) end result = fhir_client.read(fhir_model, id, nil, nil, { headers: default_headers }) From 84d83dc9ade5efbd5c8e2ddee0c853852947671b Mon Sep 17 00:00:00 2001 From: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Date: Thu, 20 Mar 2025 13:34:36 -0400 Subject: [PATCH 05/30] MHV-68159 More header fixes --- lib/common/client/concerns/mhv_jwt_session_client.rb | 6 +++++- lib/medical_records/client.rb | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/common/client/concerns/mhv_jwt_session_client.rb b/lib/common/client/concerns/mhv_jwt_session_client.rb index 6c8e9b397c8..0dc66f1d507 100644 --- a/lib/common/client/concerns/mhv_jwt_session_client.rb +++ b/lib/common/client/concerns/mhv_jwt_session_client.rb @@ -49,7 +49,11 @@ def get_session def get_jwt_from_headers(res_headers) # Get the JWT token from the headers - auth_header = res_headers['authorization'] + auth_header = if Flipper.enabled?(:mhv_medical_records_migrate_to_api_gateway) + res_headers['x-amzn-remapped-authorization'] + else + res_headers['authorization'] + end if auth_header.nil? || !auth_header.start_with?('Bearer ') raise Common::Exceptions::Unauthorized, detail: 'Invalid or missing authorization header' end diff --git a/lib/medical_records/client.rb b/lib/medical_records/client.rb index 146c3556dc5..4cf64cb2c72 100644 --- a/lib/medical_records/client.rb +++ b/lib/medical_records/client.rb @@ -82,9 +82,14 @@ def fhir_client end def get_patient_by_identifier(fhir_client, identifier) + default_headers = { 'Cache-Control' => 'no-cache' } + if Flipper.enabled?(:mhv_medical_records_migrate_to_api_gateway) + default_headers = default_headers.merge('x-api-key' => Settings.mhv.medical_records.x_api_key) + end + result = fhir_client.search(FHIR::Patient, { search: { parameters: { identifier: } }, - headers: { 'Cache-Control': 'no-cache' } + headers: default_headers }) # MHV will return a 202 if and only if the patient does not exist. It will not return 202 for From abeee7e22c434c7844a1b419a32c9cc85d0db371 Mon Sep 17 00:00:00 2001 From: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Date: Thu, 20 Mar 2025 14:21:45 -0400 Subject: [PATCH 06/30] MHV-68159 Updated some specs/cassettes --- .../spec/requests/my_health/v1/medical_records/vaccines_spec.rb | 1 + .../support/vcr_cassettes/mr_client/get_a_list_of_allergies.yml | 2 +- .../vcr_cassettes/mr_client/get_a_list_of_chemhem_labs.yml | 2 +- .../vcr_cassettes/mr_client/get_a_list_of_clinical_notes.yml | 2 +- .../vcr_cassettes/mr_client/get_a_list_of_diagreport_labs.yml | 2 +- .../vcr_cassettes/mr_client/get_a_list_of_docref_labs.yml | 2 +- .../vcr_cassettes/mr_client/get_a_list_of_health_conditions.yml | 2 +- .../mr_client/get_a_list_of_health_conditions_error.yml | 2 +- .../vcr_cassettes/mr_client/get_a_list_of_labs_and_tests.yml | 2 +- spec/support/vcr_cassettes/mr_client/get_a_list_of_vaccines.yml | 2 +- spec/support/vcr_cassettes/mr_client/get_a_list_of_vitals.yml | 2 +- .../vcr_cassettes/mr_client/get_full_list_of_labs_and_tests.yml | 2 +- .../support/vcr_cassettes/mr_client/get_multiple_fhir_pages.yml | 2 +- 13 files changed, 13 insertions(+), 12 deletions(-) diff --git a/modules/my_health/spec/requests/my_health/v1/medical_records/vaccines_spec.rb b/modules/my_health/spec/requests/my_health/v1/medical_records/vaccines_spec.rb index 01c8f6352c6..16e96db6ea4 100644 --- a/modules/my_health/spec/requests/my_health/v1/medical_records/vaccines_spec.rb +++ b/modules/my_health/spec/requests/my_health/v1/medical_records/vaccines_spec.rb @@ -15,6 +15,7 @@ let(:current_user) { build(:user, :mhv, va_patient:, mhv_account_type:) } before do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) allow(MedicalRecords::Client).to receive(:new).and_return(authenticated_client) allow(BBInternal::Client).to receive(:new).and_return(authenticated_client) sign_in_as(current_user) diff --git a/spec/support/vcr_cassettes/mr_client/get_a_list_of_allergies.yml b/spec/support/vcr_cassettes/mr_client/get_a_list_of_allergies.yml index 8484c229add..64da218bde4 100644 --- a/spec/support/vcr_cassettes/mr_client/get_a_list_of_allergies.yml +++ b/spec/support/vcr_cassettes/mr_client/get_a_list_of_allergies.yml @@ -2,7 +2,7 @@ http_interactions: - request: method: get - uri: "/fhir/AllergyIntolerance?_count=9999&clinical-status=active&patient=2952&verification-status:not=entered-in-error" + uri: "/fhir/AllergyIntolerance?_count=3000&clinical-status=active&patient=2952&verification-status:not=entered-in-error" body: encoding: US-ASCII string: "" diff --git a/spec/support/vcr_cassettes/mr_client/get_a_list_of_chemhem_labs.yml b/spec/support/vcr_cassettes/mr_client/get_a_list_of_chemhem_labs.yml index f3b0486c49e..d1e8e7bd8ae 100644 --- a/spec/support/vcr_cassettes/mr_client/get_a_list_of_chemhem_labs.yml +++ b/spec/support/vcr_cassettes/mr_client/get_a_list_of_chemhem_labs.yml @@ -2,7 +2,7 @@ http_interactions: - request: method: get - uri: "/fhir/DiagnosticReport?_count=9999&patient=2952&status:not=entered-in-error" + uri: "/fhir/DiagnosticReport?_count=3000&patient=2952&status:not=entered-in-error" body: encoding: US-ASCII string: "" diff --git a/spec/support/vcr_cassettes/mr_client/get_a_list_of_clinical_notes.yml b/spec/support/vcr_cassettes/mr_client/get_a_list_of_clinical_notes.yml index 06e348cdd05..310e693d3dc 100644 --- a/spec/support/vcr_cassettes/mr_client/get_a_list_of_clinical_notes.yml +++ b/spec/support/vcr_cassettes/mr_client/get_a_list_of_clinical_notes.yml @@ -2,7 +2,7 @@ http_interactions: - request: method: get - uri: "/fhir/DocumentReference?_count=9999&patient=2952&status:not=entered-in-error&type=11506-3,18842-5,11488-4" + uri: "/fhir/DocumentReference?_count=3000&patient=2952&status:not=entered-in-error&type=11506-3,18842-5,11488-4" body: encoding: US-ASCII string: "" diff --git a/spec/support/vcr_cassettes/mr_client/get_a_list_of_diagreport_labs.yml b/spec/support/vcr_cassettes/mr_client/get_a_list_of_diagreport_labs.yml index 5f7ea0496d4..29f40974115 100644 --- a/spec/support/vcr_cassettes/mr_client/get_a_list_of_diagreport_labs.yml +++ b/spec/support/vcr_cassettes/mr_client/get_a_list_of_diagreport_labs.yml @@ -2,7 +2,7 @@ http_interactions: - request: method: get - uri: "/fhir/DiagnosticReport?_count=9999&code=79381-0,60567-5&patient=2952&status:not=entered-in-error" + uri: "/fhir/DiagnosticReport?_count=3000&code=79381-0,60567-5&patient=2952&status:not=entered-in-error" body: encoding: US-ASCII string: "" diff --git a/spec/support/vcr_cassettes/mr_client/get_a_list_of_docref_labs.yml b/spec/support/vcr_cassettes/mr_client/get_a_list_of_docref_labs.yml index 8762077bcd0..3ab9ed3bd58 100644 --- a/spec/support/vcr_cassettes/mr_client/get_a_list_of_docref_labs.yml +++ b/spec/support/vcr_cassettes/mr_client/get_a_list_of_docref_labs.yml @@ -2,7 +2,7 @@ http_interactions: - request: method: get - uri: "/fhir/DocumentReference?_count=9999&patient=2952&status:not=entered-in-error&type=11524-6,18748-4" + uri: "/fhir/DocumentReference?_count=3000&patient=2952&status:not=entered-in-error&type=11524-6,18748-4" body: encoding: US-ASCII string: "" diff --git a/spec/support/vcr_cassettes/mr_client/get_a_list_of_health_conditions.yml b/spec/support/vcr_cassettes/mr_client/get_a_list_of_health_conditions.yml index f6a562fa4e9..c76b46cdfee 100644 --- a/spec/support/vcr_cassettes/mr_client/get_a_list_of_health_conditions.yml +++ b/spec/support/vcr_cassettes/mr_client/get_a_list_of_health_conditions.yml @@ -2,7 +2,7 @@ http_interactions: - request: method: get - uri: "/fhir/Condition?_count=9999&patient=2952&verification-status:not=entered-in-error" + uri: "/fhir/Condition?_count=3000&patient=2952&verification-status:not=entered-in-error" body: encoding: US-ASCII string: "" diff --git a/spec/support/vcr_cassettes/mr_client/get_a_list_of_health_conditions_error.yml b/spec/support/vcr_cassettes/mr_client/get_a_list_of_health_conditions_error.yml index 52ce1b9e756..00458c4b5eb 100644 --- a/spec/support/vcr_cassettes/mr_client/get_a_list_of_health_conditions_error.yml +++ b/spec/support/vcr_cassettes/mr_client/get_a_list_of_health_conditions_error.yml @@ -2,7 +2,7 @@ http_interactions: - request: method: get - uri: "/fhir/Condition?_count=9999&patient=39254&verification-status:not=entered-in-error" + uri: "/fhir/Condition?_count=3000&patient=39254&verification-status:not=entered-in-error" body: encoding: US-ASCII string: "" diff --git a/spec/support/vcr_cassettes/mr_client/get_a_list_of_labs_and_tests.yml b/spec/support/vcr_cassettes/mr_client/get_a_list_of_labs_and_tests.yml index 21c311ecda8..820b3a6b838 100644 --- a/spec/support/vcr_cassettes/mr_client/get_a_list_of_labs_and_tests.yml +++ b/spec/support/vcr_cassettes/mr_client/get_a_list_of_labs_and_tests.yml @@ -2,7 +2,7 @@ http_interactions: - request: method: get - uri: "/fhir/DiagnosticReport?_count=9999&category=LAB&patient=258974&status:not=entered-in-error" + uri: "/fhir/DiagnosticReport?_count=3000&category=LAB&patient=258974&status:not=entered-in-error" body: encoding: US-ASCII string: "" diff --git a/spec/support/vcr_cassettes/mr_client/get_a_list_of_vaccines.yml b/spec/support/vcr_cassettes/mr_client/get_a_list_of_vaccines.yml index f08d959b0f0..179694957e7 100644 --- a/spec/support/vcr_cassettes/mr_client/get_a_list_of_vaccines.yml +++ b/spec/support/vcr_cassettes/mr_client/get_a_list_of_vaccines.yml @@ -2,7 +2,7 @@ http_interactions: - request: method: get - uri: "/fhir/Immunization?_count=9999&patient=2952&status:not=entered-in-error" + uri: "/fhir/Immunization?_count=3000&patient=2952&status:not=entered-in-error" body: encoding: US-ASCII string: "" diff --git a/spec/support/vcr_cassettes/mr_client/get_a_list_of_vitals.yml b/spec/support/vcr_cassettes/mr_client/get_a_list_of_vitals.yml index f66367c1003..175fac24037 100644 --- a/spec/support/vcr_cassettes/mr_client/get_a_list_of_vitals.yml +++ b/spec/support/vcr_cassettes/mr_client/get_a_list_of_vitals.yml @@ -2,7 +2,7 @@ http_interactions: - request: method: get - uri: "/fhir/Observation?_count=9999&category=vital-signs&patient=2952&status:not=entered-in-error" + uri: "/fhir/Observation?_count=3000&category=vital-signs&patient=2952&status:not=entered-in-error" body: encoding: US-ASCII string: "" diff --git a/spec/support/vcr_cassettes/mr_client/get_full_list_of_labs_and_tests.yml b/spec/support/vcr_cassettes/mr_client/get_full_list_of_labs_and_tests.yml index 623a78dc92d..6191d0b6d11 100644 --- a/spec/support/vcr_cassettes/mr_client/get_full_list_of_labs_and_tests.yml +++ b/spec/support/vcr_cassettes/mr_client/get_full_list_of_labs_and_tests.yml @@ -2,7 +2,7 @@ http_interactions: - request: method: get - uri: "/fhir/DiagnosticReport?_count=9999&category=LAB&patient=49006&status:not=entered-in-error" + uri: "/fhir/DiagnosticReport?_count=3000&category=LAB&patient=49006&status:not=entered-in-error" body: encoding: US-ASCII string: "" diff --git a/spec/support/vcr_cassettes/mr_client/get_multiple_fhir_pages.yml b/spec/support/vcr_cassettes/mr_client/get_multiple_fhir_pages.yml index 8cc2d0876b1..56c24bb9264 100644 --- a/spec/support/vcr_cassettes/mr_client/get_multiple_fhir_pages.yml +++ b/spec/support/vcr_cassettes/mr_client/get_multiple_fhir_pages.yml @@ -2,7 +2,7 @@ http_interactions: - request: method: get - uri: "/fhir/AllergyIntolerance?_count=9999&clinical-status=active&patient=2952&verification-status:not=entered-in-error" + uri: "/fhir/AllergyIntolerance?_count=3000&clinical-status=active&patient=2952&verification-status:not=entered-in-error" body: encoding: US-ASCII string: "" From e14d34389be7e067258f94c160b7f9e883f6bd20 Mon Sep 17 00:00:00 2001 From: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Date: Thu, 20 Mar 2025 14:42:35 -0400 Subject: [PATCH 07/30] MHV-68159 Spec updates --- .../spec/requests/my_health/v1/medical_records/allergies_spec.rb | 1 + .../requests/my_health/v1/medical_records/clinical_notes_spec.rb | 1 + .../requests/my_health/v1/medical_records/conditions_spec.rb | 1 + .../spec/requests/my_health/v1/medical_records/imaging_spec.rb | 1 + .../requests/my_health/v1/medical_records/labs_and_tests_spec.rb | 1 + .../spec/requests/my_health/v1/medical_records/radiology_spec.rb | 1 + .../spec/requests/my_health/v1/medical_records/session_spec.rb | 1 + .../spec/requests/my_health/v1/medical_records/vitals_spec.rb | 1 + 8 files changed, 8 insertions(+) diff --git a/modules/my_health/spec/requests/my_health/v1/medical_records/allergies_spec.rb b/modules/my_health/spec/requests/my_health/v1/medical_records/allergies_spec.rb index 793670bf644..abd51332ea0 100644 --- a/modules/my_health/spec/requests/my_health/v1/medical_records/allergies_spec.rb +++ b/modules/my_health/spec/requests/my_health/v1/medical_records/allergies_spec.rb @@ -15,6 +15,7 @@ let(:current_user) { build(:user, :mhv, va_patient:, mhv_account_type:) } before do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) allow(MedicalRecords::Client).to receive(:new).and_return(authenticated_client) allow(BBInternal::Client).to receive(:new).and_return(authenticated_client) sign_in_as(current_user) diff --git a/modules/my_health/spec/requests/my_health/v1/medical_records/clinical_notes_spec.rb b/modules/my_health/spec/requests/my_health/v1/medical_records/clinical_notes_spec.rb index 683d52d42af..9b6f28db4fa 100644 --- a/modules/my_health/spec/requests/my_health/v1/medical_records/clinical_notes_spec.rb +++ b/modules/my_health/spec/requests/my_health/v1/medical_records/clinical_notes_spec.rb @@ -15,6 +15,7 @@ let(:current_user) { build(:user, :mhv, va_patient:, mhv_account_type:) } before do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) allow(MedicalRecords::Client).to receive(:new).and_return(authenticated_client) allow(BBInternal::Client).to receive(:new).and_return(authenticated_client) sign_in_as(current_user) diff --git a/modules/my_health/spec/requests/my_health/v1/medical_records/conditions_spec.rb b/modules/my_health/spec/requests/my_health/v1/medical_records/conditions_spec.rb index 54bca6cbdd3..a94fd3ab314 100644 --- a/modules/my_health/spec/requests/my_health/v1/medical_records/conditions_spec.rb +++ b/modules/my_health/spec/requests/my_health/v1/medical_records/conditions_spec.rb @@ -15,6 +15,7 @@ let(:current_user) { build(:user, :mhv, va_patient:, mhv_account_type:) } before do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) allow(MedicalRecords::Client).to receive(:new).and_return(authenticated_client) allow(BBInternal::Client).to receive(:new).and_return(authenticated_client) sign_in_as(current_user) diff --git a/modules/my_health/spec/requests/my_health/v1/medical_records/imaging_spec.rb b/modules/my_health/spec/requests/my_health/v1/medical_records/imaging_spec.rb index 8d3d9831856..aa67c9b32f2 100644 --- a/modules/my_health/spec/requests/my_health/v1/medical_records/imaging_spec.rb +++ b/modules/my_health/spec/requests/my_health/v1/medical_records/imaging_spec.rb @@ -16,6 +16,7 @@ let(:study_id) { '453-2487448' } before do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) bb_internal_client = BBInternal::Client.new( session: { user_id: 11_375_034, diff --git a/modules/my_health/spec/requests/my_health/v1/medical_records/labs_and_tests_spec.rb b/modules/my_health/spec/requests/my_health/v1/medical_records/labs_and_tests_spec.rb index e3da9711030..3e069c96b77 100644 --- a/modules/my_health/spec/requests/my_health/v1/medical_records/labs_and_tests_spec.rb +++ b/modules/my_health/spec/requests/my_health/v1/medical_records/labs_and_tests_spec.rb @@ -15,6 +15,7 @@ let(:current_user) { build(:user, :mhv, va_patient:, mhv_account_type:) } before do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) allow(MedicalRecords::Client).to receive(:new).and_return(authenticated_client) allow(BBInternal::Client).to receive(:new).and_return(authenticated_client) sign_in_as(current_user) diff --git a/modules/my_health/spec/requests/my_health/v1/medical_records/radiology_spec.rb b/modules/my_health/spec/requests/my_health/v1/medical_records/radiology_spec.rb index fa0ed38e27b..3a1fde74b0b 100644 --- a/modules/my_health/spec/requests/my_health/v1/medical_records/radiology_spec.rb +++ b/modules/my_health/spec/requests/my_health/v1/medical_records/radiology_spec.rb @@ -14,6 +14,7 @@ let(:current_user) { build(:user, :mhv, va_patient:, mhv_account_type:) } before do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) bb_internal_client = BBInternal::Client.new( session: { user_id: 11_375_034, diff --git a/modules/my_health/spec/requests/my_health/v1/medical_records/session_spec.rb b/modules/my_health/spec/requests/my_health/v1/medical_records/session_spec.rb index 4315284c394..da6ad9896bf 100644 --- a/modules/my_health/spec/requests/my_health/v1/medical_records/session_spec.rb +++ b/modules/my_health/spec/requests/my_health/v1/medical_records/session_spec.rb @@ -15,6 +15,7 @@ let(:current_user) { build(:user, :mhv, va_patient:, mhv_account_type:) } before do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) allow(MedicalRecords::Client).to receive(:new).and_return(authenticated_client) allow(BBInternal::Client).to receive(:new).and_return(authenticated_client) allow(PHRMgr::Client).to receive(:new).and_return(PHRMgr::Client.new(12_345)) diff --git a/modules/my_health/spec/requests/my_health/v1/medical_records/vitals_spec.rb b/modules/my_health/spec/requests/my_health/v1/medical_records/vitals_spec.rb index d32d7891524..e585d32b162 100644 --- a/modules/my_health/spec/requests/my_health/v1/medical_records/vitals_spec.rb +++ b/modules/my_health/spec/requests/my_health/v1/medical_records/vitals_spec.rb @@ -15,6 +15,7 @@ let(:current_user) { build(:user, :mhv, va_patient:, mhv_account_type:) } before do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) allow(MedicalRecords::Client).to receive(:new).and_return(authenticated_client) allow(BBInternal::Client).to receive(:new).and_return(authenticated_client) sign_in_as(current_user) From 3cd7906ff104a9d28905fbfaa389beb8e2d8a5da Mon Sep 17 00:00:00 2001 From: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Date: Thu, 20 Mar 2025 15:09:06 -0400 Subject: [PATCH 08/30] MHV-68159 Updates to fix MR client_spec tests --- spec/lib/medical_records/bb_internal/client_spec.rb | 5 +++++ spec/lib/medical_records/client_spec.rb | 5 +++++ spec/lib/medical_records/phr_mgr/client_spec.rb | 8 ++++++++ 3 files changed, 18 insertions(+) diff --git a/spec/lib/medical_records/bb_internal/client_spec.rb b/spec/lib/medical_records/bb_internal/client_spec.rb index 843e1d515c0..686da852354 100644 --- a/spec/lib/medical_records/bb_internal/client_spec.rb +++ b/spec/lib/medical_records/bb_internal/client_spec.rb @@ -8,6 +8,11 @@ describe BBInternal::Client do before(:all) do + VCR.configure do |vcr_config| + vcr_config.default_cassette_options = { + allow_playback_repeats: true + } + end VCR.use_cassette 'mr_client/bb_internal/session_auth' do @client ||= begin client = BBInternal::Client.new(session: { user_id: '11375034', icn: '1012740022V620959' }) diff --git a/spec/lib/medical_records/client_spec.rb b/spec/lib/medical_records/client_spec.rb index e41846288f9..8534d521e0f 100644 --- a/spec/lib/medical_records/client_spec.rb +++ b/spec/lib/medical_records/client_spec.rb @@ -7,6 +7,11 @@ describe MedicalRecords::Client do context 'when a valid session exists', :vcr do before(:all) do + VCR.configure do |vcr_config| + vcr_config.default_cassette_options = { + allow_playback_repeats: true + } + end VCR.use_cassette('user_eligibility_client/perform_an_eligibility_check_for_premium_user', match_requests_on: %i[method sm_user_ignoring_path_param]) do VCR.use_cassette 'mr_client/session' do diff --git a/spec/lib/medical_records/phr_mgr/client_spec.rb b/spec/lib/medical_records/phr_mgr/client_spec.rb index 2986f309c24..4ba7a0cfa86 100644 --- a/spec/lib/medical_records/phr_mgr/client_spec.rb +++ b/spec/lib/medical_records/phr_mgr/client_spec.rb @@ -4,6 +4,14 @@ require 'medical_records/phr_mgr/client' describe PHRMgr::Client do + before(:all) do + VCR.configure do |vcr_config| + vcr_config.default_cassette_options = { + allow_playback_repeats: true + } + end + end + describe 'PHR operations', :vcr do context 'when ICN is valid' do let(:icn) { '1000000000V000000' } From 3d58bc3696b29ec9667d865429c59d5b2218b760 Mon Sep 17 00:00:00 2001 From: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Date: Thu, 20 Mar 2025 15:48:46 -0400 Subject: [PATCH 09/30] MHV-68159 Attempting to get spec tests to pass in PR --- spec/lib/medical_records/bb_internal/client_spec.rb | 5 +++++ spec/lib/medical_records/client_spec.rb | 2 ++ spec/lib/medical_records/phr_mgr/client_spec.rb | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/spec/lib/medical_records/bb_internal/client_spec.rb b/spec/lib/medical_records/bb_internal/client_spec.rb index 686da852354..1b61a937a67 100644 --- a/spec/lib/medical_records/bb_internal/client_spec.rb +++ b/spec/lib/medical_records/bb_internal/client_spec.rb @@ -14,6 +14,7 @@ } end VCR.use_cassette 'mr_client/bb_internal/session_auth' do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) @client ||= begin client = BBInternal::Client.new(session: { user_id: '11375034', icn: '1012740022V620959' }) client.authenticate @@ -22,6 +23,10 @@ end end + before do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + end + let(:client) { @client } RSpec.shared_context 'redis setup' do diff --git a/spec/lib/medical_records/client_spec.rb b/spec/lib/medical_records/client_spec.rb index 8534d521e0f..4d317cf39f6 100644 --- a/spec/lib/medical_records/client_spec.rb +++ b/spec/lib/medical_records/client_spec.rb @@ -16,6 +16,7 @@ match_requests_on: %i[method sm_user_ignoring_path_param]) do VCR.use_cassette 'mr_client/session' do VCR.use_cassette 'mr_client/get_a_patient_by_identifier' do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) @client ||= begin client = MedicalRecords::Client.new(session: { user_id: '22406991', icn: '1013868614V792025' }) client.authenticate @@ -27,6 +28,7 @@ end before do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) MedicalRecords::Client.send(:public, *MedicalRecords::Client.protected_instance_methods) # Redirect FHIR logger's output to the buffer before each test diff --git a/spec/lib/medical_records/phr_mgr/client_spec.rb b/spec/lib/medical_records/phr_mgr/client_spec.rb index 4ba7a0cfa86..e1d1cc2d5b9 100644 --- a/spec/lib/medical_records/phr_mgr/client_spec.rb +++ b/spec/lib/medical_records/phr_mgr/client_spec.rb @@ -12,6 +12,10 @@ end end + before do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + end + describe 'PHR operations', :vcr do context 'when ICN is valid' do let(:icn) { '1000000000V000000' } From 0b2666316f6589628f826222ed756e91982dfb96 Mon Sep 17 00:00:00 2001 From: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Date: Thu, 20 Mar 2025 16:04:25 -0400 Subject: [PATCH 10/30] MHV-68159 Spec fix --- .../lib/common/client/concerns/mhv_jwt_session_client_spec.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/lib/common/client/concerns/mhv_jwt_session_client_spec.rb b/spec/lib/common/client/concerns/mhv_jwt_session_client_spec.rb index 80e7cd79130..43ad349a862 100644 --- a/spec/lib/common/client/concerns/mhv_jwt_session_client_spec.rb +++ b/spec/lib/common/client/concerns/mhv_jwt_session_client_spec.rb @@ -5,6 +5,10 @@ require_relative '../../../../../lib/common/client/concerns/mhv_jwt_session_client' describe Common::Client::Concerns::MHVJwtSessionClient do + before do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + end + let(:dummy_class) do Class.new do include Common::Client::Concerns::MHVJwtSessionClient From cf5283a9ffe7e7df2ac92d4fa1501158216e2d3f Mon Sep 17 00:00:00 2001 From: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Date: Thu, 20 Mar 2025 16:29:26 -0400 Subject: [PATCH 11/30] MHV-68159 spec fixes --- spec/lib/medical_records/client_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/lib/medical_records/client_spec.rb b/spec/lib/medical_records/client_spec.rb index 4d317cf39f6..05fc1ee787b 100644 --- a/spec/lib/medical_records/client_spec.rb +++ b/spec/lib/medical_records/client_spec.rb @@ -462,6 +462,7 @@ match_requests_on: %i[method sm_user_ignoring_path_param]) do VCR.use_cassette 'mr_client/session' do VCR.use_cassette 'mr_client/get_a_patient_by_identifier_hapi_1363' do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) partial_client ||= begin partial_client = MedicalRecords::Client.new(session: { user_id: '22406991', icn: '1013868614V792025' }) @@ -482,6 +483,7 @@ match_requests_on: %i[method sm_user_ignoring_path_param]) do VCR.use_cassette 'mr_client/session' do VCR.use_cassette 'mr_client/get_a_patient_by_identifier_not_found' do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) partial_client ||= begin partial_client = MedicalRecords::Client.new(session: { user_id: '22406991', icn: '1013868614V792025' }) From e270e9226ad0200393aeb1e2db447011ca4605fa Mon Sep 17 00:00:00 2001 From: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Date: Thu, 20 Mar 2025 16:45:45 -0400 Subject: [PATCH 12/30] MHV-68159 Fixed a linter error --- lib/medical_records/bb_internal/client.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/medical_records/bb_internal/client.rb b/lib/medical_records/bb_internal/client.rb index b17bc352e96..3b935107c46 100644 --- a/lib/medical_records/bb_internal/client.rb +++ b/lib/medical_records/bb_internal/client.rb @@ -95,8 +95,10 @@ def request_study(id) study_id = get_study_id_from_cache(id) # Perform the API call with the original studyIdUrn - response = perform(:get, "bluebutton/studyjob/#{session.patient_id}/icn/#{session.icn}/studyid/#{study_id}", nil, - token_headers) + response = perform( + :get, "bluebutton/studyjob/#{session.patient_id}/icn/#{session.icn}/studyid/#{study_id}", nil, + token_headers + ) data = response.body # Transform the response to replace the studyIdUrn with the UUID @@ -116,8 +118,10 @@ def request_study(id) def list_images(id) with_custom_base_path(BLUEBUTTON_BASE_PATH) do study_id = get_study_id_from_cache(id) - response = perform(:get, "bluebutton/studyjob/zip/preview/list/#{session.patient_id}/studyidUrn/#{study_id}", nil, - token_headers) + response = perform( + :get, "bluebutton/studyjob/zip/preview/list/#{session.patient_id}/studyidUrn/#{study_id}", nil, + token_headers + ) response.body end end From 7310138d25eebc840cb1e699ebda520ff62f164c Mon Sep 17 00:00:00 2001 From: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Date: Fri, 21 Mar 2025 12:21:40 -0400 Subject: [PATCH 13/30] MHV-68159 Converted bb client to use API Gateway --- lib/bb/client.rb | 51 ++++++++++++++++++++++++++++++++------ lib/bb/configuration.rb | 18 +++++++++++++- spec/lib/bb/client_spec.rb | 10 ++++++++ 3 files changed, 71 insertions(+), 8 deletions(-) diff --git a/lib/bb/client.rb b/lib/bb/client.rb index 1be4e05a6db..4ac5d2b3953 100644 --- a/lib/bb/client.rb +++ b/lib/bb/client.rb @@ -21,6 +21,10 @@ class Client < Common::Client::Base CACHE_TTL = 3600 * 3 # cache for 3 hours + LEGACY_BASE_PATH = "#{Settings.mhv.rx.host}/mhv-api/patient/v1".freeze + APIGW_BASE_PATH = "#{Settings.mhv.api_gateway.hosts.bluebutton}/v1/bluebutton".freeze + APIGW_AUTH_BASE_PATH = "#{Settings.mhv.api_gateway.hosts.bluebutton}/v1/usermgmt/auth".freeze + ## # PHR (Personal Health Record) refresh # @@ -29,7 +33,8 @@ class Client < Common::Client::Base # @return [Common::Collection] # def get_extract_status - json = perform(:get, 'bluebutton/extractstatus', nil, token_headers).body + _, prefix = base_path_and_prefix + json = perform(:get, "#{prefix}/extractstatus", nil, token_headers).body log_refresh_errors(json[:data]) if refresh_final?(json[:data]) Common::Collection.new(ExtractStatus, **json) end @@ -40,8 +45,9 @@ def get_extract_status # @return [Common::Collection] # def get_eligible_data_classes + _, prefix = base_path_and_prefix Common::Collection.fetch(::EligibleDataClass, cache_key: cache_key('geteligibledataclass'), ttl: CACHE_TTL) do - perform(:get, 'bluebutton/geteligibledataclass', nil, token_headers).body + perform(:get, "#{prefix}/geteligibledataclass", nil, token_headers).body end end @@ -58,7 +64,8 @@ def post_generate(params) form = BB::GenerateReportRequestForm.new(self, params) raise Common::Exceptions::ValidationErrors, form unless form.valid? - perform(:post, 'bluebutton/generate', form.params, token_headers).body + _, prefix = base_path_and_prefix + perform(:post, "#{prefix}/generate", form.params, token_headers).body end ## @@ -75,7 +82,8 @@ def get_download_report(doctype, header_callback, yielder) # TODO: For testing purposes, use one of the following static URIs: # uri = URI("#{Settings.mhv.rx.host}/vetsgov/1mb.file") # uri = URI("#{Settings.mhv.rx.host}/vetsgov/90mb.file") - uri = URI.join(config.base_path, "bluebutton/bbreport/#{doctype}") + base, prefix = base_path_and_prefix + uri = URI.join(config.base_path, "#{base}/#{prefix}/bbreport/#{doctype}") streaming_get(uri, token_headers, header_callback, yielder) end @@ -83,7 +91,9 @@ def get_download_report(doctype, header_callback, yielder) # Opt user in to VHIE sharing. # def post_opt_in - perform(:post, 'bluebutton/external/optinout/optin', nil, token_headers).body + base_path, = base_path_and_prefix + prefix = base_path == APIGW_BASE_PATH ? '' : 'bluebutton/external/' + perform(:post, "#{prefix}optinout/optin", nil, token_headers).body rescue ServiceException => e # Ignore the error that the user is already opted in to VHIE sharing. raise unless e.message.include? 'already.opted.in' @@ -93,7 +103,9 @@ def post_opt_in # Opt user out of VHIE sharing. # def post_opt_out - perform(:post, 'bluebutton/external/optinout/optout', nil, token_headers).body + base_path, = base_path_and_prefix + prefix = base_path == APIGW_BASE_PATH ? '' : 'bluebutton/external/' + perform(:post, "#{prefix}optinout/optout", nil, token_headers).body rescue ServiceException => e # Ignore the error that the user is already opted out of VHIE sharing. raise unless e.message.include? 'Opt-out consent policy is already set' @@ -105,11 +117,36 @@ def post_opt_out # @return [Hash] an object containing the body of the response # def get_status - perform(:get, 'bluebutton/external/optinout/status', nil, token_headers).body + base_path, = base_path_and_prefix + prefix = base_path == APIGW_BASE_PATH ? '' : 'bluebutton/external/' + perform(:get, "#{prefix}optinout/status", nil, token_headers).body end private + def base_path_and_prefix + if Flipper.enabled?(:mhv_medical_records_migrate_to_api_gateway) + BB::Configuration.custom_base_path = APIGW_BASE_PATH + [APIGW_BASE_PATH, 'ess'] + else + BB::Configuration.custom_base_path = LEGACY_BASE_PATH + [LEGACY_BASE_PATH, 'bluebutton'] + end + end + + def get_session_tagged + Sentry.set_tags(error: 'mhv_session') + BB::Configuration.custom_base_path = if Flipper.enabled?(:mhv_medical_records_migrate_to_api_gateway) + APIGW_AUTH_BASE_PATH + else + LEGACY_BASE_PATH + end + env = perform(:get, 'session', nil, auth_headers) + + Sentry.get_current_scope.tags.delete(:error) + env + end + def cache_key(action) return nil unless config.caching_enabled? return nil if session.user_id.blank? diff --git a/lib/bb/configuration.rb b/lib/bb/configuration.rb index 60f47e34b36..437bb2a60c4 100644 --- a/lib/bb/configuration.rb +++ b/lib/bb/configuration.rb @@ -14,6 +14,20 @@ module BB # HTTP client configuration for {BB::Client}, sets the token, base path and a service name for breakers and metrics # class Configuration < Common::Client::Configuration::REST + ## + # Setter for thread-local variable custom_base_path + # + def self.custom_base_path=(value) + Thread.current[:custom_base_path] = value + end + + ## + # Getter for thread-local variable custom_base_path + # + def self.custom_base_path + Thread.current[:custom_base_path] + end + ## # @return [String] Client token set in `settings.yml` via credstash # @@ -25,7 +39,9 @@ def app_token # @return [String] Base path for dependent URLs # def base_path - "#{Settings.mhv.rx.host}/mhv-api/patient/v1/" + # We can't use Flipper in this class due to a race condition with Breakers. So we will set + # the path in the client and use a thread-local variable here. + self.class.custom_base_path || "#{Settings.mhv.rx.host}/mhv-api/patient/v1/" end ## diff --git a/spec/lib/bb/client_spec.rb b/spec/lib/bb/client_spec.rb index f3b9df87b55..be47f3659ed 100644 --- a/spec/lib/bb/client_spec.rb +++ b/spec/lib/bb/client_spec.rb @@ -16,7 +16,13 @@ end before(:all) do + VCR.configure do |vcr_config| + vcr_config.default_cassette_options = { + allow_playback_repeats: true + } + end VCR.use_cassette 'bb_client/session' do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) @client ||= begin client = BB::Client.new(session: { user_id: '5751732' }) client.authenticate @@ -25,6 +31,10 @@ end end + before do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + end + let(:client) { @client } # Need to pull the last updated to determine the staleness / freshness of the data From 38bd7c246272b421953c7286362e31336b90df02 Mon Sep 17 00:00:00 2001 From: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Date: Fri, 21 Mar 2025 12:25:39 -0400 Subject: [PATCH 14/30] Reverting unrelated change -- will do in another PR --- lib/medical_records/client.rb | 2 +- .../support/vcr_cassettes/mr_client/get_a_list_of_allergies.yml | 2 +- .../vcr_cassettes/mr_client/get_a_list_of_chemhem_labs.yml | 2 +- .../vcr_cassettes/mr_client/get_a_list_of_clinical_notes.yml | 2 +- .../vcr_cassettes/mr_client/get_a_list_of_diagreport_labs.yml | 2 +- .../vcr_cassettes/mr_client/get_a_list_of_docref_labs.yml | 2 +- .../vcr_cassettes/mr_client/get_a_list_of_health_conditions.yml | 2 +- .../mr_client/get_a_list_of_health_conditions_error.yml | 2 +- .../vcr_cassettes/mr_client/get_a_list_of_labs_and_tests.yml | 2 +- spec/support/vcr_cassettes/mr_client/get_a_list_of_vaccines.yml | 2 +- spec/support/vcr_cassettes/mr_client/get_a_list_of_vitals.yml | 2 +- .../vcr_cassettes/mr_client/get_full_list_of_labs_and_tests.yml | 2 +- .../support/vcr_cassettes/mr_client/get_multiple_fhir_pages.yml | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/medical_records/client.rb b/lib/medical_records/client.rb index 4cf64cb2c72..ca8ae431f04 100644 --- a/lib/medical_records/client.rb +++ b/lib/medical_records/client.rb @@ -14,7 +14,7 @@ class Client < Common::Client::Base include Common::Client::Concerns::MhvFhirSessionClient # Default number of records to request per call when searching - DEFAULT_COUNT = 3000 + DEFAULT_COUNT = 9999 # LOINC codes for clinical notes PHYSICIAN_PROCEDURE_NOTE = '11506-3' # Physician procedure note diff --git a/spec/support/vcr_cassettes/mr_client/get_a_list_of_allergies.yml b/spec/support/vcr_cassettes/mr_client/get_a_list_of_allergies.yml index 64da218bde4..8484c229add 100644 --- a/spec/support/vcr_cassettes/mr_client/get_a_list_of_allergies.yml +++ b/spec/support/vcr_cassettes/mr_client/get_a_list_of_allergies.yml @@ -2,7 +2,7 @@ http_interactions: - request: method: get - uri: "/fhir/AllergyIntolerance?_count=3000&clinical-status=active&patient=2952&verification-status:not=entered-in-error" + uri: "/fhir/AllergyIntolerance?_count=9999&clinical-status=active&patient=2952&verification-status:not=entered-in-error" body: encoding: US-ASCII string: "" diff --git a/spec/support/vcr_cassettes/mr_client/get_a_list_of_chemhem_labs.yml b/spec/support/vcr_cassettes/mr_client/get_a_list_of_chemhem_labs.yml index d1e8e7bd8ae..f3b0486c49e 100644 --- a/spec/support/vcr_cassettes/mr_client/get_a_list_of_chemhem_labs.yml +++ b/spec/support/vcr_cassettes/mr_client/get_a_list_of_chemhem_labs.yml @@ -2,7 +2,7 @@ http_interactions: - request: method: get - uri: "/fhir/DiagnosticReport?_count=3000&patient=2952&status:not=entered-in-error" + uri: "/fhir/DiagnosticReport?_count=9999&patient=2952&status:not=entered-in-error" body: encoding: US-ASCII string: "" diff --git a/spec/support/vcr_cassettes/mr_client/get_a_list_of_clinical_notes.yml b/spec/support/vcr_cassettes/mr_client/get_a_list_of_clinical_notes.yml index 310e693d3dc..06e348cdd05 100644 --- a/spec/support/vcr_cassettes/mr_client/get_a_list_of_clinical_notes.yml +++ b/spec/support/vcr_cassettes/mr_client/get_a_list_of_clinical_notes.yml @@ -2,7 +2,7 @@ http_interactions: - request: method: get - uri: "/fhir/DocumentReference?_count=3000&patient=2952&status:not=entered-in-error&type=11506-3,18842-5,11488-4" + uri: "/fhir/DocumentReference?_count=9999&patient=2952&status:not=entered-in-error&type=11506-3,18842-5,11488-4" body: encoding: US-ASCII string: "" diff --git a/spec/support/vcr_cassettes/mr_client/get_a_list_of_diagreport_labs.yml b/spec/support/vcr_cassettes/mr_client/get_a_list_of_diagreport_labs.yml index 29f40974115..5f7ea0496d4 100644 --- a/spec/support/vcr_cassettes/mr_client/get_a_list_of_diagreport_labs.yml +++ b/spec/support/vcr_cassettes/mr_client/get_a_list_of_diagreport_labs.yml @@ -2,7 +2,7 @@ http_interactions: - request: method: get - uri: "/fhir/DiagnosticReport?_count=3000&code=79381-0,60567-5&patient=2952&status:not=entered-in-error" + uri: "/fhir/DiagnosticReport?_count=9999&code=79381-0,60567-5&patient=2952&status:not=entered-in-error" body: encoding: US-ASCII string: "" diff --git a/spec/support/vcr_cassettes/mr_client/get_a_list_of_docref_labs.yml b/spec/support/vcr_cassettes/mr_client/get_a_list_of_docref_labs.yml index 3ab9ed3bd58..8762077bcd0 100644 --- a/spec/support/vcr_cassettes/mr_client/get_a_list_of_docref_labs.yml +++ b/spec/support/vcr_cassettes/mr_client/get_a_list_of_docref_labs.yml @@ -2,7 +2,7 @@ http_interactions: - request: method: get - uri: "/fhir/DocumentReference?_count=3000&patient=2952&status:not=entered-in-error&type=11524-6,18748-4" + uri: "/fhir/DocumentReference?_count=9999&patient=2952&status:not=entered-in-error&type=11524-6,18748-4" body: encoding: US-ASCII string: "" diff --git a/spec/support/vcr_cassettes/mr_client/get_a_list_of_health_conditions.yml b/spec/support/vcr_cassettes/mr_client/get_a_list_of_health_conditions.yml index c76b46cdfee..f6a562fa4e9 100644 --- a/spec/support/vcr_cassettes/mr_client/get_a_list_of_health_conditions.yml +++ b/spec/support/vcr_cassettes/mr_client/get_a_list_of_health_conditions.yml @@ -2,7 +2,7 @@ http_interactions: - request: method: get - uri: "/fhir/Condition?_count=3000&patient=2952&verification-status:not=entered-in-error" + uri: "/fhir/Condition?_count=9999&patient=2952&verification-status:not=entered-in-error" body: encoding: US-ASCII string: "" diff --git a/spec/support/vcr_cassettes/mr_client/get_a_list_of_health_conditions_error.yml b/spec/support/vcr_cassettes/mr_client/get_a_list_of_health_conditions_error.yml index 00458c4b5eb..52ce1b9e756 100644 --- a/spec/support/vcr_cassettes/mr_client/get_a_list_of_health_conditions_error.yml +++ b/spec/support/vcr_cassettes/mr_client/get_a_list_of_health_conditions_error.yml @@ -2,7 +2,7 @@ http_interactions: - request: method: get - uri: "/fhir/Condition?_count=3000&patient=39254&verification-status:not=entered-in-error" + uri: "/fhir/Condition?_count=9999&patient=39254&verification-status:not=entered-in-error" body: encoding: US-ASCII string: "" diff --git a/spec/support/vcr_cassettes/mr_client/get_a_list_of_labs_and_tests.yml b/spec/support/vcr_cassettes/mr_client/get_a_list_of_labs_and_tests.yml index 820b3a6b838..21c311ecda8 100644 --- a/spec/support/vcr_cassettes/mr_client/get_a_list_of_labs_and_tests.yml +++ b/spec/support/vcr_cassettes/mr_client/get_a_list_of_labs_and_tests.yml @@ -2,7 +2,7 @@ http_interactions: - request: method: get - uri: "/fhir/DiagnosticReport?_count=3000&category=LAB&patient=258974&status:not=entered-in-error" + uri: "/fhir/DiagnosticReport?_count=9999&category=LAB&patient=258974&status:not=entered-in-error" body: encoding: US-ASCII string: "" diff --git a/spec/support/vcr_cassettes/mr_client/get_a_list_of_vaccines.yml b/spec/support/vcr_cassettes/mr_client/get_a_list_of_vaccines.yml index 179694957e7..f08d959b0f0 100644 --- a/spec/support/vcr_cassettes/mr_client/get_a_list_of_vaccines.yml +++ b/spec/support/vcr_cassettes/mr_client/get_a_list_of_vaccines.yml @@ -2,7 +2,7 @@ http_interactions: - request: method: get - uri: "/fhir/Immunization?_count=3000&patient=2952&status:not=entered-in-error" + uri: "/fhir/Immunization?_count=9999&patient=2952&status:not=entered-in-error" body: encoding: US-ASCII string: "" diff --git a/spec/support/vcr_cassettes/mr_client/get_a_list_of_vitals.yml b/spec/support/vcr_cassettes/mr_client/get_a_list_of_vitals.yml index 175fac24037..f66367c1003 100644 --- a/spec/support/vcr_cassettes/mr_client/get_a_list_of_vitals.yml +++ b/spec/support/vcr_cassettes/mr_client/get_a_list_of_vitals.yml @@ -2,7 +2,7 @@ http_interactions: - request: method: get - uri: "/fhir/Observation?_count=3000&category=vital-signs&patient=2952&status:not=entered-in-error" + uri: "/fhir/Observation?_count=9999&category=vital-signs&patient=2952&status:not=entered-in-error" body: encoding: US-ASCII string: "" diff --git a/spec/support/vcr_cassettes/mr_client/get_full_list_of_labs_and_tests.yml b/spec/support/vcr_cassettes/mr_client/get_full_list_of_labs_and_tests.yml index 6191d0b6d11..623a78dc92d 100644 --- a/spec/support/vcr_cassettes/mr_client/get_full_list_of_labs_and_tests.yml +++ b/spec/support/vcr_cassettes/mr_client/get_full_list_of_labs_and_tests.yml @@ -2,7 +2,7 @@ http_interactions: - request: method: get - uri: "/fhir/DiagnosticReport?_count=3000&category=LAB&patient=49006&status:not=entered-in-error" + uri: "/fhir/DiagnosticReport?_count=9999&category=LAB&patient=49006&status:not=entered-in-error" body: encoding: US-ASCII string: "" diff --git a/spec/support/vcr_cassettes/mr_client/get_multiple_fhir_pages.yml b/spec/support/vcr_cassettes/mr_client/get_multiple_fhir_pages.yml index 56c24bb9264..8cc2d0876b1 100644 --- a/spec/support/vcr_cassettes/mr_client/get_multiple_fhir_pages.yml +++ b/spec/support/vcr_cassettes/mr_client/get_multiple_fhir_pages.yml @@ -2,7 +2,7 @@ http_interactions: - request: method: get - uri: "/fhir/AllergyIntolerance?_count=3000&clinical-status=active&patient=2952&verification-status:not=entered-in-error" + uri: "/fhir/AllergyIntolerance?_count=9999&clinical-status=active&patient=2952&verification-status:not=entered-in-error" body: encoding: US-ASCII string: "" From 0a27b43606c40b45a6b288494dcc93f02991c3a1 Mon Sep 17 00:00:00 2001 From: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Date: Mon, 24 Mar 2025 09:50:49 -0400 Subject: [PATCH 15/30] MHV-68159 Updating tests --- spec/requests/v0/health_records_spec.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spec/requests/v0/health_records_spec.rb b/spec/requests/v0/health_records_spec.rb index 71d2b6ea511..29478578840 100644 --- a/spec/requests/v0/health_records_spec.rb +++ b/spec/requests/v0/health_records_spec.rb @@ -20,7 +20,16 @@ end let(:inflection_header) { { 'X-Key-Inflection' => 'camel' } } + before(:all) do + VCR.configure do |vcr_config| + vcr_config.default_cassette_options = { + allow_playback_repeats: true + } + end + end + before do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) allow(BB::Client).to receive(:new).and_return(authenticated_client) sign_in_as(current_user) end From 7fd4eb4b9a420986d45342d96dbc826c47d05589 Mon Sep 17 00:00:00 2001 From: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Date: Mon, 24 Mar 2025 10:22:35 -0400 Subject: [PATCH 16/30] MHV-68159 Fixed tests --- spec/lib/bb/generate_report_request_form_spec.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/spec/lib/bb/generate_report_request_form_spec.rb b/spec/lib/bb/generate_report_request_form_spec.rb index 0a01a61f0a4..842ea411cff 100644 --- a/spec/lib/bb/generate_report_request_form_spec.rb +++ b/spec/lib/bb/generate_report_request_form_spec.rb @@ -24,7 +24,18 @@ let(:attributes) { {} } - before { allow(subject).to receive(:eligible_data_classes).and_return(eligible_data_classes) } + before(:all) do + VCR.configure do |vcr_config| + vcr_config.default_cassette_options = { + allow_playback_repeats: true + } + end + end + + before do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + allow(subject).to receive(:eligible_data_classes).and_return(eligible_data_classes) + end context 'with null attributes' do it 'responds to params' do From b963bc07f43e68d7f1e24d61038c0969957be7a9 Mon Sep 17 00:00:00 2001 From: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Date: Mon, 24 Mar 2025 11:14:39 -0400 Subject: [PATCH 17/30] MHV-68159 Fixed tests --- spec/requests/swagger_spec.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spec/requests/swagger_spec.rb b/spec/requests/swagger_spec.rb index 8d10469d88a..f6e649c5379 100644 --- a/spec/requests/swagger_spec.rb +++ b/spec/requests/swagger_spec.rb @@ -1795,6 +1795,8 @@ describe 'show a report' do context 'successful calls' do it 'supports showing a report' do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + # Using mucked-up yml because apivore has a problem processing non-json responses VCR.use_cassette('bb_client/gets_a_text_report_for_apivore') do expect(subject).to validate(:get, '/v0/health_records', 200, @@ -1805,6 +1807,8 @@ context 'unsuccessful calls' do it 'handles a backend error' do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + VCR.use_cassette('bb_client/report_error_response') do expect(subject).to validate(:get, '/v0/health_records', 503, headers.merge('_query_string' => 'doc_type=txt')) @@ -1816,6 +1820,8 @@ describe 'create a report' do context 'successful calls' do it 'supports creating a report' do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + VCR.use_cassette('bb_client/generates_a_report') do expect(subject).to validate( :post, '/v0/health_records', 202, @@ -1860,6 +1866,8 @@ describe 'eligible data classes' do it 'supports retrieving eligible data classes' do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + VCR.use_cassette('bb_client/gets_a_list_of_eligible_data_classes') do expect(subject).to validate(:get, '/v0/health_records/eligible_data_classes', 200, headers) end @@ -1869,6 +1877,8 @@ describe 'refresh' do context 'successful calls' do it 'supports health records refresh' do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + VCR.use_cassette('bb_client/gets_a_list_of_extract_statuses') do expect(subject).to validate(:get, '/v0/health_records/refresh', 200, headers) end From 23a9c6dd0b3c05037c6b5834364e9d01c7fb5211 Mon Sep 17 00:00:00 2001 From: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Date: Mon, 24 Mar 2025 11:53:50 -0400 Subject: [PATCH 18/30] MHV-68149 Diagnosing test errors --- modules/check_in/spec/requests/check_in/v2/sessions_spec.rb | 4 ++++ .../spec/requests/v1/supplemental_claims_spec.rb | 2 ++ modules/decision_reviews/spec/sidekiq/form4142_submit_spec.rb | 2 ++ spec/services/mhv_account_type_service_spec.rb | 4 ++++ 4 files changed, 12 insertions(+) diff --git a/modules/check_in/spec/requests/check_in/v2/sessions_spec.rb b/modules/check_in/spec/requests/check_in/v2/sessions_spec.rb index 397bbae6541..bf7f89219ac 100644 --- a/modules/check_in/spec/requests/check_in/v2/sessions_spec.rb +++ b/modules/check_in/spec/requests/check_in/v2/sessions_spec.rb @@ -299,6 +299,10 @@ } end + before do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + end + context 'in session created using DOB' do let(:session_params_with_dob) do { diff --git a/modules/decision_reviews/spec/requests/v1/supplemental_claims_spec.rb b/modules/decision_reviews/spec/requests/v1/supplemental_claims_spec.rb index fb7c8917040..bedbb22ce96 100644 --- a/modules/decision_reviews/spec/requests/v1/supplemental_claims_spec.rb +++ b/modules/decision_reviews/spec/requests/v1/supplemental_claims_spec.rb @@ -173,6 +173,8 @@ def personal_information_logs end it 'creates a supplemental claim and queues and saves a 4142 form when 4142 info is provided' do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + VCR.use_cassette('decision_review/SC-CREATE-RESPONSE-WITH-4142-200_V1') do VCR.use_cassette('lighthouse/benefits_intake/200_lighthouse_intake_upload_location') do VCR.use_cassette('lighthouse/benefits_intake/200_lighthouse_intake_upload') do diff --git a/modules/decision_reviews/spec/sidekiq/form4142_submit_spec.rb b/modules/decision_reviews/spec/sidekiq/form4142_submit_spec.rb index c6de7ffb2f0..d40462645ca 100644 --- a/modules/decision_reviews/spec/sidekiq/form4142_submit_spec.rb +++ b/modules/decision_reviews/spec/sidekiq/form4142_submit_spec.rb @@ -64,6 +64,8 @@ end it 'generates a 4142 PDF and sends it to Lighthouse API' do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + VCR.use_cassette('lighthouse/benefits_intake/200_lighthouse_intake_upload_location') do VCR.use_cassette('lighthouse/benefits_intake/200_lighthouse_intake_upload') do expect do diff --git a/spec/services/mhv_account_type_service_spec.rb b/spec/services/mhv_account_type_service_spec.rb index cfaa0390f6d..4d66073159d 100644 --- a/spec/services/mhv_account_type_service_spec.rb +++ b/spec/services/mhv_account_type_service_spec.rb @@ -20,6 +20,10 @@ ) end + before do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + end + context 'no mhv_correlation_id' do let(:user) { instance_double(User, mhv_correlation_id: nil) } From 1f2d990368ca69e7ebbef1f5ad6df7151d71b23d Mon Sep 17 00:00:00 2001 From: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Date: Mon, 24 Mar 2025 12:13:10 -0400 Subject: [PATCH 19/30] MHV-68149 Reverting a change --- .../spec/requests/v1/supplemental_claims_spec.rb | 2 -- modules/decision_reviews/spec/sidekiq/form4142_submit_spec.rb | 2 -- 2 files changed, 4 deletions(-) diff --git a/modules/decision_reviews/spec/requests/v1/supplemental_claims_spec.rb b/modules/decision_reviews/spec/requests/v1/supplemental_claims_spec.rb index bedbb22ce96..fb7c8917040 100644 --- a/modules/decision_reviews/spec/requests/v1/supplemental_claims_spec.rb +++ b/modules/decision_reviews/spec/requests/v1/supplemental_claims_spec.rb @@ -173,8 +173,6 @@ def personal_information_logs end it 'creates a supplemental claim and queues and saves a 4142 form when 4142 info is provided' do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) - VCR.use_cassette('decision_review/SC-CREATE-RESPONSE-WITH-4142-200_V1') do VCR.use_cassette('lighthouse/benefits_intake/200_lighthouse_intake_upload_location') do VCR.use_cassette('lighthouse/benefits_intake/200_lighthouse_intake_upload') do diff --git a/modules/decision_reviews/spec/sidekiq/form4142_submit_spec.rb b/modules/decision_reviews/spec/sidekiq/form4142_submit_spec.rb index d40462645ca..c6de7ffb2f0 100644 --- a/modules/decision_reviews/spec/sidekiq/form4142_submit_spec.rb +++ b/modules/decision_reviews/spec/sidekiq/form4142_submit_spec.rb @@ -64,8 +64,6 @@ end it 'generates a 4142 PDF and sends it to Lighthouse API' do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) - VCR.use_cassette('lighthouse/benefits_intake/200_lighthouse_intake_upload_location') do VCR.use_cassette('lighthouse/benefits_intake/200_lighthouse_intake_upload') do expect do From 7b8a26a3d6abafc44b36580bb05eef5360283342 Mon Sep 17 00:00:00 2001 From: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Date: Mon, 24 Mar 2025 16:21:01 -0400 Subject: [PATCH 20/30] MHV-68149 Updated user eligibility and spec --- .../user_eligibility/configuration.rb | 17 ++++++++++++----- .../user_eligibility/client_spec.rb | 2 ++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/medical_records/user_eligibility/configuration.rb b/lib/medical_records/user_eligibility/configuration.rb index 58603056f9d..aea92bc2151 100644 --- a/lib/medical_records/user_eligibility/configuration.rb +++ b/lib/medical_records/user_eligibility/configuration.rb @@ -19,17 +19,24 @@ class Configuration < Common::Client::Configuration::REST # @return [String] Base path for dependent URLs # def base_path - "#{Settings.mhv.medical_records.host}/mhvapi/v1/usermgmt/usereligibility/" + if Flipper.enabled?(:mhv_medical_records_migrate_to_api_gateway) + "#{Settings.mhv.medical_records.host}/v1/usermgmt/usereligibility/" + else + "#{Settings.mhv.medical_records.host}/mhvapi/v1/usermgmt/usereligibility/" + end end ## # @return [Hash] Headers with x-api-key and RX appToken header values for dependent URLs # def x_headers - base_request_headers.merge({ - 'x-api-key': Settings.mhv.medical_records.mhv_x_api_key, - appToken: Settings.mhv.rx.app_token - }) + api_key = if Flipper.enabled?(:mhv_medical_records_migrate_to_api_gateway) + Settings.mhv.medical_records.x_auth_key + else + Settings.mhv.medical_records.mhv_x_auth_key + end + + base_request_headers.merge('x-api-key' => api_key, appToken: Settings.mhv.rx.app_token) end ## diff --git a/spec/lib/medical_records/user_eligibility/client_spec.rb b/spec/lib/medical_records/user_eligibility/client_spec.rb index 46cbd93a0a5..2ac9b95b80f 100644 --- a/spec/lib/medical_records/user_eligibility/client_spec.rb +++ b/spec/lib/medical_records/user_eligibility/client_spec.rb @@ -10,6 +10,8 @@ let(:client) { UserEligibility::Client.new(user_id, icn) } before do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_new_eligibility_check).and_return(true) end From 8d6722c84357a58c1c1bbd02ec050018ac27516f Mon Sep 17 00:00:00 2001 From: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Date: Mon, 24 Mar 2025 16:32:54 -0400 Subject: [PATCH 21/30] MHV-68149 Attempting to fix spec test --- spec/requests/v0/user_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/requests/v0/user_spec.rb b/spec/requests/v0/user_spec.rb index 581b2aa776b..c9d917bf63e 100644 --- a/spec/requests/v0/user_spec.rb +++ b/spec/requests/v0/user_spec.rb @@ -14,6 +14,8 @@ let!(:mhv_user_verification) { create(:mhv_user_verification, mhv_uuid: mhv_user.mhv_credential_uuid) } before do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + allow(SM::Client).to receive(:new).and_return(authenticated_client) allow_any_instance_of(MHVAccountTypeService).to receive(:mhv_account_type).and_return('Premium') create(:account, idme_uuid: mhv_user.uuid) From 0083bc35b443a5d192b1420ddd267557d7b78113 Mon Sep 17 00:00:00 2001 From: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Date: Mon, 24 Mar 2025 16:45:46 -0400 Subject: [PATCH 22/30] MHV-68149 Fix test --- spec/services/users/services_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/services/users/services_spec.rb b/spec/services/users/services_spec.rb index d93086c7ebb..9ed7a473ad2 100644 --- a/spec/services/users/services_spec.rb +++ b/spec/services/users/services_spec.rb @@ -71,6 +71,8 @@ end it 'returns an array including the MHV services' do + Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + %w[health-records medical-records messaging rx].each do |service| expect(subject).to include(service) end From 28d05d4e999a743f31ffb2b9b941e12c5c1e5771 Mon Sep 17 00:00:00 2001 From: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Date: Tue, 25 Mar 2025 09:31:42 -0400 Subject: [PATCH 23/30] MHV-68149 Moving user_eligibility over fully to API Gateway --- .../user_eligibility/configuration.rb | 15 +--- .../user_eligibility/client_spec.rb | 4 +- spec/requests/v0/user_spec.rb | 2 - spec/services/users/services_spec.rb | 2 - .../perform_an_eligibility_check.yml | 77 ++++++++-------- ...eligibility_check_for_non_premium_user.yml | 74 +++++++-------- ..._an_eligibility_check_for_premium_user.yml | 75 ++++++++-------- ..._check_on_a_patient_who_is_not_premium.yml | 74 +++++++-------- ...form_an_eligibility_check_with_bad_icn.yml | 77 ++++++++-------- ..._eligibility_check_with_client_failure.yml | 89 ++++++++++--------- 10 files changed, 239 insertions(+), 250 deletions(-) diff --git a/lib/medical_records/user_eligibility/configuration.rb b/lib/medical_records/user_eligibility/configuration.rb index aea92bc2151..af0d79794ba 100644 --- a/lib/medical_records/user_eligibility/configuration.rb +++ b/lib/medical_records/user_eligibility/configuration.rb @@ -19,24 +19,15 @@ class Configuration < Common::Client::Configuration::REST # @return [String] Base path for dependent URLs # def base_path - if Flipper.enabled?(:mhv_medical_records_migrate_to_api_gateway) - "#{Settings.mhv.medical_records.host}/v1/usermgmt/usereligibility/" - else - "#{Settings.mhv.medical_records.host}/mhvapi/v1/usermgmt/usereligibility/" - end + "#{Settings.mhv.medical_records.host}/v1/usermgmt/usereligibility/" end ## # @return [Hash] Headers with x-api-key and RX appToken header values for dependent URLs # def x_headers - api_key = if Flipper.enabled?(:mhv_medical_records_migrate_to_api_gateway) - Settings.mhv.medical_records.x_auth_key - else - Settings.mhv.medical_records.mhv_x_auth_key - end - - base_request_headers.merge('x-api-key' => api_key, appToken: Settings.mhv.rx.app_token) + base_request_headers.merge('x-api-key' => Settings.mhv.medical_records.x_auth_key, + appToken: Settings.mhv.rx.app_token) end ## diff --git a/spec/lib/medical_records/user_eligibility/client_spec.rb b/spec/lib/medical_records/user_eligibility/client_spec.rb index 2ac9b95b80f..f0d05b5d499 100644 --- a/spec/lib/medical_records/user_eligibility/client_spec.rb +++ b/spec/lib/medical_records/user_eligibility/client_spec.rb @@ -10,8 +10,6 @@ let(:client) { UserEligibility::Client.new(user_id, icn) } before do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) - allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_new_eligibility_check).and_return(true) end @@ -68,7 +66,7 @@ end it 'does not perform an eligibility check on the user' do - expect(a_request(:get, %r{mhvapi/v1/usermgmt/usereligibility/isValidSMUser})).not_to have_been_made + expect(a_request(:get, %r{v1/usermgmt/usereligibility/isValidSMUser})).not_to have_been_made end end diff --git a/spec/requests/v0/user_spec.rb b/spec/requests/v0/user_spec.rb index c9d917bf63e..581b2aa776b 100644 --- a/spec/requests/v0/user_spec.rb +++ b/spec/requests/v0/user_spec.rb @@ -14,8 +14,6 @@ let!(:mhv_user_verification) { create(:mhv_user_verification, mhv_uuid: mhv_user.mhv_credential_uuid) } before do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) - allow(SM::Client).to receive(:new).and_return(authenticated_client) allow_any_instance_of(MHVAccountTypeService).to receive(:mhv_account_type).and_return('Premium') create(:account, idme_uuid: mhv_user.uuid) diff --git a/spec/services/users/services_spec.rb b/spec/services/users/services_spec.rb index 9ed7a473ad2..d93086c7ebb 100644 --- a/spec/services/users/services_spec.rb +++ b/spec/services/users/services_spec.rb @@ -71,8 +71,6 @@ end it 'returns an array including the MHV services' do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) - %w[health-records medical-records messaging rx].each do |service| expect(subject).to include(service) end diff --git a/spec/support/vcr_cassettes/user_eligibility_client/perform_an_eligibility_check.yml b/spec/support/vcr_cassettes/user_eligibility_client/perform_an_eligibility_check.yml index 43c0c415c1a..3c654226051 100644 --- a/spec/support/vcr_cassettes/user_eligibility_client/perform_an_eligibility_check.yml +++ b/spec/support/vcr_cassettes/user_eligibility_client/perform_an_eligibility_check.yml @@ -1,40 +1,41 @@ --- http_interactions: -- request: - method: get - uri: "/mhvapi/v1/usermgmt/usereligibility/isValidSMUser/10000000/1000000000V000000" - body: - encoding: US-ASCII - string: '' - headers: - Accept: - - application/json - Content-Type: - - application/json - User-Agent: - - Vets.gov Agent - X-Api-Key: - - - Apptoken: - - - Accept-Encoding: - - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - response: - status: - code: 200 - message: '' - headers: - Date: - - Tue, 24 Sep 2024 16:50:53 GMT - Content-Type: - - application/json - Transfer-Encoding: - - chunked - Strict-Transport-Security: - - max-age=16000000; includeSubDomains; preload; - body: - encoding: UTF-8 - string: '{"correlationId":10000000,"accountStatus":"MHV Premium SM account with - Logins in past 26 months","apiCompletionStatus":"Successful"}' - recorded_at: Tue, 24 Sep 2024 16:50:53 GMT -recorded_with: VCR 6.3.1 \ No newline at end of file + - request: + method: get + uri: "/v1/usermgmt/usereligibility/isValidSMUser/10000000/1000000000V000000" + body: + encoding: US-ASCII + string: "" + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Vets.gov Agent + X-Api-Key: + - + Apptoken: + - + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: "" + headers: + Date: + - Tue, 24 Sep 2024 16:50:53 GMT + Content-Type: + - application/json + Transfer-Encoding: + - chunked + Strict-Transport-Security: + - max-age=16000000; includeSubDomains; preload; + body: + encoding: UTF-8 + string: + '{"correlationId":10000000,"accountStatus":"MHV Premium SM account with + Logins in past 26 months","apiCompletionStatus":"Successful"}' + recorded_at: Tue, 24 Sep 2024 16:50:53 GMT +recorded_with: VCR 6.3.1 diff --git a/spec/support/vcr_cassettes/user_eligibility_client/perform_an_eligibility_check_for_non_premium_user.yml b/spec/support/vcr_cassettes/user_eligibility_client/perform_an_eligibility_check_for_non_premium_user.yml index 766d10edf15..a31422f29b1 100644 --- a/spec/support/vcr_cassettes/user_eligibility_client/perform_an_eligibility_check_for_non_premium_user.yml +++ b/spec/support/vcr_cassettes/user_eligibility_client/perform_an_eligibility_check_for_non_premium_user.yml @@ -1,39 +1,39 @@ --- http_interactions: -- request: - method: get - uri: /mhvapi/v1/usermgmt/usereligibility/isValidSMUser - body: - encoding: US-ASCII - string: '' - headers: - Accept: - - application/json - Content-Type: - - application/json - User-Agent: - - Vets.gov Agent - X-Api-Key: - - "" - Apptoken: - - "" - Accept-Encoding: - - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - response: - status: - code: 400 - message: '' - headers: - Date: - - Thu, 26 Sep 2024 15:46:29 GMT - Content-Type: - - application/json - Transfer-Encoding: - - chunked - Strict-Transport-Security: - - max-age=16000000; includeSubDomains; preload; - body: - encoding: UTF-8 - string: '{"errorCode":405,"developerMessage":"","message":"Not MHV Premium account"}' - recorded_at: Thu, 26 Sep 2024 15:46:29 GMT -recorded_with: VCR 6.3.1 \ No newline at end of file + - request: + method: get + uri: /v1/usermgmt/usereligibility/isValidSMUser + body: + encoding: US-ASCII + string: "" + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Vets.gov Agent + X-Api-Key: + - "" + Apptoken: + - "" + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 400 + message: "" + headers: + Date: + - Thu, 26 Sep 2024 15:46:29 GMT + Content-Type: + - application/json + Transfer-Encoding: + - chunked + Strict-Transport-Security: + - max-age=16000000; includeSubDomains; preload; + body: + encoding: UTF-8 + string: '{"errorCode":405,"developerMessage":"","message":"Not MHV Premium account"}' + recorded_at: Thu, 26 Sep 2024 15:46:29 GMT +recorded_with: VCR 6.3.1 diff --git a/spec/support/vcr_cassettes/user_eligibility_client/perform_an_eligibility_check_for_premium_user.yml b/spec/support/vcr_cassettes/user_eligibility_client/perform_an_eligibility_check_for_premium_user.yml index 8b40d859ad8..455cb09c693 100644 --- a/spec/support/vcr_cassettes/user_eligibility_client/perform_an_eligibility_check_for_premium_user.yml +++ b/spec/support/vcr_cassettes/user_eligibility_client/perform_an_eligibility_check_for_premium_user.yml @@ -1,40 +1,41 @@ --- http_interactions: -- request: - method: get - uri: /mhvapi/v1/usermgmt/usereligibility/isValidSMUser - body: - encoding: US-ASCII - string: '' - headers: - Accept: - - application/json - Content-Type: - - application/json - User-Agent: - - Vets.gov Agent - X-Api-Key: - - - Apptoken: - - - Accept-Encoding: - - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - response: - status: - code: 200 - message: '' - headers: - Date: - - Tue, 24 Sep 2024 16:50:53 GMT - Content-Type: - - application/json - Transfer-Encoding: - - chunked - Strict-Transport-Security: - - max-age=16000000; includeSubDomains; preload; - body: - encoding: UTF-8 - string: '{"correlationId":10000000,"accountStatus":"MHV Premium SM account with - Logins in past 26 months","apiCompletionStatus":"Successful"}' - recorded_at: Tue, 24 Sep 2024 16:50:53 GMT + - request: + method: get + uri: /v1/usermgmt/usereligibility/isValidSMUser + body: + encoding: US-ASCII + string: "" + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Vets.gov Agent + X-Api-Key: + - + Apptoken: + - + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: "" + headers: + Date: + - Tue, 24 Sep 2024 16:50:53 GMT + Content-Type: + - application/json + Transfer-Encoding: + - chunked + Strict-Transport-Security: + - max-age=16000000; includeSubDomains; preload; + body: + encoding: UTF-8 + string: + '{"correlationId":10000000,"accountStatus":"MHV Premium SM account with + Logins in past 26 months","apiCompletionStatus":"Successful"}' + recorded_at: Tue, 24 Sep 2024 16:50:53 GMT recorded_with: VCR 6.3.1 diff --git a/spec/support/vcr_cassettes/user_eligibility_client/perform_an_eligibility_check_on_a_patient_who_is_not_premium.yml b/spec/support/vcr_cassettes/user_eligibility_client/perform_an_eligibility_check_on_a_patient_who_is_not_premium.yml index b4e24cd09b3..fbfd8348d71 100644 --- a/spec/support/vcr_cassettes/user_eligibility_client/perform_an_eligibility_check_on_a_patient_who_is_not_premium.yml +++ b/spec/support/vcr_cassettes/user_eligibility_client/perform_an_eligibility_check_on_a_patient_who_is_not_premium.yml @@ -1,39 +1,39 @@ --- http_interactions: -- request: - method: get - uri: "/mhvapi/v1/usermgmt/usereligibility/isValidSMUser/10000000/1000000000V000000" - body: - encoding: US-ASCII - string: '' - headers: - Accept: - - application/json - Content-Type: - - application/json - User-Agent: - - Vets.gov Agent - X-Api-Key: - - "" - Apptoken: - - "" - Accept-Encoding: - - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - response: - status: - code: 400 - message: '' - headers: - Date: - - Thu, 26 Sep 2024 15:46:29 GMT - Content-Type: - - application/json - Transfer-Encoding: - - chunked - Strict-Transport-Security: - - max-age=16000000; includeSubDomains; preload; - body: - encoding: UTF-8 - string: '{"errorCode":405,"developerMessage":"","message":"Not MHV Premium account"}' - recorded_at: Thu, 26 Sep 2024 15:46:29 GMT -recorded_with: VCR 6.3.1 \ No newline at end of file + - request: + method: get + uri: "/v1/usermgmt/usereligibility/isValidSMUser/10000000/1000000000V000000" + body: + encoding: US-ASCII + string: "" + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Vets.gov Agent + X-Api-Key: + - "" + Apptoken: + - "" + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 400 + message: "" + headers: + Date: + - Thu, 26 Sep 2024 15:46:29 GMT + Content-Type: + - application/json + Transfer-Encoding: + - chunked + Strict-Transport-Security: + - max-age=16000000; includeSubDomains; preload; + body: + encoding: UTF-8 + string: '{"errorCode":405,"developerMessage":"","message":"Not MHV Premium account"}' + recorded_at: Thu, 26 Sep 2024 15:46:29 GMT +recorded_with: VCR 6.3.1 diff --git a/spec/support/vcr_cassettes/user_eligibility_client/perform_an_eligibility_check_with_bad_icn.yml b/spec/support/vcr_cassettes/user_eligibility_client/perform_an_eligibility_check_with_bad_icn.yml index cccf17c57b3..90b9e77a06c 100644 --- a/spec/support/vcr_cassettes/user_eligibility_client/perform_an_eligibility_check_with_bad_icn.yml +++ b/spec/support/vcr_cassettes/user_eligibility_client/perform_an_eligibility_check_with_bad_icn.yml @@ -1,40 +1,41 @@ --- http_interactions: -- request: - method: get - uri: "/mhvapi/v1/usermgmt/usereligibility/isValidSMUser/10000000/12345" - body: - encoding: US-ASCII - string: '' - headers: - Accept: - - application/json - Content-Type: - - application/json - User-Agent: - - Vets.gov Agent - X-Api-Key: - - - Apptoken: - - - Accept-Encoding: - - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - response: - status: - code: 400 - message: '' - headers: - Date: - - Tue, 24 Sep 2024 20:20:06 GMT - Content-Type: - - application/json - Transfer-Encoding: - - chunked - Strict-Transport-Security: - - max-age=16000000; includeSubDomains; preload; - body: - encoding: UTF-8 - string: '{"errorCode":401,"developerMessage":"","message":"No MHV account matching - the ICN"}' - recorded_at: Tue, 24 Sep 2024 20:20:06 GMT -recorded_with: VCR 6.3.1 \ No newline at end of file + - request: + method: get + uri: "/v1/usermgmt/usereligibility/isValidSMUser/10000000/12345" + body: + encoding: US-ASCII + string: "" + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Vets.gov Agent + X-Api-Key: + - + Apptoken: + - + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 400 + message: "" + headers: + Date: + - Tue, 24 Sep 2024 20:20:06 GMT + Content-Type: + - application/json + Transfer-Encoding: + - chunked + Strict-Transport-Security: + - max-age=16000000; includeSubDomains; preload; + body: + encoding: UTF-8 + string: + '{"errorCode":401,"developerMessage":"","message":"No MHV account matching + the ICN"}' + recorded_at: Tue, 24 Sep 2024 20:20:06 GMT +recorded_with: VCR 6.3.1 diff --git a/spec/support/vcr_cassettes/user_eligibility_client/perform_an_eligibility_check_with_client_failure.yml b/spec/support/vcr_cassettes/user_eligibility_client/perform_an_eligibility_check_with_client_failure.yml index a1e668cc131..5269f1d683e 100644 --- a/spec/support/vcr_cassettes/user_eligibility_client/perform_an_eligibility_check_with_client_failure.yml +++ b/spec/support/vcr_cassettes/user_eligibility_client/perform_an_eligibility_check_with_client_failure.yml @@ -1,47 +1,48 @@ --- http_interactions: -- request: - method: get - uri: "/mhvapi/v1/usermgmt/usereligibility/isValidSMUser/10000000/1000000000V000000" - body: - encoding: US-ASCII - string: '' - headers: - Accept: - - application/json - Content-Type: - - application/json - User-Agent: - - Vets.gov Agent - X-Api-Key: - - '' - Apptoken: - - "" - Accept-Encoding: - - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - response: - status: - code: 500 - message: Internal Server Error - headers: - Cache-Control: - - max-age=604800 - Content-Type: - - text/html; charset=UTF-8 - Date: - - Mon, 30 Sep 2024 04:04:17 GMT - Expires: - - Mon, 07 Oct 2024 04:04:17 GMT - Server: - - EOS (vny/0452) - Content-Length: - - '433' - body: - encoding: UTF-8 - string: "\n\n\n\t\n\t\t404 - - Not Found\n\t\n\t\n\t\t

404 - Not Found

\n\t\t\n\t\n\n" - recorded_at: Mon, 30 Sep 2024 04:04:17 GMT + - request: + method: get + uri: "/v1/usermgmt/usereligibility/isValidSMUser/10000000/1000000000V000000" + body: + encoding: US-ASCII + string: "" + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Vets.gov Agent + X-Api-Key: + - "" + Apptoken: + - "" + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 500 + message: Internal Server Error + headers: + Cache-Control: + - max-age=604800 + Content-Type: + - text/html; charset=UTF-8 + Date: + - Mon, 30 Sep 2024 04:04:17 GMT + Expires: + - Mon, 07 Oct 2024 04:04:17 GMT + Server: + - EOS (vny/0452) + Content-Length: + - "433" + body: + encoding: UTF-8 + string: + "\n\n\n\t\n\t\t404 + - Not Found\n\t\n\t\n\t\t

404 - Not Found

\n\t\t\n\t\n\n" + recorded_at: Mon, 30 Sep 2024 04:04:17 GMT recorded_with: VCR 6.3.1 From bde8471b4ef3a945e3bb14b87d26d46c10841f79 Mon Sep 17 00:00:00 2001 From: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Date: Tue, 25 Mar 2025 09:36:17 -0400 Subject: [PATCH 24/30] MHV-68159 Fixed error --- lib/medical_records/user_eligibility/configuration.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/medical_records/user_eligibility/configuration.rb b/lib/medical_records/user_eligibility/configuration.rb index af0d79794ba..6d4627e6fca 100644 --- a/lib/medical_records/user_eligibility/configuration.rb +++ b/lib/medical_records/user_eligibility/configuration.rb @@ -26,8 +26,10 @@ def base_path # @return [Hash] Headers with x-api-key and RX appToken header values for dependent URLs # def x_headers - base_request_headers.merge('x-api-key' => Settings.mhv.medical_records.x_auth_key, - appToken: Settings.mhv.rx.app_token) + base_request_headers.merge({ + 'x-api-key': Settings.mhv.medical_records.x_api_key, + appToken: Settings.mhv.rx.app_token + }) end ## From 18f27a165559a1515788de562aff20db0acb8202 Mon Sep 17 00:00:00 2001 From: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Date: Wed, 26 Mar 2025 12:42:11 -0400 Subject: [PATCH 25/30] MHV-68149 Fixed BB code --- lib/bb/client.rb | 89 +++++++++++++++++++++++++++-------------- lib/bb/configuration.rb | 4 ++ 2 files changed, 62 insertions(+), 31 deletions(-) diff --git a/lib/bb/client.rb b/lib/bb/client.rb index 4ac5d2b3953..c39e27bdda5 100644 --- a/lib/bb/client.rb +++ b/lib/bb/client.rb @@ -21,9 +21,9 @@ class Client < Common::Client::Base CACHE_TTL = 3600 * 3 # cache for 3 hours - LEGACY_BASE_PATH = "#{Settings.mhv.rx.host}/mhv-api/patient/v1".freeze - APIGW_BASE_PATH = "#{Settings.mhv.api_gateway.hosts.bluebutton}/v1/bluebutton".freeze - APIGW_AUTH_BASE_PATH = "#{Settings.mhv.api_gateway.hosts.bluebutton}/v1/usermgmt/auth".freeze + LEGACY_BASE_PATH = "#{Settings.mhv.rx.host}/mhv-api/patient/".freeze + APIGW_BASE_PATH = "#{Settings.mhv.api_gateway.hosts.bluebutton}/".freeze + APIGW_AUTH_BASE_PATH = "#{Settings.mhv.api_gateway.hosts.usermgmt}/".freeze ## # PHR (Personal Health Record) refresh @@ -33,8 +33,14 @@ class Client < Common::Client::Base # @return [Common::Collection] # def get_extract_status - _, prefix = base_path_and_prefix - json = perform(:get, "#{prefix}/extractstatus", nil, token_headers).body + if Flipper.enabled?(:mhv_medical_records_migrate_to_api_gateway) + BB::Configuration.custom_base_path = APIGW_BASE_PATH + json = perform(:get, 'v1/bluebutton/ess/extractstatus', nil, token_headers).body + else + BB::Configuration.custom_base_path = LEGACY_BASE_PATH + json = perform(:get, 'v1/bluebutton/extractstatus', nil, token_headers).body + end + log_refresh_errors(json[:data]) if refresh_final?(json[:data]) Common::Collection.new(ExtractStatus, **json) end @@ -45,9 +51,14 @@ def get_extract_status # @return [Common::Collection] # def get_eligible_data_classes - _, prefix = base_path_and_prefix Common::Collection.fetch(::EligibleDataClass, cache_key: cache_key('geteligibledataclass'), ttl: CACHE_TTL) do - perform(:get, "#{prefix}/geteligibledataclass", nil, token_headers).body + if Flipper.enabled?(:mhv_medical_records_migrate_to_api_gateway) + BB::Configuration.custom_base_path = APIGW_BASE_PATH + perform(:get, 'v1/bluebutton/ess/geteligibledataclass', nil, token_headers).body + else + BB::Configuration.custom_base_path = LEGACY_BASE_PATH + perform(:get, 'v1/bluebutton/geteligibledataclass', nil, token_headers).body + end end end @@ -64,8 +75,13 @@ def post_generate(params) form = BB::GenerateReportRequestForm.new(self, params) raise Common::Exceptions::ValidationErrors, form unless form.valid? - _, prefix = base_path_and_prefix - perform(:post, "#{prefix}/generate", form.params, token_headers).body + if Flipper.enabled?(:mhv_medical_records_migrate_to_api_gateway) + BB::Configuration.custom_base_path = APIGW_BASE_PATH + perform(:post, 'v1/bluebutton/ess/generate', form.params, token_headers).body + else + BB::Configuration.custom_base_path = LEGACY_BASE_PATH + perform(:post, 'v1/bluebutton/generate', form.params, token_headers).body + end end ## @@ -82,8 +98,14 @@ def get_download_report(doctype, header_callback, yielder) # TODO: For testing purposes, use one of the following static URIs: # uri = URI("#{Settings.mhv.rx.host}/vetsgov/1mb.file") # uri = URI("#{Settings.mhv.rx.host}/vetsgov/90mb.file") - base, prefix = base_path_and_prefix - uri = URI.join(config.base_path, "#{base}/#{prefix}/bbreport/#{doctype}") + if Flipper.enabled?(:mhv_medical_records_migrate_to_api_gateway) + BB::Configuration.custom_base_path = APIGW_BASE_PATH + uri = URI.join(config.base_path, "v1/bluebutton/ess/bbreport/#{doctype}") + else + BB::Configuration.custom_base_path = LEGACY_BASE_PATH + uri = URI.join(config.base_path, "v1/bluebutton/bbreport/#{doctype}") + end + streaming_get(uri, token_headers, header_callback, yielder) end @@ -91,9 +113,8 @@ def get_download_report(doctype, header_callback, yielder) # Opt user in to VHIE sharing. # def post_opt_in - base_path, = base_path_and_prefix - prefix = base_path == APIGW_BASE_PATH ? '' : 'bluebutton/external/' - perform(:post, "#{prefix}optinout/optin", nil, token_headers).body + BB::Configuration.custom_base_path = get_base_path + perform(:post, 'v1/bluebutton/external/optinout/optin', nil, token_headers).body rescue ServiceException => e # Ignore the error that the user is already opted in to VHIE sharing. raise unless e.message.include? 'already.opted.in' @@ -103,9 +124,8 @@ def post_opt_in # Opt user out of VHIE sharing. # def post_opt_out - base_path, = base_path_and_prefix - prefix = base_path == APIGW_BASE_PATH ? '' : 'bluebutton/external/' - perform(:post, "#{prefix}optinout/optout", nil, token_headers).body + BB::Configuration.custom_base_path = get_base_path + perform(:post, 'v1/bluebutton/external/optinout/optout', nil, token_headers).body rescue ServiceException => e # Ignore the error that the user is already opted out of VHIE sharing. raise unless e.message.include? 'Opt-out consent policy is already set' @@ -117,31 +137,38 @@ def post_opt_out # @return [Hash] an object containing the body of the response # def get_status - base_path, = base_path_and_prefix - prefix = base_path == APIGW_BASE_PATH ? '' : 'bluebutton/external/' - perform(:get, "#{prefix}optinout/status", nil, token_headers).body + BB::Configuration.custom_base_path = get_base_path + perform(:get, 'v1/bluebutton/external/optinout/status', nil, token_headers).body end private - def base_path_and_prefix + def get_base_path if Flipper.enabled?(:mhv_medical_records_migrate_to_api_gateway) - BB::Configuration.custom_base_path = APIGW_BASE_PATH - [APIGW_BASE_PATH, 'ess'] + APIGW_BASE_PATH else - BB::Configuration.custom_base_path = LEGACY_BASE_PATH - [LEGACY_BASE_PATH, 'bluebutton'] + LEGACY_BASE_PATH end end + def token_headers + super.merge('x-api-key' => config.x_api_key) + end + + def auth_headers + super.merge('x-api-key' => config.x_api_key) + end + def get_session_tagged Sentry.set_tags(error: 'mhv_session') - BB::Configuration.custom_base_path = if Flipper.enabled?(:mhv_medical_records_migrate_to_api_gateway) - APIGW_AUTH_BASE_PATH - else - LEGACY_BASE_PATH - end - env = perform(:get, 'session', nil, auth_headers) + + if Flipper.enabled?(:mhv_medical_records_migrate_to_api_gateway) + BB::Configuration.custom_base_path = APIGW_BASE_PATH + env = perform(:get, 'v1/usermgmt/auth/session', nil, auth_headers) + else + BB::Configuration.custom_base_path = LEGACY_BASE_PATH + env = perform(:get, '/mhv-api/patient/v1/session', nil, auth_headers) + end Sentry.get_current_scope.tags.delete(:error) env diff --git a/lib/bb/configuration.rb b/lib/bb/configuration.rb index 437bb2a60c4..dc8ea331571 100644 --- a/lib/bb/configuration.rb +++ b/lib/bb/configuration.rb @@ -35,6 +35,10 @@ def app_token Settings.mhv.rx.app_token end + def x_api_key + Settings.mhv.medical_records.x_api_key + end + ## # @return [String] Base path for dependent URLs # From d7da9111654a2069e4dfe259703b837c295cecee Mon Sep 17 00:00:00 2001 From: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Date: Thu, 27 Mar 2025 07:57:49 -0400 Subject: [PATCH 26/30] MHV-68149 Roll back default config setting --- spec/lib/bb/client_spec.rb | 5 ----- spec/lib/bb/generate_report_request_form_spec.rb | 8 -------- spec/lib/medical_records/bb_internal/client_spec.rb | 5 ----- spec/lib/medical_records/client_spec.rb | 5 ----- spec/lib/medical_records/phr_mgr/client_spec.rb | 8 -------- spec/requests/v0/health_records_spec.rb | 8 -------- 6 files changed, 39 deletions(-) diff --git a/spec/lib/bb/client_spec.rb b/spec/lib/bb/client_spec.rb index be47f3659ed..1fd8ab16184 100644 --- a/spec/lib/bb/client_spec.rb +++ b/spec/lib/bb/client_spec.rb @@ -16,11 +16,6 @@ end before(:all) do - VCR.configure do |vcr_config| - vcr_config.default_cassette_options = { - allow_playback_repeats: true - } - end VCR.use_cassette 'bb_client/session' do Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) @client ||= begin diff --git a/spec/lib/bb/generate_report_request_form_spec.rb b/spec/lib/bb/generate_report_request_form_spec.rb index 842ea411cff..6f09a7dc0a5 100644 --- a/spec/lib/bb/generate_report_request_form_spec.rb +++ b/spec/lib/bb/generate_report_request_form_spec.rb @@ -24,14 +24,6 @@ let(:attributes) { {} } - before(:all) do - VCR.configure do |vcr_config| - vcr_config.default_cassette_options = { - allow_playback_repeats: true - } - end - end - before do Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) allow(subject).to receive(:eligible_data_classes).and_return(eligible_data_classes) diff --git a/spec/lib/medical_records/bb_internal/client_spec.rb b/spec/lib/medical_records/bb_internal/client_spec.rb index 1b61a937a67..a98bf607de3 100644 --- a/spec/lib/medical_records/bb_internal/client_spec.rb +++ b/spec/lib/medical_records/bb_internal/client_spec.rb @@ -8,11 +8,6 @@ describe BBInternal::Client do before(:all) do - VCR.configure do |vcr_config| - vcr_config.default_cassette_options = { - allow_playback_repeats: true - } - end VCR.use_cassette 'mr_client/bb_internal/session_auth' do Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) @client ||= begin diff --git a/spec/lib/medical_records/client_spec.rb b/spec/lib/medical_records/client_spec.rb index 05fc1ee787b..53b14098f69 100644 --- a/spec/lib/medical_records/client_spec.rb +++ b/spec/lib/medical_records/client_spec.rb @@ -7,11 +7,6 @@ describe MedicalRecords::Client do context 'when a valid session exists', :vcr do before(:all) do - VCR.configure do |vcr_config| - vcr_config.default_cassette_options = { - allow_playback_repeats: true - } - end VCR.use_cassette('user_eligibility_client/perform_an_eligibility_check_for_premium_user', match_requests_on: %i[method sm_user_ignoring_path_param]) do VCR.use_cassette 'mr_client/session' do diff --git a/spec/lib/medical_records/phr_mgr/client_spec.rb b/spec/lib/medical_records/phr_mgr/client_spec.rb index e1d1cc2d5b9..026c6fa88dd 100644 --- a/spec/lib/medical_records/phr_mgr/client_spec.rb +++ b/spec/lib/medical_records/phr_mgr/client_spec.rb @@ -4,14 +4,6 @@ require 'medical_records/phr_mgr/client' describe PHRMgr::Client do - before(:all) do - VCR.configure do |vcr_config| - vcr_config.default_cassette_options = { - allow_playback_repeats: true - } - end - end - before do Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) end diff --git a/spec/requests/v0/health_records_spec.rb b/spec/requests/v0/health_records_spec.rb index 29478578840..74163071b78 100644 --- a/spec/requests/v0/health_records_spec.rb +++ b/spec/requests/v0/health_records_spec.rb @@ -20,14 +20,6 @@ end let(:inflection_header) { { 'X-Key-Inflection' => 'camel' } } - before(:all) do - VCR.configure do |vcr_config| - vcr_config.default_cassette_options = { - allow_playback_repeats: true - } - end - end - before do Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) allow(BB::Client).to receive(:new).and_return(authenticated_client) From ae2585729ad4891cd4ca4f15cf498e82959d3d00 Mon Sep 17 00:00:00 2001 From: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Date: Thu, 27 Mar 2025 09:43:04 -0400 Subject: [PATCH 27/30] MHV-68149 Removing unnecessary test fix --- modules/check_in/spec/requests/check_in/v2/sessions_spec.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/modules/check_in/spec/requests/check_in/v2/sessions_spec.rb b/modules/check_in/spec/requests/check_in/v2/sessions_spec.rb index bf7f89219ac..397bbae6541 100644 --- a/modules/check_in/spec/requests/check_in/v2/sessions_spec.rb +++ b/modules/check_in/spec/requests/check_in/v2/sessions_spec.rb @@ -299,10 +299,6 @@ } end - before do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) - end - context 'in session created using DOB' do let(:session_params_with_dob) do { From 0dd64b96c732a80fd525ac284a0d80a00a370110 Mon Sep 17 00:00:00 2001 From: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Date: Thu, 27 Mar 2025 11:35:39 -0400 Subject: [PATCH 28/30] MHV-68149 Fixed images and DICOM download --- .../my_health/v1/medical_records/imaging_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/my_health/app/controllers/my_health/v1/medical_records/imaging_controller.rb b/modules/my_health/app/controllers/my_health/v1/medical_records/imaging_controller.rb index 200f43db1cf..780ad72ac82 100644 --- a/modules/my_health/app/controllers/my_health/v1/medical_records/imaging_controller.rb +++ b/modules/my_health/app/controllers/my_health/v1/medical_records/imaging_controller.rb @@ -55,7 +55,7 @@ def render_resource(resource) def header_callback lambda do |headers| headers.each do |k, v| - next if %w[Content-Type Transfer-Encoding].include?(k) + next if %w[Content-Type Transfer-Encoding Content-Encoding].include?(k) response.headers[k] = v if k.present? end From a88aed9fb46358d40bd3a32080d93b0d76935dec Mon Sep 17 00:00:00 2001 From: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Date: Mon, 31 Mar 2025 12:21:11 -0400 Subject: [PATCH 29/30] MHV-68149 Mock Flipper settings in specs --- .../my_health/v1/medical_records/allergies_spec.rb | 2 +- .../v1/medical_records/clinical_notes_spec.rb | 2 +- .../my_health/v1/medical_records/conditions_spec.rb | 2 +- .../my_health/v1/medical_records/imaging_spec.rb | 2 +- .../v1/medical_records/labs_and_tests_spec.rb | 2 +- .../my_health/v1/medical_records/radiology_spec.rb | 2 +- .../my_health/v1/medical_records/session_spec.rb | 2 +- .../my_health/v1/medical_records/vaccines_spec.rb | 2 +- .../my_health/v1/medical_records/vitals_spec.rb | 2 +- spec/lib/bb/client_spec.rb | 4 ++-- spec/lib/bb/generate_report_request_form_spec.rb | 2 +- .../client/concerns/mhv_jwt_session_client_spec.rb | 2 +- spec/lib/medical_records/bb_internal/client_spec.rb | 4 ++-- spec/lib/medical_records/client_spec.rb | 8 ++++---- spec/lib/medical_records/phr_mgr/client_spec.rb | 2 +- spec/requests/swagger_spec.rb | 10 +++++----- spec/requests/v0/health_records_spec.rb | 2 +- spec/services/mhv_account_type_service_spec.rb | 2 +- 18 files changed, 27 insertions(+), 27 deletions(-) diff --git a/modules/my_health/spec/requests/my_health/v1/medical_records/allergies_spec.rb b/modules/my_health/spec/requests/my_health/v1/medical_records/allergies_spec.rb index abd51332ea0..5b099037159 100644 --- a/modules/my_health/spec/requests/my_health/v1/medical_records/allergies_spec.rb +++ b/modules/my_health/spec/requests/my_health/v1/medical_records/allergies_spec.rb @@ -15,7 +15,7 @@ let(:current_user) { build(:user, :mhv, va_patient:, mhv_account_type:) } before do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) allow(MedicalRecords::Client).to receive(:new).and_return(authenticated_client) allow(BBInternal::Client).to receive(:new).and_return(authenticated_client) sign_in_as(current_user) diff --git a/modules/my_health/spec/requests/my_health/v1/medical_records/clinical_notes_spec.rb b/modules/my_health/spec/requests/my_health/v1/medical_records/clinical_notes_spec.rb index 9b6f28db4fa..88fb6db6503 100644 --- a/modules/my_health/spec/requests/my_health/v1/medical_records/clinical_notes_spec.rb +++ b/modules/my_health/spec/requests/my_health/v1/medical_records/clinical_notes_spec.rb @@ -15,7 +15,7 @@ let(:current_user) { build(:user, :mhv, va_patient:, mhv_account_type:) } before do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) allow(MedicalRecords::Client).to receive(:new).and_return(authenticated_client) allow(BBInternal::Client).to receive(:new).and_return(authenticated_client) sign_in_as(current_user) diff --git a/modules/my_health/spec/requests/my_health/v1/medical_records/conditions_spec.rb b/modules/my_health/spec/requests/my_health/v1/medical_records/conditions_spec.rb index a94fd3ab314..5e278d4dd6e 100644 --- a/modules/my_health/spec/requests/my_health/v1/medical_records/conditions_spec.rb +++ b/modules/my_health/spec/requests/my_health/v1/medical_records/conditions_spec.rb @@ -15,7 +15,7 @@ let(:current_user) { build(:user, :mhv, va_patient:, mhv_account_type:) } before do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) allow(MedicalRecords::Client).to receive(:new).and_return(authenticated_client) allow(BBInternal::Client).to receive(:new).and_return(authenticated_client) sign_in_as(current_user) diff --git a/modules/my_health/spec/requests/my_health/v1/medical_records/imaging_spec.rb b/modules/my_health/spec/requests/my_health/v1/medical_records/imaging_spec.rb index aa67c9b32f2..6ccf47e3504 100644 --- a/modules/my_health/spec/requests/my_health/v1/medical_records/imaging_spec.rb +++ b/modules/my_health/spec/requests/my_health/v1/medical_records/imaging_spec.rb @@ -16,7 +16,7 @@ let(:study_id) { '453-2487448' } before do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) bb_internal_client = BBInternal::Client.new( session: { user_id: 11_375_034, diff --git a/modules/my_health/spec/requests/my_health/v1/medical_records/labs_and_tests_spec.rb b/modules/my_health/spec/requests/my_health/v1/medical_records/labs_and_tests_spec.rb index 3e069c96b77..a12d651a045 100644 --- a/modules/my_health/spec/requests/my_health/v1/medical_records/labs_and_tests_spec.rb +++ b/modules/my_health/spec/requests/my_health/v1/medical_records/labs_and_tests_spec.rb @@ -15,7 +15,7 @@ let(:current_user) { build(:user, :mhv, va_patient:, mhv_account_type:) } before do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) allow(MedicalRecords::Client).to receive(:new).and_return(authenticated_client) allow(BBInternal::Client).to receive(:new).and_return(authenticated_client) sign_in_as(current_user) diff --git a/modules/my_health/spec/requests/my_health/v1/medical_records/radiology_spec.rb b/modules/my_health/spec/requests/my_health/v1/medical_records/radiology_spec.rb index 3a1fde74b0b..5ae33f1d1fd 100644 --- a/modules/my_health/spec/requests/my_health/v1/medical_records/radiology_spec.rb +++ b/modules/my_health/spec/requests/my_health/v1/medical_records/radiology_spec.rb @@ -14,7 +14,7 @@ let(:current_user) { build(:user, :mhv, va_patient:, mhv_account_type:) } before do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) bb_internal_client = BBInternal::Client.new( session: { user_id: 11_375_034, diff --git a/modules/my_health/spec/requests/my_health/v1/medical_records/session_spec.rb b/modules/my_health/spec/requests/my_health/v1/medical_records/session_spec.rb index da6ad9896bf..e34055a1ff2 100644 --- a/modules/my_health/spec/requests/my_health/v1/medical_records/session_spec.rb +++ b/modules/my_health/spec/requests/my_health/v1/medical_records/session_spec.rb @@ -15,7 +15,7 @@ let(:current_user) { build(:user, :mhv, va_patient:, mhv_account_type:) } before do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) allow(MedicalRecords::Client).to receive(:new).and_return(authenticated_client) allow(BBInternal::Client).to receive(:new).and_return(authenticated_client) allow(PHRMgr::Client).to receive(:new).and_return(PHRMgr::Client.new(12_345)) diff --git a/modules/my_health/spec/requests/my_health/v1/medical_records/vaccines_spec.rb b/modules/my_health/spec/requests/my_health/v1/medical_records/vaccines_spec.rb index 16e96db6ea4..4fd1724858d 100644 --- a/modules/my_health/spec/requests/my_health/v1/medical_records/vaccines_spec.rb +++ b/modules/my_health/spec/requests/my_health/v1/medical_records/vaccines_spec.rb @@ -15,7 +15,7 @@ let(:current_user) { build(:user, :mhv, va_patient:, mhv_account_type:) } before do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) allow(MedicalRecords::Client).to receive(:new).and_return(authenticated_client) allow(BBInternal::Client).to receive(:new).and_return(authenticated_client) sign_in_as(current_user) diff --git a/modules/my_health/spec/requests/my_health/v1/medical_records/vitals_spec.rb b/modules/my_health/spec/requests/my_health/v1/medical_records/vitals_spec.rb index e585d32b162..855303a8e92 100644 --- a/modules/my_health/spec/requests/my_health/v1/medical_records/vitals_spec.rb +++ b/modules/my_health/spec/requests/my_health/v1/medical_records/vitals_spec.rb @@ -15,7 +15,7 @@ let(:current_user) { build(:user, :mhv, va_patient:, mhv_account_type:) } before do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) allow(MedicalRecords::Client).to receive(:new).and_return(authenticated_client) allow(BBInternal::Client).to receive(:new).and_return(authenticated_client) sign_in_as(current_user) diff --git a/spec/lib/bb/client_spec.rb b/spec/lib/bb/client_spec.rb index 1fd8ab16184..c1932fed710 100644 --- a/spec/lib/bb/client_spec.rb +++ b/spec/lib/bb/client_spec.rb @@ -17,7 +17,7 @@ before(:all) do VCR.use_cassette 'bb_client/session' do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) @client ||= begin client = BB::Client.new(session: { user_id: '5751732' }) client.authenticate @@ -27,7 +27,7 @@ end before do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) end let(:client) { @client } diff --git a/spec/lib/bb/generate_report_request_form_spec.rb b/spec/lib/bb/generate_report_request_form_spec.rb index 6f09a7dc0a5..b6aec775f85 100644 --- a/spec/lib/bb/generate_report_request_form_spec.rb +++ b/spec/lib/bb/generate_report_request_form_spec.rb @@ -25,7 +25,7 @@ let(:attributes) { {} } before do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) allow(subject).to receive(:eligible_data_classes).and_return(eligible_data_classes) end diff --git a/spec/lib/common/client/concerns/mhv_jwt_session_client_spec.rb b/spec/lib/common/client/concerns/mhv_jwt_session_client_spec.rb index 43ad349a862..2101076a361 100644 --- a/spec/lib/common/client/concerns/mhv_jwt_session_client_spec.rb +++ b/spec/lib/common/client/concerns/mhv_jwt_session_client_spec.rb @@ -6,7 +6,7 @@ describe Common::Client::Concerns::MHVJwtSessionClient do before do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) end let(:dummy_class) do diff --git a/spec/lib/medical_records/bb_internal/client_spec.rb b/spec/lib/medical_records/bb_internal/client_spec.rb index a98bf607de3..9237b648bec 100644 --- a/spec/lib/medical_records/bb_internal/client_spec.rb +++ b/spec/lib/medical_records/bb_internal/client_spec.rb @@ -9,7 +9,7 @@ describe BBInternal::Client do before(:all) do VCR.use_cassette 'mr_client/bb_internal/session_auth' do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) @client ||= begin client = BBInternal::Client.new(session: { user_id: '11375034', icn: '1012740022V620959' }) client.authenticate @@ -19,7 +19,7 @@ end before do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) end let(:client) { @client } diff --git a/spec/lib/medical_records/client_spec.rb b/spec/lib/medical_records/client_spec.rb index 53b14098f69..68d0694de13 100644 --- a/spec/lib/medical_records/client_spec.rb +++ b/spec/lib/medical_records/client_spec.rb @@ -11,7 +11,7 @@ match_requests_on: %i[method sm_user_ignoring_path_param]) do VCR.use_cassette 'mr_client/session' do VCR.use_cassette 'mr_client/get_a_patient_by_identifier' do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) @client ||= begin client = MedicalRecords::Client.new(session: { user_id: '22406991', icn: '1013868614V792025' }) client.authenticate @@ -23,7 +23,7 @@ end before do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) MedicalRecords::Client.send(:public, *MedicalRecords::Client.protected_instance_methods) # Redirect FHIR logger's output to the buffer before each test @@ -457,7 +457,7 @@ match_requests_on: %i[method sm_user_ignoring_path_param]) do VCR.use_cassette 'mr_client/session' do VCR.use_cassette 'mr_client/get_a_patient_by_identifier_hapi_1363' do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) partial_client ||= begin partial_client = MedicalRecords::Client.new(session: { user_id: '22406991', icn: '1013868614V792025' }) @@ -478,7 +478,7 @@ match_requests_on: %i[method sm_user_ignoring_path_param]) do VCR.use_cassette 'mr_client/session' do VCR.use_cassette 'mr_client/get_a_patient_by_identifier_not_found' do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) partial_client ||= begin partial_client = MedicalRecords::Client.new(session: { user_id: '22406991', icn: '1013868614V792025' }) diff --git a/spec/lib/medical_records/phr_mgr/client_spec.rb b/spec/lib/medical_records/phr_mgr/client_spec.rb index 026c6fa88dd..961929d3746 100644 --- a/spec/lib/medical_records/phr_mgr/client_spec.rb +++ b/spec/lib/medical_records/phr_mgr/client_spec.rb @@ -5,7 +5,7 @@ describe PHRMgr::Client do before do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) end describe 'PHR operations', :vcr do diff --git a/spec/requests/swagger_spec.rb b/spec/requests/swagger_spec.rb index 35e96fad1b2..9ab706b4a78 100644 --- a/spec/requests/swagger_spec.rb +++ b/spec/requests/swagger_spec.rb @@ -1814,7 +1814,7 @@ describe 'show a report' do context 'successful calls' do it 'supports showing a report' do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) # Using mucked-up yml because apivore has a problem processing non-json responses VCR.use_cassette('bb_client/gets_a_text_report_for_apivore') do @@ -1826,7 +1826,7 @@ context 'unsuccessful calls' do it 'handles a backend error' do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) VCR.use_cassette('bb_client/report_error_response') do expect(subject).to validate(:get, '/v0/health_records', 503, @@ -1839,7 +1839,7 @@ describe 'create a report' do context 'successful calls' do it 'supports creating a report' do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) VCR.use_cassette('bb_client/generates_a_report') do expect(subject).to validate( @@ -1885,7 +1885,7 @@ describe 'eligible data classes' do it 'supports retrieving eligible data classes' do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) VCR.use_cassette('bb_client/gets_a_list_of_eligible_data_classes') do expect(subject).to validate(:get, '/v0/health_records/eligible_data_classes', 200, headers) @@ -1896,7 +1896,7 @@ describe 'refresh' do context 'successful calls' do it 'supports health records refresh' do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) VCR.use_cassette('bb_client/gets_a_list_of_extract_statuses') do expect(subject).to validate(:get, '/v0/health_records/refresh', 200, headers) diff --git a/spec/requests/v0/health_records_spec.rb b/spec/requests/v0/health_records_spec.rb index 74163071b78..50af54d18b7 100644 --- a/spec/requests/v0/health_records_spec.rb +++ b/spec/requests/v0/health_records_spec.rb @@ -21,7 +21,7 @@ let(:inflection_header) { { 'X-Key-Inflection' => 'camel' } } before do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) allow(BB::Client).to receive(:new).and_return(authenticated_client) sign_in_as(current_user) end diff --git a/spec/services/mhv_account_type_service_spec.rb b/spec/services/mhv_account_type_service_spec.rb index 4d66073159d..f47973725ce 100644 --- a/spec/services/mhv_account_type_service_spec.rb +++ b/spec/services/mhv_account_type_service_spec.rb @@ -21,7 +21,7 @@ end before do - Flipper.disable(:mhv_medical_records_migrate_to_api_gateway) + allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) end context 'no mhv_correlation_id' do From 2fd711095d6c673d0dafd301f520ee01c6a67006 Mon Sep 17 00:00:00 2001 From: Mike Moyer <87040148+mmoyer-va@users.noreply.github.com> Date: Mon, 31 Mar 2025 12:39:22 -0400 Subject: [PATCH 30/30] MHV-68159 Move functionality to before(:each) to allow mocking --- spec/lib/bb/client_spec.rb | 8 ++------ spec/lib/medical_records/bb_internal/client_spec.rb | 8 ++------ spec/lib/medical_records/client_spec.rb | 6 ++---- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/spec/lib/bb/client_spec.rb b/spec/lib/bb/client_spec.rb index c1932fed710..eae538bf81b 100644 --- a/spec/lib/bb/client_spec.rb +++ b/spec/lib/bb/client_spec.rb @@ -15,9 +15,9 @@ vapathology vaproblemlist varadiology vahth wellness dodmilitaryservice ] end - before(:all) do + before do + allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) VCR.use_cassette 'bb_client/session' do - allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) @client ||= begin client = BB::Client.new(session: { user_id: '5751732' }) client.authenticate @@ -26,10 +26,6 @@ end end - before do - allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) - end - let(:client) { @client } # Need to pull the last updated to determine the staleness / freshness of the data diff --git a/spec/lib/medical_records/bb_internal/client_spec.rb b/spec/lib/medical_records/bb_internal/client_spec.rb index 9237b648bec..291a731683f 100644 --- a/spec/lib/medical_records/bb_internal/client_spec.rb +++ b/spec/lib/medical_records/bb_internal/client_spec.rb @@ -7,9 +7,9 @@ UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i describe BBInternal::Client do - before(:all) do + before do + allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) VCR.use_cassette 'mr_client/bb_internal/session_auth' do - allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) @client ||= begin client = BBInternal::Client.new(session: { user_id: '11375034', icn: '1012740022V620959' }) client.authenticate @@ -18,10 +18,6 @@ end end - before do - allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) - end - let(:client) { @client } RSpec.shared_context 'redis setup' do diff --git a/spec/lib/medical_records/client_spec.rb b/spec/lib/medical_records/client_spec.rb index 68d0694de13..16268035660 100644 --- a/spec/lib/medical_records/client_spec.rb +++ b/spec/lib/medical_records/client_spec.rb @@ -6,7 +6,8 @@ describe MedicalRecords::Client do context 'when a valid session exists', :vcr do - before(:all) do + before do + allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) VCR.use_cassette('user_eligibility_client/perform_an_eligibility_check_for_premium_user', match_requests_on: %i[method sm_user_ignoring_path_param]) do VCR.use_cassette 'mr_client/session' do @@ -20,10 +21,7 @@ end end end - end - before do - allow(Flipper).to receive(:enabled?).with(:mhv_medical_records_migrate_to_api_gateway).and_return(false) MedicalRecords::Client.send(:public, *MedicalRecords::Client.protected_instance_methods) # Redirect FHIR logger's output to the buffer before each test