Permalink
Browse files

Removed Patient new & edit from AS, reformatted form. ATP.

  • Loading branch information...
1 parent 05cca47 commit 870569049caf37fafa7c02b75da78a816db72d68 @MikeBlyth committed Jan 18, 2013
@@ -10,6 +10,6 @@
*
*= require_self
*= require active_scaffold
- *= require rickshaw
+ * require rickshaw
*= require_tree .
*/
@@ -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;
}
@@ -23,17 +23,26 @@ def do_show
super
end
+ def new
+ @patient = Patient.new
+ end
+
def create
@record = patient = Patient.new(params[:patient])
- # binding.pry
+ # 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])
@@ -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
@@ -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_text, as: :string, :input_html => {class: "span12" }
- .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
@@ -0,0 +1,2 @@
+%h2= "Edit #{patient_name_link(@patient)}".html_safe
+= render :partial => 'form'
@@ -0,0 +1,2 @@
+%h2= "Create new Patient :-)".html_safe
+= render :partial => 'form'
@@ -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'
@@ -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}
@@ -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

0 comments on commit 8705690

Please sign in to comment.