Skip to content

Commit

Permalink
Working on visit and diagnoses. ATP (no new tests still).
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeBlyth committed Jan 19, 2013
1 parent 2b7d891 commit fa052df
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 7 deletions.
5 changes: 4 additions & 1 deletion app/controllers/diagnoses_controller.rb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion app/controllers/visits_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions app/helpers/visits_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
16 changes: 16 additions & 0 deletions app/models/diagnosis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
6 changes: 6 additions & 0 deletions app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/views/visits/_diagnoses.html.haml
Original file line number Diff line number Diff line change
@@ -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?
4 changes: 2 additions & 2 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit fa052df

Please sign in to comment.