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,102 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class Ccls::HospitalTest < ActiveSupport::TestCase
|
|
4
|
+
|
|
5
|
+
assert_should_create_default_object
|
|
6
|
+
assert_should_act_as_list
|
|
7
|
+
assert_should_initially_belong_to(:organization)
|
|
8
|
+
assert_should_require_attributes_not_nil( :has_irb_waiver )
|
|
9
|
+
assert_should_not_require_attributes( :position )
|
|
10
|
+
assert_should_require_unique_attributes( :organization_id )
|
|
11
|
+
|
|
12
|
+
test "explicit Factory hospital test" do
|
|
13
|
+
assert_difference('Organization.count',1) {
|
|
14
|
+
assert_difference('Hospital.count',1) {
|
|
15
|
+
hospital = Factory(:hospital)
|
|
16
|
+
assert_not_nil hospital.organization
|
|
17
|
+
assert !hospital.has_irb_waiver # database default
|
|
18
|
+
} }
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
test "explicit Factory nonwaivered hospital test" do
|
|
22
|
+
assert_difference('Organization.count',1) {
|
|
23
|
+
assert_difference('Hospital.count',1) {
|
|
24
|
+
hospital = Factory(:nonwaivered_hospital)
|
|
25
|
+
assert_not_nil hospital.organization
|
|
26
|
+
assert !hospital.has_irb_waiver # database default
|
|
27
|
+
} }
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
test "explicit Factory waivered hospital test" do
|
|
31
|
+
assert_difference('Organization.count',1) {
|
|
32
|
+
assert_difference('Hospital.count',1) {
|
|
33
|
+
hospital = Factory(:waivered_hospital)
|
|
34
|
+
assert_not_nil hospital.organization
|
|
35
|
+
assert hospital.has_irb_waiver
|
|
36
|
+
} }
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
test "should require organization" do
|
|
40
|
+
assert_difference( "Hospital.count", 0 ) do
|
|
41
|
+
hospital = create_hospital( :organization => nil)
|
|
42
|
+
assert !hospital.errors.on(:organization)
|
|
43
|
+
assert hospital.errors.on_attr_and_type?(:organization_id,:blank)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
test "should require valid organization" do
|
|
48
|
+
assert_difference( "Hospital.count", 0 ) do
|
|
49
|
+
hospital = create_hospital( :organization_id => 0)
|
|
50
|
+
assert !hospital.errors.on(:organization_id)
|
|
51
|
+
assert hospital.errors.on_attr_and_type?(:organization,:blank)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
test "should return organization name as to_s if organization" do
|
|
56
|
+
organization = create_organization
|
|
57
|
+
hospital = create_hospital(:organization => organization)
|
|
58
|
+
assert_not_nil hospital.organization
|
|
59
|
+
assert_equal organization.name, "#{hospital}"
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# If organization is required, this can't ever happen
|
|
63
|
+
# test "should return Unknown as to_s if no organization" do
|
|
64
|
+
# hospital = create_hospital
|
|
65
|
+
# assert_nil hospital.reload.organization
|
|
66
|
+
# assert_equal 'Unknown', "#{hospital}"
|
|
67
|
+
# end
|
|
68
|
+
|
|
69
|
+
test "should return waivered hospitals" do
|
|
70
|
+
hospitals = Hospital.waivered
|
|
71
|
+
assert !hospitals.empty?
|
|
72
|
+
assert_equal 22, hospitals.length # this is true now, but will change
|
|
73
|
+
hospitals.each do |hospital|
|
|
74
|
+
assert hospital.has_irb_waiver
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
test "should return nonwaivered hospitals" do
|
|
79
|
+
hospitals = Hospital.nonwaivered
|
|
80
|
+
assert !hospitals.empty?
|
|
81
|
+
# the addition of the "unspecified" and "don't know" make this 5 now
|
|
82
|
+
assert_equal 5, hospitals.length # this is true now, but will change
|
|
83
|
+
hospitals.each do |hospital|
|
|
84
|
+
assert !hospital.has_irb_waiver
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
#protected
|
|
89
|
+
#
|
|
90
|
+
# def create_hospital(options={})
|
|
91
|
+
# hospital = Factory.build(:hospital,options)
|
|
92
|
+
# hospital.save
|
|
93
|
+
# hospital
|
|
94
|
+
# end
|
|
95
|
+
#
|
|
96
|
+
# def create_organization(options={})
|
|
97
|
+
# organization = Factory.build(:organization,options)
|
|
98
|
+
# organization.save
|
|
99
|
+
# organization
|
|
100
|
+
# end
|
|
101
|
+
|
|
102
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class Ccls::IcfMasterIdTest < 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
|
+
|
|
9
|
+
test "explicit Factory icf_master_id test" do
|
|
10
|
+
assert_difference('IcfMasterId.count',1) {
|
|
11
|
+
icf_master_id = Factory(:icf_master_id)
|
|
12
|
+
assert_nil icf_master_id.icf_master_id
|
|
13
|
+
}
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
test "should return icf_master_id as to_s" do
|
|
17
|
+
icf_master_id = create_icf_master_id(:icf_master_id => '123456789')
|
|
18
|
+
assert_equal "#{icf_master_id.icf_master_id}", "#{icf_master_id}"
|
|
19
|
+
assert_equal "123456789", "#{icf_master_id}"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
#protected
|
|
23
|
+
#
|
|
24
|
+
# def create_icf_master_id(options={})
|
|
25
|
+
# icf_master_id = Factory.build(:icf_master_id,options)
|
|
26
|
+
# icf_master_id.save
|
|
27
|
+
# icf_master_id
|
|
28
|
+
# end
|
|
29
|
+
|
|
30
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class Ccls::IcfMasterTrackerChangeTest < ActiveSupport::TestCase
|
|
4
|
+
# t.string :icf_master_id
|
|
5
|
+
# t.date :master_tracker_date
|
|
6
|
+
# t.boolean :new_tracker_record
|
|
7
|
+
# t.string :modified_column
|
|
8
|
+
# t.string :previous_value
|
|
9
|
+
# t.string :new_value
|
|
10
|
+
|
|
11
|
+
assert_should_create_default_object
|
|
12
|
+
assert_should_require( :icf_master_id )
|
|
13
|
+
|
|
14
|
+
end
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class Ccls::IcfMasterTrackerTest < ActiveSupport::TestCase
|
|
4
|
+
|
|
5
|
+
assert_should_create_default_object
|
|
6
|
+
assert_should_protect(:Masterid)
|
|
7
|
+
assert_should_require(:Masterid)
|
|
8
|
+
assert_should_require_unique(:Masterid)
|
|
9
|
+
assert_should_require_attribute_length( :last_update_attempt_errors, :maximum => 65000 )
|
|
10
|
+
|
|
11
|
+
test "should not attach to study subject on create if none exists" do
|
|
12
|
+
icf_master_tracker = Factory(:icf_master_tracker,
|
|
13
|
+
:Masterid => '1234')
|
|
14
|
+
assert_nil icf_master_tracker.study_subject
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
test "should attach to study subject on create if exists" do
|
|
18
|
+
icf_master_id = Factory(:icf_master_id, :icf_master_id => '1234')
|
|
19
|
+
study_subject = Factory(:complete_case_study_subject)
|
|
20
|
+
study_subject.assign_icf_master_id
|
|
21
|
+
icf_master_tracker = Factory(:icf_master_tracker,
|
|
22
|
+
:Masterid => '1234')
|
|
23
|
+
assert_not_nil icf_master_tracker.study_subject
|
|
24
|
+
assert_equal icf_master_tracker.study_subject, study_subject
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
test "should attach to study subject on update if exists" do
|
|
28
|
+
icf_master_tracker = Factory(:icf_master_tracker,
|
|
29
|
+
:Masterid => '1234')
|
|
30
|
+
assert_nil icf_master_tracker.study_subject
|
|
31
|
+
icf_master_id = Factory(:icf_master_id, :icf_master_id => '1234')
|
|
32
|
+
study_subject = Factory(:complete_case_study_subject)
|
|
33
|
+
study_subject.assign_icf_master_id
|
|
34
|
+
icf_master_tracker.save
|
|
35
|
+
assert_not_nil icf_master_tracker.study_subject
|
|
36
|
+
assert_equal icf_master_tracker.study_subject, study_subject
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
test "should flag for update on create" do
|
|
40
|
+
icf_master_tracker = Factory(:icf_master_tracker)
|
|
41
|
+
assert icf_master_tracker.flagged_for_update
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
test "should flag for update on change" do
|
|
45
|
+
icf_master_tracker = Factory(:icf_master_tracker)
|
|
46
|
+
assert icf_master_tracker.flagged_for_update
|
|
47
|
+
icf_master_tracker.update_attribute(:flagged_for_update,false)
|
|
48
|
+
assert !icf_master_tracker.flagged_for_update
|
|
49
|
+
icf_master_tracker.update_attribute(:Eligible, 'trigger change')
|
|
50
|
+
assert icf_master_tracker.flagged_for_update
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
test "should NOT flag for update if no change" do
|
|
54
|
+
icf_master_tracker = Factory(:icf_master_tracker)
|
|
55
|
+
assert icf_master_tracker.flagged_for_update
|
|
56
|
+
icf_master_tracker.update_attribute(:flagged_for_update,false)
|
|
57
|
+
assert !icf_master_tracker.flagged_for_update
|
|
58
|
+
icf_master_tracker.save
|
|
59
|
+
assert !icf_master_tracker.flagged_for_update
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
test "should return those flagged for update" do
|
|
63
|
+
assert IcfMasterTracker.have_changed.empty?
|
|
64
|
+
icf_master_tracker = Factory(:icf_master_tracker)
|
|
65
|
+
assert IcfMasterTracker.have_changed.include?(
|
|
66
|
+
icf_master_tracker )
|
|
67
|
+
icf_master_tracker.update_attribute(:flagged_for_update,false)
|
|
68
|
+
assert IcfMasterTracker.have_changed.empty?
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# test "should create operational event for study subject if change" do
|
|
72
|
+
# icf_master_id = Factory(:icf_master_id, :icf_master_id => '1234')
|
|
73
|
+
# study_subject = Factory(:complete_case_study_subject)
|
|
74
|
+
# study_subject.assign_icf_master_id
|
|
75
|
+
# assert_difference('OperationalEvent.count',1) {
|
|
76
|
+
# icf_master_tracker = Factory(:icf_master_tracker,
|
|
77
|
+
# :Masterid => '1234', :Eligible => 'trigger change')
|
|
78
|
+
# assert_not_nil icf_master_tracker.study_subject
|
|
79
|
+
# assert_equal icf_master_tracker.study_subject, study_subject
|
|
80
|
+
# assert icf_master_tracker.study_subject.enrollments.find_by_project_id(
|
|
81
|
+
# Project['ccls'].id).operational_events.collect(&:operational_event_type_id
|
|
82
|
+
# ).include?(OperationalEventType[:other].id)
|
|
83
|
+
# }
|
|
84
|
+
# end
|
|
85
|
+
#
|
|
86
|
+
# test "should not create operational event for study subject if no change" do
|
|
87
|
+
# icf_master_id = Factory(:icf_master_id, :icf_master_id => '1234')
|
|
88
|
+
# study_subject = Factory(:complete_case_study_subject)
|
|
89
|
+
# study_subject.assign_icf_master_id
|
|
90
|
+
# assert_difference('OperationalEvent.count',0) {
|
|
91
|
+
# icf_master_tracker = Factory(:icf_master_tracker,
|
|
92
|
+
# :Masterid => '1234') #, :Eligible => 'trigger change')
|
|
93
|
+
# assert_not_nil icf_master_tracker.study_subject
|
|
94
|
+
# assert_equal icf_master_tracker.study_subject, study_subject
|
|
95
|
+
# assert !icf_master_tracker.study_subject.enrollments.find_by_project_id(
|
|
96
|
+
# Project['ccls'].id).operational_events.collect(&:operational_event_type_id
|
|
97
|
+
# ).include?(OperationalEventType[:other].id)
|
|
98
|
+
# }
|
|
99
|
+
# end
|
|
100
|
+
|
|
101
|
+
test "should create one new icf_master_tracker_change record on create" do
|
|
102
|
+
assert_difference('IcfMasterTracker.count',1) {
|
|
103
|
+
assert_difference('IcfMasterTrackerChange.count',1) {
|
|
104
|
+
@icf_master_tracker = Factory(:icf_master_tracker)
|
|
105
|
+
} }
|
|
106
|
+
last_tracker_change = IcfMasterTrackerChange.last
|
|
107
|
+
assert last_tracker_change.new_tracker_record
|
|
108
|
+
assert_equal last_tracker_change.icf_master_id, @icf_master_tracker.Masterid
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
test "should not create icf_master_tracker_change on save if no change" do
|
|
112
|
+
icf_master_tracker = Factory(:icf_master_tracker)
|
|
113
|
+
assert_difference('IcfMasterTracker.count',0) {
|
|
114
|
+
assert_difference('IcfMasterTrackerChange.count',0) {
|
|
115
|
+
icf_master_tracker.save
|
|
116
|
+
} }
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
test "should create one icf_master_tracker_change on save if one change" do
|
|
120
|
+
icf_master_tracker = Factory(:icf_master_tracker, :Currphone => "something")
|
|
121
|
+
assert_difference('IcfMasterTracker.count',0) {
|
|
122
|
+
assert_difference('IcfMasterTrackerChange.count',1) {
|
|
123
|
+
icf_master_tracker.update_attribute(:Currphone, "something else")
|
|
124
|
+
} }
|
|
125
|
+
last_tracker = IcfMasterTrackerChange.last
|
|
126
|
+
assert !last_tracker.new_tracker_record
|
|
127
|
+
assert_equal last_tracker.modified_column, 'Currphone'
|
|
128
|
+
assert_equal last_tracker.previous_value, 'something'
|
|
129
|
+
assert_equal last_tracker.new_value, 'something else'
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
end
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class Ccls::IcfMasterTrackerUpdateTest < ActiveSupport::TestCase
|
|
4
|
+
include Ccls::IcfMasterTrackerUpdateTestHelper
|
|
5
|
+
|
|
6
|
+
setup :turn_off_paperclip_logging
|
|
7
|
+
|
|
8
|
+
assert_should_create_default_object
|
|
9
|
+
|
|
10
|
+
test "should create without attached csv_file" do
|
|
11
|
+
assert_difference('IcfMasterTrackerUpdate.count',1) {
|
|
12
|
+
@object = Factory(:icf_master_tracker_update)
|
|
13
|
+
}
|
|
14
|
+
assert_nil @object.csv_file_file_name
|
|
15
|
+
assert_nil @object.csv_file_content_type
|
|
16
|
+
assert_nil @object.csv_file_file_size
|
|
17
|
+
assert_nil @object.csv_file_updated_at
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
test "should create with attached csv_file" do
|
|
21
|
+
assert_difference('IcfMasterTrackerUpdate.count',1) {
|
|
22
|
+
@object = create_test_file_and_icf_master_tracker_update
|
|
23
|
+
}
|
|
24
|
+
assert_not_nil @object.csv_file_file_name
|
|
25
|
+
assert_equal @object.csv_file_file_name, csv_test_file_name
|
|
26
|
+
assert_not_nil @object.csv_file_content_type
|
|
27
|
+
assert_not_nil @object.csv_file_file_size
|
|
28
|
+
assert_not_nil @object.csv_file_updated_at
|
|
29
|
+
cleanup_icf_master_tracker_update_and_test_file(@object)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
test "should parse nil attached csv_file" do
|
|
33
|
+
icf_master_tracker_update = Factory(:icf_master_tracker_update)
|
|
34
|
+
assert_nil icf_master_tracker_update.csv_file_file_name
|
|
35
|
+
assert_difference('IcfMasterTracker.count',0) {
|
|
36
|
+
results = icf_master_tracker_update.parse
|
|
37
|
+
assert_equal [], results
|
|
38
|
+
}
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
test "should parse non-existant attached csv_file" do
|
|
42
|
+
icf_master_tracker_update = create_test_file_and_icf_master_tracker_update
|
|
43
|
+
assert File.exists?(icf_master_tracker_update.csv_file.path)
|
|
44
|
+
File.delete(icf_master_tracker_update.csv_file.path)
|
|
45
|
+
assert !File.exists?(icf_master_tracker_update.csv_file.path)
|
|
46
|
+
assert_difference('IcfMasterTracker.count',0) {
|
|
47
|
+
results = icf_master_tracker_update.parse
|
|
48
|
+
assert_equal [], results
|
|
49
|
+
}
|
|
50
|
+
cleanup_icf_master_tracker_update_and_test_file(icf_master_tracker_update)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
test "should parse attached csv_file" do
|
|
54
|
+
icf_master_tracker_update = create_test_file_and_icf_master_tracker_update
|
|
55
|
+
assert_difference('IcfMasterTracker.count',1) {
|
|
56
|
+
results = icf_master_tracker_update.parse
|
|
57
|
+
assert_equal results.length, 1
|
|
58
|
+
assert results[0].is_a?(IcfMasterTracker)
|
|
59
|
+
assert results[0].flagged_for_update
|
|
60
|
+
}
|
|
61
|
+
cleanup_icf_master_tracker_update_and_test_file(icf_master_tracker_update)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
test "should parse attached csv_file with existing icf_master_tracker" do
|
|
65
|
+
icf_master_tracker_update = create_test_file_and_icf_master_tracker_update
|
|
66
|
+
results = nil
|
|
67
|
+
assert_difference('IcfMasterTracker.count',1) {
|
|
68
|
+
results = icf_master_tracker_update.parse
|
|
69
|
+
assert_equal results.length, 1
|
|
70
|
+
assert results[0].is_a?(IcfMasterTracker)
|
|
71
|
+
assert results[0].flagged_for_update
|
|
72
|
+
}
|
|
73
|
+
assert_difference('IcfMasterTracker.count',0) {
|
|
74
|
+
new_results = icf_master_tracker_update.parse
|
|
75
|
+
assert_equal new_results.length, 1
|
|
76
|
+
assert new_results[0].is_a?(IcfMasterTracker)
|
|
77
|
+
assert_equal results, new_results
|
|
78
|
+
}
|
|
79
|
+
cleanup_icf_master_tracker_update_and_test_file(icf_master_tracker_update)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
test "should copy attributes when csv_file converted to icf_master_tracker" do
|
|
83
|
+
icf_master_tracker_update = create_test_file_and_icf_master_tracker_update
|
|
84
|
+
assert_difference('IcfMasterTracker.count',1) {
|
|
85
|
+
results = icf_master_tracker_update.parse
|
|
86
|
+
assert_equal 1, results.length
|
|
87
|
+
assert results[0].flagged_for_update
|
|
88
|
+
icf_master_tracker = results.last
|
|
89
|
+
# assert_equal candidate_control.related_patid, study_subject.patid
|
|
90
|
+
# assert_equal candidate_control.mom_is_biomom, control[:biomom]
|
|
91
|
+
# assert_equal candidate_control.dad_is_biodad, control[:biodad]
|
|
92
|
+
##control[:date]},#{
|
|
93
|
+
# assert_equal candidate_control.mother_full_name, control[:mother_full_name]
|
|
94
|
+
# assert_equal candidate_control.mother_maiden_name, control[:mother_maiden_name]
|
|
95
|
+
##control[:father_full_name]},#{
|
|
96
|
+
# assert_equal candidate_control.full_name, control[:child_full_name]
|
|
97
|
+
# assert_equal candidate_control.dob,
|
|
98
|
+
# Date.new(control[:child_doby].to_i, control[:child_dobm].to_i, control[:child_dobd].to_i)
|
|
99
|
+
# assert_equal candidate_control.sex, control[:child_gender]
|
|
100
|
+
##control[:birthplace_country]},#{
|
|
101
|
+
##control[:birthplace_state]},#{
|
|
102
|
+
##control[:birthplace_city]},#{
|
|
103
|
+
# assert_equal candidate_control.mother_hispanicity_id, control[:mother_hispanicity]
|
|
104
|
+
##control[:mother_hispanicity_mex]},#{
|
|
105
|
+
# assert_equal candidate_control.mother_race_id, control[:mother_race]
|
|
106
|
+
##control[:mother_race_other]},#{
|
|
107
|
+
# assert_equal candidate_control.father_hispanicity_id, control[:father_hispanicity]
|
|
108
|
+
##control[:father_hispanicity_mex]},#{
|
|
109
|
+
# assert_equal candidate_control.father_race_id, control[:father_race]
|
|
110
|
+
##control[:father_race_other]}} }
|
|
111
|
+
}
|
|
112
|
+
cleanup_icf_master_tracker_update_and_test_file(icf_master_tracker_update)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
test "should parse attached csv_file and attach tracker to subject" do
|
|
116
|
+
study_subject = create_case_for_icf_master_tracker_update
|
|
117
|
+
icf_master_tracker_update = create_test_file_and_icf_master_tracker_update
|
|
118
|
+
assert_difference('IcfMasterTracker.count',1) {
|
|
119
|
+
results = icf_master_tracker_update.parse
|
|
120
|
+
assert_equal results.length, 1
|
|
121
|
+
assert results[0].flagged_for_update
|
|
122
|
+
assert results[0].is_a?(IcfMasterTracker)
|
|
123
|
+
assert_equal results[0].study_subject, study_subject
|
|
124
|
+
}
|
|
125
|
+
cleanup_icf_master_tracker_update_and_test_file(icf_master_tracker_update)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
test "should test with real data file" do
|
|
129
|
+
# real data and won't be in repository
|
|
130
|
+
real_data_file = 'icf_master_tracker_011712.csv'
|
|
131
|
+
unless File.exists?(real_data_file)
|
|
132
|
+
puts
|
|
133
|
+
puts "-- Real data test file does not exist. Skipping."
|
|
134
|
+
return
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# minimal semi-real case creation
|
|
138
|
+
s0 = Factory(:study_subject,:sex => 'F',
|
|
139
|
+
:first_name => 'FakeFirst1',:last_name => 'FakeLast1',
|
|
140
|
+
:dob => Date.parse('10/16/1977'))
|
|
141
|
+
|
|
142
|
+
s1 = Factory(:study_subject,:sex => 'F',
|
|
143
|
+
:first_name => 'FakeFirst2',:last_name => 'FakeLast2',
|
|
144
|
+
:dob => Date.parse('9/21/1988'))
|
|
145
|
+
Factory(:icf_master_id,:icf_master_id => '15270110G')
|
|
146
|
+
s1.assign_icf_master_id
|
|
147
|
+
|
|
148
|
+
s2 = Factory(:study_subject,:sex => 'M',
|
|
149
|
+
:first_name => 'FakeFirst3',:last_name => 'FakeLast3',
|
|
150
|
+
:dob => Date.parse('6/1/2009'))
|
|
151
|
+
Factory(:icf_master_id,:icf_master_id => '15397125B')
|
|
152
|
+
s2.assign_icf_master_id
|
|
153
|
+
|
|
154
|
+
icf_master_tracker_update = Factory(:icf_master_tracker_update,
|
|
155
|
+
:csv_file => File.open(real_data_file) )
|
|
156
|
+
assert_not_nil icf_master_tracker_update.csv_file_file_name
|
|
157
|
+
|
|
158
|
+
assert_difference('IcfMasterTracker.count',62){
|
|
159
|
+
results = icf_master_tracker_update.parse
|
|
160
|
+
assert_equal results.length, 62
|
|
161
|
+
assert_nil results[0].study_subject
|
|
162
|
+
assert_equal results[1].study_subject, s1
|
|
163
|
+
assert_equal results[2].study_subject, s2
|
|
164
|
+
results.each { |r|
|
|
165
|
+
assert r.is_a?(IcfMasterTracker)
|
|
166
|
+
assert !r.new_record?
|
|
167
|
+
assert r.flagged_for_update
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
#
|
|
171
|
+
# TODO add some tests to see if anything was updated
|
|
172
|
+
#
|
|
173
|
+
icf_master_tracker_update.destroy
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
end
|