Class: AUPSTestKit::RetrieveBundleTestClass

Inherits:
BasicTest
  • Object
show all
Defined in:
lib/au_ps_inferno/utils/retrieve_bundle_test_class.rb

Overview

Retrieves a Bundle from a FHIR server (or a direct URL) into the group's scratch space

Constant Summary collapse

NO_RETRIEVAL_INPUTS_MESSAGE =
'No FHIR server URL with Bundle ID, and no Bundle URL, were provided, ' \
'so this test group is omitted.'

Constants included from BasicTestCompositionSectionReadModule

BasicTestCompositionSectionReadModule::MANDATORY_SECTIONS_CODES, BasicTestCompositionSectionReadModule::OPTIONAL_SECTIONS_CODES, BasicTestCompositionSectionReadModule::RECOMMENDED_SECTIONS_CODES

Constants included from BasicTestCompositionSectionReadModule::BasicTestCompositionSectionCheckResourcesMSElementsModule

BasicTestCompositionSectionReadModule::BasicTestCompositionSectionCheckResourcesMSElementsModule::AU_PS_PROFILE_BASE_URL

Constants included from BasicTestConstants

BasicTestConstants::AUTHOR_MS_IDENTIFIER_SLICES_BY_TYPE, BasicTestConstants::NO_SERVER_URL_OMIT_MESSAGE, BasicTestConstants::ORGANIZATION_MS_IDENTIFIER_SLICES, BasicTestConstants::PATIENT_MS_IDENTIFIER_SLICES, BasicTestConstants::PRACTITIONER_MS_IDENTIFIER_SLICES, BasicTestConstants::PRACTITIONER_ROLE_MS_IDENTIFIER_SLICES

Constants included from ValidatorHelpers

ValidatorHelpers::DEFAULT_VALUE, ValidatorHelpers::RESPONSE_KEYS, ValidatorHelpers::RESPONSE_VALIDATOR_KEY, ValidatorHelpers::RESPONSE_WRAPPER_KEY, ValidatorHelpers::VALIDATOR_KEY, ValidatorHelpers::WRAPPER_KEY

Constants included from CompositionUtils

CompositionUtils::BUNDLE_SOURCE_GROUPS, CompositionUtils::NO_BUNDLE_OMIT_MESSAGE

Instance Method Summary collapse

Methods included from BasicTestResolveResourceTypeModule

#raw_resource_type_is_valid, #test_resource_type_is_valid?

Methods included from BasicTestMsSubElementsPopulatedModule

#ms_sub_elements_populated_message

Methods included from BasicTestMsElementsPopulatedModule

#ms_elements_populated_message

Methods included from BasicTestResolvePathDebugModule

#resolve_path_with_dar

Methods included from BasicTestCompositionSectionReadIssuesHelpersModule

#references_resolution_report

Methods included from BasicTestCompositionSectionReadModule::BasicTestCompositionSectionCheckResourcesMSElementsModule

#check_ms_elements_populated

Methods included from BasicTestCapabilityOperationsModule

#operation_defined?, #operations, #select_op, #summary_op_defined?

Methods included from BasicTestBundleModule

#bundle_mandatory_ms_elements_info, #mandatory_ms_elements_info, #skip_validation?, #validate_au_ps_bundle, #validate_ips_bundle

Methods included from BasicTestAttesterIdentifierSlices

#test_composition_attester_party_ms_identifier_slices, #validate_attester_party_ms_identifier_slices

Methods included from BasicTestAttesterResource

#attester_party_resource

Methods included from BasicTestCustodianTests

#test_composition_custodian_ms_identifier_slices

Methods included from BasicTestCustodianIdentifierSlices

#validate_custodian_ms_identifier_slices

Methods included from BasicTestCustodianResource

#custodian_resource

Methods included from BasicTestAuthorTests

#test_composition_author_ms_identifier_slices

Methods included from BasicTestAuthorResource

#author_resource

Methods included from BasicTestSubjectPatientMsOtherTests

#test_subject_ms_identifier_slices

Methods included from BasicTestSubjectResource

#subject_resource

Methods included from SectionNamesMapping

#get_section_name, #section_names_mapping

Methods included from SectionTestModule

#entry_resources_info

Methods included from ValidatorHelpers

#show_validator_version

Methods included from CompositionUtils

#bundle_scratch_key, #group_section_output, #omit_unless_bundle_in_scratch, #save_bundle_to_scratch, #scratch_bundle

Methods included from CompositionUtilsBooleanAndStats

#all_entries_have_full_url_info?, #boolean_to_existent_string, #identifier_info?, #timestamp_info?, #type_info?

Instance Method Details

#extra_headersObject



62
63
64
# File 'lib/au_ps_inferno/utils/retrieve_bundle_test_class.rb', line 62

def extra_headers
  header_name.present? && header_value.present? ? { header_name => header_value } : {}
end

#get_bundle_resource_from_fhir_server(bundle_id) ⇒ Object



45
46
47
48
49
50
# File 'lib/au_ps_inferno/utils/retrieve_bundle_test_class.rb', line 45

def get_bundle_resource_from_fhir_server(bundle_id)
  fhir_read(:bundle, bundle_id)
  assert_response_status(200)
  assert_resource_type(:bundle)
  save_bundle_to_scratch(resource)
end

#get_bundle_resource_from_url(bundle_url) ⇒ Object



52
53
54
55
56
57
58
59
60
# File 'lib/au_ps_inferno/utils/retrieve_bundle_test_class.rb', line 52

def get_bundle_resource_from_url(bundle_url)
  get(bundle_url, headers: extra_headers)
  assert_response_status(200)
  bundle_resource = parse_bundle(request.response_body)
  assert bundle_resource.present?, "The response from #{bundle_url} could not be parsed as a FHIR resource"
  assert bundle_resource.resourceType == 'Bundle',
         "The resource at #{bundle_url} is a #{bundle_resource.resourceType}, expected a Bundle"
  save_bundle_to_scratch(bundle_resource)
end

#parse_bundle(body) ⇒ Object



66
67
68
69
70
# File 'lib/au_ps_inferno/utils/retrieve_bundle_test_class.rb', line 66

def parse_bundle(body)
  FHIR.from_contents(body)
rescue StandardError
  nil
end

#read_and_save_dataObject



76
77
78
79
80
81
82
# File 'lib/au_ps_inferno/utils/retrieve_bundle_test_class.rb', line 76

def read_and_save_data
  if url.present? && bundle_id.present?
    get_bundle_resource_from_fhir_server(bundle_id)
  elsif bundle_url.present?
    get_bundle_resource_from_url(bundle_url)
  end
end

#skip_test?Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/au_ps_inferno/utils/retrieve_bundle_test_class.rb', line 72

def skip_test?
  !((url.present? && bundle_id.present?) || bundle_url.present?)
end