Skip to content

Commit

Permalink
Moving to the latest version of health-data-standards
Browse files Browse the repository at this point in the history
  • Loading branch information
eedrummer committed Aug 27, 2012
1 parent 3202e4c commit 0f59a0e
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 16 deletions.
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ source 'http://rubygems.org'


gem 'rails', '3.2.8'
# gem "health-data-standards", :git => "http://github.com/projectcypress/health-data-standards.git", :branch => "develop"
gem "health-data-standards", :git => "http://github.com/ssayer/health-data-standards.git", :branch => "develop"
gem "health-data-standards", :git => "http://github.com/projectcypress/health-data-standards.git", :branch => "develop"
gem 'ruby-openid', :git => 'https://github.com/rdingwell/ruby-openid.git',:branch => "master"
gem "mongoid"
gem "bson_ext"
Expand Down
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
GIT
remote: http://github.com/ssayer/health-data-standards.git
revision: 0d7bdd630b3c6730de2b06949554ad61d0607c7c
remote: http://github.com/projectcypress/health-data-standards.git
revision: 41354a3fb14530ded02f5a35fdefac2aec3fa665
branch: develop
specs:
health-data-standards (1.0.0)
health-data-standards (1.0.1)
builder (~> 3.0.0)
erubis (~> 2.6)
mongoid (~> 2.4.2)
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/entries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ def update
content_type = request.content_type
section_document = import_document(content_type)
@entry.update_attributes!(section_document.attributes)
@entry.reflect_on_all_associations(:embeds_many).each do |relation|
@entry.send(relation.name).destroy_all
@entry.send("#{relation.name}=", section_document.send(relation.name))
end

render text: 'Document updated', status: 200
end

Expand Down
6 changes: 3 additions & 3 deletions app/helpers/record_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def latest_matching_vital(record, name)
vitals = record.get_recent_vitals
record.vital_signs.each do |result|
if result.description.downcase.start_with?(name)
return show_value result.value
return show_value result.values.first
end
end
""
Expand All @@ -43,8 +43,8 @@ def most_recent_vital_date(record)
# Takes the value portion of a record and formats it
def show_value(value, low = -1E99, high = 1E99)
return "" unless value
s = value['scalar']
units = value['units']
s = value.scalar
units = value.units
if s.class == Fixnum || s.class == Float
n = s;
n = n.round(2) if n.class == Float
Expand Down
6 changes: 5 additions & 1 deletion test/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
description 'LDL Cholesterol'
time 1285387200
codes({'CPT' => ['83721'], 'LOINC' => ['2089-1']})
value({'scalar' => 127, 'units' => 'mg/dL'})
values {[FactoryGirl.build(:physical_quantity_result_value)]}
reference_range '70 mg/dL - 160 mg/dL'
end

Expand All @@ -32,6 +32,10 @@
version 0
end

factory :physical_quantity_result_value do |f|
f.scalar 127
f.units "mg/dL"
end


factory :user do |u|
Expand Down
4 changes: 2 additions & 2 deletions test/functional/entries_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class EntriesControllerTest < AtomTest
@record.reload
assert_equal 2, @record.results.count
result = @record.results[1]
assert_equal 135, result.value['scalar']
assert_equal 135, result.values.first.scalar
end

test "update a lab result" do
Expand All @@ -64,7 +64,7 @@ class EntriesControllerTest < AtomTest
put :update, {record_id: @record.medical_record_number, section: 'results', id: result.id}
assert_response :success
result.reload
assert_equal 135, result.value['scalar']
assert_equal 135, result.values.first.scalar
end

test "delete a result" do
Expand Down
11 changes: 6 additions & 5 deletions test/unit/helpers/record_helper_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'test_helper'
require 'ostruct'

class RecordHelperTest < ActionView::TestCase
test "section_enumerator" do
Expand Down Expand Up @@ -58,23 +59,23 @@ class RecordHelperTest < ActionView::TestCase

test "format a value" do
r = FactoryGirl.create(:lab_result)
assert_equal "<span class='lab_value'>127&nbsp;(mg/dL)</span>", show_value(r.value)
assert_equal "<span class='lab_value'>127&nbsp;(mg/dL)</span>", show_value(r.values.first)
end

test "format a value 2" do
assert_equal "<span class='lab_value'>127</span>", show_value({'scalar' => 127})
assert_equal "<span class='lab_value'>127</span>", show_value(OpenStruct.new('scalar' => 127))
end

test "format a value 3" do
assert_equal "<span class='lab_value'>127.12</span>", show_value({'scalar' => 127.12345})
assert_equal "<span class='lab_value'>127.12</span>", show_value(OpenStruct.new('scalar' => 127.12345))
end

test "format a value 4" do
assert_equal "<span class='lab_value'>127.12</span>", show_value({'scalar' => "127.12345"})
assert_equal "<span class='lab_value'>127.12</span>", show_value(OpenStruct.new('scalar' => "127.12345"))
end

test "format a value 5" do
assert_equal "", show_value({})
assert_equal "", show_value(OpenStruct.new())
end

end

0 comments on commit 0f59a0e

Please sign in to comment.