Skip to content

Commit

Permalink
wth - RMID Functionalities - Part 1
Browse files Browse the repository at this point in the history
Add Research Master ID field and validate field to be number only and
for presence if the Human Subjects checkbox is checked. [#136737011]
  • Loading branch information
William Holt committed Jan 9, 2017
1 parent 52b13d2 commit 8a3838a
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 9 deletions.
9 changes: 9 additions & 0 deletions app/assets/javascripts/protocol_form.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@
# 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.

$(document).ready ->

$(document).on 'click', '.human-subjects', ->
if $('.rm-id').hasClass('required-field')
$('.rm-id').removeClass('required-field')
$('.has-human-subject-info').val('false')
else
$('.rm-id').addClass('required-field')
$('.has-human-subject-info').val('true')

# Protocol Edit Begin
$(document).on 'click', '#protocol-type-button', ->
protocol_id = $(this).data('protocol-id')
Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/protocol_form.sass
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@ textarea

.gray_note
color: gray

label.required-field:after
content: "*"

10 changes: 10 additions & 0 deletions app/models/protocol.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ class Protocol < ActiveRecord::Base
attr_accessible :type
attr_accessible :udak_project_number
attr_accessible :vertebrate_animals_info_attributes
attr_accessible :research_master_id
attr_accessible :has_human_subject_info

validates :research_master_id, numericality: { only_integer: true }, allow_blank: true

validates :research_master_id, presence: true, if: :has_human_subject_info?

attr_accessor :requester_id
attr_accessor :validate_nct
Expand Down Expand Up @@ -130,6 +136,10 @@ class Protocol < ActiveRecord::Base
validate :primary_pi_exists
end

def has_human_subject_info?
self.has_human_subject_info == true
end

scope :for_identity, -> (identity) {
joins(:project_roles).
where(project_roles: { identity_id: identity.id }).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
.form-group.row.human_subjects
= rt_form.label :human_subjects, t(:protocols)[:studies][:research_involving][:humans][:header], class: 'col-lg-2 control-label'
.col-lg-1
= rt_form.check_box :human_subjects, class: 'form-control'
= rt_form.check_box :human_subjects, class: 'form-control human-subjects'

/ Human Subjects selected begin
.human_subjects_dependent{ display_if(rt_form.object.human_subjects) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
.sub_text
= t(:protocols)[:studies][:information][:subtext]
.panel-body.container-fluid
.form-group.row
= form.label :research_master_id, class: 'col-lg-2 control-label rm-id' do
= link_to t(:protocols)[:studies][:information][:research_master_id], RESEARCH_MASTER_LINK
.col-lg-10
= form.text_field :research_master_id, class: 'form-control'
= form.hidden_field :has_human_subject_info, value: false, class: 'has-human-subject-info'

.form-group.row
= form.label :short_title, t(:protocols)[:studies][:information][:short_title], class: 'col-lg-2 control-label required'
.col-lg-10
Expand Down Expand Up @@ -96,4 +103,4 @@
= form.text_field :sponsor_name, class: 'form-control'
- if USE_EPIC
= render partial: 'protocols/form/study_form_sections/interactive_form', locals: { protocol: protocol, form: form }
= render partial: 'protocols/form/study_form_sections/study_type_note', locals: { protocol: protocol, form: form }
= render partial: 'protocols/form/study_form_sections/study_type_note', locals: { protocol: protocol, form: form }
2 changes: 2 additions & 0 deletions config/application.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ development:
system_satisfaction_survey_cc: 'amcates@gmail.com, catesa@musc.edu'
root_url: "https://andrews-mac-pro.thurmond-gazes.musc.edu"
dashboard_link: 'http://musc-pro.homelinux.net:3001/dashboard'
research_master_link: 'https://research-master-staging.musc.edu/'
create_an_account: false
header_link_1: http://sctr.musc.edu
header_link_2_proper: http://localhost:3000/
Expand Down Expand Up @@ -98,6 +99,7 @@ test:
system_satisfaction_survey_cc: 'amcates@gmail.com, catesa@musc.edu'
root_url: /
dashboard_link: /dashboard
research_master_link: 'https://research-master-staging.musc.edu/'
header_link_1: http://sctr.musc.edu
header_link_2_proper: http://localhost:3000/
header_link_2_dashboard: http://localhost:3000/dashboard
Expand Down
1 change: 1 addition & 0 deletions config/initializers/01_obis_setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
SYSTEM_SATISFACTION_SURVEY_CC = application_config['system_satisfaction_survey_cc']
ROOT_URL = application_config['root_url']
DASHBOARD_LINK = application_config['dashboard_link']
RESEARCH_MASTER_LINK = application_config['research_master_link']
HEADER_LINK_1 = application_config['header_link_1']
HEADER_LINK_2_PROPER = application_config['header_link_2_proper']
HEADER_LINK_2_DASHBOARD = application_config['header_link_2_dashboard']
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ en:
funding_source: "Funding Source:"
potential_funding_source: "Potential Funding Source:"
funding_source_internal: "Please Specify:"
research_master_id: "Research Master ID:"
funding_source_federal:
title: "Federal Grant Title:"
code: "Federal Grant Code:"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddResearchMasterIdToProtocols < ActiveRecord::Migration
def change
add_column :protocols, :research_master_id, :integer
end
end
5 changes: 5 additions & 0 deletions db/migrate/20170103201850_add_has_hs_info_to_protocols.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddHasHsInfoToProtocols < ActiveRecord::Migration
def change
add_column :protocols, :has_human_subject_info, :boolean
end
end
4 changes: 3 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20161122130742) do
ActiveRecord::Schema.define(version: 20170103201850) do

create_table "admin_rates", force: :cascade do |t|
t.integer "line_item_id", limit: 4
Expand Down Expand Up @@ -723,6 +723,8 @@
t.boolean "selected_for_epic"
t.boolean "archived", default: false
t.integer "study_type_question_group_id", limit: 4
t.integer "research_master_id", limit: 4
t.boolean "has_human_subject_info"
end

add_index "protocols", ["next_ssr_id"], name: "index_protocols_on_next_ssr_id", using: :btree
Expand Down
4 changes: 2 additions & 2 deletions spec/api/v1/protocols/get_protocol_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
parsed_body = JSON.parse(response.body)
expected_attributes = build(:protocol).attributes.
keys.
reject { |key| ['id', 'created_at', 'updated_at', 'deleted_at'].include?(key) }.
reject { |key| ['id', 'created_at', 'updated_at', 'deleted_at', 'research_master_id', 'has_human_subject_info'].include?(key) }.
push('callback_url', 'sparc_id').
sort

Expand All @@ -82,7 +82,7 @@
parsed_body = JSON.parse(response.body)
expected_attributes = build(:protocol).attributes.
keys.
reject { |key| ['id', 'created_at', 'updated_at', 'deleted_at'].include?(key) }.
reject { |key| ['id', 'created_at', 'updated_at', 'deleted_at', 'research_master_id', 'has_human_subject_info'].include?(key) }.
push('callback_url', 'sparc_id', 'arms', 'service_requests', 'project_roles', 'human_subjects_info').
sort

Expand Down
4 changes: 2 additions & 2 deletions spec/api/v1/protocols/get_protocols_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
parsed_body = JSON.parse(response.body)
expected_attributes = build(:protocol).attributes.
keys.
reject { |key| ['id', 'created_at', 'updated_at', 'deleted_at'].include?(key) }.
reject { |key| ['id', 'created_at', 'updated_at', 'deleted_at', 'research_master_id', 'has_human_subject_info'].include?(key) }.
push('callback_url', 'sparc_id').
sort

Expand All @@ -93,7 +93,7 @@
parsed_body = JSON.parse(response.body)
expected_attributes = build(:protocol).attributes.
keys.
reject { |key| ['id', 'created_at', 'updated_at', 'deleted_at'].include?(key) }.
reject { |key| ['id', 'created_at', 'updated_at', 'deleted_at', 'research_master_id', 'has_human_subject_info'].include?(key) }.
push('callback_url', 'sparc_id', 'arms', 'service_requests', 'project_roles', 'human_subjects_info').
sort

Expand Down
4 changes: 2 additions & 2 deletions spec/api/v1/protocols/get_protocols_with_ids_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
parsed_body = JSON.parse(response.body)
expected_attributes = build(:protocol).attributes.
keys.
reject { |key| ['id', 'created_at', 'updated_at', 'deleted_at'].include?(key) }.
reject { |key| ['id', 'created_at', 'updated_at', 'deleted_at', 'research_master_id', 'has_human_subject_info'].include?(key) }.
push('callback_url', 'sparc_id').
sort

Expand All @@ -94,7 +94,7 @@
parsed_body = JSON.parse(response.body)
expected_attributes = build(:protocol).attributes.
keys.
reject { |key| ['id', 'created_at', 'updated_at', 'deleted_at'].include?(key) }.
reject { |key| ['id', 'created_at', 'updated_at', 'deleted_at', 'research_master_id', 'has_human_subject_info'].include?(key) }.
push('callback_url', 'sparc_id', 'arms', 'service_requests', 'project_roles', 'human_subjects_info').
sort

Expand Down

0 comments on commit 8a3838a

Please sign in to comment.