Permalink
Browse files

in progress

  • Loading branch information...
1 parent f4d6b48 commit 2b7d891b44c949c06d3fb8dda6b1fc6e14f7ca4e @MikeBlyth committed Jan 19, 2013
View
4 app/controllers/visits_controller.rb
@@ -43,9 +43,7 @@ def update
end
def set_diagnosis_fields
-#puts "set dx fields"
- @dx_fields = Diagnosis.where(:show_visits => true).order('name ASC')
- @dx_fields.each { |dx| dx.name = 'dx_' + dx.name } # prepend 'dx_' to each field name
+ @dx_fields = Diagnosis.dx_visit_prefixed_names.sort
end
def make_growthchart
View
13 app/helpers/visits_helper.rb
@@ -2,18 +2,18 @@
module VisitsHelper
def diagnosis_check_boxes(dx_fields, dx_columns=4)
- return nil if dx_fields.blank?
+ return nil if dx_fields.empty?
dx_columns = 4
- dx_rows = ((dx_fields.count + dx_columns -1) / dx_columns).to_i # how many rows
+ dx_rows = ((dx_fields.length + dx_columns -1) / dx_columns).to_i # how many rows
table_contents = ''.html_safe
0.upto(dx_rows-1) do |row|
row_contents = ''.html_safe
0.upto(dx_columns-1) do |column|
dx_i = column*dx_rows + row # which diagnosis to put here
dx_field = dx_fields[dx_i]
unless dx_i >= dx_fields.count
- box = check_box :visit, dx_field.name
- label = label_tag :visit, dx_field.name
+ box = check_box :visit, dx_field
+ label = label_tag :visit, dx_field
row_contents << content_tag(:td, box+label)
end
end
@@ -22,6 +22,11 @@ def diagnosis_check_boxes(dx_fields, dx_columns=4)
return content_tag(:table, table_contents)
end
+ # To DISPLAY the diagnoses selected for this visit
+ def check_box_diagnoses(visit)
+ diagnoses = Diagnosis.dx_visit_prefixed_names.select {|dx| visit.send(dx) }.join('; ')
+ end
+
def phys_finding(afield, alabel=afield.capitalize)
s = "<td><label for='visit_pe_#{afield}'>#{alabel}</label></td><td>" +
View
12 app/models/diagnosis.rb
@@ -16,4 +16,16 @@
class Diagnosis < ActiveRecord::Base
attr_protected
validates_presence_of :name
+
+ def self.dx_visit_fields
+ self.where(show_visits: true)
+ end
+
+ def self.dx_visit_names
+ dx_visit_fields.map(&:name)
+ end
+
+ def self.dx_visit_prefixed_names
+ dx_visit_fields.map {|dx| "dx_#{dx.name}"}
+ end
end
View
2 app/views/patients/_form.html.haml
@@ -1,4 +1,4 @@
-= simple_form_for(@patient, :html => {:class => 'form-horizontal' }) do |form|
+= simple_form_for(@patient, :html => {:class => 'vertical' }) do |form|
= form.error_notification
%h4 Basic information
.row-fluid
View
3 app/views/visits/_diagnoses.html.haml
@@ -0,0 +1,3 @@
+= "Diagnoses/Assessment: #{[@visit.dx, @visit.dx2].join(', ')}"
+= check_box_diagnoses(@visit)
+= (@visit.assessment +".") if @visit.assessment
View
6 app/views/visits/show.html.haml
@@ -0,0 +1,6 @@
+- @visit ||= @record
+- patient = @visit.patient
+%h2= "Visit for #{patient_name_link(patient)} on #{@visit.date}".html_safe
+%p= "Provider: #{@record.provider}"
+%p#diagnoses
+ = render "diagnoses"

0 comments on commit 2b7d891

Please sign in to comment.