Sha256: 0ea8900793daa7b3b373842241ab3b851c0214ba32d3c60651b2fa8c379dbeea

Contents?: true

Size: 1.54 KB

Versions: 2

Compression:

Stored size: 1.54 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::DataTypes::Text
include OpenEHR::RM::Support::Identification

module OpenEHR
  module Parser
    class ADLParser < Base
      def initialize(filename)
        super(filename)
        data = File.read(filename)
        Treetop.load(File.dirname(__FILE__)+'/adl_grammar.tt')
        ap = ADLGrammarParser.new
        @result = ap.parse(data)
        if @result.nil?
          puts ap.failure_reason
          puts ap.failure_line
          puts ap.failure_column
        end
      end

      def parse
        original_language = @result.original_language
        archetype_id = ArchetypeID.new(:value => @result.archetype_id)
        definition = @result.definition
        ontology = @result.ontology
        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

2 entries across 2 versions & 1 rubygems

Version Path
open_ehr-0.9.5 lib/open_ehr/parser/adl_parser.rb
open_ehr-0.9.4 lib/open_ehr/parser/adl_parser.rb