Permalink
Browse files

in progress

  • Loading branch information...
1 parent 07ee81f commit da737edaf8671a4801f1b7fd2457a8fc8bd6c51d @MikeBlyth committed Jan 25, 2013
@@ -53,6 +53,44 @@ def twitter_box(id, name, label, checked)
SSIZE = SUFFIX.size
end
+
+ # Called from Patient#show via _visit_summary
+ def show_pe_findings(model)
+ columns = Visit.content_columns
+ pe_columns = []
+ # Get list of all the columns (variables) with form like 'pe_mouth', excluding the matching
+ # items, 'pe_mouth_ok' etc. This gives a list of the elements in the physical exam
+ for column in Visit.content_columns
+ if (column.name.slice(0,VSIZE) == VARBASE) && (column.name.slice(-3,3) != SUFFIX)
+ pe_columns << column.name.slice(VSIZE,column.name.size-VSIZE)
+ end
+ end
+ # First, generate list of all the items which have some text.
+ s = ''
+ for column in pe_columns
+ s << ' ' if s > ''
+ finding = model.send(VARBASE+column)
+ s << (column.capitalize) + ': ' + finding.to_s + '.' unless finding.blank?
+ end
+ s_findings = s
+ s_normal = ''
+ # Second, generate a list of items ticked as normal. This could be optional.
+ normal_count = 0
+ for column in pe_columns
+ if (model.send(VARBASE+column+SUFFIX) || 0) == 1 # append the name if ticked
+ s_normal << ', ' if s_normal > ''
+ s_normal << column
+ normal_count = normal_count + 1
+ end
+ end
+ if s_normal > ''
+ s_normal << ' all' if normal_count > 1 # just for style, to say 'mouth, eyes ... all normal'
+ s_normal << ' normal.'
+ end
+
+ return s_findings + ' ' + s_normal.capitalize
+ end
+
# ToDo - Needs work (and tests)
def show_val(value,
str_if_empty='____',
@@ -1,2 +1,10 @@
module ImmunizationsHelper
+
+ def imm_table(patient)
+ imms = patient.immunizations.includes(:immunization_type).order(:immunization_type_id, :date)
+ dates = imms.map{|i| i.date}.uniq.sort
+ imm_types = imms.map{|i| i.abbrev}.uniq
+
+ end
+
end
@@ -21,7 +21,7 @@ def check_boxes(record, section_name, columns=4) # section is attribute name fo
# **************************
name = "visit[#{section_name}][#{field.name}]"
id = "visit_#{section_name}_#{field.name}"
- checked = record.send(section_name)[field.name]
+ checked = record.send(section_name).try(:[], field.name)
box_with_label = twitter_box(id, name, field.name, checked)
# **************************
comment = field.with_comment ? text_field_tag("visit[#{section_name}][#{field.name}_comment]") : nil
@@ -8,6 +8,8 @@
# NB This model is not used yet and it's not clear how it should be organized!
class Immunization < ActiveRecord::Base
include DateValidators
+ delegate :abbrev, to: :immunization_type
+
attr_protected
belongs_to :patient
belongs_to :provider
@@ -45,7 +45,7 @@ class Patient < ActiveRecord::Base
has_many :lab_results
has_many :problems, dependent: :delete_all
has_many :admissions
- has_one :immunization, dependent: :delete
+ has_many :immunizations, dependent: :delete_all
has_many :prescriptions
has_many :prescription_items, through: :prescriptions
has_many :photos, dependent: :delete_all
@@ -0,0 +1 @@
+%h4 Immunization Summary
@@ -33,10 +33,12 @@
%fieldset
%legend Current medical info
.row-fluid
- = render(:partial => 'shared/medinfo', :object => @patient, as: :patient )
+ = render(:partial => 'shared/medinfo', object: @patient, as: :patient )
.row-fluid
- = render(:partial => 'shared/problem_list', :object => @patient )
+ = render(:partial => 'shared/problem_list', object: @patient )
%hr
+ .row-fluid
+ = render :partial => 'immunizations/summary', object: @patient, as: :patient
.row-fluid.footer_buttons
= link_to 'Edit patient', {:action => 'edit', :id => @patient}, :class => 'btn'
= link_to 'Patient list', patients_path, class: 'btn'
@@ -6,7 +6,7 @@
= show_val(visit.hpi,'suppress','visit_detail','HPI: ','.', 'v_det_lbl')
= show_val(visit.weight, 'suppress', 'visit_detail', 'Wt: ', ' kg.', 'v_det_lbl')
= show_val(visit.temperature, 'suppress', 'visit_detail', 'T: ', 'C.', 'v_det_lbl')
-= show_pe_findings(visit)
+= show_exam(visit)
= show_val(visit.development, 'suppress', 'visit_detail', 'Development: ', '.', 'v_det_lbl')
= show_val(concat_list([visit.dx, visit.dx2, visit.comments, visit.assessment]), |
'suppress', 'visit_detail', 'Dx: ','.', 'v_det_lbl') |

0 comments on commit da737ed

Please sign in to comment.