ccls-ccls_engine 3.11.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +182 -0
- data/app/models/abstract.rb +181 -0
- data/app/models/abstract_search.rb +50 -0
- data/app/models/abstract_validations.rb +324 -0
- data/app/models/address.rb +70 -0
- data/app/models/address_type.rb +15 -0
- data/app/models/addressing.rb +147 -0
- data/app/models/aliquot.rb +44 -0
- data/app/models/aliquot_sample_format.rb +13 -0
- data/app/models/analysis.rb +14 -0
- data/app/models/bc_request.rb +20 -0
- data/app/models/candidate_control.rb +101 -0
- data/app/models/context.rb +23 -0
- data/app/models/context_data_source.rb +4 -0
- data/app/models/county.rb +16 -0
- data/app/models/data_source.rb +24 -0
- data/app/models/diagnosis.rb +23 -0
- data/app/models/document_type.rb +16 -0
- data/app/models/document_version.rb +27 -0
- data/app/models/enrollment.rb +78 -0
- data/app/models/enrollment_validations.rb +167 -0
- data/app/models/follow_up.rb +16 -0
- data/app/models/follow_up_type.rb +18 -0
- data/app/models/gift_card.rb +22 -0
- data/app/models/gift_card_search.rb +137 -0
- data/app/models/home_exposure_response.rb +24 -0
- data/app/models/homex_outcome.rb +75 -0
- data/app/models/hospital.rb +22 -0
- data/app/models/icf_master_id.rb +30 -0
- data/app/models/icf_master_tracker.rb +217 -0
- data/app/models/icf_master_tracker_change.rb +9 -0
- data/app/models/icf_master_tracker_update.rb +50 -0
- data/app/models/ineligible_reason.rb +26 -0
- data/app/models/instrument.rb +26 -0
- data/app/models/instrument_type.rb +17 -0
- data/app/models/instrument_version.rb +28 -0
- data/app/models/interview.rb +122 -0
- data/app/models/interview_method.rb +17 -0
- data/app/models/interview_outcome.rb +16 -0
- data/app/models/language.rb +28 -0
- data/app/models/live_birth_data_update.rb +142 -0
- data/app/models/operational_event.rb +99 -0
- data/app/models/operational_event_type.rb +31 -0
- data/app/models/organization.rb +28 -0
- data/app/models/patient.rb +63 -0
- data/app/models/patient_validations.rb +118 -0
- data/app/models/person.rb +28 -0
- data/app/models/phone_number.rb +105 -0
- data/app/models/phone_type.rb +15 -0
- data/app/models/project.rb +39 -0
- data/app/models/project_outcome.rb +19 -0
- data/app/models/race.rb +31 -0
- data/app/models/refusal_reason.rb +23 -0
- data/app/models/sample.rb +168 -0
- data/app/models/sample_kit.rb +14 -0
- data/app/models/sample_outcome.rb +16 -0
- data/app/models/sample_temperature.rb +14 -0
- data/app/models/sample_type.rb +37 -0
- data/app/models/search.rb +195 -0
- data/app/models/section.rb +18 -0
- data/app/models/state.rb +25 -0
- data/app/models/study_subject.rb +237 -0
- data/app/models/study_subject_abstracts.rb +47 -0
- data/app/models/study_subject_addresses.rb +34 -0
- data/app/models/study_subject_associations.rb +38 -0
- data/app/models/study_subject_duplicates.rb +111 -0
- data/app/models/study_subject_enrollments.rb +17 -0
- data/app/models/study_subject_homex_outcome.rb +22 -0
- data/app/models/study_subject_identifier.rb +153 -0
- data/app/models/study_subject_interviews.rb +25 -0
- data/app/models/study_subject_languages.rb +21 -0
- data/app/models/study_subject_operational_events.rb +66 -0
- data/app/models/study_subject_patient.rb +177 -0
- data/app/models/study_subject_pii.rb +74 -0
- data/app/models/study_subject_races.rb +25 -0
- data/app/models/study_subject_search.rb +260 -0
- data/app/models/study_subject_validations.rb +116 -0
- data/app/models/subject_language.rb +11 -0
- data/app/models/subject_race.rb +11 -0
- data/app/models/subject_relationship.rb +21 -0
- data/app/models/subject_type.rb +22 -0
- data/app/models/tracing_status.rb +20 -0
- data/app/models/transfer.rb +40 -0
- data/app/models/unit.rb +14 -0
- data/app/models/vital_status.rb +19 -0
- data/app/models/zip_code.rb +36 -0
- data/config/abstract_fields.yml +1038 -0
- data/config/abstract_sections.yml +77 -0
- data/config/home_exposure_response_fields.yml +583 -0
- data/config/icf_master_tracker_update.yml +56 -0
- data/config/live_birth_data_update.yml +56 -0
- data/config/shared_use_db.yml +4 -0
- data/generators/ccls_engine/USAGE +2 -0
- data/generators/ccls_engine/ccls_engine_generator.rb +123 -0
- data/generators/ccls_engine/templates/autotest_ccls_engine.rb +3 -0
- data/generators/ccls_engine/templates/ccls_engine.rake +12 -0
- data/generators/ccls_engine/templates/fixtures/address_types.yml +30 -0
- data/generators/ccls_engine/templates/fixtures/context_data_sources.yml +54 -0
- data/generators/ccls_engine/templates/fixtures/contexts.yml +19 -0
- data/generators/ccls_engine/templates/fixtures/data_sources.yml +40 -0
- data/generators/ccls_engine/templates/fixtures/diagnoses.yml +40 -0
- data/generators/ccls_engine/templates/fixtures/document_types.yml +65 -0
- data/generators/ccls_engine/templates/fixtures/document_versions.csv +155 -0
- data/generators/ccls_engine/templates/fixtures/follow_up_types.yml +16 -0
- data/generators/ccls_engine/templates/fixtures/hospitals.yml +114 -0
- data/generators/ccls_engine/templates/fixtures/ineligible_reasons.yml +35 -0
- data/generators/ccls_engine/templates/fixtures/instrument_types.yml +26 -0
- data/generators/ccls_engine/templates/fixtures/instrument_versions.yml +22 -0
- data/generators/ccls_engine/templates/fixtures/instruments.yml +22 -0
- data/generators/ccls_engine/templates/fixtures/interview_methods.yml +30 -0
- data/generators/ccls_engine/templates/fixtures/interview_outcomes.yml +31 -0
- data/generators/ccls_engine/templates/fixtures/languages.yml +34 -0
- data/generators/ccls_engine/templates/fixtures/operational_event_types.yml +141 -0
- data/generators/ccls_engine/templates/fixtures/organizations.yml +198 -0
- data/generators/ccls_engine/templates/fixtures/people.yml +130 -0
- data/generators/ccls_engine/templates/fixtures/phone_types.yml +30 -0
- data/generators/ccls_engine/templates/fixtures/project_outcomes.yml +25 -0
- data/generators/ccls_engine/templates/fixtures/projects.yml +59 -0
- data/generators/ccls_engine/templates/fixtures/races.yml +52 -0
- data/generators/ccls_engine/templates/fixtures/refusal_reasons.yml +55 -0
- data/generators/ccls_engine/templates/fixtures/sample_outcomes.yml +36 -0
- data/generators/ccls_engine/templates/fixtures/sample_temperatures.yml +16 -0
- data/generators/ccls_engine/templates/fixtures/sample_types.yml +147 -0
- data/generators/ccls_engine/templates/fixtures/sections.yml +31 -0
- data/generators/ccls_engine/templates/fixtures/states.yml +363 -0
- data/generators/ccls_engine/templates/fixtures/subject_relationships.yml +46 -0
- data/generators/ccls_engine/templates/fixtures/subject_types.yml +30 -0
- data/generators/ccls_engine/templates/fixtures/tracing_statuses.yml +30 -0
- data/generators/ccls_engine/templates/fixtures/units.yml +13 -0
- data/generators/ccls_engine/templates/fixtures/vital_statuses.yml +28 -0
- data/generators/ccls_engine/templates/functional/roles_controller_test.rb +142 -0
- data/generators/ccls_engine/templates/functional/sessions_controller_test.rb +19 -0
- data/generators/ccls_engine/templates/functional/users_controller_test.rb +94 -0
- data/generators/ccls_engine/templates/images/sort_down.png +0 -0
- data/generators/ccls_engine/templates/images/sort_up.png +0 -0
- data/generators/ccls_engine/templates/initializer.rb +28 -0
- data/generators/ccls_engine/templates/javascripts/ccls_engine.js +24 -0
- data/generators/ccls_engine/templates/javascripts/jquery-ui.js +763 -0
- data/generators/ccls_engine/templates/javascripts/jquery.js +154 -0
- data/generators/ccls_engine/templates/javascripts/jrails.js +1 -0
- data/generators/ccls_engine/templates/migrations/create_user_invitations.rb +18 -0
- data/generators/ccls_engine/templates/migrations/create_users.rb +33 -0
- data/generators/ccls_engine/templates/migrations/drop_user_invitations.rb +18 -0
- data/generators/ccls_engine/templates/stylesheets/ccls_engine.css +180 -0
- data/generators/ccls_engine/templates/stylesheets/user.css +35 -0
- data/generators/ccls_engine/templates/stylesheets/users.css +23 -0
- data/generators/ccls_engine/templates/unit/core_extension_test.rb +18 -0
- data/generators/ccls_engine/templates/unit/role_test.rb +30 -0
- data/generators/ccls_engine/templates/unit/user_test.rb +321 -0
- data/lib/ccls-ccls_engine.rb +1 -0
- data/lib/ccls_engine.rb +135 -0
- data/lib/ccls_engine/action_view_extension.rb +3 -0
- data/lib/ccls_engine/action_view_extension/base.rb +53 -0
- data/lib/ccls_engine/action_view_extension/form_builder.rb +39 -0
- data/lib/ccls_engine/active_record_extension.rb +2 -0
- data/lib/ccls_engine/active_record_extension/base.rb +70 -0
- data/lib/ccls_engine/active_record_shared.rb +8 -0
- data/lib/ccls_engine/assertions.rb +69 -0
- data/lib/ccls_engine/autotest.rb +54 -0
- data/lib/ccls_engine/ccls_user.rb +117 -0
- data/lib/ccls_engine/core_extension.rb +14 -0
- data/lib/ccls_engine/date_and_time_formats.rb +30 -0
- data/lib/ccls_engine/factories.rb +880 -0
- data/lib/ccls_engine/factory_test_helper.rb +276 -0
- data/lib/ccls_engine/helper.rb +112 -0
- data/lib/ccls_engine/icf_master_tracker_update_test_helper.rb +121 -0
- data/lib/ccls_engine/live_birth_data_update_test_helper.rb +110 -0
- data/lib/ccls_engine/package_test_helper.rb +49 -0
- data/lib/ccls_engine/shared_database.rb +20 -0
- data/lib/ccls_engine/tasks.rb +1 -0
- data/lib/ccls_engine/test_tasks.rb +52 -0
- data/lib/ccls_engine/translation_table.rb +86 -0
- data/lib/shared_migration.rb +5 -0
- data/lib/surveyor/survey_extensions.rb +125 -0
- data/lib/tasks/application.rake +286 -0
- data/lib/tasks/calnet_authenticated.rake +6 -0
- data/lib/tasks/common_lib.rake +7 -0
- data/lib/tasks/database.rake +288 -0
- data/lib/tasks/documentation.rake +71 -0
- data/lib/tasks/homex_import.rake +723 -0
- data/lib/tasks/odms_import.rake +1116 -0
- data/lib/tasks/simply_authorized.rake +6 -0
- data/lib/tasks/ucb_ccls_engine_tasks.rake +4 -0
- data/lib/tasks/use_db.rake +4 -0
- data/rails/init.rb +4 -0
- data/test/unit/ccls/abstract_search_test.rb +150 -0
- data/test/unit/ccls/abstract_test.rb +674 -0
- data/test/unit/ccls/address_test.rb +155 -0
- data/test/unit/ccls/address_type_test.rb +25 -0
- data/test/unit/ccls/addressing_test.rb +466 -0
- data/test/unit/ccls/aliquot_sample_format_test.rb +20 -0
- data/test/unit/ccls/aliquot_test.rb +156 -0
- data/test/unit/ccls/analysis_test.rb +31 -0
- data/test/unit/ccls/bc_request_test.rb +43 -0
- data/test/unit/ccls/candidate_control_test.rb +712 -0
- data/test/unit/ccls/context_data_source_test.rb +26 -0
- data/test/unit/ccls/context_test.rb +40 -0
- data/test/unit/ccls/core_extension_test.rb +17 -0
- data/test/unit/ccls/county_test.rb +34 -0
- data/test/unit/ccls/data_source_test.rb +41 -0
- data/test/unit/ccls/diagnosis_test.rb +51 -0
- data/test/unit/ccls/document_type_test.rb +35 -0
- data/test/unit/ccls/document_version_test.rb +68 -0
- data/test/unit/ccls/enrollment_test.rb +575 -0
- data/test/unit/ccls/follow_up_test.rb +23 -0
- data/test/unit/ccls/follow_up_type_test.rb +34 -0
- data/test/unit/ccls/gift_card_search_test.rb +153 -0
- data/test/unit/ccls/gift_card_test.rb +40 -0
- data/test/unit/ccls/home_exposure_response_test.rb +83 -0
- data/test/unit/ccls/homex_outcome_test.rb +199 -0
- data/test/unit/ccls/hospital_test.rb +102 -0
- data/test/unit/ccls/icf_master_id_test.rb +30 -0
- data/test/unit/ccls/icf_master_tracker_change_test.rb +14 -0
- data/test/unit/ccls/icf_master_tracker_test.rb +132 -0
- data/test/unit/ccls/icf_master_tracker_update_test.rb +176 -0
- data/test/unit/ccls/ineligible_reason_test.rb +48 -0
- data/test/unit/ccls/instrument_test.rb +62 -0
- data/test/unit/ccls/instrument_type_test.rb +39 -0
- data/test/unit/ccls/instrument_version_test.rb +71 -0
- data/test/unit/ccls/interview_method_test.rb +44 -0
- data/test/unit/ccls/interview_outcome_test.rb +34 -0
- data/test/unit/ccls/interview_test.rb +298 -0
- data/test/unit/ccls/language_test.rb +47 -0
- data/test/unit/ccls/live_birth_data_update_test.rb +358 -0
- data/test/unit/ccls/operational_event_test.rb +187 -0
- data/test/unit/ccls/operational_event_type_test.rb +51 -0
- data/test/unit/ccls/organization_test.rb +64 -0
- data/test/unit/ccls/patient_test.rb +538 -0
- data/test/unit/ccls/person_test.rb +55 -0
- data/test/unit/ccls/phone_number_test.rb +244 -0
- data/test/unit/ccls/phone_type_test.rb +32 -0
- data/test/unit/ccls/project_outcome_test.rb +34 -0
- data/test/unit/ccls/project_test.rb +60 -0
- data/test/unit/ccls/race_test.rb +37 -0
- data/test/unit/ccls/refusal_reason_test.rb +52 -0
- data/test/unit/ccls/role_test.rb +26 -0
- data/test/unit/ccls/sample_kit_test.rb +35 -0
- data/test/unit/ccls/sample_outcome_test.rb +34 -0
- data/test/unit/ccls/sample_temperature_test.rb +25 -0
- data/test/unit/ccls/sample_test.rb +363 -0
- data/test/unit/ccls/sample_type_test.rb +58 -0
- data/test/unit/ccls/section_test.rb +34 -0
- data/test/unit/ccls/state_test.rb +31 -0
- data/test/unit/ccls/study_subject_abstracts_test.rb +115 -0
- data/test/unit/ccls/study_subject_addresses_test.rb +93 -0
- data/test/unit/ccls/study_subject_duplicates_test.rb +407 -0
- data/test/unit/ccls/study_subject_enrollments_test.rb +65 -0
- data/test/unit/ccls/study_subject_homex_outcome_test.rb +64 -0
- data/test/unit/ccls/study_subject_identifier_test.rb +439 -0
- data/test/unit/ccls/study_subject_interviews_test.rb +26 -0
- data/test/unit/ccls/study_subject_languages_test.rb +142 -0
- data/test/unit/ccls/study_subject_operational_events_test.rb +53 -0
- data/test/unit/ccls/study_subject_patient_test.rb +249 -0
- data/test/unit/ccls/study_subject_pii_test.rb +278 -0
- data/test/unit/ccls/study_subject_races_test.rb +203 -0
- data/test/unit/ccls/study_subject_search_test.rb +704 -0
- data/test/unit/ccls/study_subject_test.rb +770 -0
- data/test/unit/ccls/subject_language_test.rb +43 -0
- data/test/unit/ccls/subject_race_test.rb +35 -0
- data/test/unit/ccls/subject_relationship_test.rb +43 -0
- data/test/unit/ccls/subject_type_test.rb +40 -0
- data/test/unit/ccls/tracing_status_test.rb +32 -0
- data/test/unit/ccls/transfer_test.rb +81 -0
- data/test/unit/ccls/translation_table_test.rb +40 -0
- data/test/unit/ccls/unit_test.rb +21 -0
- data/test/unit/ccls/user_test.rb +156 -0
- data/test/unit/ccls/vital_status_test.rb +36 -0
- data/test/unit/ccls/zip_code_test.rb +55 -0
- metadata +633 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Ccls::OperationalEventTypeTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
assert_should_behave_like_a_hash
|
6
|
+
|
7
|
+
assert_should_create_default_object
|
8
|
+
assert_should_act_as_list
|
9
|
+
assert_should_have_many(:operational_events)
|
10
|
+
assert_should_not_require_attributes( :position ) #, :project_id )
|
11
|
+
assert_should_require_attribute_length( :event_category, :in => 4..250 )
|
12
|
+
|
13
|
+
test "explicit Factory operational_event_type test" do
|
14
|
+
assert_difference('OperationalEventType.count',1) {
|
15
|
+
operational_event_type = Factory(:operational_event_type)
|
16
|
+
assert_match /Key\d*/, operational_event_type.key
|
17
|
+
assert_match /Desc\d*/, operational_event_type.description
|
18
|
+
assert_match /Cat\d*/, operational_event_type.event_category
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
# test "should return event_category as to_s" do
|
23
|
+
# operational_event_type = create_operational_event_type
|
24
|
+
# assert_equal operational_event_type.event_category, "#{operational_event_type}"
|
25
|
+
# end
|
26
|
+
|
27
|
+
test "should return event_category and description as to_s" do
|
28
|
+
operational_event_type = create_operational_event_type
|
29
|
+
assert_equal "#{operational_event_type}",
|
30
|
+
"#{operational_event_type.event_category}:#{operational_event_type.description}"
|
31
|
+
end
|
32
|
+
|
33
|
+
test "categories should return a unique, sorted array of event categories" do
|
34
|
+
#["ascertainment", "compensation", "completions", "correspondence", "enrollments", "interviews", "operations", "recruitment", "samples"]
|
35
|
+
categories = OperationalEventType.categories
|
36
|
+
assert categories.is_a?(Array)
|
37
|
+
assert !categories.empty?
|
38
|
+
categories.each do |category|
|
39
|
+
assert category.is_a?(String)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
#protected
|
44
|
+
#
|
45
|
+
# def create_operational_event_type(options={})
|
46
|
+
# operational_event_type = Factory.build(:operational_event_type,options)
|
47
|
+
# operational_event_type.save
|
48
|
+
# operational_event_type
|
49
|
+
# end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Ccls::OrganizationTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
assert_should_behave_like_a_hash( :value => :name )
|
6
|
+
|
7
|
+
assert_should_create_default_object
|
8
|
+
assert_should_act_as_list
|
9
|
+
assert_should_not_require_attributes( :position, :person_id )
|
10
|
+
assert_should_belong_to( :person )
|
11
|
+
assert_should_have_many( :patients )
|
12
|
+
# assert_should_have_many( :hospitals )
|
13
|
+
assert_should_have_one( :hospital )
|
14
|
+
|
15
|
+
assert_should_have_many(:aliquots,
|
16
|
+
:foreign_key => :owner_id)
|
17
|
+
|
18
|
+
with_options :class_name => 'Transfer' do |o|
|
19
|
+
o.assert_should_have_many(:incoming_transfers,
|
20
|
+
:foreign_key => :to_organization_id)
|
21
|
+
o.assert_should_have_many(:outgoing_transfers,
|
22
|
+
:foreign_key => :from_organization_id)
|
23
|
+
end
|
24
|
+
|
25
|
+
test "explicit Factory organization test" do
|
26
|
+
assert_difference('Organization.count',1) {
|
27
|
+
organization = Factory(:organization)
|
28
|
+
assert_match /Key \d*/, organization.key
|
29
|
+
assert_match /Name \d*/, organization.name
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
test "new incoming_transfer should have matching organization id" do
|
34
|
+
organization = create_organization
|
35
|
+
transfer = organization.incoming_transfers.build
|
36
|
+
assert_equal organization.id, transfer.to_organization_id
|
37
|
+
end
|
38
|
+
|
39
|
+
test "new outgoing_transfer should have matching organization id" do
|
40
|
+
organization = create_organization
|
41
|
+
transfer = organization.outgoing_transfers.build
|
42
|
+
assert_equal organization.id, transfer.from_organization_id
|
43
|
+
end
|
44
|
+
|
45
|
+
# TODO haven't really implemented organization samples yet
|
46
|
+
# test "should have many samples" do
|
47
|
+
# # this is unclear in my diagram
|
48
|
+
# pending
|
49
|
+
# end
|
50
|
+
|
51
|
+
test "should return name as to_s" do
|
52
|
+
organization = create_organization
|
53
|
+
assert_equal organization.name, "#{organization}"
|
54
|
+
end
|
55
|
+
|
56
|
+
#protected
|
57
|
+
#
|
58
|
+
# def create_organization(options={})
|
59
|
+
# organization = Factory.build(:organization,options)
|
60
|
+
# organization.save
|
61
|
+
# organization
|
62
|
+
# end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,538 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Ccls::PatientTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
[ :was_under_15_at_dx, :was_previously_treated,
|
6
|
+
:was_ca_resident_at_diagnosis ].each do |field|
|
7
|
+
|
8
|
+
# Making assumption that 12345 will NEVER be a valid value.
|
9
|
+
test "should NOT allow 12345 for #{field}" do
|
10
|
+
patient = Patient.new(field => 12345)
|
11
|
+
patient.valid?
|
12
|
+
assert patient.errors.on_attr_and_type?(field,:inclusion)
|
13
|
+
end
|
14
|
+
|
15
|
+
test "should allow nil for #{field}" do
|
16
|
+
patient = Patient.new(field => nil)
|
17
|
+
assert_nil patient.send(field)
|
18
|
+
patient.valid?
|
19
|
+
assert !patient.errors.on(field)
|
20
|
+
end
|
21
|
+
|
22
|
+
test "should allow all valid YNDK values for #{field}" do
|
23
|
+
patient = Patient.new
|
24
|
+
YNDK.valid_values.each do |value|
|
25
|
+
patient.send("#{field}=", value)
|
26
|
+
patient.valid?
|
27
|
+
assert !patient.errors.on(field)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
assert_should_create_default_object
|
34
|
+
assert_should_initially_belong_to :study_subject
|
35
|
+
assert_should_initially_belong_to :organization
|
36
|
+
assert_should_initially_belong_to :diagnosis
|
37
|
+
assert_should_protect( :study_subject_id, :study_subject )
|
38
|
+
|
39
|
+
assert_should_require_attributes(
|
40
|
+
:diagnosis_id,
|
41
|
+
:hospital_no, :organization_id, :admit_date )
|
42
|
+
|
43
|
+
assert_should_not_require_attributes(
|
44
|
+
:other_diagnosis,
|
45
|
+
:diagnosis_date,
|
46
|
+
:raf_zip,
|
47
|
+
:raf_county )
|
48
|
+
|
49
|
+
assert_should_require_attribute_length :hospital_no, :maximum => 25
|
50
|
+
assert_should_require_unique(:hospital_no, :scope => :organization_id)
|
51
|
+
assert_should_require_attribute_length( :raf_zip, :maximum => 10 )
|
52
|
+
assert_requires_complete_date :admit_date
|
53
|
+
assert_requires_complete_date :diagnosis_date
|
54
|
+
assert_requires_complete_date :treatment_began_on
|
55
|
+
assert_requires_past_date :admit_date
|
56
|
+
assert_requires_past_date :diagnosis_date
|
57
|
+
assert_requires_past_date :treatment_began_on
|
58
|
+
|
59
|
+
test "explicit Factory subjectless patient test" do
|
60
|
+
assert_difference('StudySubject.count',0) {
|
61
|
+
assert_difference('Patient.count',1) {
|
62
|
+
patient = Factory(:subjectless_patient)
|
63
|
+
assert_nil patient.study_subject
|
64
|
+
assert_not_nil patient.admit_date
|
65
|
+
assert_not_nil patient.hospital_no
|
66
|
+
assert_not_nil patient.organization_id
|
67
|
+
assert_not_nil patient.diagnosis_id
|
68
|
+
} }
|
69
|
+
end
|
70
|
+
|
71
|
+
test "explicit Factory patient hospital sequence test" do
|
72
|
+
patient = Factory(:patient) # 'first' hospital
|
73
|
+
(Hospital.count - 1).times { # loop over the rest of the hospitals
|
74
|
+
new_patient = Factory(:patient)
|
75
|
+
assert patient.organization_id != new_patient.organization_id
|
76
|
+
}
|
77
|
+
new_patient = Factory(:patient) # back to the 'first' hospital
|
78
|
+
assert patient.organization_id == new_patient.organization_id
|
79
|
+
end
|
80
|
+
|
81
|
+
test "explicit Factory patient test" do
|
82
|
+
assert_difference('StudySubject.count',1) {
|
83
|
+
assert_difference('Patient.count',1) {
|
84
|
+
patient = Factory(:patient)
|
85
|
+
assert_not_nil patient.study_subject
|
86
|
+
assert_equal patient.study_subject.subject_type, SubjectType['Case']
|
87
|
+
} }
|
88
|
+
end
|
89
|
+
|
90
|
+
test "explicit Factory waivered patient hospital sequence test" do
|
91
|
+
patient = Factory(:waivered_patient) # 'first' hospital
|
92
|
+
(Hospital.waivered.count - 1).times { # loop over the rest of the hospitals
|
93
|
+
new_patient = Factory(:waivered_patient)
|
94
|
+
assert patient.organization_id != new_patient.organization_id
|
95
|
+
}
|
96
|
+
new_patient = Factory(:waivered_patient) # back to the 'first' hospital
|
97
|
+
assert patient.organization_id == new_patient.organization_id
|
98
|
+
end
|
99
|
+
|
100
|
+
test "explicit Factory waivered_patient test" do
|
101
|
+
assert_difference('StudySubject.count',1) {
|
102
|
+
assert_difference('Patient.count',1) {
|
103
|
+
patient = Factory(:waivered_patient)
|
104
|
+
assert_not_nil patient.study_subject
|
105
|
+
assert_equal patient.study_subject.subject_type, SubjectType['Case']
|
106
|
+
assert patient.organization.hospital.has_irb_waiver
|
107
|
+
} }
|
108
|
+
end
|
109
|
+
|
110
|
+
test "explicit Factory nonwaivered patient hospital sequence test" do
|
111
|
+
patient = Factory(:nonwaivered_patient) # 'first' hospital
|
112
|
+
(Hospital.nonwaivered.count - 1).times { # loop over the rest of the hospitals
|
113
|
+
new_patient = Factory(:nonwaivered_patient)
|
114
|
+
assert patient.organization_id != new_patient.organization_id
|
115
|
+
}
|
116
|
+
new_patient = Factory(:nonwaivered_patient) # back to the 'first' hospital
|
117
|
+
assert patient.organization_id == new_patient.organization_id
|
118
|
+
end
|
119
|
+
|
120
|
+
test "explicit Factory nonwaivered_patient test" do
|
121
|
+
assert_difference('StudySubject.count',1) {
|
122
|
+
assert_difference('Patient.count',1) {
|
123
|
+
patient = Factory(:nonwaivered_patient)
|
124
|
+
assert_not_nil patient.study_subject
|
125
|
+
assert_equal patient.study_subject.subject_type, SubjectType['Case']
|
126
|
+
assert !patient.organization.hospital.has_irb_waiver
|
127
|
+
} }
|
128
|
+
end
|
129
|
+
|
130
|
+
test "should default was_ca_resident_at_diagnosis to null" do
|
131
|
+
assert_difference( "Patient.count", 1 ) {
|
132
|
+
patient = create_patient
|
133
|
+
assert_nil patient.reload.was_ca_resident_at_diagnosis
|
134
|
+
}
|
135
|
+
end
|
136
|
+
|
137
|
+
test "should default was_previously_treated to null" do
|
138
|
+
assert_difference( "Patient.count", 1 ) {
|
139
|
+
patient = create_patient
|
140
|
+
assert_nil patient.reload.was_previously_treated
|
141
|
+
}
|
142
|
+
end
|
143
|
+
|
144
|
+
# This would have been because there was no dob because
|
145
|
+
# there was no pii. Not true anymore
|
146
|
+
# test "should default was_under_15_at_dx to null" do
|
147
|
+
# assert_difference( "Patient.count", 1 ) {
|
148
|
+
# patient = create_patient
|
149
|
+
# assert_nil patient.reload.was_under_15_at_dx
|
150
|
+
# }
|
151
|
+
# end
|
152
|
+
|
153
|
+
test "should require Case study_subject" do
|
154
|
+
assert_difference( "StudySubject.count", 1 ) {
|
155
|
+
assert_difference( "Patient.count", 0 ) {
|
156
|
+
patient = create_patient(:study_subject => Factory(:study_subject))
|
157
|
+
assert patient.errors.on(:study_subject)
|
158
|
+
} }
|
159
|
+
end
|
160
|
+
|
161
|
+
test "should require case study_subject when using nested attributes" do
|
162
|
+
assert_difference( "StudySubject.count", 0 ) {
|
163
|
+
assert_difference( "Patient.count", 0 ) {
|
164
|
+
study_subject = create_study_subject(
|
165
|
+
:patient_attributes => Factory.attributes_for(:patient))
|
166
|
+
# raised from study_subject model, NOT patient
|
167
|
+
assert study_subject.errors.on(:patient)
|
168
|
+
} }
|
169
|
+
end
|
170
|
+
|
171
|
+
test "should allow admit_date be on DOB" do
|
172
|
+
assert_difference( "Patient.count", 1 ) {
|
173
|
+
study_subject = Factory(:case_study_subject)
|
174
|
+
patient = create_patient(
|
175
|
+
:study_subject => study_subject,
|
176
|
+
:admit_date => study_subject.dob )
|
177
|
+
assert !patient.errors.on(:admit_date)
|
178
|
+
assert_equal study_subject.dob, patient.admit_date
|
179
|
+
}
|
180
|
+
end
|
181
|
+
|
182
|
+
test "should require admit_date be after DOB" do
|
183
|
+
assert_difference( "Patient.count", 0 ) {
|
184
|
+
study_subject = Factory(:case_study_subject)
|
185
|
+
assert Date.jd(2430000) < study_subject.dob
|
186
|
+
patient = create_patient(
|
187
|
+
:study_subject => study_subject,
|
188
|
+
:admit_date => Date.jd(2430000) )
|
189
|
+
# BEFORE my factory set dob to raise error (Date.jd(2440000+rand(15000))
|
190
|
+
assert patient.errors.on(:admit_date)
|
191
|
+
assert_match(/before.*dob/,
|
192
|
+
patient.errors.on(:admit_date))
|
193
|
+
}
|
194
|
+
end
|
195
|
+
|
196
|
+
test "should NOT require admit_date 1/1/1900 be after DOB" do
|
197
|
+
assert_difference( "Patient.count", 1 ) {
|
198
|
+
study_subject = Factory(:case_study_subject)
|
199
|
+
patient = create_patient(
|
200
|
+
:study_subject => study_subject,
|
201
|
+
:admit_date => Date.parse('1/1/1900') )
|
202
|
+
assert !patient.errors.on(:admit_date)
|
203
|
+
}
|
204
|
+
end
|
205
|
+
|
206
|
+
test "should require admit_date be after DOB when using nested attributes" do
|
207
|
+
assert_difference( "StudySubject.count", 0 ) {
|
208
|
+
assert_difference( "Patient.count", 0 ) {
|
209
|
+
study_subject = create_case_study_subject(
|
210
|
+
:patient_attributes => Factory.attributes_for(:patient,{
|
211
|
+
# BEFORE my factory set dob to raise error (Date.jd(2440000+rand(15000))
|
212
|
+
:admit_date => Date.jd(2430000)
|
213
|
+
}))
|
214
|
+
assert study_subject.errors.on('patient:admit_date')
|
215
|
+
assert_match(/before.*dob/,
|
216
|
+
study_subject.errors.on('patient:admit_date'))
|
217
|
+
} }
|
218
|
+
end
|
219
|
+
|
220
|
+
test "should NOT require admit_date 1/1/1900 be after DOB" <<
|
221
|
+
" when using nested attributes" do
|
222
|
+
assert_difference( "StudySubject.count", 1 ) {
|
223
|
+
assert_difference( "Patient.count", 1 ) {
|
224
|
+
study_subject = create_case_study_subject(
|
225
|
+
:patient_attributes => Factory.attributes_for(:patient,{
|
226
|
+
:admit_date => Date.parse('1/1/1900')
|
227
|
+
}))
|
228
|
+
assert !study_subject.errors.on('patient:admit_date')
|
229
|
+
} }
|
230
|
+
end
|
231
|
+
|
232
|
+
|
233
|
+
test "should allow diagnosis_date be on DOB" do
|
234
|
+
assert_difference( "Patient.count", 1 ) do
|
235
|
+
study_subject = Factory(:case_study_subject)
|
236
|
+
patient = create_patient(
|
237
|
+
:study_subject => study_subject,
|
238
|
+
:diagnosis_date => study_subject.dob )
|
239
|
+
assert !patient.errors.on(:diagnosis_date)
|
240
|
+
assert_equal patient.diagnosis_date, study_subject.dob
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
test "should require diagnosis_date be after DOB" do
|
245
|
+
assert_difference( "Patient.count", 0 ) do
|
246
|
+
study_subject = Factory(:case_study_subject)
|
247
|
+
assert Date.jd(2430000) < study_subject.dob
|
248
|
+
patient = create_patient(
|
249
|
+
:study_subject => study_subject,
|
250
|
+
:diagnosis_date => Date.jd(2430000) )
|
251
|
+
# BEFORE my factory set dob to raise error (Date.jd(2440000+rand(15000))
|
252
|
+
assert patient.errors.on(:diagnosis_date)
|
253
|
+
assert_match(/before.*dob/,
|
254
|
+
patient.errors.on(:diagnosis_date))
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
test "should require diagnosis_date be after DOB when using nested attributes" do
|
259
|
+
assert_difference( "StudySubject.count", 0 ) {
|
260
|
+
assert_difference( "Patient.count", 0 ) {
|
261
|
+
study_subject = create_case_study_subject(
|
262
|
+
:patient_attributes => Factory.attributes_for(:patient,{
|
263
|
+
# BEFORE my factory set dob to raise error
|
264
|
+
:diagnosis_date => Date.jd(2430000),
|
265
|
+
}))
|
266
|
+
assert study_subject.errors.on('patient:diagnosis_date')
|
267
|
+
} }
|
268
|
+
end
|
269
|
+
|
270
|
+
|
271
|
+
test "should require treatment_began_on be after diagnosis_date" do
|
272
|
+
assert_difference( "Patient.count", 0 ) do
|
273
|
+
study_subject = Factory(:case_study_subject,
|
274
|
+
:dob => Date.jd(2420000) )
|
275
|
+
patient = create_patient(
|
276
|
+
:study_subject => study_subject,
|
277
|
+
:diagnosis_date => Date.jd(2440000),
|
278
|
+
:treatment_began_on => Date.jd(2430000) )
|
279
|
+
assert patient.errors.on(:treatment_began_on)
|
280
|
+
assert_match(/Date treatment began must be on or after the diagnosis date/,
|
281
|
+
patient.errors.on(:treatment_began_on))
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
test "should require treatment_began_on be after diagnosis_date" <<
|
286
|
+
" when using nested attributes" do
|
287
|
+
assert_difference( "StudySubject.count", 0 ) {
|
288
|
+
assert_difference( "Patient.count", 0 ) {
|
289
|
+
study_subject = create_case_study_subject(
|
290
|
+
:dob => Date.jd(2420000),
|
291
|
+
:patient_attributes => Factory.attributes_for(:patient,{
|
292
|
+
:diagnosis_date => Date.jd(2440000),
|
293
|
+
:treatment_began_on => Date.jd(2430000),
|
294
|
+
}))
|
295
|
+
assert study_subject.patient.errors.on(:treatment_began_on)
|
296
|
+
assert study_subject.errors.on('patient.treatment_began_on')
|
297
|
+
assert_match(/Date treatment began must be on or after the diagnosis date/,
|
298
|
+
study_subject.patient.errors.on(:treatment_began_on))
|
299
|
+
} }
|
300
|
+
end
|
301
|
+
|
302
|
+
|
303
|
+
test "should NOT set was_under_15_at_dx with admit_date 1/1/1900" <<
|
304
|
+
" using nested attributes" do
|
305
|
+
assert_difference( "StudySubject.count", 1 ) {
|
306
|
+
assert_difference( "Patient.count", 1 ) {
|
307
|
+
dob = 10.years.ago.to_date
|
308
|
+
admit_date = Date.parse('1/1/1900')
|
309
|
+
study_subject = create_case_study_subject(
|
310
|
+
:dob => dob,
|
311
|
+
:patient_attributes => Factory.attributes_for(:patient,{
|
312
|
+
:admit_date => admit_date
|
313
|
+
})
|
314
|
+
).reload
|
315
|
+
assert_equal dob, study_subject.dob
|
316
|
+
assert_equal admit_date, study_subject.patient.admit_date
|
317
|
+
assert_nil study_subject.patient.was_under_15_at_dx
|
318
|
+
} }
|
319
|
+
end
|
320
|
+
|
321
|
+
test "should NOT set was_under_15_at_dx with admit_date 1/1/1900" <<
|
322
|
+
" not using nested attributes" do
|
323
|
+
assert_difference( "StudySubject.count", 1 ) {
|
324
|
+
assert_difference( "Patient.count", 1 ) {
|
325
|
+
dob = 10.years.ago.to_date
|
326
|
+
admit_date = Date.parse('1/1/1900')
|
327
|
+
study_subject = create_case_study_subject( :dob => dob )
|
328
|
+
patient = Factory(:patient,{
|
329
|
+
:study_subject => study_subject,
|
330
|
+
:admit_date => admit_date
|
331
|
+
})
|
332
|
+
study_subject.reload
|
333
|
+
assert_equal dob, study_subject.dob
|
334
|
+
assert_equal admit_date, study_subject.patient.admit_date
|
335
|
+
assert_nil study_subject.patient.was_under_15_at_dx
|
336
|
+
} }
|
337
|
+
end
|
338
|
+
|
339
|
+
|
340
|
+
test "should NOT set was_under_15_at_dx with dob 1/1/1900 using nested attributes" do
|
341
|
+
assert_difference( "StudySubject.count", 1 ) {
|
342
|
+
assert_difference( "Patient.count", 1 ) {
|
343
|
+
dob = Date.parse('1/1/1900')
|
344
|
+
admit_date = 1.year.ago.to_date
|
345
|
+
study_subject = create_case_study_subject(
|
346
|
+
:dob => dob,
|
347
|
+
:patient_attributes => Factory.attributes_for(:patient,{
|
348
|
+
:admit_date => admit_date
|
349
|
+
})
|
350
|
+
).reload
|
351
|
+
assert_equal dob, study_subject.dob
|
352
|
+
assert_equal admit_date, study_subject.patient.admit_date
|
353
|
+
assert_nil study_subject.patient.was_under_15_at_dx
|
354
|
+
} }
|
355
|
+
end
|
356
|
+
|
357
|
+
test "should NOT set was_under_15_at_dx with dob 1/1/1900 not using nested attributes" do
|
358
|
+
assert_difference( "StudySubject.count", 1 ) {
|
359
|
+
assert_difference( "Patient.count", 1 ) {
|
360
|
+
dob = Date.parse('1/1/1900')
|
361
|
+
admit_date = 1.year.ago.to_date
|
362
|
+
study_subject = create_case_study_subject( :dob => dob )
|
363
|
+
patient = Factory(:patient,{
|
364
|
+
:study_subject => study_subject,
|
365
|
+
:admit_date => admit_date
|
366
|
+
})
|
367
|
+
study_subject.reload
|
368
|
+
assert_equal dob, study_subject.dob
|
369
|
+
assert_equal admit_date, study_subject.patient.admit_date
|
370
|
+
assert_nil study_subject.patient.was_under_15_at_dx
|
371
|
+
} }
|
372
|
+
end
|
373
|
+
|
374
|
+
|
375
|
+
test "should set was_under_15_at_dx to YNDK[:yes] using nested attributes" do
|
376
|
+
assert_difference( "StudySubject.count", 1 ) {
|
377
|
+
assert_difference( "Patient.count", 1 ) {
|
378
|
+
dob = 14.years.ago.to_date
|
379
|
+
admit_date = 1.year.ago.to_date
|
380
|
+
study_subject = create_case_study_subject(
|
381
|
+
:dob => dob,
|
382
|
+
:patient_attributes => Factory.attributes_for(:patient,{
|
383
|
+
:admit_date => admit_date
|
384
|
+
})
|
385
|
+
).reload
|
386
|
+
assert_equal dob, study_subject.dob
|
387
|
+
assert_equal admit_date, study_subject.patient.admit_date
|
388
|
+
assert_equal YNDK[:yes], study_subject.patient.was_under_15_at_dx
|
389
|
+
} }
|
390
|
+
end
|
391
|
+
|
392
|
+
test "should set was_under_15_at_dx to YNDK[:yes] not using nested attributes" do
|
393
|
+
assert_difference( "StudySubject.count", 1 ) {
|
394
|
+
assert_difference( "Patient.count", 1 ) {
|
395
|
+
dob = 14.years.ago.to_date
|
396
|
+
admit_date = 1.year.ago.to_date
|
397
|
+
study_subject = create_case_study_subject( :dob => dob )
|
398
|
+
patient = Factory(:patient,{
|
399
|
+
:study_subject => study_subject,
|
400
|
+
:admit_date => admit_date
|
401
|
+
})
|
402
|
+
study_subject.reload
|
403
|
+
assert_equal dob, study_subject.dob
|
404
|
+
assert_equal admit_date, study_subject.patient.admit_date
|
405
|
+
assert_equal YNDK[:yes], study_subject.patient.was_under_15_at_dx
|
406
|
+
} }
|
407
|
+
end
|
408
|
+
|
409
|
+
|
410
|
+
test "should set was_under_15_at_dx to YNDK[:no] using nested attributes" do
|
411
|
+
assert_difference( "StudySubject.count", 1 ) {
|
412
|
+
assert_difference( "Patient.count", 1 ) {
|
413
|
+
dob = 20.years.ago.to_date
|
414
|
+
admit_date = 1.year.ago.to_date
|
415
|
+
study_subject = create_case_study_subject(
|
416
|
+
:dob => dob,
|
417
|
+
:patient_attributes => Factory.attributes_for(:patient,{
|
418
|
+
:admit_date => admit_date
|
419
|
+
})
|
420
|
+
).reload
|
421
|
+
assert_equal dob, study_subject.dob
|
422
|
+
assert_equal admit_date, study_subject.patient.admit_date
|
423
|
+
assert_equal YNDK[:no], study_subject.patient.was_under_15_at_dx
|
424
|
+
} }
|
425
|
+
end
|
426
|
+
|
427
|
+
test "should set was_under_15_at_dx to YNDK[:no] not using nested attributes" do
|
428
|
+
assert_difference( "StudySubject.count", 1 ) {
|
429
|
+
assert_difference( "Patient.count", 1 ) {
|
430
|
+
dob = 20.years.ago.to_date
|
431
|
+
admit_date = 1.year.ago.to_date
|
432
|
+
study_subject = create_case_study_subject( :dob => dob )
|
433
|
+
# patient creation MUST come AFTER pii creation
|
434
|
+
patient = Factory(:patient,{
|
435
|
+
:study_subject => study_subject,
|
436
|
+
:admit_date => admit_date
|
437
|
+
})
|
438
|
+
study_subject.reload
|
439
|
+
assert_equal dob, study_subject.dob
|
440
|
+
assert_equal admit_date, study_subject.patient.admit_date
|
441
|
+
assert_equal YNDK[:no], study_subject.patient.was_under_15_at_dx
|
442
|
+
} }
|
443
|
+
end
|
444
|
+
|
445
|
+
test "should set was_under_15_at_dx on dob change" do
|
446
|
+
study_subject = create_case_study_subject(
|
447
|
+
:dob => 20.years.ago.to_date,
|
448
|
+
:patient_attributes => Factory.attributes_for(:patient,{
|
449
|
+
:admit_date => 1.year.ago.to_date
|
450
|
+
})
|
451
|
+
).reload
|
452
|
+
assert_equal YNDK[:no], study_subject.patient.was_under_15_at_dx
|
453
|
+
study_subject.update_attributes(:dob => 10.years.ago.to_date)
|
454
|
+
assert_equal YNDK[:yes], study_subject.patient.reload.was_under_15_at_dx
|
455
|
+
end
|
456
|
+
|
457
|
+
test "should set was_under_15_at_dx on admit_date change" do
|
458
|
+
study_subject = create_case_study_subject(
|
459
|
+
:dob => 20.years.ago.to_date,
|
460
|
+
:patient_attributes => Factory.attributes_for(:patient,{
|
461
|
+
:admit_date => 1.year.ago.to_date
|
462
|
+
})
|
463
|
+
).reload
|
464
|
+
assert_equal YNDK[:no], study_subject.patient.was_under_15_at_dx
|
465
|
+
study_subject.patient.update_attributes(:admit_date => 10.years.ago.to_date)
|
466
|
+
assert_equal YNDK[:yes], study_subject.patient.reload.was_under_15_at_dx
|
467
|
+
end
|
468
|
+
|
469
|
+
test "should require 5 or 9 digit raf_zip" do
|
470
|
+
%w( asdf 1234 123456 1234Q ).each do |bad_zip|
|
471
|
+
assert_difference( "Patient.count", 0 ) do
|
472
|
+
patient = create_patient( :raf_zip => bad_zip )
|
473
|
+
assert patient.errors.on(:raf_zip)
|
474
|
+
end
|
475
|
+
end
|
476
|
+
%w( 12345 12345-6789 123456789 ).each do |good_zip|
|
477
|
+
assert_difference( "Patient.count", 1 ) do
|
478
|
+
patient = create_patient( :raf_zip => good_zip )
|
479
|
+
assert !patient.errors.on(:raf_zip)
|
480
|
+
assert patient.raf_zip =~ /\A\d{5}(-)?(\d{4})?\z/
|
481
|
+
end
|
482
|
+
end
|
483
|
+
end
|
484
|
+
|
485
|
+
test "should format 9 digit zip" do
|
486
|
+
assert_difference( "Patient.count", 1 ) do
|
487
|
+
patient = create_patient( :raf_zip => '123456789' )
|
488
|
+
assert !patient.errors.on(:raf_zip)
|
489
|
+
assert patient.raf_zip =~ /\A\d{5}(-)?(\d{4})?\z/
|
490
|
+
assert_equal '12345-6789', patient.raf_zip
|
491
|
+
end
|
492
|
+
end
|
493
|
+
|
494
|
+
test "should require other_diagnosis if diagnosis == other" do
|
495
|
+
assert_difference( "Patient.count", 0 ) do
|
496
|
+
patient = create_patient(:diagnosis => Diagnosis['other'])
|
497
|
+
assert patient.errors.on_attr_and_type?(:other_diagnosis,:blank)
|
498
|
+
end
|
499
|
+
end
|
500
|
+
|
501
|
+
test "should not require other_diagnosis if diagnosis != other" do
|
502
|
+
assert_difference( "Patient.count", 1 ) do
|
503
|
+
patient = create_patient(:diagnosis => Diagnosis['ALL'])
|
504
|
+
assert !patient.errors.on_attr_and_type?(:other_diagnosis,:blank)
|
505
|
+
end
|
506
|
+
end
|
507
|
+
|
508
|
+
test "should require hospital_no with custom message" do
|
509
|
+
assert_difference( "Patient.count", 0 ) do
|
510
|
+
patient = create_patient( :hospital_no => nil )
|
511
|
+
assert patient.errors.on_attr_and_type?(:hospital_no,:blank)
|
512
|
+
assert_match /Hospital record number can't be blank/,
|
513
|
+
patient.errors.full_messages.to_sentence
|
514
|
+
assert_no_match /Hospital no/i,
|
515
|
+
patient.errors.full_messages.to_sentence
|
516
|
+
end
|
517
|
+
end
|
518
|
+
|
519
|
+
test "should require organization_id with custom message" do
|
520
|
+
assert_difference( "Patient.count", 0 ) do
|
521
|
+
patient = create_patient( :organization_id => nil )
|
522
|
+
assert patient.errors.on_attr_and_type?(:organization_id,:blank)
|
523
|
+
assert_match /Treating institution can't be blank/,
|
524
|
+
patient.errors.full_messages.to_sentence
|
525
|
+
assert_no_match /Organization/i,
|
526
|
+
patient.errors.full_messages.to_sentence
|
527
|
+
end
|
528
|
+
end
|
529
|
+
|
530
|
+
#protected
|
531
|
+
#
|
532
|
+
# def create_patient(options={})
|
533
|
+
# patient = Factory.build(:patient,options)
|
534
|
+
# patient.save
|
535
|
+
# patient
|
536
|
+
# end
|
537
|
+
|
538
|
+
end
|