Module: DaVinciPASTestKit::ClaimOperationLogic

Included in:
ClaimInquireOperationTest, ClaimSubmitOperationTest
Defined in:
lib/davinci_pas_test_kit/server/claim_operation_logic.rb

Instance Method Summary collapse

Instance Method Details

#check_response_status_and_payload(request) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/davinci_pas_test_kit/server/claim_operation_logic.rb', line 43

def check_response_status_and_payload(request)
  assert_response_status([200, 201])
  assert_valid_json(request.response_body, "Server response to $#{operation} was not json.")
  resource = FHIR.from_contents(request.response_body)
  if config.options[:ig_version] == 'v2.2.1' && operation == 'inquire'
    assert resource.resourceType == 'Parameters',
           "Expected Parameters resource for v2.2.1 inquire response, but received #{resource.resourceType}"
  else
    assert_resource_type(:bundle, resource:)
  end
end

#operation_tagObject



5
6
7
# File 'lib/davinci_pas_test_kit/server/claim_operation_logic.rb', line 5

def operation_tag
  DaVinciPASTestKit.const_get(:"#{operation.upcase}_TAG")
end

#perform_operation(request_payload) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/davinci_pas_test_kit/server/claim_operation_logic.rb', line 26

def perform_operation(request_payload)
  start_time = Time.now
  request = fhir_operation("/Claim/$#{operation}", body: request_payload, tags: [use_case_tag, operation_tag])
  response_time = Time.now - start_time

  if operation == 'submit' && response_time > 15
    warning %(
          The server took more that 15 seconds to respond to the Prior Authorization
          request.

          Response Time: #{response_time}
        )
  end

  request
end

#request_bundles(request_payload) ⇒ Object



21
22
23
24
# File 'lib/davinci_pas_test_kit/server/claim_operation_logic.rb', line 21

def request_bundles(request_payload)
  parsed_payload = JSON.parse(request_payload)
  [parsed_payload].flatten.compact
end

#run_operation_test(request_payload) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/davinci_pas_test_kit/server/claim_operation_logic.rb', line 55

def run_operation_test(request_payload)
  skip_if request_payload.blank?, "No bundle request provided to perform the #{operation} operation"
  assert_valid_json(request_payload,
                    "Provide valid json to use for the $#{operation} during the #{use_case.titleize} workflow.")

  requests_performed = request_bundles(request_payload).map do |bundle|
    perform_operation(bundle)
  end

  requests_performed.each { |request| check_response_status_and_payload(request) }
end

#use_caseObject



9
10
11
# File 'lib/davinci_pas_test_kit/server/claim_operation_logic.rb', line 9

def use_case
  config.options[:use_case]
end

#use_case_tagObject

The workflow tag applied to (and used to reload) the request. Tests that run a single tagged submission per use case (e.g. Claim Updates) set an explicit request_tag; the standard workflow tests fall back to the use-case-derived *_WORKFLOW_TAG.



16
17
18
19
# File 'lib/davinci_pas_test_kit/server/claim_operation_logic.rb', line 16

def use_case_tag
  config.options[:request_tag].presence ||
    DaVinciPASTestKit.const_get(:"#{use_case.upcase}_WORKFLOW_TAG")
end