Permalink
Browse files

Working on selected_items_helper, which works on informal testing. hs…

…tore now incorporated in models.
  • Loading branch information...
1 parent d10ef26 commit 2a9cc6c2446515bc5f44d9ae8465aa7df741d0c0 @MikeBlyth committed Jan 19, 2013
@@ -1,6 +1,6 @@
class DiagnosesController < ApplicationController
active_scaffold :diagnosis do |config|
- %w(name label comments show_visits sort_order synonyms).each do |col|
+ %w(name label comments show_visits sort_order synonyms with_comment).each do |col|
config.columns[col.to_sym].inplace_edit = true
end
end
@@ -1,5 +0,0 @@
-class HealthDataController < ApplicationController
-# Probably don't want to use a controller for this
- #active_scaffold :health_data do |conf|
- #end
-end
@@ -1,7 +1,7 @@
class PhysicalsController < ApplicationController
active_scaffold :physical do |config|
config.label = "Physical Exam Features"
- %w(name label comments show_visits sort_order synonyms).each do |col|
+ %w(name label comments show_visits sort_order synonyms with_comment).each do |col|
config.columns[col.to_sym].inplace_edit = true
end
end
@@ -1,6 +1,6 @@
class SymptomsController < ApplicationController
active_scaffold :symptom do |config|
- %w(name label comments show_visits sort_order synonyms).each do |col|
+ %w(name label comments show_visits sort_order synonyms with_comment).each do |col|
config.columns[col.to_sym].inplace_edit = true
end
@@ -0,0 +1,29 @@
+require 'pry'
+module SelectableItemsHelper
+
+ def check_boxes(record, section, columns=4) # section is Class name for table to use e.g., Symptom
+ section_name = section.to_s.underscore.pluralize
+ fields = section.visit_fields
+ return nil if fields.empty?
+ rows = ((fields.length + columns -1) / columns).to_i # how many rows
+ table_contents = ''.html_safe
+ 0.upto(rows-1) do |row|
+ row_contents = ''.html_safe
+ 0.upto(columns-1) do |column|
+ i = column*rows + row # which diagnosis to put here
+ field = fields[i]
+ unless i >= fields.count
+ #box = check_box :visit, field.to_tag
+ box = check_box_tag("visit[#{section_name}][#{field.name}]", 1, record.send(section_name)[field.name])
+ label = label_tag :visit, field.to_label
+ comment = field.with_comment ? text_field_tag("visit[#{section_name}][#{field.name}_comment]") : nil
+ row_contents << content_tag(:td, box+label+comment)
+ end
+ end
+ table_contents << content_tag(:tr, row_contents)
+ end
+ return content_tag(:table, table_contents)
+ end
+
+end
+
@@ -14,35 +14,7 @@
#
class Diagnosis < ActiveRecord::Base
- attr_protected
+ include SelectableItems
validates_presence_of :name
-
- def to_label
- label || name.gsub('_',' ')
- end
-
- def to_tag
- "dx_#{name.downcase}"
- end
-
- def to_s
- name
- end
-
- def self.dx_visit_fields
- self.where(show_visits: true)
- end
-
- def self.dx_visit_names
- dx_visit_fields.map(&:name)
- end
-
- 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)
- self.name <=> other.name
- end
+ attr_accessible :name, :label, :synonyms, :comments, :show_visits, :sort_order, :with_comment
end
@@ -1,46 +0,0 @@
-# == Schema Information
-#
-# Table name: health_data
-#
-# id :integer not null, primary key
-# patient_id :integer
-# created_at :datetime not null
-# updated_at :datetime not null
-#
-
-require 'rx_drug_list'
-
-class HealthData < ActiveRecord::Base
- belongs_to :patient
- attr_protected
-
- # Has HIV concern if own status is positive OR (mother's status is positive and own is not Negative)
- def hiv?
- return hiv_status == 'positive' ||
- (hiv_pos_mother && hiv_status != 'negative')
- end
-
- def hiv_pos
- return hiv_status == 'positive'
- end
-
- def hiv_pos_mother # see hiv_pos;
- return self.maternal_hiv_status == 'positive'
- end
-
- def current_drugs
- recent_drugs(6).current
- end
-
- def current_drugs_formatted
- current_drugs.formatted
- end
-
-private
-
- def recent_drugs(since=3)
- prescriptions = patient.prescriptions.confirmed.valid.where('date >= ?', Date.today-since.months)
- RxDrugList.new.add_prescriptions(prescriptions)
- end
-
-end
@@ -1,10 +1,21 @@
+# == Schema Information
+#
+# Table name: physicals
+#
+# id :integer not null, primary key
+# name :string(255)
+# label :string(255)
+# synonyms :string(255)
+# comments :string(255)
+# sort_order :integer
+# show_visits :boolean
+# created_at :datetime not null
+# updated_at :datetime not null
+#
+
class Physical < ActiveRecord::Base
include SelectableItems
validates_presence_of :name
- attr_accessible :name, :label, :synonyms, :comments, :show_visits, :sort_order
-
- def prefix
- 'pe_'
- end
+ attr_accessible :name, :label, :synonyms, :comments, :show_visits, :sort_order, :with_comment
end
@@ -10,16 +10,15 @@ def self.included(base)
module ClassMethods
def visit_fields
- self.where(show_visits: true).select{|f| Visit.column_names.include? f.to_tag}
+ self.where(show_visits: true)
end
def visit_names
visit_fields.map(&:name)
end
def visit_tags
- visit_fields.map(&:to_tag).keep_if{|f| Visit.column_names.include? f}
- # ToDO -- the "keep if" won't be necessary when Visit is changed to be able to handle arbitrary diagnoses
+ visit_fields.map(&:to_tag)
end
end
@@ -28,7 +27,7 @@ def to_label
end
def to_tag
- prefix+name.downcase # prefix must be defined in the class including this module
+ name.downcase # prefix must be defined in the class including this module
end
def to_s
View
@@ -1,10 +1,21 @@
+# == Schema Information
+#
+# Table name: symptoms
+#
+# id :integer not null, primary key
+# name :string(255)
+# label :string(255)
+# synonyms :string(255)
+# comments :string(255)
+# show_visits :boolean
+# sort_order :integer
+# created_at :datetime not null
+# updated_at :datetime not null
+#
+
require 'selectable_items'
class Symptom < ActiveRecord::Base
include SelectableItems
validates_presence_of :name
- attr_accessible :name, :label, :synonyms, :comments, :show_visits, :sort_order
-
- def prefix
- 'sx_'
- end
+ attr_accessible :name, :label, :synonyms, :comments, :show_visits, :sort_order, :with_comment
end
View
@@ -18,33 +18,6 @@
# adm :boolean
# sbp :integer
# dbp :integer
-# sx_wt_loss :boolean
-# sx_fever :boolean
-# sx_headache :boolean
-# sx_diarrhea :boolean
-# sx_numbness :boolean
-# sx_nausea :boolean
-# sx_rash :boolean
-# sx_vomiting :boolean
-# sx_cough :boolean
-# sx_night_sweats :boolean
-# sx_visual_prob_new :boolean
-# sx_pain_swallowing :boolean
-# sx_short_breath :boolean
-# sx_other :string(255)
-# dx_hiv :boolean
-# dx_tb_pulm :boolean
-# dx_pneumonia :boolean
-# dx_malaria :boolean
-# dx_uri :boolean
-# dx_acute_ge :boolean
-# dx_otitis_media_acute :boolean
-# dx_otitis_media_chronic :boolean
-# dx_thrush :boolean
-# dx_tinea_capitis :boolean
-# dx_scabies :boolean
-# dx_parotitis :boolean
-# dx_dysentery :boolean
# scheduled :boolean
# provider_id :integer
# hiv_stage :string(255)
@@ -65,7 +38,6 @@
# mid_arm_circ :float
# resp_rate :integer
# heart_rate :integer
-# sx_ear_pain_disch :boolean
# phys_exam :text
# diet_breast :boolean
# diet_breastmilk_substitute :boolean
@@ -77,43 +49,12 @@
# assessment_nonadherence :boolean
# arv_missed :integer
# arv_missed_week :integer
-# pe_scalp_ok :boolean
-# pe_scalp :string(255)
-# pe_conjunct_ok :boolean
-# pe_conjunct :string(255)
-# pe_eyes_ok :boolean
-# pe_eyes :string(255)
-# pe_ears_ok :boolean
-# pe_ears :string(255)
-# pe_mouth_ok :boolean
-# pe_mouth :string(255)
-# pe_nose_ok :boolean
-# pe_nose :string(255)
-# pe_chest_ok :boolean
-# pe_chest :string(255)
-# pe_heart_ok :boolean
-# pe_heart :string(255)
-# pe_abd_ok :boolean
-# pe_abd :string(255)
-# pe_liver_ok :boolean
-# pe_liver :string(255)
-# pe_spleen_ok :boolean
-# pe_spleen :string(255)
-# pe_skin_ok :boolean
-# pe_skin :string(255)
-# pe_lymph_ok :boolean
-# pe_lymph :string(255)
-# pe_extr_ok :boolean
-# pe_extr :string(255)
-# pe_neuro_ok :boolean
-# pe_neuro :string(255)
-# pe_genitalia_ok :boolean
-# pe_genitalia :string(255)
-# pe_tanner_ok :boolean
-# pe_tanner :string(255)
# created_at :datetime
# updated_at :datetime
# arv_regimen :string(255)
+# symptoms :hstore
+# exam :hstore
+# diagnoses :hstore
#
# ToDo Refactor to Vital signs, diagnoses, visit info (date, time, provider), etc.
@@ -0,0 +1,68 @@
+class RemoveDxSxPeFromVisits < ActiveRecord::Migration
+ def up
+ %w(sx_wt_loss
+sx_fever
+sx_headache
+sx_diarrhea
+sx_numbness
+sx_nausea
+sx_rash
+sx_vomiting
+sx_cough
+sx_night_sweats
+sx_visual_prob_new
+sx_pain_swallowing
+sx_short_breath
+sx_ear_pain_disch
+sx_other dx_hiv
+dx_tb_pulm
+dx_pneumonia
+dx_malaria
+dx_uri
+dx_acute_ge
+dx_otitis_media_acute
+dx_otitis_media_chronic
+dx_thrush
+dx_tinea_capitis
+dx_scabies
+dx_parotitis
+dx_dysentery pe_scalp_ok
+pe_scalp
+pe_conjunct_ok
+pe_conjunct
+pe_eyes_ok
+pe_eyes
+pe_ears_ok
+pe_ears
+pe_mouth_ok
+pe_mouth
+pe_nose_ok
+pe_nose
+pe_chest_ok
+pe_chest
+pe_heart_ok
+pe_heart
+pe_abd_ok
+pe_abd
+pe_liver_ok
+pe_liver
+pe_spleen_ok
+pe_spleen
+pe_skin_ok
+pe_skin
+pe_lymph_ok
+pe_lymph
+pe_extr_ok
+pe_extr
+pe_neuro_ok
+pe_neuro
+pe_genitalia_ok
+pe_genitalia
+pe_tanner_ok
+pe_tanner
+).each {|col| remove_column :visits, col}
+ end
+
+ def down
+ end
+end
@@ -0,0 +1,7 @@
+class AddWithCommentToSelectables < ActiveRecord::Migration
+ def change
+ add_column :symptoms, :with_comment, :boolean
+ add_column :diagnoses, :with_comment, :boolean
+ add_column :physicals, :with_comment, :boolean
+ end
+end
Oops, something went wrong.

0 comments on commit 2a9cc6c

Please sign in to comment.