Class: OpenEHR::Parser::OPTParser

Inherits:
Base
  • Object
show all
Defined in:
lib/openehr/parser/opt_parser.rb

Constant Summary collapse

TEMPLATE_LANGUAGE_CODE_PATH =
'/template/language/code_string'
TEMPLATE_LANGUAGE_TERM_ID_PATH =
'/template/language/terminology_id/value'
TEMPLATE_ID_PATH =
'/template/template_id/value'
UID_PATH =
'/template/uid/value'
CONCEPT_PATH =
'/template/concept'
DESC_ORIGINAL_AUTHOR_PATH =
'/template/description/original_author'
DESC_LIFECYCLE_STATE_PATH =
'/template/description/lifecycle_state'
DESC_DETAILS_LANGUAGE_TERM_ID_PATH =
'/template/description/details/language/terminology_id/value'
DESC_DETAILS_LANGUAGE_CODE_PATH =
'/template/description/details/language/code_string'
DESC_DETAILS_PURPOSE_PATH =
'/template/description/details/purpose'
DESC_DETAILS_KEYWORDS_PATH =
'/template/description/details/keywords'
DESC_DETAILS_USE_PATH =
'/template/description/details/use'
DESC_DETAILS_MISUSE_PATH =
'/template/description/details/misuse'
'/template/description/details/copyright'
DESC_OTHER_DETAILS_PATH =
'/template/description/other_details'
DEFINITION_PATH =
'/template/definition'
OCCURRENCE_PATH =
'/occurrences'

Instance Attribute Summary

Attributes inherited from Base

#filename

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ OPTParser

Returns a new instance of OPTParser.



35
36
37
# File 'lib/openehr/parser/opt_parser.rb', line 35

def initialize(filename)
  super(filename)
end

Instance Method Details

#parseObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/openehr/parser/opt_parser.rb', line 39

def parse
  @opt = Nokogiri::XML::Document.parse(File.open(@filename))
  @opt.remove_namespaces!
  
  uid = OpenEHR::RM::Support::Identification::UIDBasedID.new(value: text_on_path(@opt, UID_PATH))
  defs = definition
  
  # Create operational template with archetype-compatible parameters
  OpenEHR::AM::Template::OperationalTemplate.new(
    uid: uid,
    concept: concept,
    original_language: language,
    description: description,
    template_id: template_id,
    archetype_id: template_id,  # Use template_id as archetype_id for compatibility
    definition: defs,
    ontology: create_template_ontology,
    component_terminologies: @component_terminologies || {},
    terminology_extracts: @component_terminologies || {},
    adl_version: "1.4"
  )
end