Class: DaVinciPASTestKit::DaVinciPASV221::PasClientModificationVerificationTest
- Inherits:
-
Inferno::Test
- Object
- Inferno::Test
- DaVinciPASTestKit::DaVinciPASV221::PasClientModificationVerificationTest
- Defined in:
- lib/davinci_pas_test_kit/client/v2.2.1/workflows/pas_client_modification_verification_test.rb
Constant Summary collapse
- REVIEW_ACTION_URL =
'http://hl7.org/fhir/us/davinci-pas/StructureDefinition/extension-reviewAction'.freeze
- REVIEW_ACTION_CODE_URL =
'http://hl7.org/fhir/us/davinci-pas/StructureDefinition/extension-reviewActionCode'.freeze
- MODIFIED_REVIEW_ACTION_CODE =
'A6'.freeze
Instance Method Summary collapse
- #adjudication_modified?(adjudication) ⇒ Boolean
- #check_modification_response(submit_request) ⇒ Object
-
#claim_response_from_response_body(response_body) ⇒ Object
Extracts the ClaimResponse from a $submit response body, unwrapping the Parameters resource that wraps the Bundle for v2.2.1 inquire responses if one is present.
- #item_modified?(item) ⇒ Boolean
- #modified_item_sequences(claim_response) ⇒ Object
Instance Method Details
#adjudication_modified?(adjudication) ⇒ Boolean
88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/davinci_pas_test_kit/client/v2.2.1/workflows/pas_client_modification_verification_test.rb', line 88 def adjudication_modified?(adjudication) review_action = Array(adjudication.extension).find { |ext| ext.url == REVIEW_ACTION_URL } return false if review_action.blank? review_action_code = Array(review_action.extension).find { |ext| ext.url == REVIEW_ACTION_CODE_URL } return false if review_action_code&.valueCodeableConcept.blank? Array(review_action_code.valueCodeableConcept.coding).any? do |coding| coding.code == MODIFIED_REVIEW_ACTION_CODE end end |
#check_modification_response(submit_request) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/davinci_pas_test_kit/client/v2.2.1/workflows/pas_client_modification_verification_test.rb', line 40 def check_modification_response(submit_request) claim_response = claim_response_from_response_body(submit_request.response_body) if claim_response.blank? ('error', 'No ClaimResponse was found in the $submit response.') return end modified_sequences = modified_item_sequences(claim_response) if modified_sequences.blank? ('error', 'Expected at least one ClaimResponse.item entry with an adjudication review action code of ' \ "'#{MODIFIED_REVIEW_ACTION_CODE}' (Modified), but none were found.") end add_item_sequences = Array(claim_response.addItem).flat_map { |add_item| Array(add_item.itemSequence) } missing = modified_sequences.reject { |sequence| add_item_sequences.include?(sequence) } return if missing.empty? ('error', 'Each modified item must be paired with a ClaimResponse.addItem entry that has the same ' \ "itemSequence. No matching addItem was found for itemSequence(s): #{missing.join(', ')}.") end |
#claim_response_from_response_body(response_body) ⇒ Object
Extracts the ClaimResponse from a $submit response body, unwrapping the Parameters resource that wraps the Bundle for v2.2.1 inquire responses if one is present.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/davinci_pas_test_kit/client/v2.2.1/workflows/pas_client_modification_verification_test.rb', line 65 def claim_response_from_response_body(response_body) resource = FHIR.from_contents(response_body) return if resource.blank? bundle = if resource.is_a?(FHIR::Parameters) resource.parameter&.map(&:resource)&.find { |r| r.is_a?(FHIR::Bundle) } else resource end return unless bundle.is_a?(FHIR::Bundle) bundle.entry&.map(&:resource)&.find { |r| r.is_a?(FHIR::ClaimResponse) } end |
#item_modified?(item) ⇒ Boolean
84 85 86 |
# File 'lib/davinci_pas_test_kit/client/v2.2.1/workflows/pas_client_modification_verification_test.rb', line 84 def item_modified?(item) Array(item.adjudication).any? { |adjudication| adjudication_modified?(adjudication) } end |
#modified_item_sequences(claim_response) ⇒ Object
80 81 82 |
# File 'lib/davinci_pas_test_kit/client/v2.2.1/workflows/pas_client_modification_verification_test.rb', line 80 def modified_item_sequences(claim_response) Array(claim_response.item).select { |item| item_modified?(item) }.map(&:itemSequence).compact end |