Skip to content

Commit

Permalink
passed minimum_template
Browse files Browse the repository at this point in the history
  • Loading branch information
skoba committed Apr 4, 2014
1 parent e053233 commit ac76a51
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 12 deletions.
1 change: 1 addition & 0 deletions .rspec
@@ -1 +1,2 @@
--require spec_helper
--colour
19 changes: 18 additions & 1 deletion lib/openehr/parser/opt_parser.rb
Expand Up @@ -25,6 +25,7 @@ def initialize(filename)

def parse
@opt = Nokogiri::XML::Document.parse(File.open(@filename))
@opt.remove_namespaces!
terminology_id = OpenEHR::RM::Support::Identification::TerminologyID.new(value: text_on_path(@opt,TEMPLATE_LANGUAGE_TERM_ID_PATH))
language = OpenEHR::RM::DataTypes::Text::CodePhrase.new(code_string: text_on_path(@opt, TEMPLATE_LANGUAGE_CODE_PATH), terminology_id: terminology_id)
OpenEHR::AM::Template::OperationalTemplate.new(concept: concept, language: language, description: description, template_id: template_id, definition: definition)
Expand Down Expand Up @@ -173,7 +174,8 @@ def constraint_ref(attr_xml, node)
end

def assertions(attr_xml, node)
string_expression = attr_xml.at('string_expression').text
string_expression = attr_xml.at('string_expression')
string_expression = string_expression.nil? ? nil : string_expression.text
expression_leaf = attr_xml.at 'expression'
expression = send expression_leaf.attributes['type'].text.downcase, expression_leaf
[OpenEHR::AM::Archetype::Assertion::Assertion.new(expression: expression, string_expression: string_expression)]
Expand Down Expand Up @@ -210,6 +212,21 @@ def c_string(attr_xml)
OpenEHR::AM::Archetype::ConstraintModel::Primitive::CString.new(pattern: pattern)
end

def c_dv_quantity(attr_xml, node)
rm_type_name = attr_xml.at('rm_type_name').text
occurrences = occurrences(attr_xml.at('occurrences'))
property_terminology_id = OpenEHR::RM::Support::Identification::TerminologyID.new(value: attr_xml.at('property/terminology_id/value').text)
property_code_string = attr_xml.at('property/code_string').text
property = OpenEHR::RM::DataTypes::Text::CodePhrase.new(terminology_id: property_terminology_id, code_string: property_code_string)
list = attr_xml.xpath('.//list').map do |element|
units = element.at('units').text if element.at('units')
magnitude = occurrences(element.at('magnitude')) if element.at('magnitude')
precision = occurrences(element.at('precision')) if element.at('precision')
OpenEHR::AM::OpenEHRProfile::DataTypes::Quantity::CQuantityItem.new(magnitude: magnitude, precision: precision, units: units)
end
OpenEHR::AM::OpenEHRProfile::DataTypes::Quantity::CDvQuantity.new(rm_type_name: rm_type_name, occurrences: occurrences, list: list, property: property)
end

def string(attr_xml)
attr_xml.text
end
Expand Down
5 changes: 2 additions & 3 deletions openehr.gemspec
Expand Up @@ -38,13 +38,12 @@ Gem::Specification.new do |gem|
gem.add_development_dependency('guard')
gem.add_development_dependency('guard-rspec')
gem.add_development_dependency('guard-cucumber')
# gem.add_development_dependency('ruby-debug19')
gem.add_development_dependency('spork') #, '> 1.0rc')
gem.add_development_dependency('spork')#, '> 1.0rc')
gem.add_development_dependency('guard-spork')
gem.add_development_dependency('simplecov')
gem.add_development_dependency('listen','0.6.0')
gem.add_development_dependency('rb-kqueue')
gem.add_development_dependency('libnotify')
gem.add_development_dependency('rb-inotify', '~>0.8.8')
gem.add_development_dependency('rb-inotify')#, '~>0.8.8')
end

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!--Operational template XML automatically generated by Ocean Template Designer Version 2.6.1214Beta-->
<template xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.openehr.org/v1">
<language>
Expand Down Expand Up @@ -36,9 +36,9 @@
<value>199f6890-5c06-4cb2-92de-422848ffe3a8</value>
</uid>
<template_id>
<value>minimal template</value>
<value>minimum template</value>
</template_id>
<concept>minimal template</concept>
<concept>minimum template</concept>
<definition>
<rm_type_name>COMPOSITION</rm_type_name>
<occurrences>
Expand Down Expand Up @@ -1473,10 +1473,10 @@
<value>openEHR-EHR-COMPOSITION.minimum.v1</value>
</archetype_id>
<template_id>
<value>minimal template</value>
<value>minimum template</value>
</template_id>
<term_definitions code="at0000">
<items id="description">minimal set for </items>
<items id="description">minimun set for </items>
<items id="text">Minimum</items>
</term_definitions>
<term_definitions code="at0001">
Expand All @@ -1488,4 +1488,4 @@
<items id="text">*新規Element(ja)</items>
</term_definitions>
</definition>
</template>
</template>
8 changes: 8 additions & 0 deletions spec/lib/openehr/opt_parser/minimum_template_spec.rb
@@ -0,0 +1,8 @@
describe 'minimum_template' do
let(:optparser) { OpenEHR::Parser::OPTParser.new(File.join(File.dirname(__FILE__), '/minimum_template.opt'))}
let(:opt) {optparser.parse}

it 'concept is minimum template' do
expect(opt.concept).to eq 'minimum template'
end
end
2 changes: 0 additions & 2 deletions spec/lib/openehr/opt_parser/opt_parser_spec.rb
@@ -1,5 +1,3 @@
require 'spec_helper'

module OpenEHR
module Parser
describe OPTParser do
Expand Down

0 comments on commit ac76a51

Please sign in to comment.