uds_plus_test_kit 0.9.1 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/uds_plus_test_kit/examples/condition.ndjson +1 -0
- data/lib/uds_plus_test_kit/examples/encounter.ndjson +1 -0
- data/lib/uds_plus_test_kit/examples/invalid_condition.ndjson +1 -0
- data/lib/uds_plus_test_kit/examples/invalid_encounter.ndjson +1 -0
- data/lib/uds_plus_test_kit/examples/invalid_patient.ndjson +2 -0
- data/lib/uds_plus_test_kit/examples/manifest.json +76 -14
- data/lib/uds_plus_test_kit/examples/observation.ndjson +3 -0
- data/lib/uds_plus_test_kit/examples/patient.ndjson +2 -0
- data/lib/uds_plus_test_kit/input_resource_tests/read_immunization_test.rb +54 -0
- data/lib/uds_plus_test_kit/input_resource_tests/read_lab_test.rb +54 -0
- data/lib/uds_plus_test_kit/input_resource_tests/read_med_request_test.rb +54 -0
- data/lib/uds_plus_test_kit/input_resource_tests/read_med_statement_test.rb +54 -0
- data/lib/uds_plus_test_kit/input_resource_tests/read_related_person_test.rb +54 -0
- data/lib/uds_plus_test_kit/input_resource_tests/read_service_request_test.rb +54 -0
- data/lib/uds_plus_test_kit/input_resource_tests/read_special_observation_test.rb +54 -0
- data/lib/uds_plus_test_kit/input_resource_tests/resource_group.rb +30 -2
- data/lib/uds_plus_test_kit/manifest_tests/invalid_type_test.rb +4 -1
- data/lib/uds_plus_test_kit/manifest_tests/uds_plus_test_group.rb +16 -2
- data/lib/uds_plus_test_kit/post_tests/post_group.rb +59 -0
- data/lib/uds_plus_test_kit/post_tests/post_manifest_test.rb +41 -0
- data/lib/uds_plus_test_kit/post_tests/read_post_test.rb +32 -0
- data/lib/uds_plus_test_kit/uds_plus_test_suite.rb +40 -0
- data/lib/uds_plus_test_kit/validate_immunization_test.rb +33 -0
- data/lib/uds_plus_test_kit/validate_income_test.rb +7 -10
- data/lib/uds_plus_test_kit/validate_lab_test.rb +65 -0
- data/lib/uds_plus_test_kit/validate_med_request_test.rb +33 -0
- data/lib/uds_plus_test_kit/validate_med_statement_test.rb +33 -0
- data/lib/uds_plus_test_kit/validate_related_person_test.rb +33 -0
- data/lib/uds_plus_test_kit/validate_service_request_test.rb +33 -0
- data/lib/uds_plus_test_kit/validate_sexual_orientation_test.rb +6 -9
- data/lib/uds_plus_test_kit/validate_special_observation_test.rb +65 -0
- data/lib/uds_plus_test_kit/version.rb +2 -2
- metadata +26 -4
- data/lib/uds_plus_test_kit/examples/manifest_2.json +0 -101
- data/lib/uds_plus_test_kit/examples/manifest_not_deidentified.json +0 -67
@@ -15,6 +15,20 @@ require_relative '../validate_procedure_test'
|
|
15
15
|
require_relative '../validate_sexual_orientation_test'
|
16
16
|
require_relative './read_manifest_ind_test'
|
17
17
|
require_relative '../manifest_tests/validate_manifest_test'
|
18
|
+
require_relative './read_special_observation_test'
|
19
|
+
require_relative '../validate_special_observation_test'
|
20
|
+
require_relative './read_related_person_test'
|
21
|
+
require_relative '../validate_related_person_test'
|
22
|
+
require_relative './read_immunization_test'
|
23
|
+
require_relative '../validate_immunization_test'
|
24
|
+
require_relative './read_lab_test'
|
25
|
+
require_relative '../validate_lab_test'
|
26
|
+
require_relative './read_med_request_test'
|
27
|
+
require_relative '../validate_med_request_test'
|
28
|
+
require_relative './read_med_statement_test'
|
29
|
+
require_relative '../validate_med_statement_test'
|
30
|
+
require_relative './read_service_request_test'
|
31
|
+
require_relative '../validate_service_request_test'
|
18
32
|
|
19
33
|
module UDSPlusTestKit
|
20
34
|
class UDSPlusResourceTestGroup < Inferno::TestGroup
|
@@ -39,13 +53,27 @@ module UDSPlusTestKit
|
|
39
53
|
test from: :uds_plus_validate_diagnosis_test
|
40
54
|
test from: :uds_plus_read_encounter_test
|
41
55
|
test from: :uds_plus_validate_encounter_test
|
42
|
-
test from: :uds_plus_read_income_test
|
43
|
-
test from: :uds_plus_validate_income_test
|
44
56
|
test from: :uds_plus_read_patient_test
|
45
57
|
test from: :uds_plus_validate_patient_test
|
46
58
|
test from: :uds_plus_read_procedure_test
|
47
59
|
test from: :uds_plus_validate_procedure_test
|
60
|
+
test from: :uds_plus_read_related_person_test
|
61
|
+
test from: :uds_plus_validate_related_person_test
|
62
|
+
test from: :uds_plus_read_immunization_test
|
63
|
+
test from: :uds_plus_validate_immunization_test
|
64
|
+
test from: :uds_plus_read_income_test
|
65
|
+
test from: :uds_plus_validate_income_test
|
48
66
|
test from: :uds_plus_read_sexual_orientation_test
|
49
67
|
test from: :uds_plus_validate_sexual_orientation_test
|
68
|
+
test from: :uds_plus_read_lab_test
|
69
|
+
test from: :uds_plus_validate_lab_test
|
70
|
+
test from: :uds_plus_read_special_observation_test
|
71
|
+
test from: :uds_plus_read_medication_request_test
|
72
|
+
test from: :uds_plus_validate_medication_request_test
|
73
|
+
test from: :uds_plus_read_medication_statement_test
|
74
|
+
test from: :uds_plus_validate_medication_statement_test
|
75
|
+
test from: :uds_plus_read_service_request_test
|
76
|
+
test from: :uds_plus_validate_service_request_test
|
77
|
+
test from: :uds_plus_validate_special_observation_test
|
50
78
|
end
|
51
79
|
end
|
@@ -17,7 +17,10 @@ module UDSPlusTestKit
|
|
17
17
|
def valid_data_types
|
18
18
|
[
|
19
19
|
'Coverage', 'Condition', 'Encounter',
|
20
|
-
'Observation', 'Patient', 'Procedure'
|
20
|
+
'Observation', 'Patient', 'Procedure',
|
21
|
+
'RelatedPerson', 'Immunization',
|
22
|
+
'ServiceRequest', 'MedicationRequest',
|
23
|
+
'MedicationStatement'
|
21
24
|
]
|
22
25
|
end
|
23
26
|
|
@@ -10,10 +10,17 @@ require_relative './validate_manifest_test'
|
|
10
10
|
require_relative '../validate_patient_test'
|
11
11
|
require_relative '../validate_procedure_test'
|
12
12
|
require_relative '../validate_sexual_orientation_test'
|
13
|
+
require_relative '../validate_special_observation_test'
|
14
|
+
require_relative '../validate_related_person_test'
|
15
|
+
require_relative '../validate_immunization_test'
|
16
|
+
require_relative '../validate_lab_test'
|
17
|
+
require_relative '../validate_med_request_test'
|
18
|
+
require_relative '../validate_med_statement_test'
|
19
|
+
require_relative '../validate_service_request_test'
|
13
20
|
|
14
21
|
module UDSPlusTestKit
|
15
22
|
class UDSPlusTestGroup < Inferno::TestGroup
|
16
|
-
title '
|
23
|
+
title 'Import Manifest Tests'
|
17
24
|
id :uds_plus_test_group
|
18
25
|
description %(
|
19
26
|
The tests below validate the import manifest produced by a UDS+ Data Submitter.
|
@@ -30,10 +37,17 @@ module UDSPlusTestKit
|
|
30
37
|
test from: :uds_plus_validate_coverage_test
|
31
38
|
test from: :uds_plus_validate_diagnosis_test
|
32
39
|
test from: :uds_plus_validate_encounter_test
|
33
|
-
test from: :uds_plus_validate_income_test
|
34
40
|
test from: :uds_plus_validate_patient_test
|
35
41
|
test from: :uds_plus_validate_procedure_test
|
42
|
+
test from: :uds_plus_validate_related_person_test
|
43
|
+
test from: :uds_plus_validate_immunization_test
|
44
|
+
test from: :uds_plus_validate_income_test
|
36
45
|
test from: :uds_plus_validate_sexual_orientation_test
|
46
|
+
test from: :uds_plus_validate_lab_test
|
47
|
+
test from: :uds_plus_validate_special_observation_test
|
48
|
+
test from: :uds_plus_validate_medication_request_test
|
49
|
+
test from: :uds_plus_validate_medication_statement_test
|
50
|
+
test from: :uds_plus_validate_service_request_test
|
37
51
|
test from: :uds_plus_invalid_type_test
|
38
52
|
end
|
39
53
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
|
2
|
+
require_relative '../version'
|
3
|
+
|
4
|
+
require_relative './post_manifest_test'
|
5
|
+
require_relative './read_post_test'
|
6
|
+
|
7
|
+
require_relative '../manifest_tests/invalid_type_test'
|
8
|
+
require_relative '../manifest_tests/read_data_test'
|
9
|
+
require_relative '../manifest_tests/validate_manifest_test'
|
10
|
+
|
11
|
+
require_relative '../validate_coverage_test'
|
12
|
+
require_relative '../validate_diagnosis_test'
|
13
|
+
require_relative '../validate_encounter_test'
|
14
|
+
require_relative '../validate_income_test'
|
15
|
+
require_relative '../validate_patient_test'
|
16
|
+
require_relative '../validate_procedure_test'
|
17
|
+
require_relative '../validate_sexual_orientation_test'
|
18
|
+
require_relative '../validate_special_observation_test'
|
19
|
+
require_relative '../validate_related_person_test'
|
20
|
+
require_relative '../validate_immunization_test'
|
21
|
+
require_relative '../validate_lab_test'
|
22
|
+
require_relative '../validate_med_request_test'
|
23
|
+
require_relative '../validate_med_statement_test'
|
24
|
+
require_relative '../validate_service_request_test'
|
25
|
+
|
26
|
+
module UDSPlusTestKit
|
27
|
+
class UDSPlusPostGroup < Inferno::TestGroup
|
28
|
+
title 'End-to-End Import Manifest Tests'
|
29
|
+
id :uds_plus_manifest_post_group
|
30
|
+
description %(
|
31
|
+
The tests below validate the import manifest produced by a UDS+ Data Submitter.
|
32
|
+
This receiver will take a provided Import Manifest via POST request to a given
|
33
|
+
location and validate its contents. This includes validating the structure
|
34
|
+
of the manifest, as well as the structure of the data the manifest points to.
|
35
|
+
)
|
36
|
+
|
37
|
+
run_as_group
|
38
|
+
|
39
|
+
test from: :uds_plus_post_manifest_test
|
40
|
+
test from: :uds_plus_read_post_test
|
41
|
+
test from: :uds_plus_validate_manifest_test
|
42
|
+
test from: :uds_plus_read_data_test
|
43
|
+
test from: :uds_plus_validate_coverage_test
|
44
|
+
test from: :uds_plus_validate_diagnosis_test
|
45
|
+
test from: :uds_plus_validate_encounter_test
|
46
|
+
test from: :uds_plus_validate_patient_test
|
47
|
+
test from: :uds_plus_validate_procedure_test
|
48
|
+
test from: :uds_plus_validate_related_person_test
|
49
|
+
test from: :uds_plus_validate_immunization_test
|
50
|
+
test from: :uds_plus_validate_income_test
|
51
|
+
test from: :uds_plus_validate_sexual_orientation_test
|
52
|
+
test from: :uds_plus_validate_lab_test
|
53
|
+
test from: :uds_plus_validate_special_observation_test
|
54
|
+
test from: :uds_plus_validate_medication_request_test
|
55
|
+
test from: :uds_plus_validate_medication_statement_test
|
56
|
+
test from: :uds_plus_validate_service_request_test
|
57
|
+
test from: :uds_plus_invalid_type_test
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
|
4
|
+
module UDSPlusTestKit
|
5
|
+
class PostManifestTest < Inferno::Test
|
6
|
+
id :uds_plus_post_manifest_test
|
7
|
+
title 'Receive UDS+ Import Manifest via POST request'
|
8
|
+
description %(
|
9
|
+
Test waits for an import manifest to be posted at the
|
10
|
+
provided location. Test passes if it recieves a post
|
11
|
+
request within 3 mins of test start.
|
12
|
+
)
|
13
|
+
|
14
|
+
receives_request :import_manifest
|
15
|
+
|
16
|
+
def id_gen
|
17
|
+
output = ''
|
18
|
+
ranNum = Random.new
|
19
|
+
for _ in 1..10
|
20
|
+
output += ranNum.rand(10).to_s
|
21
|
+
end
|
22
|
+
output
|
23
|
+
end
|
24
|
+
|
25
|
+
run do
|
26
|
+
session_id = id_gen
|
27
|
+
wait(
|
28
|
+
identifier: session_id,
|
29
|
+
timeout: 300,
|
30
|
+
message: %(
|
31
|
+
Post your Import Manifest JSON to the following URL:
|
32
|
+
#{Inferno::Application['base_url']}/custom/uds_plus/postHere?id=#{session_id}
|
33
|
+
|
34
|
+
If the test times out or is cancelled for any reason, rerunning the test group will restart the timeout.
|
35
|
+
|
36
|
+
Your request body MUST be your Import Manifest in raw json format. Testing will resume automatically after a valid POST is received.
|
37
|
+
)
|
38
|
+
)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
|
4
|
+
module UDSPlusTestKit
|
5
|
+
class ReadPostTest < Inferno::Test
|
6
|
+
id :uds_plus_read_post_test
|
7
|
+
title 'Read Input from POST Request'
|
8
|
+
description %(
|
9
|
+
Test takes the file POSTed in the previous test,
|
10
|
+
and validates whether a FHIR resource can be generated from the input data.
|
11
|
+
)
|
12
|
+
|
13
|
+
uses_request :import_manifest
|
14
|
+
|
15
|
+
def manifest_scratch
|
16
|
+
scratch[:manifest_resources] ||= {}
|
17
|
+
end
|
18
|
+
|
19
|
+
def manifest_resources
|
20
|
+
manifest_scratch[:all] ||= []
|
21
|
+
end
|
22
|
+
|
23
|
+
run do
|
24
|
+
found_resource = FHIR::Json.from_json(request.request_body)
|
25
|
+
assert found_resource.is_a?(FHIR::Model), "Could not generate a valid resource from the input provided"
|
26
|
+
|
27
|
+
if found_resource.is_a?(FHIR::Model)
|
28
|
+
manifest_resources << found_resource
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -2,6 +2,7 @@ require 'inferno/dsl/oauth_credentials'
|
|
2
2
|
require_relative './version'
|
3
3
|
require_relative './manifest_tests/uds_plus_test_group'
|
4
4
|
require_relative './input_resource_tests/resource_group'
|
5
|
+
require_relative './post_tests/post_group'
|
5
6
|
|
6
7
|
module UDSPlusTestKit
|
7
8
|
class UDSPlusTestSuite < Inferno::TestSuite
|
@@ -29,6 +30,44 @@ module UDSPlusTestKit
|
|
29
30
|
|
30
31
|
id :uds_plus
|
31
32
|
|
33
|
+
# Example urls generated here
|
34
|
+
patient_ex = File.read(File.join(__dir__, 'examples/patient.ndjson'))
|
35
|
+
patient_ex_route_handler = proc { [200, { 'Content-Type' => 'application/ndjson' }, [patient_ex]] }
|
36
|
+
route(:get, "/examples/patient", patient_ex_route_handler)
|
37
|
+
|
38
|
+
condition_ex = File.read(File.join(__dir__, 'examples/condition.ndjson'))
|
39
|
+
condition_ex_route_handler = proc { [200, { 'Content-Type' => 'application/ndjson' }, [condition_ex]] }
|
40
|
+
route(:get, "/examples/condition", condition_ex_route_handler)
|
41
|
+
|
42
|
+
encounter_ex = File.read(File.join(__dir__, 'examples/encounter.ndjson'))
|
43
|
+
encounter_ex_route_handler = proc { [200, { 'Content-Type' => 'application/ndjson' }, [encounter_ex]] }
|
44
|
+
route(:get, "/examples/encounter", encounter_ex_route_handler)
|
45
|
+
|
46
|
+
manifest_ex = File.read(File.join(__dir__, 'examples/manifest.json'))
|
47
|
+
manifest_ex_route_handler = proc { [200, { 'Content-Type' => 'application/json' }, [manifest_ex]] }
|
48
|
+
route(:get, "/examples/manifest", manifest_ex_route_handler)
|
49
|
+
|
50
|
+
bad_condition_ex = File.read(File.join(__dir__, 'examples/invalid_condition.ndjson'))
|
51
|
+
bad_condition_ex_route_handler = proc { [200, { 'Content-Type' => 'application/ndjson' }, [bad_condition_ex]] }
|
52
|
+
route(:get, "/examples/invalid_condition", bad_condition_ex_route_handler)
|
53
|
+
|
54
|
+
bad_patient_ex = File.read(File.join(__dir__, 'examples/invalid_patient.ndjson'))
|
55
|
+
bad_patient_ex_route_handler = proc { [200, { 'Content-Type' => 'application/ndjson' }, [bad_patient_ex]] }
|
56
|
+
route(:get, "/examples/invalid_patient", bad_patient_ex_route_handler)
|
57
|
+
|
58
|
+
bad_encounter_ex = File.read(File.join(__dir__, 'examples/invalid_encounter.ndjson'))
|
59
|
+
bad_encounter_ex_route_handler = proc { [200, { 'Content-Type' => 'application/ndjson' }, [bad_encounter_ex]] }
|
60
|
+
route(:get, "/examples/invalid_encounter", bad_encounter_ex_route_handler)
|
61
|
+
|
62
|
+
observation_ex = File.read(File.join(__dir__, 'examples/observation.ndjson'))
|
63
|
+
observation_ex_route_handler = proc { [200, { 'Content-Type' => 'application/ndjson' }, [observation_ex]] }
|
64
|
+
route(:get, "/examples/observation", observation_ex_route_handler)
|
65
|
+
|
66
|
+
# Receive Manifest via POST set-up
|
67
|
+
resume_test_route :post, '/postHere' do |request|
|
68
|
+
request.query_parameters["id"]
|
69
|
+
end
|
70
|
+
|
32
71
|
links [
|
33
72
|
{
|
34
73
|
label: 'Report Issue',
|
@@ -45,6 +84,7 @@ module UDSPlusTestKit
|
|
45
84
|
]
|
46
85
|
|
47
86
|
group from: :uds_plus_test_group
|
87
|
+
group from: :uds_plus_manifest_post_group
|
48
88
|
group from: :uds_plus_resource_test_group
|
49
89
|
end
|
50
90
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'json'
|
2
|
+
require_relative './version'
|
3
|
+
|
4
|
+
module UDSPlusTestKit
|
5
|
+
class ValidateImmunizationTest < Inferno::Test
|
6
|
+
id :uds_plus_validate_immunization_test
|
7
|
+
title 'Validate UDS+ Immunization Data'
|
8
|
+
description %(
|
9
|
+
Test takes the Immunization resources identified
|
10
|
+
by the import manifest, and validates whether they conform
|
11
|
+
to their UDS+ Structure Definitions.
|
12
|
+
)
|
13
|
+
|
14
|
+
def data_scratch
|
15
|
+
scratch[:data_resources] ||= {}
|
16
|
+
end
|
17
|
+
|
18
|
+
def data_to_test
|
19
|
+
data_scratch['Immunization'] ||= []
|
20
|
+
end
|
21
|
+
|
22
|
+
run do
|
23
|
+
omit_if data_to_test.empty?, "No data of this type was identified."
|
24
|
+
|
25
|
+
profile_definition = 'http://hl7.org/fhir/us/uds-plus/StructureDefinition/uds-plus-immunization'
|
26
|
+
profile_with_version = "#{profile_definition}|#{UDS_PLUS_VERSION}"
|
27
|
+
|
28
|
+
data_to_test.each do |resource|
|
29
|
+
assert_valid_resource(resource: resource, profile_url: profile_with_version)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -22,21 +22,20 @@ module UDSPlusTestKit
|
|
22
22
|
run do
|
23
23
|
omit_if data_to_test.empty?, "No data of this type was identified."
|
24
24
|
|
25
|
-
profile_definition = 'http://hl7.org/fhir/us/uds-plus/StructureDefinition/uds-plus-income-observation'
|
25
|
+
profile_definition = 'http://hl7.org/fhir/us/uds-plus/StructureDefinition/de-identified-uds-plus-income-observation'
|
26
26
|
profile_with_version = "#{profile_definition}|#{UDS_PLUS_VERSION}"
|
27
27
|
|
28
28
|
no_resource_of_this_type = true
|
29
29
|
identifier_fail_message = %(Resource.meta.profile should contain the HTTP location of the
|
30
30
|
resource's Structure Definition. Resource.meta.profile either does
|
31
31
|
not exist in this resource, or its contents do not point to a valid
|
32
|
-
location for type Observation
|
33
|
-
If this error occurs, it
|
34
|
-
|
35
|
-
to run.)
|
32
|
+
location for type Observation. **NOTE:**
|
33
|
+
If this error occurs, it can trigger a fail for all observation-type tests,
|
34
|
+
regardless of whether both tests were meant to run.)
|
36
35
|
|
37
36
|
data_to_test.each do |resource|
|
38
|
-
# All these assertions are to differentaite Observation data between
|
39
|
-
# A resource is skipped if it
|
37
|
+
# All these assertions are to differentaite Observation data between orientation types.
|
38
|
+
# A resource is skipped if it cannot be identified as an income resource.
|
40
39
|
type_identifier = resource.to_hash
|
41
40
|
assert type_identifier['meta'].present?, identifier_fail_message
|
42
41
|
|
@@ -51,10 +50,8 @@ module UDSPlusTestKit
|
|
51
50
|
|
52
51
|
type_identifier = type_identifier.first
|
53
52
|
assert type_identifier.is_a?(String), identifier_fail_message
|
54
|
-
if type_identifier.include?("
|
53
|
+
if !type_identifier.include?("income")
|
55
54
|
next
|
56
|
-
else
|
57
|
-
assert type_identifier.include?("income"), identifier_fail_message
|
58
55
|
end
|
59
56
|
|
60
57
|
no_resource_of_this_type = false
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'json'
|
2
|
+
require_relative './version'
|
3
|
+
|
4
|
+
module UDSPlusTestKit
|
5
|
+
class ValidateLabTest < Inferno::Test
|
6
|
+
id :uds_plus_validate_lab_test
|
7
|
+
title 'Validate UDS+ Lab Observation Data'
|
8
|
+
description %(
|
9
|
+
Test takes the Lab Observation resources identified
|
10
|
+
by the import manifest, and validates whether they conform
|
11
|
+
to their UDS+ Structure Definitions.
|
12
|
+
)
|
13
|
+
|
14
|
+
def data_scratch
|
15
|
+
scratch[:data_resources] ||= {}
|
16
|
+
end
|
17
|
+
|
18
|
+
def data_to_test
|
19
|
+
data_scratch['Observation'] ||= []
|
20
|
+
end
|
21
|
+
|
22
|
+
run do
|
23
|
+
omit_if data_to_test.empty?, "No data of this type was identified."
|
24
|
+
|
25
|
+
profile_definition = 'http://hl7.org/fhir/us/uds-plus/StructureDefinition/uds-plus-lab-observation'
|
26
|
+
profile_with_version = "#{profile_definition}|#{UDS_PLUS_VERSION}"
|
27
|
+
|
28
|
+
no_resource_of_this_type = true
|
29
|
+
identifier_fail_message = %(Resource.meta.profile should contain the HTTP location of the
|
30
|
+
resource's Structure Definition. Resource.meta.profile either does
|
31
|
+
not exist in this resource, or its contents do not point to a valid
|
32
|
+
location for type Observation. **NOTE:**
|
33
|
+
If this error occurs, it can trigger a fail for all observation-type tests,
|
34
|
+
regardless of whether both tests were meant to run.)
|
35
|
+
|
36
|
+
data_to_test.each do |resource|
|
37
|
+
# All these assertions are to differentaite Observation data between Income Data and Sexual Orientation data.
|
38
|
+
# A resource is skipped if it is a sexual orientation resource and fails if it cannot be identified as an income resource.
|
39
|
+
type_identifier = resource.to_hash
|
40
|
+
assert type_identifier['meta'].present?, identifier_fail_message
|
41
|
+
|
42
|
+
type_identifier = type_identifier['meta']
|
43
|
+
assert type_identifier.is_a?(Hash), identifier_fail_message
|
44
|
+
assert type_identifier['profile'].present?, identifier_fail_message
|
45
|
+
|
46
|
+
type_identifier = type_identifier['profile']
|
47
|
+
assert type_identifier.is_a?(Array), identifier_fail_message
|
48
|
+
assert !type_identifier.empty?, identifier_fail_message
|
49
|
+
|
50
|
+
|
51
|
+
type_identifier = type_identifier.first
|
52
|
+
assert type_identifier.is_a?(String), identifier_fail_message
|
53
|
+
if !type_identifier.include?("-lab-")
|
54
|
+
next
|
55
|
+
end
|
56
|
+
|
57
|
+
no_resource_of_this_type = false
|
58
|
+
|
59
|
+
assert_valid_resource(resource: resource, profile_url: profile_with_version)
|
60
|
+
end
|
61
|
+
|
62
|
+
omit_if no_resource_of_this_type, "No data of this type was identified."
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'json'
|
2
|
+
require_relative './version'
|
3
|
+
|
4
|
+
module UDSPlusTestKit
|
5
|
+
class ValidateMedicationRequestTest < Inferno::Test
|
6
|
+
id :uds_plus_validate_medication_request_test
|
7
|
+
title 'Validate UDS+ Medication Request Data'
|
8
|
+
description %(
|
9
|
+
Test takes the Medication Request resources identified
|
10
|
+
by the import manifest, and validates whether they conform
|
11
|
+
to their UDS+ Structure Definitions.
|
12
|
+
)
|
13
|
+
|
14
|
+
def data_scratch
|
15
|
+
scratch[:data_resources] ||= {}
|
16
|
+
end
|
17
|
+
|
18
|
+
def data_to_test
|
19
|
+
data_scratch['MedicationRequest'] ||= []
|
20
|
+
end
|
21
|
+
|
22
|
+
run do
|
23
|
+
omit_if data_to_test.empty?, "No data of this type was identified."
|
24
|
+
|
25
|
+
profile_definition = 'http://hl7.org/fhir/us/uds-plus/StructureDefinition/uds-plus-medicationrequest'
|
26
|
+
profile_with_version = "#{profile_definition}|#{UDS_PLUS_VERSION}"
|
27
|
+
|
28
|
+
data_to_test.each do |resource|
|
29
|
+
assert_valid_resource(resource: resource, profile_url: profile_with_version)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'json'
|
2
|
+
require_relative './version'
|
3
|
+
|
4
|
+
module UDSPlusTestKit
|
5
|
+
class ValidateMedicationStatementTest < Inferno::Test
|
6
|
+
id :uds_plus_validate_medication_statement_test
|
7
|
+
title 'Validate UDS+ Medication Statement Data'
|
8
|
+
description %(
|
9
|
+
Test takes the Medication Statement resources identified
|
10
|
+
by the import manifest, and validates whether they conform
|
11
|
+
to their UDS+ Structure Definitions.
|
12
|
+
)
|
13
|
+
|
14
|
+
def data_scratch
|
15
|
+
scratch[:data_resources] ||= {}
|
16
|
+
end
|
17
|
+
|
18
|
+
def data_to_test
|
19
|
+
data_scratch['MedicationStatement'] ||= []
|
20
|
+
end
|
21
|
+
|
22
|
+
run do
|
23
|
+
omit_if data_to_test.empty?, "No data of this type was identified."
|
24
|
+
|
25
|
+
profile_definition = 'http://hl7.org/fhir/us/uds-plus/StructureDefinition/uds-plus-medicationstatement'
|
26
|
+
profile_with_version = "#{profile_definition}|#{UDS_PLUS_VERSION}"
|
27
|
+
|
28
|
+
data_to_test.each do |resource|
|
29
|
+
assert_valid_resource(resource: resource, profile_url: profile_with_version)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'json'
|
2
|
+
require_relative './version'
|
3
|
+
|
4
|
+
module UDSPlusTestKit
|
5
|
+
class ValidateRelatedPersonTest < Inferno::Test
|
6
|
+
id :uds_plus_validate_related_person_test
|
7
|
+
title 'Validate UDS+ Related Person Data'
|
8
|
+
description %(
|
9
|
+
Test takes the Related Person resources identified
|
10
|
+
by the import manifest, and validates whether they conform
|
11
|
+
to their UDS+ Structure Definitions.
|
12
|
+
)
|
13
|
+
|
14
|
+
def data_scratch
|
15
|
+
scratch[:data_resources] ||= {}
|
16
|
+
end
|
17
|
+
|
18
|
+
def data_to_test
|
19
|
+
data_scratch['RelatedPerson'] ||= []
|
20
|
+
end
|
21
|
+
|
22
|
+
run do
|
23
|
+
omit_if data_to_test.empty?, "No data of this type was identified."
|
24
|
+
|
25
|
+
profile_definition = 'http://hl7.org/fhir/us/uds-plus/StructureDefinition/de-identified-uds-plus-relatedperson'
|
26
|
+
profile_with_version = "#{profile_definition}|#{UDS_PLUS_VERSION}"
|
27
|
+
|
28
|
+
data_to_test.each do |resource|
|
29
|
+
assert_valid_resource(resource: resource, profile_url: profile_with_version)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'json'
|
2
|
+
require_relative './version'
|
3
|
+
|
4
|
+
module UDSPlusTestKit
|
5
|
+
class ValidateServiceRequestTest < Inferno::Test
|
6
|
+
id :uds_plus_validate_service_request_test
|
7
|
+
title 'Validate UDS+ Service Request Data'
|
8
|
+
description %(
|
9
|
+
Test takes the Service Request resources identified
|
10
|
+
by the import manifest, and validates whether they conform
|
11
|
+
to their UDS+ Structure Definitions.
|
12
|
+
)
|
13
|
+
|
14
|
+
def data_scratch
|
15
|
+
scratch[:data_resources] ||= {}
|
16
|
+
end
|
17
|
+
|
18
|
+
def data_to_test
|
19
|
+
data_scratch['ServiceRequest'] ||= []
|
20
|
+
end
|
21
|
+
|
22
|
+
run do
|
23
|
+
omit_if data_to_test.empty?, "No data of this type was identified."
|
24
|
+
|
25
|
+
profile_definition = 'http://hl7.org/fhir/us/uds-plus/StructureDefinition/uds-plus-servicerequest'
|
26
|
+
profile_with_version = "#{profile_definition}|#{UDS_PLUS_VERSION}"
|
27
|
+
|
28
|
+
data_to_test.each do |resource|
|
29
|
+
assert_valid_resource(resource: resource, profile_url: profile_with_version)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -29,14 +29,13 @@ module UDSPlusTestKit
|
|
29
29
|
identifier_fail_message = %(Resource.meta.profile should contain the HTTP location of the
|
30
30
|
resource's Structure Definition. Resource.meta.profile either does
|
31
31
|
not exist in this resource, or its contents do not point to a valid
|
32
|
-
location for type Observation
|
33
|
-
If this error occurs, it
|
34
|
-
|
35
|
-
to run.)
|
32
|
+
location for type Observation. **NOTE:**
|
33
|
+
If this error occurs, it can trigger a fail for all observation-type tests,
|
34
|
+
regardless of whether both tests were meant to run.)
|
36
35
|
|
37
36
|
data_to_test.each do |resource|
|
38
|
-
# All these assertions are to differentaite Observation data between
|
39
|
-
# A resource is skipped if it
|
37
|
+
# All these assertions are to differentaite Observation data between orientation types.
|
38
|
+
# A resource is skipped if it cannot be identified as a sexual orientation resource.
|
40
39
|
type_identifier = resource.to_hash
|
41
40
|
assert type_identifier['meta'].present?, identifier_fail_message
|
42
41
|
|
@@ -51,10 +50,8 @@ module UDSPlusTestKit
|
|
51
50
|
|
52
51
|
type_identifier = type_identifier.first
|
53
52
|
assert type_identifier.is_a?(String), identifier_fail_message
|
54
|
-
if type_identifier.include?("
|
53
|
+
if !type_identifier.include?("sexual-orientation")
|
55
54
|
next
|
56
|
-
else
|
57
|
-
assert type_identifier.include?("sexual-orientation"), identifier_fail_message
|
58
55
|
end
|
59
56
|
|
60
57
|
no_resource_of_this_type = false
|