Module: CancerPathologyDataSharingTestKit::BundleParse
- Extended by:
- Forwardable
- Included in:
- ContentBundleValidationTest, DiagnosticReportValidationTest, EncounterValidationTest, PatientValidationTest, PractitionerRoleValidationTest, ServiceRequestValidationTest, SpecimenValidationTest
- Defined in:
- lib/cancer_pathology_data_sharing_test_kit/bundle_parse.rb
Constant Summary collapse
- PE_BUNDLE_SLICE_RESOURCES =
ResourcesTypes in Slicing with Profiles
{ 'Patient' => 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient', 'Encounter' => 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-encounter', 'DiagnosticReport' => 'http://hl7.org/fhir/us/cancer-reporting/StructureDefinition/us-pathology-diagnostic-report', 'Specimen' => 'http://hl7.org/fhir/us/cancer-reporting/StructureDefinition/us-pathology-specimen', 'ServiceRequest' => 'http://hl7.org/fhir/us/cancer-reporting/StructureDefinition/us-pathology-service-request', 'PractitionerRole' => 'http://hl7.org/fhir/us/cancer-reporting/StructureDefinition/us-pathology-related-practitioner-role' }.freeze
Instance Method Summary collapse
- #clear_unresolved_references ⇒ Object
-
#filter_exchange_bundle_resources(parsed_bundle) ⇒ Object
Only returns the resources from the parsed bundle that match Pathology Exchange type.
- #find_resource_in_bundle(reference, bundle) ⇒ Object
-
#parse_bundle(bundle) ⇒ Object
Method for translating received bundle into a hash of resources.
- #pe_bundle_resource_types ⇒ Object
- #unresolved_references ⇒ Object
Instance Method Details
#clear_unresolved_references ⇒ Object
9 10 11 |
# File 'lib/cancer_pathology_data_sharing_test_kit/bundle_parse.rb', line 9 def clear_unresolved_references @unresolved_references = [] end |
#filter_exchange_bundle_resources(parsed_bundle) ⇒ Object
Only returns the resources from the parsed bundle that match Pathology Exchange type
45 46 47 |
# File 'lib/cancer_pathology_data_sharing_test_kit/bundle_parse.rb', line 45 def filter_exchange_bundle_resources(parsed_bundle) parsed_bundle.select { |key| pe_bundle_resource_types.include?(key) } end |
#find_resource_in_bundle(reference, bundle) ⇒ Object
49 50 51 |
# File 'lib/cancer_pathology_data_sharing_test_kit/bundle_parse.rb', line 49 def find_resource_in_bundle(reference, bundle) bundle.entry.find { |res| res.resource.id == reference.split('/').last && res.resource.resourceType == reference.split('/').first }&.resource end |
#parse_bundle(bundle) ⇒ Object
Method for translating received bundle into a hash of resources
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/cancer_pathology_data_sharing_test_kit/bundle_parse.rb', line 28 def parse_bundle(bundle) # TODO: For now, use ResourceType as Key, but determine if profile is indeed better? # But with openslicing, we don't have too many options here... parsed_bundle ||= {} bundle.entry.each do |entry| current_resource = entry.resource next if current_resource.is_a?(FHIR::Reference) # Not a reference, then just add the resoure to parsed bundle parsed_bundle[current_resource.resourceType] ||= [] parsed_bundle[current_resource.resourceType] << current_resource end parsed_bundle end |
#pe_bundle_resource_types ⇒ Object
23 24 25 |
# File 'lib/cancer_pathology_data_sharing_test_kit/bundle_parse.rb', line 23 def pe_bundle_resource_types PE_BUNDLE_SLICE_RESOURCES.keys end |
#unresolved_references ⇒ Object
5 6 7 |
# File 'lib/cancer_pathology_data_sharing_test_kit/bundle_parse.rb', line 5 def unresolved_references @unresolved_references ||= [] end |