ccls-ccls_engine 3.11.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +182 -0
- data/app/models/abstract.rb +181 -0
- data/app/models/abstract_search.rb +50 -0
- data/app/models/abstract_validations.rb +324 -0
- data/app/models/address.rb +70 -0
- data/app/models/address_type.rb +15 -0
- data/app/models/addressing.rb +147 -0
- data/app/models/aliquot.rb +44 -0
- data/app/models/aliquot_sample_format.rb +13 -0
- data/app/models/analysis.rb +14 -0
- data/app/models/bc_request.rb +20 -0
- data/app/models/candidate_control.rb +101 -0
- data/app/models/context.rb +23 -0
- data/app/models/context_data_source.rb +4 -0
- data/app/models/county.rb +16 -0
- data/app/models/data_source.rb +24 -0
- data/app/models/diagnosis.rb +23 -0
- data/app/models/document_type.rb +16 -0
- data/app/models/document_version.rb +27 -0
- data/app/models/enrollment.rb +78 -0
- data/app/models/enrollment_validations.rb +167 -0
- data/app/models/follow_up.rb +16 -0
- data/app/models/follow_up_type.rb +18 -0
- data/app/models/gift_card.rb +22 -0
- data/app/models/gift_card_search.rb +137 -0
- data/app/models/home_exposure_response.rb +24 -0
- data/app/models/homex_outcome.rb +75 -0
- data/app/models/hospital.rb +22 -0
- data/app/models/icf_master_id.rb +30 -0
- data/app/models/icf_master_tracker.rb +217 -0
- data/app/models/icf_master_tracker_change.rb +9 -0
- data/app/models/icf_master_tracker_update.rb +50 -0
- data/app/models/ineligible_reason.rb +26 -0
- data/app/models/instrument.rb +26 -0
- data/app/models/instrument_type.rb +17 -0
- data/app/models/instrument_version.rb +28 -0
- data/app/models/interview.rb +122 -0
- data/app/models/interview_method.rb +17 -0
- data/app/models/interview_outcome.rb +16 -0
- data/app/models/language.rb +28 -0
- data/app/models/live_birth_data_update.rb +142 -0
- data/app/models/operational_event.rb +99 -0
- data/app/models/operational_event_type.rb +31 -0
- data/app/models/organization.rb +28 -0
- data/app/models/patient.rb +63 -0
- data/app/models/patient_validations.rb +118 -0
- data/app/models/person.rb +28 -0
- data/app/models/phone_number.rb +105 -0
- data/app/models/phone_type.rb +15 -0
- data/app/models/project.rb +39 -0
- data/app/models/project_outcome.rb +19 -0
- data/app/models/race.rb +31 -0
- data/app/models/refusal_reason.rb +23 -0
- data/app/models/sample.rb +168 -0
- data/app/models/sample_kit.rb +14 -0
- data/app/models/sample_outcome.rb +16 -0
- data/app/models/sample_temperature.rb +14 -0
- data/app/models/sample_type.rb +37 -0
- data/app/models/search.rb +195 -0
- data/app/models/section.rb +18 -0
- data/app/models/state.rb +25 -0
- data/app/models/study_subject.rb +237 -0
- data/app/models/study_subject_abstracts.rb +47 -0
- data/app/models/study_subject_addresses.rb +34 -0
- data/app/models/study_subject_associations.rb +38 -0
- data/app/models/study_subject_duplicates.rb +111 -0
- data/app/models/study_subject_enrollments.rb +17 -0
- data/app/models/study_subject_homex_outcome.rb +22 -0
- data/app/models/study_subject_identifier.rb +153 -0
- data/app/models/study_subject_interviews.rb +25 -0
- data/app/models/study_subject_languages.rb +21 -0
- data/app/models/study_subject_operational_events.rb +66 -0
- data/app/models/study_subject_patient.rb +177 -0
- data/app/models/study_subject_pii.rb +74 -0
- data/app/models/study_subject_races.rb +25 -0
- data/app/models/study_subject_search.rb +260 -0
- data/app/models/study_subject_validations.rb +116 -0
- data/app/models/subject_language.rb +11 -0
- data/app/models/subject_race.rb +11 -0
- data/app/models/subject_relationship.rb +21 -0
- data/app/models/subject_type.rb +22 -0
- data/app/models/tracing_status.rb +20 -0
- data/app/models/transfer.rb +40 -0
- data/app/models/unit.rb +14 -0
- data/app/models/vital_status.rb +19 -0
- data/app/models/zip_code.rb +36 -0
- data/config/abstract_fields.yml +1038 -0
- data/config/abstract_sections.yml +77 -0
- data/config/home_exposure_response_fields.yml +583 -0
- data/config/icf_master_tracker_update.yml +56 -0
- data/config/live_birth_data_update.yml +56 -0
- data/config/shared_use_db.yml +4 -0
- data/generators/ccls_engine/USAGE +2 -0
- data/generators/ccls_engine/ccls_engine_generator.rb +123 -0
- data/generators/ccls_engine/templates/autotest_ccls_engine.rb +3 -0
- data/generators/ccls_engine/templates/ccls_engine.rake +12 -0
- data/generators/ccls_engine/templates/fixtures/address_types.yml +30 -0
- data/generators/ccls_engine/templates/fixtures/context_data_sources.yml +54 -0
- data/generators/ccls_engine/templates/fixtures/contexts.yml +19 -0
- data/generators/ccls_engine/templates/fixtures/data_sources.yml +40 -0
- data/generators/ccls_engine/templates/fixtures/diagnoses.yml +40 -0
- data/generators/ccls_engine/templates/fixtures/document_types.yml +65 -0
- data/generators/ccls_engine/templates/fixtures/document_versions.csv +155 -0
- data/generators/ccls_engine/templates/fixtures/follow_up_types.yml +16 -0
- data/generators/ccls_engine/templates/fixtures/hospitals.yml +114 -0
- data/generators/ccls_engine/templates/fixtures/ineligible_reasons.yml +35 -0
- data/generators/ccls_engine/templates/fixtures/instrument_types.yml +26 -0
- data/generators/ccls_engine/templates/fixtures/instrument_versions.yml +22 -0
- data/generators/ccls_engine/templates/fixtures/instruments.yml +22 -0
- data/generators/ccls_engine/templates/fixtures/interview_methods.yml +30 -0
- data/generators/ccls_engine/templates/fixtures/interview_outcomes.yml +31 -0
- data/generators/ccls_engine/templates/fixtures/languages.yml +34 -0
- data/generators/ccls_engine/templates/fixtures/operational_event_types.yml +141 -0
- data/generators/ccls_engine/templates/fixtures/organizations.yml +198 -0
- data/generators/ccls_engine/templates/fixtures/people.yml +130 -0
- data/generators/ccls_engine/templates/fixtures/phone_types.yml +30 -0
- data/generators/ccls_engine/templates/fixtures/project_outcomes.yml +25 -0
- data/generators/ccls_engine/templates/fixtures/projects.yml +59 -0
- data/generators/ccls_engine/templates/fixtures/races.yml +52 -0
- data/generators/ccls_engine/templates/fixtures/refusal_reasons.yml +55 -0
- data/generators/ccls_engine/templates/fixtures/sample_outcomes.yml +36 -0
- data/generators/ccls_engine/templates/fixtures/sample_temperatures.yml +16 -0
- data/generators/ccls_engine/templates/fixtures/sample_types.yml +147 -0
- data/generators/ccls_engine/templates/fixtures/sections.yml +31 -0
- data/generators/ccls_engine/templates/fixtures/states.yml +363 -0
- data/generators/ccls_engine/templates/fixtures/subject_relationships.yml +46 -0
- data/generators/ccls_engine/templates/fixtures/subject_types.yml +30 -0
- data/generators/ccls_engine/templates/fixtures/tracing_statuses.yml +30 -0
- data/generators/ccls_engine/templates/fixtures/units.yml +13 -0
- data/generators/ccls_engine/templates/fixtures/vital_statuses.yml +28 -0
- data/generators/ccls_engine/templates/functional/roles_controller_test.rb +142 -0
- data/generators/ccls_engine/templates/functional/sessions_controller_test.rb +19 -0
- data/generators/ccls_engine/templates/functional/users_controller_test.rb +94 -0
- data/generators/ccls_engine/templates/images/sort_down.png +0 -0
- data/generators/ccls_engine/templates/images/sort_up.png +0 -0
- data/generators/ccls_engine/templates/initializer.rb +28 -0
- data/generators/ccls_engine/templates/javascripts/ccls_engine.js +24 -0
- data/generators/ccls_engine/templates/javascripts/jquery-ui.js +763 -0
- data/generators/ccls_engine/templates/javascripts/jquery.js +154 -0
- data/generators/ccls_engine/templates/javascripts/jrails.js +1 -0
- data/generators/ccls_engine/templates/migrations/create_user_invitations.rb +18 -0
- data/generators/ccls_engine/templates/migrations/create_users.rb +33 -0
- data/generators/ccls_engine/templates/migrations/drop_user_invitations.rb +18 -0
- data/generators/ccls_engine/templates/stylesheets/ccls_engine.css +180 -0
- data/generators/ccls_engine/templates/stylesheets/user.css +35 -0
- data/generators/ccls_engine/templates/stylesheets/users.css +23 -0
- data/generators/ccls_engine/templates/unit/core_extension_test.rb +18 -0
- data/generators/ccls_engine/templates/unit/role_test.rb +30 -0
- data/generators/ccls_engine/templates/unit/user_test.rb +321 -0
- data/lib/ccls-ccls_engine.rb +1 -0
- data/lib/ccls_engine.rb +135 -0
- data/lib/ccls_engine/action_view_extension.rb +3 -0
- data/lib/ccls_engine/action_view_extension/base.rb +53 -0
- data/lib/ccls_engine/action_view_extension/form_builder.rb +39 -0
- data/lib/ccls_engine/active_record_extension.rb +2 -0
- data/lib/ccls_engine/active_record_extension/base.rb +70 -0
- data/lib/ccls_engine/active_record_shared.rb +8 -0
- data/lib/ccls_engine/assertions.rb +69 -0
- data/lib/ccls_engine/autotest.rb +54 -0
- data/lib/ccls_engine/ccls_user.rb +117 -0
- data/lib/ccls_engine/core_extension.rb +14 -0
- data/lib/ccls_engine/date_and_time_formats.rb +30 -0
- data/lib/ccls_engine/factories.rb +880 -0
- data/lib/ccls_engine/factory_test_helper.rb +276 -0
- data/lib/ccls_engine/helper.rb +112 -0
- data/lib/ccls_engine/icf_master_tracker_update_test_helper.rb +121 -0
- data/lib/ccls_engine/live_birth_data_update_test_helper.rb +110 -0
- data/lib/ccls_engine/package_test_helper.rb +49 -0
- data/lib/ccls_engine/shared_database.rb +20 -0
- data/lib/ccls_engine/tasks.rb +1 -0
- data/lib/ccls_engine/test_tasks.rb +52 -0
- data/lib/ccls_engine/translation_table.rb +86 -0
- data/lib/shared_migration.rb +5 -0
- data/lib/surveyor/survey_extensions.rb +125 -0
- data/lib/tasks/application.rake +286 -0
- data/lib/tasks/calnet_authenticated.rake +6 -0
- data/lib/tasks/common_lib.rake +7 -0
- data/lib/tasks/database.rake +288 -0
- data/lib/tasks/documentation.rake +71 -0
- data/lib/tasks/homex_import.rake +723 -0
- data/lib/tasks/odms_import.rake +1116 -0
- data/lib/tasks/simply_authorized.rake +6 -0
- data/lib/tasks/ucb_ccls_engine_tasks.rake +4 -0
- data/lib/tasks/use_db.rake +4 -0
- data/rails/init.rb +4 -0
- data/test/unit/ccls/abstract_search_test.rb +150 -0
- data/test/unit/ccls/abstract_test.rb +674 -0
- data/test/unit/ccls/address_test.rb +155 -0
- data/test/unit/ccls/address_type_test.rb +25 -0
- data/test/unit/ccls/addressing_test.rb +466 -0
- data/test/unit/ccls/aliquot_sample_format_test.rb +20 -0
- data/test/unit/ccls/aliquot_test.rb +156 -0
- data/test/unit/ccls/analysis_test.rb +31 -0
- data/test/unit/ccls/bc_request_test.rb +43 -0
- data/test/unit/ccls/candidate_control_test.rb +712 -0
- data/test/unit/ccls/context_data_source_test.rb +26 -0
- data/test/unit/ccls/context_test.rb +40 -0
- data/test/unit/ccls/core_extension_test.rb +17 -0
- data/test/unit/ccls/county_test.rb +34 -0
- data/test/unit/ccls/data_source_test.rb +41 -0
- data/test/unit/ccls/diagnosis_test.rb +51 -0
- data/test/unit/ccls/document_type_test.rb +35 -0
- data/test/unit/ccls/document_version_test.rb +68 -0
- data/test/unit/ccls/enrollment_test.rb +575 -0
- data/test/unit/ccls/follow_up_test.rb +23 -0
- data/test/unit/ccls/follow_up_type_test.rb +34 -0
- data/test/unit/ccls/gift_card_search_test.rb +153 -0
- data/test/unit/ccls/gift_card_test.rb +40 -0
- data/test/unit/ccls/home_exposure_response_test.rb +83 -0
- data/test/unit/ccls/homex_outcome_test.rb +199 -0
- data/test/unit/ccls/hospital_test.rb +102 -0
- data/test/unit/ccls/icf_master_id_test.rb +30 -0
- data/test/unit/ccls/icf_master_tracker_change_test.rb +14 -0
- data/test/unit/ccls/icf_master_tracker_test.rb +132 -0
- data/test/unit/ccls/icf_master_tracker_update_test.rb +176 -0
- data/test/unit/ccls/ineligible_reason_test.rb +48 -0
- data/test/unit/ccls/instrument_test.rb +62 -0
- data/test/unit/ccls/instrument_type_test.rb +39 -0
- data/test/unit/ccls/instrument_version_test.rb +71 -0
- data/test/unit/ccls/interview_method_test.rb +44 -0
- data/test/unit/ccls/interview_outcome_test.rb +34 -0
- data/test/unit/ccls/interview_test.rb +298 -0
- data/test/unit/ccls/language_test.rb +47 -0
- data/test/unit/ccls/live_birth_data_update_test.rb +358 -0
- data/test/unit/ccls/operational_event_test.rb +187 -0
- data/test/unit/ccls/operational_event_type_test.rb +51 -0
- data/test/unit/ccls/organization_test.rb +64 -0
- data/test/unit/ccls/patient_test.rb +538 -0
- data/test/unit/ccls/person_test.rb +55 -0
- data/test/unit/ccls/phone_number_test.rb +244 -0
- data/test/unit/ccls/phone_type_test.rb +32 -0
- data/test/unit/ccls/project_outcome_test.rb +34 -0
- data/test/unit/ccls/project_test.rb +60 -0
- data/test/unit/ccls/race_test.rb +37 -0
- data/test/unit/ccls/refusal_reason_test.rb +52 -0
- data/test/unit/ccls/role_test.rb +26 -0
- data/test/unit/ccls/sample_kit_test.rb +35 -0
- data/test/unit/ccls/sample_outcome_test.rb +34 -0
- data/test/unit/ccls/sample_temperature_test.rb +25 -0
- data/test/unit/ccls/sample_test.rb +363 -0
- data/test/unit/ccls/sample_type_test.rb +58 -0
- data/test/unit/ccls/section_test.rb +34 -0
- data/test/unit/ccls/state_test.rb +31 -0
- data/test/unit/ccls/study_subject_abstracts_test.rb +115 -0
- data/test/unit/ccls/study_subject_addresses_test.rb +93 -0
- data/test/unit/ccls/study_subject_duplicates_test.rb +407 -0
- data/test/unit/ccls/study_subject_enrollments_test.rb +65 -0
- data/test/unit/ccls/study_subject_homex_outcome_test.rb +64 -0
- data/test/unit/ccls/study_subject_identifier_test.rb +439 -0
- data/test/unit/ccls/study_subject_interviews_test.rb +26 -0
- data/test/unit/ccls/study_subject_languages_test.rb +142 -0
- data/test/unit/ccls/study_subject_operational_events_test.rb +53 -0
- data/test/unit/ccls/study_subject_patient_test.rb +249 -0
- data/test/unit/ccls/study_subject_pii_test.rb +278 -0
- data/test/unit/ccls/study_subject_races_test.rb +203 -0
- data/test/unit/ccls/study_subject_search_test.rb +704 -0
- data/test/unit/ccls/study_subject_test.rb +770 -0
- data/test/unit/ccls/subject_language_test.rb +43 -0
- data/test/unit/ccls/subject_race_test.rb +35 -0
- data/test/unit/ccls/subject_relationship_test.rb +43 -0
- data/test/unit/ccls/subject_type_test.rb +40 -0
- data/test/unit/ccls/tracing_status_test.rb +32 -0
- data/test/unit/ccls/transfer_test.rb +81 -0
- data/test/unit/ccls/translation_table_test.rb +40 -0
- data/test/unit/ccls/unit_test.rb +21 -0
- data/test/unit/ccls/user_test.rb +156 -0
- data/test/unit/ccls/vital_status_test.rb +36 -0
- data/test/unit/ccls/zip_code_test.rb +55 -0
- metadata +633 -0
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Ccls::StudySubjectEnrollmentsTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
test "should create study_subject and accept_nested_attributes_for enrollments" do
|
6
|
+
assert_difference( 'Enrollment.count', 2) { # ccls enrollment is auto-created, so 2
|
7
|
+
assert_difference( "StudySubject.count", 1 ) {
|
8
|
+
study_subject = create_study_subject(
|
9
|
+
:enrollments_attributes => [Factory.attributes_for(:enrollment,
|
10
|
+
:project_id => Project['non-specific'].id)])
|
11
|
+
assert !study_subject.new_record?,
|
12
|
+
"#{study_subject.errors.full_messages.to_sentence}"
|
13
|
+
} }
|
14
|
+
end
|
15
|
+
|
16
|
+
test "should NOT destroy enrollments with study_subject" do
|
17
|
+
assert_difference('StudySubject.count',1) {
|
18
|
+
assert_difference('Enrollment.count',2) { # due to the callback creation of ccls enrollment
|
19
|
+
@study_subject = Factory(:enrollment).study_subject
|
20
|
+
} }
|
21
|
+
assert_difference('StudySubject.count',-1) {
|
22
|
+
assert_difference('Enrollment.count',0) {
|
23
|
+
@study_subject.destroy
|
24
|
+
} }
|
25
|
+
end
|
26
|
+
|
27
|
+
test "should return nil hx_enrollment if not enrolled" do
|
28
|
+
study_subject = create_study_subject
|
29
|
+
assert_nil study_subject.enrollments.find_by_project_id(
|
30
|
+
Project['HomeExposures'].id)
|
31
|
+
end
|
32
|
+
|
33
|
+
test "should return valid hx_enrollment if enrolled" do
|
34
|
+
study_subject = create_study_subject
|
35
|
+
hxe = Factory(:enrollment,
|
36
|
+
:study_subject => study_subject,
|
37
|
+
:project => Project['HomeExposures']
|
38
|
+
)
|
39
|
+
assert_not_nil study_subject.enrollments.find_by_project_id(
|
40
|
+
Project['HomeExposures'].id)
|
41
|
+
end
|
42
|
+
|
43
|
+
test "should create ccls project enrollment on creation" do
|
44
|
+
study_subject = nil
|
45
|
+
assert_difference('Project.count',0) { # make sure it didn't create id
|
46
|
+
assert_difference('Enrollment.count',1) {
|
47
|
+
assert_difference('StudySubject.count',1) {
|
48
|
+
study_subject = create_study_subject
|
49
|
+
} } }
|
50
|
+
assert_not_nil study_subject.enrollments.find_by_project_id(Project['ccls'].id)
|
51
|
+
end
|
52
|
+
|
53
|
+
test "should only create 1 ccls project enrollment on creation if given one" do
|
54
|
+
study_subject = nil
|
55
|
+
assert_difference('Project.count',0) { # make sure it didn't create id
|
56
|
+
assert_difference('Enrollment.count',1) {
|
57
|
+
assert_difference('StudySubject.count',1) {
|
58
|
+
study_subject = create_study_subject(:enrollments_attributes => [
|
59
|
+
{ :project_id => Project['ccls'].id }
|
60
|
+
])
|
61
|
+
} } }
|
62
|
+
assert_not_nil study_subject.enrollments.find_by_project_id(Project['ccls'].id)
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Ccls::StudySubjectHomexOutcomeTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
test "should create study_subject and accept_nested_attributes_for homex_outcome" do
|
6
|
+
assert_difference( 'HomexOutcome.count', 1) {
|
7
|
+
assert_difference( "StudySubject.count", 1 ) {
|
8
|
+
study_subject = create_study_subject(
|
9
|
+
:homex_outcome_attributes => Factory.attributes_for(:homex_outcome))
|
10
|
+
assert !study_subject.new_record?,
|
11
|
+
"#{study_subject.errors.full_messages.to_sentence}"
|
12
|
+
} }
|
13
|
+
end
|
14
|
+
|
15
|
+
# StudySubject currently accepts nested attributes for homex_outcome,
|
16
|
+
# but an empty homex_outcome is no longer invalid.
|
17
|
+
test "should create study_subject with empty homex_outcome" do
|
18
|
+
assert_difference( 'HomexOutcome.count', 1) {
|
19
|
+
assert_difference( 'StudySubject.count', 1) {
|
20
|
+
study_subject = create_study_subject( :homex_outcome_attributes => {})
|
21
|
+
} }
|
22
|
+
end
|
23
|
+
|
24
|
+
test "should NOT destroy homex_outcome with study_subject" do
|
25
|
+
assert_difference('StudySubject.count',1) {
|
26
|
+
assert_difference('HomexOutcome.count',1) {
|
27
|
+
@study_subject = Factory(:study_subject)
|
28
|
+
Factory(:homex_outcome, :study_subject => @study_subject)
|
29
|
+
} }
|
30
|
+
assert_difference('StudySubject.count',-1) {
|
31
|
+
assert_difference('HomexOutcome.count',0) {
|
32
|
+
@study_subject.destroy
|
33
|
+
} }
|
34
|
+
end
|
35
|
+
|
36
|
+
# Delegated homex_outcome fields
|
37
|
+
%w( interview_outcome sample_outcome
|
38
|
+
interview_outcome_on sample_outcome_on
|
39
|
+
).each do |method_name|
|
40
|
+
|
41
|
+
test "should respond to #{method_name}" do
|
42
|
+
study_subject = create_study_subject
|
43
|
+
assert study_subject.respond_to?(method_name)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
# Delegated homex_outcome fields except ... interview_outcome, sample_outcome
|
49
|
+
%w( interview_outcome_on sample_outcome_on ).each do |method_name|
|
50
|
+
|
51
|
+
test "should return nil #{method_name} without homex_outcome" do
|
52
|
+
study_subject = create_study_subject
|
53
|
+
assert_nil study_subject.send(method_name)
|
54
|
+
end
|
55
|
+
|
56
|
+
test "should return #{method_name} with homex_outcome" do
|
57
|
+
study_subject = create_study_subject(
|
58
|
+
:homex_outcome_attributes => Factory.attributes_for(:homex_outcome))
|
59
|
+
assert_not_nil study_subject.send(method_name)
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,439 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
# This is just a collection of identifier related tests
|
4
|
+
# for StudySubject separated only for clarity due
|
5
|
+
# to the size of the StudySubjectTest class.
|
6
|
+
class Ccls::StudySubjectIdentifierTest < ActiveSupport::TestCase
|
7
|
+
|
8
|
+
test "studyid should be patid, case_control_type and orderno" do
|
9
|
+
StudySubject.any_instance.stubs(:get_next_patid).returns('123')
|
10
|
+
study_subject = Factory(:case_study_subject)
|
11
|
+
assert study_subject.is_case?
|
12
|
+
assert_not_nil study_subject.studyid
|
13
|
+
assert_nil study_subject.studyid_nohyphen
|
14
|
+
assert_nil study_subject.studyid_intonly_nohyphen
|
15
|
+
assert_equal "0123-C-0", study_subject.studyid
|
16
|
+
end
|
17
|
+
|
18
|
+
test "should create study subject with specified matchingid" do
|
19
|
+
# just to make sure that this method is defined
|
20
|
+
# get funny errors when accidentally comment out.
|
21
|
+
assert_difference('StudySubject.count',1) {
|
22
|
+
study_subject = create_study_subject(:matchingid => '54321')
|
23
|
+
assert_equal '054321', study_subject.matchingid
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
test "should not assign icf_master_id when there are none" do
|
28
|
+
study_subject = Factory(:study_subject, :icf_master_id => nil)
|
29
|
+
study_subject.assign_icf_master_id
|
30
|
+
assert_nil study_subject.icf_master_id
|
31
|
+
end
|
32
|
+
|
33
|
+
test "should not assign icf_master_id if already have one and one exists" do
|
34
|
+
study_subject = Factory(:study_subject)
|
35
|
+
assert_nil study_subject.reload.icf_master_id
|
36
|
+
imi1 = Factory(:icf_master_id,:icf_master_id => '12345678A')
|
37
|
+
study_subject.assign_icf_master_id
|
38
|
+
assert_equal imi1.icf_master_id, study_subject.reload.icf_master_id
|
39
|
+
imi2 = Factory(:icf_master_id,:icf_master_id => '12345678B')
|
40
|
+
study_subject.assign_icf_master_id
|
41
|
+
assert_equal imi1.icf_master_id, study_subject.reload.icf_master_id
|
42
|
+
end
|
43
|
+
|
44
|
+
test "should assign icf_master_id when there is one" do
|
45
|
+
study_subject = create_study_subject
|
46
|
+
imi = Factory(:icf_master_id,:icf_master_id => '12345678A')
|
47
|
+
study_subject.assign_icf_master_id
|
48
|
+
assert_not_nil study_subject.icf_master_id
|
49
|
+
assert_equal '12345678A', study_subject.icf_master_id
|
50
|
+
imi.reload
|
51
|
+
assert_not_nil imi.assigned_on
|
52
|
+
assert_equal Date.today, imi.assigned_on
|
53
|
+
assert_not_nil imi.study_subject_id
|
54
|
+
assert_equal imi.study_subject_id, study_subject.id
|
55
|
+
end
|
56
|
+
|
57
|
+
test "should assign icf_master_id to mother on creation if one exists" do
|
58
|
+
study_subject = create_study_subject
|
59
|
+
imi = Factory(:icf_master_id,:icf_master_id => '12345678A')
|
60
|
+
assert_equal '12345678A', imi.icf_master_id
|
61
|
+
mother = study_subject.create_mother
|
62
|
+
assert_not_nil mother.reload.icf_master_id
|
63
|
+
assert_equal '12345678A', mother.icf_master_id
|
64
|
+
end
|
65
|
+
|
66
|
+
test "should not assign icf_master_id to mother on creation if none exist" do
|
67
|
+
study_subject = create_study_subject
|
68
|
+
mother = study_subject.create_mother
|
69
|
+
assert_nil mother.reload.icf_master_id
|
70
|
+
end
|
71
|
+
|
72
|
+
test "should return 'no ID assigned' if study_subject has no icf_master_id" do
|
73
|
+
study_subject = create_study_subject
|
74
|
+
assert_nil study_subject.icf_master_id
|
75
|
+
assert_equal study_subject.icf_master_id_to_s, '[no ID assigned]'
|
76
|
+
end
|
77
|
+
|
78
|
+
test "should return icf_master_id if study_subject has icf_master_id" do
|
79
|
+
study_subject = create_study_subject
|
80
|
+
assert_nil study_subject.icf_master_id
|
81
|
+
assert_equal study_subject.icf_master_id_to_s, '[no ID assigned]'
|
82
|
+
imi = Factory(:icf_master_id,:icf_master_id => '12345678A')
|
83
|
+
study_subject.assign_icf_master_id
|
84
|
+
assert_not_nil study_subject.icf_master_id
|
85
|
+
assert_equal study_subject.icf_master_id, imi.icf_master_id
|
86
|
+
assert_equal study_subject.icf_master_id_to_s, imi.icf_master_id
|
87
|
+
end
|
88
|
+
|
89
|
+
test "should require unique icf_master_id" do
|
90
|
+
assert_difference('StudySubject.count',1){
|
91
|
+
Factory(:study_subject, :icf_master_id => 'Fake1234')
|
92
|
+
}
|
93
|
+
assert_difference('StudySubject.count',0){
|
94
|
+
study_subject = Factory.build(:study_subject, :icf_master_id => 'Fake1234')
|
95
|
+
study_subject.save
|
96
|
+
assert study_subject.errors.on_attr_and_type?(:icf_master_id, :taken)
|
97
|
+
}
|
98
|
+
end
|
99
|
+
|
100
|
+
test "should nullify blank state_id_no before validation" do
|
101
|
+
study_subject = Factory.build(:study_subject, :state_id_no => '')
|
102
|
+
assert study_subject.state_id_no.blank?
|
103
|
+
assert !study_subject.state_id_no.nil?
|
104
|
+
study_subject.valid?
|
105
|
+
assert study_subject.state_id_no.blank?
|
106
|
+
assert study_subject.state_id_no.nil?
|
107
|
+
end
|
108
|
+
|
109
|
+
test "should nullify blank state_registrar_no before validation" do
|
110
|
+
study_subject = Factory.build(:study_subject, :state_registrar_no => '')
|
111
|
+
assert study_subject.state_registrar_no.blank?
|
112
|
+
assert !study_subject.state_registrar_no.nil?
|
113
|
+
study_subject.valid?
|
114
|
+
assert study_subject.state_registrar_no.blank?
|
115
|
+
assert study_subject.state_registrar_no.nil?
|
116
|
+
end
|
117
|
+
|
118
|
+
test "should nullify blank local_registrar_no before validation" do
|
119
|
+
study_subject = Factory.build(:study_subject, :local_registrar_no => '')
|
120
|
+
assert study_subject.local_registrar_no.blank?
|
121
|
+
assert !study_subject.local_registrar_no.nil?
|
122
|
+
study_subject.valid?
|
123
|
+
assert study_subject.local_registrar_no.blank?
|
124
|
+
assert study_subject.local_registrar_no.nil?
|
125
|
+
end
|
126
|
+
|
127
|
+
# test "should pad subjectid with leading zeros before validation" do
|
128
|
+
# study_subject = Factory.build(:study_subject)
|
129
|
+
# assert study_subject.subjectid.length < 6
|
130
|
+
# study_subject.valid? #save
|
131
|
+
# assert study_subject.subjectid.length == 6
|
132
|
+
# end
|
133
|
+
|
134
|
+
test "should pad matchingid with leading zeros before validation" do
|
135
|
+
study_subject = Factory.build(:study_subject,{ :matchingid => '123' })
|
136
|
+
assert study_subject.matchingid.length < 6
|
137
|
+
assert_equal '123', study_subject.matchingid
|
138
|
+
study_subject.valid? #save
|
139
|
+
assert study_subject.matchingid.length == 6
|
140
|
+
assert_equal '000123', study_subject.matchingid
|
141
|
+
end
|
142
|
+
|
143
|
+
test "should pad patid with leading zeros before validation" do
|
144
|
+
study_subject = Factory.build(:study_subject)
|
145
|
+
study_subject.patid = '123'
|
146
|
+
assert study_subject.patid.length < 4
|
147
|
+
assert_equal '123', study_subject.patid
|
148
|
+
study_subject.valid? #save
|
149
|
+
assert study_subject.patid.length == 4
|
150
|
+
assert_equal '0123', study_subject.patid
|
151
|
+
end
|
152
|
+
|
153
|
+
# remove ssn from factory and don't use class level test
|
154
|
+
test "should require unique ssn" do
|
155
|
+
Factory(:study_subject,:ssn => '123-45-6789')
|
156
|
+
assert_difference('StudySubject.count',0){
|
157
|
+
study_subject = Factory.build(:study_subject,:ssn => '123-45-6789')
|
158
|
+
study_subject.save
|
159
|
+
assert study_subject.errors.on_attr_and_type?(:ssn,:taken)
|
160
|
+
}
|
161
|
+
end
|
162
|
+
|
163
|
+
test "should nullify blank ssn" do
|
164
|
+
assert_difference('StudySubject.count',1){
|
165
|
+
study_subject = Factory(:study_subject, :ssn => '')
|
166
|
+
assert study_subject.reload.ssn.nil?
|
167
|
+
}
|
168
|
+
end
|
169
|
+
|
170
|
+
test "should create with string standard format ssn" do
|
171
|
+
assert_difference( "StudySubject.count", 1 ) do
|
172
|
+
study_subject = create_study_subject(:ssn => '987-65-4321')
|
173
|
+
assert !study_subject.new_record?,
|
174
|
+
"#{study_subject.errors.full_messages.to_sentence}"
|
175
|
+
assert_equal '987-65-4321', study_subject.reload.ssn
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
test "should require standard formatted ssn" do
|
180
|
+
%w( 1s2n3-4k5=6;7sdfg89 123456789 12345678X 12345678 1-34-56-789 ).each do |invalid_ssn|
|
181
|
+
assert_difference( "StudySubject.count", 0 ) do
|
182
|
+
study_subject = create_study_subject(:ssn => invalid_ssn)
|
183
|
+
assert study_subject.errors.on_attr_and_type?(:ssn,:invalid)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
# patid and childid should be protected as they are generated values
|
189
|
+
|
190
|
+
test "should generate orderno = 0 for case_control_type == 'c'" do
|
191
|
+
# case_control_type is NOT the trigger. SubjectType is.
|
192
|
+
study_subject = Factory(:case_study_subject).reload
|
193
|
+
assert_equal 0, study_subject.orderno
|
194
|
+
end
|
195
|
+
|
196
|
+
test "should not overwrite given studyid" do
|
197
|
+
study_subject = Factory(:study_subject,:studyid => 'MyStudyId').reload
|
198
|
+
assert_equal 'MyStudyId', study_subject.studyid
|
199
|
+
end
|
200
|
+
|
201
|
+
test "should set studyid with patid, case_control_type and orderno for" <<
|
202
|
+
" case_control_type c" do
|
203
|
+
StudySubject.any_instance.stubs(:get_next_patid).returns('123')
|
204
|
+
study_subject = Factory(:case_study_subject).reload
|
205
|
+
assert_equal "0123", study_subject.patid
|
206
|
+
assert_equal "C", study_subject.case_control_type
|
207
|
+
assert_equal "0", study_subject.orderno.to_s
|
208
|
+
assert_not_nil study_subject.studyid
|
209
|
+
assert_nil study_subject.studyid_nohyphen
|
210
|
+
assert_nil study_subject.studyid_intonly_nohyphen
|
211
|
+
assert_equal "0123-C-0", study_subject.studyid
|
212
|
+
end
|
213
|
+
|
214
|
+
test "should generate subjectid on creation for any study_subject" do
|
215
|
+
study_subject = Factory(:study_subject)
|
216
|
+
assert_not_nil study_subject.subjectid
|
217
|
+
assert study_subject.subjectid.length == 6
|
218
|
+
end
|
219
|
+
|
220
|
+
test "should generate patid on creation of case_control_type == 'c'" do
|
221
|
+
assert_difference('StudySubject.maximum(:patid).to_i', 1) {
|
222
|
+
study_subject = Factory(:case_study_subject).reload
|
223
|
+
assert_not_nil study_subject.patid
|
224
|
+
}
|
225
|
+
end
|
226
|
+
|
227
|
+
%w( c b f 4 5 6 ).each do |cct|
|
228
|
+
|
229
|
+
test "should generate childid on creation of case_control_type #{cct}" do
|
230
|
+
assert_difference('StudySubject.maximum(:childid).to_i', 1) {
|
231
|
+
study_subject = Factory(:study_subject, :case_control_type => cct )
|
232
|
+
assert_not_nil study_subject.childid
|
233
|
+
}
|
234
|
+
end
|
235
|
+
|
236
|
+
test "should generate familyid == subjectid on creation of case_control_type #{cct}" do
|
237
|
+
study_subject = Factory(:study_subject, :case_control_type => cct )
|
238
|
+
assert_not_nil study_subject.subjectid
|
239
|
+
assert_not_nil study_subject.familyid
|
240
|
+
assert_equal study_subject.subjectid, study_subject.familyid
|
241
|
+
end
|
242
|
+
|
243
|
+
end
|
244
|
+
|
245
|
+
test "should generate familyid == child's subjectid on creation of case's mother" do
|
246
|
+
case_study_subject = create_case_study_subject
|
247
|
+
assert_equal case_study_subject.subjectid, case_study_subject.familyid
|
248
|
+
mother = case_study_subject.create_mother
|
249
|
+
assert_equal case_study_subject.subjectid, mother.familyid
|
250
|
+
end
|
251
|
+
|
252
|
+
test "should generate familyid == child's subjectid on creation of control's mother" do
|
253
|
+
control_study_subject = create_control_study_subject
|
254
|
+
assert_equal control_study_subject.subjectid, control_study_subject.familyid
|
255
|
+
mother = control_study_subject.create_mother
|
256
|
+
assert_equal control_study_subject.subjectid, mother.familyid
|
257
|
+
end
|
258
|
+
|
259
|
+
test "should generate matchingid == subjectid on creation of case" do
|
260
|
+
study_subject = Factory(:case_study_subject).reload
|
261
|
+
assert_not_nil study_subject.subjectid
|
262
|
+
assert_not_nil study_subject.matchingid
|
263
|
+
assert_equal study_subject.subjectid, study_subject.matchingid
|
264
|
+
end
|
265
|
+
|
266
|
+
test "should not generate new patid for case if given" do
|
267
|
+
# existing data import
|
268
|
+
assert_difference( "StudySubject.maximum(:patid).to_i", 123 ) { # was 0, now 123
|
269
|
+
assert_difference( "StudySubject.count", 1 ) {
|
270
|
+
study_subject = Factory(:case_study_subject, :patid => '123').reload
|
271
|
+
assert_not_nil study_subject.studyid
|
272
|
+
assert_nil study_subject.studyid_nohyphen
|
273
|
+
assert_nil study_subject.studyid_intonly_nohyphen
|
274
|
+
assert_equal "0123-C-0", study_subject.studyid
|
275
|
+
assert_equal "0123", study_subject.patid
|
276
|
+
} } #}
|
277
|
+
end
|
278
|
+
|
279
|
+
test "should not generate new childid if given" do
|
280
|
+
# existing data import
|
281
|
+
assert_difference( "StudySubject.maximum(:childid).to_i", 123 ) { # was 0, now 123
|
282
|
+
assert_difference( "StudySubject.count", 1 ) {
|
283
|
+
study_subject = Factory(:case_study_subject, :childid => '123').reload
|
284
|
+
assert_equal 123, study_subject.childid
|
285
|
+
} } #}
|
286
|
+
end
|
287
|
+
|
288
|
+
test "should not generate new orderno if given" do
|
289
|
+
# existing data import
|
290
|
+
assert_difference( "StudySubject.count", 1 ) {
|
291
|
+
study_subject = Factory(:case_study_subject, :orderno => 9).reload
|
292
|
+
assert_equal 9, study_subject.orderno
|
293
|
+
}
|
294
|
+
end
|
295
|
+
|
296
|
+
test "should not generate new subjectid if given" do
|
297
|
+
# existing data import
|
298
|
+
assert_difference( "StudySubject.count", 1 ) {
|
299
|
+
study_subject = Factory(:case_study_subject, :subjectid => 'ABCDEF').reload
|
300
|
+
assert_equal "ABCDEF", study_subject.subjectid
|
301
|
+
}
|
302
|
+
end
|
303
|
+
|
304
|
+
test "should not generate new familyid if given" do
|
305
|
+
# existing data import
|
306
|
+
assert_difference( "StudySubject.count", 1 ) {
|
307
|
+
study_subject = Factory(:case_study_subject, :familyid => 'ABCDEF').reload
|
308
|
+
assert_equal "ABCDEF", study_subject.familyid
|
309
|
+
}
|
310
|
+
end
|
311
|
+
|
312
|
+
test "should not generate new matchingid if given" do
|
313
|
+
# existing data import
|
314
|
+
assert_difference( "StudySubject.count", 1 ) {
|
315
|
+
study_subject = Factory(:case_study_subject, :matchingid => '123456').reload
|
316
|
+
assert_equal "123456", study_subject.matchingid
|
317
|
+
}
|
318
|
+
end
|
319
|
+
|
320
|
+
test "should find by studyid or icf_master_id with studyid" do
|
321
|
+
study_subject1 = Factory(:case_study_subject)
|
322
|
+
study_subject2 = Factory(:case_study_subject)
|
323
|
+
study_subjects = StudySubject.find_all_by_studyid_or_icf_master_id(
|
324
|
+
study_subject1.studyid, nil )
|
325
|
+
assert study_subjects.include?(study_subject1)
|
326
|
+
assert !study_subjects.include?(study_subject2)
|
327
|
+
end
|
328
|
+
|
329
|
+
test "should find by studyid or icf_master_id with case studyid" do
|
330
|
+
subject = Factory(:complete_case_study_subject)
|
331
|
+
study_subjects = StudySubject.find_all_by_studyid_or_icf_master_id(
|
332
|
+
subject.studyid, nil )
|
333
|
+
assert study_subjects.include?(subject)
|
334
|
+
end
|
335
|
+
|
336
|
+
test "should find by studyid or icf_master_id with case icf_master_id" do
|
337
|
+
subject = Factory(:complete_case_study_subject)
|
338
|
+
Factory(:icf_master_id, :icf_master_id => '123456789' )
|
339
|
+
subject.assign_icf_master_id
|
340
|
+
study_subjects = StudySubject.find_all_by_studyid_or_icf_master_id(
|
341
|
+
nil, subject.icf_master_id )
|
342
|
+
assert study_subjects.include?(subject)
|
343
|
+
end
|
344
|
+
|
345
|
+
test "should find by studyid or icf_master_id with control studyid" do
|
346
|
+
subject = Factory(:complete_control_study_subject,
|
347
|
+
:patid => '1234', :case_control_type => 'X', :orderno => 9)
|
348
|
+
assert_equal subject.patid, '1234'
|
349
|
+
assert_equal subject.case_control_type, 'X'
|
350
|
+
assert_equal subject.orderno, 9
|
351
|
+
assert_equal subject.studyid, '1234-X-9'
|
352
|
+
study_subjects = StudySubject.find_all_by_studyid_or_icf_master_id(
|
353
|
+
subject.studyid, nil )
|
354
|
+
assert study_subjects.include?(subject)
|
355
|
+
end
|
356
|
+
|
357
|
+
test "should find by studyid or icf_master_id with control icf_master_id" do
|
358
|
+
subject = Factory(:complete_control_study_subject)
|
359
|
+
Factory(:icf_master_id, :icf_master_id => '123456789' )
|
360
|
+
subject.assign_icf_master_id
|
361
|
+
study_subjects = StudySubject.find_all_by_studyid_or_icf_master_id(
|
362
|
+
nil, subject.icf_master_id )
|
363
|
+
assert study_subjects.include?(subject)
|
364
|
+
end
|
365
|
+
|
366
|
+
# Mothers won't have a studyid
|
367
|
+
# test "should find by studyid or icf_master_id with mother studyid" do
|
368
|
+
# subject = Factory(:complete_mother_study_subject)
|
369
|
+
# puts subject.studyid
|
370
|
+
# study_subjects = StudySubject.find_all_by_studyid_or_icf_master_id(
|
371
|
+
# subject.studyid, nil )
|
372
|
+
# assert study_subjects.include?(subject)
|
373
|
+
# end
|
374
|
+
|
375
|
+
test "should find by studyid or icf_master_id with mother icf_master_id" do
|
376
|
+
subject = Factory(:complete_mother_study_subject)
|
377
|
+
Factory(:icf_master_id, :icf_master_id => '123456789' )
|
378
|
+
subject.assign_icf_master_id
|
379
|
+
study_subjects = StudySubject.find_all_by_studyid_or_icf_master_id(
|
380
|
+
nil, subject.icf_master_id )
|
381
|
+
assert study_subjects.include?(subject)
|
382
|
+
end
|
383
|
+
|
384
|
+
# TODO what about both studyid and icf_master_id?
|
385
|
+
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
|
396
|
+
# The problems with autogeneration of childid, patid and subjectid are
|
397
|
+
# that they cannot be validated automatically. Validation would simply
|
398
|
+
# return this failure to the user, whom can do nothing about it.
|
399
|
+
# Autogeneration must work on its own. subjectid seems to effectively
|
400
|
+
# select an unused subjectid, but if many subjects were being created at
|
401
|
+
# the same time could theoretically select the same random number.
|
402
|
+
# If/When this occurs, a database error will be returned and confuse
|
403
|
+
# the user.
|
404
|
+
#
|
405
|
+
|
406
|
+
# ActiveRecord::StatementInvalid: Mysql::Error: Duplicate entry '12345' for key 'index_identifiers_on_childid': INSERT INTO `identifiers` (`familyid`, `created_at`, `case_control_type`, `childidwho`, `ssn`, `updated_at`, `state_id_no`, `matchingid`, `gbid`, `idno_wiemels`, `related_childid`, `state_registrar_no`, `study_subject_id`, `studyid`, `childid`, `studyid_nohyphen`, `icf_master_id`, `orderno`, `lab_no`, `lab_no_wiemels`, `accession_no`, `subjectid`, `newid`, `studyid_intonly_nohyphen`, `local_registrar_no`, `patid`, `related_case_childid`) VALUES('407928', '2011-10-28 12:36:07', '3', NULL, '000000002', '2011-10-28 12:36:07', '2', NULL, '2', '2', NULL, '2', 2, NULL, 12345, NULL, '2', NULL, NULL, '2', '2', '407928', NULL, NULL, '2', NULL, NULL)
|
407
|
+
test "duplicating childid should raise database error" do
|
408
|
+
StudySubject.any_instance.stubs(:get_next_childid).returns(12345)
|
409
|
+
study_subject1 = Factory(:study_subject)
|
410
|
+
assert_not_nil study_subject1.childid
|
411
|
+
assert_raises(ActiveRecord::StatementInvalid){
|
412
|
+
study_subject2 = Factory(:study_subject)
|
413
|
+
}
|
414
|
+
end
|
415
|
+
|
416
|
+
# ActiveRecord::StatementInvalid: Mysql::Error: Duplicate entry '0123-C-0' for key 'piccton': INSERT INTO `identifiers` (`familyid`, `created_at`, `case_control_type`, `childidwho`, `ssn`, `updated_at`, `state_id_no`, `matchingid`, `gbid`, `idno_wiemels`, `related_childid`, `state_registrar_no`, `study_subject_id`, `studyid`, `childid`, `studyid_nohyphen`, `icf_master_id`, `orderno`, `lab_no`, `lab_no_wiemels`, `accession_no`, `subjectid`, `newid`, `studyid_intonly_nohyphen`, `local_registrar_no`, `patid`, `related_case_childid`) VALUES('975152', '2011-10-28 12:36:08', 'C', NULL, '000000004', '2011-10-28 12:36:08', '4', '975152', '4', '4', NULL, '4', 4, NULL, 2, NULL, '4', 0, NULL, '4', '4', '975152', NULL, NULL, '4', '0123', NULL)
|
417
|
+
test "duplicating patid should raise database error" do
|
418
|
+
StudySubject.any_instance.stubs(:get_next_patid).returns('0123')
|
419
|
+
study_subject1 = Factory(:case_study_subject)
|
420
|
+
assert_not_nil study_subject1.patid
|
421
|
+
assert_raises(ActiveRecord::StatementInvalid){
|
422
|
+
study_subject2 = Factory(:case_study_subject)
|
423
|
+
}
|
424
|
+
end
|
425
|
+
|
426
|
+
# This should never actually happen as the code actually removes all those that exist.
|
427
|
+
# But it does show that if/when creation of an identifier with an existing
|
428
|
+
# is attempted, it will raise a database error.
|
429
|
+
# ActiveRecord::StatementInvalid: Mysql::Error: Duplicate entry '012345' for key 'index_identifiers_on_subjectid': INSERT INTO `identifiers` (`familyid`, `created_at`, `case_control_type`, `childidwho`, `ssn`, `updated_at`, `state_id_no`, `matchingid`, `gbid`, `idno_wiemels`, `related_childid`, `state_registrar_no`, `study_subject_id`, `studyid`, `childid`, `studyid_nohyphen`, `icf_master_id`, `orderno`, `lab_no`, `lab_no_wiemels`, `accession_no`, `subjectid`, `newid`, `studyid_intonly_nohyphen`, `local_registrar_no`, `patid`, `related_case_childid`) VALUES('012345', '2011-10-28 12:36:08', '5', NULL, '000000006', '2011-10-28 12:36:08', '6', NULL, '6', '6', NULL, '6', 6, NULL, 4, NULL, '6', NULL, NULL, '6', '6', '012345', NULL, NULL, '6', NULL, NULL)
|
430
|
+
test "duplicating subjectid should raise database error" do
|
431
|
+
StudySubject.any_instance.stubs(:generate_subjectid).returns('012345')
|
432
|
+
study_subject1 = Factory(:study_subject)
|
433
|
+
assert_not_nil study_subject1.subjectid
|
434
|
+
assert_raises(ActiveRecord::StatementInvalid){
|
435
|
+
study_subject2 = Factory(:study_subject)
|
436
|
+
}
|
437
|
+
end
|
438
|
+
|
439
|
+
end
|