Class: AUPSTestKit::RetrieveBundleTestClass
- 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
Direct Known Subclasses
AUPSSuiteRetrieveAuPsBundleValidationTestsBundleValidationRetrieveAuPsBundleFromTheFhirServer
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
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
- #extra_headers ⇒ Object
- #get_bundle_resource_from_fhir_server(bundle_id) ⇒ Object
- #get_bundle_resource_from_url(bundle_url) ⇒ Object
- #parse_bundle(body) ⇒ Object
- #read_and_save_data ⇒ Object
- #skip_test? ⇒ Boolean
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
Methods included from BasicTestCompositionSectionReadIssuesHelpersModule
Methods included from BasicTestCompositionSectionReadModule::BasicTestCompositionSectionCheckResourcesMSElementsModule
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
Methods included from BasicTestCustodianTests
#test_composition_custodian_ms_identifier_slices
Methods included from BasicTestCustodianIdentifierSlices
#validate_custodian_ms_identifier_slices
Methods included from BasicTestCustodianResource
Methods included from BasicTestAuthorTests
#test_composition_author_ms_identifier_slices
Methods included from BasicTestAuthorResource
Methods included from BasicTestSubjectPatientMsOtherTests
#test_subject_ms_identifier_slices
Methods included from BasicTestSubjectResource
Methods included from SectionNamesMapping
#get_section_name, #section_names_mapping
Methods included from SectionTestModule
Methods included from ValidatorHelpers
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_headers ⇒ Object
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_data ⇒ Object
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
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 |