Sha256: 66528fc04b3bba08224ecff1466377af4bc5cb6ee10482707f50322ff8b98c11

Contents?: true

Size: 1.92 KB

Versions: 4

Compression:

Stored size: 1.92 KB

Contents

$:.unshift(File.dirname(__FILE__)) unless
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
require 'polyglot'
require 'treetop'
include OpenEHR::Parser
include OpenEHR::AM::Archetype
include OpenEHR::RM::Support::Identification
include OpenEHR::RM::DataTypes::Text

module OpenEHR
  module Parser
    class ADLParser < Base
      def initialize(filename)
        super(filename)
        file = File.open(filename, 'r:bom|utf-8')
        data = file.read
        Treetop.load(File.dirname(__FILE__)+'/adl_grammar.tt')
        ap = ADLGrammarParser.new
        @result = ap.parse(data)
        file.close
        unless @result
          puts ap.failure_reason
          puts ap.failure_line
          puts ap.failure_column
        end
      end

      def parse
        archetype_id = ArchetypeID.new(:value => @result.archetype_id)
        definition = @result.definition
        ontology = @result.ontology
        original_language = nil
        if @result.original_language
          original_language = @result.original_language
        else
          terminology_id = TerminologyID.new(:value => 'ISO639-1')
          original_language = CodePhrase.new(:terminology_id => terminology_id,
                                      :code_string =>ontology.primary_language)
        end
        archetype = Archetype.new(:archetype_id => archetype_id,
                                  :adl_version => @result.adl_version,
                                  :concept => @result.concept,
                                  :original_language => original_language,
                                  :translations => @result.translations,
                                  :description => @result.description,
                                  :definition => @result.definition,
                                  :ontology => @result.ontology)
        return archetype
      end
    end
  end # of Parser
end # of OpenEHR

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
openehr-1.1.0 lib/openehr/parser/adl_parser.rb
open_ehr-1.0.2 lib/open_ehr/parser/adl_parser.rb
open_ehr-1.0.1 lib/open_ehr/parser/adl_parser.rb
open_ehr-1.0.0 lib/open_ehr/parser/adl_parser.rb