From 31cec0c1aea27dcd5e0ee621ee784ca8066c3d1d Mon Sep 17 00:00:00 2001 From: degradification Date: Wed, 18 Dec 2024 13:50:43 -0500 Subject: [PATCH] Updated Supported Payer Endpoint to properly perform requests -Added test for supported payer --- ...dtr_light_ehr_supported_endpoints_group.rb | 14 +++++ ...light_ehr_supported_payer_endpoint_test.rb | 42 ++++++++++++++ .../dtr_light_ehr_suite.rb | 16 +++++- .../light_ehr_supported_payer_endpoint.rb | 57 +++++++++++-------- lib/davinci_dtr_test_kit/tags.rb | 1 + lib/davinci_dtr_test_kit/urls.rb | 5 ++ 6 files changed, 109 insertions(+), 26 deletions(-) create mode 100644 lib/davinci_dtr_test_kit/client_groups/light_ehr/dtr_light_ehr_supported_endpoints_group.rb create mode 100644 lib/davinci_dtr_test_kit/client_groups/light_ehr/dtr_light_ehr_supported_payer_endpoint_test.rb diff --git a/lib/davinci_dtr_test_kit/client_groups/light_ehr/dtr_light_ehr_supported_endpoints_group.rb b/lib/davinci_dtr_test_kit/client_groups/light_ehr/dtr_light_ehr_supported_endpoints_group.rb new file mode 100644 index 0000000..ef81b24 --- /dev/null +++ b/lib/davinci_dtr_test_kit/client_groups/light_ehr/dtr_light_ehr_supported_endpoints_group.rb @@ -0,0 +1,14 @@ +require_relative 'dtr_light_ehr_supported_payer_endpoint_test' + +module DaVinciDTRTestKit + class DtrLightEhrSupportedEndpointsGroup < Inferno::TestGroup + id :dtr_light_ehr_supported_endpoints + title 'Supported Endpoints' + description %( + Demonstrate the ability to access supported endpoints + ) + run_as_group + + test from: :dtr_light_ehr_supported_payer_endpoint + end +end diff --git a/lib/davinci_dtr_test_kit/client_groups/light_ehr/dtr_light_ehr_supported_payer_endpoint_test.rb b/lib/davinci_dtr_test_kit/client_groups/light_ehr/dtr_light_ehr_supported_payer_endpoint_test.rb new file mode 100644 index 0000000..1f37db7 --- /dev/null +++ b/lib/davinci_dtr_test_kit/client_groups/light_ehr/dtr_light_ehr_supported_payer_endpoint_test.rb @@ -0,0 +1,42 @@ +require_relative '../../urls' + +module DaVinciDTRTestKit + class DtrLightEhrSupportedPayerEndpointTest < Inferno::Test + include URLs + id :dtr_light_ehr_supported_payer_endpoint + title 'Client can retrieve payers from supported payer endpoint' + description %( + Inferno, will wait for a request to return the payer details from the supported endpoint. + ) + input :access_token, + description: %( + `Bearer` token that the client under test will send in the + `Authorization` header of each HTTP request to Inferno. Inferno + will look for this value to associate requests with this session. + ) + + run do + wait( + identifier: access_token, + message: %( + ### Supported Payer Endpoint + + Inferno will wait for the Light EHR to to make a GET request to + + `#{supported_payer_url}` + + Inferno will return the static payers json details + + ### Request Identification + + In order to identify requests for this session, Inferno will look for + an `Authorization` header with value: + + ``` + Bearer #{access_token} + ``` + ) + ) + end + end +end diff --git a/lib/davinci_dtr_test_kit/dtr_light_ehr_suite.rb b/lib/davinci_dtr_test_kit/dtr_light_ehr_suite.rb index b3953cb..7fdbd02 100644 --- a/lib/davinci_dtr_test_kit/dtr_light_ehr_suite.rb +++ b/lib/davinci_dtr_test_kit/dtr_light_ehr_suite.rb @@ -13,6 +13,7 @@ require_relative 'profiles/task_group' require_relative 'profiles/vision_prescription_group' require_relative 'endpoints/mock_payer/light_ehr_supported_payer_endpoint' +require_relative 'client_groups/light_ehr/dtr_light_ehr_supported_endpoints_group' require 'smart_app_launch/smart_stu1_suite' require 'smart_app_launch/smart_stu2_suite' @@ -56,7 +57,8 @@ class DTRLightEHRSuite < Inferno::TestSuite end end - route :get, '/supported-payers', DaVinciDTRTestKit::Endpoints::MockPayer::LightEHRSupportedPayerEndpoint + suite_endpoint :get, SUPPORTED_PAYER_PATH, MockPayer::LightEHRSupportedPayerEndpoint + group do title 'Authorization' @@ -138,5 +140,17 @@ class DTRLightEHRSuite < Inferno::TestSuite group from: :task_group group from: :vision_prescription_group end + + group do + title 'Supported Endpoints' + description %(This test group tests system for their conformance to + the supported endpoint capabilities as defined by the DaVinci Documentation + Templates and Rules (DTR) v2.0,1 Implementation Guide Light DTR EHR + Capability Statement. + + ) + + group from: :dtr_light_ehr_supported_endpoints + end end end diff --git a/lib/davinci_dtr_test_kit/endpoints/mock_payer/light_ehr_supported_payer_endpoint.rb b/lib/davinci_dtr_test_kit/endpoints/mock_payer/light_ehr_supported_payer_endpoint.rb index eaaa7d7..886ad62 100644 --- a/lib/davinci_dtr_test_kit/endpoints/mock_payer/light_ehr_supported_payer_endpoint.rb +++ b/lib/davinci_dtr_test_kit/endpoints/mock_payer/light_ehr_supported_payer_endpoint.rb @@ -1,37 +1,44 @@ require_relative '../mock_payer' +require_relative '../../tags' module DaVinciDTRTestKit - module Endpoints - module MockPayer - class LightEHRSupportedPayerEndpoint < Inferno::DSL::SuiteEndpoint - include DaVinciDTRTestKit::MockPayer + module MockPayer + class LightEHRSupportedPayerEndpoint < Inferno::DSL::SuiteEndpoint + include MockPayer - def make_response - puts "Request method: #{request.request_method}" - if request.headers['Accept'] != 'application/json' - response.status = 406 - response.body = { error: 'Not Acceptable', message: 'Accept header must be application/json' }.to_json - response.headers['Content-Type'] = 'application/json' - return - end + def name + 'light_ehr_supported_payer_endpoint' + end + + def test_run_identifier + request.headers['authorization']&.delete_prefix('Bearer ') + end + + def tags + [SUPPORTED_PAYER_TAG] + end - response.status = 200 - response.body = { - payers: [ - { id: 'payer1', name: 'Payer One' }, - { id: 'payer2', name: 'Payer Two' } - ] - }.to_json + def make_response + puts "Request method: #{request.request_method}" + if request.headers['Accept'] != 'application/json' + response.status = 406 response.headers['Content-Type'] = 'application/json' + response.body = { error: 'Not Acceptable', message: 'Accept header must be application/json' }.to_json + return end - def tags - ['supported_payers'] - end + response.status = 200 + response.headers['Content-Type'] = 'application/json' + response.body = { + payers: [ + { id: 'payer1', name: 'Payer One' }, + { id: 'payer2', name: 'Payer Two' } + ] + }.to_json + end - def name - 'light_ehr_supported_payer_endpoint' - end + def update_result + results_repo.update_result(result.id, 'pass') unless test.config.options[:accepts_multiple_requests] end end end diff --git a/lib/davinci_dtr_test_kit/tags.rb b/lib/davinci_dtr_test_kit/tags.rb index a8725ec..47d9547 100644 --- a/lib/davinci_dtr_test_kit/tags.rb +++ b/lib/davinci_dtr_test_kit/tags.rb @@ -4,4 +4,5 @@ module DaVinciDTRTestKit QUESTIONNAIRE_PACKAGE_TAG = 'dtr_questionnaire_package'.freeze CLIENT_NEXT_TAG = 'dtr_questionnaire_next_question'.freeze EHR_AUTHORIZE_TAG = 'dtr_smart_app_ehr_authorize'.freeze + SUPPORTED_PAYER_TAG = 'light_ehr_supported_payer_endpoint'.freeze end diff --git a/lib/davinci_dtr_test_kit/urls.rb b/lib/davinci_dtr_test_kit/urls.rb index 04170af..533f7d9 100644 --- a/lib/davinci_dtr_test_kit/urls.rb +++ b/lib/davinci_dtr_test_kit/urls.rb @@ -13,6 +13,7 @@ module DaVinciDTRTestKit QUESTIONNAIRE_RESPONSE_PATH = "#{FHIR_BASE_PATH}/QuestionnaireResponse".freeze FHIR_RESOURCE_PATH = "#{FHIR_BASE_PATH}/:resource/:id".freeze FHIR_SEARCH_PATH = "#{FHIR_BASE_PATH}/:resource".freeze + SUPPORTED_PAYER_PATH = '/supported-payers' RESUME_PASS_PATH = '/resume_pass' RESUME_FAIL_PATH = '/resume_fail' @@ -49,6 +50,10 @@ def fhir_base_url @fhir_base_url ||= base_url + FHIR_BASE_PATH end + def supported_payer_url + @supported_payer_url ||= base_url + SUPPORTED_PAYER_PATH + end + def resume_pass_url @resume_pass_url ||= base_url + RESUME_PASS_PATH end