ccls-ccls_engine 3.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,20 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class Ccls::AliquotSampleFormatTest < ActiveSupport::TestCase
|
|
4
|
+
|
|
5
|
+
assert_should_behave_like_a_hash
|
|
6
|
+
|
|
7
|
+
assert_should_create_default_object
|
|
8
|
+
assert_should_not_require_attributes(:position)
|
|
9
|
+
assert_should_act_as_list
|
|
10
|
+
assert_should_have_many( :aliquots, :samples )
|
|
11
|
+
|
|
12
|
+
test "explicit Factory aliquot_sample_format test" do
|
|
13
|
+
assert_difference('AliquotSampleFormat.count',1) {
|
|
14
|
+
aliquot_sample_format = Factory(:aliquot_sample_format)
|
|
15
|
+
assert_match /Key\d*/, aliquot_sample_format.key
|
|
16
|
+
assert_match /Desc\d*/, aliquot_sample_format.description
|
|
17
|
+
}
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class Ccls::AliquotTest < ActiveSupport::TestCase
|
|
4
|
+
|
|
5
|
+
assert_should_create_default_object
|
|
6
|
+
assert_should_not_require_attributes(
|
|
7
|
+
:position,
|
|
8
|
+
:aliquot_sample_format_id,
|
|
9
|
+
:location,
|
|
10
|
+
:mass,
|
|
11
|
+
:external_aliquot_id,
|
|
12
|
+
:external_aliquot_id_source )
|
|
13
|
+
assert_should_require_attribute_length(
|
|
14
|
+
:location,
|
|
15
|
+
:mass,
|
|
16
|
+
:maximum => 250 )
|
|
17
|
+
assert_should_have_many(:transfers)
|
|
18
|
+
assert_should_belong_to( :aliquot_sample_format )
|
|
19
|
+
assert_should_initially_belong_to( :sample, :unit )
|
|
20
|
+
assert_should_initially_belong_to( :owner, :class_name => 'Organization' )
|
|
21
|
+
|
|
22
|
+
test "explicit Factory aliquot test" do
|
|
23
|
+
assert_difference('Sample.count',1) {
|
|
24
|
+
assert_difference('Unit.count',1) {
|
|
25
|
+
assert_difference('Organization.count',1) {
|
|
26
|
+
assert_difference('Aliquot.count',1) {
|
|
27
|
+
aliquot = Factory(:aliquot)
|
|
28
|
+
assert_not_nil aliquot.sample
|
|
29
|
+
assert_not_nil aliquot.unit
|
|
30
|
+
assert_not_nil aliquot.owner
|
|
31
|
+
} } } }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
test "should require owner" do
|
|
35
|
+
assert_difference( "Aliquot.count", 0 ) do
|
|
36
|
+
aliquot = create_aliquot( :owner => nil)
|
|
37
|
+
assert aliquot.errors.on(:owner)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
test "should require valid owner" do
|
|
42
|
+
assert_difference( "Aliquot.count", 0 ) do
|
|
43
|
+
aliquot = create_aliquot( :owner_id => 0)
|
|
44
|
+
assert aliquot.errors.on(:owner)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
test "should require unit" do
|
|
49
|
+
assert_difference( "Aliquot.count", 0 ) do
|
|
50
|
+
aliquot = create_aliquot( :unit => nil)
|
|
51
|
+
assert aliquot.errors.on(:unit)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
test "should require valid unit" do
|
|
56
|
+
assert_difference( "Aliquot.count", 0 ) do
|
|
57
|
+
aliquot = create_aliquot( :unit_id => 0)
|
|
58
|
+
assert aliquot.errors.on(:unit)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
test "should require sample" do
|
|
63
|
+
assert_difference( "Aliquot.count", 0 ) do
|
|
64
|
+
aliquot = create_aliquot( :sample => nil)
|
|
65
|
+
assert aliquot.errors.on(:sample)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
test "should require valid sample" do
|
|
70
|
+
assert_difference( "Aliquot.count", 0 ) do
|
|
71
|
+
aliquot = create_aliquot( :sample_id => 0)
|
|
72
|
+
assert aliquot.errors.on(:sample)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
test "should transfer to another organization" do
|
|
78
|
+
aliquot = create_aliquot
|
|
79
|
+
initial_owner = aliquot.owner
|
|
80
|
+
assert_not_nil initial_owner
|
|
81
|
+
new_owner = Factory(:organization)
|
|
82
|
+
assert_difference('aliquot.reload.owner_id') {
|
|
83
|
+
assert_difference('aliquot.transfers.count', 1) {
|
|
84
|
+
# assert_difference('initial_owner.reload.aliquots_count', -1) {
|
|
85
|
+
assert_difference('initial_owner.aliquots.count', -1) {
|
|
86
|
+
# assert_difference('new_owner.reload.aliquots_count', 1) {
|
|
87
|
+
assert_difference('new_owner.aliquots.count', 1) {
|
|
88
|
+
assert_difference('Transfer.count',1) {
|
|
89
|
+
aliquot.transfer_to(new_owner)
|
|
90
|
+
} } } } } #} }
|
|
91
|
+
assert_not_nil aliquot.reload.owner
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
test "should NOT transfer if aliquot owner update fails" do
|
|
95
|
+
aliquot = create_aliquot
|
|
96
|
+
initial_owner = aliquot.owner
|
|
97
|
+
assert_not_nil initial_owner
|
|
98
|
+
new_owner = Factory(:organization)
|
|
99
|
+
Aliquot.any_instance.stubs(:update_attribute).returns(false)
|
|
100
|
+
assert_no_difference('aliquot.reload.owner_id') {
|
|
101
|
+
assert_no_difference('aliquot.transfers.count') {
|
|
102
|
+
assert_no_difference('initial_owner.aliquots.count') {
|
|
103
|
+
# assert_no_difference('initial_owner.aliquots_count') {
|
|
104
|
+
assert_no_difference('new_owner.aliquots.count') {
|
|
105
|
+
# assert_no_difference('new_owner.aliquots_count') {
|
|
106
|
+
assert_no_difference('Transfer.count') {
|
|
107
|
+
assert_raise(ActiveRecord::RecordNotSaved){
|
|
108
|
+
aliquot.transfer_to(new_owner)
|
|
109
|
+
} } } } } } #} }
|
|
110
|
+
assert_not_nil aliquot.reload.owner
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
test "should NOT transfer if transfer creation fails" do
|
|
114
|
+
aliquot = create_aliquot
|
|
115
|
+
initial_owner = aliquot.owner
|
|
116
|
+
assert_not_nil initial_owner
|
|
117
|
+
new_owner = Factory(:organization)
|
|
118
|
+
Transfer.any_instance.stubs(:save!).raises(
|
|
119
|
+
ActiveRecord::RecordInvalid.new(Transfer.new))
|
|
120
|
+
assert_no_difference('aliquot.reload.owner_id') {
|
|
121
|
+
assert_no_difference('aliquot.transfers.count') {
|
|
122
|
+
assert_no_difference('initial_owner.aliquots.count') {
|
|
123
|
+
# assert_no_difference('initial_owner.aliquots_count') {
|
|
124
|
+
assert_no_difference('new_owner.aliquots.count') {
|
|
125
|
+
# assert_no_difference('new_owner.aliquots_count') {
|
|
126
|
+
assert_no_difference('Transfer.count') {
|
|
127
|
+
assert_raise(ActiveRecord::RecordInvalid){
|
|
128
|
+
aliquot.transfer_to(new_owner)
|
|
129
|
+
} } } } } } #} }
|
|
130
|
+
assert_not_nil aliquot.reload.owner
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
test "should NOT transfer to invalid organization" do
|
|
134
|
+
aliquot = create_aliquot
|
|
135
|
+
initial_owner = aliquot.owner
|
|
136
|
+
assert_not_nil initial_owner
|
|
137
|
+
assert_no_difference('aliquot.reload.owner_id') {
|
|
138
|
+
assert_no_difference('aliquot.transfers.count') {
|
|
139
|
+
# assert_no_difference('initial_owner.aliquots_count') {
|
|
140
|
+
assert_no_difference('initial_owner.aliquots.count') {
|
|
141
|
+
assert_no_difference('Transfer.count') {
|
|
142
|
+
assert_raise(ActiveRecord::RecordNotFound){
|
|
143
|
+
aliquot.transfer_to(0)
|
|
144
|
+
} } } } } #}
|
|
145
|
+
assert_not_nil aliquot.reload.owner
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
protected
|
|
149
|
+
|
|
150
|
+
def create_aliquot(options={})
|
|
151
|
+
aliquot = Factory.build(:aliquot,options)
|
|
152
|
+
aliquot.save
|
|
153
|
+
aliquot
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class Ccls::AnalysisTest < ActiveSupport::TestCase
|
|
4
|
+
|
|
5
|
+
assert_should_behave_like_a_hash
|
|
6
|
+
|
|
7
|
+
assert_should_create_default_object
|
|
8
|
+
assert_should_not_require_attributes(
|
|
9
|
+
:analyst_id,
|
|
10
|
+
:project_id,
|
|
11
|
+
:analytic_file_creator_id,
|
|
12
|
+
:analytic_file_created_date,
|
|
13
|
+
:analytic_file_last_pulled_date,
|
|
14
|
+
:analytic_file_location,
|
|
15
|
+
:analytic_file_filename )
|
|
16
|
+
assert_should_belong_to(
|
|
17
|
+
:analytic_file_creator,
|
|
18
|
+
:analyst,
|
|
19
|
+
:class_name => 'Person' )
|
|
20
|
+
assert_should_belong_to( :project )
|
|
21
|
+
assert_should_habtm( :study_subjects )
|
|
22
|
+
|
|
23
|
+
test "explicit Factory analysis test" do
|
|
24
|
+
assert_difference('Analysis.count',1) {
|
|
25
|
+
analysis = Factory(:analysis)
|
|
26
|
+
assert_match /Key\d*/, analysis.key
|
|
27
|
+
assert_match /Desc\d*/, analysis.description
|
|
28
|
+
}
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class Ccls::BcRequestTest < ActiveSupport::TestCase
|
|
4
|
+
|
|
5
|
+
assert_should_create_default_object
|
|
6
|
+
assert_should_belong_to( :study_subject )
|
|
7
|
+
assert_should_protect( :study_subject_id, :study_subject )
|
|
8
|
+
assert_should_not_require(:request_type, :status)
|
|
9
|
+
assert_should_require_attribute_length( :request_type, :status, :maximum => 250 )
|
|
10
|
+
assert_should_require_attribute_length( :notes, :maximum => 65000 )
|
|
11
|
+
|
|
12
|
+
test "statuses should return an array of strings" do
|
|
13
|
+
statuses = BcRequest.statuses
|
|
14
|
+
assert statuses.is_a?(Array)
|
|
15
|
+
assert_equal 4, statuses.length
|
|
16
|
+
statuses.each { |s| assert s.is_a?(String) }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
test "explicit Factory bc_request test" do
|
|
20
|
+
assert_difference('BcRequest.count',1) {
|
|
21
|
+
bc_request = Factory(:bc_request)
|
|
22
|
+
assert_match /Notes\d*/, bc_request.notes
|
|
23
|
+
}
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
test "should return self for to_s if no study subject" do
|
|
27
|
+
assert_difference('BcRequest.count',1) {
|
|
28
|
+
bc_request = Factory(:bc_request)
|
|
29
|
+
assert_match /^#<BcRequest:0x.+>$/, "#{bc_request}"
|
|
30
|
+
}
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
test "should return study subject's studyid for to_s if study subject" do
|
|
34
|
+
assert_difference('StudySubject.count',1) {
|
|
35
|
+
assert_difference('BcRequest.count',1) {
|
|
36
|
+
study_subject = Factory(:complete_case_study_subject)
|
|
37
|
+
bc_request = Factory(:bc_request)
|
|
38
|
+
study_subject.bc_requests << bc_request
|
|
39
|
+
assert_equal study_subject.studyid, "#{bc_request}"
|
|
40
|
+
} }
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
@@ -0,0 +1,712 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class Ccls::CandidateControlTest < ActiveSupport::TestCase
|
|
4
|
+
|
|
5
|
+
[ :mother_hispanicity_id, :father_hispanicity_id ].each do |field|
|
|
6
|
+
|
|
7
|
+
# Making assumption that 12345 will NEVER be a valid value.
|
|
8
|
+
test "should NOT allow 12345 for #{field}" do
|
|
9
|
+
candidate_control = CandidateControl.new(field => 12345)
|
|
10
|
+
candidate_control.valid?
|
|
11
|
+
assert candidate_control.errors.on_attr_and_type?(field,:inclusion)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
test "should allow nil for #{field}" do
|
|
15
|
+
candidate_control = CandidateControl.new(field => nil)
|
|
16
|
+
assert_nil candidate_control.send(field)
|
|
17
|
+
candidate_control.valid?
|
|
18
|
+
assert !candidate_control.errors.on(field)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
test "should allow all valid YNODK values for #{field}" do
|
|
22
|
+
candidate_control = CandidateControl.new
|
|
23
|
+
YNODK.valid_values.each do |value|
|
|
24
|
+
candidate_control.send("#{field}=", value)
|
|
25
|
+
candidate_control.valid?
|
|
26
|
+
assert !candidate_control.errors.on(field)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
[ :mom_is_biomom, :dad_is_biodad ].each do |field|
|
|
33
|
+
|
|
34
|
+
# Making assumption that 12345 will NEVER be a valid value.
|
|
35
|
+
test "should NOT allow 12345 for #{field}" do
|
|
36
|
+
candidate_control = CandidateControl.new(field => 12345)
|
|
37
|
+
candidate_control.valid?
|
|
38
|
+
assert candidate_control.errors.on_attr_and_type?(field,:inclusion)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
test "should allow nil for #{field}" do
|
|
42
|
+
candidate_control = CandidateControl.new(field => nil)
|
|
43
|
+
assert_nil candidate_control.send(field)
|
|
44
|
+
candidate_control.valid?
|
|
45
|
+
assert !candidate_control.errors.on(field)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
test "should allow all valid YNDK values for #{field}" do
|
|
49
|
+
candidate_control = CandidateControl.new
|
|
50
|
+
YNDK.valid_values.each do |value|
|
|
51
|
+
candidate_control.send("#{field}=", value)
|
|
52
|
+
candidate_control.valid?
|
|
53
|
+
assert !candidate_control.errors.on(field)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
assert_should_create_default_object
|
|
61
|
+
assert_should_belong_to( :study_subject )
|
|
62
|
+
assert_should_protect( :study_subject_id, :study_subject )
|
|
63
|
+
assert_should_require_attributes(
|
|
64
|
+
:first_name,
|
|
65
|
+
:last_name,
|
|
66
|
+
:dob )
|
|
67
|
+
assert_should_not_require_attributes(
|
|
68
|
+
:dad_is_biodad,
|
|
69
|
+
:mom_is_biomom,
|
|
70
|
+
:mother_first_name,
|
|
71
|
+
:mother_middle_name,
|
|
72
|
+
:mother_last_name,
|
|
73
|
+
:mother_dob,
|
|
74
|
+
:icf_master_id,
|
|
75
|
+
:related_patid,
|
|
76
|
+
:middle_name,
|
|
77
|
+
:state_registrar_no,
|
|
78
|
+
:local_registrar_no,
|
|
79
|
+
:birth_county,
|
|
80
|
+
:assigned_on,
|
|
81
|
+
:mother_race_id,
|
|
82
|
+
:mother_hispanicity_id,
|
|
83
|
+
:father_race_id,
|
|
84
|
+
:father_hispanicity_id,
|
|
85
|
+
:birth_type,
|
|
86
|
+
:mother_maiden_name,
|
|
87
|
+
:mother_yrs_educ,
|
|
88
|
+
:father_yrs_educ,
|
|
89
|
+
:rejection_reason )
|
|
90
|
+
assert_should_require_attribute_length( :related_patid, :is => 4 )
|
|
91
|
+
assert_should_require_attribute_length( :state_registrar_no, :maximum => 25 )
|
|
92
|
+
assert_should_require_attribute_length( :local_registrar_no, :maximum => 25 )
|
|
93
|
+
assert_should_require_attribute_length(
|
|
94
|
+
:first_name,
|
|
95
|
+
:middle_name,
|
|
96
|
+
:last_name,
|
|
97
|
+
:birth_county,
|
|
98
|
+
:birth_type,
|
|
99
|
+
:mother_maiden_name,
|
|
100
|
+
:rejection_reason,
|
|
101
|
+
:maximum => 250 )
|
|
102
|
+
assert_should_require_attributes_not_nil( :sex )
|
|
103
|
+
|
|
104
|
+
test "explicit Factory candidate_control test" do
|
|
105
|
+
assert_difference('CandidateControl.count',1) {
|
|
106
|
+
candidate_control = Factory(:candidate_control)
|
|
107
|
+
assert_equal 'First', candidate_control.first_name
|
|
108
|
+
assert_equal 'Last', candidate_control.last_name
|
|
109
|
+
assert_not_nil candidate_control.dob
|
|
110
|
+
assert_not_nil candidate_control.reject_candidate
|
|
111
|
+
assert !candidate_control.reject_candidate
|
|
112
|
+
assert_not_nil candidate_control.sex
|
|
113
|
+
}
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
test "should require sex be either M, F or DK" do
|
|
117
|
+
assert_difference("CandidateControl.count",0) {
|
|
118
|
+
candidate_control = Factory.build(:candidate_control, :sex => 'X')
|
|
119
|
+
candidate_control.save
|
|
120
|
+
assert candidate_control.errors.on_attr_and_type?(:sex,:inclusion)
|
|
121
|
+
}
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
test "should require rejection_reason if reject_candidate is true" do
|
|
125
|
+
assert_difference("CandidateControl.count",0) {
|
|
126
|
+
candidate_control = Factory.build(:candidate_control,
|
|
127
|
+
:reject_candidate => true,
|
|
128
|
+
:rejection_reason => nil)
|
|
129
|
+
candidate_control.save
|
|
130
|
+
assert candidate_control.errors.on_attr_and_type?(:rejection_reason,:blank)
|
|
131
|
+
}
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
test "should not require rejection_reason if reject_candidate is false" do
|
|
135
|
+
assert_difference("CandidateControl.count",1) {
|
|
136
|
+
candidate_control = Factory(:candidate_control,
|
|
137
|
+
:reject_candidate => false,
|
|
138
|
+
:rejection_reason => nil)
|
|
139
|
+
}
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
test "should require reject_candidate is not nil" do
|
|
143
|
+
assert_difference("CandidateControl.count",0) {
|
|
144
|
+
candidate_control = Factory.build(:candidate_control, :reject_candidate => nil)
|
|
145
|
+
candidate_control.save
|
|
146
|
+
assert candidate_control.errors.on_attr_and_type?(:reject_candidate,:inclusion)
|
|
147
|
+
}
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
test "should return join of candidate's name" do
|
|
151
|
+
candidate_control = Factory(:candidate_control,
|
|
152
|
+
:first_name => "John",
|
|
153
|
+
:middle_name => "Michael",
|
|
154
|
+
:last_name => "Smith" )
|
|
155
|
+
assert_equal 'John Michael Smith', candidate_control.full_name
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
test "should return join of candidate's name with blank middle name" do
|
|
159
|
+
candidate_control = Factory(:candidate_control,
|
|
160
|
+
:first_name => "John",
|
|
161
|
+
:middle_name => "",
|
|
162
|
+
:last_name => "Smith" )
|
|
163
|
+
assert_equal 'John Smith', candidate_control.full_name
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
test "should return join of candidate's mother's name" do
|
|
167
|
+
candidate_control = Factory(:candidate_control,
|
|
168
|
+
:mother_first_name => "Jane",
|
|
169
|
+
:mother_middle_name => "Anne",
|
|
170
|
+
:mother_last_name => "Smith" )
|
|
171
|
+
assert_equal 'Jane Anne Smith', candidate_control.mother_full_name
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
test "should return join of candidate's mother's name with blank mother's middle name" do
|
|
175
|
+
candidate_control = Factory(:candidate_control,
|
|
176
|
+
:mother_first_name => "Jane",
|
|
177
|
+
:mother_middle_name => "",
|
|
178
|
+
:mother_last_name => "Smith" )
|
|
179
|
+
assert_equal 'Jane Smith', candidate_control.mother_full_name
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
################################################################################
|
|
183
|
+
#
|
|
184
|
+
# BEGIN: MANY subject creation tests
|
|
185
|
+
#
|
|
186
|
+
|
|
187
|
+
test "should create study_subjects from attributes" do
|
|
188
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
189
|
+
candidate_control = Factory(:candidate_control)
|
|
190
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
191
|
+
candidate_control.reload # ensure that it is saved in the db!
|
|
192
|
+
assert_not_nil candidate_control.assigned_on
|
|
193
|
+
assert_not_nil candidate_control.study_subject_id
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
test "should create study_subjects and set is_matched" do
|
|
197
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
198
|
+
assert_nil case_study_subject.is_matched
|
|
199
|
+
candidate_control = Factory(:candidate_control)
|
|
200
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
201
|
+
candidate_control.reload # ensure that it is saved in the db!
|
|
202
|
+
assert_not_nil candidate_control.study_subject_id
|
|
203
|
+
assert_not_nil candidate_control.study_subject.is_matched
|
|
204
|
+
assert candidate_control.study_subject.is_matched
|
|
205
|
+
assert_not_nil case_study_subject.is_matched
|
|
206
|
+
assert case_study_subject.is_matched
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
# this enrollment is actually a callback in study_subject
|
|
210
|
+
# now and is not explictly called.
|
|
211
|
+
test "should create control with enrollment in ccls" do
|
|
212
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
213
|
+
candidate_control = Factory(:candidate_control)
|
|
214
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
215
|
+
assert !candidate_control.study_subject.enrollments.empty?
|
|
216
|
+
assert_equal [Project['ccls']],
|
|
217
|
+
candidate_control.study_subject.enrollments.collect(&:project)
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
test "should create control from attributes without patient" do
|
|
221
|
+
case_study_subject = create_case_study_subject
|
|
222
|
+
assert_nil case_study_subject.patient
|
|
223
|
+
candidate_control = Factory(:candidate_control)
|
|
224
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
225
|
+
assert_nil candidate_control.study_subject.reference_date
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
test "should create control from attributes and copy case patid" do
|
|
229
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
230
|
+
candidate_control = Factory(:candidate_control)
|
|
231
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
232
|
+
control_subject = candidate_control.study_subject
|
|
233
|
+
assert_not_nil control_subject.patid
|
|
234
|
+
assert_equal control_subject.patid, case_study_subject.patid
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
test "should create control from attributes and set hispanicity_id nil" do
|
|
238
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
239
|
+
candidate_control = Factory(:candidate_control)
|
|
240
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
241
|
+
control_subject = candidate_control.study_subject
|
|
242
|
+
assert_nil control_subject.hispanicity_id
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
test "should create control from attributes and set hispanicity_id if father_hispanicity" do
|
|
246
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
247
|
+
candidate_control = Factory(:candidate_control, :father_hispanicity_id => 1 )
|
|
248
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
249
|
+
control_subject = candidate_control.study_subject
|
|
250
|
+
assert_not_nil control_subject.hispanicity_id
|
|
251
|
+
assert_equal control_subject.hispanicity_id, 1
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
test "should create control from attributes and set hispanicity_id if mother_hispanicity" do
|
|
255
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
256
|
+
candidate_control = Factory(:candidate_control, :mother_hispanicity_id => 1 )
|
|
257
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
258
|
+
control_subject = candidate_control.study_subject
|
|
259
|
+
assert_not_nil control_subject.hispanicity_id
|
|
260
|
+
assert_equal control_subject.hispanicity_id, 1
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
test "should create control from attributes and copy state_registrar_no" do
|
|
264
|
+
attribute = 'fake number'
|
|
265
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
266
|
+
candidate_control = Factory(:candidate_control, :state_registrar_no => attribute )
|
|
267
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
268
|
+
control_subject = candidate_control.study_subject
|
|
269
|
+
assert_equal attribute, candidate_control.state_registrar_no
|
|
270
|
+
assert_equal attribute, control_subject.state_registrar_no
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
test "should create control from attributes and copy local_registrar_no" do
|
|
274
|
+
attribute = 'fake number'
|
|
275
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
276
|
+
candidate_control = Factory(:candidate_control, :local_registrar_no => attribute )
|
|
277
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
278
|
+
control_subject = candidate_control.study_subject
|
|
279
|
+
assert_equal attribute, candidate_control.local_registrar_no
|
|
280
|
+
assert_equal attribute, control_subject.local_registrar_no
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
test "should create control from attributes and copy sex" do
|
|
284
|
+
attribute = 'DK'
|
|
285
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
286
|
+
candidate_control = Factory(:candidate_control, :sex => attribute)
|
|
287
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
288
|
+
control_subject = candidate_control.study_subject
|
|
289
|
+
assert_equal attribute, candidate_control.sex
|
|
290
|
+
assert_equal attribute, control_subject.sex
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
test "should create control from attributes and copy mother_hispanicity_id" do
|
|
294
|
+
attribute = 999
|
|
295
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
296
|
+
candidate_control = Factory(:candidate_control, :mother_hispanicity_id => attribute )
|
|
297
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
298
|
+
control_subject = candidate_control.study_subject
|
|
299
|
+
assert_equal attribute, candidate_control.mother_hispanicity_id
|
|
300
|
+
assert_equal attribute, control_subject.mother_hispanicity_id
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
test "should create control from attributes and copy father_hispanicity_id" do
|
|
304
|
+
attribute = 999
|
|
305
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
306
|
+
candidate_control = Factory(:candidate_control, :father_hispanicity_id => attribute )
|
|
307
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
308
|
+
control_subject = candidate_control.study_subject
|
|
309
|
+
assert_equal attribute, candidate_control.father_hispanicity_id
|
|
310
|
+
assert_equal attribute, control_subject.father_hispanicity_id
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
test "should create control from attributes and copy birth_type" do
|
|
314
|
+
attribute = 'xyz'
|
|
315
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
316
|
+
candidate_control = Factory(:candidate_control, :birth_type => attribute )
|
|
317
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
318
|
+
control_subject = candidate_control.study_subject
|
|
319
|
+
assert_equal attribute, candidate_control.birth_type
|
|
320
|
+
assert_equal attribute, control_subject.birth_type
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
test "should create control from attributes and copy mother_yrs_educ" do
|
|
324
|
+
attribute = 7
|
|
325
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
326
|
+
candidate_control = Factory(:candidate_control, :mother_yrs_educ => attribute )
|
|
327
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
328
|
+
control_subject = candidate_control.study_subject
|
|
329
|
+
assert_equal attribute, candidate_control.mother_yrs_educ
|
|
330
|
+
assert_equal attribute, control_subject.mother_yrs_educ
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
test "should create control from attributes and copy father_yrs_educ" do
|
|
334
|
+
attribute = 7
|
|
335
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
336
|
+
candidate_control = Factory(:candidate_control, :father_yrs_educ => attribute )
|
|
337
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
338
|
+
control_subject = candidate_control.study_subject
|
|
339
|
+
assert_equal attribute, candidate_control.father_yrs_educ
|
|
340
|
+
assert_equal attribute, control_subject.father_yrs_educ
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
test "should create control from attributes and copy birth_county" do
|
|
344
|
+
attribute = 'Somewhere'
|
|
345
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
346
|
+
candidate_control = Factory(:candidate_control, :birth_county => attribute )
|
|
347
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
348
|
+
control_subject = candidate_control.study_subject
|
|
349
|
+
assert_equal attribute, candidate_control.birth_county
|
|
350
|
+
assert_equal attribute, control_subject.birth_county
|
|
351
|
+
end
|
|
352
|
+
|
|
353
|
+
test "should create control from attributes and copy first_name" do
|
|
354
|
+
attribute = 'SomeName'
|
|
355
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
356
|
+
candidate_control = Factory(:candidate_control, :first_name => attribute )
|
|
357
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
358
|
+
control_subject = candidate_control.study_subject
|
|
359
|
+
assert_equal attribute, candidate_control.first_name
|
|
360
|
+
assert_equal attribute, control_subject.first_name
|
|
361
|
+
end
|
|
362
|
+
|
|
363
|
+
test "should create control from attributes and copy middle_name" do
|
|
364
|
+
attribute = 'SomeName'
|
|
365
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
366
|
+
candidate_control = Factory(:candidate_control, :middle_name => attribute )
|
|
367
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
368
|
+
control_subject = candidate_control.study_subject
|
|
369
|
+
assert_equal attribute, candidate_control.middle_name
|
|
370
|
+
assert_equal attribute, control_subject.middle_name
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
test "should create control from attributes and copy last_name" do
|
|
374
|
+
attribute = 'SomeName'
|
|
375
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
376
|
+
candidate_control = Factory(:candidate_control, :last_name => attribute )
|
|
377
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
378
|
+
control_subject = candidate_control.study_subject
|
|
379
|
+
assert_equal attribute, candidate_control.last_name
|
|
380
|
+
assert_equal attribute, control_subject.last_name
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
test "should create control from attributes and copy dob" do
|
|
384
|
+
attribute = Date.parse('Dec 5, 1971')
|
|
385
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
386
|
+
candidate_control = Factory(:candidate_control, :dob => attribute )
|
|
387
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
388
|
+
control_subject = candidate_control.study_subject
|
|
389
|
+
assert_equal attribute, candidate_control.dob
|
|
390
|
+
assert_equal attribute, control_subject.dob
|
|
391
|
+
end
|
|
392
|
+
|
|
393
|
+
test "should create control from attributes and copy mother_first_name" do
|
|
394
|
+
attribute = 'SomeName'
|
|
395
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
396
|
+
candidate_control = Factory(:candidate_control, :mother_first_name => attribute )
|
|
397
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
398
|
+
control_subject = candidate_control.study_subject
|
|
399
|
+
assert_equal attribute, candidate_control.mother_first_name
|
|
400
|
+
assert_equal attribute, control_subject.mother_first_name
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
test "should create control from attributes and copy mother_middle_name" do
|
|
404
|
+
attribute = 'SomeName'
|
|
405
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
406
|
+
candidate_control = Factory(:candidate_control, :mother_middle_name => attribute )
|
|
407
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
408
|
+
control_subject = candidate_control.study_subject
|
|
409
|
+
assert_equal attribute, candidate_control.mother_middle_name
|
|
410
|
+
assert_equal attribute, control_subject.mother_middle_name
|
|
411
|
+
end
|
|
412
|
+
|
|
413
|
+
test "should create control from attributes and copy mother_last_name" do
|
|
414
|
+
attribute = 'SomeName'
|
|
415
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
416
|
+
candidate_control = Factory(:candidate_control, :mother_last_name => attribute )
|
|
417
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
418
|
+
control_subject = candidate_control.study_subject
|
|
419
|
+
assert_equal attribute, candidate_control.mother_last_name
|
|
420
|
+
assert_equal attribute, control_subject.mother_last_name
|
|
421
|
+
end
|
|
422
|
+
|
|
423
|
+
test "should create control from attributes and copy mother_maiden_name" do
|
|
424
|
+
attribute = 'SomeName'
|
|
425
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
426
|
+
candidate_control = Factory(:candidate_control, :mother_maiden_name => attribute )
|
|
427
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
428
|
+
control_subject = candidate_control.study_subject
|
|
429
|
+
assert_equal attribute, candidate_control.mother_maiden_name
|
|
430
|
+
assert_equal attribute, control_subject.mother_maiden_name
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
test "should create control from attributes and copy mother_race_id" do
|
|
434
|
+
attribute = 123
|
|
435
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
436
|
+
candidate_control = Factory(:candidate_control, :mother_race_id => attribute )
|
|
437
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
438
|
+
control_subject = candidate_control.study_subject
|
|
439
|
+
assert_equal attribute, candidate_control.mother_race_id
|
|
440
|
+
assert_equal attribute, control_subject.mother_race_id
|
|
441
|
+
end
|
|
442
|
+
|
|
443
|
+
test "should create control from attributes and copy father_race_id" do
|
|
444
|
+
attribute = 123
|
|
445
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
446
|
+
candidate_control = Factory(:candidate_control, :father_race_id => attribute )
|
|
447
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
448
|
+
control_subject = candidate_control.study_subject
|
|
449
|
+
assert_equal attribute, candidate_control.father_race_id
|
|
450
|
+
assert_equal attribute, control_subject.father_race_id
|
|
451
|
+
end
|
|
452
|
+
|
|
453
|
+
test "should create control from attributes and copy mom_is_biomom" do
|
|
454
|
+
attribute = 999
|
|
455
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
456
|
+
candidate_control = Factory(:candidate_control, :mom_is_biomom => attribute )
|
|
457
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
458
|
+
control_subject = candidate_control.study_subject
|
|
459
|
+
assert_equal attribute, candidate_control.mom_is_biomom
|
|
460
|
+
assert_equal attribute, control_subject.mom_is_biomom
|
|
461
|
+
end
|
|
462
|
+
|
|
463
|
+
test "should create control from attributes and copy dad_is_biodad" do
|
|
464
|
+
attribute = 999
|
|
465
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
466
|
+
candidate_control = Factory(:candidate_control, :dad_is_biodad => attribute )
|
|
467
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
468
|
+
control_subject = candidate_control.study_subject
|
|
469
|
+
assert_equal attribute, candidate_control.dad_is_biodad
|
|
470
|
+
assert_equal attribute, control_subject.dad_is_biodad
|
|
471
|
+
end
|
|
472
|
+
|
|
473
|
+
# test "should create control from attributes with patient" do
|
|
474
|
+
# case_study_subject = Factory(:complete_case_study_subject)
|
|
475
|
+
## unnecessary with complete case factory
|
|
476
|
+
## create_patient_for_subject(case_study_subject)
|
|
477
|
+
# candidate_control = Factory(:candidate_control)
|
|
478
|
+
# create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
479
|
+
# assert_equal candidate_control.study_subject.reference_date,
|
|
480
|
+
# case_study_subject.admit_date
|
|
481
|
+
# end
|
|
482
|
+
|
|
483
|
+
test "should create control from attributes with patient and copy case admit_date" do
|
|
484
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
485
|
+
assert_not_nil case_study_subject.patient
|
|
486
|
+
candidate_control = Factory(:candidate_control)
|
|
487
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
488
|
+
control_subject = candidate_control.study_subject
|
|
489
|
+
assert_not_nil control_subject.reference_date
|
|
490
|
+
assert_equal control_subject.reference_date, case_study_subject.patient.admit_date
|
|
491
|
+
end
|
|
492
|
+
|
|
493
|
+
test "should create control from attributes and add subjectid" do
|
|
494
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
495
|
+
candidate_control = Factory(:candidate_control)
|
|
496
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
497
|
+
assert_not_nil candidate_control.study_subject.subjectid
|
|
498
|
+
assert_equal candidate_control.study_subject.subjectid.length, 6
|
|
499
|
+
end
|
|
500
|
+
|
|
501
|
+
test "should create control from attributes and add familyid" do
|
|
502
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
503
|
+
candidate_control = Factory(:candidate_control)
|
|
504
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
505
|
+
assert_not_nil candidate_control.study_subject.familyid
|
|
506
|
+
assert_equal candidate_control.study_subject.familyid.length, 6
|
|
507
|
+
end
|
|
508
|
+
|
|
509
|
+
test "should create control from attributes and subjectid should equal familyid" do
|
|
510
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
511
|
+
candidate_control = Factory(:candidate_control)
|
|
512
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
513
|
+
assert_equal candidate_control.study_subject.familyid,
|
|
514
|
+
candidate_control.study_subject.subjectid
|
|
515
|
+
end
|
|
516
|
+
|
|
517
|
+
test "should create control from attributes and copy case matchingid" do
|
|
518
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
519
|
+
candidate_control = Factory(:candidate_control)
|
|
520
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
521
|
+
assert_not_nil candidate_control.study_subject.matchingid
|
|
522
|
+
assert_equal candidate_control.study_subject.matchingid,
|
|
523
|
+
case_study_subject.matchingid
|
|
524
|
+
end
|
|
525
|
+
|
|
526
|
+
test "should create control from attributes and add orderno = 1" do
|
|
527
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
528
|
+
candidate_control = Factory(:candidate_control)
|
|
529
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
530
|
+
assert_not_nil candidate_control.study_subject.orderno
|
|
531
|
+
# As this will be the first control here ...
|
|
532
|
+
assert_equal candidate_control.study_subject.orderno, 1
|
|
533
|
+
end
|
|
534
|
+
|
|
535
|
+
test "should create second control from attributes and add orderno = 2" do
|
|
536
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
537
|
+
candidate_control_1 = Factory(:candidate_control)
|
|
538
|
+
create_study_subjects_for_candidate_control(candidate_control_1,case_study_subject)
|
|
539
|
+
candidate_control_2 = Factory(:candidate_control)
|
|
540
|
+
create_study_subjects_for_candidate_control(candidate_control_2,case_study_subject)
|
|
541
|
+
assert_not_nil candidate_control_2.study_subject.orderno
|
|
542
|
+
# As this will be the second control here ...
|
|
543
|
+
assert_equal candidate_control_2.study_subject.orderno, 2
|
|
544
|
+
end
|
|
545
|
+
|
|
546
|
+
test "should create control from attributes and add studyid" do
|
|
547
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
548
|
+
candidate_control = Factory(:candidate_control)
|
|
549
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
550
|
+
assert_not_nil candidate_control.study_subject.studyid
|
|
551
|
+
assert_match /\d{4}-\d-\d/, candidate_control.study_subject.studyid
|
|
552
|
+
end
|
|
553
|
+
|
|
554
|
+
# icf_master_id isn't required as may not have any
|
|
555
|
+
test "should create control from attributes and add icf_master_id if any" do
|
|
556
|
+
imi = Factory(:icf_master_id,:icf_master_id => '123456789')
|
|
557
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
558
|
+
candidate_control = Factory(:candidate_control)
|
|
559
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
560
|
+
assert_not_nil candidate_control.study_subject.icf_master_id
|
|
561
|
+
assert_equal candidate_control.study_subject.icf_master_id, '123456789'
|
|
562
|
+
assert_not_nil imi.reload.study_subject
|
|
563
|
+
assert_equal imi.study_subject, candidate_control.study_subject
|
|
564
|
+
assert_not_nil imi.assigned_on
|
|
565
|
+
assert_equal imi.assigned_on, Date.today
|
|
566
|
+
end
|
|
567
|
+
|
|
568
|
+
test "should create mother from attributes" do
|
|
569
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
570
|
+
candidate_control = Factory(:candidate_control)
|
|
571
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
572
|
+
assert_not_nil candidate_control.study_subject.mother
|
|
573
|
+
mother = candidate_control.study_subject.mother
|
|
574
|
+
assert_nil mother.case_control_type
|
|
575
|
+
assert_nil mother.orderno
|
|
576
|
+
end
|
|
577
|
+
|
|
578
|
+
test "should create mother from attributes and NOT copy case patid" do
|
|
579
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
580
|
+
candidate_control = Factory(:candidate_control)
|
|
581
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
582
|
+
mother = candidate_control.study_subject.mother
|
|
583
|
+
assert_nil mother.patid
|
|
584
|
+
end
|
|
585
|
+
|
|
586
|
+
test "should create mother from attributes with patient and copy case admit_date" do
|
|
587
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
588
|
+
case_study_subject.reload
|
|
589
|
+
candidate_control = Factory(:candidate_control)
|
|
590
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
591
|
+
mother = candidate_control.study_subject.reload.mother
|
|
592
|
+
assert_not_nil mother.reference_date
|
|
593
|
+
assert_equal mother.reference_date, case_study_subject.patient.admit_date
|
|
594
|
+
end
|
|
595
|
+
|
|
596
|
+
test "should create mother from attributes and copy case matchingid" do
|
|
597
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
598
|
+
candidate_control = Factory(:candidate_control)
|
|
599
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
600
|
+
mother = candidate_control.study_subject.mother
|
|
601
|
+
assert_not_nil mother.matchingid
|
|
602
|
+
assert_equal mother.matchingid,
|
|
603
|
+
case_study_subject.matchingid
|
|
604
|
+
end
|
|
605
|
+
|
|
606
|
+
test "should create mother from attributes and copy child familyid" do
|
|
607
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
608
|
+
candidate_control = Factory(:candidate_control)
|
|
609
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
610
|
+
mother = candidate_control.study_subject.mother
|
|
611
|
+
assert_not_nil mother.familyid
|
|
612
|
+
assert_equal candidate_control.study_subject.familyid,
|
|
613
|
+
mother.familyid
|
|
614
|
+
end
|
|
615
|
+
|
|
616
|
+
# icf_master_id isn't required as may not have any
|
|
617
|
+
test "should create mother from attributes and add icf_master_id if any" do
|
|
618
|
+
child_imi = Factory(:icf_master_id,:icf_master_id => 'child')
|
|
619
|
+
mother_imi = Factory(:icf_master_id,:icf_master_id => 'mother')
|
|
620
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
621
|
+
candidate_control = Factory(:candidate_control)
|
|
622
|
+
create_study_subjects_for_candidate_control(candidate_control,case_study_subject)
|
|
623
|
+
assert_not_nil candidate_control.study_subject.icf_master_id
|
|
624
|
+
assert_equal candidate_control.study_subject.icf_master_id, 'child'
|
|
625
|
+
assert_not_nil candidate_control.study_subject.mother.icf_master_id
|
|
626
|
+
assert_equal candidate_control.study_subject.mother.icf_master_id, 'mother'
|
|
627
|
+
assert_not_nil child_imi.reload.study_subject
|
|
628
|
+
assert_equal child_imi.study_subject, candidate_control.study_subject
|
|
629
|
+
assert_not_nil child_imi.assigned_on
|
|
630
|
+
assert_equal child_imi.assigned_on, Date.today
|
|
631
|
+
assert_not_nil mother_imi.reload.study_subject
|
|
632
|
+
assert_equal mother_imi.study_subject, candidate_control.study_subject.mother
|
|
633
|
+
assert_not_nil mother_imi.assigned_on
|
|
634
|
+
assert_equal mother_imi.assigned_on, Date.today
|
|
635
|
+
end
|
|
636
|
+
|
|
637
|
+
test "should rollback study subject creation of icf_master_id save fails" do
|
|
638
|
+
Factory(:icf_master_id,:icf_master_id => '123456789')
|
|
639
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
640
|
+
candidate_control = Factory(:candidate_control)
|
|
641
|
+
assert_not_nil IcfMasterId.next_unused
|
|
642
|
+
IcfMasterId.any_instance.stubs(:save!
|
|
643
|
+
).raises(ActiveRecord::RecordNotSaved)
|
|
644
|
+
assert_difference('Enrollment.count',0) {
|
|
645
|
+
assert_difference('StudySubject.count',0) {
|
|
646
|
+
assert_raises(ActiveRecord::RecordNotSaved){
|
|
647
|
+
candidate_control.create_study_subjects(case_study_subject)
|
|
648
|
+
} } }
|
|
649
|
+
end
|
|
650
|
+
|
|
651
|
+
test "should rollback if create_mother raises error" do
|
|
652
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
653
|
+
candidate_control = Factory(:candidate_control)
|
|
654
|
+
StudySubject.any_instance.stubs(:create_mother
|
|
655
|
+
).raises(ActiveRecord::RecordNotSaved)
|
|
656
|
+
assert_difference('Enrollment.count',0) {
|
|
657
|
+
assert_difference('StudySubject.count',0) {
|
|
658
|
+
assert_raises(ActiveRecord::RecordNotSaved){
|
|
659
|
+
candidate_control.create_study_subjects(case_study_subject)
|
|
660
|
+
} } }
|
|
661
|
+
end
|
|
662
|
+
|
|
663
|
+
test "should rollback if assign_icf_master_id raises error" do
|
|
664
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
665
|
+
candidate_control = Factory(:candidate_control)
|
|
666
|
+
StudySubject.any_instance.stubs(:assign_icf_master_id
|
|
667
|
+
).raises(ActiveRecord::RecordNotSaved)
|
|
668
|
+
assert_difference('Enrollment.count',0) {
|
|
669
|
+
assert_difference('StudySubject.count',0) {
|
|
670
|
+
assert_raises(ActiveRecord::RecordNotSaved){
|
|
671
|
+
candidate_control.create_study_subjects(case_study_subject)
|
|
672
|
+
} } }
|
|
673
|
+
end
|
|
674
|
+
|
|
675
|
+
test "should rollback if create_study_subject raises error" do
|
|
676
|
+
case_study_subject = Factory(:complete_case_study_subject)
|
|
677
|
+
candidate_control = Factory(:candidate_control)
|
|
678
|
+
StudySubject.any_instance.stubs(:create_or_update).returns(false)
|
|
679
|
+
assert_difference('Enrollment.count',0) {
|
|
680
|
+
assert_difference('StudySubject.count',0) {
|
|
681
|
+
assert_raises(ActiveRecord::RecordNotSaved){
|
|
682
|
+
candidate_control.create_study_subjects(case_study_subject)
|
|
683
|
+
} } }
|
|
684
|
+
end
|
|
685
|
+
|
|
686
|
+
#
|
|
687
|
+
# END: MANY subject creation tests
|
|
688
|
+
#
|
|
689
|
+
################################################################################
|
|
690
|
+
|
|
691
|
+
protected
|
|
692
|
+
|
|
693
|
+
def create_study_subjects_for_candidate_control(candidate,case_subject)
|
|
694
|
+
assert_difference('Enrollment.count',2) { # both get auto-created ccls enrollment
|
|
695
|
+
assert_difference('StudySubject.count',2) {
|
|
696
|
+
candidate.create_study_subjects(case_subject)
|
|
697
|
+
} }
|
|
698
|
+
end
|
|
699
|
+
|
|
700
|
+
# def create_patient_for_subject(subject)
|
|
701
|
+
# patient = Factory(:patient, :study_subject => subject,
|
|
702
|
+
# :admit_date => 5.years.ago )
|
|
703
|
+
# assert_not_nil patient.admit_date
|
|
704
|
+
# end
|
|
705
|
+
|
|
706
|
+
# def create_candidate_control(options={})
|
|
707
|
+
# candidate_control = Factory.build(:candidate_control,options)
|
|
708
|
+
# candidate_control.save
|
|
709
|
+
# candidate_control
|
|
710
|
+
# end
|
|
711
|
+
|
|
712
|
+
end
|