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
data/rails/init.rb
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class Ccls::AbstractSearchTest < ActiveSupport::TestCase
|
|
4
|
+
|
|
5
|
+
# test "should return AbstractSearch" do
|
|
6
|
+
# assert AbstractSearch().is_a?(AbstractSearch)
|
|
7
|
+
# end
|
|
8
|
+
|
|
9
|
+
test "should respond to search" do
|
|
10
|
+
assert Abstract.respond_to?(:search)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
test "should return Array" do
|
|
14
|
+
abstracts = Abstract.search()
|
|
15
|
+
assert abstracts.is_a?(Array)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
test "should include abstract" do
|
|
19
|
+
abstract = create_abstract
|
|
20
|
+
# there are already about 40 in the fixtures
|
|
21
|
+
# so we need to get more than that to include the last one.
|
|
22
|
+
abstracts = Abstract.search(:per_page => 50)
|
|
23
|
+
assert abstracts.include?(abstract)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
test "should include abstract without pagination" do
|
|
27
|
+
abstract = create_abstract
|
|
28
|
+
abstracts = Abstract.search(:paginate => false)
|
|
29
|
+
assert abstracts.include?(abstract)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
test "should NOT order by bogus column with dir" do
|
|
33
|
+
Abstract.destroy_all
|
|
34
|
+
a1,a2,a3 = create_abstracts(3)
|
|
35
|
+
abstracts = Abstract.search(
|
|
36
|
+
:order => 'whatever', :dir => 'asc')
|
|
37
|
+
assert_equal [a1,a2,a3], abstracts
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
test "should NOT order by bogus column" do
|
|
41
|
+
Abstract.destroy_all
|
|
42
|
+
a1,a2,a3 = create_abstracts(3)
|
|
43
|
+
abstracts = Abstract.search(:order => 'whatever')
|
|
44
|
+
assert_equal [a1,a2,a3], abstracts
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
test "should order by id asc by default" do
|
|
48
|
+
Abstract.destroy_all
|
|
49
|
+
a1,a2,a3 = create_abstracts(3)
|
|
50
|
+
abstracts = Abstract.search(
|
|
51
|
+
:order => 'id')
|
|
52
|
+
assert_equal [a1,a2,a3], abstracts
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
test "should order by id asc" do
|
|
56
|
+
Abstract.destroy_all
|
|
57
|
+
a1,a2,a3 = create_abstracts(3)
|
|
58
|
+
abstracts = Abstract.search(
|
|
59
|
+
:order => 'id', :dir => 'asc')
|
|
60
|
+
assert_equal [a1,a2,a3], abstracts
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
test "should order by id desc" do
|
|
64
|
+
Abstract.destroy_all
|
|
65
|
+
a1,a2,a3 = create_abstracts(3)
|
|
66
|
+
abstracts = Abstract.search(
|
|
67
|
+
:order => 'id', :dir => 'desc')
|
|
68
|
+
assert_equal [a3,a2,a1], abstracts
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
test "should include abstract by q first_name" do
|
|
72
|
+
a1,a2 = create_abstracts_with_first_names('Michael','Bob')
|
|
73
|
+
assert_equal 'Michael', a1.study_subject.first_name
|
|
74
|
+
abstracts = Abstract.search(:q => 'mi ch ha')
|
|
75
|
+
assert abstracts.include?(a1)
|
|
76
|
+
assert !abstracts.include?(a2)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
test "should include abstract by q last_name" do
|
|
80
|
+
a1,a2 = create_abstracts_with_last_names('Michael','Bob')
|
|
81
|
+
assert_equal 'Michael', a1.study_subject.last_name
|
|
82
|
+
abstracts = Abstract.search(:q => 'cha ael')
|
|
83
|
+
assert abstracts.include?(a1)
|
|
84
|
+
assert !abstracts.include?(a2)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
test "should include abstract by q childid" do
|
|
88
|
+
a1,a2 = create_abstracts_with_childids(999999,'1')
|
|
89
|
+
assert_equal 999999, a1.study_subject.childid
|
|
90
|
+
abstracts = Abstract.search(:q => a1.study_subject.childid)
|
|
91
|
+
assert abstracts.include?(a1)
|
|
92
|
+
assert !abstracts.include?(a2)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
test "should include abstract by q patid" do
|
|
96
|
+
a1,a2 = create_abstracts_with_patids(9999,'1')
|
|
97
|
+
assert_equal '9999', a1.study_subject.patid
|
|
98
|
+
abstracts = Abstract.search(:q => a1.study_subject.patid)
|
|
99
|
+
assert abstracts.include?(a1)
|
|
100
|
+
assert !abstracts.include?(a2)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
test "should find abstracts that are merged" do
|
|
104
|
+
a1,a2 = create_abstracts(2)
|
|
105
|
+
a1.merged_by = Factory(:user)
|
|
106
|
+
a1.save
|
|
107
|
+
assert a1.merged?
|
|
108
|
+
assert !a2.merged?
|
|
109
|
+
abstracts = Abstract.search(:merged => true)
|
|
110
|
+
assert abstracts.include?(a1)
|
|
111
|
+
assert !abstracts.include?(a2)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
protected
|
|
115
|
+
|
|
116
|
+
def create_abstracts(count=0,options={})
|
|
117
|
+
abstracts = []
|
|
118
|
+
count.times{ abstracts.push(create_abstract(options)) }
|
|
119
|
+
return abstracts
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def create_abstract_with_first_name(first_name)
|
|
123
|
+
study_subject = create_study_subject_with_first_name(first_name)
|
|
124
|
+
abstract = create_abstract
|
|
125
|
+
study_subject.abstracts << abstract
|
|
126
|
+
abstract
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def create_abstract_with_last_name(last_name)
|
|
130
|
+
study_subject = create_study_subject_with_last_name(last_name)
|
|
131
|
+
abstract = create_abstract
|
|
132
|
+
study_subject.abstracts << abstract
|
|
133
|
+
abstract
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def create_abstract_with_childid(childid)
|
|
137
|
+
study_subject = create_study_subject_with_childid(childid)
|
|
138
|
+
abstract = create_abstract
|
|
139
|
+
study_subject.abstracts << abstract
|
|
140
|
+
abstract
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def create_abstract_with_patid(patid)
|
|
144
|
+
study_subject = create_study_subject_with_patid(patid)
|
|
145
|
+
abstract = create_abstract
|
|
146
|
+
study_subject.abstracts << abstract
|
|
147
|
+
abstract
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
end
|
|
@@ -0,0 +1,674 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class Ccls::AbstractTest < ActiveSupport::TestCase
|
|
4
|
+
|
|
5
|
+
assert_should_belong_to :study_subject
|
|
6
|
+
assert_should_protect( :study_subject_id, :study_subject, :entry_1_by_uid,
|
|
7
|
+
:entry_2_by_uid, :merged_by_uid )
|
|
8
|
+
assert_should_not_require( *Abstract.db_fields )
|
|
9
|
+
|
|
10
|
+
assert_should_require_length(
|
|
11
|
+
:response_classification_day_7,
|
|
12
|
+
:response_classification_day_14,
|
|
13
|
+
:response_classification_day_28,
|
|
14
|
+
:maximum => 2 )
|
|
15
|
+
|
|
16
|
+
assert_should_require_length(
|
|
17
|
+
:cytogen_chromosome_number,
|
|
18
|
+
:maximum => 3 )
|
|
19
|
+
|
|
20
|
+
assert_should_require_length(
|
|
21
|
+
:flow_cyto_other_marker_1,
|
|
22
|
+
:flow_cyto_other_marker_2,
|
|
23
|
+
:flow_cyto_other_marker_3,
|
|
24
|
+
:flow_cyto_other_marker_4,
|
|
25
|
+
:flow_cyto_other_marker_5,
|
|
26
|
+
:response_other1_value_day_7,
|
|
27
|
+
:response_other1_value_day_14,
|
|
28
|
+
:response_other2_value_day_7,
|
|
29
|
+
:response_other2_value_day_14,
|
|
30
|
+
:response_other3_value_day_14,
|
|
31
|
+
:response_other4_value_day_14,
|
|
32
|
+
:response_other5_value_day_14,
|
|
33
|
+
:maximum => 4 )
|
|
34
|
+
|
|
35
|
+
assert_should_require_length(
|
|
36
|
+
:normal_cytogen,
|
|
37
|
+
:is_cytogen_hosp_fish_t1221_done,
|
|
38
|
+
:is_karyotype_normal,
|
|
39
|
+
:physical_neuro,
|
|
40
|
+
:physical_other_soft_2,
|
|
41
|
+
:physical_gingival,
|
|
42
|
+
:physical_leukemic_skin,
|
|
43
|
+
:physical_lymph,
|
|
44
|
+
:physical_spleen,
|
|
45
|
+
:physical_testicle,
|
|
46
|
+
:physical_other_soft,
|
|
47
|
+
:is_hypodiploid,
|
|
48
|
+
:is_hyperdiploid,
|
|
49
|
+
:is_diploid,
|
|
50
|
+
:dna_index,
|
|
51
|
+
:cytogen_is_hyperdiploidy,
|
|
52
|
+
:maximum => 5 )
|
|
53
|
+
|
|
54
|
+
assert_should_require_length(
|
|
55
|
+
:cytogen_t1221,
|
|
56
|
+
:cytogen_inv16,
|
|
57
|
+
:cytogen_t119,
|
|
58
|
+
:cytogen_t821,
|
|
59
|
+
:cytogen_t1517,
|
|
60
|
+
:maximum => 9 )
|
|
61
|
+
|
|
62
|
+
assert_should_require_length(
|
|
63
|
+
:response_tdt_day_7,
|
|
64
|
+
:response_tdt_day_14,
|
|
65
|
+
:response_cd10_day_7,
|
|
66
|
+
:response_cd10_day_14,
|
|
67
|
+
:response_cd13_day_7,
|
|
68
|
+
:response_cd13_day_14,
|
|
69
|
+
:response_cd14_day_7,
|
|
70
|
+
:response_cd14_day_14,
|
|
71
|
+
:response_cd15_day_7,
|
|
72
|
+
:response_cd15_day_14,
|
|
73
|
+
:response_cd19_day_7,
|
|
74
|
+
:response_cd19_day_14,
|
|
75
|
+
:response_cd19cd10_day_7,
|
|
76
|
+
:response_cd19cd10_day_14,
|
|
77
|
+
:response_cd1a_day_14,
|
|
78
|
+
:response_cd2a_day_14,
|
|
79
|
+
:response_cd20_day_7,
|
|
80
|
+
:response_cd20_day_14,
|
|
81
|
+
:response_cd3_day_7,
|
|
82
|
+
:response_cd3a_day_14,
|
|
83
|
+
:response_cd33_day_7,
|
|
84
|
+
:response_cd33_day_14,
|
|
85
|
+
:response_cd34_day_7,
|
|
86
|
+
:response_cd34_day_14,
|
|
87
|
+
:response_cd4a_day_14,
|
|
88
|
+
:response_cd5a_day_14,
|
|
89
|
+
:response_cd56_day_14,
|
|
90
|
+
:response_cd61_day_14,
|
|
91
|
+
:response_cd7a_day_14,
|
|
92
|
+
:response_cd8a_day_14,
|
|
93
|
+
:flow_cyto_cd10,
|
|
94
|
+
:flow_cyto_igm,
|
|
95
|
+
:flow_cyto_bm_kappa,
|
|
96
|
+
:flow_cyto_bm_lambda,
|
|
97
|
+
:flow_cyto_cd10_19,
|
|
98
|
+
:flow_cyto_cd19,
|
|
99
|
+
:flow_cyto_cd20,
|
|
100
|
+
:flow_cyto_cd21,
|
|
101
|
+
:flow_cyto_cd22,
|
|
102
|
+
:flow_cyto_cd23,
|
|
103
|
+
:flow_cyto_cd24,
|
|
104
|
+
:flow_cyto_cd40,
|
|
105
|
+
:flow_cyto_surface_ig,
|
|
106
|
+
:flow_cyto_cd1a,
|
|
107
|
+
:flow_cyto_cd2,
|
|
108
|
+
:flow_cyto_cd3,
|
|
109
|
+
:flow_cyto_cd3_cd4,
|
|
110
|
+
:flow_cyto_cd3_cd8,
|
|
111
|
+
:flow_cyto_cd4,
|
|
112
|
+
:flow_cyto_cd5,
|
|
113
|
+
:flow_cyto_cd7,
|
|
114
|
+
:flow_cyto_cd8,
|
|
115
|
+
:flow_cyto_cd11b,
|
|
116
|
+
:flow_cyto_cd11c,
|
|
117
|
+
:flow_cyto_cd13,
|
|
118
|
+
:flow_cyto_cd15,
|
|
119
|
+
:flow_cyto_cd33,
|
|
120
|
+
:flow_cyto_cd41,
|
|
121
|
+
:flow_cyto_cdw65,
|
|
122
|
+
:flow_cyto_cd34,
|
|
123
|
+
:flow_cyto_cd61,
|
|
124
|
+
:flow_cyto_cd14,
|
|
125
|
+
:flow_cyto_glycoa,
|
|
126
|
+
:flow_cyto_cd16,
|
|
127
|
+
:flow_cyto_cd56,
|
|
128
|
+
:flow_cyto_cd57,
|
|
129
|
+
:flow_cyto_cd9,
|
|
130
|
+
:flow_cyto_cd25,
|
|
131
|
+
:flow_cyto_cd38,
|
|
132
|
+
:flow_cyto_cd45,
|
|
133
|
+
:flow_cyto_cd71,
|
|
134
|
+
:flow_cyto_tdt,
|
|
135
|
+
:flow_cyto_hladr,
|
|
136
|
+
:response_hladr_day_7,
|
|
137
|
+
:response_hladr_day_14,
|
|
138
|
+
:maximum => 10 )
|
|
139
|
+
|
|
140
|
+
assert_should_require_length(
|
|
141
|
+
:response_blasts_units_day_7,
|
|
142
|
+
:response_blasts_units_day_14,
|
|
143
|
+
:response_blasts_units_day_28,
|
|
144
|
+
:other_dna_measure,
|
|
145
|
+
:response_fab_subtype,
|
|
146
|
+
:maximum => 15 )
|
|
147
|
+
|
|
148
|
+
assert_should_require_length(
|
|
149
|
+
:flow_cyto_other_marker_1_name,
|
|
150
|
+
:flow_cyto_other_marker_2_name,
|
|
151
|
+
:flow_cyto_other_marker_3_name,
|
|
152
|
+
:flow_cyto_other_marker_4_name,
|
|
153
|
+
:flow_cyto_other_marker_5_name,
|
|
154
|
+
:maximum => 20 )
|
|
155
|
+
|
|
156
|
+
assert_should_require_length(
|
|
157
|
+
:response_other1_name_day_7,
|
|
158
|
+
:response_other1_name_day_14,
|
|
159
|
+
:response_other2_name_day_7,
|
|
160
|
+
:response_other2_name_day_14,
|
|
161
|
+
:response_other3_name_day_14,
|
|
162
|
+
:response_other4_name_day_14,
|
|
163
|
+
:response_other5_name_day_14,
|
|
164
|
+
:maximum => 25 )
|
|
165
|
+
|
|
166
|
+
assert_should_require_length(
|
|
167
|
+
:cytogen_other_trans_1,
|
|
168
|
+
:cytogen_other_trans_2,
|
|
169
|
+
:cytogen_other_trans_3,
|
|
170
|
+
:cytogen_other_trans_4,
|
|
171
|
+
:cytogen_other_trans_5,
|
|
172
|
+
:cytogen_other_trans_6,
|
|
173
|
+
:cytogen_other_trans_7,
|
|
174
|
+
:cytogen_other_trans_8,
|
|
175
|
+
:cytogen_other_trans_9,
|
|
176
|
+
:cytogen_other_trans_10,
|
|
177
|
+
:maximum => 35 )
|
|
178
|
+
|
|
179
|
+
assert_should_require_length(
|
|
180
|
+
:flow_cyto_igm_text,
|
|
181
|
+
:flow_cyto_bm_kappa_text,
|
|
182
|
+
:flow_cyto_bm_lambda_text,
|
|
183
|
+
:flow_cyto_cd10_text,
|
|
184
|
+
:flow_cyto_cd19_text,
|
|
185
|
+
:flow_cyto_cd10_19_text,
|
|
186
|
+
:flow_cyto_cd20_text,
|
|
187
|
+
:flow_cyto_cd21_text,
|
|
188
|
+
:flow_cyto_cd22_text,
|
|
189
|
+
:flow_cyto_cd23_text,
|
|
190
|
+
:flow_cyto_cd24_text,
|
|
191
|
+
:flow_cyto_cd40_text,
|
|
192
|
+
:flow_cyto_surface_ig_text,
|
|
193
|
+
:flow_cyto_cd1a_text,
|
|
194
|
+
:flow_cyto_cd2_text,
|
|
195
|
+
:flow_cyto_cd3_text,
|
|
196
|
+
:flow_cyto_cd4_text,
|
|
197
|
+
:flow_cyto_cd5_text,
|
|
198
|
+
:flow_cyto_cd7_text,
|
|
199
|
+
:flow_cyto_cd8_text,
|
|
200
|
+
:flow_cyto_cd3_cd4_text,
|
|
201
|
+
:flow_cyto_cd3_cd8_text,
|
|
202
|
+
:flow_cyto_cd11b_text,
|
|
203
|
+
:flow_cyto_cd11c_text,
|
|
204
|
+
:flow_cyto_cd13_text,
|
|
205
|
+
:flow_cyto_cd15_text,
|
|
206
|
+
:flow_cyto_cd33_text,
|
|
207
|
+
:flow_cyto_cd41_text,
|
|
208
|
+
:flow_cyto_cdw65_text,
|
|
209
|
+
:flow_cyto_cd34_text,
|
|
210
|
+
:flow_cyto_cd61_text,
|
|
211
|
+
:flow_cyto_cd14_text,
|
|
212
|
+
:flow_cyto_glycoa_text,
|
|
213
|
+
:flow_cyto_cd16_text,
|
|
214
|
+
:flow_cyto_cd56_text,
|
|
215
|
+
:flow_cyto_cd57_text,
|
|
216
|
+
:flow_cyto_cd9_text,
|
|
217
|
+
:flow_cyto_cd25_text,
|
|
218
|
+
:flow_cyto_cd38_text,
|
|
219
|
+
:flow_cyto_cd45_text,
|
|
220
|
+
:flow_cyto_cd71_text,
|
|
221
|
+
:flow_cyto_tdt_text,
|
|
222
|
+
:flow_cyto_hladr_text,
|
|
223
|
+
:flow_cyto_other_marker_1_text,
|
|
224
|
+
:flow_cyto_other_marker_2_text,
|
|
225
|
+
:flow_cyto_other_marker_3_text,
|
|
226
|
+
:flow_cyto_other_marker_4_text,
|
|
227
|
+
:flow_cyto_other_marker_5_text,
|
|
228
|
+
:ucb_fish_results,
|
|
229
|
+
:fab_classification,
|
|
230
|
+
:diagnosis_icdo_number,
|
|
231
|
+
:cytogen_t922,
|
|
232
|
+
:maximum => 50 )
|
|
233
|
+
|
|
234
|
+
assert_should_require_length(
|
|
235
|
+
:diagnosis_icdo_description,
|
|
236
|
+
:maximum => 55 )
|
|
237
|
+
|
|
238
|
+
assert_should_require_length(
|
|
239
|
+
:ploidy_comment,
|
|
240
|
+
:maximum => 100 )
|
|
241
|
+
|
|
242
|
+
assert_should_require_length(
|
|
243
|
+
:csf_red_blood_count_text,
|
|
244
|
+
:blasts_are_present,
|
|
245
|
+
:peripheral_blood_in_csf,
|
|
246
|
+
:chemo_protocol_name,
|
|
247
|
+
:conventional_karyotype_results,
|
|
248
|
+
:hospital_fish_results,
|
|
249
|
+
:hyperdiploidy_by,
|
|
250
|
+
:maximum => 250 )
|
|
251
|
+
|
|
252
|
+
assert_should_require_length(
|
|
253
|
+
:marrow_biopsy_diagnosis,
|
|
254
|
+
:marrow_aspirate_diagnosis,
|
|
255
|
+
:csf_white_blood_count_text,
|
|
256
|
+
:csf_comment,
|
|
257
|
+
:chemo_protocol_agent_description,
|
|
258
|
+
:chest_imaging_comment,
|
|
259
|
+
:cytogen_comment,
|
|
260
|
+
:discharge_summary,
|
|
261
|
+
:flow_cyto_remarks,
|
|
262
|
+
:response_comment_day_7,
|
|
263
|
+
:response_comment_day_14,
|
|
264
|
+
:histo_report_results,
|
|
265
|
+
:response_comment,
|
|
266
|
+
:maximum => 65000 )
|
|
267
|
+
|
|
268
|
+
test "explicit Factory abstract test" do
|
|
269
|
+
assert_difference('Abstract.count',1) {
|
|
270
|
+
@abstract = Factory(:abstract)
|
|
271
|
+
}
|
|
272
|
+
( not_nil = %w( id created_at updated_at cbc_percent_blasts_unknown ) ).each do |c|
|
|
273
|
+
assert_not_nil @abstract.send(c), "#{c} is nil"
|
|
274
|
+
end
|
|
275
|
+
( Abstract.column_names - not_nil ).each do |c|
|
|
276
|
+
assert_nil @abstract.send(c), "#{c} is not nil"
|
|
277
|
+
end
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
test "explicit Factory complete_abstract test" do
|
|
281
|
+
assert_difference('Abstract.count',1) {
|
|
282
|
+
# this factory randomly sets values, some of which can be nil
|
|
283
|
+
abstract = Factory(:complete_abstract)
|
|
284
|
+
}
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
test "should not convert weight if weight_units is null" do
|
|
288
|
+
abstract = Factory(:abstract,:weight_at_diagnosis => 100)
|
|
289
|
+
assert_equal 100, abstract.reload.weight_at_diagnosis
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
test "should not convert weight if weight_units is kg" do
|
|
293
|
+
abstract = Factory(:abstract,:weight_at_diagnosis => 100, :weight_units => 'kg')
|
|
294
|
+
assert_equal 100, abstract.reload.weight_at_diagnosis
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
test "should convert weight to kg if weight_units is lb" do
|
|
298
|
+
abstract = Factory(:abstract,:weight_at_diagnosis => 100, :weight_units => 'lb')
|
|
299
|
+
abstract.reload
|
|
300
|
+
assert_nil abstract.weight_units
|
|
301
|
+
assert_not_equal 100, abstract.weight_at_diagnosis
|
|
302
|
+
assert_in_delta 45.3, abstract.weight_at_diagnosis, 0.1
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
test "should not convert height if height_units is null" do
|
|
306
|
+
abstract = Factory(:abstract,:height_at_diagnosis => 100)
|
|
307
|
+
assert_equal 100, abstract.reload.height_at_diagnosis
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
test "should not convert height if height_units is cm" do
|
|
311
|
+
abstract = Factory(:abstract,:height_at_diagnosis => 100, :height_units => 'cm')
|
|
312
|
+
assert_equal 100, abstract.reload.height_at_diagnosis
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
test "should convert height to cm if height_units is in" do
|
|
316
|
+
abstract = Factory(:abstract,:height_at_diagnosis => 100, :height_units => 'in')
|
|
317
|
+
abstract.reload
|
|
318
|
+
assert_nil abstract.height_units
|
|
319
|
+
assert_not_equal 100, abstract.height_at_diagnosis
|
|
320
|
+
assert_in_delta 254, abstract.height_at_diagnosis, 0.1
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
# test "should return an array of ignorable columns" do
|
|
324
|
+
# abstract = Factory(:abstract)
|
|
325
|
+
# assert_equal abstract.ignorable_columns,
|
|
326
|
+
# ["id", "entry_1_by_uid", "entry_2_by_uid", "merged_by_uid",
|
|
327
|
+
# "created_at", "updated_at", "study_subject_id"]
|
|
328
|
+
# end
|
|
329
|
+
#
|
|
330
|
+
# test "should return hash of comparable attributes" do
|
|
331
|
+
# abstract = Factory(:abstract)
|
|
332
|
+
# assert abstract.comparable_attributes.is_a?(Hash)
|
|
333
|
+
# end
|
|
334
|
+
|
|
335
|
+
test "should return true if abstracts are the same" do
|
|
336
|
+
abstract1 = Factory(:abstract)
|
|
337
|
+
abstract2 = Factory(:abstract)
|
|
338
|
+
assert abstract1.is_the_same_as?(abstract2)
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
test "should return false if abstracts are not the same" do
|
|
342
|
+
abstract1 = Factory(:abstract)
|
|
343
|
+
abstract2 = Factory(:abstract, :height_at_diagnosis => 100 )
|
|
344
|
+
assert !abstract1.is_the_same_as?(abstract2)
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
test "should return empty hash if abstracts are the same" do
|
|
348
|
+
abstract1 = Factory(:abstract)
|
|
349
|
+
abstract2 = Factory(:abstract)
|
|
350
|
+
assert_equal Hash.new, abstract1.diff(abstract2)
|
|
351
|
+
assert abstract1.diff(abstract2).empty?
|
|
352
|
+
end
|
|
353
|
+
|
|
354
|
+
test "should return hash if abstracts are not the same" do
|
|
355
|
+
abstract1 = Factory(:abstract)
|
|
356
|
+
abstract2 = Factory(:abstract, :height_at_diagnosis => 100 )
|
|
357
|
+
assert !abstract1.diff(abstract2).empty?
|
|
358
|
+
assert abstract1.diff(abstract2).has_key?('height_at_diagnosis')
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
test "should NOT set days since diagnosis fields on create without diagnosed_on" do
|
|
362
|
+
abstract = Factory(:abstract)
|
|
363
|
+
assert_nil abstract.diagnosed_on
|
|
364
|
+
assert_nil abstract.response_day_7_days_since_diagnosis
|
|
365
|
+
assert_nil abstract.response_day_14_days_since_diagnosis
|
|
366
|
+
assert_nil abstract.response_day_28_days_since_diagnosis
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
test "should NOT set days since diagnosis fields on create without response_report_on" do
|
|
370
|
+
abstract = Factory(:abstract,
|
|
371
|
+
:diagnosed_on => ( Date.today - 10 ),
|
|
372
|
+
:response_report_on_day_7 => nil,
|
|
373
|
+
:response_report_on_day_14 => nil,
|
|
374
|
+
:response_report_on_day_28 => nil
|
|
375
|
+
)
|
|
376
|
+
assert_not_nil abstract.diagnosed_on
|
|
377
|
+
assert_nil abstract.response_day_7_days_since_diagnosis
|
|
378
|
+
assert_nil abstract.response_day_14_days_since_diagnosis
|
|
379
|
+
assert_nil abstract.response_day_28_days_since_diagnosis
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
test "should set days since diagnosis fields on create with diagnosed_on" do
|
|
383
|
+
today = Date.today
|
|
384
|
+
abstract = Factory(:abstract,
|
|
385
|
+
:diagnosed_on => ( today - 40 ),
|
|
386
|
+
:response_report_on_day_7 => ( today - 30 ),
|
|
387
|
+
:response_report_on_day_14 => ( today - 20 ),
|
|
388
|
+
:response_report_on_day_28 => ( today - 10 )
|
|
389
|
+
)
|
|
390
|
+
assert_not_nil abstract.diagnosed_on
|
|
391
|
+
assert_not_nil abstract.response_day_7_days_since_diagnosis
|
|
392
|
+
assert_equal 10, abstract.response_day_7_days_since_diagnosis
|
|
393
|
+
assert_not_nil abstract.response_day_14_days_since_diagnosis
|
|
394
|
+
assert_equal 20, abstract.response_day_14_days_since_diagnosis
|
|
395
|
+
assert_not_nil abstract.response_day_28_days_since_diagnosis
|
|
396
|
+
assert_equal 30, abstract.response_day_28_days_since_diagnosis
|
|
397
|
+
end
|
|
398
|
+
|
|
399
|
+
test "should NOT set days since treatment_began fields on create" <<
|
|
400
|
+
" without treatment_began_on" do
|
|
401
|
+
abstract = Factory(:abstract)
|
|
402
|
+
assert_nil abstract.treatment_began_on
|
|
403
|
+
assert_nil abstract.response_day_7_days_since_treatment_began
|
|
404
|
+
assert_nil abstract.response_day_14_days_since_treatment_began
|
|
405
|
+
assert_nil abstract.response_day_28_days_since_treatment_began
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
test "should NOT set days since treatment_began fields on create" <<
|
|
409
|
+
" without response_report_on" do
|
|
410
|
+
abstract = Factory(:abstract,
|
|
411
|
+
:treatment_began_on => ( Date.today - 10 ),
|
|
412
|
+
:response_report_on_day_7 => nil,
|
|
413
|
+
:response_report_on_day_14 => nil,
|
|
414
|
+
:response_report_on_day_28 => nil
|
|
415
|
+
)
|
|
416
|
+
assert_not_nil abstract.treatment_began_on
|
|
417
|
+
assert_nil abstract.response_day_7_days_since_treatment_began
|
|
418
|
+
assert_nil abstract.response_day_14_days_since_treatment_began
|
|
419
|
+
assert_nil abstract.response_day_28_days_since_treatment_began
|
|
420
|
+
end
|
|
421
|
+
|
|
422
|
+
test "should set days since treatment_began fields on create" <<
|
|
423
|
+
" with treatment_began_on" do
|
|
424
|
+
today = Date.today
|
|
425
|
+
abstract = Factory(:abstract,
|
|
426
|
+
:treatment_began_on => ( today - 40 ),
|
|
427
|
+
:response_report_on_day_7 => ( today - 30 ),
|
|
428
|
+
:response_report_on_day_14 => ( today - 20 ),
|
|
429
|
+
:response_report_on_day_28 => ( today - 10 )
|
|
430
|
+
)
|
|
431
|
+
assert_not_nil abstract.treatment_began_on
|
|
432
|
+
assert_not_nil abstract.response_day_7_days_since_treatment_began
|
|
433
|
+
assert_equal 10, abstract.response_day_7_days_since_treatment_began
|
|
434
|
+
assert_not_nil abstract.response_day_14_days_since_treatment_began
|
|
435
|
+
assert_equal 20, abstract.response_day_14_days_since_treatment_began
|
|
436
|
+
assert_not_nil abstract.response_day_28_days_since_treatment_began
|
|
437
|
+
assert_equal 30, abstract.response_day_28_days_since_treatment_began
|
|
438
|
+
end
|
|
439
|
+
|
|
440
|
+
test "should save a User as entry_1_by" do
|
|
441
|
+
assert_difference('User.count',1) {
|
|
442
|
+
assert_difference('Abstract.count',1) {
|
|
443
|
+
abstract = Factory(:abstract,:entry_1_by => Factory(:user))
|
|
444
|
+
assert abstract.entry_1_by.is_a?(User)
|
|
445
|
+
} }
|
|
446
|
+
end
|
|
447
|
+
|
|
448
|
+
test "should save a User as entry_2_by" do
|
|
449
|
+
assert_difference('User.count',1) {
|
|
450
|
+
assert_difference('Abstract.count',1) {
|
|
451
|
+
abstract = Factory(:abstract,:entry_2_by => Factory(:user))
|
|
452
|
+
assert abstract.entry_2_by.is_a?(User)
|
|
453
|
+
} }
|
|
454
|
+
end
|
|
455
|
+
|
|
456
|
+
test "should save a User as merged_by" do
|
|
457
|
+
assert_difference('User.count',1) {
|
|
458
|
+
assert_difference('Abstract.count',1) {
|
|
459
|
+
abstract = Factory(:abstract,:merged_by => Factory(:user))
|
|
460
|
+
assert abstract.merged_by.is_a?(User)
|
|
461
|
+
} }
|
|
462
|
+
end
|
|
463
|
+
|
|
464
|
+
test "should create first abstract for study_subject with current_user" do
|
|
465
|
+
assert_difference('StudySubject.count',1) {
|
|
466
|
+
@study_subject = create_case_study_subject_with_patid(1234)
|
|
467
|
+
assert_equal '1234', @study_subject.patid
|
|
468
|
+
}
|
|
469
|
+
@current_user = Factory(:user)
|
|
470
|
+
assert_difference('Abstract.count',1) {
|
|
471
|
+
abstract = create_abstract(:current_user => @current_user,
|
|
472
|
+
:study_subject => @study_subject)
|
|
473
|
+
assert_equal abstract.entry_1_by, @current_user
|
|
474
|
+
assert_equal abstract.entry_2_by, @current_user
|
|
475
|
+
assert_equal abstract.study_subject, @study_subject
|
|
476
|
+
}
|
|
477
|
+
end
|
|
478
|
+
|
|
479
|
+
test "should create second abstract for study_subject with current_user" do
|
|
480
|
+
assert_difference('StudySubject.count',1) {
|
|
481
|
+
@study_subject = create_case_study_subject_with_patid(1234)
|
|
482
|
+
assert_equal '1234', @study_subject.patid
|
|
483
|
+
}
|
|
484
|
+
@current_user = Factory(:user)
|
|
485
|
+
abstract = create_abstract(:current_user => @current_user,
|
|
486
|
+
:study_subject => @study_subject)
|
|
487
|
+
assert_difference('Abstract.count',1) {
|
|
488
|
+
abstract = create_abstract(:current_user => @current_user,
|
|
489
|
+
:study_subject => @study_subject.reload)
|
|
490
|
+
assert_equal abstract.entry_1_by, @current_user
|
|
491
|
+
assert_equal abstract.entry_2_by, @current_user
|
|
492
|
+
assert_equal abstract.study_subject, @study_subject
|
|
493
|
+
}
|
|
494
|
+
end
|
|
495
|
+
|
|
496
|
+
test "should NOT create third abstract for study_subject with current_user " <<
|
|
497
|
+
"without merging flag" do
|
|
498
|
+
assert_difference('StudySubject.count',1) {
|
|
499
|
+
@study_subject = create_case_study_subject_with_patid(1234)
|
|
500
|
+
assert_equal '1234', @study_subject.patid
|
|
501
|
+
}
|
|
502
|
+
@current_user = Factory(:user)
|
|
503
|
+
abstract = create_abstract(:current_user => @current_user,
|
|
504
|
+
:study_subject => @study_subject)
|
|
505
|
+
abstract = create_abstract(:current_user => @current_user,
|
|
506
|
+
:study_subject => @study_subject.reload)
|
|
507
|
+
assert_difference('Abstract.count',0) {
|
|
508
|
+
abstract = create_abstract(:current_user => @current_user,
|
|
509
|
+
:study_subject => @study_subject.reload)
|
|
510
|
+
assert abstract.errors.on(:study_subject_id)
|
|
511
|
+
}
|
|
512
|
+
end
|
|
513
|
+
|
|
514
|
+
test "should create third abstract for study_subject with current_user " <<
|
|
515
|
+
"with merging flag" do
|
|
516
|
+
assert_difference('StudySubject.count',1) {
|
|
517
|
+
@study_subject = create_case_study_subject_with_patid(1234)
|
|
518
|
+
assert_equal '1234', @study_subject.patid
|
|
519
|
+
}
|
|
520
|
+
@current_user = Factory(:user)
|
|
521
|
+
abstract = create_abstract(:current_user => @current_user,
|
|
522
|
+
:study_subject => @study_subject)
|
|
523
|
+
abstract = create_abstract(:current_user => @current_user,
|
|
524
|
+
:study_subject => @study_subject.reload)
|
|
525
|
+
# yes, when creating the merged, the other 2 go away
|
|
526
|
+
assert_difference('Abstract.count',-1) {
|
|
527
|
+
abstract = create_abstract(:current_user => @current_user,
|
|
528
|
+
:study_subject => @study_subject.reload, :merging => true)
|
|
529
|
+
assert_equal abstract.merged_by, @current_user
|
|
530
|
+
assert_equal abstract.study_subject, @study_subject
|
|
531
|
+
}
|
|
532
|
+
end
|
|
533
|
+
|
|
534
|
+
test "should NOT create merged abstract if study_subject already has one" do
|
|
535
|
+
study_subject = create_case_study_subject_with_patid(1234)
|
|
536
|
+
a1 = create_abstract(:study_subject => study_subject)
|
|
537
|
+
a1.merged_by = Factory(:user)
|
|
538
|
+
a1.save
|
|
539
|
+
assert_not_nil study_subject.reload.merged_abstract
|
|
540
|
+
assert_not_nil a1.reload.merged_by
|
|
541
|
+
assert a1.merged?
|
|
542
|
+
assert_difference('Abstract.count',0) {
|
|
543
|
+
a2 = create_abstract( :study_subject => study_subject, :merging => true)
|
|
544
|
+
assert a2.errors.on(:study_subject_id)
|
|
545
|
+
}
|
|
546
|
+
end
|
|
547
|
+
|
|
548
|
+
test "should return abstract sections for class" do
|
|
549
|
+
sections = Abstract.sections
|
|
550
|
+
assert Abstract.class_variable_defined?("@@sections")
|
|
551
|
+
assert sections.is_a?(Array)
|
|
552
|
+
assert sections.length >= 15
|
|
553
|
+
assert sections.first.is_a?(Hash)
|
|
554
|
+
end
|
|
555
|
+
|
|
556
|
+
test "should return abstract fields for class" do
|
|
557
|
+
fields = Abstract.fields
|
|
558
|
+
assert Abstract.class_variable_defined?("@@fields")
|
|
559
|
+
assert fields.is_a?(Array)
|
|
560
|
+
assert fields.length >= 15
|
|
561
|
+
assert fields.first.is_a?(Hash)
|
|
562
|
+
end
|
|
563
|
+
|
|
564
|
+
test "should return abstract fields for instance" do
|
|
565
|
+
fields = Abstract.new.fields
|
|
566
|
+
assert Abstract.class_variable_defined?("@@fields")
|
|
567
|
+
assert fields.is_a?(Array)
|
|
568
|
+
assert fields.length >= 15
|
|
569
|
+
assert fields.first.is_a?(Hash)
|
|
570
|
+
end
|
|
571
|
+
|
|
572
|
+
test "should return abstract db_fields for class" do
|
|
573
|
+
db_fields = Abstract.db_fields
|
|
574
|
+
assert Abstract.class_variable_defined?("@@fields")
|
|
575
|
+
assert db_fields.is_a?(Array)
|
|
576
|
+
assert db_fields.length >= 15
|
|
577
|
+
assert db_fields.first.is_a?(String)
|
|
578
|
+
end
|
|
579
|
+
|
|
580
|
+
test "should return abstract db_fields for instance" do
|
|
581
|
+
db_fields = Abstract.new.db_fields
|
|
582
|
+
assert Abstract.class_variable_defined?("@@fields")
|
|
583
|
+
assert db_fields.is_a?(Array)
|
|
584
|
+
assert db_fields.length >= 15
|
|
585
|
+
assert db_fields.first.is_a?(String)
|
|
586
|
+
end
|
|
587
|
+
|
|
588
|
+
[ :cbc_report_found,
|
|
589
|
+
:cerebrospinal_fluid_report_found,
|
|
590
|
+
:chemo_protocol_report_found,
|
|
591
|
+
:chest_ct_medmass_present,
|
|
592
|
+
:chest_imaging_report_found,
|
|
593
|
+
:cytogen_hospital_fish_done,
|
|
594
|
+
:cytogen_karyotype_done,
|
|
595
|
+
:cytogen_report_found,
|
|
596
|
+
:cytogen_trisomy4,
|
|
597
|
+
:cytogen_trisomy5,
|
|
598
|
+
:cytogen_trisomy10,
|
|
599
|
+
:cytogen_trisomy17,
|
|
600
|
+
:cytogen_trisomy21,
|
|
601
|
+
:cytogen_ucb_fish_done,
|
|
602
|
+
:diagnosis_is_all,
|
|
603
|
+
:diagnosis_is_aml,
|
|
604
|
+
:diagnosis_is_b_all,
|
|
605
|
+
:diagnosis_is_cll,
|
|
606
|
+
:diagnosis_is_cml,
|
|
607
|
+
:diagnosis_is_other,
|
|
608
|
+
:diagnosis_is_t_all,
|
|
609
|
+
:discharge_summary_found,
|
|
610
|
+
:flow_cyto_num_results_available,
|
|
611
|
+
:flow_cyto_report_found,
|
|
612
|
+
:h_and_p_reports_found,
|
|
613
|
+
:hepatomegaly_present,
|
|
614
|
+
:histo_report_found,
|
|
615
|
+
:is_down_syndrome_phenotype,
|
|
616
|
+
:marrow_aspirate_report_found,
|
|
617
|
+
:marrow_biopsy_report_found,
|
|
618
|
+
:mediastinal_mass_present,
|
|
619
|
+
:patient_on_chemo_protocol,
|
|
620
|
+
:ploidy_report_found,
|
|
621
|
+
:received_bone_marrow_aspirate,
|
|
622
|
+
:received_bone_marrow_biopsy,
|
|
623
|
+
:received_cbc,
|
|
624
|
+
:received_chemo_protocol,
|
|
625
|
+
:received_chest_ct,
|
|
626
|
+
:received_chest_xray,
|
|
627
|
+
:received_csf,
|
|
628
|
+
:received_cytogenetics,
|
|
629
|
+
:received_discharge_summary,
|
|
630
|
+
:received_flow_cytometry,
|
|
631
|
+
:received_hla_typing,
|
|
632
|
+
:received_h_and_p,
|
|
633
|
+
:received_other_reports,
|
|
634
|
+
:received_ploidy,
|
|
635
|
+
:received_resp_to_therapy,
|
|
636
|
+
:response_day14or28_flag,
|
|
637
|
+
:response_day30_is_in_remission,
|
|
638
|
+
:response_is_inconclusive_day_7,
|
|
639
|
+
:response_is_inconclusive_day_14,
|
|
640
|
+
:response_is_inconclusive_day_21,
|
|
641
|
+
:response_is_inconclusive_day_28,
|
|
642
|
+
:response_report_found_day_7,
|
|
643
|
+
:response_report_found_day_14,
|
|
644
|
+
:response_report_found_day_28,
|
|
645
|
+
:splenomegaly_present,
|
|
646
|
+
:tdt_often_found_flow_cytometry,
|
|
647
|
+
:tdt_report_found ].each do |field|
|
|
648
|
+
|
|
649
|
+
# Making assumption that 12345 will NEVER be a valid value.
|
|
650
|
+
test "should NOT allow 12345 for #{field}" do
|
|
651
|
+
abstract = Abstract.new(field => 12345)
|
|
652
|
+
abstract.valid?
|
|
653
|
+
assert abstract.errors.on_attr_and_type?(field,:inclusion)
|
|
654
|
+
end
|
|
655
|
+
|
|
656
|
+
test "should allow nil for #{field}" do
|
|
657
|
+
abstract = Abstract.new(field => nil)
|
|
658
|
+
assert_nil abstract.send(field)
|
|
659
|
+
abstract.valid?
|
|
660
|
+
assert !abstract.errors.on(field)
|
|
661
|
+
end
|
|
662
|
+
|
|
663
|
+
test "should allow all valid YNDK values for #{field}" do
|
|
664
|
+
abstract = Abstract.new
|
|
665
|
+
YNDK.valid_values.each do |value|
|
|
666
|
+
abstract.send("#{field}=", value)
|
|
667
|
+
abstract.valid?
|
|
668
|
+
assert !abstract.errors.on(field)
|
|
669
|
+
end
|
|
670
|
+
end
|
|
671
|
+
|
|
672
|
+
end
|
|
673
|
+
|
|
674
|
+
end
|