Sha256: 97039ed320fccf90cf19daa555bb92df770e172633b29dda2b56d5cb42ab10c8

Contents?: true

Size: 1.92 KB

Versions: 11

Compression:

Stored size: 1.92 KB

Contents

$:.unshift(File.dirname(__FILE__)) unless
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
require 'treetop'
require 'polyglot'
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

11 entries across 11 versions & 1 rubygems

Version Path
openehr-1.2.4 lib/openehr/parser/adl_parser.rb
openehr-1.2.3 lib/openehr/parser/adl_parser.rb
openehr-1.2.2 lib/openehr/parser/adl_parser.rb
openehr-1.2.1 lib/openehr/parser/adl_parser.rb
openehr-1.2.0 lib/openehr/parser/adl_parser.rb
openehr-1.1.6 lib/openehr/parser/adl_parser.rb
openehr-1.1.5 lib/openehr/parser/adl_parser.rb
openehr-1.1.4 lib/openehr/parser/adl_parser.rb
openehr-1.1.3 lib/openehr/parser/adl_parser.rb
openehr-1.1.2 lib/openehr/parser/adl_parser.rb
openehr-1.1.1 lib/openehr/parser/adl_parser.rb