Module: DaVinciPASTestKit::DaVinciPASV221::ServerClaimUpdateResponseValidation
- Defined in:
- lib/davinci_pas_test_kit/server/v2.2.1/claim_updates/server_claim_update_response_tests.rb
Overview
Shared helpers for the server-side Claim Update response verification tests. Inferno (acting as the client) sends a sequence of update submissions to the server under test; these helpers reload each submission by its unique tag and compare the submitted Claim's items against the ClaimResponse the server returned. No live state is used - everything is reloaded from the tagged, persisted requests/responses.
Instance Method Summary collapse
- #claim_item_sequences(claim) ⇒ Object
- #claim_response_item_sequences(claim_response) ⇒ Object
-
#claim_update_response_steps ⇒ Object
The ordered Claim Update submissions, paired with the unique tag each was stored under.
-
#evaluated_update_steps ⇒ Object
Collects the steps for which the server returned a ClaimResponse, attaching the submitted Claim item sequences and the returned ClaimResponse item sequences.
- #first_resource_of_type(body, type) ⇒ Object
-
#item_bearing_update_steps ⇒ Object
The item-bearing steps (cancel-entire-request carries no items, so item.sequence checks do not apply to it).
-
#response_claim_response(request) ⇒ Object
The PAS Response Bundle starts with the ClaimResponse.
-
#submitted_claim(request) ⇒ Object
The Claim under submission is the first Bundle entry (a conformant update Bundle also includes the referenced prior Claim per spec-65, so select by position, not by type-order).
-
#tagged_update_request(tag) ⇒ Object
The most recent request stored under
tag(it carries both the request body Inferno sent and the response body the server returned).
Instance Method Details
#claim_item_sequences(claim) ⇒ Object
53 54 55 |
# File 'lib/davinci_pas_test_kit/server/v2.2.1/claim_updates/server_claim_update_response_tests.rb', line 53 def claim_item_sequences(claim) Array(claim&.item).map(&:sequence).compact end |
#claim_response_item_sequences(claim_response) ⇒ Object
57 58 59 |
# File 'lib/davinci_pas_test_kit/server/v2.2.1/claim_updates/server_claim_update_response_tests.rb', line 57 def claim_response_item_sequences(claim_response) Array(claim_response&.item).map(&:itemSequence).compact end |
#claim_update_response_steps ⇒ Object
The ordered Claim Update submissions, paired with the unique tag each was stored under.
12 13 14 15 16 17 18 19 |
# File 'lib/davinci_pas_test_kit/server/v2.2.1/claim_updates/server_claim_update_response_tests.rb', line 12 def claim_update_response_steps [ { label: 'initial submission', tag: CLAIM_UPDATE_INITIAL_TAG }, { label: 'add-item update', tag: CLAIM_UPDATE_ADD_ITEM_TAG }, { label: 'modify-and-cancel update', tag: CLAIM_UPDATE_MODIFY_CANCEL_TAG }, { label: 'cancel-entire-request update', tag: CLAIM_UPDATE_CANCEL_ALL_TAG } ] end |
#evaluated_update_steps ⇒ Object
Collects the steps for which the server returned a ClaimResponse, attaching the submitted Claim item sequences and the returned ClaimResponse item sequences.
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/davinci_pas_test_kit/server/v2.2.1/claim_updates/server_claim_update_response_tests.rb', line 63 def evaluated_update_steps claim_update_response_steps.filter_map do |step| request = tagged_update_request(step[:tag]) next if request.nil? claim = submitted_claim(request) claim_response = response_claim_response(request) next if claim.nil? || claim_response.nil? step.merge(submitted_sequences: claim_item_sequences(claim), response_sequences: claim_response_item_sequences(claim_response)) end end |
#first_resource_of_type(body, type) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/davinci_pas_test_kit/server/v2.2.1/claim_updates/server_claim_update_response_tests.rb', line 38 def first_resource_of_type(body, type) return nil if body.blank? bundle = FHIR.from_contents(body) return nil unless bundle.is_a?(FHIR::Bundle) first_resource = bundle.entry.first&.resource return first_resource if first_resource.is_a?(type) # Fall back to the first matching resource if the Bundle is ordered unexpectedly. bundle.entry.map(&:resource).find { |resource| resource.is_a?(type) } rescue StandardError nil end |
#item_bearing_update_steps ⇒ Object
The item-bearing steps (cancel-entire-request carries no items, so item.sequence checks do not apply to it).
79 80 81 |
# File 'lib/davinci_pas_test_kit/server/v2.2.1/claim_updates/server_claim_update_response_tests.rb', line 79 def item_bearing_update_steps evaluated_update_steps.reject { |step| step[:submitted_sequences].empty? } end |
#response_claim_response(request) ⇒ Object
The PAS Response Bundle starts with the ClaimResponse.
34 35 36 |
# File 'lib/davinci_pas_test_kit/server/v2.2.1/claim_updates/server_claim_update_response_tests.rb', line 34 def response_claim_response(request) first_resource_of_type(request&.response_body, FHIR::ClaimResponse) end |
#submitted_claim(request) ⇒ Object
The Claim under submission is the first Bundle entry (a conformant update Bundle also includes the referenced prior Claim per spec-65, so select by position, not by type-order).
29 30 31 |
# File 'lib/davinci_pas_test_kit/server/v2.2.1/claim_updates/server_claim_update_response_tests.rb', line 29 def submitted_claim(request) first_resource_of_type(request&.request_body, FHIR::Claim) end |
#tagged_update_request(tag) ⇒ Object
The most recent request stored under tag (it carries both the request body Inferno sent
and the response body the server returned).
23 24 25 |
# File 'lib/davinci_pas_test_kit/server/v2.2.1/claim_updates/server_claim_update_response_tests.rb', line 23 def tagged_update_request(tag) load_tagged_requests(tag).last end |