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,70 @@
|
|
|
1
|
+
# Address for a study_subject
|
|
2
|
+
# Actually, this may be used for things other than subjects
|
|
3
|
+
class Address < ActiveRecordShared
|
|
4
|
+
|
|
5
|
+
default_scope :order => 'created_at DESC'
|
|
6
|
+
|
|
7
|
+
has_many :interviews
|
|
8
|
+
has_one :addressing
|
|
9
|
+
has_one :study_subject, :through => :addressing
|
|
10
|
+
belongs_to :address_type
|
|
11
|
+
|
|
12
|
+
validate :address_type_matches_line
|
|
13
|
+
|
|
14
|
+
validates_presence_of :address_type_id
|
|
15
|
+
validates_presence_of :address_type, :if => :address_type_id
|
|
16
|
+
|
|
17
|
+
validates_presence_of :line_1
|
|
18
|
+
validates_length_of :line_1, :maximum => 250, :allow_blank => true
|
|
19
|
+
validates_length_of :line_2, :maximum => 250, :allow_blank => true
|
|
20
|
+
validates_length_of :unit, :maximum => 250, :allow_blank => true
|
|
21
|
+
validates_presence_of :city
|
|
22
|
+
validates_length_of :city, :maximum => 250, :allow_blank => true
|
|
23
|
+
validates_presence_of :state
|
|
24
|
+
validates_length_of :state, :maximum => 250, :allow_blank => true
|
|
25
|
+
validates_presence_of :zip
|
|
26
|
+
validates_length_of :zip, :maximum => 10, :allow_blank => true
|
|
27
|
+
|
|
28
|
+
# this needs to be unique, but is only used during importing
|
|
29
|
+
validates_uniqueness_of :external_address_id, :allow_blank => true
|
|
30
|
+
|
|
31
|
+
validates_format_of :zip,
|
|
32
|
+
:with => /\A\s*\d{5}(-)?(\d{4})?\s*\z/,
|
|
33
|
+
:message => "should be 12345, 123451234 or 12345-1234", :allow_blank => true
|
|
34
|
+
|
|
35
|
+
# Would it be better to do this before_validation?
|
|
36
|
+
before_save :format_zip, :if => :zip_changed?
|
|
37
|
+
|
|
38
|
+
# Returns a string with the city, state and zip
|
|
39
|
+
def csz
|
|
40
|
+
"#{self.city}, #{self.state} #{self.zip}"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
protected
|
|
44
|
+
|
|
45
|
+
# Determine if the address is a PO Box and then
|
|
46
|
+
# require that the address type NOT be a residence.
|
|
47
|
+
def address_type_matches_line
|
|
48
|
+
# It is inevitable that this will match too much
|
|
49
|
+
# Pobox Street?
|
|
50
|
+
if(( line_1 =~ /p.*o.*box/i ) &&
|
|
51
|
+
( address_type_id.to_s == '1' )) # 1 is 'residence'
|
|
52
|
+
errors.add(:address_type_id,
|
|
53
|
+
"must not be residence with PO Box")
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Simply squish the zip removing leading and trailing spaces.
|
|
58
|
+
# zip MUST be a string or this won't work. Will always be
|
|
59
|
+
# a string when sent from a form.
|
|
60
|
+
def format_zip
|
|
61
|
+
# zip was nil during import and skipping validations
|
|
62
|
+
self.zip.squish! unless zip.nil?
|
|
63
|
+
# convert to 12345-1234
|
|
64
|
+
if !self.zip.nil? and self.zip.length > 5
|
|
65
|
+
old = self.zip.gsub(/\D/,'')
|
|
66
|
+
self.zip = "#{old[0..4]}-#{old[5..8]}"
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# The type of address (home,work,residence,pobox,etc.)
|
|
2
|
+
class AddressType < ActiveRecordShared
|
|
3
|
+
|
|
4
|
+
acts_as_list
|
|
5
|
+
default_scope :order => :position
|
|
6
|
+
|
|
7
|
+
acts_like_a_hash
|
|
8
|
+
has_many :addresses
|
|
9
|
+
|
|
10
|
+
# Returns the key
|
|
11
|
+
def to_s
|
|
12
|
+
self.key
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# Rich join of Subject and Address
|
|
2
|
+
class Addressing < ActiveRecordShared
|
|
3
|
+
|
|
4
|
+
belongs_to :study_subject
|
|
5
|
+
belongs_to :address
|
|
6
|
+
belongs_to :data_source
|
|
7
|
+
|
|
8
|
+
# TODO test this. Also may not need current_user now.
|
|
9
|
+
# This works in the console and such, but ActiveScaffold tries
|
|
10
|
+
# to use it in a join, but it is in a different database so fails.
|
|
11
|
+
# May be able to make it work in AS, but need to fiddle.
|
|
12
|
+
# belongs_to :verified_by, :foreign_key => 'verified_by_uid',
|
|
13
|
+
# :class_name => 'User', :primary_key => 'uid'
|
|
14
|
+
|
|
15
|
+
delegate :is_other?, :to => :data_source, :allow_nil => true, :prefix => true
|
|
16
|
+
delegate :address_type, :address_type_id,
|
|
17
|
+
:line_1,:line_2,:unit,:city,:state,:zip,:csz,:county,
|
|
18
|
+
:to => :address, :allow_nil => true
|
|
19
|
+
|
|
20
|
+
attr_accessor :current_user
|
|
21
|
+
|
|
22
|
+
# flag used in study_subject's nested attributes for addressing
|
|
23
|
+
# to not reject if address fields are blank.
|
|
24
|
+
attr_accessor :address_required
|
|
25
|
+
|
|
26
|
+
validates_length_of :why_invalid, :maximum => 250, :allow_blank => true
|
|
27
|
+
validates_presence_of :why_invalid, :if => :is_not_valid?
|
|
28
|
+
validates_length_of :how_verified, :maximum => 250, :allow_blank => true
|
|
29
|
+
validates_presence_of :how_verified, :if => :is_verified?
|
|
30
|
+
validates_complete_date_for :valid_from, :allow_nil => true
|
|
31
|
+
validates_complete_date_for :valid_to, :allow_nil => true
|
|
32
|
+
|
|
33
|
+
validates_presence_of :data_source_other, :if => :data_source_is_other?
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
attr_protected :study_subject_id, :study_subject
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
validates_inclusion_of :current_address, :is_valid,
|
|
44
|
+
:address_at_diagnosis,
|
|
45
|
+
:in => YNDK.valid_values, :allow_nil => true
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
named_scope :current, :conditions => [
|
|
49
|
+
'current_address IS NOT NULL AND current_address != 2'
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
named_scope :historic, :conditions => [
|
|
53
|
+
'current_address IS NULL OR current_address = 2'
|
|
54
|
+
]
|
|
55
|
+
|
|
56
|
+
# Don't do the rejections here.
|
|
57
|
+
accepts_nested_attributes_for :address
|
|
58
|
+
|
|
59
|
+
attr_accessor :subject_moved
|
|
60
|
+
|
|
61
|
+
after_save :create_subject_moved_event, :if => :subject_moved
|
|
62
|
+
|
|
63
|
+
before_save :set_verifier,
|
|
64
|
+
:if => :is_verified?,
|
|
65
|
+
:unless => :is_verified_was
|
|
66
|
+
|
|
67
|
+
before_save :nullify_verifier,
|
|
68
|
+
:unless => :is_verified?,
|
|
69
|
+
:if => :is_verified_was
|
|
70
|
+
|
|
71
|
+
after_create :check_state_for_eligibilty
|
|
72
|
+
|
|
73
|
+
# Returns boolean of comparison of is_valid == 2 or 999
|
|
74
|
+
# Rails SHOULD convert incoming string params to integer.
|
|
75
|
+
def is_not_valid?
|
|
76
|
+
# [2,999].include?(is_valid.to_i)
|
|
77
|
+
[2,999].include?(is_valid)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
protected
|
|
81
|
+
|
|
82
|
+
# Set verified time and user if given
|
|
83
|
+
def set_verifier
|
|
84
|
+
self.verified_on = Time.now
|
|
85
|
+
self.verified_by_uid = current_user.try(:uid)||''
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Unset verified time and user
|
|
89
|
+
def nullify_verifier
|
|
90
|
+
self.verified_on = nil
|
|
91
|
+
self.verified_by_uid = nil
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def check_state_for_eligibilty
|
|
95
|
+
if( state != 'CA' && study_subject &&
|
|
96
|
+
( hxe = study_subject.enrollments.find_by_project_id(Project['HomeExposures'].id) ) &&
|
|
97
|
+
address_type == AddressType['residence'] )
|
|
98
|
+
|
|
99
|
+
# This is an after_save so using 1 NOT 0
|
|
100
|
+
ineligible_reason = if( study_subject.residence_addresses_count == 1 )
|
|
101
|
+
IneligibleReason['newnonCA']
|
|
102
|
+
else
|
|
103
|
+
IneligibleReason['moved']
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
hxe.update_attributes(
|
|
107
|
+
:is_eligible => YNDK[:no],
|
|
108
|
+
:ineligible_reason => ineligible_reason
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
oet = OperationalEventType['ineligible']
|
|
112
|
+
if( oet.blank? )
|
|
113
|
+
errors.add(:base,"OperationalEventType['ineligible'] not found")
|
|
114
|
+
raise ActiveRecord::RecordNotSaved
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
OperationalEvent.create!(
|
|
118
|
+
:enrollment => hxe,
|
|
119
|
+
:operational_event_type => oet,
|
|
120
|
+
:occurred_on => Date.today,
|
|
121
|
+
:description => ineligible_reason.to_s
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# this will actually create an event on creation as well
|
|
128
|
+
# if attributes match
|
|
129
|
+
def create_subject_moved_event
|
|
130
|
+
# subject_moved will most likely be a string 'true' or 'false'
|
|
131
|
+
# as it will really only come as a hash value from a view.
|
|
132
|
+
# .true? is a common_lib#object method.
|
|
133
|
+
if subject_moved.true? &&
|
|
134
|
+
current_address == YNDK[:no] &&
|
|
135
|
+
current_address_was != YNDK[:no] &&
|
|
136
|
+
address.address_type == AddressType['residence']
|
|
137
|
+
ccls_enrollment = study_subject.enrollments.find_or_create_by_project_id(
|
|
138
|
+
Project['ccls'].id)
|
|
139
|
+
OperationalEvent.create!(
|
|
140
|
+
:enrollment => ccls_enrollment,
|
|
141
|
+
:operational_event_type => OperationalEventType['subject_moved'],
|
|
142
|
+
:occurred_on => Date.today
|
|
143
|
+
)
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# == requires
|
|
2
|
+
# * sample_id
|
|
3
|
+
# * unit_id
|
|
4
|
+
# * owner_id
|
|
5
|
+
class Aliquot < ActiveRecordShared
|
|
6
|
+
|
|
7
|
+
belongs_to :sample
|
|
8
|
+
belongs_to :unit
|
|
9
|
+
belongs_to :aliquot_sample_format
|
|
10
|
+
belongs_to :owner, :class_name => "Organization"
|
|
11
|
+
has_many :transfers
|
|
12
|
+
|
|
13
|
+
validates_presence_of :sample
|
|
14
|
+
validates_presence_of :unit
|
|
15
|
+
validates_presence_of :owner
|
|
16
|
+
validates_length_of :location, :maximum => 250, :allow_blank => true
|
|
17
|
+
validates_length_of :mass, :maximum => 250, :allow_blank => true
|
|
18
|
+
|
|
19
|
+
# Create a #Transfer for the given #Aliquot from the
|
|
20
|
+
# current owner(#Organization) to the given #Organization.
|
|
21
|
+
def transfer_to(organization)
|
|
22
|
+
org = Organization.find(organization)
|
|
23
|
+
# I don't think that the transaction is necessary
|
|
24
|
+
# but I also don't think that it will hurt.
|
|
25
|
+
Aliquot.transaction do
|
|
26
|
+
# wrap this in a transaction because
|
|
27
|
+
# we don't want the aliquot.owner being
|
|
28
|
+
# out of sync with the last transfer.to
|
|
29
|
+
self.transfer.to(org).save!
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
protected
|
|
34
|
+
|
|
35
|
+
# Begin building the #Transfer from the current
|
|
36
|
+
# owner(#Organization)
|
|
37
|
+
def transfer
|
|
38
|
+
Transfer.new({
|
|
39
|
+
:aliquot_id => self.id,
|
|
40
|
+
:from_organization_id => self.owner_id
|
|
41
|
+
})
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# don't know exactly
|
|
2
|
+
class Analysis < ActiveRecordShared
|
|
3
|
+
#
|
|
4
|
+
# TODO remove the habtm and replace it with hmt SubjectAnalyses ?
|
|
5
|
+
#
|
|
6
|
+
has_and_belongs_to_many :study_subjects
|
|
7
|
+
|
|
8
|
+
belongs_to :analyst, :class_name => 'Person'
|
|
9
|
+
belongs_to :analytic_file_creator, :class_name => 'Person'
|
|
10
|
+
belongs_to :project
|
|
11
|
+
|
|
12
|
+
acts_like_a_hash
|
|
13
|
+
|
|
14
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
class BcRequest < ActiveRecordShared
|
|
2
|
+
|
|
3
|
+
belongs_to :study_subject
|
|
4
|
+
attr_protected :study_subject_id, :study_subject
|
|
5
|
+
|
|
6
|
+
validates_length_of :request_type, :maximum => 250, :allow_blank => true
|
|
7
|
+
validates_length_of :status, :maximum => 250, :allow_blank => true
|
|
8
|
+
validates_length_of :notes, :maximum => 65000, :allow_blank => true
|
|
9
|
+
|
|
10
|
+
# validates_inclusion_of :status, :in => statuses
|
|
11
|
+
|
|
12
|
+
def self.statuses
|
|
13
|
+
%w( active waitlist pending complete )
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def to_s
|
|
17
|
+
( study_subject ) ? study_subject.studyid : self
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
class CandidateControl < ActiveRecordShared
|
|
2
|
+
|
|
3
|
+
belongs_to :study_subject
|
|
4
|
+
attr_protected :study_subject_id, :study_subject
|
|
5
|
+
|
|
6
|
+
validates_presence_of :first_name
|
|
7
|
+
validates_presence_of :last_name
|
|
8
|
+
validates_presence_of :dob
|
|
9
|
+
validates_inclusion_of :reject_candidate, :in => [true, false]
|
|
10
|
+
validates_presence_of :rejection_reason, :if => :reject_candidate
|
|
11
|
+
validates_length_of :related_patid, :is => 4, :allow_blank => true
|
|
12
|
+
validates_length_of :state_registrar_no, :maximum => 25, :allow_blank => true
|
|
13
|
+
validates_length_of :local_registrar_no, :maximum => 25, :allow_blank => true
|
|
14
|
+
|
|
15
|
+
validates_length_of :first_name, :middle_name, :last_name,
|
|
16
|
+
:birth_county, :birth_type, :mother_maiden_name,
|
|
17
|
+
:rejection_reason, :maximum => 250, :allow_blank => true
|
|
18
|
+
|
|
19
|
+
# validates_inclusion_of :sex, :in => %w( M F DK )
|
|
20
|
+
validates_inclusion_of :sex, :in => valid_sex_values
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
validates_inclusion_of :mother_hispanicity_id, :father_hispanicity_id,
|
|
24
|
+
:in => YNODK.valid_values, :allow_nil => true
|
|
25
|
+
validates_inclusion_of :mom_is_biomom, :dad_is_biodad,
|
|
26
|
+
:in => YNDK.valid_values, :allow_nil => true
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# Returns string containing candidates's first, middle and last name
|
|
30
|
+
def full_name
|
|
31
|
+
[first_name, middle_name, last_name].delete_if(&:blank?).join(' ')
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Returns string containing candidates's mother's first, middle and last name
|
|
35
|
+
def mother_full_name
|
|
36
|
+
[mother_first_name, mother_middle_name, mother_last_name].delete_if(&:blank?).join(' ')
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def create_study_subjects(case_subject,grouping = '6')
|
|
40
|
+
next_orderno = case_subject.next_control_orderno(grouping)
|
|
41
|
+
|
|
42
|
+
CandidateControl.transaction do
|
|
43
|
+
|
|
44
|
+
# Use a block so can assign all attributes without concern for attr_protected
|
|
45
|
+
child = StudySubject.new do |s|
|
|
46
|
+
s.subject_type = SubjectType['Control']
|
|
47
|
+
s.vital_status = VitalStatus['living']
|
|
48
|
+
s.sex = sex
|
|
49
|
+
s.mom_is_biomom = mom_is_biomom
|
|
50
|
+
s.dad_is_biodad = dad_is_biodad
|
|
51
|
+
s.mother_hispanicity_id = mother_hispanicity_id
|
|
52
|
+
s.father_hispanicity_id = father_hispanicity_id
|
|
53
|
+
s.birth_type = birth_type
|
|
54
|
+
s.mother_yrs_educ = mother_yrs_educ
|
|
55
|
+
s.father_yrs_educ = father_yrs_educ
|
|
56
|
+
s.birth_county = birth_county
|
|
57
|
+
s.hispanicity_id = (
|
|
58
|
+
( [mother_hispanicity_id,father_hispanicity_id].include?(1) ) ? 1 : nil )
|
|
59
|
+
s.first_name = first_name
|
|
60
|
+
s.middle_name = middle_name
|
|
61
|
+
s.last_name = last_name
|
|
62
|
+
s.dob = dob
|
|
63
|
+
s.mother_first_name = mother_first_name
|
|
64
|
+
s.mother_middle_name = mother_middle_name
|
|
65
|
+
s.mother_last_name = mother_last_name
|
|
66
|
+
s.mother_maiden_name = mother_maiden_name
|
|
67
|
+
s.mother_race_id = mother_race_id
|
|
68
|
+
s.father_race_id = father_race_id
|
|
69
|
+
|
|
70
|
+
s.case_control_type = grouping
|
|
71
|
+
s.state_registrar_no = state_registrar_no
|
|
72
|
+
s.local_registrar_no = local_registrar_no
|
|
73
|
+
s.orderno = next_orderno
|
|
74
|
+
s.matchingid = case_subject.subjectid
|
|
75
|
+
s.patid = case_subject.patid
|
|
76
|
+
s.is_matched = true
|
|
77
|
+
end
|
|
78
|
+
child.save!
|
|
79
|
+
child.assign_icf_master_id
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
# TODO May have to set is_matched for both the Case and Control here [#217]
|
|
83
|
+
# We will default it to null and add logic to set it to true for both the new control and their related case when a new control is added to study_subjects from candidate_controls.
|
|
84
|
+
case_subject.update_attributes!(:is_matched => true)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
# NOTE this may require passing info
|
|
88
|
+
# that is in the candidate_control record, but not in the child subject
|
|
89
|
+
# mother_hispanicity_id (actually this is now)
|
|
90
|
+
# worst case scenario is just create the full mother here
|
|
91
|
+
# rather than through the child.
|
|
92
|
+
child.create_mother # ({ .... })
|
|
93
|
+
|
|
94
|
+
self.study_subject_id = child.id
|
|
95
|
+
self.assigned_on = Date.today
|
|
96
|
+
self.save!
|
|
97
|
+
end
|
|
98
|
+
self
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# == requires
|
|
2
|
+
# * description (unique and >3 chars)
|
|
3
|
+
class Context < ActiveRecordShared
|
|
4
|
+
|
|
5
|
+
acts_as_list
|
|
6
|
+
default_scope :order => :position
|
|
7
|
+
|
|
8
|
+
acts_like_a_hash
|
|
9
|
+
|
|
10
|
+
has_many :units
|
|
11
|
+
# has_many :people
|
|
12
|
+
|
|
13
|
+
has_many :context_data_sources
|
|
14
|
+
has_many :data_sources, :through => :context_data_sources
|
|
15
|
+
|
|
16
|
+
validates_length_of :notes, :maximum => 65000, :allow_blank => true
|
|
17
|
+
|
|
18
|
+
# Returns description
|
|
19
|
+
def to_s
|
|
20
|
+
description
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|