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,26 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class Ccls::StudySubjectInterviewsTest < ActiveSupport::TestCase
|
|
4
|
+
|
|
5
|
+
test "should NOT destroy interviews with study_subject" do
|
|
6
|
+
assert_difference('StudySubject.count',1) {
|
|
7
|
+
assert_difference('Interview.count',1) {
|
|
8
|
+
@study_subject = Factory(:interview).study_subject
|
|
9
|
+
} }
|
|
10
|
+
assert_difference('StudySubject.count',-1) {
|
|
11
|
+
assert_difference('Interview.count',0) {
|
|
12
|
+
@study_subject.destroy
|
|
13
|
+
} }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
test "should not have hx_interview" do
|
|
17
|
+
study_subject = create_study_subject
|
|
18
|
+
assert_nil study_subject.hx_interview
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
test "should have hx_interview" do
|
|
22
|
+
study_subject = create_hx_interview_study_subject
|
|
23
|
+
assert_not_nil study_subject.hx_interview
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
# This is just a collection of language related tests
|
|
4
|
+
# for StudySubject separated only for clarity due
|
|
5
|
+
# to the size of the StudySubjectTest class.
|
|
6
|
+
class Ccls::StudySubjectLanguagesTest < ActiveSupport::TestCase
|
|
7
|
+
|
|
8
|
+
test "should create study_subject with language" do
|
|
9
|
+
assert_difference( 'Language.count', 1 ){
|
|
10
|
+
assert_difference( 'SubjectLanguage.count', 1 ){
|
|
11
|
+
assert_difference( "StudySubject.count", 1 ) {
|
|
12
|
+
study_subject = create_study_subject
|
|
13
|
+
study_subject.languages << Factory(:language)
|
|
14
|
+
assert !study_subject.new_record?,
|
|
15
|
+
"#{study_subject.errors.full_messages.to_sentence}"
|
|
16
|
+
} } }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
test "should NOT destroy languages with study_subject" do
|
|
20
|
+
assert_difference('StudySubject.count',1) {
|
|
21
|
+
assert_difference('SubjectLanguage.count',1) {
|
|
22
|
+
@study_subject = Factory(:subject_language).study_subject
|
|
23
|
+
} }
|
|
24
|
+
assert_difference('StudySubject.count',-1) {
|
|
25
|
+
assert_difference('SubjectLanguage.count',0) {
|
|
26
|
+
@study_subject.destroy
|
|
27
|
+
} }
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
test "should NOT destroy subject_languages with study_subject" do
|
|
31
|
+
assert_difference('StudySubject.count',1) {
|
|
32
|
+
assert_difference('SubjectLanguage.count',1) {
|
|
33
|
+
@study_subject = Factory(:subject_language).study_subject
|
|
34
|
+
} }
|
|
35
|
+
assert_difference('StudySubject.count',-1) {
|
|
36
|
+
assert_difference('SubjectLanguage.count',0) {
|
|
37
|
+
@study_subject.destroy
|
|
38
|
+
} }
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# add similar for languages?
|
|
42
|
+
# test "should return race name for string" do
|
|
43
|
+
# study_subject = create_study_subject
|
|
44
|
+
# assert_equal study_subject.race_names,
|
|
45
|
+
# "#{study_subject.races.first}"
|
|
46
|
+
# end
|
|
47
|
+
|
|
48
|
+
test "should create study_subject with empty subject_languages_attributes" do
|
|
49
|
+
assert_difference( 'SubjectLanguage.count', 0 ){
|
|
50
|
+
assert_difference( "StudySubject.count", 1 ) {
|
|
51
|
+
@study_subject = create_study_subject(:subject_languages_attributes => { })
|
|
52
|
+
assert !@study_subject.new_record?,
|
|
53
|
+
"#{@study_subject.errors.full_messages.to_sentence}"
|
|
54
|
+
} }
|
|
55
|
+
assert @study_subject.languages.empty?
|
|
56
|
+
assert @study_subject.subject_languages.empty?
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
test "should create study_subject with blank language_id" do
|
|
60
|
+
assert_difference( 'SubjectLanguage.count', 0 ){
|
|
61
|
+
assert_difference( "StudySubject.count", 1 ) {
|
|
62
|
+
@study_subject = create_study_subject(:subject_languages_attributes => {
|
|
63
|
+
'0' => { :language_id => '' }
|
|
64
|
+
})
|
|
65
|
+
assert !@study_subject.new_record?,
|
|
66
|
+
"#{@study_subject.errors.full_messages.to_sentence}"
|
|
67
|
+
} }
|
|
68
|
+
assert @study_subject.languages.empty?
|
|
69
|
+
assert @study_subject.subject_languages.empty?
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
test "should create study_subject with subject_languages_attributes language_id" do
|
|
73
|
+
assert Language.count > 0
|
|
74
|
+
assert_difference( 'SubjectLanguage.count', 1 ){
|
|
75
|
+
assert_difference( "StudySubject.count", 1 ) {
|
|
76
|
+
@study_subject = create_study_subject(:subject_languages_attributes => {
|
|
77
|
+
'0' => { :language_id => Language.first.id }
|
|
78
|
+
})
|
|
79
|
+
assert !@study_subject.new_record?,
|
|
80
|
+
"#{@study_subject.errors.full_messages.to_sentence}"
|
|
81
|
+
} }
|
|
82
|
+
assert !@study_subject.languages.empty?
|
|
83
|
+
assert_equal 1, @study_subject.languages.length
|
|
84
|
+
assert !@study_subject.subject_languages.empty?
|
|
85
|
+
assert_equal 1, @study_subject.subject_languages.length
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
test "should create study_subject with subject_languages_attributes multiple languages" do
|
|
89
|
+
assert Language.count > 1
|
|
90
|
+
languages = Language.all
|
|
91
|
+
assert_difference( 'SubjectLanguage.count', 2 ){
|
|
92
|
+
assert_difference( "StudySubject.count", 1 ) {
|
|
93
|
+
@study_subject = create_study_subject(:subject_languages_attributes => {
|
|
94
|
+
'0' => { :language_id => languages[0].id },
|
|
95
|
+
'1' => { :language_id => languages[1].id }
|
|
96
|
+
})
|
|
97
|
+
assert !@study_subject.new_record?,
|
|
98
|
+
"#{@study_subject.errors.full_messages.to_sentence}"
|
|
99
|
+
} }
|
|
100
|
+
assert !@study_subject.languages.empty?
|
|
101
|
+
assert_equal 2, @study_subject.languages.length
|
|
102
|
+
assert !@study_subject.subject_languages.empty?
|
|
103
|
+
assert_equal 2, @study_subject.subject_languages.length
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
test "should NOT create study_subject with subject_languages_attributes " <<
|
|
107
|
+
"if language is other and no other given" do
|
|
108
|
+
assert Language.count > 0
|
|
109
|
+
assert_difference( 'SubjectLanguage.count', 0 ){
|
|
110
|
+
assert_difference( "StudySubject.count", 0 ) {
|
|
111
|
+
@study_subject = create_study_subject(:subject_languages_attributes => {
|
|
112
|
+
'0' => { :language_id => Language['other'].id }
|
|
113
|
+
})
|
|
114
|
+
assert @study_subject.errors.on_attr_and_type?("subject_languages.other",:blank)
|
|
115
|
+
} }
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
test "should update study_subject with subject_languages_attributes" do
|
|
119
|
+
study_subject = create_study_subject
|
|
120
|
+
assert_difference( 'SubjectLanguage.count', 1 ){
|
|
121
|
+
study_subject.update_attributes(:subject_languages_attributes => {
|
|
122
|
+
'0' => { :language_id => Language.first.id }
|
|
123
|
+
})
|
|
124
|
+
}
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
test "should destroy subject_language on update with _destroy" do
|
|
128
|
+
study_subject = create_study_subject
|
|
129
|
+
assert_difference( 'SubjectLanguage.count', 1 ){
|
|
130
|
+
study_subject.update_attributes(:subject_languages_attributes => {
|
|
131
|
+
'0' => { :language_id => Language.first.id }
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
subject_language = study_subject.subject_languages.first
|
|
135
|
+
assert_difference( 'SubjectLanguage.count', -1 ){
|
|
136
|
+
study_subject.update_attributes(:subject_languages_attributes => {
|
|
137
|
+
'0' => { :id => subject_language.id, :_destroy => 1 }
|
|
138
|
+
})
|
|
139
|
+
}
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
# This is just a collection of race related tests
|
|
4
|
+
# for StudySubject separated only for clarity due
|
|
5
|
+
# to the size of the StudySubjectTest class.
|
|
6
|
+
class Ccls::StudySubjectOperationalEventsTest < ActiveSupport::TestCase
|
|
7
|
+
|
|
8
|
+
test "should create newSubject operational event on creation" do
|
|
9
|
+
study_subject = nil
|
|
10
|
+
assert_difference('OperationalEventType.count',0) { # make sure it didn't create it
|
|
11
|
+
assert_difference('OperationalEvent.count',1) {
|
|
12
|
+
assert_difference('StudySubject.count',1) {
|
|
13
|
+
study_subject = Factory(:study_subject)
|
|
14
|
+
} } }
|
|
15
|
+
ccls_enrollment = study_subject.enrollments.find_by_project_id(Project['ccls'].id)
|
|
16
|
+
assert_not_nil ccls_enrollment
|
|
17
|
+
assert_not_nil ccls_enrollment.operational_events.find_by_operational_event_type_id(
|
|
18
|
+
OperationalEventType['newSubject'].id )
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
test "should create subjectDied operational event when vital status changed to deceased" do
|
|
22
|
+
study_subject = Factory(:study_subject).reload
|
|
23
|
+
assert_not_nil study_subject.vital_status
|
|
24
|
+
assert_difference('OperationalEventType.count',0) { # make sure it didn't create it
|
|
25
|
+
assert_difference('OperationalEvent.count',1) {
|
|
26
|
+
study_subject.update_attributes(:vital_status_id => VitalStatus['deceased'].id)
|
|
27
|
+
} }
|
|
28
|
+
assert_equal study_subject.reload.vital_status, VitalStatus['deceased']
|
|
29
|
+
ccls_enrollment = study_subject.enrollments.find_by_project_id(Project['ccls'].id)
|
|
30
|
+
assert_not_nil ccls_enrollment
|
|
31
|
+
assert_not_nil ccls_enrollment.operational_events.find_by_operational_event_type_id(
|
|
32
|
+
OperationalEventType['subjectDied'].id )
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
test "should return nil for subject's screener_complete_date_for_open_project" <<
|
|
36
|
+
" when subject has no associated operational event type" do
|
|
37
|
+
study_subject = Factory(:study_subject)
|
|
38
|
+
assert_nil study_subject.screener_complete_date_for_open_project
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
test "should return date for subject's screener_complete_date_for_open_project" <<
|
|
42
|
+
" when subject has associated operational event type" do
|
|
43
|
+
study_subject = Factory(:study_subject)
|
|
44
|
+
assert_nil study_subject.screener_complete_date_for_open_project
|
|
45
|
+
ccls_enrollment = study_subject.enrollments.find_by_project_id(Project['ccls'].id)
|
|
46
|
+
ccls_enrollment.operational_events.create(
|
|
47
|
+
:operational_event_type_id => OperationalEventType['screener_complete'].id,
|
|
48
|
+
:occurred_on => Date.today)
|
|
49
|
+
date = study_subject.screener_complete_date_for_open_project
|
|
50
|
+
assert_equal date, Date.today
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
end
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
# This is just a collection of patient related tests
|
|
4
|
+
# for StudySubject separated only for clarity due
|
|
5
|
+
# to the size of the StudySubjectTest class.
|
|
6
|
+
class Ccls::StudySubjectPatientTest < ActiveSupport::TestCase
|
|
7
|
+
|
|
8
|
+
%w( admit_date organization
|
|
9
|
+
organization_id hospital_no
|
|
10
|
+
).each do |method_name|
|
|
11
|
+
|
|
12
|
+
test "should respond to #{method_name}" do
|
|
13
|
+
study_subject = create_study_subject
|
|
14
|
+
assert study_subject.respond_to?(method_name)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# test "set organization for complete case study subject factory test" do
|
|
20
|
+
# # Factory only does a merge, NOT a deep_merge, so this won' work
|
|
21
|
+
# s = Factory(:complete_case_study_subject,
|
|
22
|
+
# :patient_attributes => { :organization_id => Hospital.last.organization_id } )
|
|
23
|
+
# assert Hospital.first != Hospital.last
|
|
24
|
+
# assert_equal s.organization_id, Hospital.last.organization_id
|
|
25
|
+
# end
|
|
26
|
+
|
|
27
|
+
test "should create case study_subject and accept_nested_attributes_for patient" do
|
|
28
|
+
assert_difference( 'Patient.count', 1) {
|
|
29
|
+
assert_difference( "StudySubject.count", 1 ) {
|
|
30
|
+
study_subject = Factory(:case_study_subject,
|
|
31
|
+
:patient_attributes => Factory.attributes_for(:patient))
|
|
32
|
+
assert study_subject.is_case?
|
|
33
|
+
assert !study_subject.new_record?,
|
|
34
|
+
"#{study_subject.errors.full_messages.to_sentence}"
|
|
35
|
+
} }
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
test "should NOT create non-case study_subject with patient" do
|
|
39
|
+
assert_difference( 'Patient.count', 0) {
|
|
40
|
+
assert_difference( "StudySubject.count", 0 ) {
|
|
41
|
+
study_subject = create_study_subject(
|
|
42
|
+
:patient_attributes => Factory.attributes_for(:patient))
|
|
43
|
+
assert !study_subject.is_case?
|
|
44
|
+
assert study_subject.errors.on(:patient) # no type
|
|
45
|
+
assert study_subject.new_record?,
|
|
46
|
+
"#{study_subject.errors.full_messages.to_sentence}"
|
|
47
|
+
} }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
test "should create patient for case study_subject" do
|
|
51
|
+
assert_difference( 'Patient.count', 1) {
|
|
52
|
+
assert_difference( "StudySubject.count", 1 ) {
|
|
53
|
+
study_subject = Factory(:case_study_subject)
|
|
54
|
+
assert study_subject.is_case?
|
|
55
|
+
assert !study_subject.new_record?,
|
|
56
|
+
"#{study_subject.errors.full_messages.to_sentence}"
|
|
57
|
+
patient = Factory(:patient, :study_subject => study_subject)
|
|
58
|
+
assert !patient.new_record?,
|
|
59
|
+
"#{patient.errors.full_messages.to_sentence}"
|
|
60
|
+
} }
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
test "should NOT create patient for non-case study_subject" do
|
|
64
|
+
assert_difference( 'Patient.count', 0) {
|
|
65
|
+
assert_difference( "StudySubject.count", 1 ) {
|
|
66
|
+
study_subject = create_study_subject
|
|
67
|
+
assert !study_subject.is_case?
|
|
68
|
+
assert !study_subject.new_record?,
|
|
69
|
+
"#{study_subject.errors.full_messages.to_sentence}"
|
|
70
|
+
patient = Factory.build(:patient, :study_subject => study_subject)
|
|
71
|
+
patient.save # avoid an exception being raised
|
|
72
|
+
assert patient.errors.on(:study_subject)
|
|
73
|
+
} }
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
test "should NOT create study_subject with empty patient" do
|
|
77
|
+
assert_difference( 'Patient.count', 0) {
|
|
78
|
+
assert_difference( "StudySubject.count", 0 ) {
|
|
79
|
+
study_subject = create_study_subject( :patient_attributes => {})
|
|
80
|
+
assert study_subject.errors.on('patient.diagnosis_id')
|
|
81
|
+
assert study_subject.errors.on_attr_and_type?('patient.diagnosis_id',:blank)
|
|
82
|
+
assert study_subject.errors.on('patient.hospital_no')
|
|
83
|
+
assert study_subject.errors.on_attr_and_type?('patient.hospital_no',:blank)
|
|
84
|
+
assert study_subject.errors.on('patient.admit_date')
|
|
85
|
+
assert study_subject.errors.on_attr_and_type?('patient.admit_date',:blank)
|
|
86
|
+
assert study_subject.errors.on('patient.organization_id')
|
|
87
|
+
assert study_subject.errors.on_attr_and_type?('patient.organization_id',:blank)
|
|
88
|
+
} }
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
test "should NOT destroy patient with study_subject" do
|
|
92
|
+
assert_difference('StudySubject.count',1) {
|
|
93
|
+
assert_difference('Patient.count',1) {
|
|
94
|
+
@study_subject = Factory(:patient).study_subject
|
|
95
|
+
} }
|
|
96
|
+
assert_difference('StudySubject.count',-1) {
|
|
97
|
+
assert_difference('Patient.count',0) {
|
|
98
|
+
@study_subject.destroy
|
|
99
|
+
} }
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Delegated patient fields
|
|
103
|
+
%w( admit_date organization
|
|
104
|
+
organization_id hospital_no
|
|
105
|
+
).each do |method_name|
|
|
106
|
+
|
|
107
|
+
test "should return nil #{method_name} without patient" do
|
|
108
|
+
study_subject = create_study_subject
|
|
109
|
+
assert_nil study_subject.send(method_name)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
test "should return #{method_name} with patient" do
|
|
113
|
+
study_subject = create_study_subject(
|
|
114
|
+
:patient_attributes => Factory.attributes_for(:patient))
|
|
115
|
+
assert_not_nil study_subject.send(method_name)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
test "should return 'no oncologist specified' for study_subject without patient" do
|
|
121
|
+
study_subject = create_study_subject.reload
|
|
122
|
+
assert_nil study_subject.patient
|
|
123
|
+
assert_equal '[no oncologist specified]', study_subject.admitting_oncologist
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
test "should return 'no oncologist specified' for study_subject with null patient#admitting_oncologist" do
|
|
127
|
+
assert_difference('Patient.count',1) {
|
|
128
|
+
assert_difference('StudySubject.count',1) {
|
|
129
|
+
study_subject = create_patient(:admitting_oncologist => nil
|
|
130
|
+
).study_subject.reload
|
|
131
|
+
assert_equal '[no oncologist specified]', study_subject.admitting_oncologist
|
|
132
|
+
} }
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
test "should return 'no oncologist specified' for study_subject with blank patient#admitting_oncologist" do
|
|
136
|
+
assert_difference('Patient.count',1) {
|
|
137
|
+
assert_difference('StudySubject.count',1) {
|
|
138
|
+
study_subject = create_patient(:admitting_oncologist => ''
|
|
139
|
+
).study_subject.reload
|
|
140
|
+
assert_equal '[no oncologist specified]', study_subject.admitting_oncologist
|
|
141
|
+
} }
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
test "should return admitting_oncologist for study_subject with patient#admitting_oncologist" do
|
|
145
|
+
assert_difference('Patient.count',1) {
|
|
146
|
+
assert_difference('StudySubject.count',1) {
|
|
147
|
+
study_subject = create_patient(:admitting_oncologist => 'Dr Jim'
|
|
148
|
+
).study_subject.reload
|
|
149
|
+
assert_equal 'Dr Jim', study_subject.admitting_oncologist
|
|
150
|
+
} }
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
test "should set study_subject.reference_date to self.patient.admit_date on create" do
|
|
154
|
+
create_case_study_subject_with_patient
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
test "should update all matching study_subjects' reference date " <<
|
|
158
|
+
"with updated admit date" do
|
|
159
|
+
study_subject = create_case_study_subject(
|
|
160
|
+
:matchingid => '12345',
|
|
161
|
+
:patient_attributes => Factory.attributes_for(:patient)).reload
|
|
162
|
+
other = create_study_subject( :matchingid => '12345' )
|
|
163
|
+
nobody = create_study_subject( :matchingid => '54321' )
|
|
164
|
+
# admit_date is now required, so will exist initially
|
|
165
|
+
# assert_nil study_subject.reference_date
|
|
166
|
+
# assert_nil study_subject.patient.admit_date
|
|
167
|
+
# assert_nil other.reference_date
|
|
168
|
+
assert_nil nobody.reference_date
|
|
169
|
+
study_subject.patient.update_attributes(
|
|
170
|
+
:admit_date => Date.yesterday )
|
|
171
|
+
assert_not_nil study_subject.patient.admit_date
|
|
172
|
+
assert_not_nil study_subject.reload.reference_date
|
|
173
|
+
assert_not_nil other.reload.reference_date
|
|
174
|
+
assert_nil nobody.reload.reference_date
|
|
175
|
+
assert_equal study_subject.reference_date, study_subject.patient.admit_date
|
|
176
|
+
assert_equal study_subject.reference_date, other.reference_date
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
test "should set study_subject.reference_date to matching patient.admit_date " <<
|
|
180
|
+
"on create with patient created first" do
|
|
181
|
+
study_subject = create_case_study_subject_with_patient
|
|
182
|
+
other = create_study_subject( :matchingid => '12345' )
|
|
183
|
+
assert_not_nil other.reload.reference_date
|
|
184
|
+
assert_equal other.reference_date, study_subject.reference_date
|
|
185
|
+
assert_equal other.reference_date, study_subject.patient.admit_date
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
test "should set study_subject.reference_date to matching patient.admit_date " <<
|
|
189
|
+
"on create with patient created last" do
|
|
190
|
+
other = create_study_subject( :matchingid => '12345' )
|
|
191
|
+
study_subject = create_case_study_subject_with_patient
|
|
192
|
+
assert_not_nil other.reload.reference_date
|
|
193
|
+
assert_equal other.reference_date, study_subject.reference_date
|
|
194
|
+
assert_equal other.reference_date, study_subject.patient.admit_date
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
test "should nullify study_subject.reference_date if matching patient changes matchingid" do
|
|
198
|
+
other = create_study_subject( :matchingid => '12345' )
|
|
199
|
+
study_subject = create_case_study_subject_with_patient
|
|
200
|
+
assert_not_nil other.reload.reference_date
|
|
201
|
+
study_subject.update_attributes(:matchingid => '12346')
|
|
202
|
+
assert_nil other.reload.reference_date
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
test "should nullify study_subject.reference_date if matching patient nullifies matchingid" do
|
|
206
|
+
other = create_study_subject( :matchingid => '12345' )
|
|
207
|
+
study_subject = create_case_study_subject_with_patient
|
|
208
|
+
assert_not_nil other.reload.reference_date
|
|
209
|
+
study_subject.update_attributes(:matchingid => nil)
|
|
210
|
+
assert_nil other.reload.reference_date
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
test "should nullify study_subject.reference_date if matching patient nullifies admit_date (admit_date now required)" do
|
|
214
|
+
other = create_study_subject( :matchingid => '12345' )
|
|
215
|
+
study_subject = create_case_study_subject_with_patient
|
|
216
|
+
assert_not_nil study_subject.patient.admit_date
|
|
217
|
+
assert_not_nil study_subject.reference_date
|
|
218
|
+
assert_not_nil other.reload.reference_date
|
|
219
|
+
# admit_date is now required, so can't nullify admit_date
|
|
220
|
+
# This actually now returns false
|
|
221
|
+
assert !study_subject.patient.update_attributes(:admit_date => nil)
|
|
222
|
+
assert_not_nil study_subject.patient.reload.admit_date
|
|
223
|
+
assert_not_nil study_subject.reference_date
|
|
224
|
+
assert_not_nil other.reload.reference_date
|
|
225
|
+
# assert_nil other.reload.reference_date
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
protected
|
|
229
|
+
|
|
230
|
+
# def create_study_subject_with_matchingid(matchingid='12345')
|
|
231
|
+
## study_subject = create_study_subject(
|
|
232
|
+
## :identifier_attributes => Factory.attributes_for(:identifier,
|
|
233
|
+
## { :matchingid => matchingid })).reload
|
|
234
|
+
# study_subject = create_study_subject( :matchingid => matchingid ).reload
|
|
235
|
+
# end
|
|
236
|
+
|
|
237
|
+
# Used more than once so ...
|
|
238
|
+
def create_case_study_subject_with_patient
|
|
239
|
+
study_subject = create_case_study_subject(
|
|
240
|
+
:matchingid => '12345', # NOTE expected
|
|
241
|
+
:patient_attributes => Factory.attributes_for(:patient,
|
|
242
|
+
{ :admit_date => Date.yesterday })).reload
|
|
243
|
+
assert_not_nil study_subject.reference_date
|
|
244
|
+
assert_not_nil study_subject.patient.admit_date
|
|
245
|
+
assert_equal study_subject.reference_date, study_subject.patient.admit_date
|
|
246
|
+
study_subject
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
end
|