Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

in progress

  • Loading branch information...
commit a31f3403cc173d77f7d300541d57e87b391387ea 1 parent 09e3293
@MikeBlyth authored
View
4 app/controllers/visits_controller.rb
@@ -3,7 +3,7 @@ class VisitsController < ApplicationController
before_filter :authenticate_user!
active_scaffold :visit do |config|
- config.list.columns = :patient, :date,:weight, :dx, :dx2, :meds, :adm
+ config.list.columns = :patient, :date,:weight, :dx, :dx2, :meds, :adm, :symptoms
config.create.link.page = true
config.create.link.inline = false
end
@@ -43,7 +43,7 @@ def update
end
def set_diagnosis_fields
- @dx_fields = Diagnosis.dx_visit_fields.sort
+ @dx_fields = Diagnosis.visit_fields.sort
end
def make_growthchart
View
15 app/helpers/selectable_items_helper.rb
@@ -3,9 +3,9 @@ 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 Class name for table to use e.g., Symptom
- section= section_name.singularize.camelize.constantize
- fields = section.visit_fields
+ 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
+ fields = section.visit_fields #
return nil if fields.empty?
rows = ((fields.length + columns -1) / columns).to_i # how many rows
table_contents = ''.html_safe
@@ -41,14 +41,15 @@ def selections_to_string(record, section_name)
# {:headache=>'improving', :fever=>'high--night sweats', :cough => ''}
def selected(record, section_name)
merged = Hash.new {|h,k| h[k] = ''}
- comments, basic = record.send(section_name).partition {|x| x[0] =~ /_comment\Z/}
- basic.each do |b|
- merged[b[0]] = (b[1] == 'true') ? '' : b[1]
- end
+ stored_hash = record.send(section_name)
+ return {} if stored_hash.nil?
+ comments, basic =stored_hash.partition {|x| x[0] =~ /_comment\Z/}
+ basic.each { |b| merged[b[0]] = (b[1] == 'true') ? '' : b[1] }
comments.each do |comment|
source_key = comment[0][0..-9]
merged[source_key] = [merged[source_key], comment[1]].join ('--')
end
+ return merged
end
end
View
26 app/helpers/visits_helper.rb
@@ -46,29 +46,27 @@ def diagnosis_check_boxes(dx_fields, dx_columns=4)
# To DISPLAY the diagnoses selected for this visit
def show_diagnoses(visit)
- diagnoses = (visit.diagnosis_labels << visit.dx << visit.dx2).join('; ')
+ diagnoses = ([visit.dx, visit.dx2, selections_to_string(visit, :diagnoses)]).join('; ')
return diagnoses.blank? ? nil : diagnoses + '.'
end
def show_symptoms(visit)
- "--Symptom list--"
+ selections_to_string(visit, :symptoms)
end
- def phys_finding(afield, alabel=afield.capitalize)
-
- s = "<td><label for='visit_pe_#{afield}'>#{alabel}</label></td><td>" +
- check_box('visit', "pe_"+afield+"_ok") +
- text_field('visit', 'pe_'+afield, :size => 14) + "</td>"
- return s.html_safe
+ def show_exam(visit)
+ normal, noted = 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
end
- def phys_findings_column(items)
- s = "<td style='padding: 5px'><table>"
- for item in items
- s << '<tr>' + phys_finding(item) + '</tr>'
+ def all_both(n)
+ case n
+ when 0, 1 then nil
+ when 2 then 'both'
+ else 'all'
end
- s << '</table></td>'
- return s.html_safe
end
# Not in use #########
View
17 app/views/visits/_form.html.haml
@@ -27,21 +27,8 @@
%fieldset
%legend Signs and Symptoms
- = form.input :sx_wt_loss, label: "weight loss"
- = form.input :sx_diarrhea, label: "diarrhea"
- = form.input :sx_headache, label: "headache"
- = form.input :sx_fever, label: "fever"
- = form.input :sx_numbness, label: "numbness"
- = form.input :sx_ear_pain_disch, label: "ear pain, disch"
- = form.input :sx_nausea, label: "nausea"
- = form.input :sx_rash, label: "rash"
- = form.input :sx_vomiting, label: "vomiting"
- = form.input :sx_cough, label: "cough"
- = form.input :sx_night_sweats, label: "night sweats"
- = form.input :sx_visual_prob_new, label: "new visual prob"
- = form.input :sx_pain_swallowing, label: "pain swallowing"
- = form.input :sx_short_breath, label: "dyspnea"
- = form.input :sx_other, label: "Other"
+ *** SIGNS AND SYMPTOMS GO HERE ***
+
%fieldset
%legend History
= form.input :hpi, label: "History of present illness"
View
1  app/views/visits/_history.html.haml
@@ -1,2 +1,3 @@
= @visit.hpi
+Signs/symptoms:
= show_symptoms(@visit)
View
2  app/views/visits/_physical_exam.html.haml
@@ -0,0 +1,2 @@
+Physical exam:
+= show_exam(@visit)
View
5 app/views/visits/show.html.haml
@@ -5,5 +5,8 @@
%p#diagnoses
= render "diagnoses"
%p#hpi
- History
+ History:
= render "history"
+%p#exam
+ Exam:
+ = render "physical_exam"
View
5 db/migrate/20130120135959_rename_visit_exams_to_physicals.rb
@@ -0,0 +1,5 @@
+class RenameVisitExamsToPhysicals < ActiveRecord::Migration
+ def change
+ rename_column :visits, :exam, :physical
+ end
+end
View
8 db/structure.sql
@@ -944,7 +944,7 @@ CREATE TABLE visits (
updated_at timestamp without time zone,
arv_regimen character varying(255),
symptoms hstore,
- exam hstore,
+ physical hstore,
diagnoses hstore
);
@@ -1330,7 +1330,7 @@ CREATE INDEX visits_diagnoses ON visits USING gin (diagnoses);
-- Name: visits_exam; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
-CREATE INDEX visits_exam ON visits USING gin (exam);
+CREATE INDEX visits_exam ON visits USING gin (physical);
--
@@ -1458,4 +1458,6 @@ INSERT INTO schema_migrations (version) VALUES ('20130119171053');
INSERT INTO schema_migrations (version) VALUES ('20130119195813');
-INSERT INTO schema_migrations (version) VALUES ('20130119210742');
+INSERT INTO schema_migrations (version) VALUES ('20130119210742');
+
+INSERT INTO schema_migrations (version) VALUES ('20130120135959');
Please sign in to comment.
Something went wrong with that request. Please try again.