Skip to content

Commit

Permalink
controller
Browse files Browse the repository at this point in the history
  • Loading branch information
skoba committed Feb 9, 2015
1 parent f315a34 commit 2724d21
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 50 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Expand Up @@ -10,4 +10,8 @@ Lint/HandleExceptions:
Lint/ParenthesesAsGroupedExpression:
Enabled: true

Metrics/AbcSize:
Max: 15



2 changes: 1 addition & 1 deletion .travis.yml
@@ -1,7 +1,7 @@
language: ruby
cache: bundler
rvm:
- 2.1.3
- 2.1.5

addons:
postgresql: "9.3"
Expand Down
71 changes: 36 additions & 35 deletions Gemfile.lock
Expand Up @@ -36,12 +36,12 @@ GEM
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
addressable (2.3.6)
addressable (2.3.7)
arel (6.0.0)
ast (2.0.0)
astrolabe (1.3.0)
parser (>= 2.2.0.pre.3, < 3.0)
autoprefixer-rails (5.0.0.3)
autoprefixer-rails (5.1.3.1)
execjs
json
bootstrap-sass (3.3.3)
Expand All @@ -65,7 +65,7 @@ GEM
coffee-script (2.3.0)
coffee-script-source
execjs
coffee-script-source (1.8.0)
coffee-script-source (1.9.0)
database_cleaner (1.4.0)
diff-lcs (1.2.5)
draw_erd (0.2.0)
Expand All @@ -77,17 +77,17 @@ GEM
enumerize (0.9.0)
activesupport (>= 3.2)
erubis (2.7.0)
eventmachine (1.0.4)
execjs (2.2.2)
eventmachine (1.0.6)
execjs (2.3.0)
factory_girl (4.5.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.5.0)
factory_girl (~> 4.5.0)
railties (>= 3.0.0)
ffaker (1.31.0)
ffaker (1.32.1)
ffi (1.9.6)
formatador (0.2.5)
globalid (0.3.0)
globalid (0.3.2)
activesupport (>= 4.1.0)
guard (2.11.1)
formatador (>= 0.2.4)
Expand Down Expand Up @@ -152,18 +152,18 @@ GEM
nenv (0.2.0)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
notiffany (0.0.3)
notiffany (0.0.4)
nenv (~> 0.1)
shellany (~> 0.0)
parser (2.2.0.2)
ast (>= 1.1, < 3.0)
pg (0.18.1)
poltergeist (1.5.1)
poltergeist (1.6.0)
capybara (~> 2.1)
cliver (~> 0.3.1)
multi_json (~> 1.0)
websocket-driver (>= 0.2.0)
powerpack (0.0.9)
powerpack (0.1.0)
pry (0.10.1)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
Expand Down Expand Up @@ -201,7 +201,7 @@ GEM
rails_serve_static_assets
rails_stdout_logging
rails_layout (1.0.24)
rails_serve_static_assets (0.0.3)
rails_serve_static_assets (0.0.4)
rails_stdout_logging (0.0.3)
railties (4.2.0)
actionpack (= 4.2.0)
Expand All @@ -218,37 +218,38 @@ GEM
ffi (>= 0.5.0)
rdoc (4.2.0)
json (~> 1.4)
rspec (3.1.0)
rspec-core (~> 3.1.0)
rspec-expectations (~> 3.1.0)
rspec-mocks (~> 3.1.0)
rspec (3.2.0)
rspec-core (~> 3.2.0)
rspec-expectations (~> 3.2.0)
rspec-mocks (~> 3.2.0)
rspec-collection_matchers (1.1.2)
rspec-expectations (>= 2.99.0.beta1)
rspec-core (3.1.7)
rspec-support (~> 3.1.0)
rspec-expectations (3.1.2)
rspec-core (3.2.0)
rspec-support (~> 3.2.0)
rspec-expectations (3.2.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.1.0)
rspec-mocks (3.1.3)
rspec-support (~> 3.1.0)
rspec-rails (3.1.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 3.1.0)
rspec-expectations (~> 3.1.0)
rspec-mocks (~> 3.1.0)
rspec-support (~> 3.1.0)
rspec-support (3.1.2)
rubocop (0.28.0)
rspec-support (~> 3.2.0)
rspec-mocks (3.2.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.2.0)
rspec-rails (3.2.0)
actionpack (>= 3.0, <= 4.2)
activesupport (>= 3.0, <= 4.2)
railties (>= 3.0, <= 4.2)
rspec-core (~> 3.2.0)
rspec-expectations (~> 3.2.0)
rspec-mocks (~> 3.2.0)
rspec-support (~> 3.2.0)
rspec-support (3.2.1)
rubocop (0.29.0)
astrolabe (~> 1.3)
parser (>= 2.2.0.pre.7, < 3.0)
powerpack (~> 0.0.6)
parser (>= 2.2.0.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.4)
ruby-graphviz (1.0.9)
ruby-progressbar (1.7.1)
sass (3.4.10)
sass (3.4.11)
sass-rails (5.0.1)
railties (>= 4.0.0, < 5.0)
sass (~> 3.1)
Expand All @@ -259,7 +260,7 @@ GEM
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
shellany (0.0.1)
shoulda-matchers (2.7.0)
shoulda-matchers (2.8.0)
activesupport (>= 3.0.0)
slop (3.6.0)
spring (1.2.0)
Expand Down
29 changes: 15 additions & 14 deletions app/models/mml_patient.rb
Expand Up @@ -53,24 +53,13 @@ def given_name=(given_name)

def name
party_identities.where(name: 'person name').map do |identity|
family_name = identity.identity_details.find_by(name: 'family name').exists? ? identity.identity_details.find_by(name: 'family name').value : nil
given_name = identity.identity_details.find_by(name: 'given name').exists? ? identity.identity_details.find_by(name: 'given name').value : nil
full_name = identity.identity_details.find_by(name: 'full name').exists? ? identity.identity_details.find_by(name: 'full name').value : nil
family_name = family_name(identity)
given_name = given_name('given name')
full_name = find_name_by_type('full name')
MML::Name.new(family_name: family_name, given_name: given_name, full_name: full_name)
end
end

# def person_name
# self.party_identities.where(name: 'person name').map do |party_identity|
# MML::Name.new(repCode: 'A',
# fullname: party_identity.identity_details.find_by(name: 'full name').value,
# family: party_identity.identity_details.find_by(name: 'family name').value,
# given: party_identity.identity_details.find_by(name: 'given name').value,
# middle: party_identity.identity_details.find_by(name: 'middle name').value,
# prefix: party_identity.identity_details.find_by(name: 'title').value)
# end
# end

def details_general
@details_general ||= party_details.build(name: 'general')
end
Expand Down Expand Up @@ -138,6 +127,18 @@ def phones=(phones)
end
end

def family_name(identity)
find_name_by_type(identity, 'family name')
end

def find_name_by_type(identity, type)
confirm_name_by_type(type).exist? ? confirm_name_by_type(type).value : nil
end

def confirm_namename_by_type(type)
identity.identity_details.find_by(name: type).exist?
end

def to_mml
MML::Patient.info.new(masterId: masterId, birthday: birthday, sex: sex, nationality: nationality, marital: marital)
end
Expand Down

0 comments on commit 2724d21

Please sign in to comment.