module SimpleXml::Utilities
Constants
- MEASURE_ATTRIBUTES_MAP
Public Class Methods
attr_val(node, xpath)
click to toggle source
Utility function to handle optional attributes @param xpath an XPath that identifies an XML attribute @return the value of the attribute or nil if the attribute is missing
# File lib/model/utilities.rb, line 16 def self.attr_val(node, xpath) attr = node.at_xpath(xpath) if attr attr.value else nil end end
build_value(comparison, quantity, unit, type=nil)
click to toggle source
# File lib/model/utilities.rb, line 34 def self.build_value(comparison, quantity, unit, type=nil) return nil if !comparison || !quantity unit = nil if unit && unit.strip.empty? if comparison.downcase == 'equal to' && type != 'IVL_TS' Value.new(quantity, unit, true) else Range.new(comparison, quantity, unit, type) end end
Public Instance Methods
attr_val(xpath)
click to toggle source
Utility function to handle optional attributes @param xpath an XPath that identifies an XML attribute @return the value of the attribute or nil if the attribute is missing
# File lib/model/utilities.rb, line 9 def attr_val(xpath) Utilities::attr_val(@entry, xpath) end
children_of(node)
click to toggle source
# File lib/model/utilities.rb, line 25 def children_of(node) node.xpath('*[not(self::text|self::comment)]') end
comments_on(node)
click to toggle source
# File lib/model/utilities.rb, line 29 def comments_on(node) # find comments and remove comments that have a value of 'comment' since those are bad MAT artifacts node.xpath('comment').reject {|c| c.children.empty?}.map {|c| c.children[0].to_s} end
create_age_timing(birthdate_hqmf_id, right, operator, quantity, unit)
click to toggle source
# File lib/model/utilities.rb, line 49 def create_age_timing(birthdate_hqmf_id, right, operator, quantity, unit) age_element = " <relationalOp displayName='Starts Before Start Of' type='SBS' operatorType='#{operator}' quantity='#{quantity}' unit='#{unit}'> <elementRef displayName='birthdate : Patient Characteristic Birthdate' id='#{birthdate_hqmf_id}' type='qdm'/> #{right.to_s} </relationalOp> " Document.parse(age_element).child end
create_birthdate_criteria()
click to toggle source
# File lib/model/utilities.rb, line 44 def create_birthdate_criteria default_birthdate = '<qdm datatype="Patient Characteristic Birthdate" id="birth_date_hqmf_id" name="birthdate" oid="2.16.840.1.113883.3.117.1.7.1.70" suppDataElement="false" taxonomy="User Defined QDM" uuid="birth_date_hqmf_id" version="1.0"/>' DataCriteria.new(Document.parse(default_birthdate).child) end