Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

in progress

  • Loading branch information...
commit 07ee81f6c59a2a6c238e31b9cfc85030c5971195 1 parent ec7d7fe
@MikeBlyth authored
View
4 app/assets/stylesheets/ptbase.scss
@@ -22,11 +22,11 @@ input, textarea, .uneditable-input {
float: left;
padding-top: 5px;
text-align: right;
- width: 100px;
+ width: 150px;
}
.form-horizontal .controls {
- margin-left: 110px;
+ margin-left: 160px;
}
select {
View
5 app/controllers/admissions_controller.rb
@@ -15,7 +15,8 @@ class AdmissionsController < ApplicationController
def new
@patient = Patient.find params[:patient_id]
- @admission = @patient.admissions.new
+ @admission = Admission.new(patient_id: params[:patient_id], provider_id: params[:provider_id],
+ date: Date.zone.now)
end
def edit
@@ -35,7 +36,7 @@ def create
end
def update
- @admission = admission.find(params[:id])
+ @admission = Admission.find(params[:id])
if @admission.update_attributes(params[:admission])
flash[:notice] = 'admission was successfully updated.'
redirect_to :action => 'show', :id => @admission
View
37 app/controllers/immunizations_controller.rb
@@ -1,4 +1,41 @@
class ImmunizationsController < ApplicationController
active_scaffold :immunization do |config|
+ as_no_inline = lambda do |action|
+ config.send(action).link.page = true
+ config.send(action).link.inline = false
+ end
+ %w(create update).each &as_no_inline
+ %w(date provider immunization_type comments).each {|col| config.columns[col].inplace_edit = true}
+ %w(provider immunization_type).each {|col| config.columns[col].form_ui = :select}
end
+
+ def new
+ @immunization = Immunization.new(patient_id: params[:patient_id], provider_id: params[:provider_id],
+ date: Date.current)
+ end
+
+ def edit
+ @immunization = Immunization.find params[:id]
+ end
+
+ def create
+ @immunization = Immunization.new(params[:immunization])
+ if @immunization.save
+ flash[:notice] = 'immunization was successfully created.'
+ redirect_to :action => 'show', :id => @immunization
+ else
+ render :action => 'edit'
+ end
+ end
+
+ def update
+ @immunization = immunization.find(params[:id])
+ if @immunization.update_attributes(params[:immunization])
+ flash[:notice] = 'immunization was successfully updated.'
+ redirect_to :action => 'show', :id => @immunization
+ else
+ render :action => 'edit'
+ end
+ end
+
end
View
3  app/controllers/lab_requests_controller.rb
@@ -12,7 +12,8 @@ class LabRequestsController < ApplicationController
end
def new
- @lab_request = LabRequest.new(patient_id: params[:patient_id])
+ @lab_request = LabRequest.new(patient_id: params[:patient_id],
+ date: Date.zone.now)
end
def edit
View
3  app/controllers/prescriptions_controller.rb
@@ -12,7 +12,8 @@ class PrescriptionsController < ApplicationController
def new
@patient = Patient.find params[:patient_id]
- @prescription = @patient.prescriptions.new(provider_id: current_user.id)
+ @prescription = @patient.prescriptions.new(patient_id: params[:patient_id], provider_id: current_user.id,
+ date: Date.current)
@selected = get_selected_drugs(params) # need to use empty array if no drugs already selected
@preselect = @selected.any? # means user has preselected drugs, so we'll "tick" each one's box on prescr. form
@doses = suggested_doses(@selected, @patient)
View
2  app/controllers/visits_controller.rb
@@ -21,7 +21,7 @@ class VisitsController < ApplicationController
#
def new
patient = Patient.find params[:patient_id]
- @visit = Visit.new(patient: patient) #ToDO Error checking!
+ @visit = Visit.new(patient: params[:patient_id], provider_id: current_user.id, date: Date.current ) #ToDO Error checking!
end
def create
View
6 app/models/immunization.rb
@@ -12,7 +12,11 @@ class Immunization < ActiveRecord::Base
belongs_to :patient
belongs_to :provider
belongs_to :immunization_type
- validates_presence_of :patient_id
+ validates_presence_of :patient_id, :immunization_type, :date
+
+ def to_s
+ "#{immunization_type.abbrev} on #{date.to_date}"
+ end
# ToDo: Refactor
def summary()
View
1  app/views/admissions/_form.html.haml
@@ -17,3 +17,4 @@
.row-fluid.control-row
.span6= form.input :comments, input_html: {class: 'input-block-level'}
= form.button :submit, class: 'btn btn-primary'
+ = link_to "Cancel", request.referer, class: 'btn'
View
10 app/views/immunizations/_form.html.haml
@@ -0,0 +1,10 @@
+- @immunization ||= @record
+= simple_form_for @immunization, html: {class: 'form-horizontal'} do |form|
+ .rowx-fluid
+ = form.association :patient
+ = form.input :date, as: :string
+ = form.association :immunization_type
+ = form.association :provider
+ = form.input :comments
+ = form.button :submit, class: 'btn btn-primary'
+ = link_to "Cancel", request.referer, class: 'btn'
View
2  app/views/immunizations/edit.html.haml
@@ -0,0 +1,2 @@
+%h2 Edit Immunization
+= render :partial => 'form'
View
2  app/views/immunizations/new.html.haml
@@ -0,0 +1,2 @@
+%h2 Record Immunization
+= render :partial => 'form'
View
4 app/views/lab_requests/_form.html.haml
@@ -10,4 +10,6 @@
= render partial: 'lab_results/select', collection: services, as: :service
.row-fluid
%hr
- = form.input :comments
+ = form.input :comments
+ = form.button :submit, class: 'btn btn-primary'
+ = link_to "Cancel", request.referer, class: 'btn'
View
3  app/views/lab_results/_form.html.haml
@@ -11,4 +11,5 @@
.span1= form.input :abnormal, input_html: {class: 'input-mini'}
.span1= form.input :panic, input_html: {class: 'input-mini'}
.span5= form.input :comments , input_html: {:class => 'input-xlarge'}
-
+ = form.button :submit, class: 'btn btn-primary'
+ = link_to "Cancel", request.referer, class: 'btn'
View
3  app/views/prescriptions/_form.html.haml
@@ -22,4 +22,5 @@
#prescription-items
= form.simple_fields_for :prescription_items do |builder|
= render 'prescription_items/form', f: builder
- = form.submit
+ = form.button :submit, class: 'btn btn-primary'
+ = link_to "Cancel", request.referer, class: 'btn'
View
4 app/views/providers/_form.html.haml
@@ -11,5 +11,5 @@
.span3= form.input :ident, :input_html=>{:class=>'input-medium'}, :label=>'Provider ID'
= form.error :base
- = form.submit
- = link_to "Cancel", request.referer
+ = form.button :submit, class: 'btn btn-primary'
+ = link_to "Cancel", request.referer, class: 'btn'
View
4 app/views/visits/_form.html.haml
@@ -91,7 +91,7 @@
%hr
= form.error :base
- = form.submit
- = link_to "Cancel", request.referer
+ = form.button :submit, class: 'btn btn-primary'
+ = link_to "Cancel", request.referer, class: 'btn'
View
4 db/migrate/20130124163521_create_immunization_types.rb
@@ -1,10 +1,10 @@
class CreateImmunizationTypes < ActiveRecord::Migration
def change
- drop_table :immunizations
+ #drop_table :immunizations
create_table :immunizations do |t|
t.integer :immunization_type_id
t.integer :patient_id
- t.date :datetime
+ t.datetime :date
t.integer :provider_id
t.string :comments
end
View
28 db/seeds.rb
@@ -9,10 +9,14 @@
############ THESE ARE FOR TESTING ONLY ############
Patient.delete_all
anderson = Patient.create(last_name: 'Anderson', first_name: 'Charity', sex: 'F', birth_date: '1989-05-15', ident: 'P001')
-audu = Patient.create(last_name: 'Audu', first_name: 'Mohammed', sex: 'M', birth_date: '2003-09-15',
+audu = Patient.create(last_name: 'Audu', first_name: 'Mohammed', sex: 'M', birth_date: '2000-01-1',
ident: 'P002',
hiv_status: 'P', maternal_hiv_status: 'P')
+Provider.delete_all
+hertz = Provider.create(last_name: 'Hertz', first_name: 'Joshua', ident: 'Prov 001', degree: 'M.D.', position: 'staff physician')
+yu = Provider.create(last_name: 'Yu', first_name: 'Debora', ident: 'Prov 002', degree: 'M.D.', position: 'staff physician')
+
Admission.delete_all
Admission.create(patient: audu, date: audu.birth_date+12.months, diagnosis_1: 'malaria', meds: 'ampicillin')
@@ -44,10 +48,15 @@
ImmunizationType.delete_all
bcg = ImmunizationType.create(name: 'BCG', abbrev: 'BCG')
opv = ImmunizationType.create(name: 'polio, oral', abbrev: 'OPV')
+dpt = ImmunizationType.create(name: 'diphtheria-tetanus-pertussis', abbrev: 'DPT')
Immunization.delete_all
birth = audu.birth_date
-Immunization.create(patient: audu, bcg: birth+2.weeks, opv1: birth+6.weeks, opv2: birth+10.weeks, dpt1: birth+6.weeks, dpt2: birth+10.weeks)
+Immunization.create(patient: audu, immunization_type: bcg, date: birth+1.week, provider: yu )
+Immunization.create(patient: audu, immunization_type: opv, date: birth+4.weeks, provider: yu )
+Immunization.create(patient: audu, immunization_type: dpt, date: birth+4.weeks, provider: yu )
+Immunization.create(patient: audu, immunization_type: opv, date: birth+8.weeks, provider: yu )
+Immunization.create(patient: audu, immunization_type: dpt, date: birth+8.weeks, provider: yu )
LabGroup.delete_all
heme = LabGroup.create(name: 'Hematology', abbrev: 'heme')
@@ -77,7 +86,7 @@
LabRequest.delete_all
audu_lab_1 = LabRequest.create(patient: audu)
-audu_lab_1.created_at = audu.birth_date+5.months
+audu_lab_1.created_at = audu.birth_date+12.months
audu_lab_1.save
audu_lab_2 = LabRequest.create(patient: audu)
audu_lab_1.created_at = Date.today - 1.year
@@ -92,13 +101,10 @@
Photo.delete_all
Photo.create(patient: audu, date: audu.birth_date+5.months)
-Provider.delete_all
-hertz = Provider.create(last_name: 'Hertz', first_name: 'Joshua', ident: 'Prov 001')
-
Prescription.delete_all
-prescription = Prescription.create(patient: audu, date: audu.birth_date+5.months, provider: hertz,
+prescription = Prescription.create(patient: audu, date: audu.birth_date+12.months, provider: hertz,
confirmed: true)
-recent_prescription = Prescription.create(patient: audu, date: Date.yesterday, provider: hertz,
+recent_prescription = Prescription.create(patient: audu, date: Date.yesterday, provider: yu,
confirmed: true)
PrescriptionItem.delete_all
@@ -114,7 +120,7 @@
User.create(email: 'admin@example.com', password: 'appendix', username: 'admin', name: 'Administrator')
Visit.delete_all
-audu.visits.create(patient_id: audu.id, date: '2011-07-30', dx: 'pneumonia')
-audu.visits.create(patient_id: audu.id, date: '2012-04-12', dx: 'malaria', dx2: 'gastroenteritis',
- weight: 30, meds: 'artequine')
+audu.visits.create(patient_id: audu.id, date: birth+12.months, dx: 'pneumonia')
+audu.visits.create(patient_id: audu.id, date: birth+18.months, dx: 'malaria', dx2: 'gastroenteritis',
+ weight: 11, meds: 'artequine')
View
2  db/structure.sql
@@ -269,7 +269,7 @@ CREATE TABLE immunizations (
id integer NOT NULL,
immunization_type_id integer,
patient_id integer,
- datetime date,
+ date timestamp without time zone,
provider_id integer,
comments character varying(255)
);
Please sign in to comment.
Something went wrong with that request. Please try again.