Changeset 412 for ruby/trunk


Ignore:
Timestamp:
Apr 25, 2010, 5:21:15 PM (14 years ago)
Author:
KOBAYASHI, Shinji
Message:

implemented adl_serializer ontology spec

Location:
ruby/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • ruby/trunk/lib/open_ehr/am/archetype/ontology.rb

    r411 r412  
    1414            self.term_bindings = args[:term_bindings]
    1515          end
    16 
    17           # def terminologies_available=(terminologies_available)
    18           #   if terminologies_available.nil?
    19           #     raise ArgumentError, 'terminologies_available is mandatory'
    20           #   end
    21           #   @terminologies_available = terminologies_available
    22           # end
    2316
    2417          def term_definitions=(term_definitions)
     
    4134                value.collect {|term| term.code}}.flatten.uniq
    4235            end
     36          end
     37
     38          def terminologies_available
     39            return @term_bindings.keys
    4340          end
    4441
  • ruby/trunk/lib/open_ehr/parser.rb

    r404 r412  
    1515
    1616  class XMLParser < Parser
    17 
     17   
    1818  end
    1919end
  • ruby/trunk/lib/open_ehr/serializer.rb

    r411 r412  
    105105        ontology = 'ontology'+NL
    106106        ontology << INDENT + 'term_definitions = <' + NL
    107         ao.term_codes.each do |term, items|
    108           ontology << INDENT*2 + "[\"#{term}\"] = <" + NL
     107        ao.term_definitions.each do |lang, items|
     108          ontology << INDENT*2 + "[\"#{lang}\"] = <" + NL
    109109          ontology << INDENT*3 + 'items = <'  + NL
    110           items.each do |code, attribute|
    111             ontology << INDENT*4 + "[\"#{code}\] = <" + NL
    112             terms.each do |name, description|
    113               ontology << INDENT*5 + "#{name} = <\"#{description}\">" +NL
     110          items.each do |item|
     111            ontology << INDENT*4 + "[\"#{item.code}\"] = <" + NL           
     112            item.items.each do |name, desc|
     113              ontology << INDENT*5 + "#{name} = <\"#{desc}\">" +NL
    114114            end
    115115            ontology << INDENT*4 + '>'+NL
    116116          end
    117           ontogoly << INDENT*3 + '>' + NL
     117          ontology << INDENT*3 + '>' + NL
    118118          ontology << INDENT*2 + '>' + NL
    119119        end
  • ruby/trunk/spec/lib/open_ehr/am/archetype/ontology/archetype_ontology_spec.rb

    r411 r412  
    5252      code_string.should == '163020007'
    5353  end
     54
     55  it 'terminologies_available should return available terminology' do
     56    @archetype_ontology.terminologies_available.should == ['SNOMED-CT(2003)']
     57  end
    5458end
    5559                           
  • ruby/trunk/spec/lib/open_ehr/serializer/adl_serializer_spec.rb

    r411 r412  
    4040
    4141  it 'ontology should return ADL formatted ontology' do
    42     @adl_serializer.ontology.should == @sample_definition
     42    @adl_serializer.ontology.should == @sample_ontology
    4343  end
    4444end
  • ruby/trunk/spec/lib/open_ehr/serializer/sample_archetype_spec.rb

    r408 r412  
    99shared_examples_for 'sample archetype' do
    1010  before(:all) do
    11     terminologies_available = Set.new('ja')
    12     term_codes = ['at0000']
    13     archetype_term = ArchetypeTerm.new(:code => 'ja',
     11    archetype_term = ArchetypeTerm.new(:code => 'at0000',
    1412                                       :items => {'text' => 'simple test',
    1513                                         'description' => 'simple test for serializer'})
    16     term_definitions = {'ja' => {'at0000' => archetype_term}}
     14    term_definitions = {'ja' => [archetype_term]}
    1715    ontology =
    18       ArchetypeOntology.new(:terminologies_available => terminologies_available,
    19                             :specialisation_depth => 0,
    20                             :term_codes => term_codes,
    21                             :constraint_codes => [],
    22                             :term_attribute_names => ['text','description'],
     16      ArchetypeOntology.new(:specialisation_depth => 0,
    2317                            :term_definitions => term_definitions)
    2418    archetype_id = ArchetypeID.new(:value =>
Note: See TracChangeset for help on using the changeset viewer.