Skip to content

Commit

Permalink
Merge pull request #178 from sparc-request/ac-spec-fixes
Browse files Browse the repository at this point in the history
Ac spec fixes
  • Loading branch information
amcates committed Jun 16, 2016
2 parents 0b2b7eb + 801c2da commit 5fd60e0
Show file tree
Hide file tree
Showing 75 changed files with 298 additions and 366 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ sudo: false
language: ruby
cache: bundler
before_install:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- export TZ=America/New_York
before_script:
- cp config/database.yml.example config/database.yml
- cp config/shards.yml.example config/shards.yml
Expand Down
42 changes: 22 additions & 20 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,14 @@ GEM
launchy (2.4.3)
addressable (~> 2.3)
libv8 (3.16.14.7)
loofah (2.0.2)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
method_source (0.8.2)
mime-types (2.6.2)
mini_portile (0.6.2)
minitest (5.7.0)
mini_portile2 (2.1.0)
minitest (5.9.0)
momentjs-rails (2.10.2)
railties (>= 3.1)
multi_json (1.11.0)
Expand All @@ -237,8 +237,9 @@ GEM
net-ssh (>= 2.6.5)
net-ssh (2.9.2)
netrc (0.10.3)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
nokogiri (1.6.8)
mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
omniauth (1.2.2)
hashie (>= 1.2, < 4)
rack (~> 1.0)
Expand All @@ -252,6 +253,7 @@ GEM
request_store (~> 1.1.0)
paranoia (2.1.2)
activerecord (~> 4.0)
pkg-config (1.1.7)
progress_bar (1.0.3)
highline (~> 1.6.1)
options (~> 2.3.0)
Expand Down Expand Up @@ -283,18 +285,18 @@ GEM
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.6)
rails-dom-testing (1.0.7)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.2)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (4.2.2)
actionpack (= 4.2.2)
activesupport (= 4.2.2)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.4.2)
rake (11.1.2)
rdoc (4.2.0)
json (~> 1.4)
ref (1.0.5)
Expand All @@ -311,23 +313,23 @@ GEM
rspec-mocks
rspec-collection_matchers (1.1.2)
rspec-expectations (>= 2.99.0.beta1)
rspec-core (3.2.3)
rspec-support (~> 3.2.0)
rspec-expectations (3.2.1)
rspec-core (3.4.4)
rspec-support (~> 3.4.0)
rspec-expectations (3.4.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.2.0)
rspec-mocks (3.2.1)
rspec-support (~> 3.4.0)
rspec-mocks (3.4.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.2.0)
rspec-rails (3.2.2)
rspec-support (~> 3.4.0)
rspec-rails (3.4.2)
actionpack (>= 3.0, < 4.3)
activesupport (>= 3.0, < 4.3)
railties (>= 3.0, < 4.3)
rspec-core (~> 3.2.0)
rspec-expectations (~> 3.2.0)
rspec-mocks (~> 3.2.0)
rspec-support (~> 3.2.0)
rspec-support (3.2.2)
rspec-core (~> 3.4.0)
rspec-expectations (~> 3.4.0)
rspec-mocks (~> 3.4.0)
rspec-support (~> 3.4.0)
rspec-support (3.4.1)
ruby_parser (3.7.0)
sexp_processor (~> 4.1)
rubyzip (1.0.0)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/arms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def destroy
@arm.errors.add(:arm, "'#{@arm.name}' has completed procedures and cannot be deleted")
@errors = @arm.errors
else
@arm.delay.destroy
@arm.destroy_later
flash.now[:alert] = t(:arm)[:deleted]
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/fulfillments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def detect_changes_and_create_notes
unless new_field.blank?
unless current_field.blank?
current_field = (field == :fulfilled_at ? current_field.to_date.to_s : current_field.to_s)
new_field = (field == :fulfilled_at ? Time.strptime(new_field, "%m-%d-%Y").to_date.to_s : new_field.to_s)
new_field = (field == :fulfilled_at ? Time.strptime(new_field, "%m/%d/%Y").to_date.to_s : new_field.to_s)
end
if current_field != new_field
comment = t(:fulfillment)[:log_notes][field] + (field == :performer_id ? Identity.find(new_field).full_name : new_field.to_s)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/line_items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def detect_changes_and_create_notes
unless new_field.blank?
unless current_field.blank?
current_field = (field == "started_at" ? current_field.to_date.to_s : current_field.to_s)
new_field = (field == "started_at" ? Time.strptime(new_field, "%m-%d-%Y").to_date.to_s : new_field)
new_field = (field == "started_at" ? Time.strptime(new_field, "%m/%d/%Y").to_date.to_s : new_field)
end
if current_field != new_field
comment = t(:line_item)[:log_notes][field.to_sym] + (field == "service_id" ? Service.find(new_field).name : new_field.to_s)
Expand Down
1 change: 1 addition & 0 deletions app/controllers/participants_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def participant_params
def find_participant
participant_id = params[:id] || params[:participant_id]
@participant = Participant.where(id: participant_id).first

if @participant.present?
@protocol = @participant.protocol
else
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/procedures_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def create_note_before_update

def change_in_completed_date_detected?
if procedure_params[:completed_date]
Time.strptime(procedure_params[:completed_date], "%m-%d-%Y") != @procedure.completed_date
Time.strptime(procedure_params[:completed_date], "%m/%d/%Y") != @procedure.completed_date
else
return false
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def create

@report = @report_type.classify.constantize.new(reports_params)
@errors = @report.errors

if @report.valid?
@reports_params = reports_params
@documentable.documents.push @document
Expand Down
10 changes: 2 additions & 8 deletions app/controllers/update_dropdowns_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@ class UpdateDropdownsController < ApplicationController

def create
org_ids = params[:org_ids]
@protocols = []
@protocols = org_ids.flat_map{ |id| find_protocols(id) }
end

private

def find_protocols(org_ids)
Protocol.find_protocols_by_org_id(org_ids)
ssrs = SubServiceRequest.where(organization_id: org_ids)
@protocols = ssrs.map(&:protocol)
end
end
9 changes: 6 additions & 3 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ def generate_history_text url
url
end
rescue Exception => e
puts "#"*20
puts e.message
puts "#"*20
#TODO do we want the message in test, this is just breadcrumbs
unless Rails.env.test?
puts "#"*20
puts e.message
puts "#"*20
end
return url
end
end
Expand Down
7 changes: 7 additions & 0 deletions app/jobs/delayed_destroy_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class DelayedDestroyJob < ActiveJob::Base
queue_as :delayed_destroy

def perform(object)
object.destroy
end
end
11 changes: 3 additions & 8 deletions app/jobs/importer_job.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
class ImporterJob < Struct.new(:sparc_id, :callback_url, :action)
class ImporterJob < ActiveJob::Base
queue_as :sparc_api_requests

class SparcApiError < StandardError
end

def self.enqueue(sparc_id, callback_url, action)
job = new(sparc_id, callback_url, action)

Delayed::Job.enqueue job, queue: 'sparc_api_requests'
end

def perform
def perform sparc_id, callback_url, action
skip_faye_callbacks
yield
set_faye_callbacks
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/protocol_importer_job.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class ProtocolImporterJob < ImporterJob

def perform
def perform sparc_id, callback_url, action
super {
case action
when 'create'
Expand Down
4 changes: 2 additions & 2 deletions app/jobs/service_importer_job.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class ServiceImporterJob < ImporterJob

def perform
def perform sparc_id, callback_url, action
super {
case action
when 'create'
Expand Down Expand Up @@ -30,4 +30,4 @@ def update_components(callback_url)
end
end
end
end
end
4 changes: 4 additions & 0 deletions app/models/arm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ class Arm < ActiveRecord::Base
validates :name, presence: true
validates_numericality_of :subject_count, greater_than_or_equal_to: 1
validates_numericality_of :visit_count, greater_than_or_equal_to: 1

def destroy_later
DelayedDestroyJob.perform_later self
end
end
2 changes: 2 additions & 0 deletions app/models/core.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Core < Organization
end
2 changes: 1 addition & 1 deletion app/models/fulfillment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Fulfillment < ActiveRecord::Base
where("fulfilled_at is not NULL AND fulfilled_at between ? AND ?", start_date, end_date)}

def fulfilled_at=(date_time)
write_attribute(:fulfilled_at, Time.strptime(date_time, "%m-%d-%Y")) if date_time.present?
write_attribute(:fulfilled_at, Time.strptime(date_time, "%m/%d/%Y")) if date_time.present?
end

def total_cost
Expand Down
2 changes: 2 additions & 0 deletions app/models/institution.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Institution < Organization
end
2 changes: 1 addition & 1 deletion app/models/line_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def decrement_sparc_service_counter
end

def started_at=(date)
write_attribute(:started_at, Time.strptime(date, "%m-%d-%Y")) if date.present?
write_attribute(:started_at, Time.strptime(date, "%m/%d/%Y")) if date.present?
end

def quantity_remaining
Expand Down
12 changes: 0 additions & 12 deletions app/models/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,3 @@ def all_child_services(scope)
all_child_organizations_with_non_process_ssrs.map { |child| child.services.send(scope) }
end
end

class Program < Organization
end

class Core < Organization
end

class Provider < Organization
end

class Institution < Organization
end
2 changes: 1 addition & 1 deletion app/models/participant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def self.title id
end

def date_of_birth=(dob)
write_attribute(:date_of_birth, Time.strptime(dob, "%m-%d-%Y")) if dob.present?
write_attribute(:date_of_birth, Time.strptime(dob, "%m/%d/%Y")) if dob.present?
end

def phone_number_format
Expand Down
2 changes: 1 addition & 1 deletion app/models/procedure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def reset

def completed_date=(completed_date)
if completed_date.present?
write_attribute(:completed_date, Time.strptime(completed_date, "%m-%d-%Y"))
write_attribute(:completed_date, Time.strptime(completed_date, "%m/%d/%Y"))
else
write_attribute(:completed_date, nil)
end
Expand Down
2 changes: 2 additions & 0 deletions app/models/program.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Program < Organization
end
5 changes: 0 additions & 5 deletions app/models/protocol.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ def self.title id
["Protocol", Protocol.find(id).srid].join(' ')
end

def self.find_protocols_by_org_id(org_ids)
joins(:sub_service_request).
where(sub_service_requests: { organization_id: org_ids })
end

def sparc_uri
[
ENV.fetch('GLOBAL_SCHEME'),
Expand Down
3 changes: 3 additions & 0 deletions app/models/provider.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Provider < Organization
end

2 changes: 1 addition & 1 deletion app/models/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Task < ActiveRecord::Base
scope :mine, -> (identity) { incomplete.where(assignee: identity) }

def due_at=(due_date)
write_attribute(:due_at, Time.strptime(due_date, "%m-%d-%Y")) if due_date.present?
write_attribute(:due_at, Time.strptime(due_date, "%m/%d/%Y")) if due_date.present?
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/views/multiple_procedures/update_procedures.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ $('#modal_place').modal 'hide'

$("tr.procedure[data-id='<%= procedure.id %>'] td.status .complete").addClass('active')
$("tr.procedure[data-id='<%= procedure.id %>'] td.status .incomplete").removeClass('active')
$("tr.procedure[data-id='<%= procedure.id %>'] div.completed_date_field input.datetimepicker").val("<%= @completed_date.strftime('%m-%d-%Y') %>").removeAttr("disabled")
$("tr.procedure[data-id='<%= procedure.id %>'] div.completed_date_field input.datetimepicker").val("<%= @completed_date.strftime('%m/%d/%Y') %>").removeAttr("disabled")

<% end %>
<% end %>
Expand Down
5 changes: 3 additions & 2 deletions lib/identity_organizations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def super_user_protocols
end

def clinical_provider_protocols
Protocol.joins(:clinical_providers).where(clinical_providers: { identity_id: @id }).to_a
org_ids = ClinicalProvider.where(identity_id: @id).select(:organization_id).map(&:organization_id)
Protocol.joins(:sub_service_request).where(sub_service_requests: { organization_id: org_ids }).to_a
end

# returns protocols that clinical provider and super user have access to.
Expand All @@ -51,4 +52,4 @@ def fulfillment_access_protocols
def fulfillment_organizations_with_protocols
(clinical_provider_organizations_with_protocols + super_user_organizations_with_protocols).uniq
end
end
end
6 changes: 3 additions & 3 deletions lib/importers/sparc_fulfillment_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def create_line_item_fulfillment(sparc_line_item_fulfillment, fulfillment_line_i
quantity = sparc_quantity * sparc_unit_quantity

fulfillment_line_item_fulfillment = fulfillment_line_item.fulfillments.new(sparc_id: sparc_line_item_fulfillment.id,
fulfilled_at: sparc_line_item_fulfillment.date.strftime("%m-%d-%Y"),
fulfilled_at: sparc_line_item_fulfillment.date.strftime("%m/%d/%Y"),
quantity: quantity,
performer_id: sparc_line_item_fulfillment_audit.user_id,
service_id: fulfillment_line_item.service_id,
Expand Down Expand Up @@ -168,7 +168,7 @@ def create_fulfillment_participant(name_parts, sparc_subject, fulfillment_arm)
mrn: sparc_subject.mrn,
external_id: sparc_subject.external_subject_id,
status: STATUS_OPTIONS[sparc_subject.status],
date_of_birth: (sparc_subject.dob.present? ? sparc_subject.dob.strftime("%m-%d-%Y") : nil),
date_of_birth: (sparc_subject.dob.present? ? sparc_subject.dob.strftime("%m/%d/%Y") : nil),
gender: sparc_subject.gender.capitalize,
ethnicity: 'Unknown/Other/Unreported',
race: RACE_OPTIONS[sparc_subject.ethnicity],
Expand Down Expand Up @@ -276,7 +276,7 @@ def generate_procedures(sparc_procedure, fulfillment_appointment, quantity, bill
sparc_procedure_completed_by = sparc_procedure_completed_audit.user_id

fulfillment_procedure.status = 'complete'
fulfillment_procedure.completed_date = sparc_procedure_completed_date.strftime("%m-%d-%Y")
fulfillment_procedure.completed_date = sparc_procedure_completed_date.strftime("%m/%d/%Y")
fulfillment_procedure.service_cost = fulfillment_service.cost(fulfillment_procedure.protocol.sparc_funding_source, sparc_procedure_completed_date)
fulfillment_procedure.performer_id = sparc_procedure_completed_by
end
Expand Down

0 comments on commit 5fd60e0

Please sign in to comment.