Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add USCore 3.1.1 test group, CRD profile tests #26

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
8 changes: 7 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ PATH
inferno_core (~> 0.5.0)
jwt (~> 2.6)
smart_app_launch_test_kit (~> 0.4.4)
tls_test_kit (= 0.2.2)
us_core_test_kit (= 0.9.0)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -291,7 +293,7 @@ GEM
connection_pool (>= 2.3.0)
rack (>= 2.2.4)
redis-client (>= 0.19.0)
smart_app_launch_test_kit (0.4.4)
smart_app_launch_test_kit (0.4.6)
inferno_core (>= 0.4.2)
json-jwt (~> 1.15.3)
jwt (~> 2.6)
Expand Down Expand Up @@ -324,6 +326,10 @@ GEM
concurrent-ruby (~> 1.0)
unicode-display_width (2.6.0)
unicode_utils (1.4.0)
us_core_test_kit (0.9.0)
inferno_core (>= 0.4.37)
smart_app_launch_test_kit (>= 0.4.6)
tls_test_kit (~> 0.2.0)
webmock (3.23.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
Expand Down
59 changes: 58 additions & 1 deletion config/presets/inferno_dtr_server_suite.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"description": "URL of the FHIR endpoint used by SMART applications",
"title": "FHIR Endpoint",
"type": "text",
"value": "https://inferno-qa.healthit.gov/reference-server/r4"
"value": "http://localhost:8080/reference-server/r4"
},
{
"name": "ehr_client_id",
Expand All @@ -21,6 +21,63 @@
"name": "standalone_client_id",
"type": "text",
"value": "SAMPLE_PUBLIC_CLIENT_ID"
},
{
"name": "smart_credentials",
"type": "oauth_credentials",
"title": "OAuth Credentials",
"optional": true,
"value": "{\"access_token\":\"SAMPLE_TOKEN\"}"
},
{
"name": "patient_ids",
"type": "text",
"value": "pat001"
},
{
"name": "coverage_ids",
"type": "text",
"value": "coverage-example1"
},
{
"name": "communication_request_ids",
"type": "text",
"value": "communicationrequest-example1"
},
{
"name": "device_request_ids",
"type": "text",
"value": "devicerequest-example1"
},
{
"name": "encounter_ids",
"type": "text",
"value": "encounter-example1"
},
{
"name": "medication_request_ids",
"type": "text",
"value": "medicationrequest-example1"
},
{
"name": "nutrition_order_ids",
"type": "text",
"value": "nutritionorder-example1"
},
{
"name": "service_request_ids",
"type": "text",
"value": "servicerequest-example1"
},
{
"name": "task_ids",
"type": "text",
"value": "cdex-task-example19"
},
{
"name": "vision_prescription_ids",
"type": "text",
"value": "visionprescription-example,visionprescription-example2"
}
]
}
2 changes: 2 additions & 0 deletions davinci_dtr_test_kit.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Gem::Specification.new do |spec|
spec.add_dependency 'inferno_core', '~> 0.5.0'
spec.add_dependency 'jwt', '~> 2.6'
spec.add_dependency 'smart_app_launch_test_kit', '~> 0.4.4'
spec.add_dependency 'tls_test_kit', '0.2.2'
spec.add_dependency 'us_core_test_kit', '0.9.0'
spec.required_ruby_version = Gem::Requirement.new('>= 3.1.2')
spec.metadata['homepage_uri'] = spec.homepage
spec.metadata['source_code_uri'] = spec.homepage
Expand Down
157 changes: 157 additions & 0 deletions lib/davinci_dtr_test_kit/dtr_light_ehr_suite.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
require_relative 'ext/inferno_core/runnable'
require_relative 'ext/inferno_core/record_response_route'
require_relative 'ext/inferno_core/request'
require 'us_core_test_kit'
require 'tls_test_kit'
require_relative 'version'
require_relative 'dtr_options'
require_relative 'profiles/questionnaire_response/questionnaire_response_patient_search'
require_relative 'profiles/questionnaire_response/questionnaire_response_context_search'
require_relative 'profiles/questionnaire_response/questionnaire_response_read'
require_relative 'profiles/questionnaire_response/questionnaire_response_validation'
require_relative 'profiles/coverage/coverage_read'
require_relative 'profiles/coverage/coverage_validation'
require_relative 'profiles/communication_request/communication_request_read'
require_relative 'profiles/communication_request/communication_request_validation'
require_relative 'profiles/device_request/device_request_read'
require_relative 'profiles/device_request/device_request_validation'
require_relative 'profiles/encounter/encounter_read'
require_relative 'profiles/encounter/encounter_validation'
require_relative 'profiles/medication_request/medication_request_read'
require_relative 'profiles/medication_request/medication_request_validation'
require_relative 'profiles/nutrition_order/nutrition_order_read'
require_relative 'profiles/nutrition_order/nutrition_order_validation'
require_relative 'profiles/service_request/service_request_read'
require_relative 'profiles/service_request/service_request_validation'
require_relative 'profiles/task/task_read'
require_relative 'profiles/task/task_validation'
require_relative 'profiles/vision_prescription/vision_prescription_read'
require_relative 'profiles/vision_prescription/vision_prescription_validation'
require 'smart_app_launch/smart_stu1_suite'
require 'smart_app_launch/smart_stu2_suite'

Expand Down Expand Up @@ -35,6 +61,15 @@ class DTRLightEHRSuite < Inferno::TestSuite
title: 'FHIR Endpoint',
description: 'URL of the DTR FHIR server'

# Hl7 Validator Wrapper:
fhir_resource_validator do
igs('hl7.fhir.us.davinci-dtr#2.0.1', 'hl7.fhir.us.davinci-cdex#2.0.0', 'hl7.fhir.us.davinci-crd#2.0.1')

exclude_message do |message|
message.message.match?(/\A\S+: \S+: URL value '.*' does not resolve/)
end
end

group do
title 'Authorization'

Expand Down Expand Up @@ -71,5 +106,127 @@ class DTRLightEHRSuite < Inferno::TestSuite
required_suite_options: DTROptions::SMART_2_REQUIREMENT,
run_as_group: true
end

group do
title 'FHIR API'

group from: :'us_core_v311-us_core_v311_fhir_api',
run_as_group: true
end

group do
title 'DTR Light EHR Profiles'

input :credentials,
title: 'OAuth Credentials',
type: :oauth_credentials,
optional: true

# All FHIR requests in this suite will use this FHIR client
fhir_client do
url :url
oauth_credentials :credentials
end

group do
title 'DTR QuestionnaireResponse'
run_as_group

test from: :questionnaire_response_patient_search
test from: :questionnaire_response_context_search
test from: :questionnaire_response_read
test from: :questionnaire_response_validation
end

group do
title 'CRD Coverage'
karlnaden marked this conversation as resolved.
Show resolved Hide resolved
run_as_group

input :coverage_ids

test from: :coverage_read
test from: :coverage_validation
end

group do
title 'CRD CommunicationRequest'
run_as_group

input :communication_request_ids

test from: :communication_request_read
test from: :communication_request_validation
end

group do
title 'CRD DeviceRequest'
run_as_group

input :device_request_ids

test from: :device_request_read
test from: :device_request_validation
end

group do
title 'CRD Encounter'
run_as_group

input :encounter_ids

test from: :encounter_read
test from: :encounter_validation
end

group do
title 'CRD MedicationRequest'
run_as_group

input :medication_request_ids

test from: :medication_request_read
test from: :medication_request_validation
end

group do
title 'CRD NutritionOrder'
run_as_group

input :nutrition_order_ids

test from: :nutrition_order_read
test from: :nutrition_order_validation
end

group do
title 'CRD ServiceRequest'
run_as_group

input :service_request_ids

test from: :service_request_read
test from: :service_request_validation
end

group do
title 'CDex Task'
run_as_group

input :task_ids

test from: :task_read
test from: :task_validation
end

group do
title 'CRD VisionPrescription'
run_as_group

input :vision_prescription_ids

test from: :vision_prescription_read
test from: :vision_prescription_validation
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require_relative '../../read_test'

module DaVinciDTRTestKit
class CommunicationRequestReadTest < Inferno::Test
include DaVinciDTRTestKit::ReadTest

title 'Server returns correct CommunicationRequest resource from CommunicationRequest read interaction'
description 'A server SHOULD support the CommunicationRequest read interaction.'

id :communication_request_read
output :communication_request_resources

def resource_type
'CommunicationRequest'
end

def communication_request_id_list
return [nil] unless respond_to? :communication_request_ids

communication_request_ids.split(',').map(&:strip)
end

run do
resources = perform_read_test(communication_request_id_list, resource_type)

output communication_request_resources: resources.to_json
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require_relative '../../validation_test'

module DaVinciDTRTestKit
class CommunicationRequestValidationTest < Inferno::Test
include DaVinciDTRTestKit::ValidationTest

title 'CommunicationRequest resources returned during previous tests conform to the CRD CommunicationRequest'
description %(
This test verifies resources returned from the first read conform to
the [CRD CommunicationRequest](https://hl7.org/fhir/us/davinci-crd/STU2/StructureDefinition-profile-communicationrequest).
Systems must demonstrate at least one valid example in order to pass this test.

It verifies the presence of mandatory elements and that elements with
required bindings contain appropriate values. CodeableConcept element
bindings will fail if none of their codings have a code/system belonging
to the bound ValueSet. Quantity, Coding, and code element bindings will
fail if their code/system are not found in the valueset.

)

id :communication_request_validation
input :communication_request_resources

def resource_type
'CommunicationRequest'
end

run do
perform_profile_validation_test(communication_request_resources, resource_type,
'http://hl7.org/fhir/us/davinci-crd/StructureDefinition/profile-communicationrequest|2.0.1')
end
end
end
29 changes: 29 additions & 0 deletions lib/davinci_dtr_test_kit/profiles/coverage/coverage_read.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require_relative '../../read_test'

module DaVinciDTRTestKit
class CoverageReadTest < Inferno::Test
include DaVinciDTRTestKit::ReadTest

title 'Server returns correct Coverage resource from Coverage read interaction'
description 'A server SHALL support the Coverage read interaction.'

id :coverage_read
output :coverage_resources

def resource_type
'Coverage'
end

def coverage_id_list
return [nil] unless respond_to? :coverage_ids

coverage_ids.split(',').map(&:strip)
end

run do
resources = perform_read_test(coverage_id_list, resource_type)

output coverage_resources: resources.to_json
end
end
end
Loading
Loading