Skip to content

Commit

Permalink
Updated Supported Payer Endpoint to properly perform requests
Browse files Browse the repository at this point in the history
-Added test for supported payer
  • Loading branch information
degradification committed Dec 18, 2024
1 parent 6a7a850 commit 31cec0c
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
16 changes: 15 additions & 1 deletion lib/davinci_dtr_test_kit/dtr_light_ehr_suite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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'

Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/davinci_dtr_test_kit/tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions lib/davinci_dtr_test_kit/urls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 31cec0c

Please sign in to comment.