Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adjusted Visit form to use new hstore-based methods. Working but not …

…tested.
  • Loading branch information...
commit 4ebd9eb25b3fd3c74dc5ccb205cdb27fc55391e2 1 parent a31f340
@MikeBlyth authored
View
6 app/helpers/selectable_items_helper.rb
@@ -4,7 +4,7 @@ module SelectableItemsHelper
# Set up HTML table containing checkboxes supplied by SectionName.visit_fields, and pre-checked
# according to their status in record.
def check_boxes(record, section_name, columns=4) # section is attribute name for table to use e.g., symptoms
- section= section_name.singularize.camelize.constantize # e.g. Symptom
+ section= section_name.to_s.singularize.camelize.constantize # e.g. Symptom
fields = section.visit_fields #
return nil if fields.empty?
rows = ((fields.length + columns -1) / columns).to_i # how many rows
@@ -28,7 +28,7 @@ def check_boxes(record, section_name, columns=4) # section is attribute name fo
end
def selections_to_string(record, section_name)
- merged = selected(record, section_name)
+ merged = selectable_selected(record, section_name)
merged.map do |k,v|
v = v.blank? ? nil : v
[k,v].compact.join(': ')
@@ -39,7 +39,7 @@ def selections_to_string(record, section_name)
# {:headache=>'true', :fever=>'high', :cough => 'true', :headache_comment => 'improving', :fever_comment=>'night sweats'}
# return a hash like
# {:headache=>'improving', :fever=>'high--night sweats', :cough => ''}
- def selected(record, section_name)
+ def selectable_selected(record, section_name)
merged = Hash.new {|h,k| h[k] = ''}
stored_hash = record.send(section_name)
return {} if stored_hash.nil?
View
24 app/helpers/visits_helper.rb
@@ -22,28 +22,6 @@ def section_check_boxes(section, columns=4) # section is Class name for table t
return content_tag(:table, table_contents)
end
- def diagnosis_check_boxes(dx_fields, dx_columns=4)
- dx_fields.try(:keep_if) {|dx| Visit.column_names.include? dx.to_tag} # ToDo ... this won't be needed when we change the way diagnoses are stored ... not in individual columns
- return nil if dx_fields.empty?
- dx_columns = 4
- 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_#{dx_field.name.downcase}"
- label = label_tag :visit, dx_field.to_label
- row_contents << content_tag(:td, box+label)
- end
- end
- table_contents << content_tag(:tr, row_contents)
- end
- return content_tag(:table, table_contents)
- end
-
# To DISPLAY the diagnoses selected for this visit
def show_diagnoses(visit)
diagnoses = ([visit.dx, visit.dx2, selections_to_string(visit, :diagnoses)]).join('; ')
@@ -55,7 +33,7 @@ def show_symptoms(visit)
end
def show_exam(visit)
- normal, noted = selected(visit, :physical).partition {|x| ['', 'normal'].include? x[1]}
+ normal, noted = selectable_selected(visit, :physical).partition {|x| ['', 'normal'].include? x[1]}
noted_str = noted.any? ? noted.map{|x| "#{x[0]}: #{x[1]}"}.join('; ') + '. ' : ''
normal_str = normal.any? ? [normal.map {|x| x[0]}.join(', '), all_both(normal.size), 'normal.'].join(' ') : ''
return noted_str + normal_str.capitalize
View
10 app/views/visits/_form.html.haml
@@ -27,7 +27,7 @@
%fieldset
%legend Signs and Symptoms
- *** SIGNS AND SYMPTOMS GO HERE ***
+ = check_boxes(@visit, :symptoms)
%fieldset
%legend History
@@ -35,16 +35,12 @@
%fieldset
%legend Physical Exam
%p.form_instruction Tick box if this part of exam is normal.
- %table
- %tr{:valign => "top"}
- = phys_findings_column(%w(scalp conjunct eyes ears mouth nose))
- = phys_findings_column(%w(chest heart abd liver spleen))
- = phys_findings_column(%w(skin lymph extr neuro genitalia tanner))
+ = check_boxes(@visit, :physical)
%br
= text_area 'visit', 'phys_exam', {:rows => '1', :cols => '70' }
%fieldset
%legend Assessment and Diagnosis
- = diagnosis_check_boxes(@dx_fields)
+ = check_boxes(@visit, :diagnoses)
= form.input :dx, label: 'Other diagnoses'
= form.input :newdx, label: 'New diagnosis given?'
%br
Please sign in to comment.
Something went wrong with that request. Please try again.