openehr-rails 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +46 -0
- data/.rspec +1 -0
- data/.travis.yml +4 -0
- data/Gemfile +3 -0
- data/Guardfile +15 -0
- data/README.rdoc +21 -0
- data/Rakefile +33 -0
- data/db/seeds.rb +7 -0
- data/doc/README_FOR_APP +2 -0
- data/lib/assets/.gitkeep +0 -0
- data/lib/generators/openehr/controller/controller_generator.rb +16 -0
- data/lib/generators/openehr/controller/templates/controller.rb +13 -0
- data/lib/generators/openehr/i18n/i18n_generator.rb +53 -0
- data/lib/generators/openehr/i18n/templates/i18n.rb +6 -0
- data/lib/generators/openehr/i18n/templates/language.yml +10 -0
- data/lib/generators/openehr/install/install_generator.rb +18 -0
- data/lib/generators/openehr/install/templates/i18n.rb +8 -0
- data/lib/generators/openehr/migration/migration_generator.rb +17 -0
- data/lib/generators/openehr/model/model_generator.rb +16 -0
- data/lib/generators/openehr/scaffold/scaffold_generator.rb +149 -0
- data/lib/generators/openehr/scaffold/templates/_form.html.erb +19 -0
- data/lib/generators/openehr/scaffold/templates/application_controller.rb +2 -0
- data/lib/generators/openehr/scaffold/templates/edit.html.erb +6 -0
- data/lib/generators/openehr/scaffold/templates/index.html.erb +28 -0
- data/lib/generators/openehr/scaffold/templates/new.html.erb +0 -0
- data/lib/generators/openehr/scaffold/templates/route.rb +2 -0
- data/lib/generators/openehr/scaffold/templates/routes.rb +2 -0
- data/lib/generators/openehr/scaffold/templates/show.html.erb +6 -0
- data/lib/generators/openehr.rb +71 -0
- data/lib/openehr/rails.rb +1 -0
- data/lib/openehr-rails/version.rb +5 -0
- data/lib/openehr-rails.rb +7 -0
- data/lib/rcomponents.rb +48 -0
- data/openehr-rails.gemspec +36 -0
- data/spec/generators/openehr/archetyped_base_spec.rb +47 -0
- data/spec/generators/openehr/controller/controller_generator_spec.rb +9 -0
- data/spec/generators/openehr/i18n/i18n_generator_spec.rb +62 -0
- data/spec/generators/openehr/install/install_generator_spec.rb +15 -0
- data/spec/generators/openehr/migration/migration_generator_spec.rb +16 -0
- data/spec/generators/openehr/scaffold/scaffold_generator_spec.rb +70 -0
- data/spec/generators/templates/openEHR-EHR-OBSERVATION.blood_pressure.v1.adl +1021 -0
- data/spec/rcomponents/relement_spec.rb +21 -0
- data/spec/rcomponents/robservation_spec.rb +21 -0
- data/spec/spec_helper.rb +18 -0
- metadata +257 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: eb28457735ac8ff463f890b40d259fda64eb01c1
|
4
|
+
data.tar.gz: bf1d603f93bbbcefa970f17ad275dbd530ef258a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3a3af84044fe580253e9be69960443644ab62f4f7f9bedb10ed8d2ab1052c2489d287f7454de331e92664a2e6deb18a4ed063f13b2cdfd6e2b59dd159382f84c
|
7
|
+
data.tar.gz: 801e8187ca7351a868e4a25aa213b932350d2b0880a8e464b808aded1fd9a871aebafd386231f65b99910acdf9cd8ec4ade8674fd57268f19096f2165fb7a891
|
data/.gitignore
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
/.bundle
|
2
|
+
|
3
|
+
/app
|
4
|
+
/config
|
5
|
+
/public
|
6
|
+
/vendor
|
7
|
+
/plugin
|
8
|
+
/db
|
9
|
+
/bin
|
10
|
+
|
11
|
+
# For emacs:
|
12
|
+
*~
|
13
|
+
\#*
|
14
|
+
.\#*
|
15
|
+
|
16
|
+
# sinplecov generate file
|
17
|
+
coverage.data
|
18
|
+
coverage
|
19
|
+
|
20
|
+
pkg
|
21
|
+
|
22
|
+
# Ignore all logfiles and tempfiles.
|
23
|
+
/log/*.log
|
24
|
+
/tmp
|
25
|
+
|
26
|
+
#bundler
|
27
|
+
.bundle
|
28
|
+
*.lock
|
29
|
+
|
30
|
+
#
|
31
|
+
# For MacOS:
|
32
|
+
#
|
33
|
+
.DS_Store
|
34
|
+
|
35
|
+
# For TextMate
|
36
|
+
#*.tmproj
|
37
|
+
#tmtags
|
38
|
+
|
39
|
+
# For vim:
|
40
|
+
#*.swp
|
41
|
+
|
42
|
+
# For redcar:
|
43
|
+
#.redcar
|
44
|
+
|
45
|
+
# For rubinius:
|
46
|
+
#*.rbc
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard 'rspec' do
|
5
|
+
watch(%r{^spec/.+_spec\.rb$})
|
6
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
|
+
watch('spec/spec_helper.rb') { "spec" }
|
8
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
9
|
+
end
|
10
|
+
|
11
|
+
guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do
|
12
|
+
watch('Gemfile.lock')
|
13
|
+
watch('spec/spec_helper.rb') { :rspec }
|
14
|
+
watch(%r{features/support/}) { :cucumber }
|
15
|
+
end
|
data/README.rdoc
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
== Synopsys
|
2
|
+
|
3
|
+
This is a support library for openEHR on Rails implementation and
|
4
|
+
still working exeperimental codes.
|
5
|
+
|
6
|
+
== License
|
7
|
+
This product is under Apache 2.0 license
|
8
|
+
|
9
|
+
Copyright [2012] Shinji Kobayashi, openEHR.jp
|
10
|
+
|
11
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
12
|
+
you may not use this file except in compliance with the License.
|
13
|
+
You may obtain a copy of the License at
|
14
|
+
|
15
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
16
|
+
|
17
|
+
Unless required by applicable law or agreed to in writing, software
|
18
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
19
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
20
|
+
See the License for the specific language governing permissions and
|
21
|
+
limitations under the License.
|
data/Rakefile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# encoding: utf-8
|
3
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
4
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require 'bundler'
|
8
|
+
require "bundler/gem_tasks"
|
9
|
+
require 'rake'
|
10
|
+
|
11
|
+
require 'rspec/core'
|
12
|
+
require 'rspec/core/rake_task'
|
13
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
14
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
15
|
+
end
|
16
|
+
|
17
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
18
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
19
|
+
spec.rcov = true
|
20
|
+
end
|
21
|
+
|
22
|
+
task :default => :spec
|
23
|
+
|
24
|
+
require 'rdoc/task'
|
25
|
+
Rake::RDocTask.new do |rdoc|
|
26
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
27
|
+
|
28
|
+
rdoc.rdoc_dir = 'rdoc'
|
29
|
+
rdoc.title = "openehr-rails #{version}"
|
30
|
+
rdoc.rdoc_files.include('README*')
|
31
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
32
|
+
end
|
33
|
+
|
data/db/seeds.rb
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# This file should contain all the record creation needed to seed the database with its default values.
|
2
|
+
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
3
|
+
#
|
4
|
+
# Examples:
|
5
|
+
#
|
6
|
+
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
|
7
|
+
# Mayor.create(name: 'Emanuel', city: cities.first)
|
data/doc/README_FOR_APP
ADDED
data/lib/assets/.gitkeep
ADDED
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module OpenEHR
|
2
|
+
module Rails
|
3
|
+
module Generators
|
4
|
+
class ControllerGenerator < ::Rails::Generators::NamedBase
|
5
|
+
argument :actions, :type => :array, :default => [], :bannar => 'action action'
|
6
|
+
desc <<DESC
|
7
|
+
generate controler from template and archetype
|
8
|
+
DESC
|
9
|
+
|
10
|
+
def create_controller
|
11
|
+
template 'controller.rb', File.join('app/controllers', class_path, "#{file_name}_controller.rb")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<% if namespaced? -%>
|
2
|
+
require_dependency "<%= namespaced_file_path %>/application_controller"
|
3
|
+
|
4
|
+
<% end -%>
|
5
|
+
<% module_namespacing do -%>
|
6
|
+
class <%= class_name %>Controller < ApplicationController
|
7
|
+
<% actions.each do |action| -%>
|
8
|
+
def <%= action %>
|
9
|
+
end
|
10
|
+
<%= "\n" unless action == actions.last -%>
|
11
|
+
<% end -%>
|
12
|
+
end
|
13
|
+
<% end -%>
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'openehr/rm'
|
3
|
+
require 'openehr/am'
|
4
|
+
require 'openehr/parser'
|
5
|
+
require 'locale/info'
|
6
|
+
require 'generators/openehr'
|
7
|
+
|
8
|
+
module OpenEHR
|
9
|
+
module Rails
|
10
|
+
module Generators
|
11
|
+
class I18nGenerator < ArchetypedBase
|
12
|
+
source_root File.expand_path '../templates', __FILE__
|
13
|
+
|
14
|
+
def create_i18n_file
|
15
|
+
@original_language = original_language
|
16
|
+
@translations = translations
|
17
|
+
template 'i18n.rb', 'config/initializers/i18n.rb'
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_yaml_files
|
21
|
+
@controller_path = archetype.archetype_id.value.underscore
|
22
|
+
archetype.ontology.term_definitions.each do |code, terms|
|
23
|
+
@language_code = code
|
24
|
+
@terms = terms.map do |atcode, term|
|
25
|
+
{atcode: atcode, item: term.items['text']}
|
26
|
+
end
|
27
|
+
template 'language.yml', "config/locales/#{@language_code}.yml"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
def original_language
|
33
|
+
{ code: original_language_code,
|
34
|
+
text: language_name(original_language_code) }
|
35
|
+
end
|
36
|
+
|
37
|
+
def original_language_code
|
38
|
+
archetype.original_language.code_string
|
39
|
+
end
|
40
|
+
|
41
|
+
def translations
|
42
|
+
archetype.translations.each_key.map do |code|
|
43
|
+
{ code: code, text: language_name(code) }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def language_name(code)
|
48
|
+
Locale::Info.get_language(code).name
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module OpenEHR
|
2
|
+
module Rails
|
3
|
+
module Generators
|
4
|
+
class InstallGenerator < ::Rails::Generators::Base
|
5
|
+
|
6
|
+
desc <<DESC
|
7
|
+
Description:
|
8
|
+
setup openEHR environment with archetype directory.
|
9
|
+
DESC
|
10
|
+
|
11
|
+
def create_archetype_directory
|
12
|
+
empty_directory 'app/archetypes'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'generators/openehr'
|
2
|
+
require 'rails/generators/active_record'
|
3
|
+
|
4
|
+
module OpenEHR
|
5
|
+
module Rails
|
6
|
+
module Generators
|
7
|
+
class MigrationGenerator < ::ActiveRecord::Generators::Base
|
8
|
+
argument :attributes
|
9
|
+
source_root File.expand_path("./templates", __FILE__)
|
10
|
+
|
11
|
+
def copy_archetype_migration
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
require 'openehr/rm'
|
2
|
+
require 'openehr/am'
|
3
|
+
require 'openehr/parser'
|
4
|
+
require 'generators/openehr'
|
5
|
+
|
6
|
+
module OpenEHR
|
7
|
+
module Rails
|
8
|
+
module Generators
|
9
|
+
class ScaffoldGenerator < ArchetypedBase
|
10
|
+
source_root File.expand_path("../templates", __FILE__)
|
11
|
+
|
12
|
+
def create_root_folder
|
13
|
+
empty_directory File.join("app/views", controller_file_path)
|
14
|
+
end
|
15
|
+
|
16
|
+
def generate_index
|
17
|
+
generate_view "index.html.erb"
|
18
|
+
end
|
19
|
+
|
20
|
+
def generate_show
|
21
|
+
generate_view "show.html.erb"
|
22
|
+
end
|
23
|
+
|
24
|
+
def generate_edit
|
25
|
+
generate_view "edit.html.erb"
|
26
|
+
end
|
27
|
+
|
28
|
+
def generate_form
|
29
|
+
generate_view "_form.html.erb"
|
30
|
+
end
|
31
|
+
|
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
|
41
|
+
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"
|
47
|
+
before_action :set_locale
|
48
|
+
|
49
|
+
def set_locale
|
50
|
+
I18n.locale = params[:locale] || I18n.default_locale
|
51
|
+
end
|
52
|
+
LOCALE
|
53
|
+
end
|
54
|
+
|
55
|
+
protected
|
56
|
+
|
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
|
76
|
+
|
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"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
return html
|
89
|
+
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"
|
95
|
+
end
|
96
|
+
|
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
|
108
|
+
|
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
|
119
|
+
end
|
120
|
+
html
|
121
|
+
end
|
122
|
+
|
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
|
129
|
+
end
|
130
|
+
html
|
131
|
+
end
|
132
|
+
|
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
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<%%= form_for(@<%= model_name %>) do |f| %>
|
2
|
+
<%% if @<%= model_name %>.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%%= pluralize(@<%= model_name %>.errors.count, "error") %> prohibited this <%= model_name %> from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<%% @<%= model_name %>.errors.full_messages.each do |msg| %>
|
8
|
+
<li><%%= msg %></li>
|
9
|
+
<%% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<%% end %>
|
13
|
+
|
14
|
+
<%= form_format(archetype.definition) %>
|
15
|
+
|
16
|
+
<div class="actions">
|
17
|
+
<%%= f.submit %>
|
18
|
+
</div>
|
19
|
+
<%% end %>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<h1>Listing <%%= t(".<%= concept %>") %></h1>
|
2
|
+
|
3
|
+
<table>
|
4
|
+
<thead>
|
5
|
+
<tr>
|
6
|
+
<% index_data.each do |atcode| -%>
|
7
|
+
<th><%%= t(".<%= atcode %>") %></th>
|
8
|
+
<% end -%>
|
9
|
+
</tr>
|
10
|
+
</thead>
|
11
|
+
<tbody>
|
12
|
+
<%% @<%= model_name %>.each do |<%= model_name %>| %>
|
13
|
+
<tr>
|
14
|
+
<% index_data.each do |atcode| -%>
|
15
|
+
<td><%%= <%= model_name %>.<%= atcode %> %></td>
|
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>
|
20
|
+
</tr>
|
21
|
+
<%% end %>
|
22
|
+
|
23
|
+
</tbody>
|
24
|
+
</table>
|
25
|
+
|
26
|
+
<br>
|
27
|
+
|
28
|
+
<%%= link_to <%%= t(".<%= concept %>") %>, new_<%= model_name %>_path %>
|
File without changes
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module OpenEHR
|
2
|
+
module Rails
|
3
|
+
module Generators
|
4
|
+
class ArchetypedBase < ::Rails::Generators::Base
|
5
|
+
argument :archetype_name
|
6
|
+
|
7
|
+
def initialize(args, *options)
|
8
|
+
@archetype_name = args[0]
|
9
|
+
super
|
10
|
+
end
|
11
|
+
|
12
|
+
def archetype
|
13
|
+
@archetype ||= OpenEHR::Parser::ADLParser.new(archetype_file).parse
|
14
|
+
end
|
15
|
+
|
16
|
+
def archetype_path
|
17
|
+
'app/archetypes'
|
18
|
+
end
|
19
|
+
|
20
|
+
def archetype_file
|
21
|
+
@archetype_file ||= File.exist?(@archetype_name) ? @archetype_name : File.join(archetype_path, @archetype_name)
|
22
|
+
end
|
23
|
+
|
24
|
+
def controller_name
|
25
|
+
archetype.archetype_id.value.underscore
|
26
|
+
end
|
27
|
+
|
28
|
+
def controller_file_path
|
29
|
+
controller_name
|
30
|
+
end
|
31
|
+
|
32
|
+
def model_name
|
33
|
+
controller_name.tr ".", "_"
|
34
|
+
end
|
35
|
+
|
36
|
+
def concept
|
37
|
+
archetype.concept
|
38
|
+
end
|
39
|
+
|
40
|
+
def data_tree
|
41
|
+
archetype.definition.attributes.each do |attribute|
|
42
|
+
return attribute if attribute.rm_attribute_name == "data"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
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
|
58
|
+
end
|
59
|
+
end
|
60
|
+
values
|
61
|
+
end
|
62
|
+
end
|
63
|
+
data
|
64
|
+
end
|
65
|
+
|
66
|
+
def show_data(tree = archetype.definition)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'openehr'
|