Skip to content

Commit 32d0e52

Browse files
authored
Document add_messages_to_runnable param in resource_is_valid? examples (#89)
Signed-off-by: Vanessa Fotso <vfotso@mitre.org>
1 parent 851723e commit 32d0e52

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

docs/writing-tests/fhir-validation.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ section: docs
77
---
88
# FHIR Resource Validation
99
[FHIR Resource validation](https://www.hl7.org/fhir/validation.html) is
10-
performed by the [HL7® FHIR Java Validator](https://github.com/hapifhir/org.hl7.fhir.core).
10+
performed by the [HL7® FHIR Java Validator](https://github.com/hapifhir/org.hl7.fhir.core).
1111
Two validator "wrapper" services are currently included in the Inferno framework:
1212
- [HL7 Validator Wrapper](https://github.com/hapifhir/org.hl7.fhir.validator-wrapper)
1313
- Used to validate resources as part of the test suite
@@ -26,8 +26,8 @@ the contents are automatically deleted prior to loading.
2626

2727
### Defining Validators
2828
The Inferno Template defines one basic validator in the suite. The validator must be configured to
29-
reference the IG being tested against. IGs may be referenced by package identifier
30-
(for example, `'hl7.fhir.us.core#1.0.0'`) if they are published, or by filename.
29+
reference the IG being tested against. IGs may be referenced by package identifier
30+
(for example, `'hl7.fhir.us.core#1.0.0'`) if they are published, or by filename.
3131
It is not necessary to alter the template suite further unless you need multiple validators or want to add
3232
[extra validator behaviors](/docs/writing-tests/fhir-validation.html#performing-additional-validation). Validators are defined with `fhir_resource_validator`:
3333

@@ -56,22 +56,28 @@ docs](/inferno-core/docs/Inferno/DSL/FHIRResourceValidation/ClassMethods.html#fh
5656
The `resource_is_valid?` method will validate a FHIR resource and add any
5757
validation messages to the runnable.
5858

59+
You can optionally skip adding validation messages by setting `add_messages_to_runnable: false`.
60+
5961
```ruby
6062
test do
6163
fhir_read(:patient, '123')
62-
64+
6365
# Validate the resource from the last request
6466
if resource_is_valid?
6567
end
66-
68+
69+
# Validate the resource from last request without adding messages to the runnable
70+
if resource_is_valid?(add_messages_to_runnable: false)
71+
end
72+
6773
# Validate some other resource
6874
if resource_is_valid?(resource: some_other_resource)
6975
end
70-
76+
7177
# Validate against a particular profile
7278
if resource_is_valid?(profile_url: 'http://example.com/fhir_profile_url')
7379
end
74-
80+
7581
# Validate using a particular named validator
7682
if resource_is_valid?(validator: :my_customized_validator)
7783
end
@@ -87,16 +93,16 @@ to the runnable, and fail the test if the resource is invalid.
8793
```ruby
8894
test do
8995
fhir_read(:patient, '123')
90-
96+
9197
# Use the resource from the last request
9298
assert_valid_resource
93-
99+
94100
# Validate some other resource
95101
assert_valid_resource(resource: some_other_resource)
96-
102+
97103
# Validate against a particular profile
98104
assert_valid_resource(profile_url: 'http://example.com/fhir_profile_url')
99-
105+
100106
# Validate using a particular named validator
101107
assert_valid_resource(validator: :my_customized_validator)
102108
end
@@ -143,9 +149,9 @@ end
143149
# MustSupport Test using the Evaluator
144150

145151
Checking the presence of Must Support elements is a common feature across test kits and
146-
its implementation has been copy-and-pasted between them.
147-
To improve the productivity of developing test kits, the Evaluator CLI is built into
148-
inferno core, and the MustSupport checks can also be invoked in the context of a test kit
152+
its implementation has been copy-and-pasted between them.
153+
To improve the productivity of developing test kits, the Evaluator CLI is built into
154+
inferno core, and the MustSupport checks can also be invoked in the context of a test kit
149155
by a single method.
150156

151157
To invoke the MustSupport checks, add the following code into test:
@@ -162,4 +168,4 @@ Refer to the examples used in IGs below:
162168

163169
[CARIN for BlueButton IG Test kit](https://github.com/inferno-framework/carin-for-blue-button-test-kit/blob/main/lib/carin_for_blue_button_test_kit/must_support_test.rb)
164170

165-
[International Patient Summary IG Test kit](https://github.com/inferno-framework/ipa-test-kit/blob/main/lib/ipa_test_kit/must_support_test.rb)
171+
[International Patient Summary IG Test kit](https://github.com/inferno-framework/ipa-test-kit/blob/main/lib/ipa_test_kit/must_support_test.rb)

0 commit comments

Comments
 (0)