Class: OpenEHR::AM::Template::OperationalTemplate

Inherits:
Archetype::Archetype show all
Defined in:
lib/openehr/am/template.rb

Overview

OPERATIONAL_TEMPLATE class represents a “compiled” template derived from a source TEMPLATE by a “flattening” process, used for generating and validating reference model instance data. According to openEHR AOM2 specification, it inherits from AUTHORED_ARCHETYPE.

Constant Summary

Constants included from Archetype::ADLDefinition

Archetype::ADLDefinition::CURRENT_ADL_VERSION

Instance Attribute Summary collapse

Attributes inherited from Archetype::Archetype

#adl_version, #archetype_id, #definition, #invariants, #ontology, #parent_archetype_id, #uid

Attributes inherited from RM::Common::Resource::AuthoredResource

#description, #original_language, #revision_history, #translations

Instance Method Summary collapse

Methods inherited from Archetype::Archetype

#concept_name, #constraint_references_valid?, create, #internal_references_valid?, #is_specialised?, #is_valid?, #logical_paths, #node_ids_vaild?, #physical_paths, #previous_version, #short_concept_name, #specialisation_depth, #to_rm, #version

Methods inherited from RM::Common::Resource::AuthoredResource

#current_revision, #is_controlled?, #languages_available

Constructor Details

#initialize(args = {}) ⇒ OperationalTemplate

Returns a new instance of OperationalTemplate.



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/openehr/am/template.rb', line 13

def initialize(args = {})
  # Initialize parent archetype with template-specific archetype_id
  template_args = args.dup
  template_args[:archetype_id] = args[:template_id] if args[:template_id] && !args[:archetype_id]
  
  super(template_args)
  
  self.template_id = args[:template_id]
  self.component_terminologies = args[:component_terminologies] || {}
  self.terminology_extracts = args[:terminology_extracts] || {}
end

Instance Attribute Details

#component_terminologiesObject

Returns the value of attribute component_terminologies.



11
12
13
# File 'lib/openehr/am/template.rb', line 11

def component_terminologies
  @component_terminologies
end

#template_idObject

Returns the value of attribute template_id.



11
12
13
# File 'lib/openehr/am/template.rb', line 11

def template_id
  @template_id
end

#terminology_extractsObject

Returns the value of attribute terminology_extracts.



11
12
13
# File 'lib/openehr/am/template.rb', line 11

def terminology_extracts
  @terminology_extracts
end

Instance Method Details

#conceptObject

Override concept to use template concept or fallback to archetype concept



66
67
68
# File 'lib/openehr/am/template.rb', line 66

def concept
  @concept || (archetype_id ? archetype_id.concept_name : nil)
end

#is_specialized?Boolean

Returns whether the template is specialized (should be true for operational templates)

Returns:

  • (Boolean)


51
52
53
# File 'lib/openehr/am/template.rb', line 51

def is_specialized?
  !parent_archetype_id.nil?
end

#is_valid_operational_template?Boolean

Returns true if this is a valid operational template

Returns:

  • (Boolean)


43
44
45
46
47
48
# File 'lib/openehr/am/template.rb', line 43

def is_valid_operational_template?
  return false if template_id.nil?
  return false if definition.nil?
  return false if component_terminologies.nil?
  true
end

#languageObject

Compatibility method for backward compatibility with existing tests



71
72
73
# File 'lib/openehr/am/template.rb', line 71

def language
  original_language
end

#language=(language) ⇒ Object

Compatibility setter for language (maps to original_language)



76
77
78
# File 'lib/openehr/am/template.rb', line 76

def language=(language)
  self.original_language = language
end

#referenced_archetype_idsObject

Get all archetype identifiers referenced in this operational template



56
57
58
# File 'lib/openehr/am/template.rb', line 56

def referenced_archetype_ids
  component_terminologies.keys
end

#terminology_for_archetype(archetype_id) ⇒ Object

Get terminology for a specific archetype



61
62
63
# File 'lib/openehr/am/template.rb', line 61

def terminology_for_archetype(archetype_id)
  component_terminologies[archetype_id]
end