Skip to content

Commit

Permalink
Merge pull request #281 from sparc-request/jl-invoiced-lockdown
Browse files Browse the repository at this point in the history
Jl - invoiced lockdown
  • Loading branch information
Stuart-Johnson committed May 3, 2018
2 parents af3003a + cf2a077 commit 1cdea14
Show file tree
Hide file tree
Showing 16 changed files with 80 additions and 38 deletions.
38 changes: 21 additions & 17 deletions app/assets/javascripts/appointments.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -196,26 +196,27 @@ $ ->
url: "/procedures/#{procedure_id}.js"

$(document).on 'click', 'label.status.incomplete', ->
active = $(this).hasClass('active')
procedure_id = $(this).parents('.procedure').data('id')
# undo incomplete status
if active
data = procedure:
status: "unstarted"
performer_id: null
if !$(this).hasClass('disabled')
active = $(this).hasClass('active')
procedure_id = $(this).parents('.procedure').data('id')
# undo incomplete status
if active
data = procedure:
status: "unstarted"
performer_id: null

$.ajax
type: 'PUT'
data: data
url: "/procedures/#{procedure_id}.js"
$.ajax
type: 'PUT'
data: data
url: "/procedures/#{procedure_id}.js"

else
data = partial: "incomplete", procedure: status: "incomplete"
else
data = partial: "incomplete", procedure: status: "incomplete"

$.ajax
type: 'GET'
data: data
url: "/procedures/#{procedure_id}/edit.js"
$.ajax
type: 'GET'
data: data
url: "/procedures/#{procedure_id}/edit.js"

$(document).on 'click', 'button.incomplete_all', ->
status = 'incomplete'
Expand Down Expand Up @@ -392,5 +393,8 @@ $ ->
$(document).on 'click', '.pre_start_disabled, .complete-all-container.contains_disabled, .incomplete-all-container.contains_disabled', ->
alert(I18n["appointment"]["warning"])

$(document).on 'click', '.invoiced_disabled, .complete-all-container.invoiced_disabled, .incomplete-all-container.invoiced_disabled', ->
alert(I18n["appointment"]["procedure_invoiced_warning"])

$(document).on 'click', '.completed_date_btn.contains_disabled', ->
alert("After clicking Start Visit, please either complete, incomplete, or assign a follow up date for each procedure before completing visit.")
2 changes: 1 addition & 1 deletion app/assets/javascripts/procedure_grouper.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ $ ->
row_count = rows.length
procedures_table = $(rows).first().parents('.procedures tbody')

$(procedures_table).prepend("<tr class='procedure-group' id='group-#{group_id}' data-group-id='#{group_id}'><td colspan='8'><button type='button' class='btn btn-xs btn-primary'><span class='count'>#{row_count}</span><span class='glyphicon glyphicon-chevron-right'></span></button>#{title} #{service_billing_type}</td></tr>")
$(procedures_table).prepend("<tr class='procedure-group' id='group-#{group_id}' data-group-id='#{group_id}'><td colspan='10'><button type='button' class='btn btn-xs btn-primary'><span class='count'>#{row_count}</span><span class='glyphicon glyphicon-chevron-right'></span></button>#{title} #{service_billing_type}</td></tr>")

return this.find_group(group_id)

Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/study_level_activities.sass
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ td.wrap

div.modal-content
width: 60%
min-width: 922px
min-width: 1050px
4 changes: 4 additions & 0 deletions app/helpers/appointment_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,8 @@ def procedure_notes_formatter(procedure)
has_notes: procedure.notes.any?,
button_class: "#{procedure.appt_started? ? '' : 'disabled'}"})
end

def procedures_invoiced?(appointment)
appointment.procedures.any?{|procedure| procedure.invoiced == true}
end
end
31 changes: 20 additions & 11 deletions app/helpers/study_level_activities_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,27 @@ def is_protocol_type_study? (protocol)
end

def fulfillment_options_buttons fulfillment
options = raw(
note_list_item({object: fulfillment, has_notes: fulfillment.notes.any?})+
content_tag(:li, raw(
content_tag(:button, raw(content_tag(:span, '', class: "glyphicon glyphicon-open-file", aria: {hidden: "true"}))+' Documents', type: 'button', class: 'btn btn-default form-control actions-button documents list', data: {documentable_id: fulfillment.id, documentable_type: "Fulfillment"}))
)+
content_tag(:li, raw(
content_tag(:button, raw(content_tag(:span, '', class: "glyphicon glyphicon-edit", aria: {hidden: "true"}))+' Edit Fulfillment', type: 'button', class: 'btn btn-default form-control actions-button otf_fulfillment_edit'))
)+
content_tag(:li, raw(
content_tag(:button, raw(content_tag(:span, '', class: "glyphicon glyphicon-remove", aria: {hidden: "true"}))+' Delete Fulfillment', type: 'button', class: 'btn btn-default form-control actions-button otf_fulfillment_delete', data: { id: fulfillment.id }))
unless fulfillment.invoiced?
options = raw(
note_list_item({object: fulfillment, has_notes: fulfillment.notes.any?})+
content_tag(:li, raw(
content_tag(:button, raw(content_tag(:span, '', class: "glyphicon glyphicon-open-file", aria: {hidden: "true"}))+' Documents', type: 'button', class: 'btn btn-default form-control actions-button documents list', data: {documentable_id: fulfillment.id, documentable_type: "Fulfillment"}))
)+
content_tag(:li, raw(
content_tag(:button, raw(content_tag(:span, '', class: "glyphicon glyphicon-edit", aria: {hidden: "true"}))+' Edit Fulfillment', type: 'button', class: 'btn btn-default form-control actions-button otf_fulfillment_edit'))
)+
content_tag(:li, raw(
content_tag(:button, raw(content_tag(:span, '', class: "glyphicon glyphicon-remove", aria: {hidden: "true"}))+' Delete Fulfillment', type: 'button', class: 'btn btn-default form-control actions-button otf_fulfillment_delete', data: { id: fulfillment.id }))
)
)
)
else
options = raw(
note_list_item({object: fulfillment, has_notes: fulfillment.notes.any?})+
content_tag(:li, raw(
content_tag(:button, raw(content_tag(:span, '', class: "glyphicon glyphicon-open-file", aria: {hidden: "true"}))+' Documents', type: 'button', class: 'btn btn-default form-control actions-button documents list', data: {documentable_id: fulfillment.id, documentable_type: "Fulfillment"}))
)
)
end

span = raw content_tag(:span, '', class: 'glyphicon glyphicon-triangle-bottom')
button = raw content_tag(:button, raw(span), type: 'button', class: 'btn btn-default btn-sm dropdown-toggle form-control available-actions-button', 'data-toggle' => 'dropdown', 'aria-expanded' => 'false')
Expand Down
3 changes: 3 additions & 0 deletions app/views/appointments/_core.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
= t(:procedure)[:performed_by]
%th.notes
= t(:procedure)[:notes]
- if procedures_invoiced?(appointment)
%th.invoiced
= t(:procedure)[:invoiced]
%th.remove
= t(:procedure)[:remove]
%tbody
Expand Down
14 changes: 9 additions & 5 deletions app/views/appointments/_procedure.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
%td.billing
= select_tag "quantity_type_#{procedure.id}", options_for_select(Procedure.billing_display, procedure.billing_type), class: "form-control billing_type selectpicker"
%td.status
.btn-group{data: {toggle: "buttons"}, class: "#{ procedure.appt_started? ? '' : 'pre_start_disabled' }"}
.btn-group{data: {toggle: "buttons"}, class: "#{ procedure.appt_started? ? '' : 'pre_start_disabled' } #{procedure.invoiced? ? 'invoiced_disabled' : ''}"}
%label.status.complete{class: "btn btn-default #{procedure.complete? ? 'selected_before active' : 'inactive'} #{ procedure.appt_started? ? '' : 'disabled' }", data: {core_id: "#{procedure.sparc_core_id}"}}
%input{class: "procedure_status", type: "radio", value: "complete", autocomplete: "off", id: "complete_button_#{procedure.id}"} Complete
%label.status.incomplete{class: "btn btn-default #{procedure.incomplete? ? 'active': ''} #{ procedure.appt_started? ? '' : 'disabled' }"}
%label.status.incomplete{class: "btn btn-default #{procedure.incomplete? ? 'active': ''} #{ (procedure.appt_started? && !procedure.invoiced?) ? '' : 'disabled' }"}
%input{class: "procedure_status", type: "radio", value: "incomplete", autocomplete: "off", id: "incomplete_button_#{procedure.id}"} Incomplete
%td.followup{id: "follow_up_#{procedure.id}"}
= render partial: "/appointments/followup_calendar", locals: { procedure: procedure }
Expand All @@ -40,6 +40,10 @@
-# div used for capturing click events when button is disabled
.btn-group{ class: "#{ procedure.appt_started? ? '' : 'pre_start_disabled' }" }
= procedure_notes_formatter(procedure)
%td.remove
%button.btn.btn-danger.delete{type: "button", aria: {label: "Remove Procedure"}}
%span.glyphicon.glyphicon-remove{aria: {hidden: "true"}}
- if procedures_invoiced?(procedure.appointment)
%td.invoiced
= (procedure.invoiced? ? "Yes" : "No")
- unless procedure.invoiced?
%td.remove
%button.btn.btn-danger.delete{type: "button", aria: {label: "Remove Procedure"}}
%span.glyphicon.glyphicon-remove{aria: {hidden: "true"}}
3 changes: 2 additions & 1 deletion app/views/appointments/_start_complete_buttons.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
.col-xs-6
= text_field_tag 'start_date', '', class: 'form-control', readonly: true
.col-xs-1.reset_button
%button.btn.btn-warning.reset_visit{type: "button"}= t(:appointment)[:reset_visit]
%button.btn.btn-warning.reset_visit{type: "button", class: hidden_class(procedures_invoiced?(appointment))}= t(:appointment)[:reset_visit]
/ %button.btn.btn-warning.reset_visit{type: "button", class: "#{procedures_invoiced?(appointment) ? 'disabled' : ''}"}= t(:appointment)[:reset_visit]
.start_date_btn{class: hidden_class(!appointment.start_date.blank?) }
%button.btn.btn-success.start_visit= t(:appointment)[:start_visit]
Expand Down
1 change: 1 addition & 0 deletions app/views/fulfillments/_fulfillment.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ json.quantity_type fulfillment.line_item.quantity_type
json.performed_by fulfillment.performer.full_name if fulfillment.performer
json.components fulfillment_components_formatter(fulfillment.components)
json.options fulfillment_options_buttons(fulfillment)
json.invoiced (fulfillment.invoiced? ? "Yes" : "No")
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
= t(:fulfillment)[:components]
%th{data: {class: 'options', align: "center", field: "options"}}
= t(:actions)[:actions]
- if line_item.fulfillments.any?{|fulfillment| fulfillment.invoiced == true}
%th{data: {class: 'invoiced', align: "center", field: "invoiced"}}
= t(:fulfillment)[:invoiced]
#fulfillment-klok-description
%i{class: 'glyphicon glyphicon-time'}
%span= t(:fulfillment)[:klok_description]
Expand Down
3 changes: 3 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ en:
visit_indications: "Visit Indications:"
visit_type: "Type of Visit:"
warning: "Please click 'Start Visit' and enter a start date to continue."
procedure_invoiced_warning: "This procedure has been invoiced and can not be altered."

arm:
object: "Arm"
Expand Down Expand Up @@ -148,6 +149,7 @@ en:
add_fulfillment: "Add Fulfillment"
list_fulfillments: "List"
components: "Fulfillment Components"
invoiced: "Invoiced"
edit: "Edit Fulfillment"
flash_messages:
created: "Fulfillment Created"
Expand Down Expand Up @@ -298,6 +300,7 @@ en:
r_t: "R/T"
select_reason: "Select a Reason"
status: "Status"
invoiced: "Invoiced"

protocol:
object: "Protocol"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddInvoicedToProceduresAndFulfillments < ActiveRecord::Migration[5.0]
def change
add_column :procedures, :invoiced, :boolean
add_column :fulfillments, :invoiced, :boolean
end
end
4 changes: 3 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20180306213506) do
ActiveRecord::Schema.define(version: 20180322134942) do

create_table "appointment_statuses", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin" do |t|
t.string "status"
Expand Down Expand Up @@ -111,6 +111,7 @@
t.string "service_name"
t.integer "service_cost"
t.integer "klok_entry_id"
t.boolean "invoiced"
t.index ["creator_id"], name: "index_fulfillments_on_creator_id", using: :btree
t.index ["klok_entry_id"], name: "index_fulfillments_on_klok_entry_id", using: :btree
t.index ["line_item_id"], name: "index_fulfillments_on_line_item_id", using: :btree
Expand Down Expand Up @@ -235,6 +236,7 @@
t.integer "visit_id"
t.integer "performer_id"
t.datetime "incompleted_date"
t.boolean "invoiced"
t.index ["appointment_id"], name: "index_procedures_on_appointment_id", using: :btree
t.index ["completed_date"], name: "index_procedures_on_completed_date", using: :btree
t.index ["service_id"], name: "index_procedures_on_service_id", using: :btree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def and_i_click_incomplete_all_and_close_the_alert
end

def and_i_unroll_accordion
find("tr.procedure-group td[colspan='8'] button").click
find("tr.procedure-group td[colspan='10'] button").click
wait_for_ajax
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
scenario 'and sees the complete note' do
given_i_have_added_a_procedure_to_an_appointment
when_i_start_the_appointment
wait_for_ajax
when_i_incomplete_the_procedure
when_i_complete_the_procedure
when_i_view_the_notes_list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def given_i_am_viewing_a_procedure_marked_as_complete

def when_i_begin_the_appointment
find('button.start_visit').click
wait_for_ajax
end

def when_i_complete_the_procedure
Expand Down

0 comments on commit 1cdea14

Please sign in to comment.