Class: CarinForBlueButtonTestKit::ResourceAPIEndpoint

Inherits:
Inferno::DSL::SuiteEndpoint
  • Object
show all
Includes:
ClientValidationTest, MockServer
Defined in:
lib/carin_for_blue_button_test_kit/client/v2.0.0/endpoints/resource_api_endpoint.rb

Instance Method Summary collapse

Methods included from ClientValidationTest

#all_resource_types, #connect_bundle, #extract_eob_profile, #flattened_all_resources, #previous_claims_data_request_resources, #previous_claims_data_request_resources_scratch, #previous_claims_data_requests, #previous_claims_data_search_parameters_scratch, #previous_resource_requests, #resource_previous_search_params, #resource_type_endpoint

Methods included from MockServer

#carin_resource_id_response, #carin_resource_response, #error_response_resource, #extract_bearer_token, #extract_client_id, #extract_token_from_query_params, #find_matching_entry, #get_metadata, #get_params, #match_request_to_expectation, #mock_operation_outcome_resource, #new_link, #read_next_page, #relative_reference?, #remove_transfer_encoding_and_content_length_header, #replace_bundle_urls, #resource_endpoint, #resource_id_endpoint, #server_proxy, #token_response

Methods included from URLs

#base_fhir_url, #base_url, #metadata_url, #patient_url, #resource_id_url, #resume_claims_data_url, #resume_fail_url, #resume_pass_url, #submit_url, #suite_id, #token_url

Instance Method Details

#add_resource_tags(tags, response_body_resource) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/carin_for_blue_button_test_kit/client/v2.0.0/endpoints/resource_api_endpoint.rb', line 18

def add_resource_tags(tags, response_body_resource)
  if response_body_resource.resourceType == 'Bundle'
    response_body_resource.entry.each do |entry_resource|
      resource = entry_resource.resource
      resource_type_tag = resource.resourceType
      if resource.resourceType == 'ExplanationOfBenefit'
        profile = extract_eob_profile(resource)
        resource_type_tag = "#{resource.resourceType}_#{profile}"
      end
      tags.append(resource_type_tag) unless tags.include?(resource_type_tag)
    end
  else
    resource = response_body_resource
    resource_type_tag = resource.resourceType
    if resource.resourceType == 'ExplanationOfBenefit'
      profile = extract_eob_profile(resource)
      resource_type_tag = "#{resource.resourceType}_#{profile}"
    end
    tags.append(resource_type_tag) unless tags.include?(resource_type_tag)
  end
end

#add_search_param_tags(tags, endpoint_resource, params) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/carin_for_blue_button_test_kit/client/v2.0.0/endpoints/resource_api_endpoint.rb', line 40

def add_search_param_tags(tags, endpoint_resource, params)
  tags.append("#{endpoint_resource}Search")
  params.keys.each do |key|
    next unless key == '_include'

    params[key].each do |value|
      params["#{key}=#{value}"] = value
    end
    params.delete(key)
  end

  params.each_key do |param|
    tags.append(param)
  end
end

#make_responseObject



14
15
16
# File 'lib/carin_for_blue_button_test_kit/client/v2.0.0/endpoints/resource_api_endpoint.rb', line 14

def make_response
  response
end

#tagsObject



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/carin_for_blue_button_test_kit/client/v2.0.0/endpoints/resource_api_endpoint.rb', line 56

def tags
  response_body = FHIR.from_contents(carin_resource_response(request))
  params = get_params(request.query_string)

  endpoint_resource = resource_endpoint(request.url)

  tags = [RESOURCE_API_TAG]

  add_resource_tags(tags, response_body) if response_body.present?
  add_search_param_tags(tags, endpoint_resource, params)

  tags
end

#test_run_identifierObject



10
11
12
# File 'lib/carin_for_blue_button_test_kit/client/v2.0.0/endpoints/resource_api_endpoint.rb', line 10

def test_run_identifier
  extract_bearer_token(request)
end

#update_resultObject



70
71
72
# File 'lib/carin_for_blue_button_test_kit/client/v2.0.0/endpoints/resource_api_endpoint.rb', line 70

def update_result
  results_repo.update(result.id, result: 'pass') unless test.config.options[:accepts_multiple_requests]
end