class OpenEHR::Serializer::ADLSerializer

Public Instance Methods

definition() click to toggle source
# File lib/open_ehr/serializer.rb, line 83
def definition
  ad = @archetype.definition
  definition = 'definition'+NL
  definition << INDENT+ad.rm_type_name+"[#{ad.node_id}] matches {"
  if ad.any_allowed?
    definition << '*}'+NL
  else
    definition << NL
    if ad.attributes
      attributes = ad.attributes
      indents = 2
      while attributes
        definition << INDENT*indents+attributes.rm_type_name
        definition << "[#{attributes.node_id}] "
        definition << existence(attributes.existence)
        definition << " matches {"
      end
    end
  end
end
description() click to toggle source
# File lib/open_ehr/serializer.rb, line 34
def description
  desc = ''
  if @archetype.description
    ad = @archetype.description
    desc << 'description' + NL
    desc << INDENT + 'original_author = <' + NL
    ad.original_author.each do |k,v|
      desc << INDENT+INDENT+'["'+k+'"] = <"'+v+'">'+NL
    end
    desc << INDENT+'>'+NL
    desc << INDENT+'lifecycle_state = <"'+ad.lifecycle_state+'">'+NL
    desc << INDENT+'details = <'+NL
    ad.details.each do |lang,item|
      desc << INDENT*2+'["'+lang+'"] = <'+NL
      desc << INDENT*3+'language = <['+
        item.language.terminology_id.value+'::'+
        item.language.code_string+']>'+NL
      desc << INDENT*3+'purpose = <"'+item.purpose+'">'+NL
      if item.keywords then
        desc << INDENT*3+'keywords = <'
        item.keywords.each do |word|
          desc << '"'+word+'",'
        end
        desc.chop! << '>'+NL
      end
      desc << INDENT*3+'use = <"'+item.use+'">'+NL if item.use
      desc << INDENT*3+'misuse = <"'+item.misuse+'">'+NL if item.misuse
      desc << INDENT*3+'copyright = <"'+item.copyright+'">'+NL if item.copyright
      if item.original_resource_uri
        desc << INDENT*3 + 'original_resource_uri = <'
        item.original_resource_uri.each do |k,v|
          desc << INDENT*4+'["'+k+'"] = <"'+v+'">'+NL
        end
        desc << INDENT*3+'>'+NL
      end
      if item.other_details
        desc << INDENT*3 + 'other_details = <'
        item.original_resource_uri.each do |k,v|
          desc << INDENT*4+'["'+k+'"] = <"'+v+'">'+NL
        end
        desc << INDENT*3+'>'+NL
      end
      desc << INDENT*2+'>'+NL
    end
    desc << INDENT+'>'+NL
  end
  return desc
end
header() click to toggle source
# File lib/open_ehr/serializer.rb, line 21
def header
  hd = 'archetype'
  unless @archetype.adl_version.nil?
    hd << " (adl_version = #{@archetype.adl_version})"
  end
  hd << NL+INDENT + "#{@archetype.archetype_id.value}"+NL*2
  hd << 'concept'+NL+ INDENT+"[#{@archetype.concept}]"+NL
  hd << NL+'language'+NL+INDENT+'original_language = <['+
    @archetype.original_language.terminology_id.value+'::'+
    @archetype.original_language.code_string+']>'+NL
  return hd
end
merge() click to toggle source
# File lib/open_ehr/serializer.rb, line 124
def merge
  return header + NL + description + NL + definition + NL + ontology
end
ontology() click to toggle source
# File lib/open_ehr/serializer.rb, line 104
def ontology
  ao = @archetype.ontology
  ontology = 'ontology'+NL
  ontology << INDENT + 'term_definitions = <' + NL
  ao.term_definitions.each do |lang, items|
    ontology << INDENT*2 + "[\"#{lang}\"] = <" + NL
    ontology << INDENT*3 + 'items = <'  + NL
    items.each do |item|
      ontology << INDENT*4 + "[\"#{item.code}\"] = <" + NL            
      item.items.each do |name, desc|
        ontology << INDENT*5 + "#{name} = <\"#{desc}\">" +NL
      end
      ontology << INDENT*4 + '>'+NL
    end
    ontology << INDENT*3 + '>' + NL
    ontology << INDENT*2 + '>' + NL
  end
  ontology << INDENT + '>' + NL
end

Private Instance Methods

c_object() click to toggle source
# File lib/open_ehr/serializer.rb, line 129
def c_object
end
existence(existence) click to toggle source
# File lib/open_ehr/serializer.rb, line 132
def existence(existence)
  "existence matches {#{existence.lower}..#{existence.upper}}"
end