open_ehr 0.6.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. data/Gemfile +10 -2
  2. data/Gemfile.lock +58 -18
  3. data/Guardfile +2 -1
  4. data/History.txt +10 -3
  5. data/Manifest.txt +3 -5
  6. data/README.rdoc +36 -32
  7. data/Rakefile +1 -1
  8. data/VERSION +1 -1
  9. data/bin/adl_validator.rb +84 -0
  10. data/lib/open_ehr/am/archetype/constraint_model/primitive.rb +11 -7
  11. data/lib/open_ehr/am/archetype/constraint_model.rb +4 -16
  12. data/lib/open_ehr/am/archetype/ontology.rb +37 -6
  13. data/lib/open_ehr/am/archetype.rb +6 -7
  14. data/lib/open_ehr/am/open_ehr_profile/data_types/text.rb +5 -2
  15. data/lib/open_ehr/parser/adl.rb +19 -0
  16. data/lib/open_ehr/parser/adl_grammar.tt +155 -0
  17. data/lib/open_ehr/parser/adl_parser.rb +48 -0
  18. data/lib/open_ehr/parser/cadl_grammar.tt +803 -0
  19. data/lib/open_ehr/parser/dadl.rb +13 -0
  20. data/lib/open_ehr/parser/dadl_grammar.tt +358 -0
  21. data/lib/open_ehr/parser/exception.rb +68 -0
  22. data/lib/open_ehr/parser/scanner/adl_scanner.rb +819 -0
  23. data/lib/open_ehr/parser/shared_token_grammar.tt +1200 -0
  24. data/lib/open_ehr/parser/validator.rb +20 -0
  25. data/lib/open_ehr/parser.rb +16 -12
  26. data/lib/open_ehr.rb +1 -0
  27. data/open_ehr.gemspec +364 -0
  28. data/spec/lib/open_ehr/am/archetype/archetype_spec.rb +7 -2
  29. data/spec/lib/open_ehr/am/archetype/constraint_model/c_multiple_attribute_spec.rb +0 -6
  30. data/spec/lib/open_ehr/am/archetype/constraint_model/c_object_spec.rb +10 -10
  31. data/spec/lib/open_ehr/am/archetype/constraint_model/c_single_attribute_spec.rb +0 -6
  32. data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_boolean_spec.rb +5 -0
  33. data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_date_time_spec.rb +5 -0
  34. data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_duration_spec.rb +5 -0
  35. data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_integer_spec.rb +5 -0
  36. data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_primitive_spec.rb +8 -6
  37. data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_real_spec.rb +7 -2
  38. data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_string_spec.rb +5 -0
  39. data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_time_spec.rb +5 -0
  40. data/spec/lib/open_ehr/am/archetype/ontology/archetype_ontology_spec.rb +27 -7
  41. data/spec/lib/open_ehr/am/archetype/ontology/archetype_term_spec.rb +3 -3
  42. data/spec/lib/open_ehr/parser/adl/adl-test-ENTRY.assumed_types.v1.adl +88 -0
  43. data/spec/lib/open_ehr/parser/adl/adl-test-ENTRY.basic_types.v1.adl +143 -0
  44. data/spec/lib/open_ehr/parser/adl/adl-test-ENTRY.basic_types_fail.v1.adl +50 -0
  45. data/spec/lib/open_ehr/parser/adl/adl-test-ENTRY.most_minimal.v1.adl +27 -0
  46. data/spec/lib/open_ehr/parser/adl/adl-test-ENTRY.structure_test1.v1.adl +46 -0
  47. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-ACTION.imaging.v1.adl +275 -0
  48. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-ACTION.referral.v1.adl +351 -0
  49. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-CLUSTER.auscultation-chest.v1.adl +765 -0
  50. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-CLUSTER.auscultation.v1.adl +217 -0
  51. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-CLUSTER.dimensions-circumference.v1.adl +134 -0
  52. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-CLUSTER.dimensions.v1.adl +241 -0
  53. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-CLUSTER.exam-abdomen.v1.adl +321 -0
  54. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-CLUSTER.exam-chest.v1.adl +379 -0
  55. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-CLUSTER.exam-fetus.v1.adl +577 -0
  56. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-CLUSTER.exam-generic-joint.v1.adl +146 -0
  57. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-CLUSTER.exam-generic-lymphnode.v1.adl +176 -0
  58. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-CLUSTER.exam-generic-mass.v1.adl +221 -0
  59. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-CLUSTER.exam-generic.v1.adl +139 -0
  60. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-CLUSTER.exam-nervous_system.v1.adl +116 -0
  61. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-CLUSTER.exam-uterine_cervix.v1.adl +420 -0
  62. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-CLUSTER.exam-uterus.v1.adl +293 -0
  63. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-COMPOSITION.discharge.v1draft.adl +53 -0
  64. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-COMPOSITION.encounter.v1draft.adl +45 -0
  65. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-EVALUATION.adverse.v1.adl +411 -0
  66. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-INSTRUCTION.medication.v1.adl +88 -0
  67. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-INSTRUCTION.referral.v1.adl +84 -0
  68. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-ITEM_TREE.Laboratory_request.v1.adl +492 -0
  69. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-ITEM_TREE.follow_up.v1draft.adl +94 -0
  70. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-ITEM_TREE.imaging.v1.adl +127 -0
  71. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-ITEM_TREE.medication-formulation.v1.adl +457 -0
  72. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-ITEM_TREE.medication.v1.adl +869 -0
  73. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-ITEM_TREE.referral.v1.adl +494 -0
  74. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-OBSERVATION.apgar.v1.adl +545 -0
  75. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-OBSERVATION.blood_pressure.v1.adl +673 -0
  76. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-OBSERVATION.body_mass_index.v1.adl +166 -0
  77. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-SECTION.findings.v1.adl +47 -0
  78. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-SECTION.reason_for_encounter.v1.adl +51 -0
  79. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-SECTION.summary.v1.adl +52 -0
  80. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-SECTION.vital_signs.v1.adl +54 -0
  81. data/spec/lib/open_ehr/parser/adl/openEHR-EHR-cadl_sample.v1.adl +9 -0
  82. data/spec/lib/open_ehr/parser/adl_parser_spec.rb +210 -0
  83. data/spec/lib/open_ehr/parser/base_spec.rb +19 -0
  84. data/spec/spec.opts +2 -1
  85. data/spec/spec_helper.rb +3 -0
  86. metadata +166 -52
  87. data/doc/README_rdoc.html +0 -148
  88. data/doc/created.rid +0 -2
  89. data/doc/images/brick.png +0 -0
  90. data/doc/images/brick_link.png +0 -0
  91. data/doc/images/bug.png +0 -0
  92. data/doc/images/bullet_black.png +0 -0
  93. data/doc/images/bullet_toggle_minus.png +0 -0
  94. data/doc/images/bullet_toggle_plus.png +0 -0
  95. data/doc/images/date.png +0 -0
  96. data/doc/images/find.png +0 -0
  97. data/doc/images/loadingAnimation.gif +0 -0
  98. data/doc/images/macFFBgHack.png +0 -0
  99. data/doc/images/package.png +0 -0
  100. data/doc/images/page_green.png +0 -0
  101. data/doc/images/page_white_text.png +0 -0
  102. data/doc/images/page_white_width.png +0 -0
  103. data/doc/images/plugin.png +0 -0
  104. data/doc/images/ruby.png +0 -0
  105. data/doc/images/tag_green.png +0 -0
  106. data/doc/images/wrench.png +0 -0
  107. data/doc/images/wrench_orange.png +0 -0
  108. data/doc/images/zoom.png +0 -0
  109. data/doc/index.html +0 -54
  110. data/doc/js/darkfish.js +0 -116
  111. data/doc/js/jquery.js +0 -32
  112. data/doc/js/quicksearch.js +0 -114
  113. data/doc/js/thickbox-compressed.js +0 -10
  114. data/doc/rdoc.css +0 -706
  115. data/lib/#open_ehr.rb# +0 -11
data/Gemfile CHANGED
@@ -6,9 +6,17 @@ gem 'locale'
6
6
  gem 'builder'
7
7
  gem 'jeweler'
8
8
  gem 'i18n'
9
+ gem 'treetop'
10
+ gem 'polyglot'
11
+ gem 'rdoc'
9
12
 
10
- group :development do
13
+ group :development, :test do
11
14
  gem 'rspec'
12
15
  gem 'guard-rspec'
13
- gem 'spork'
16
+ gem 'ruby-debug19'
17
+ gem 'spork', '>=0.9.0.rc2'
18
+ gem 'guard-spork'
19
+ gem 'simplecov'
20
+ gem 'rb-inotify'
21
+ gem 'libnotify'
14
22
  end
data/Gemfile.lock CHANGED
@@ -1,32 +1,64 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- activesupport (3.0.7)
4
+ activesupport (3.1.0)
5
+ multi_json (~> 1.0)
6
+ archive-tar-minitar (0.5.2)
5
7
  builder (3.0.0)
6
- diff-lcs (1.1.2)
8
+ columnize (0.3.4)
9
+ diff-lcs (1.1.3)
10
+ ffi (1.0.9)
7
11
  git (1.2.5)
8
- guard (0.3.4)
12
+ guard (0.7.0)
9
13
  thor (~> 0.14.6)
10
- guard-rspec (0.3.1)
14
+ guard-rspec (0.4.5)
15
+ guard (>= 0.4.0)
16
+ guard-spork (0.2.1)
11
17
  guard (>= 0.2.2)
12
- i18n (0.5.0)
13
- jeweler (1.6.0)
14
- bundler (~> 1.0.0)
18
+ spork (>= 0.8.4)
19
+ i18n (0.6.0)
20
+ jeweler (1.6.4)
21
+ bundler (~> 1.0)
15
22
  git (>= 1.2.5)
16
23
  rake
24
+ libnotify (0.5.7)
25
+ linecache19 (0.5.12)
26
+ ruby_core_source (>= 0.1.4)
17
27
  locale (2.0.5)
18
- rake (0.8.7)
19
- rspec (2.5.0)
20
- rspec-core (~> 2.5.0)
21
- rspec-expectations (~> 2.5.0)
22
- rspec-mocks (~> 2.5.0)
23
- rspec-core (2.5.2)
24
- rspec-expectations (2.5.0)
28
+ multi_json (1.0.3)
29
+ polyglot (0.3.2)
30
+ rake (0.9.2)
31
+ rb-inotify (0.8.6)
32
+ ffi (>= 0.5.0)
33
+ rdoc (3.9.4)
34
+ rspec (2.6.0)
35
+ rspec-core (~> 2.6.0)
36
+ rspec-expectations (~> 2.6.0)
37
+ rspec-mocks (~> 2.6.0)
38
+ rspec-core (2.6.4)
39
+ rspec-expectations (2.6.0)
25
40
  diff-lcs (~> 1.1.2)
26
- rspec-mocks (2.5.0)
27
- spork (0.8.4)
41
+ rspec-mocks (2.6.0)
42
+ ruby-debug-base19 (0.11.25)
43
+ columnize (>= 0.3.1)
44
+ linecache19 (>= 0.5.11)
45
+ ruby_core_source (>= 0.1.4)
46
+ ruby-debug19 (0.11.6)
47
+ columnize (>= 0.3.1)
48
+ linecache19 (>= 0.5.11)
49
+ ruby-debug-base19 (>= 0.11.19)
50
+ ruby_core_source (0.1.5)
51
+ archive-tar-minitar (>= 0.5.2)
52
+ simplecov (0.5.3)
53
+ multi_json (~> 1.0.3)
54
+ simplecov-html (~> 0.5.3)
55
+ simplecov-html (0.5.3)
56
+ spork (0.9.0.rc9)
28
57
  thor (0.14.6)
29
- xml-simple (1.0.15)
58
+ treetop (1.4.10)
59
+ polyglot
60
+ polyglot (>= 0.3.1)
61
+ xml-simple (1.1.0)
30
62
 
31
63
  PLATFORMS
32
64
  ruby
@@ -35,9 +67,17 @@ DEPENDENCIES
35
67
  activesupport
36
68
  builder
37
69
  guard-rspec
70
+ guard-spork
38
71
  i18n
39
72
  jeweler
73
+ libnotify
40
74
  locale
75
+ polyglot
76
+ rb-inotify
77
+ rdoc
41
78
  rspec
42
- spork
79
+ ruby-debug19
80
+ simplecov
81
+ spork (>= 0.9.0.rc2)
82
+ treetop
43
83
  xml-simple
data/Guardfile CHANGED
@@ -2,8 +2,9 @@ guard 'rspec' do
2
2
  watch(%r{^spec/.+_spec\.rb})
3
3
  watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
4
  watch('spec/spec_helper.rb') { "spec" }
5
+ watch(%r{^lib/open_ehr/parser/.+\.tt}) { "spec/lib/open_ehr/parser" }
5
6
  end
6
7
 
7
- guard 'spork' do
8
+ guard 'spork', :wait => 30, :cucumber => false do
8
9
  watch('spec/spec_helper.rb')
9
10
  end
data/History.txt CHANGED
@@ -1,4 +1,11 @@
1
- === 0.0.1 2011-04-26
1
+ === 0.6.1 2011-05-09
2
+
3
+ * First gem package release
4
+
5
+ === 0.6.2 2011-05-09
6
+ * Fixed some package hierachy
7
+
8
+ === 0.7.0 2011-05
9
+ * Fixed ADL parser library
10
+
2
11
 
3
- * 1 major enhancement:
4
- * Initial release
data/Manifest.txt CHANGED
@@ -1,16 +1,14 @@
1
+ Gemfile
2
+ Guardfile
1
3
  History.txt
2
4
  Manifest.txt
3
5
  PostInstall.txt
4
6
  README.rdoc
5
7
  Rakefile
6
- bin/open_ehr
8
+ VERSION
7
9
  lib/open_ehr.rb
8
10
  lib/open_ehr/cli.rb
9
- script/console
10
- script/destroy
11
- script/generate
12
11
  spec/open_ehr_cli_spec.rb
13
12
  spec/open_ehr_spec.rb
14
13
  spec/spec.opts
15
14
  spec/spec_helper.rb
16
- tasks/rspec.rake
data/README.rdoc CHANGED
@@ -5,62 +5,66 @@ Ruby openEHR implementation project.
5
5
 
6
6
  = Version
7
7
 
8
- Release-0.6.0
8
+ Release-0.9.0b
9
9
 
10
10
  = Requirements
11
11
 
12
- * Ruby 1.8.7 or higher, 1.9.2 reccomended
12
+ * Ruby 1.9.2 reccomended
13
13
  * RubyGems
14
14
  * Tested with Ruby 1.9.2 on Linux and FreeBSD.
15
- * If you use Ruby 1.6, you should prepare racc
16
- runtime environment and some adjustment
15
+ * If you use early version of Ruby 1.8, you should
16
+ prepare racc runtime environment and some
17
+ adjustment. We do not support Ruby 1.6 anymore.
17
18
  * It should work on other platforms with Ruby
18
19
  support as well.
19
20
 
20
21
  == DESCRIPTION:
21
22
 
22
- This is the version 0.6.0 release of Ruby openEHR implementation
23
+ This is the beta version 0.9.0 release of Ruby openEHR implementation
23
24
  project. This release is still experimental preview of our work based
24
- on openEHR specification release 1.0.2. We implemented almost half of
25
- the specifications of the openEHR. The work is still in progress. The
26
- intention is to have complete implementation of openEHR Reference
27
- Model and some of the Archetype Object Models, with support for
28
- archetype based object creation and validation.
25
+ on openEHR specification release 1.0.2. We implemented almost of the
26
+ specifications of the openEHR. The work is still in progress. The
27
+ intention is to have a sample EHR to utilize all over the world
28
+ quickly with Ruby on Rails.
29
29
 
30
- Parser and Seriarizer are also primitive, we are challanging to
31
- descrive archetype as another formalism such as YAML, instead of ADL.
30
+ Parser is nearly performing completely. We now consider to descrive
31
+ archetype as another formalism such as YAML, instead of ADL.
32
32
 
33
- Almost all classes passed the test constructed by rspec or
34
- test/unit. This test cases are under /spec.
33
+ Almost all classes passed the test constructed by rspec2 (formaly used
34
+ test/unit). These test specification are under /spec.
35
35
 
36
- Some specifications are not well determined yet, such as
37
- rm/security and so on. We postponed to implement such
38
- classes.
36
+ Some specifications are not well determined yet, such as rm/security
37
+ and so on. We postponed to implement such classes.
39
38
 
40
- Terminology and Demographic server will be implemented in
41
- other project.
39
+ Terminology and Demographic server will be implemented in other
40
+ project.
42
41
 
43
42
  = Authors
44
43
  Akimichi Tatsukawa, Shinji Kobayashi
44
+
45
45
  openEHR.jp, <http://openehr.jp>
46
46
 
47
47
  = Copyright
48
- The software, including all files in this directory
49
- and subdirectories is copyrighted to the original
50
- authors and contributors, 2008
48
+ The software, including all files in this directory and
49
+ subdirectories is copyrighted to the original authors and
50
+ contributors, 2011.
51
+
51
52
  All Rights Reserved.
52
53
 
53
54
  = License
54
55
 
55
56
  This product is under openEHR Open Source Software License
56
57
 
57
- The openEHR Foundation uses the Mozilla Tri-license 1.1 on
58
- all software copyrighted to the Foundation. This licence
59
- essentially provides the user a choice of licence conditions
60
- under which to operate with any given piece of software,
61
- being: the Mozilla Public licence (MPL), and the Free
62
- Software Foundation GNU General Public Licence (GPL) and
63
- Lesser GNU General Public Licence (LGPL). See the Mozilla
64
- relicensing FAQ for details of this license. This in no way
65
- constrains the way in which software created by other
66
- organisations is licenced.
58
+ The openEHR Foundation has used the Mozilla Tri-license 1.1 on all
59
+ software copyrighted to the Foundation. Therefore, we release this
60
+ product under Mozilla Tri-license at now, but the openEHR foundation
61
+ is discussing about lincense for the resouces. We would change our
62
+ license for this package after the decision. The Mozilla tri-licence
63
+ essentially provides the user a choice of licence conditionsunder
64
+ which to operate with any given piece of software, being: the Mozilla
65
+ Public licence (MPL), and the Free Software Foundation GNU General
66
+ Public Licence (GPL) and Lesser GNU General Public Licence (LGPL). See
67
+ the Mozilla relicensing FAQ for details of this license. This in no
68
+ way constrains the way in which software created by other
69
+ organisations is licenced.
70
+
data/Rakefile CHANGED
@@ -38,7 +38,7 @@ end
38
38
 
39
39
  task :default => :spec
40
40
 
41
- require 'rake/rdoctask'
41
+ require 'rdoc/task'
42
42
  Rake::RDocTask.new do |rdoc|
43
43
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
44
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.1
1
+ 0.9.0
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require "adl_parser"
4
+ require 'readline'
5
+ require 'optparse'
6
+ require 'net/http'
7
+
8
+ module OpenEhr
9
+ module CommandLine
10
+ class Arguments < Hash
11
+ def initialize(args)
12
+ super() # default values
13
+ opts = ::OptionParser.new do |opts|
14
+ opts.banner = "Usage: #$0 [file|http://location.to.adl]* [options]"
15
+ opts.on('-v', '--verbose', 'display verbose message(Not Implemented Yet)') do
16
+ self[:verbose] = true
17
+ end
18
+ opts.on_tail('-h', '--help', 'display this help') do
19
+ puts opts
20
+ exit
21
+ end
22
+ end
23
+ opts.parse!(args)
24
+ end
25
+ end
26
+
27
+ class ADLValidator
28
+ def initialize(arguments)
29
+ @debug = false
30
+ @adl_validator = ::OpenEHR::Application::ADLValidator.new(::OpenEHR::ADL::Validator.new(::OpenEHR::ADL::Parser.new))
31
+ end
32
+
33
+ def run
34
+ while argv = ARGV.shift
35
+ begin
36
+ input = nil
37
+ name = nil
38
+ case argv
39
+ when /\A(http:\/\/.*)/
40
+ name = $1
41
+ input = case response = Net::HTTP.get_response(Uri.parse($1))
42
+ when Net::HTTPSuccess
43
+ response.body
44
+ when Net::HTTPRedirection
45
+ name = response['location']
46
+ fetch(response['location'], limit - 1)
47
+ else
48
+ response.error!
49
+ end
50
+ when /\A("[^"]*)"/
51
+ name = argv
52
+ input = argv
53
+ else # assumes file name
54
+ name = argv
55
+ input = File.new(argv)
56
+ end
57
+ @adl_validator.run(input, name)
58
+ rescue SocketError => message
59
+ puts "SocketError: #{message}"
60
+ rescue Racc::ParseError => message
61
+ puts "ParseError: #{message}"
62
+ else
63
+ puts "Accepted '#{argv}'"
64
+ ensure
65
+ # input.close if input.kind_of? IO
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end # of CommandLine
71
+ end # of OpenEHR
72
+
73
+ if __FILE__ == $0
74
+ begin
75
+ arguments = OpenEhr::CommandLine::Arguments.new(ARGV)
76
+ validator = OpenEhr::CommandLine::ADLValidator.new(arguments)
77
+ validator.run
78
+ end
79
+ end
80
+
81
+
82
+
83
+
84
+
@@ -5,19 +5,21 @@ module OpenEHR
5
5
  module ConstraintModel
6
6
  module Primitive
7
7
  class CPrimitive
8
- attr_reader :default_value
9
- attr_accessor :assumed_value
8
+ attr_reader :type
9
+ attr_accessor :assumed_value, :default_value
10
10
 
11
11
  def initialize(args = { })
12
12
  self.default_value = args[:default_value]
13
13
  self.assumed_value = args[:assumed_value]
14
+ self.type = args[:type]
15
+ @type ||= 'ANY'
14
16
  end
15
17
 
16
- def default_value=(default_value)
17
- if default_value.nil?
18
- raise ArgumentError, 'default_value is mandatory'
18
+ def type=(type)
19
+ if !type.nil? && type.empty?
20
+ raise ArgumentError, 'type should not be empty'
19
21
  end
20
- @default_value = default_value
22
+ @type = type
21
23
  end
22
24
 
23
25
  def has_assumed_value?
@@ -129,7 +131,9 @@ module OpenEHR
129
131
  end
130
132
 
131
133
  class CReal < CInteger
132
-
134
+ def initialize(args = { })
135
+ super
136
+ end
133
137
  end
134
138
 
135
139
  module CDateModule
@@ -89,11 +89,10 @@ module OpenEHR
89
89
  attr_reader :rm_type_name, :node_id, :occurrences
90
90
 
91
91
  def initialize(args = { })
92
- super(args)
92
+ super
93
93
  self.rm_type_name = args[:rm_type_name]
94
94
  self.node_id = args[:node_id]
95
95
  self.occurrences = args[:occurrences]
96
-
97
96
  end
98
97
 
99
98
  def rm_type_name=(rm_type_name)
@@ -104,7 +103,7 @@ module OpenEHR
104
103
  end
105
104
 
106
105
  def node_id=(node_id)
107
- if node_id.nil? || node_id.empty?
106
+ if !node_id.nil? && node_id.empty?
108
107
  raise ArgumentError, 'invalid node_id'
109
108
  end
110
109
  @node_id = node_id
@@ -145,7 +144,7 @@ module OpenEHR
145
144
  end
146
145
 
147
146
  def existence=(existence)
148
- if existence.nil? || existence.lower < 0 || existence.upper > 1
147
+ if !existence.nil? && (existence.lower < 0 || existence.upper > 1)
149
148
  raise ArgumentError, 'invalid existence'
150
149
  end
151
150
  @existence = existence
@@ -309,29 +308,18 @@ module OpenEHR
309
308
  end
310
309
 
311
310
  def alternatives=(alternatives)
312
- if alternatives.nil?
313
- raise ArgumentError, 'alternatives are mandatory'
314
- end
315
311
  @alternatives = alternatives
316
312
  end
317
313
  end
318
314
 
319
315
  class CMultipleAttribute < CAttribute
320
- attr_accessor :members
321
- attr_reader :cardinality
316
+ attr_accessor :members, :cardinality
322
317
 
323
318
  def initialize(args = { })
324
319
  super
325
320
  self.members = args[:members]
326
321
  self.cardinality = args[:cardinality]
327
322
  end
328
-
329
- def cardinality=(cardinality)
330
- if cardinality.nil?
331
- raise ArgumentError, 'cardinality is mandatory'
332
- end
333
- @cardinality = cardinality
334
- end
335
323
  end
336
324
  end # of ConstraintModel
337
325
  end # of Archetype
@@ -3,14 +3,16 @@ module OpenEHR
3
3
  module Archetype
4
4
  module Ontology
5
5
  class ArchetypeOntology
6
- attr_accessor :constraint_definitions, :specialisation_depth
6
+ attr_accessor :specialisation_depth
7
7
  attr_accessor :term_attribute_names, :term_bindings
8
- attr_reader :terminologies_available, :term_definitions
8
+ attr_reader :term_definitions, :constraint_definitions
9
9
 
10
10
  def initialize(args = { })
11
11
  self.specialisation_depth = args[:specialisation_depth]
12
12
  self.term_definitions = args[:term_definitions]
13
- self.constraint_definitions = args[:constraint_definitions]
13
+ if args[:constraint_definitions]
14
+ self.constraint_definitions = args[:constraint_definitions]
15
+ end
14
16
  self.term_bindings = args[:term_bindings]
15
17
  end
16
18
 
@@ -18,6 +20,7 @@ module OpenEHR
18
20
  if term_definitions.nil?
19
21
  raise ArgumentError, 'term_definitions is mandatory'
20
22
  end
23
+ @term_definition_map = definition_mapper(term_definitions)
21
24
  @term_definitions = term_definitions
22
25
  end
23
26
 
@@ -40,21 +43,45 @@ module OpenEHR
40
43
  end
41
44
 
42
45
  def constraint_binding(a_terminology, a_code)
46
+
47
+ end
48
+
49
+ def constraint_definitions=(constraint_definitions)
50
+ @constraint_definition_map = definition_mapper(constraint_definitions)
51
+ @constraint_definitions = constraint_definitions
43
52
  end
44
53
 
45
- def constraint_definition(a_lang, a_code)
54
+ def constraint_definition(args = {})
55
+ return @constraint_definition_map[args[:lang]][args[:code]]
46
56
  end
47
57
 
48
58
  def has_language?(a_lang)
59
+ return @term_definition_map.has_key? a_lang
49
60
  end
50
61
 
51
62
  def has_terminology?(a_terminology)
63
+ return @term_bindings.has_key? a_terminology
64
+ end
65
+
66
+ def term_binding(args = { })
67
+
52
68
  end
53
69
 
54
- def term_binding(a_terminology, a_code)
70
+ def term_definition(args = { })
71
+ return @term_definition_map[args[:lang]][args[:code]]
55
72
  end
56
73
 
57
- def term_definition(a_lang, a_code)
74
+ private
75
+ def definition_mapper(definitions)
76
+ map = { }
77
+ definitions.each do |lang, defs|
78
+ defs_map = { }
79
+ defs.each do |d|
80
+ defs_map[d.code] = d.items
81
+ end
82
+ map[lang] = defs_map
83
+ end
84
+ return map
58
85
  end
59
86
  end
60
87
 
@@ -85,6 +112,10 @@ module OpenEHR
85
112
  return Set.new(@items.keys)
86
113
  end
87
114
  end
115
+
116
+ def method_missing(key)
117
+ return @items[key.to_sym]
118
+ end
88
119
  end
89
120
 
90
121
  class ARCHETYPE_TERM < ArchetypeTerm
@@ -4,6 +4,10 @@ include OpenEHR::RM::Common::Resource
4
4
  module OpenEHR
5
5
  module AM
6
6
  module Archetype
7
+ autoload :Assertion, 'archetype/assertion'
8
+ autoload :ConstraintModel, 'archetype/constraint_model'
9
+ autoload :Ontology, 'archetype/ontology'
10
+
7
11
  module ADLDefinition
8
12
  include OpenEHR::RM::Support::Terminology
9
13
  # include OpenEHR::RM::Support::Terminology::OpenEHR_Code_Set_Identifier
@@ -64,7 +68,7 @@ module OpenEHR
64
68
  end
65
69
 
66
70
  def concept_name(a_lang)
67
-
71
+ return @ontology.term_definition(:lang => a_lang, :code => @concept)[:text]
68
72
  end
69
73
 
70
74
  def constraint_references_valid?
@@ -79,7 +83,7 @@ module OpenEHR
79
83
  def is_valid?
80
84
  end
81
85
 
82
- def logical_paths(a_lang)
86
+ def logical_paths(a_lang)
83
87
  end
84
88
 
85
89
  def node_ids_vaild?
@@ -124,11 +128,6 @@ module OpenEHR
124
128
  @value = value
125
129
  end
126
130
  end
127
-
128
- autoload :Assertion, 'archetype/assertion'
129
- autoload :ConstraintModel, 'archetype/constraint_model'
130
- autoload :Ontology, 'archetype/ontology'
131
-
132
131
  end # of Archetype
133
132
  end # of AM
134
133
  end # of OpenEHR
@@ -1,6 +1,9 @@
1
- module OpenEhr
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ module OpenEHR
2
5
  module AM
3
- module OpenEHR_Profile
6
+ module OpenEHRProfile
4
7
  module DataTypes
5
8
  module Text
6
9
  class C_CODE_PHASE < OpenEhr::AM::Archetype::Constraint_Model::C_DOMAIN_TYPE
@@ -0,0 +1,19 @@
1
+ module OpenEHR
2
+ module Parser
3
+ module ADLGrammar
4
+ class Base < Treetop::Runtime::SyntaxNode
5
+
6
+ end
7
+
8
+ class ArchLanguage < Base
9
+ def original_language
10
+ lang.value[:original_language]
11
+ end
12
+
13
+ def translations
14
+ lang.value[:translations]
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end