Skip to content

Commit

Permalink
Merge pull request #2377 from sparc-request/kg-multiple_irbs
Browse files Browse the repository at this point in the history
KG - Fix Reports Broken by Multiple IRB Changes
  • Loading branch information
Stuart-Johnson committed May 26, 2020
2 parents 612d312 + fce4bc9 commit 61ca9eb
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 21 deletions.
28 changes: 14 additions & 14 deletions app/lib/reports/protocols.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,21 @@ def default_options
def column_attrs
attrs = {}

attrs["Protocol ID"] = "service_request.try(:protocol).try(:id)"
attrs["Research Master ID"] = "service_request.try(:protocol).try(:research_master_id)"
attrs["Protocol Short Title"] = "service_request.try(:protocol).try(:short_title)"
attrs["Protocol Title"] = "service_request.try(:protocol).try(:title)"
attrs["Number of Requests"] = "service_request.try(:protocol).try(:sub_service_requests).try(:count)"
attrs["Funding Source"] = "service_request.try(:protocol).try(:funding_source)"
attrs["Protocol ID"] = "service_request.try(:protocol).try(:id)"
attrs["Research Master ID"] = "service_request.try(:protocol).try(:research_master_id)"
attrs["Protocol Short Title"] = "service_request.try(:protocol).try(:short_title)"
attrs["Protocol Title"] = "service_request.try(:protocol).try(:title)"
attrs["Number of Requests"] = "service_request.try(:protocol).try(:sub_service_requests).try(:length)"
attrs["Funding Source"] = "service_request.try(:protocol).try(:funding_source)"
attrs["Potential Funding Source"] = "service_request.try(:protocol).try(:potential_funding_source)"
attrs["Sponsor Name"] = "service_request.try(:protocol).try(:sponsor_name)"
attrs["Financial Account"] = "service_request.try(:protocol).try(:udak_project_number).try{prepend(' ')}"
attrs["Study Phase"] = "service_request.try(:protocol).try{study_phases.map(&:phase).join(', ')}"
attrs["Sponsor Name"] = "service_request.try(:protocol).try(:sponsor_name)"
attrs["Financial Account"] = "service_request.try(:protocol).try(:udak_project_number).try{prepend(' ')}"

attrs["NCT #"] = "service_request.try(:protocol).try(:human_subjects_info).try(:nct_number).try{prepend(' ')}"
attrs["PRO #"] = "service_request.try(:protocol).try(:human_subjects_info).try(:pro_number).try{prepend(' ')}"
attrs["IRB of Record"] = "service_request.try(:protocol).try(:human_subjects_info).try(:irb_of_record)"
attrs["IRB Expiration Date"] = "service_request.try(:protocol).try(:human_subjects_info).try(:irb_expiration_date)"
attrs["NCT #"] = "service_request.try(:protocol).try(:human_subjects_info).try(:nct_number).try{prepend(' ')}"
attrs["PRO #"] = "service_request.try(:protocol).try{irb_records.first}.try(:pro_number).try{prepend(' ')}"
attrs["IRB of Record"] = "service_request.try(:protocol).try{irb_records.first}.try(:irb_of_record)"
attrs["Study Phase"] = "service_request.try(:protocol).try{irb_records.first}.try{study_phases.map(&:phase).join(', ')}"
attrs["IRB Expiration Date"] = "service_request.try(:protocol).try{irb_records.first}.try(:irb_expiration_date).try(:strftime, '%D')"

attrs["Primary PI Last Name"] = "service_request.try(:protocol).try(:primary_pi).try(:last_name)"
attrs["Primary PI First Name"] = "service_request.try(:protocol).try(:primary_pi).try(:first_name)"
Expand Down Expand Up @@ -106,7 +106,7 @@ def table

# Other tables to include
def includes
[:organization, { service_request: { protocol: [:project_roles, :study_phases, :human_subjects_info, :investigational_products_info, primary_pi: { professional_organization: { parent: { parent: :parent } } }] } }, { line_items: :service }]
[:organization, { service_request: { protocol: [:sub_service_requests, :project_roles, :billing_managers, :coordinators, :human_subjects_info, :investigational_products_info, irb_records: :study_phases, primary_pi: { professional_organization: { parent: { parent: :parent } } }] } }, { line_items: :service }]
end

# Conditions
Expand Down
10 changes: 5 additions & 5 deletions app/lib/reports/service_requests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ def column_attrs

if params[:apr_data]
if params[:apr_data].include?("irb")
attrs["IRB Checked Y/N"] = "service_request.try(:protocol).try(:research_types_info).try(:human_subjects) ? \"Y\" : \"N\""
attrs["If true, PRO #)"] = "service_request.try(:protocol).try(:human_subjects_info).try(:pro_number)"
attrs["IRB Approval Date"] = "service_request.try(:protocol).try(:human_subjects_info).try(:irb_approval_date).try(:strftime, \"%D\")"
attrs["IRB Expiration Date"] = "service_request.try(:protocol).try(:human_subjects_info).try(:irb_expiration_date).try(:strftime, \"%D\")"
attrs["IRB Checked Y/N"] = "service_request.try(:protocol).try(:research_types_info).try(:human_subjects) ? 'Y' : 'N'"
attrs["If true, PRO #)"] = "service_request.try(:protocol).try{irb_records.first}.try(:pro_number)"
attrs["IRB Approval Date"] = "service_request.try(:protocol).try{irb_records.first}.try(:irb_approval_date).try(:strftime, '%D')"
attrs["IRB Expiration Date"] = "service_request.try(:protocol).try{irb_records.first}.try(:irb_expiration_date).try(:strftime, '%D')"
end
if params[:apr_data].include?("iacuc")
attrs["IACUC Checked Y/N"] = "service_request.try(:protocol).try(:research_types_info).try(:vertebrate_animals) ? \"Y\" : \"N\""
Expand Down Expand Up @@ -129,7 +129,7 @@ def table

# Other tables to include
def includes
return :organization, service_request: { protocol: { primary_pi: { professional_organization: { parent: { parent: :parent } } } }, line_items: :service }
return :organization, :owner, service_request: { protocol: [:coordinators, :irb_records, primary_pi: { professional_organization: { parent: { parent: :parent } } } ], line_items: :service }
end

# Conditions
Expand Down
6 changes: 5 additions & 1 deletion app/models/protocol.rb
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,11 @@ def billing_business_manager_email
end

def coordinator_emails
coordinators.pluck(:email).join(', ')
if self.coordinators.loaded?
coordinators.map(&:email).join(', ')
else
coordinators.pluck(:email).join(', ')
end
end

def emailed_associated_users
Expand Down
2 changes: 1 addition & 1 deletion app/models/sub_service_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def unset_effective_date_for_cost_calculations
end

def display_id
return "#{protocol.try(:id)}-#{ssr_id || 'DRAFT'}"
return "#{protocol_id}-#{ssr_id || 'DRAFT'}"
end

def has_subsidy?
Expand Down

0 comments on commit 61ca9eb

Please sign in to comment.