Permalink
Browse files

Working on visit and diagnoses. ATP (no new tests still).

  • Loading branch information...
1 parent 2b7d891 commit fa052df669d9fe5703921ed3b765dd21c9bc366f @MikeBlyth committed Jan 19, 2013
@@ -1,4 +1,7 @@
class DiagnosesController < ApplicationController
- active_scaffold :diagnosis do |conf|
+ active_scaffold :diagnosis do |config|
+ %w(name label comments show_visits sort_order synonyms).each do |col|
+ config.columns[col.to_sym].inplace_edit = true
+ end
end
end
@@ -43,7 +43,7 @@ def update
end
def set_diagnosis_fields
- @dx_fields = Diagnosis.dx_visit_prefixed_names.sort
+ @dx_fields = Diagnosis.dx_visit_fields.sort
end
def make_growthchart
@@ -2,6 +2,7 @@
module VisitsHelper
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
@@ -12,8 +13,8 @@ def diagnosis_check_boxes(dx_fields, dx_columns=4)
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_field
- label = label_tag :visit, dx_field
+ 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
View
@@ -17,6 +17,18 @@ class Diagnosis < ActiveRecord::Base
attr_protected
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
@@ -28,4 +40,8 @@ def self.dx_visit_names
def self.dx_visit_prefixed_names
dx_visit_fields.map {|dx| "dx_#{dx.name}"}
end
+
+ def <=>(other)
+ self.name <=> other.name
+ end
end
@@ -11,6 +11,12 @@
.container-fluid
.row-fluid
.span2
+ = link_to 'Visits', visits_path
+ %br
+ = link_to 'Diagnoses', diagnoses_path
+ %br
+ = link_to 'Lab services', lab_services_path
+ %br
= render(:partial => '/shared/patient_menu', :object => @patient)
%br
= link_to 'Sign out', destroy_user_session_path, :method=> :delete
@@ -1,3 +1,3 @@
= "Diagnoses/Assessment: #{[@visit.dx, @visit.dx2].join(', ')}"
= check_box_diagnoses(@visit)
-= (@visit.assessment +".") if @visit.assessment
+= (@visit.assessment + ".") unless @visit.assessment.blank?
View
@@ -17,8 +17,8 @@
Admission.create(patient: audu, date: audu.birth_date+12.months, diagnosis_1: 'malaria', meds: 'ampicillin')
Diagnosis.delete_all
-Diagnosis.create(name: 'pneumonia')
-Diagnosis.create(name: 'malaria')
+%w(pneumonia malaria HIV pulmonary_tb uri acute_ge otitis_media_acute otitis_media_chronic thrush
+ tinea_capitis scabies parotitis).each {|dx| Diagnosis.create(name: dx, show_visits: true)}
Drug.delete_all
amox = Drug.create(name: 'amoxycillin', drug_class: 'antibiotic', drug_subclass: 'penicillin', synonyms: 'amoxacillin; amoxyl; amoxil')

0 comments on commit fa052df

Please sign in to comment.