From db1e90dcabbcf7bacc39b66130a790fd330b0e67 Mon Sep 17 00:00:00 2001 From: degradification Date: Mon, 16 Dec 2024 13:00:34 -0500 Subject: [PATCH 1/6] Initial endpoint definition with sinatra-base --- .../dtr_light_ehr_suite.rb | 3 ++ .../light_ehr_supported_payer_endpoint.rb | 21 ++++++++ ...light_ehr_supported_payer_endpoint_spec.rb | 54 +++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 lib/davinci_dtr_test_kit/endpoints/mock_payer/light_ehr_supported_payer_endpoint.rb create mode 100644 spec/davinci_dtr_test_kit/endpoints/mock_payer/light_ehr_supported_payer_endpoint_spec.rb 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 b771eea..f241540 100644 --- a/lib/davinci_dtr_test_kit/dtr_light_ehr_suite.rb +++ b/lib/davinci_dtr_test_kit/dtr_light_ehr_suite.rb @@ -12,6 +12,7 @@ require_relative 'profiles/service_request_group' require_relative 'profiles/task_group' require_relative 'profiles/vision_prescription_group' +require_relative 'endpoints/mock_payer/light_ehr_supported_payer_endpoint' require 'smart_app_launch/smart_stu1_suite' require 'smart_app_launch/smart_stu2_suite' @@ -55,6 +56,8 @@ class DTRLightEHRSuite < Inferno::TestSuite end end + route :get, '/supported-payers', Endpoints::MockPayer::LightEHRSupportedPayerEndpoint + group do title 'Authorization' 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 new file mode 100644 index 0000000..5aee5c1 --- /dev/null +++ b/lib/davinci_dtr_test_kit/endpoints/mock_payer/light_ehr_supported_payer_endpoint.rb @@ -0,0 +1,21 @@ +require 'json' # TEMP +require 'sinatra/base' # TEMP + +module DaVinciDTRTestKit + module Endpoints + module MockPayer + class LightEHRSupportedPayerEndpoint < Sinatra::Base + get '/supported-payers' do + content_type :json + status 200 + { + payers: [ + { id: 'payer1', name: 'Payer One' }, + { id: 'payer2', name: 'Payer Two' } + ] + }.to_json + end + end + end + end +end diff --git a/spec/davinci_dtr_test_kit/endpoints/mock_payer/light_ehr_supported_payer_endpoint_spec.rb b/spec/davinci_dtr_test_kit/endpoints/mock_payer/light_ehr_supported_payer_endpoint_spec.rb new file mode 100644 index 0000000..f9e3c9a --- /dev/null +++ b/spec/davinci_dtr_test_kit/endpoints/mock_payer/light_ehr_supported_payer_endpoint_spec.rb @@ -0,0 +1,54 @@ +require_relative '../../../request_helper' + +RSpec.describe DaVinciDTRTestKit::Endpoints::MockPayer::LightEHRSupportedPayerEndpoint do + include Rack::Test::Methods + + def app + Inferno::Web.app + end + + let(:suite_id) { :dtr_light_ehr } + let(:resume_pass_url) { "/custom/#{suite_id}/resume_pass" } + let(:resume_fail_url) { "/custom/#{suite_id}/resume_fail" } + let(:session_data_repo) { Inferno::Repositories::SessionData.new } + let(:test_session) { repo_create(:test_session, test_suite_id: suite_id) } + let(:test_runs_repo) { Inferno::Repositories::TestRuns.new } + let(:results_repo) { Inferno::Repositories::Results.new } + + def run(runnable, test_session, inputs = {}) + test_run_params = { test_session_id: test_session.id }.merge(runnable.reference_hash) + test_run = Inferno::Repositories::TestRuns.new.create(test_run_params) + inputs.each do |name, value| + session_data_repo.save( + test_session_id: test_session.id, + name:, + value:, + type: runnable.config.input_type(name) || :text + ) + end + Inferno::TestRunner.new(test_session:, test_run:).run(runnable) + end + + describe 'Supported Payers Endpoint' do + let(:runnable) { Inferno::Repositories::TestGroups.new.find('light_ehr_supported_payer_endpoint') } + + it 'passes when a request is made to the supported payers endpoint' do + allow_any_instance_of(DaVinciDTRTestKit::URLs).to( + receive(:suite_id).and_return(suite_id) + ) + + result = repo_create(:result, test_session_id: test_session.id) + repo_create(:request, result_id: result.id, name: 'supported_payers', request_body: nil, + test_session_id: test_session.id, tags: ['supported_payers']) + + result = run(runnable, test_session) + expect(result.result).to eq('wait') + + token = test_runs_repo.last_test_run(test_session.id).identifier + get("#{resume_pass_url}?token=#{token}") + + result = results_repo.find(result.id) + expect(result.result).to eq('pass') + end + end +end From 72cc18fb7574e273ec93d5eca75e059738804147 Mon Sep 17 00:00:00 2001 From: degradification Date: Mon, 16 Dec 2024 14:31:21 -0500 Subject: [PATCH 2/6] Updated ACCEPT requirement --- .../light_ehr_supported_payer_endpoint.rb | 22 ++++++++++++------- ...light_ehr_supported_payer_endpoint_spec.rb | 17 +++++++++++--- 2 files changed, 28 insertions(+), 11 deletions(-) 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 5aee5c1..0db9ac4 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 @@ -6,14 +6,20 @@ module Endpoints module MockPayer class LightEHRSupportedPayerEndpoint < Sinatra::Base get '/supported-payers' do - content_type :json - status 200 - { - payers: [ - { id: 'payer1', name: 'Payer One' }, - { id: 'payer2', name: 'Payer Two' } - ] - }.to_json + if request.env['HTTP_ACCEPT'] == 'application/json' + content_type :json + status 200 + { + payers: [ + { id: 'payer1', name: 'Payer One' }, + { id: 'payer2', name: 'Payer Two' } + ] + }.to_json + else + status 406 + content_type :json + { error: 'Not Acceptable', message: 'Accept header must be application/json' }.to_json + end end end end diff --git a/spec/davinci_dtr_test_kit/endpoints/mock_payer/light_ehr_supported_payer_endpoint_spec.rb b/spec/davinci_dtr_test_kit/endpoints/mock_payer/light_ehr_supported_payer_endpoint_spec.rb index f9e3c9a..0fbc8c2 100644 --- a/spec/davinci_dtr_test_kit/endpoints/mock_payer/light_ehr_supported_payer_endpoint_spec.rb +++ b/spec/davinci_dtr_test_kit/endpoints/mock_payer/light_ehr_supported_payer_endpoint_spec.rb @@ -33,10 +33,14 @@ def run(runnable, test_session, inputs = {}) let(:runnable) { Inferno::Repositories::TestGroups.new.find('light_ehr_supported_payer_endpoint') } it 'passes when a request is made to the supported payers endpoint' do - allow_any_instance_of(DaVinciDTRTestKit::URLs).to( - receive(:suite_id).and_return(suite_id) - ) + header 'Accept', 'application/json' + get '/supported-payers' + + expect(last_response.status).to eq(200) + expect(last_response.content_type).to eq('application/json') + expect(JSON.parse(last_response.body)['payers']).to be_an(Array) + # Additional test logic for asynchronous handling result = repo_create(:result, test_session_id: test_session.id) repo_create(:request, result_id: result.id, name: 'supported_payers', request_body: nil, test_session_id: test_session.id, tags: ['supported_payers']) @@ -50,5 +54,12 @@ def run(runnable, test_session, inputs = {}) result = results_repo.find(result.id) expect(result.result).to eq('pass') end + + it 'returns 406 when Accept header is missing or incorrect' do + get '/supported-payers' + + expect(last_response.status).to eq(406) + expect(JSON.parse(last_response.body)['error']).to eq('Not Acceptable') + end end end From 6a7a8500e6239abb8b293e0ecebe44deb10a5bf9 Mon Sep 17 00:00:00 2001 From: degradification Date: Tue, 17 Dec 2024 10:32:23 -0500 Subject: [PATCH 3/6] Updated endpoints to use Inferno constructs -Updated route definition -TODO: Fix endpoint configuration --- .../dtr_light_ehr_suite.rb | 3 +- .../light_ehr_supported_payer_endpoint.rb | 45 ++++++++++++------- ...light_ehr_supported_payer_endpoint_spec.rb | 2 +- 3 files changed, 30 insertions(+), 20 deletions(-) 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 f241540..b3953cb 100644 --- a/lib/davinci_dtr_test_kit/dtr_light_ehr_suite.rb +++ b/lib/davinci_dtr_test_kit/dtr_light_ehr_suite.rb @@ -56,8 +56,7 @@ class DTRLightEHRSuite < Inferno::TestSuite end end - route :get, '/supported-payers', Endpoints::MockPayer::LightEHRSupportedPayerEndpoint - + route :get, '/supported-payers', DaVinciDTRTestKit::Endpoints::MockPayer::LightEHRSupportedPayerEndpoint group do title 'Authorization' 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 0db9ac4..eaaa7d7 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,25 +1,36 @@ -require 'json' # TEMP -require 'sinatra/base' # TEMP +require_relative '../mock_payer' module DaVinciDTRTestKit module Endpoints module MockPayer - class LightEHRSupportedPayerEndpoint < Sinatra::Base - get '/supported-payers' do - if request.env['HTTP_ACCEPT'] == 'application/json' - content_type :json - status 200 - { - payers: [ - { id: 'payer1', name: 'Payer One' }, - { id: 'payer2', name: 'Payer Two' } - ] - }.to_json - else - status 406 - content_type :json - { error: 'Not Acceptable', message: 'Accept header must be application/json' }.to_json + class LightEHRSupportedPayerEndpoint < Inferno::DSL::SuiteEndpoint + include DaVinciDTRTestKit::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 + + response.status = 200 + response.body = { + payers: [ + { id: 'payer1', name: 'Payer One' }, + { id: 'payer2', name: 'Payer Two' } + ] + }.to_json + response.headers['Content-Type'] = 'application/json' + end + + def tags + ['supported_payers'] + end + + def name + 'light_ehr_supported_payer_endpoint' end end end diff --git a/spec/davinci_dtr_test_kit/endpoints/mock_payer/light_ehr_supported_payer_endpoint_spec.rb b/spec/davinci_dtr_test_kit/endpoints/mock_payer/light_ehr_supported_payer_endpoint_spec.rb index 0fbc8c2..2ed03d0 100644 --- a/spec/davinci_dtr_test_kit/endpoints/mock_payer/light_ehr_supported_payer_endpoint_spec.rb +++ b/spec/davinci_dtr_test_kit/endpoints/mock_payer/light_ehr_supported_payer_endpoint_spec.rb @@ -1,4 +1,5 @@ require_relative '../../../request_helper' +require_relative '../../../../lib/davinci_dtr_test_kit/endpoints/mock_payer/light_ehr_supported_payer_endpoint' RSpec.describe DaVinciDTRTestKit::Endpoints::MockPayer::LightEHRSupportedPayerEndpoint do include Rack::Test::Methods @@ -40,7 +41,6 @@ def run(runnable, test_session, inputs = {}) expect(last_response.content_type).to eq('application/json') expect(JSON.parse(last_response.body)['payers']).to be_an(Array) - # Additional test logic for asynchronous handling result = repo_create(:result, test_session_id: test_session.id) repo_create(:request, result_id: result.id, name: 'supported_payers', request_body: nil, test_session_id: test_session.id, tags: ['supported_payers']) From 31cec0c1aea27dcd5e0ee621ee784ca8066c3d1d Mon Sep 17 00:00:00 2001 From: degradification Date: Wed, 18 Dec 2024 13:50:43 -0500 Subject: [PATCH 4/6] 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 From a9543e0ee8df64d7870c2a25f10b1a9c59d86517 Mon Sep 17 00:00:00 2001 From: degradification Date: Thu, 19 Dec 2024 09:54:21 -0500 Subject: [PATCH 5/6] Updated descriptions/fixed typos & adjusted the unit test path -TODO: Ensure the endpoint can be while unit testing --- .../light_ehr/dtr_light_ehr_supported_endpoints_group.rb | 4 ++-- lib/davinci_dtr_test_kit/dtr_light_ehr_suite.rb | 4 ++-- ...c.rb => dtr_light_ehr_supported_endpoints_group_spec.rb} | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) rename spec/davinci_dtr_test_kit/{endpoints/mock_payer/light_ehr_supported_payer_endpoint_spec.rb => dtr_light_ehr_supported_endpoints_group_spec.rb} (90%) 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 index ef81b24..6674d66 100644 --- 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 @@ -1,9 +1,9 @@ require_relative 'dtr_light_ehr_supported_payer_endpoint_test' module DaVinciDTRTestKit - class DtrLightEhrSupportedEndpointsGroup < Inferno::TestGroup + class DTRLightEhrSupportedEndpointsGroup < Inferno::TestGroup id :dtr_light_ehr_supported_endpoints - title 'Supported Endpoints' + title 'DTR Supported Endpoints' description %( Demonstrate the ability to access supported endpoints ) 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 7fdbd02..9361c05 100644 --- a/lib/davinci_dtr_test_kit/dtr_light_ehr_suite.rb +++ b/lib/davinci_dtr_test_kit/dtr_light_ehr_suite.rb @@ -142,10 +142,10 @@ class DTRLightEHRSuite < Inferno::TestSuite end group do - title 'Supported Endpoints' + title 'DTR Light EHR 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 + Templates and Rules (DTR) v2.0.1 Implementation Guide Light DTR EHR Capability Statement. ) diff --git a/spec/davinci_dtr_test_kit/endpoints/mock_payer/light_ehr_supported_payer_endpoint_spec.rb b/spec/davinci_dtr_test_kit/dtr_light_ehr_supported_endpoints_group_spec.rb similarity index 90% rename from spec/davinci_dtr_test_kit/endpoints/mock_payer/light_ehr_supported_payer_endpoint_spec.rb rename to spec/davinci_dtr_test_kit/dtr_light_ehr_supported_endpoints_group_spec.rb index 2ed03d0..11b64b4 100644 --- a/spec/davinci_dtr_test_kit/endpoints/mock_payer/light_ehr_supported_payer_endpoint_spec.rb +++ b/spec/davinci_dtr_test_kit/dtr_light_ehr_supported_endpoints_group_spec.rb @@ -1,8 +1,8 @@ -require_relative '../../../request_helper' -require_relative '../../../../lib/davinci_dtr_test_kit/endpoints/mock_payer/light_ehr_supported_payer_endpoint' +require_relative '../request_helper' -RSpec.describe DaVinciDTRTestKit::Endpoints::MockPayer::LightEHRSupportedPayerEndpoint do +RSpec.describe DaVinciDTRTestKit::DTRLightEhrSupportedEndpointsGroup do include Rack::Test::Methods + include RequestHelpers def app Inferno::Web.app From 078f8160a12fbf6ed4748766130540e13c11a220 Mon Sep 17 00:00:00 2001 From: degradification Date: Thu, 26 Dec 2024 15:24:17 -0500 Subject: [PATCH 6/6] Addressed MR comments -TODO: Address the endpoint configuration for spec file --- ...dtr_light_ehr_supported_endpoints_group.rb | 11 ++-- ...light_ehr_supported_payer_endpoint_test.rb | 5 +- .../dtr_light_ehr_suite.rb | 14 +---- .../light_ehr_supported_payer_endpoint.rb | 63 +++++++++---------- ...ehr_supported_payer_endpoint_test_spec.rb} | 10 +-- 5 files changed, 49 insertions(+), 54 deletions(-) rename spec/davinci_dtr_test_kit/{dtr_light_ehr_supported_endpoints_group_spec.rb => dtr_light_ehr_supported_payer_endpoint_test_spec.rb} (86%) 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 index 6674d66..cc43df1 100644 --- 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 @@ -3,10 +3,13 @@ module DaVinciDTRTestKit class DTRLightEhrSupportedEndpointsGroup < Inferno::TestGroup id :dtr_light_ehr_supported_endpoints - title 'DTR Supported Endpoints' - description %( - Demonstrate the ability to access supported endpoints - ) + 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. + + ) run_as_group test from: :dtr_light_ehr_supported_payer_endpoint 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 index 1f37db7..62668cc 100644 --- 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 @@ -1,12 +1,13 @@ require_relative '../../urls' module DaVinciDTRTestKit - class DtrLightEhrSupportedPayerEndpointTest < Inferno::Test + 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. + This test verifies that the app can successfully access the supported payer endpoint via a GET request, + including an Accept header set to application/json ) input :access_token, description: %( 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 9361c05..ebbc9ac 100644 --- a/lib/davinci_dtr_test_kit/dtr_light_ehr_suite.rb +++ b/lib/davinci_dtr_test_kit/dtr_light_ehr_suite.rb @@ -57,7 +57,7 @@ class DTRLightEHRSuite < Inferno::TestSuite end end - suite_endpoint :get, SUPPORTED_PAYER_PATH, MockPayer::LightEHRSupportedPayerEndpoint + suite_endpoint :get, SUPPORTED_PAYER_PATH, LightEHRSupportedPayerEndpoint group do title 'Authorization' @@ -141,16 +141,6 @@ class DTRLightEHRSuite < Inferno::TestSuite group from: :vision_prescription_group end - group do - title 'DTR Light EHR 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 + group from: :dtr_light_ehr_supported_endpoints 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 886ad62..61c32bd 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,44 +1,43 @@ -require_relative '../mock_payer' require_relative '../../tags' module DaVinciDTRTestKit - module MockPayer - class LightEHRSupportedPayerEndpoint < Inferno::DSL::SuiteEndpoint - include MockPayer - - def name - 'light_ehr_supported_payer_endpoint' - end - - def test_run_identifier - request.headers['authorization']&.delete_prefix('Bearer ') - end + class LightEHRSupportedPayerEndpoint < Inferno::DSL::SuiteEndpoint + def name + 'light_ehr_supported_payer_endpoint' + end - def tags - [SUPPORTED_PAYER_TAG] - end + def test_run_identifier + request.headers['authorization']&.delete_prefix('Bearer ') + end - 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_PAYER_TAG] + end - response.status = 200 + 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 = { - payers: [ - { id: 'payer1', name: 'Payer One' }, - { id: 'payer2', name: 'Payer Two' } - ] - }.to_json + response.body = { error: 'Not Acceptable', message: 'Accept header must be application/json' }.to_json + return end - def update_result - results_repo.update_result(result.id, 'pass') unless test.config.options[:accepts_multiple_requests] + 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 update_result + if request.headers['Accept'] == 'application/json' + results_repo.update_result(result.id, 'pass') + else + results_repo.update_result(result.id, 'fail') end end end diff --git a/spec/davinci_dtr_test_kit/dtr_light_ehr_supported_endpoints_group_spec.rb b/spec/davinci_dtr_test_kit/dtr_light_ehr_supported_payer_endpoint_test_spec.rb similarity index 86% rename from spec/davinci_dtr_test_kit/dtr_light_ehr_supported_endpoints_group_spec.rb rename to spec/davinci_dtr_test_kit/dtr_light_ehr_supported_payer_endpoint_test_spec.rb index 11b64b4..dda3c34 100644 --- a/spec/davinci_dtr_test_kit/dtr_light_ehr_supported_endpoints_group_spec.rb +++ b/spec/davinci_dtr_test_kit/dtr_light_ehr_supported_payer_endpoint_test_spec.rb @@ -1,6 +1,6 @@ require_relative '../request_helper' -RSpec.describe DaVinciDTRTestKit::DTRLightEhrSupportedEndpointsGroup do +RSpec.describe DaVinciDTRTestKit::DTRLightEhrSupportedPayerEndpointTest do include Rack::Test::Methods include RequestHelpers @@ -8,9 +8,11 @@ def app Inferno::Web.app end + let(:group) { Inferno::Repositories::TestGroups.new.find('dtr_light_ehr_supported_payer_endpoint') } let(:suite_id) { :dtr_light_ehr } let(:resume_pass_url) { "/custom/#{suite_id}/resume_pass" } let(:resume_fail_url) { "/custom/#{suite_id}/resume_fail" } + let(:supported_payer_url) { "/custom/#{suite_id}/supported_payers" } let(:session_data_repo) { Inferno::Repositories::SessionData.new } let(:test_session) { repo_create(:test_session, test_suite_id: suite_id) } let(:test_runs_repo) { Inferno::Repositories::TestRuns.new } @@ -35,7 +37,7 @@ def run(runnable, test_session, inputs = {}) it 'passes when a request is made to the supported payers endpoint' do header 'Accept', 'application/json' - get '/supported-payers' + get supported_payer_url expect(last_response.status).to eq(200) expect(last_response.content_type).to eq('application/json') @@ -43,7 +45,7 @@ def run(runnable, test_session, inputs = {}) result = repo_create(:result, test_session_id: test_session.id) repo_create(:request, result_id: result.id, name: 'supported_payers', request_body: nil, - test_session_id: test_session.id, tags: ['supported_payers']) + test_session_id: test_session.id, tags: [SUPPORTED_PAYER_TAG]) result = run(runnable, test_session) expect(result.result).to eq('wait') @@ -56,7 +58,7 @@ def run(runnable, test_session, inputs = {}) end it 'returns 406 when Accept header is missing or incorrect' do - get '/supported-payers' + get supported_payer_url expect(last_response.status).to eq(406) expect(JSON.parse(last_response.body)['error']).to eq('Not Acceptable')