Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 3 commits
  • 15 files changed
  • 0 commit comments
  • 1 contributor
View
0 ...ts/growth_chart_morris.js.coffee.not_used → app/archived/growth_chart_morris.js.coffee
File renamed without changes.
View
2 app/assets/stylesheets/application.css
@@ -10,6 +10,6 @@
*
*= require_self
*= require active_scaffold
- *= require rickshaw
+ * require rickshaw
*= require_tree .
*/
View
25 app/assets/stylesheets/ptbase.scss
@@ -11,4 +11,29 @@
.footer_buttons {
margin-top: 1.5em
+}
+
+// Bootstrap (?) overrides
+input, textarea, .uneditable-input {
+ width: 136px;
+}
+
+.form-horizontal .control-label {
+ float: left;
+ padding-top: 5px;
+ text-align: right;
+ width: 100px;
+}
+
+.form-horizontal .controls {
+ margin-left: 110px;
+}
+
+select {
+ background-color: white;
+ border: 1px solid #CCCCCC;
+ width: 140px;
+}
+select[multiple], select[size] {
+ height: auto;
}
View
15 app/controllers/patients_controller.rb
@@ -23,23 +23,34 @@ def do_show
super
end
+ def new
+ @patient = Patient.new
+ end
+
def create
@record = patient = Patient.new(params[:patient])
+ # binding.pry
if patient.save
flash[:notice] = "Created new patient #{patient}"
render :show
else
- # render :create
+ params=nil
+ render :create
end
end
+ def edit
+ @patient = Patient.find params[:id]
+ end
+
def update
@record = patient = Patient.find params[:id]
if patient.update_attributes(params[:patient])
flash[:notice] = 'Patient updated'
redirect_to patient_path(patient.id)
else
- render :edit
+
+ render :update
end
end
View
32 app/models/patient.rb
@@ -35,9 +35,11 @@ class Patient < ActiveRecord::Base
include NamesHelper
attr_accessible :first_name, :ident, :last_name, :other_names, :sex, :residence, :phone, :caregiver, :birth_date,
- :death_date, :birth_date, :birth_date_exact,:death_date,
+ :death_date, :birth_date_text, :birth_date_exact,:death_date,
:allergies, :hemoglobin_type, :hiv_status, :maternal_hiv_status
+ attr_writer :birth_date_text
+
has_many :visits
has_many :lab_requests
has_many :lab_results, through: :lab_requests
@@ -51,9 +53,11 @@ class Patient < ActiveRecord::Base
validates_presence_of :last_name, :ident, :birth_date
validates_uniqueness_of :ident
+ before_validation :save_birth_date_text
validate :valid_birth_date
+
############ NAME METHODS
def to_s
name_id
@@ -167,6 +171,15 @@ def next_appt
############### OTHER METHODS
+ def birth_date_text
+ @birth_date_text || birth_date.to_s(:day_mon_year)
+ end
+
+ def save_birth_date_text
+ self.birth_date = validate_birth_date_text unless @birth_date_text.blank?
+ #binding.pry
+ end
+
def date
birth_date
end
@@ -204,6 +217,23 @@ def recent_drugs(since=3)
RxDrugList.new.add_prescriptions(recent_prescriptions)
end
+ def validate_birth_date_text
+ if @birth_date_text.blank?
+ errors.add :birth_date_text, "cannot be blank"
+ return nil
+ end
+ parsed = Time.zone.parse(@birth_date_text)
+ if parsed
+ return parsed
+ else
+ errors.add :birth_date_text, "cannot be parsed"
+ return nil
+ end
+ rescue ArgumentError
+ errors.add :birth_date_text, "is out of range"
+ return nil
+ end
+
#def time_valid?(str)
# return false unless str =~ /\A\s*([0-9]{1,2}):([0-9]{2,2})(\s+|\Z)(am|pm)?/i
# hour, minute, am_pm = $1, $2, $4
View
3 app/views/layouts/application.html.haml
@@ -12,8 +12,9 @@
.row-fluid
.span2
= render(:partial => '/shared/patient_menu', :object => @patient)
+ %br
+ = link_to 'Sign out', destroy_user_session_path, :method=> :delete
.span10
%p.notice= notice
%p.alert= alert
= yield
- = link_to 'Sign out', destroy_user_session_path, :method=> :delete
View
86 app/views/patients/_form.html.haml
@@ -1,50 +1,48 @@
-- @patient = @record
--#= "Record = #{@record.attributes}"
-= simple_fields_for(@patient, :html => {:class => 'form-horizontal' }) do |form|
+= simple_form_for(@patient, :html => {:class => 'form-horizontal' }) do |form|
= form.error_notification
- %fieldset
- %legend Basic information
- .row-fluid
- .span2
- = form.input :last_name, :input_html => {class: :span12 }
- .span2
- = form.input :first_name, :input_html => {class: :span12 }
- .span2
- = form.input :other_names, :input_html => {class: :span12 }
- .span2
- = form.input :sex, as: :radio_buttons, collection: [['Male', 'M'],['Female', 'F']], label_html: {class: :inline}
- .row-fluid
- .span2
- = form.input :ident, :input_html => {class: :span12 }
- .row-fluid
- .span2
- = form.input :birth_date, as: :string, :input_html => {class: "span12 datepicker" }
- .span2
- = form.input :birth_date_exact, label: "Exact birth date?"
- .span2
- = form.input :death_date, as: :string, :input_html => {class: "span12 datepicker" }
+ %h4 Basic information
+ .row-fluid
+ .span4
+ = form.input :last_name
+ .span4
+ = form.input :first_name
+ .span4
+ = form.input :other_names
+ .row-fluid
+ .span4
+ = form.input :sex, collection: [['Male', 'M'],['Female', 'F']], label_html: {class: :inline}
+ .span4
+ = form.input :ident
+ .row-fluid
+ .span4
+ = form.input :birth_date_text, as: :string
+ .span4
+ = form.input :birth_date_exact, label: "Exact birth date?"
+ .span4
+ = form.input :death_date, as: :string, :input_html => {class: "datepicker" }
+ .row-fluid
+ .span4
+ = form.input :residence, as: :string
+ .span4
+ = form.input :phone, as: :tel
+ .span4
+ = form.input :caregiver
+ #health_info
+ %h4.span12 Health information
.row-fluid
.span4
- = form.input :residence, as: :string , :input_html => {class: :span12 }
- .span2
- = form.input :phone, as: :tel, :input_html => {class: :span12 }
- .span2
- = form.input :caregiver, :input_html => {class: :span12 }
- %fieldset
- %legend Health Information
- .row-fluid
- .span2
- = form.input :allergies, :input_html => {class: :span12 }
- .span2
- = form.input :hemoglobin_type, :input_html => {class: :span10 }
- #hiv_info
- .span2
- = form.input :hiv_status, :input_html => {class: :span10 },
- :collection => ['pos', 'neg', '?']
- .span2
- = form.input :maternal_hiv_status, :input_html => {class: :span10 },
- :collection => ['pos', 'neg', '?']
+ = form.input :allergies
+ .span4
+ = form.input :hemoglobin_type
+ #hiv_info.row-fluid
+ .span4
+ = form.input :hiv_status, label: 'HIV status',
+ :collection => ['pos', 'neg', '?']
+ .span4
+ = form.input :maternal_hiv_status, label: 'Mother\'s HIV status',
+ :collection => ['pos', 'neg', '?']
= form.error :base
-
+ = form.submit
+ = link_to "Cancel", request.referer
View
2 app/views/patients/edit.html.haml
@@ -0,0 +1,2 @@
+%h2= "Edit #{patient_name_link(@patient)}".html_safe
+= render :partial => 'form'
View
2 app/views/patients/new.html.haml
@@ -0,0 +1,2 @@
+%h2= "Create new Patient :-)".html_safe
+= render :partial => 'form'
View
9 app/views/patients/show.html.haml
@@ -1,10 +1,9 @@
- @patient = @record
- present @record do |pt_presenter|
-
%h2
- Main Info Page for #{@patient.name_id}
+ #{@patient.name_id}
%fieldset
- %legend Demographics
+ %legend Basic information
.row-fluid
.span3
%table{:align => "left"}
@@ -37,8 +36,10 @@
= render(:partial => 'shared/medinfo', :object => @patient )
.row-fluid
= render(:partial => 'shared/problem_list', :object => @patient )
+ %hr
.row-fluid.footer_buttons
= link_to 'Edit patient', {:action => 'edit', :id => @patient}, :class => 'btn'
+ = link_to 'Patient list', patients_path, class: 'btn'
- if true || authorized_as_admin
= link_to "Delete this patient", { :action => "destroy", :id => @patient.id} ,
- :confirm => 'Are you sure?', :class => 'btn btn-danger'
+ :confirm => 'Are you sure?', :class => 'btn btn-danger'
View
5 app/views/shared/_patient_menu.html.haml
@@ -1,7 +1,8 @@
- patient = patient_menu
- if ! patient.nil?
- - new_visit = link_to "New Visit", new_visit_path(:patient => patient)
- = new_visit
+ = link_to "New Visit", new_visit_path(patient: patient)
+ %br
+ = link_to "New Labs", new_lab_request_path(patient: patient)
-#%div
-# %p.actionshead
-# Actions for #{@patient.name}
View
12 config/environments/development.rb
@@ -38,8 +38,12 @@
end
######### IF YOU WANT TO USE FACTORYGIRL IN DEVELOPMENT
-require 'factory_girl'
-include FactoryGirl
-require "#{Rails.root}/spec/factories/factories.rb"
require 'anthropometrics'
-require 'birth_date'
+require 'birth_date'
+require 'factory_girl'
+#include FactoryGirl
+#require "#{Rails.root}/spec/factories/factories.rb"
+def fg_load
+ include FactoryGirl
+ require "#{Rails.root}/spec/factories/factories.rb"
+end
View
1 config/initializers/date_formats.rb
@@ -13,6 +13,7 @@
# TIME::DATE_FORMATS for formatting .to_s.
Time::DATE_FORMATS[:date_long] = "%-1e %B %Y"
+Time::DATE_FORMATS[:day_mon_year] = "%-1e %b %Y"
Time::DATE_FORMATS[:us_date_long] = "%B %-1e, %Y"
Time::DATE_FORMATS[:date] = "%-1e %B"
Time::DATE_FORMATS[:us_date] = "%B %-1e"
View
1 config/initializers/date_validators.rb
@@ -4,7 +4,6 @@ def not_future
end
def valid_birth_date
-puts "birth_date=#{birth_date}, #{birth_date.class}"
errors.add(:birth_date, 'cannot be in the future') if birth_date && (birth_date > DateTime.now)
errors.add(:birth_date, 'makes person too old') if birth_date && (birth_date < DateTime.now - 120.years)
end
View
4 config/locales/en.yml
@@ -2,4 +2,6 @@
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
en:
- hello: "Hello world"
+ date:
+ formats:
+ default: "%-1e %b %y"# 9 Mar 11

No commit comments for this range

Something went wrong with that request. Please try again.