Skip to content

Commit

Permalink
in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeBlyth committed Jan 19, 2013
1 parent f4d6b48 commit 2b7d891
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 8 deletions.
4 changes: 1 addition & 3 deletions app/controllers/visits_controller.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ def update
end end


def set_diagnosis_fields def set_diagnosis_fields
#puts "set dx fields" @dx_fields = Diagnosis.dx_visit_prefixed_names.sort
@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
end end


def make_growthchart def make_growthchart
Expand Down
13 changes: 9 additions & 4 deletions app/helpers/visits_helper.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
module VisitsHelper module VisitsHelper


def diagnosis_check_boxes(dx_fields, dx_columns=4) 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_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 table_contents = ''.html_safe
0.upto(dx_rows-1) do |row| 0.upto(dx_rows-1) do |row|
row_contents = ''.html_safe row_contents = ''.html_safe
0.upto(dx_columns-1) do |column| 0.upto(dx_columns-1) do |column|
dx_i = column*dx_rows + row # which diagnosis to put here dx_i = column*dx_rows + row # which diagnosis to put here
dx_field = dx_fields[dx_i] dx_field = dx_fields[dx_i]
unless dx_i >= dx_fields.count unless dx_i >= dx_fields.count
box = check_box :visit, dx_field.name box = check_box :visit, dx_field
label = label_tag :visit, dx_field.name label = label_tag :visit, dx_field
row_contents << content_tag(:td, box+label) row_contents << content_tag(:td, box+label)
end end
end end
Expand All @@ -22,6 +22,11 @@ def diagnosis_check_boxes(dx_fields, dx_columns=4)
return content_tag(:table, table_contents) return content_tag(:table, table_contents)
end 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) def phys_finding(afield, alabel=afield.capitalize)


s = "<td><label for='visit_pe_#{afield}'>#{alabel}</label></td><td>" + s = "<td><label for='visit_pe_#{afield}'>#{alabel}</label></td><td>" +
Expand Down
12 changes: 12 additions & 0 deletions app/models/diagnosis.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -16,4 +16,16 @@
class Diagnosis < ActiveRecord::Base class Diagnosis < ActiveRecord::Base
attr_protected attr_protected
validates_presence_of :name 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 end
2 changes: 1 addition & 1 deletion app/views/patients/_form.html.haml
Original file line number Original file line Diff line number Diff line change
@@ -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 = form.error_notification
%h4 Basic information %h4 Basic information
.row-fluid .row-fluid
Expand Down
3 changes: 3 additions & 0 deletions app/views/visits/_diagnoses.html.haml
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,3 @@
= "Diagnoses/Assessment: #{[@visit.dx, @visit.dx2].join(', ')}"
= check_box_diagnoses(@visit)
= (@visit.assessment +".") if @visit.assessment
6 changes: 6 additions & 0 deletions app/views/visits/show.html.haml
Original file line number Original file line Diff line number Diff line change
@@ -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.