openehr-rails 0.0.2 → 0.1.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 (50) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +13 -0
  3. data/Rakefile +1 -16
  4. data/lib/generators/openehr/assets/assets_generator.rb +28 -0
  5. data/lib/generators/openehr/assets/templates/javascript.js +1 -0
  6. data/lib/generators/openehr/assets/templates/stylesheet.css.scss +3 -0
  7. data/lib/generators/openehr/controller/controller_generator.rb +10 -9
  8. data/lib/generators/openehr/controller/templates/controller.rb +71 -10
  9. data/lib/generators/openehr/helper/helper_generator.rb +17 -0
  10. data/lib/generators/openehr/helper/templates/helper.rb +2 -0
  11. data/lib/generators/openehr/i18n/i18n_generator.rb +29 -33
  12. data/lib/generators/openehr/i18n/templates/i18n.rb +3 -3
  13. data/lib/generators/openehr/i18n/templates/language.yml +8 -3
  14. data/lib/generators/openehr/install/install_generator.rb +6 -9
  15. data/lib/generators/openehr/migration/migration_generator.rb +24 -9
  16. data/lib/generators/openehr/migration/templates/archetypes.rb +10 -0
  17. data/lib/generators/openehr/migration/templates/rms.rb +16 -0
  18. data/lib/generators/openehr/model/model_generator.rb +108 -7
  19. data/lib/generators/openehr/model/templates/activemodel.rb +71 -0
  20. data/lib/generators/openehr/model/templates/archetype.rb +3 -0
  21. data/lib/generators/openehr/model/templates/rm.rb +3 -0
  22. data/lib/generators/openehr/scaffold/scaffold_generator.rb +182 -109
  23. data/lib/generators/openehr/scaffold/templates/_form.html.erb +1 -1
  24. data/lib/generators/openehr/scaffold/templates/application.html.erb +14 -0
  25. data/lib/generators/openehr/scaffold/templates/application_controller.rb +1 -0
  26. data/lib/generators/openehr/scaffold/templates/edit.html.erb +3 -3
  27. data/lib/generators/openehr/scaffold/templates/index.html.erb +4 -4
  28. data/lib/generators/openehr/scaffold/templates/inflections.rb +3 -0
  29. data/lib/generators/openehr/scaffold/templates/layout.css.scss +4 -0
  30. data/lib/generators/openehr/scaffold/templates/new.html.erb +5 -0
  31. data/lib/generators/openehr/scaffold/templates/show.html.erb +2 -2
  32. data/lib/generators/openehr.rb +67 -49
  33. data/lib/openehr-rails/version.rb +1 -1
  34. data/lib/openehr-rails.rb +1 -1
  35. data/openehr-rails.gemspec +1 -5
  36. data/spec/generator_helper.rb +3 -0
  37. data/spec/generators/openehr/archetyped_base_spec.rb +53 -35
  38. data/spec/generators/openehr/assets/assets_generator_spec.rb +37 -0
  39. data/spec/generators/openehr/controller/controller_generator_spec.rb +20 -4
  40. data/spec/generators/openehr/helper/helper_generator_spec.rb +23 -0
  41. data/spec/generators/openehr/i18n/i18n_generator_spec.rb +49 -50
  42. data/spec/generators/openehr/install/install_generator_spec.rb +3 -3
  43. data/spec/generators/openehr/migration/migration_generator_spec.rb +18 -7
  44. data/spec/generators/openehr/model/model_generator_spec.rb +54 -0
  45. data/spec/generators/openehr/scaffold/scaffold_generator_spec.rb +121 -48
  46. data/spec/spec_helper.rb +6 -6
  47. metadata +26 -68
  48. data/Guardfile +0 -15
  49. data/db/seeds.rb +0 -7
  50. data/lib/assets/.gitkeep +0 -0
@@ -2,148 +2,221 @@ require 'openehr/rm'
2
2
  require 'openehr/am'
3
3
  require 'openehr/parser'
4
4
  require 'generators/openehr'
5
+ require 'generators/openehr/assets/assets_generator'
6
+ require 'generators/openehr/model/model_generator'
7
+ require 'generators/openehr/migration/migration_generator'
8
+ require 'generators/openehr/controller/controller_generator'
9
+ require 'generators/openehr/helper/helper_generator'
10
+ require 'generators/openehr/i18n/i18n_generator'
11
+ require 'rails/generators'
12
+
13
+ module Openehr
14
+ module Generators
15
+ class ScaffoldGenerator < ArchetypedBase
16
+ source_root File.expand_path("../templates", __FILE__)
17
+
18
+ def create_root_folder
19
+ empty_directory File.join("app/views", controller_file_path)
20
+ end
21
+
22
+ def generate_index
23
+ generate_view "index.html.erb"
24
+ end
5
25
 
6
- module OpenEHR
7
- module Rails
8
- module Generators
9
- class ScaffoldGenerator < ArchetypedBase
10
- source_root File.expand_path("../templates", __FILE__)
26
+ def generate_show
27
+ generate_view "show.html.erb"
28
+ end
11
29
 
12
- def create_root_folder
13
- empty_directory File.join("app/views", controller_file_path)
14
- end
30
+ def generate_edit
31
+ generate_view "edit.html.erb"
32
+ end
15
33
 
16
- def generate_index
17
- generate_view "index.html.erb"
18
- end
34
+ def generate_new
35
+ generate_view 'new.html.erb'
36
+ end
37
+ def generate_form
38
+ generate_view "_form.html.erb"
39
+ end
19
40
 
20
- def generate_show
21
- generate_view "show.html.erb"
41
+ invoke Openehr::Generators::MigrationGenerator
42
+ invoke Openehr::Generators::ModelGenerator, @archetype
43
+ invoke Openehr::Generators::ControllerGenerator, @archetype
44
+ invoke Openehr::Generators::HelperGenerator, @archetype
45
+ invoke Openehr::Generators::AssetsGenerator, @archetype
46
+ invoke Openehr::Generators::I18nGenerator, @archetype
47
+
48
+ def append_locale_route
49
+ unless File.exist? 'config/routes.rb'
50
+ template 'routes.rb', File.join("config", 'routes.rb')
22
51
  end
52
+ inject_into_file 'config/routes.rb',
53
+ " resources :#{controller_file_path}\n",
54
+ :after => "Application.routes.draw do\n"
55
+ end
23
56
 
24
- def generate_edit
25
- generate_view "edit.html.erb"
57
+ def insert_locale_swither
58
+ unless File.exist? 'app/views/layouts/application.html.erb'
59
+ template 'application.html.erb', File.join('app/views/layouts', 'application.html.erb')
26
60
  end
61
+ inject_into_file 'app/views/layouts/application.html.erb', <<SWITCHER, :after => "<body>\n"
62
+ <div id="banner">
63
+ <%= form_tag '', :method => 'get', class: 'locale' do %>
64
+ <%= select_tag 'locale',
65
+ options_for_select(LANGUAGES, I18n.locale.to_s),
66
+ onchange: 'this.form.submit()' %>
67
+ <% end %>
68
+ </div>
69
+ SWITCHER
70
+ end
71
+
72
+ def generate_layout_stylesheet
73
+ template 'layout.css.scss', File.join('app/assets/stylesheets', 'layout.css.scss')
74
+ end
27
75
 
28
- def generate_form
29
- generate_view "_form.html.erb"
76
+ def insert_uncountable_inflection
77
+ inflections_file_path = 'config/initializers/inflections.rb'
78
+ unless File.exist? inflections_file_path
79
+ empty_directory File.join('config/initializers')
80
+ template 'inflections.rb', File.join('config/initializers', 'inflections.rb')
81
+ else
82
+ append_to_file inflections_file_path, <<INFLECTION
83
+ ActiveSupport::Inflector.inflections(:en) do |inflect|
84
+ inflect.uncountable %w( )
85
+ end
86
+ INFLECTION
30
87
  end
88
+ insert_into_file inflections_file_path, model_name, :after => "inflect.uncountable %w( "
89
+ end
31
90
 
32
- def append_locale_route
33
- unless File.exist? 'config/routes.rb'
34
- template 'routes.rb', File.join("config", 'routes.rb')
35
- end
36
- inject_into_file 'config/routes.rb', <<LOCALE, :after => "Application.routes.draw do\n"
37
- scope "/:locale" do
38
- resources :#{controller_file_path}
39
- end
40
- LOCALE
91
+ def append_set_locale
92
+ unless File.exist? 'app/controllers/application_controller.rb'
93
+ template 'application_controller.rb', File.join("app/controllers", 'application_controller.rb')
41
94
  end
42
- def append_set_locale
43
- unless File.exist? 'app/controllers/application_controller.rb'
44
- template 'application_controller.rb', File.join("app/controllers", 'application_controller.rb')
45
- end
46
- inject_into_file 'app/controllers/application_controller.rb', <<LOCALE, :after => "class ApplicationController < ActionController::Base\n"
95
+ inject_into_file 'app/controllers/application_controller.rb', <<LOCALE, :after => "class ApplicationController < ActionController::Base\n"
47
96
  before_action :set_locale
48
97
 
49
98
  def set_locale
50
- I18n.locale = params[:locale] || I18n.default_locale
99
+ I18n.locale = params[:locale] || session[:locale] || I18n.default_locale
100
+ session[:locale] = I18n.locale
51
101
  end
52
102
  LOCALE
53
- end
103
+ end
54
104
 
55
- protected
105
+ protected
56
106
 
57
- def generate_view(filename)
58
- template filename, File.join("app/views", controller_file_path, filename)
59
- end
60
-
61
- def show_format(cobj)
62
- h = case cobj.rm_type_name
63
- when 'ELEMENT'
64
- show_element cobj
65
- when 'INTERVAL_EVENT'
66
- show_element cobj
67
- when 'OBSERVATION'
68
- show_component cobj
69
- when 'ACTION'
70
- show_component cobj
71
- else
72
- show_component cobj
73
- end
74
- h
75
- end
107
+ def generate_view(filename)
108
+ template filename, File.join("app/views", controller_file_path, filename)
109
+ end
76
110
 
77
- def show_component(cobj)
78
- html = "<strong>#{cobj.rm_type_name.humanize} t(\".#{cobj.node_id}\")</strong>:<br/>\n"
79
- unless cobj.respond_to? :attributes
80
- html += "#{cobj.rm_type_name}\n"
81
- else
82
- html += cobj.attributes.inject("") do |form, attr|
83
- form += "<p><strong>#{attr.rm_attribute_name.humanize}:</strong>"
84
- form += attr.children.inject("") {|h,c| h += show_format c}
85
- form += "</p>\n"
111
+ def show_format(cobj)
112
+ h = case cobj.rm_type_name
113
+ when 'ELEMENT'
114
+ show_element cobj
115
+ when 'EVENT'
116
+ show_component cobj
117
+ when 'INTERVAL_EVENT'
118
+ show_component cobj
119
+ when 'OBSERVATION'
120
+ show_component cobj
121
+ when 'ACTION'
122
+ show_component cobj
123
+ else
124
+ show_component cobj
86
125
  end
126
+ h
127
+ end
128
+
129
+ def show_component(cobj)
130
+ html = ''# "<strong>#{cobj.rm_type_name.humanize} t(\".#{cobj.node_id}\")</strong>:<br/>\n"
131
+ unless cobj.respond_to? :attributes
132
+ html += "#{cobj.rm_type_name}\n"
133
+ else
134
+ html += cobj.attributes.inject("") do |form, attr|
135
+ form += "<p><strong>#{attr.rm_attribute_name.humanize}:</strong>"
136
+ form += attr.children.inject("") {|h,c| h += show_format c; h}
137
+ form += "</p>\n"
87
138
  end
88
- return html
89
139
  end
90
-
91
- def show_element(cobj)
92
- html = "<strong><%= t(\"#.{cobj.node_id}\") %></strong>: "
93
- # value = cobj.select {|attr| attr.rm_attribute_name == 'value'}
94
- html += "<%= #{model_name}.#{cobj.node_id} %><br/>\n"
140
+ html
141
+ end
142
+
143
+ def show_element(cobj)
144
+ html = "<strong><%= t('.#{cobj.node_id}') %></strong>: "
145
+ value = cobj.attributes[0].children[0]
146
+ case value.rm_type_name
147
+ when 'DV_CODED_TEXT', 'DvCodedText'
148
+ html += "<%= @#{model_name}.#{cobj.node_id} %><br/>\n"
149
+ when 'DvQuantity', 'DV_QUANTITY'
150
+ html += "<%= @#{model_name}.#{cobj.node_id} %>#{value.list[0].units}<br/>\n"
151
+ else
152
+ html += "<%= @#{model_name}.#{cobj.node_id} %><br/>\n"
95
153
  end
154
+ html
155
+ end
96
156
 
97
- def form_format(cobj)
98
- html = case cobj.rm_type_name
99
- when 'ELEMENT'
100
- form_element cobj
101
- when 'INTERVAL_EVENT'
102
- form_element cobj
103
- else
104
- form_component cobj
105
- end
106
- return html
107
- end
157
+ def form_format(cobj)
158
+ html = case cobj.rm_type_name
159
+ when 'ELEMENT'
160
+ form_element cobj
161
+ when 'EVENT'
162
+ "<strong><%= t('.#{cobj.node_id}') %></strong>: <%= f.text_field :#{cobj.node_id} %><br/>\n" +
163
+ form_component(cobj)
164
+ when 'INTERVAL_EVENT'
165
+ "<strong><%= t('.#{cobj.node_id}') %></strong>: <%= f.text_field :#{cobj.node_id} %><br/>\n"
166
+ else
167
+ form_component cobj
168
+ end
169
+ return html
170
+ end
108
171
 
109
- def form_component(cobj)
110
- html = "<strong>#{cobj.rm_type_name.humanize} t(\".#{cobj.node_id}\")</strong>:<br/>\n"
111
- unless cobj.respond_to? :attributes
112
- html += "#{cobj.rm_type_name}\n"
113
- else
114
- html += cobj.attributes.inject("") do |form, attr|
115
- form += "<p><strong><%= t(\".#{cobj.node_id})\" %></strong>:"
116
- form += attr.children.inject('') {|h,c| h += form_format c}
117
- form += '</p>'
118
- end
172
+ def form_component(cobj)
173
+ html = '' #"<strong>#{cobj.rm_type_name.humanize} <%= t('.#{cobj.node_id}') %></strong>:<br/>\n"
174
+ unless cobj.respond_to? :attributes
175
+ html += "#{cobj.rm_type_name}<br/>\n"
176
+ else
177
+ html += cobj.attributes.inject("") do |form, attr|
178
+ form += "<p><strong><%= t('.#{cobj.node_id}') %></strong>:"
179
+ form += attr.children.inject('') {|h,c| h += form_format c}
180
+ form += "</p>\n"
119
181
  end
120
- html
121
182
  end
183
+ html
184
+ end
122
185
 
123
- def form_element(cobj)
124
- html = ''
125
- value = cobj.attributes.select {|attr| attr.rm_attribute_name == 'value'}
126
- unless value[0].nil?
127
- html = "<strong><%= f.label :#{cobj.node_id} %></strong>: "
128
- html += form_field value[0].children[0], cobj.node_id
186
+ def form_element(cobj)
187
+ html = ''
188
+ if cobj.respond_to? :attributes
189
+ cobj.attributes.each do |attr|
190
+ unless attr.nil?
191
+ html = "<strong><%= t('.#{cobj.node_id}') %></strong>: "
192
+ html += form_field attr.children[0], cobj.node_id
193
+ end
129
194
  end
130
- html
131
195
  end
196
+ html
197
+ end
198
+
199
+ def form_field(cobj, label)
200
+ form = case cobj.rm_type_name
201
+ when 'DV_TEXT', 'DvText'
202
+ "<%= f.text_field :#{label} %><br/>\n"
203
+ when 'DV_CODED_TEXT', 'DvCodedText'
204
+ "<%= f.select :#{label}, #{code_list_to_hash(cobj.attributes[0].children[0].code_list)} %><br/>\n"
205
+ when 'DV_QUANTITY', 'DvQuantity'
206
+ "<%= f.number_field :#{label} %> #{cobj.list[0].units}<br/>\n"
207
+ else
208
+ "<%= f.text_field :#{label} %><br/>\n"
209
+ end
210
+ form
211
+ end
132
212
 
133
- def form_field(cobj, label)
134
- form = case cobj.rm_type_name
135
- when 'DV_TEXT'
136
- "<%= f.text_field :#{label} %>\n"
137
- when 'DV_CODED_TEXT'
138
- "<%= f.select :#{label}, #{cobj.attributes[0].children[0].code_list.to_s}\n"
139
- when 'DV_QUANTITY'
140
- "<%= f.text_field :#{label} %>\n"
141
- else
142
- "<%= f.text_field :#{label} %>\n"
143
- end
144
- form
213
+ def code_list_to_hash(code_list)
214
+ html = code_list.inject('') do |form, item|
215
+ form += "t('.#{item}') => '#{item}', "
145
216
  end
217
+ html[0..-3] unless html.nil?
146
218
  end
147
219
  end
148
220
  end
149
221
  end
222
+
@@ -1,7 +1,7 @@
1
1
  <%%= form_for(@<%= model_name %>) do |f| %>
2
2
  <%% if @<%= model_name %>.errors.any? %>
3
3
  <div id="error_explanation">
4
- <h2><%%= pluralize(@<%= model_name %>.errors.count, "error") %> prohibited this <%= model_name %> from being saved:</h2>
4
+ <h2> <%%= pluralize(@<%= model_name %>.errors.count, "error") %> prohibited this <%= model_name %> from being saved:</h2>
5
5
 
6
6
  <ul>
7
7
  <%% @<%= model_name %>.errors.full_messages.each do |msg| %>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title><%= concept %></title>
5
+ <%%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
6
+ <%%= javascript_include_tag "application", "data-turbolinks-track" => true %>
7
+ <%%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -1,2 +1,3 @@
1
1
  class ApplicationController < ActionController::Base
2
+ protect_from_forgery with: :exception
2
3
  end
@@ -1,6 +1,6 @@
1
- <h1>Editing <%%= t(".<%= concept %>") %></h1>
1
+ <h1>Editing <%%= t('.<%= concept %>') %></h1>
2
2
 
3
3
  <%%= render 'form' %>
4
4
 
5
- <%%= link_to 'Show', @<%= model_name %> %> |
6
- <%%= link_to 'Back', <%= model_name %>_index_path %>
5
+ <%%= link_to 'Show', <%= controller_name %>_path(id: @<%= model_name %>.id) %> |
6
+ <%%= link_to 'Back', <%= controller_name %>_index_path %>
@@ -14,9 +14,9 @@
14
14
  <% index_data.each do |atcode| -%>
15
15
  <td><%%= <%= model_name %>.<%= atcode %> %></td>
16
16
  <% end -%>
17
- <td><%%= link_to 'Show', <%= model_name %> %></td>
18
- <td><%%= link_to 'Edit', edit_<%= model_name %>_path(<%= model_name %>) %></td>
19
- <td><%%= link_to 'Destroy', <%= model_name %>, method: :delete, data: { confirm: 'Are you sure?' } %></td>
17
+ <td><%%= link_to 'Show', <%= controller_name %>_path(id: <%= model_name %>.id) %></td>
18
+ <td><%%= link_to 'Edit', edit_<%= controller_name %>_path(id: <%= model_name %>.id) %></td>
19
+ <td><%%= link_to 'Destroy', <%= controller_name %>_path(id: <%= model_name %>.id), method: :delete, data: { confirm: 'Are you sure?' } %></td>
20
20
  </tr>
21
21
  <%% end %>
22
22
 
@@ -25,4 +25,4 @@
25
25
 
26
26
  <br>
27
27
 
28
- <%%= link_to <%%= t(".<%= concept %>") %>, new_<%= model_name %>_path %>
28
+ <%%= link_to "New <%= archetype.archetype_id.concept_name %>", new_<%= controller_file_path %>_path %>
@@ -0,0 +1,3 @@
1
+ ActiveSupport::Inflector.inflections(:en) do |inflect|
2
+ inflect.uncountable %w( )
3
+ end
@@ -0,0 +1,4 @@
1
+ .locale {
2
+ float: right;
3
+ margin: -0.25em 0.1em;
4
+ }
@@ -0,0 +1,5 @@
1
+ <h1>New <%%= t(".<%= archetype.concept %>") %></h1>
2
+
3
+ <%%= render 'form' %>
4
+
5
+ <%%= link_to 'Back', <%= controller_name %>_index_path %>
@@ -2,5 +2,5 @@
2
2
 
3
3
  <%= show_format(archetype.definition) %>
4
4
 
5
- <%%= link_to 'Edit', edit_<%= model_name %>_path(@<%= model_name %>) %> |
6
- <%%= link_to 'Back', <%= model_name %>_index_path %>
5
+ <%%= link_to 'Edit', edit_<%= controller_name %>_path(id: @<%= model_name %>.id) %> |
6
+ <%%= link_to 'Back', <%= controller_name %>_index_path %>
@@ -1,70 +1,88 @@
1
- module OpenEHR
2
- module Rails
3
- module Generators
4
- class ArchetypedBase < ::Rails::Generators::Base
5
- argument :archetype_name
1
+ require 'openehr/am'
2
+ require 'openehr/rm'
3
+ require 'openehr/parser'
4
+ require 'openehr/ckm_client'
6
5
 
7
- def initialize(args, *options)
8
- @archetype_name = args[0]
9
- super
6
+ module Openehr
7
+ module Generators
8
+ class ArchetypedBase < ::Rails::Generators::Base
9
+ def initialize(args, *options)
10
+ if args[0].class == OpenEHR::AM::Archetype::Archetype
11
+ @archetype = args[0]
12
+ else
13
+ @adl_file = args[0]
10
14
  end
15
+ super
16
+ end
11
17
 
12
- def archetype
13
- @archetype ||= OpenEHR::Parser::ADLParser.new(archetype_file).parse
14
- end
18
+ protected
19
+ def archetype
20
+ @archetype ||= OpenEHR::Parser::ADLParser.new(@adl_file).parse
21
+ end
22
+
23
+ def archetype_path
24
+ 'app/archetypes'
25
+ end
15
26
 
16
- def archetype_path
17
- 'app/archetypes'
18
- end
27
+ def archetype_file
28
+ @adl_file
29
+ end
19
30
 
20
- def archetype_file
21
- @archetype_file ||= File.exist?(@archetype_name) ? @archetype_name : File.join(archetype_path, @archetype_name)
22
- end
31
+ def archetype_name
32
+ archetype.archetype_id.value
33
+ end
23
34
 
24
- def controller_name
25
- archetype.archetype_id.value.underscore
26
- end
35
+ def controller_name
36
+ archetype_name.underscore.tr '.', '_'
37
+ end
27
38
 
28
- def controller_file_path
29
- controller_name
30
- end
39
+ def controller_file_path
40
+ controller_name
41
+ end
31
42
 
32
- def model_name
33
- controller_name.tr ".", "_"
34
- end
43
+ def model_name
44
+ controller_name
45
+ end
35
46
 
36
- def concept
37
- archetype.concept
38
- end
47
+ def concept
48
+ archetype.concept
49
+ end
39
50
 
40
- def data_tree
41
- archetype.definition.attributes.each do |attribute|
42
- return attribute if attribute.rm_attribute_name == "data"
43
- end
51
+ def model_class_name
52
+ model_name.camelize
53
+ end
54
+
55
+ def controller_class_name
56
+ model_class_name + 'Controller'
57
+ end
58
+
59
+ def data_tree
60
+ archetype.definition.attributes.each do |attribute|
61
+ return attribute if attribute.rm_attribute_name == "data"
44
62
  end
63
+ end
45
64
 
46
- def index_data(tree = data_tree)
47
- data = []
48
- if tree.has_children?
49
- data = tree.children.inject([]) do |values, child|
50
- if child.respond_to? :attributes
51
- child.attributes.each do |attribute|
52
- if attribute.rm_attribute_name == 'value'
53
- values << child.node_id unless child.node_id.nil?
54
- end
55
- if attribute.has_children?
56
- values.concat index_data(attribute)
57
- end
65
+ def index_data(tree = data_tree)
66
+ data = []
67
+ if tree.has_children?
68
+ data = tree.children.inject([]) do |values, child|
69
+ if child.respond_to? :attributes
70
+ child.attributes.each do |attribute|
71
+ if attribute.rm_attribute_name == 'value'
72
+ values << child.node_id unless child.node_id.nil?
73
+ end
74
+ if attribute.has_children?
75
+ values.concat index_data(attribute)
58
76
  end
59
77
  end
60
- values
61
78
  end
79
+ values
62
80
  end
63
- data
64
81
  end
82
+ data
83
+ end
65
84
 
66
- def show_data(tree = archetype.definition)
67
- end
85
+ def show_data(tree = archetype.definition)
68
86
  end
69
87
  end
70
88
  end
@@ -1,5 +1,5 @@
1
1
  module OpenEHR
2
2
  module Rails
3
- VERSION = '0.0.2'
3
+ VERSION = '0.1.0'
4
4
  end
5
5
  end
data/lib/openehr-rails.rb CHANGED
@@ -1,4 +1,4 @@
1
- module OpenEHR
1
+ module Openehr
2
2
  module Rails
3
3
  class Railtie < ::Rails::Railtie
4
4
 
@@ -22,15 +22,11 @@ Gem::Specification.new do |gem|
22
22
  gem.require_paths = ["lib"]
23
23
  gem.add_dependency('openehr', '1.2.14')
24
24
  gem.add_dependency('rails', '~> 4.0.0')
25
+ gem.add_dependency('ckm_client')
25
26
 
26
27
  gem.add_development_dependency('rake')
27
28
  gem.add_development_dependency('ammeter')
28
29
  gem.add_development_dependency('rspec')
29
30
  gem.add_development_dependency('rspec-rails')
30
- gem.add_development_dependency('guard')
31
- gem.add_development_dependency('guard-rspec')
32
- gem.add_development_dependency('guard-spork')
33
31
  gem.add_development_dependency('simplecov')
34
- gem.add_development_dependency('listen', '0.6')
35
- gem.add_development_dependency('libnotify')
36
32
  end
@@ -0,0 +1,3 @@
1
+ def archetype
2
+ @archetype ||= OpenEHR::Parser::ADLParser.new('spec/generators/templates/openEHR-EHR-OBSERVATION.blood_pressure.v1.adl').parse
3
+ end