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) De-identified Patient Features #512

Merged
merged 4 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
10 changes: 9 additions & 1 deletion app/assets/javascripts/patient_registry.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,12 @@ $ ->
type: 'DELETE'
url: "/participants/#{participant_id}"
data: 'protocol_id': $(this).attr('protocol_id')


### De-identified Patient ###
$('#patient-registry-table').on 'load-success.bs.table', ->
$rows = $('#patient-registry-table tr')
$rows.each (i, item) ->
$this = $(item)
if $(item).find("td.deidentified:contains('Yes')").length
$this.addClass 'deidentified_patient'
return
4 changes: 4 additions & 0 deletions app/assets/stylesheets/participants.sass
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS~
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR~
// TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.~
table#patient-registry-table tbody tr.deidentified_patient,
table#patient-registry-modal tbody tr.deidentified_patient
background-color: lightgrey
color: black

body.participants

Expand Down
4 changes: 3 additions & 1 deletion app/controllers/participants_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def index
def find_participants(action_name)
if action_name == "protocols_participants_in_protocol"
@participants = Participant.by_protocol_id(@protocol.id)
elsif action_name == "associate_participants_to_protocol"
@participants = Participant.able_to_be_associated
else
@participants = Participant.all
end
Expand Down Expand Up @@ -230,7 +232,7 @@ def find_protocols_participant
end

def participant_params
params.require(:participant).permit(:last_name, :first_name, :middle_initial, :mrn, :external_id,:date_of_birth, :gender, :ethnicity, :race, :address, :city, :state, :zipcode, :phone, :recruitment_source)
params.require(:participant).permit(:last_name, :first_name, :middle_initial, :mrn, :external_id,:date_of_birth, :gender, :ethnicity, :race, :address, :city, :state, :zipcode, :phone, :recruitment_source, :deidentified)
end

def protocols_participant_params
Expand Down
4 changes: 4 additions & 0 deletions app/helpers/participant_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ def notes_formatter(participant)
button_class: 'participant_notes'})
end

def deidentified_patient(participant)
participant.deidentified == false ? "No" : participant.deidentified == true ? "Yes" : "N/A"
end

def participant_report_formatter(protocols_participant)
icon_span = raw content_tag(:span, '', class: "glyphicon glyphicon-equalizer")
button = raw content_tag(:button, raw(icon_span), type: 'button', class: 'btn btn-default btn-xs report-button participant_report dropdown-toggle', id: "participant_report_#{protocols_participant.id.to_s}", 'aria-expanded' => 'false', title: 'Participant Report', 'data-title' => 'Participant Report', 'data-report_type' => 'participant_report', 'data-documentable_id' => protocols_participant.protocol_id, 'data-documentable_type' => 'Protocol', 'data-protocols_participant_id' => protocols_participant.id)
Expand Down
4 changes: 4 additions & 0 deletions app/models/participant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ class Participant < ApplicationRecord
scope :except_by_protocol_id, -> (protocol_id) {
joins(:protocols_participants).where("protocols_participants.protocol_id != ? ", protocol_id)
}
### A participant is marked as "de-identified" and has been associated to a protocol
scope :deidentified_true_and_associated_to_a_protocol, -> { where(deidentified: true).joins(:protocols_participants).ids }

scope :able_to_be_associated, -> { where(id: (Participant.all.ids - deidentified_true_and_associated_to_a_protocol).uniq) }

def self.title id
participant = Participant.find id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
%th{data: {class: 'first_name truncate', align: "left", sortable: "true", field: "first_middle"}}= t(:participant)[:first_name]
%th{data: {class: 'mrn truncate', align: "left", sortable: "true", field: "mrn"}}= t(:participant)[:mrn]
%th{data: {class: 'date_of_birth truncate', align: "left", sortable: "true", field: "date_of_birth"}}= t(:participant)[:dob]
%th{data: {class: 'deidentified truncate', align: "left", sortable: "true", field: "deidentified", visible: "true"}}= t(:participant)[:deidentified]
%th{data: {class: 'recruitment_source', align: "left", sortable: "true", field: "recruitment_source", visible: "false"}}= t(:participant)[:recruitment_source]
%th{data: {class: 'phone truncate', align: "left", sortable: "true", field: "phone"}}= t(:participant)[:phone_num]
.modal-footer
Expand Down
5 changes: 4 additions & 1 deletion app/views/participants/_participant_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS~
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR~
-# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.~

.modal-dialog
.modal-content
= form_for participant, {remote: true, html: {class: "form-horizontal new_participant", role: "form"}} do |p|
Expand All @@ -31,6 +30,10 @@
= render partial: 'required_fields'
.row
.col-md-12
.form-group
= p.label "deidentified", t(:patient)[:deidentified_patient], class: "col-sm-4 control-label"
.checkbox.col-sm-7
%label= p.check_box "deidentified"
.form-group
= p.label "last_name", t(:participant)[:last_name]+t(:actions)[:required], class: "col-sm-4 control-label"
.col-sm-7= p.text_field "last_name", {class: 'form-control'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,12 @@
$("#modal_area").html("<%= escape_javascript(render(:partial =>'participants/associate_participants_to_protocol_modal', locals: {protocol: @protocol})) %>");
$("#modal_place").modal 'show'
$("#patient-registry-modal").bootstrapTable()

### De-identified Patient ###
$('#patient-registry-modal').on 'load-success.bs.table', ->
$rows = $('#patient-registry-modal tr')
$rows.each (i, item) ->
$this = $(item)
if $(item).find("td.deidentified:contains('Yes')").length
$this.addClass 'deidentified_patient'
return
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ json.rows @participants do |participant|
json.gender participant.gender
json.ethnicity participant.ethnicity
json.race participant.race
json.deidentified deidentified_patient(participant)
json.address truncated_formatter(participant.address)
json.phone phoneNumberFormatter(participant)
json.edit registry_edit_formatter(participant)
Expand Down
1 change: 1 addition & 0 deletions app/views/participants/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
%th{data: {class: 'first_name truncate', align: "left", sortable: "true", field: "first_middle"}}= t(:participant)[:first_name]
%th{data: {class: 'mrn truncate', align: "left", sortable: "true", field: "mrn"}}= t(:participant)[:mrn]
%th{data: {class: 'date_of_birth truncate', align: "left", sortable: "true", field: "date_of_birth"}}= t(:participant)[:dob]
%th{data: {class: 'deidentified truncate', align: "left", sortable: "true", field: "deidentified", visible: "true"}}= t(:participant)[:deidentified]
%th{data: {class: 'recruitment_source', align: "left", sortable: "true", field: "recruitment_source", visible: "false"}}= t(:participant)[:recruitment_source]
%th{data: {class: 'details', align: "center", field: "details"}}= t(:actions)[:details]
%th{data: {class: 'edit', align: "center", field: "edit"}}= t(:actions)[:edit]
Expand Down
1 change: 1 addition & 0 deletions app/views/participants/index.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ json.rows @participants do |participant|
json.gender participant.gender
json.ethnicity participant.ethnicity
json.race participant.race
json.deidentified deidentified_patient(participant)
json.address truncated_formatter(participant.address)
json.phone phoneNumberFormatter(participant)
json.details registry_details_formatter(participant)
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ en:
city: "City"
details: "Participant Details"
dob: "Date of Birth"
deidentified: "De-identified"
ethnicity: "Ethnicity"
first_name: "First Name"
flash_messages:
Expand Down Expand Up @@ -373,6 +374,7 @@ en:
registry: "Patient Registry"
confirm_removal_part_1: "Are you sure you want to remove"
confirm_removal_part_2: "from Patient Registry?"
deidentified_patient: "De-identified Patient"

reports:
asc: "ASC"
Expand Down
25 changes: 25 additions & 0 deletions db/migrate/20190710135118_add_de_identified_to_participant.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright © 2011-2019 MUSC Foundation for Research Development~
# All rights reserved.~

# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:~

# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.~

# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following~
# disclaimer in the documentation and/or other materials provided with the distribution.~

# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products~
# derived from this software without specific prior written permission.~

# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,~
# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT~
# SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL~
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS~
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR~
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.~

class AddDeIdentifiedToParticipant < ActiveRecord::Migration[5.2]
def change
add_column :participants, :deidentified, :boolean, default: false
end
end
5 changes: 4 additions & 1 deletion lib/reports/participant_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ def generate(document)
csv << ["Gender", @gender]
end

header = [ "Participant ID" ]
header = ["Participant ID"]
header << "De-identified"
header << "First Name"
header << "Middle Initial"
header << "Last Name"
Expand All @@ -80,8 +81,10 @@ def generate(document)

csv << header
participants.find_each do |participant|
deidentified = participant.deidentified == false ? "No" : participant.deidentified == true ? "Yes" : "N/A"

data = [participant.id]
data << deidentified
data << participant.first_name
data << participant.middle_initial
data << participant.last_name
Expand Down