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

Jjh investigator #679

Merged
merged 2 commits into from
Sep 26, 2016
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: 10 additions & 0 deletions app/assets/javascripts/dashboard/protocol_form.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,16 @@ $(document).ready ->
else
$('#ind-on-hold-group').hide()
$('#protocol_investigational_products_info_attributes_ind_on_hold').attr('checked', false)

$(document).on 'change', 'input[name="protocol[investigational_products_info_attributes][exemption_type]"]', ->
$('.inv-device-number-field').appendTo($(this).closest('.row'))
$('#protocol_investigational_products_info_attributes_inv_device_number').removeClass('hidden')

$(document).on 'click', '.clear-inv-device-number-button', (event) ->
# prevent form submit?
event.preventDefault()
$('#protocol_investigational_products_info_attributes_exemption_type_').prop('checked', true)
$('#protocol_investigational_products_info_attributes_inv_device_number').addClass('hidden').val('')
###END INVESTIGATIONAL PRODUCTS FIELDS DISPLAY###


Expand Down
28 changes: 18 additions & 10 deletions app/assets/javascripts/studies.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ $(document).ready ->
'true' : ['.iacuc_number', '.name_of_iacuc', '.iacuc_approval_date',
'.iacuc_expiration_date']
'#study_research_types_info_attributes_investigational_products' :
'true' : ['.ind_number', '.ide_number']
'true' : ['.ind_number', '.inv_device_number']
'#study_research_types_info_attributes_ip_patents':
'true' : ['.patent_number', '.inventors']
'#study_investigational_products_info_attributes_ind_number':
'true' : ['.ind_on_hold']
'#study_impact_areas_attributes_6__destroy':
'true' : ['.impact_other']


FormFxManager.registerListeners($('.edit-project-view'), display_dependencies)

Expand All @@ -67,7 +67,7 @@ $(document).ready ->

$.prototype.hide_visual_error = () ->
this.removeClass('visual_error')
if $('.visual_error').length == 0
if $('.visual_error').length == 0
$('.study_type div').removeClass('field_with_errors')
if $('#errorExplanation ul li').size() == 1
$('#errorExplanation').remove()
Expand Down Expand Up @@ -110,7 +110,7 @@ $(document).ready ->
new_value = $(e.target).val()
if new_value == 'false'
$(higher_level_of_privacy_dropdown).show_elt()
else if new_value == 'true'
else if new_value == 'true'
$(higher_level_of_privacy_dropdown).hide_elt()
$(access_required_dropdown).hide_elt()
$(epic_inbasket_dropdown).hide_elt()
Expand All @@ -132,7 +132,7 @@ $(document).ready ->
$(research_active_dropdown).hide_elt()
$(restrict_sending_dropdown).hide_elt()
return

$(document).on 'change', access_required_dropdown, (e) ->
new_value = $(e.target).val()
if new_value == 'false' || new_value == nil
Expand All @@ -145,16 +145,16 @@ $(document).ready ->
$(restrict_sending_dropdown).hide_elt()
return

# When the epic box answers hit the validations with an unselected field,
# When the epic box answers hit the validations with an unselected field,
# the html.haml sets display to none for unselected fields
# So if the user has not filled out one of the
# required fields in the epic box, it will hit this code and display
# So if the user has not filled out one of the
# required fields in the epic box, it will hit this code and display
# the appropriate fields that need to be filled out with a visual cue of red border
if $('#errorExplanation ul li:contains("Study type answers")').length > 0
$(study_selected_for_epic_button).change()
if $(certificate_of_confidence_dropdown).is(':visible')
$(certificate_of_confidence_dropdown).change()
if $(higher_level_of_privacy_dropdown).val() == 'true'
if $(higher_level_of_privacy_dropdown).val() == 'true'
$(access_required_dropdown).show_elt()
$(higher_level_of_privacy_dropdown).change()
if $(higher_level_of_privacy_dropdown).val() == 'false'
Expand Down Expand Up @@ -248,9 +248,17 @@ $(document).ready ->
setupDatePicker('#iacuc_expiration_date', '#study_vertebrate_animals_info_attributes_iacuc_expiration_date')
$('#iacuc_expiration_date').attr("readOnly", true)

$(document).on 'change', 'input[name="study[investigational_products_info_attributes][exemption_type]"]', ->
$('#study_investigational_products_info_attributes_inv_device_number').removeClass('hidden')

$(document).on 'click', '.clear-inv-device-number-button', (event) ->
# prevent form submit?
event.preventDefault()
$('#study_investigational_products_info_attributes_exemption_type_').prop('checked', true)
$('#study_investigational_products_info_attributes_inv_device_number').addClass('hidden').val('')

#This is to disabled the submit after you click once, so you cant fire multiple posts at once.
$("form").submit ->
unless $('#study_research_types_info_attributes_human_subjects').is(':checked')
$('#study_human_subjects_info_attributes_nct_number').val('')
$('a.continue_button').unbind('click');

11 changes: 11 additions & 0 deletions app/assets/stylesheets/proper/protocols.sass
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,14 @@ h3.needed_info
.visual_error
border-color: red
border-width: 2px

.hidden
visibility: hidden

.clear-inv-device-number-button
display: block

.inv_device_number
input, label
display: inline !important
float: none !important
4 changes: 2 additions & 2 deletions app/controllers/dashboard/protocols_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def build_with_owner_params
service_providers = Identity.joins(:service_providers).where(service_providers: {
organization: Organization.authorized_for_identity(current_user.id) })
.distinct.order("last_name")

service_providers.map{|s| [s.last_name_first, s.id]}
end

Expand Down Expand Up @@ -262,7 +262,7 @@ def conditionally_activate_protocol
end
end

def convert_date_for_save attrs, date_field
def convert_date_for_save(attrs, date_field)
if attrs[date_field] && attrs[date_field].present?
attrs[date_field] = Time.strptime(attrs[date_field], "%m/%d/%Y")
end
Expand Down
16 changes: 14 additions & 2 deletions app/models/investigational_products_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# 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 InvestigationalProductsInfo < ActiveRecord::Base
EXEMPTION_TYPES = ["ide", "hde", "hud", ""].freeze
self.table_name = 'investigational_products_info'

audited
Expand All @@ -27,7 +28,18 @@ class InvestigationalProductsInfo < ActiveRecord::Base

attr_accessible :protocol_id
attr_accessible :ind_number
attr_accessible :ide_number
attr_accessible :inv_device_number
attr_accessible :exemption_type
attr_accessible :ind_on_hold
end

validates :exemption_type, inclusion: { in: EXEMPTION_TYPES, message: "not among #{EXEMPTION_TYPES.map(&:upcase).join(', ')}" }
validate :inv_device_number_present_when_exemption_type_present

private

def inv_device_number_present_when_exemption_type_present
if exemption_type.present? && inv_device_number.blank?
errors.add(:inv_device_number, "(#{exemption_type.upcase}#) can't be blank")
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,21 @@
.col-lg-1
= ip_form.check_box :ind_on_hold, class: 'form-control'

- InvestigationalProductsInfo::EXEMPTION_TYPES.each_with_index do |exemption_type, n|
/ Hide radio button for no exemption. There's a clear button for that.
.form-group.row.inv-device{ class: ("hidden" unless exemption_type.present?) }
.col-sm-2
.radio.pull-right
= ip_form.label :exemption_type do
= ip_form.radio_button :exemption_type, exemption_type
= t(:protocols)[:studies][:research_involving][:products][:numbers][exemption_type.to_sym]
- if exemption_type == ip_form.object.exemption_type
.col-sm-10.inv-device-number-field
= ip_form.text_field :inv_device_number, class: 'form-control'
.form-group.row
= ip_form.label :ide_number, t(:protocols)[:studies][:research_involving][:products][:ide_number], class: 'col-lg-2 control-label'
.col-lg-10
= ip_form.text_field :ide_number, class: 'form-control'
.col-sm-2
%button.btn.btn-danger.clear-inv-device-number-button.pull-right
= t(:protocols)[:studies][:research_involving][:products][:clear]
/ Investigational Products selected end

.form-group.row.ip_patents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,15 @@
%td
%label.col-lg-3
= t(:dashboard)[:protocols][:view_details][:studies][:research_involving][:products][:ind_on_hold]
.col-lg-
= products_info.ind_on_hold ? t(:constants)[:yes_select] : t(:constants)[:no_select]
%tr
%td
%label.col-lg-3

= t(:dashboard)[:protocols][:view_details][:studies][:research_involving][:products][:ide_number]
.col-lg-9
= products_info.ide_number
= products_info.ind_on_hold ? t(:constants)[:yes_select] : t(:constants)[:no_select]
- if products_info.exemption_type.present?
%tr
%td
%label.col-lg-3
= t(:dashboard)[:protocols][:view_details][:studies][:research_involving][:products][:numbers][products_info.exemption_type.to_sym]
.col-lg-9
= products_info.inv_device_number

/ IP/Patents
- if research_types_info.ip_patents
Expand Down
16 changes: 10 additions & 6 deletions app/views/studies/_fields.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
%legend= t(:study_form)[:epic]
.epic-questions
.field
= f.label :selected_for_epic, t(:study_form)[:push_to_epic]
= f.label :selected_for_epic, t(:study_form)[:push_to_epic]
-#= f.hidden_field :study_type_question_group_id, :value => study.study_type_question_group_id == StudyTypeQuestionGroup.where(active:false).pluck(:id).first ? 'inactive' : 'active'
%span.non_standard_usage_of_radio_buttons
= f.radio_button :selected_for_epic, true
Expand All @@ -111,7 +111,7 @@
= answer.label :answer, answer.object.study_type_question.question, class: "long"
= answer.select :answer, options_for_select([['Yes', true], ['No', false]], answer.object.answer), {include_blank: "Select One"}, id: "study_type_answer_#{answer.object.study_type_question.friendly_id}_answer"
= answer.hidden_field :study_type_question_id


%td.box-padding
&nbsp;
Expand Down Expand Up @@ -232,10 +232,14 @@
= ip.label :ind_on_hold, t(:study_form)[:ind_on_hold]
= ip.check_box :ind_on_hold

.field.ide_number
= ip.label :ide_number, t(:study_form)[:ide_number]
= ip.text_field :ide_number

.field.inv_device_number
- InvestigationalProductsInfo::EXEMPTION_TYPES.each_with_index do |exemption_type, n|
/ Hide radio button for no exemption. There's a clear button for that.
= ip.radio_button :exemption_type, exemption_type, class: ("hidden" unless exemption_type.present?)
= ip.label :exemption_type, t(:study_form)[:numbers][exemption_type.to_sym], class: ("hidden" unless exemption_type.present?)
= ip.text_field :inv_device_number, class: ['form-control', ("hidden" unless ip.object.exemption_type.present?)]
%button.clear-inv-device-number-button
= t(:study_form)[:clear]

= f.fields_for :research_types_info do |rt|
.field.ip_patents
Expand Down
19 changes: 17 additions & 2 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ en:
nct_number: "The NCT #"
protocol:
human_subjects_info: "The NCT #"
investigational_products_info:
inv_device_number: "Investigational device number"
admin_portal_title: "SPARC Request Administration"
application_title: "SPARCRequest"
bug_enhancement_link: "Report a bug or request an enhancement"
Expand Down Expand Up @@ -203,10 +205,14 @@ en:
iacuc_approval_date: "IACUC Approval Date:"
iacuc_expiration_date: "IACUC Expiration Date:"
products:
clear: "clear"
header: "Investigational Products:"
ind_number: "IND #:"
ind_on_hold: "IND on Hold?:"
ide_number: "IDE# / HDE# / HUD#:"
numbers:
ide: "IDE #:"
hde: "HDE #:"
hud: "HUD #:"
ip_patents:
header: "IP/Patents:"
number: "Patent Number:"
Expand Down Expand Up @@ -556,10 +562,15 @@ en:
iacuc_approval_date: "IACUC Approval Date:"
iacuc_expiration_date: "IACUC Expiration Date:"
products:
clear: "Clear"
header: "Investigational Products"
ind_number: "IND #:"
ind_on_hold: "IND on Hold?:"
ide_number: "IDE# / HDE# / HUD#:"
numbers:
ide: "IDE #:"
hde: "HDE #:"
hud: "HUD #:"
ip_patents:
header: "IP/Patents"
number: "Patent Number:"
Expand Down Expand Up @@ -1153,6 +1164,7 @@ en:
approval_pending: "Application/Approval Pending:"
study_type_questions: "Study type questions *"
attributes: "Study Attributes"
clear: "Clear"
code_blank: "Select a Federal Grant Code"
description: "Before you can complete a service request, please tell us more about your research study. This information will be used by our staff to decide the best way to process your request."
epic: "Epic Information"
Expand Down Expand Up @@ -1184,6 +1196,10 @@ en:
name_of_iacuc: "Name of IACUC:"
nct_number: "NCT# (National Clinical Trials Number):"
needed_info: "Information needed to obtain correct pricing"
numbers:
hde: "HDE #:"
hud: "HUD #:"
ide: "IDE #:"
optional_text: "Optional Information"
optional_text2: "(used for reporting purposes and saved for your future use)"
options: "Optional"
Expand Down Expand Up @@ -2093,4 +2109,3 @@ en:
message: "To begin to search and add authorized users to this study/project, type in the first or last name of the user. Select as appropriate."
search_box_header: "User Search"
search_placeholder: "Search for user..."

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class RenameIdeNumberToInvDeviceNumber < ActiveRecord::Migration
def up
rename_column :investigational_products_info, :ide_number, :inv_device_number
add_column :investigational_products_info, :exemption_type, :string, default: ""

InvestigationalProductsInfo.find_each do |inv|
if inv.inv_device_number.present?
inv.update(exemption_type: "ide")
end
end
end

def down
rename_column :investigational_products_info, :inv_device_number, :ide_number
remove_column :investigational_products_info, :exemption_type
end
end