Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JM - (SPARCFulfillment) Participant Report #511

Merged
merged 2 commits into from
Jul 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/views/reports/_participant_report.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
id: "gender_select",
title: "Select Gender"
.form-group.protocols-group
= label_tag "protocol", t(:reports)[:protocols], class: "col-sm-3 control-label"
= label_tag "protocol", t(:reports)[:not_required_protocols], class: "col-sm-3 control-label"
.col-sm-9#protocol_section.background_load
%i.dropdown-glyphicon.glyphicon.glyphicon-refresh.spin
.modal-footer
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ en:
participant_report: "Participant Report"
primary_pi: "Primary PI"
project_summary_report: "Project Summary Report"
not_required_protocols: "Protocol(s)"
protocols: "Protocol(s)*"
protocol_id: "Protocol ID"
request_report: "Request Report"
Expand Down
22 changes: 5 additions & 17 deletions lib/reports/participant_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ def generate(document)

conditions = {:mrn => @mrns, :gender => @gender, :date_of_birth => @start_date..@end_date}
conditions.delete_if {|k,v| !v.present? || v.to_s == ".." }
participants = Participant.where(conditions)
participants = Participant.where(conditions).distinct

if @protocols
participants = Participant.where(conditions).joins(:protocols_participants).where(protocol_id: @protocols)
participants = Participant.where(conditions).joins(:protocols_participants).where(protocol_id: @protocols).distinct
end

if @start_date || @gender || @mrns || @protocols
if @start_date || @gender
csv << ["Chosen Filters:"]
end

Expand All @@ -60,14 +60,6 @@ def generate(document)
csv << ["Gender", @gender]
end

if @mrns
csv << ["MRN's", @mrns.join(', ')]
end

if @protocols
csv << ["Protocols(Sparc ID)", Protocol.find(@protocols).map(&:sparc_id).join(', ')]
end

header = [ "Participant ID" ]
header << "First Name"
header << "Middle Initial"
Expand All @@ -80,31 +72,27 @@ def generate(document)
header << "Race"
header << "Address"
header << "Phone"
header << "Created At"
header << "Updated At"
header << "City"
header << "State"
header << "Zip"
header << "Recruitment Source"
header << "Protocol(s)"

csv << header

participants.find_each do |participant|

data = [participant.id]
data << participant.first_name
data << participant.middle_initial
data << participant.last_name
data << "'#{participant.mrn}"
data << "MRN: #{participant.mrn}"
data << participant.status
data << participant.date_of_birth
data << participant.gender
data << participant.ethnicity
data << participant.race
data << participant.address
data << participant.phone
data << participant.created_at
data << participant.updated_at
data << participant.city
data << participant.state
data << participant.zipcode
Expand Down