Class: HealthDataStandards::Import::Hdata::MetadataImporter
- Inherits:
-
Object
- Object
- HealthDataStandards::Import::Hdata::MetadataImporter
- Includes:
- Singleton
- Defined in:
- lib/health-data-standards/import/hdata/metadata_importer.rb
Instance Method Summary collapse
- #extract_author(pedi_el) ⇒ Object
- #extract_change_info(change_info_el) ⇒ Object
- #extract_link_info(link_info_el) ⇒ Object
- #extract_metadata(meta_element, meta) ⇒ Object
- #extract_pedigree(pedi_el) ⇒ Object
- #import(meta_xml) ⇒ Object
Instance Method Details
#extract_author(pedi_el) ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/health-data-standards/import/hdata/metadata_importer.rb', line 53 def (pedi_el) return unless pedi_el = pedi_el.at_xpath("./hrf-md:Author") return unless Metadata::Author.new(name: .try(:content), type: .attribute('typeCode').try("content"), role: .attribute('role').try("content")) end |
#extract_change_info(change_info_el) ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/health-data-standards/import/hdata/metadata_importer.rb', line 70 def extract_change_info(change_info_el) return unless change_info_el change_info = Metadata::ChangeInfo.new change_info. = change_info_el.at_xpath("./hrf-md:ChangeDateTime").try("content") change_info.pedigree = extract_pedigree(change_info_el.at_xpath("./hrf-md:PedigreeInfo")) change_info_el change_info end |
#extract_link_info(link_info_el) ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/health-data-standards/import/hdata/metadata_importer.rb', line 62 def extract_link_info(link_info_el) return unless link_info_el target_el = link_info_el.at_xpath("./hrf-md:Target") return unless target_el Metadata::LinkInfo.new(uri: target_el.content, extension: target_el.attribute("TargetExtension").try(:content)) end |
#extract_metadata(meta_element, meta) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/health-data-standards/import/hdata/metadata_importer.rb', line 19 def (, ) .mime_types = .xpath("./hrf-md:MediaType").map { |media| media.text } .confidentiality = .at_xpath("./hrf-md:Confidentiality").try(:text) .pedigrees = .xpath("./hrf-md:PedigreeInfo").map { |ped| extract_pedigree(ped) } creation_el = .at_xpath("./hrf-md:RecordDate/hrf-md:CreatedDateTime") .original_creation_time = Time.parse(creation_el.text) if creation_el .linked_documents = .xpath("./hrf-md:LinkedDocuments/hrf-md:Link").map {|l| extract_link_info(l)} copied_elements = .xpath("./hrf-md:RecordDate/hrf-md:Copied/hrf-md:CopiedInfo") .copied_dates = copied_elements.map { |cp| extract_change_info(cp) } modified_elements = .xpath("./hrf-md:RecordDate/hrf-md:Modified/hrf-md:ModifiedInfo") .modified_dates = modified_elements.map { |md| extract_change_info(md) } end |
#extract_pedigree(pedi_el) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/health-data-standards/import/hdata/metadata_importer.rb', line 33 def extract_pedigree(pedi_el) return unless pedi_el = (pedi_el) organization = pedi_el.at_xpath("./hrf-md:Organization") ped = Metadata::Pedigree.new(author: , organization: organization.try(:content)) source_pedigree_els = pedi_el.xpath("./hrf-md:Source/hrf-md:PedigreeInfo") ped.source_pedigrees = source_pedigree_els.map { |ped_el| extract_pedigree(ped_el) } ped.derived = pedi_el.attribute("derived")# == "true" ? true : false # ped.signature = pedi_el.at_xpath("./hrf-md:Signature/") source_doc_els = pedi_el.xpath("./hrf-md:Source/hrf-md:Document") ped.source_documents = source_doc_els.map { |doc_el| extract_link_info(doc_el) } ped end |