Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

in progress

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

0 comments on commit 2b7d891

Please sign in to comment.
Something went wrong with that request. Please try again.