Skip to content
Browse files

Working on Visit show. ATP but need more tests for visit features.

  • Loading branch information...
1 parent fa052df commit 135cfc0b6646a89f7576e713fea56a9f88ae7165 @MikeBlyth committed Jan 19, 2013
View
9 app/helpers/visits_helper.rb
@@ -24,8 +24,13 @@ def diagnosis_check_boxes(dx_fields, dx_columns=4)
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('; ')
+ def show_diagnoses(visit)
+ diagnoses = (visit.diagnosis_labels << visit.dx << visit.dx2).join('; ')
+ return diagnoses.blank? ? nil : diagnoses + '.'
+ end
+
+ def show_symptoms(visit)
+ "--Symptom list--"
end
def phys_finding(afield, alabel=afield.capitalize)
View
5 app/models/diagnosis.rb
@@ -37,8 +37,9 @@ 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}"}
+ def self.dx_visit_tags
+ dx_visit_fields.map(&:to_tag).keep_if{|dx| Visit.column_names.include? dx}
+ # ToDO -- the "keep if" won't be necessary when Visit is changed to be able to handle arbitrary diagnoses
end
def <=>(other)
View
9 app/models/visit.rb
@@ -183,6 +183,15 @@ def to_label
date
end
+ def diagnoses
+ Visit.column_names.select{|col| col =~ /\Adx_/ && self.send(col)}.
+ map {|dx| Diagnosis.find_by_name(dx[3..-1])}.compact
+ end
+
+ def diagnosis_labels
+ diagnoses.map{|dx| dx.to_label}
+ end
+
# Default sort order will be on date
def <=>(x,y)
x.date <=> y.date
View
6 app/views/visits/_diagnoses.html.haml
@@ -1,3 +1,3 @@
-= "Diagnoses/Assessment: #{[@visit.dx, @visit.dx2].join(', ')}"
-= check_box_diagnoses(@visit)
-= (@visit.assessment + ".") unless @visit.assessment.blank?
+= "Diagnoses/Assessment: "
+= show_diagnoses(@visit)
+= " #{@visit.assessment}." unless @visit.assessment.blank?
View
18 app/views/visits/_form.html.haml
@@ -57,19 +57,7 @@
= text_area 'visit', 'phys_exam', {:rows => '1', :cols => '70' }
%fieldset
%legend Assessment and Diagnosis
- = form.input :dx_hiv, label: "HIV"
- = form.input :dx_pneumonia, label: "pneumonia"
- = form.input :dx_tb_pulm, label: "pulmonary TB"
- = form.input :dx_malaria, label: "malaria"
- = form.input :dx_uri, label: "uri"
- = form.input :dx_acute_ge, label: "acute_ge"
- = form.input :dx_otitis_media_acute, label: "otitis_media_acute"
- = form.input :dx_otitis_media_chronic, label: "otitis_media_chronic"
- = form.input :dx_thrush, label: "thrush"
- = form.input :dx_tinea_capitis, label: "tinea_capitis"
- = form.input :dx_scabies, label: "scabies"
- = form.input :dx_parotitis, label: "parotitis"
- = form.input :dx_dysentery, label: "dysentery"
+ = diagnosis_check_boxes(@dx_fields)
= form.input :dx, label: 'Other diagnoses'
= form.input :newdx, label: 'New diagnosis given?'
%br
@@ -78,10 +66,6 @@
= form.input :assessment_drug_toxicity, label: "Drug toxicity"
= form.input :assessment_nonadherence, label: "Nonadherence"
= form.input :assessment
-
- %fieldset
- %legend Dx2
- = diagnosis_check_boxes(@dx_fields)
%fieldset
%legend Other
= form.input :development
View
2 app/views/visits/_history.html.haml
@@ -0,0 +1,2 @@
+= @visit.hpi
+= show_symptoms(@visit)
View
3 app/views/visits/show.html.haml
@@ -4,3 +4,6 @@
%p= "Provider: #{@record.provider}"
%p#diagnoses
= render "diagnoses"
+%p#hpi
+ History
+ = render "history"
View
1 config/routes.rb
@@ -47,6 +47,7 @@
resources :visits do as_routes end
post '/visits/new', to: 'visits#create'
+ put '/visits/:id/edit', to: 'visits#update'
resources :patients do as_routes end

0 comments on commit 135cfc0

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