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.
Files changed (269) hide show
  1. data/README.rdoc +182 -0
  2. data/app/models/abstract.rb +181 -0
  3. data/app/models/abstract_search.rb +50 -0
  4. data/app/models/abstract_validations.rb +324 -0
  5. data/app/models/address.rb +70 -0
  6. data/app/models/address_type.rb +15 -0
  7. data/app/models/addressing.rb +147 -0
  8. data/app/models/aliquot.rb +44 -0
  9. data/app/models/aliquot_sample_format.rb +13 -0
  10. data/app/models/analysis.rb +14 -0
  11. data/app/models/bc_request.rb +20 -0
  12. data/app/models/candidate_control.rb +101 -0
  13. data/app/models/context.rb +23 -0
  14. data/app/models/context_data_source.rb +4 -0
  15. data/app/models/county.rb +16 -0
  16. data/app/models/data_source.rb +24 -0
  17. data/app/models/diagnosis.rb +23 -0
  18. data/app/models/document_type.rb +16 -0
  19. data/app/models/document_version.rb +27 -0
  20. data/app/models/enrollment.rb +78 -0
  21. data/app/models/enrollment_validations.rb +167 -0
  22. data/app/models/follow_up.rb +16 -0
  23. data/app/models/follow_up_type.rb +18 -0
  24. data/app/models/gift_card.rb +22 -0
  25. data/app/models/gift_card_search.rb +137 -0
  26. data/app/models/home_exposure_response.rb +24 -0
  27. data/app/models/homex_outcome.rb +75 -0
  28. data/app/models/hospital.rb +22 -0
  29. data/app/models/icf_master_id.rb +30 -0
  30. data/app/models/icf_master_tracker.rb +217 -0
  31. data/app/models/icf_master_tracker_change.rb +9 -0
  32. data/app/models/icf_master_tracker_update.rb +50 -0
  33. data/app/models/ineligible_reason.rb +26 -0
  34. data/app/models/instrument.rb +26 -0
  35. data/app/models/instrument_type.rb +17 -0
  36. data/app/models/instrument_version.rb +28 -0
  37. data/app/models/interview.rb +122 -0
  38. data/app/models/interview_method.rb +17 -0
  39. data/app/models/interview_outcome.rb +16 -0
  40. data/app/models/language.rb +28 -0
  41. data/app/models/live_birth_data_update.rb +142 -0
  42. data/app/models/operational_event.rb +99 -0
  43. data/app/models/operational_event_type.rb +31 -0
  44. data/app/models/organization.rb +28 -0
  45. data/app/models/patient.rb +63 -0
  46. data/app/models/patient_validations.rb +118 -0
  47. data/app/models/person.rb +28 -0
  48. data/app/models/phone_number.rb +105 -0
  49. data/app/models/phone_type.rb +15 -0
  50. data/app/models/project.rb +39 -0
  51. data/app/models/project_outcome.rb +19 -0
  52. data/app/models/race.rb +31 -0
  53. data/app/models/refusal_reason.rb +23 -0
  54. data/app/models/sample.rb +168 -0
  55. data/app/models/sample_kit.rb +14 -0
  56. data/app/models/sample_outcome.rb +16 -0
  57. data/app/models/sample_temperature.rb +14 -0
  58. data/app/models/sample_type.rb +37 -0
  59. data/app/models/search.rb +195 -0
  60. data/app/models/section.rb +18 -0
  61. data/app/models/state.rb +25 -0
  62. data/app/models/study_subject.rb +237 -0
  63. data/app/models/study_subject_abstracts.rb +47 -0
  64. data/app/models/study_subject_addresses.rb +34 -0
  65. data/app/models/study_subject_associations.rb +38 -0
  66. data/app/models/study_subject_duplicates.rb +111 -0
  67. data/app/models/study_subject_enrollments.rb +17 -0
  68. data/app/models/study_subject_homex_outcome.rb +22 -0
  69. data/app/models/study_subject_identifier.rb +153 -0
  70. data/app/models/study_subject_interviews.rb +25 -0
  71. data/app/models/study_subject_languages.rb +21 -0
  72. data/app/models/study_subject_operational_events.rb +66 -0
  73. data/app/models/study_subject_patient.rb +177 -0
  74. data/app/models/study_subject_pii.rb +74 -0
  75. data/app/models/study_subject_races.rb +25 -0
  76. data/app/models/study_subject_search.rb +260 -0
  77. data/app/models/study_subject_validations.rb +116 -0
  78. data/app/models/subject_language.rb +11 -0
  79. data/app/models/subject_race.rb +11 -0
  80. data/app/models/subject_relationship.rb +21 -0
  81. data/app/models/subject_type.rb +22 -0
  82. data/app/models/tracing_status.rb +20 -0
  83. data/app/models/transfer.rb +40 -0
  84. data/app/models/unit.rb +14 -0
  85. data/app/models/vital_status.rb +19 -0
  86. data/app/models/zip_code.rb +36 -0
  87. data/config/abstract_fields.yml +1038 -0
  88. data/config/abstract_sections.yml +77 -0
  89. data/config/home_exposure_response_fields.yml +583 -0
  90. data/config/icf_master_tracker_update.yml +56 -0
  91. data/config/live_birth_data_update.yml +56 -0
  92. data/config/shared_use_db.yml +4 -0
  93. data/generators/ccls_engine/USAGE +2 -0
  94. data/generators/ccls_engine/ccls_engine_generator.rb +123 -0
  95. data/generators/ccls_engine/templates/autotest_ccls_engine.rb +3 -0
  96. data/generators/ccls_engine/templates/ccls_engine.rake +12 -0
  97. data/generators/ccls_engine/templates/fixtures/address_types.yml +30 -0
  98. data/generators/ccls_engine/templates/fixtures/context_data_sources.yml +54 -0
  99. data/generators/ccls_engine/templates/fixtures/contexts.yml +19 -0
  100. data/generators/ccls_engine/templates/fixtures/data_sources.yml +40 -0
  101. data/generators/ccls_engine/templates/fixtures/diagnoses.yml +40 -0
  102. data/generators/ccls_engine/templates/fixtures/document_types.yml +65 -0
  103. data/generators/ccls_engine/templates/fixtures/document_versions.csv +155 -0
  104. data/generators/ccls_engine/templates/fixtures/follow_up_types.yml +16 -0
  105. data/generators/ccls_engine/templates/fixtures/hospitals.yml +114 -0
  106. data/generators/ccls_engine/templates/fixtures/ineligible_reasons.yml +35 -0
  107. data/generators/ccls_engine/templates/fixtures/instrument_types.yml +26 -0
  108. data/generators/ccls_engine/templates/fixtures/instrument_versions.yml +22 -0
  109. data/generators/ccls_engine/templates/fixtures/instruments.yml +22 -0
  110. data/generators/ccls_engine/templates/fixtures/interview_methods.yml +30 -0
  111. data/generators/ccls_engine/templates/fixtures/interview_outcomes.yml +31 -0
  112. data/generators/ccls_engine/templates/fixtures/languages.yml +34 -0
  113. data/generators/ccls_engine/templates/fixtures/operational_event_types.yml +141 -0
  114. data/generators/ccls_engine/templates/fixtures/organizations.yml +198 -0
  115. data/generators/ccls_engine/templates/fixtures/people.yml +130 -0
  116. data/generators/ccls_engine/templates/fixtures/phone_types.yml +30 -0
  117. data/generators/ccls_engine/templates/fixtures/project_outcomes.yml +25 -0
  118. data/generators/ccls_engine/templates/fixtures/projects.yml +59 -0
  119. data/generators/ccls_engine/templates/fixtures/races.yml +52 -0
  120. data/generators/ccls_engine/templates/fixtures/refusal_reasons.yml +55 -0
  121. data/generators/ccls_engine/templates/fixtures/sample_outcomes.yml +36 -0
  122. data/generators/ccls_engine/templates/fixtures/sample_temperatures.yml +16 -0
  123. data/generators/ccls_engine/templates/fixtures/sample_types.yml +147 -0
  124. data/generators/ccls_engine/templates/fixtures/sections.yml +31 -0
  125. data/generators/ccls_engine/templates/fixtures/states.yml +363 -0
  126. data/generators/ccls_engine/templates/fixtures/subject_relationships.yml +46 -0
  127. data/generators/ccls_engine/templates/fixtures/subject_types.yml +30 -0
  128. data/generators/ccls_engine/templates/fixtures/tracing_statuses.yml +30 -0
  129. data/generators/ccls_engine/templates/fixtures/units.yml +13 -0
  130. data/generators/ccls_engine/templates/fixtures/vital_statuses.yml +28 -0
  131. data/generators/ccls_engine/templates/functional/roles_controller_test.rb +142 -0
  132. data/generators/ccls_engine/templates/functional/sessions_controller_test.rb +19 -0
  133. data/generators/ccls_engine/templates/functional/users_controller_test.rb +94 -0
  134. data/generators/ccls_engine/templates/images/sort_down.png +0 -0
  135. data/generators/ccls_engine/templates/images/sort_up.png +0 -0
  136. data/generators/ccls_engine/templates/initializer.rb +28 -0
  137. data/generators/ccls_engine/templates/javascripts/ccls_engine.js +24 -0
  138. data/generators/ccls_engine/templates/javascripts/jquery-ui.js +763 -0
  139. data/generators/ccls_engine/templates/javascripts/jquery.js +154 -0
  140. data/generators/ccls_engine/templates/javascripts/jrails.js +1 -0
  141. data/generators/ccls_engine/templates/migrations/create_user_invitations.rb +18 -0
  142. data/generators/ccls_engine/templates/migrations/create_users.rb +33 -0
  143. data/generators/ccls_engine/templates/migrations/drop_user_invitations.rb +18 -0
  144. data/generators/ccls_engine/templates/stylesheets/ccls_engine.css +180 -0
  145. data/generators/ccls_engine/templates/stylesheets/user.css +35 -0
  146. data/generators/ccls_engine/templates/stylesheets/users.css +23 -0
  147. data/generators/ccls_engine/templates/unit/core_extension_test.rb +18 -0
  148. data/generators/ccls_engine/templates/unit/role_test.rb +30 -0
  149. data/generators/ccls_engine/templates/unit/user_test.rb +321 -0
  150. data/lib/ccls-ccls_engine.rb +1 -0
  151. data/lib/ccls_engine.rb +135 -0
  152. data/lib/ccls_engine/action_view_extension.rb +3 -0
  153. data/lib/ccls_engine/action_view_extension/base.rb +53 -0
  154. data/lib/ccls_engine/action_view_extension/form_builder.rb +39 -0
  155. data/lib/ccls_engine/active_record_extension.rb +2 -0
  156. data/lib/ccls_engine/active_record_extension/base.rb +70 -0
  157. data/lib/ccls_engine/active_record_shared.rb +8 -0
  158. data/lib/ccls_engine/assertions.rb +69 -0
  159. data/lib/ccls_engine/autotest.rb +54 -0
  160. data/lib/ccls_engine/ccls_user.rb +117 -0
  161. data/lib/ccls_engine/core_extension.rb +14 -0
  162. data/lib/ccls_engine/date_and_time_formats.rb +30 -0
  163. data/lib/ccls_engine/factories.rb +880 -0
  164. data/lib/ccls_engine/factory_test_helper.rb +276 -0
  165. data/lib/ccls_engine/helper.rb +112 -0
  166. data/lib/ccls_engine/icf_master_tracker_update_test_helper.rb +121 -0
  167. data/lib/ccls_engine/live_birth_data_update_test_helper.rb +110 -0
  168. data/lib/ccls_engine/package_test_helper.rb +49 -0
  169. data/lib/ccls_engine/shared_database.rb +20 -0
  170. data/lib/ccls_engine/tasks.rb +1 -0
  171. data/lib/ccls_engine/test_tasks.rb +52 -0
  172. data/lib/ccls_engine/translation_table.rb +86 -0
  173. data/lib/shared_migration.rb +5 -0
  174. data/lib/surveyor/survey_extensions.rb +125 -0
  175. data/lib/tasks/application.rake +286 -0
  176. data/lib/tasks/calnet_authenticated.rake +6 -0
  177. data/lib/tasks/common_lib.rake +7 -0
  178. data/lib/tasks/database.rake +288 -0
  179. data/lib/tasks/documentation.rake +71 -0
  180. data/lib/tasks/homex_import.rake +723 -0
  181. data/lib/tasks/odms_import.rake +1116 -0
  182. data/lib/tasks/simply_authorized.rake +6 -0
  183. data/lib/tasks/ucb_ccls_engine_tasks.rake +4 -0
  184. data/lib/tasks/use_db.rake +4 -0
  185. data/rails/init.rb +4 -0
  186. data/test/unit/ccls/abstract_search_test.rb +150 -0
  187. data/test/unit/ccls/abstract_test.rb +674 -0
  188. data/test/unit/ccls/address_test.rb +155 -0
  189. data/test/unit/ccls/address_type_test.rb +25 -0
  190. data/test/unit/ccls/addressing_test.rb +466 -0
  191. data/test/unit/ccls/aliquot_sample_format_test.rb +20 -0
  192. data/test/unit/ccls/aliquot_test.rb +156 -0
  193. data/test/unit/ccls/analysis_test.rb +31 -0
  194. data/test/unit/ccls/bc_request_test.rb +43 -0
  195. data/test/unit/ccls/candidate_control_test.rb +712 -0
  196. data/test/unit/ccls/context_data_source_test.rb +26 -0
  197. data/test/unit/ccls/context_test.rb +40 -0
  198. data/test/unit/ccls/core_extension_test.rb +17 -0
  199. data/test/unit/ccls/county_test.rb +34 -0
  200. data/test/unit/ccls/data_source_test.rb +41 -0
  201. data/test/unit/ccls/diagnosis_test.rb +51 -0
  202. data/test/unit/ccls/document_type_test.rb +35 -0
  203. data/test/unit/ccls/document_version_test.rb +68 -0
  204. data/test/unit/ccls/enrollment_test.rb +575 -0
  205. data/test/unit/ccls/follow_up_test.rb +23 -0
  206. data/test/unit/ccls/follow_up_type_test.rb +34 -0
  207. data/test/unit/ccls/gift_card_search_test.rb +153 -0
  208. data/test/unit/ccls/gift_card_test.rb +40 -0
  209. data/test/unit/ccls/home_exposure_response_test.rb +83 -0
  210. data/test/unit/ccls/homex_outcome_test.rb +199 -0
  211. data/test/unit/ccls/hospital_test.rb +102 -0
  212. data/test/unit/ccls/icf_master_id_test.rb +30 -0
  213. data/test/unit/ccls/icf_master_tracker_change_test.rb +14 -0
  214. data/test/unit/ccls/icf_master_tracker_test.rb +132 -0
  215. data/test/unit/ccls/icf_master_tracker_update_test.rb +176 -0
  216. data/test/unit/ccls/ineligible_reason_test.rb +48 -0
  217. data/test/unit/ccls/instrument_test.rb +62 -0
  218. data/test/unit/ccls/instrument_type_test.rb +39 -0
  219. data/test/unit/ccls/instrument_version_test.rb +71 -0
  220. data/test/unit/ccls/interview_method_test.rb +44 -0
  221. data/test/unit/ccls/interview_outcome_test.rb +34 -0
  222. data/test/unit/ccls/interview_test.rb +298 -0
  223. data/test/unit/ccls/language_test.rb +47 -0
  224. data/test/unit/ccls/live_birth_data_update_test.rb +358 -0
  225. data/test/unit/ccls/operational_event_test.rb +187 -0
  226. data/test/unit/ccls/operational_event_type_test.rb +51 -0
  227. data/test/unit/ccls/organization_test.rb +64 -0
  228. data/test/unit/ccls/patient_test.rb +538 -0
  229. data/test/unit/ccls/person_test.rb +55 -0
  230. data/test/unit/ccls/phone_number_test.rb +244 -0
  231. data/test/unit/ccls/phone_type_test.rb +32 -0
  232. data/test/unit/ccls/project_outcome_test.rb +34 -0
  233. data/test/unit/ccls/project_test.rb +60 -0
  234. data/test/unit/ccls/race_test.rb +37 -0
  235. data/test/unit/ccls/refusal_reason_test.rb +52 -0
  236. data/test/unit/ccls/role_test.rb +26 -0
  237. data/test/unit/ccls/sample_kit_test.rb +35 -0
  238. data/test/unit/ccls/sample_outcome_test.rb +34 -0
  239. data/test/unit/ccls/sample_temperature_test.rb +25 -0
  240. data/test/unit/ccls/sample_test.rb +363 -0
  241. data/test/unit/ccls/sample_type_test.rb +58 -0
  242. data/test/unit/ccls/section_test.rb +34 -0
  243. data/test/unit/ccls/state_test.rb +31 -0
  244. data/test/unit/ccls/study_subject_abstracts_test.rb +115 -0
  245. data/test/unit/ccls/study_subject_addresses_test.rb +93 -0
  246. data/test/unit/ccls/study_subject_duplicates_test.rb +407 -0
  247. data/test/unit/ccls/study_subject_enrollments_test.rb +65 -0
  248. data/test/unit/ccls/study_subject_homex_outcome_test.rb +64 -0
  249. data/test/unit/ccls/study_subject_identifier_test.rb +439 -0
  250. data/test/unit/ccls/study_subject_interviews_test.rb +26 -0
  251. data/test/unit/ccls/study_subject_languages_test.rb +142 -0
  252. data/test/unit/ccls/study_subject_operational_events_test.rb +53 -0
  253. data/test/unit/ccls/study_subject_patient_test.rb +249 -0
  254. data/test/unit/ccls/study_subject_pii_test.rb +278 -0
  255. data/test/unit/ccls/study_subject_races_test.rb +203 -0
  256. data/test/unit/ccls/study_subject_search_test.rb +704 -0
  257. data/test/unit/ccls/study_subject_test.rb +770 -0
  258. data/test/unit/ccls/subject_language_test.rb +43 -0
  259. data/test/unit/ccls/subject_race_test.rb +35 -0
  260. data/test/unit/ccls/subject_relationship_test.rb +43 -0
  261. data/test/unit/ccls/subject_type_test.rb +40 -0
  262. data/test/unit/ccls/tracing_status_test.rb +32 -0
  263. data/test/unit/ccls/transfer_test.rb +81 -0
  264. data/test/unit/ccls/translation_table_test.rb +40 -0
  265. data/test/unit/ccls/unit_test.rb +21 -0
  266. data/test/unit/ccls/user_test.rb +156 -0
  267. data/test/unit/ccls/vital_status_test.rb +36 -0
  268. data/test/unit/ccls/zip_code_test.rb +55 -0
  269. metadata +633 -0
@@ -0,0 +1,704 @@
1
+ require 'test_helper'
2
+
3
+ class Ccls::StudySubjectSearchTest < ActiveSupport::TestCase
4
+
5
+ test "should return StudySubjectSearch" do
6
+ assert StudySubjectSearch().is_a?(StudySubjectSearch)
7
+ end
8
+
9
+ test "should respond to search" do
10
+ assert StudySubject.respond_to?(:search)
11
+ end
12
+
13
+ test "should return Array" do
14
+ study_subjects = StudySubject.search()
15
+ assert study_subjects.is_a?(Array)
16
+ end
17
+
18
+ test "should include study_subject" do
19
+ study_subject = create_study_subject
20
+ study_subjects = StudySubject.search()
21
+ assert study_subjects.include?(study_subject)
22
+ end
23
+
24
+ test "should include study_subject without pagination" do
25
+ study_subject = create_study_subject
26
+ study_subjects = StudySubject.search(:paginate => false)
27
+ assert study_subjects.include?(study_subject)
28
+ end
29
+
30
+ test "should include study_subject by subject_types" do
31
+ s1,s2,s3 = create_study_subjects(3)
32
+ study_subjects = StudySubject.search(
33
+ :types => [s1,s2].collect{|s|s.subject_type.description})
34
+ assert study_subjects.include?(s1)
35
+ assert study_subjects.include?(s2)
36
+ assert !study_subjects.include?(s3)
37
+ end
38
+
39
+ test "should include study_subject by races" do
40
+ s1,s2,s3 = nil
41
+ assert_difference('StudySubject.count',3) do
42
+ s1,s2,s3 = create_study_subjects_with_races(3)
43
+ end
44
+ study_subjects = StudySubject.search(
45
+ :races => [s1,s2].collect{|s|s.races.first.name})
46
+ assert study_subjects.include?(s1)
47
+ assert study_subjects.include?(s2)
48
+ assert !study_subjects.include?(s3)
49
+ end
50
+
51
+ # Don't think that this'll need to be searchable
52
+ # test "should include study_subject by hispanicity" do
53
+ # s1,s2,s3 = create_study_subjects(3)
54
+ #pending
55
+ # study_subjects = StudySubject.search(
56
+ # :races => [s1,s2].collect{|s|s.race.name})
57
+ # assert study_subjects.include?(s1)
58
+ # assert study_subjects.include?(s2)
59
+ # assert !study_subjects.include?(s3)
60
+ # end
61
+
62
+ test "should include study_subject by vital_statuses" do
63
+ s1,s2,s3 = create_study_subjects(3)
64
+ study_subjects = StudySubject.search(
65
+ :vital_statuses => [s1,s2].collect{|s|s.vital_status.key})
66
+ assert study_subjects.include?(s1)
67
+ assert study_subjects.include?(s2)
68
+ assert !study_subjects.include?(s3)
69
+ end
70
+
71
+ # test "should include all study_subjects and ignore dust kits" do
72
+ # subject1 = create_study_subject
73
+ # dust_kit = create_dust_kit(:study_subject_id => subject1.id)
74
+ # subject2 = create_study_subject
75
+ # study_subjects = StudySubject.search(:dust_kit => 'ignore')
76
+ # assert study_subjects.include?(subject1)
77
+ # assert study_subjects.include?(subject2)
78
+ # end
79
+
80
+ # test "should include study_subjects with no dust kits" do
81
+ # subject1 = create_study_subject
82
+ # dust_kit = create_dust_kit(:study_subject_id => subject1.id)
83
+ # subject2 = create_study_subject
84
+ # study_subjects = StudySubject.search(:dust_kit => 'none')
85
+ # assert study_subjects.include?(subject2)
86
+ # assert !study_subjects.include?(subject1)
87
+ # end
88
+
89
+ # test "should include study_subject with dust kit" do
90
+ # subject1 = create_study_subject
91
+ # dust_kit = create_dust_kit(:study_subject_id => subject1.id)
92
+ # subject2 = create_study_subject
93
+ # study_subjects = StudySubject.search(:dust_kit => 'shipped')
94
+ # assert study_subjects.include?(subject1)
95
+ # assert !study_subjects.include?(subject2)
96
+ # end
97
+
98
+ # test "should include study_subject with dust kit delivered to study_subject" do
99
+ # subject1 = create_study_subject
100
+ # dust_kit = create_dust_kit(:study_subject_id => subject1.id)
101
+ # dust_kit.kit_package.update_attributes(:status => 'Delivered')
102
+ # subject2 = create_study_subject
103
+ # create_dust_kit(:study_subject_id => subject2.id)
104
+ # study_subjects = StudySubject.search(:dust_kit => 'delivered')
105
+ # assert study_subjects.include?(subject1)
106
+ # assert !study_subjects.include?(subject2)
107
+ # end
108
+
109
+ # test "should include study_subject with dust kit returned to us" do
110
+ # subject1 = create_study_subject
111
+ # dust_kit = create_dust_kit(:study_subject_id => subject1.id)
112
+ # dust_kit.dust_package.update_attributes(:status => 'Transit')
113
+ # subject2 = create_study_subject
114
+ # create_dust_kit(:study_subject_id => subject2.id)
115
+ # study_subjects = StudySubject.search(:dust_kit => 'returned')
116
+ # assert study_subjects.include?(subject1)
117
+ # assert !study_subjects.include?(subject2)
118
+ # end
119
+
120
+ # test "should include study_subject with dust kit received by us" do
121
+ # subject1 = create_study_subject
122
+ # dust_kit = create_dust_kit(:study_subject_id => subject1.id)
123
+ # dust_kit.dust_package.update_attributes(:status => 'Delivered')
124
+ # subject2 = create_study_subject
125
+ # create_dust_kit(:study_subject_id => subject2.id)
126
+ # study_subjects = StudySubject.search(:dust_kit => 'received')
127
+ # assert study_subjects.include?(subject1)
128
+ # assert !study_subjects.include?(subject2)
129
+ # end
130
+
131
+ # # There was a problem doing finds which included joins
132
+ # # which included both named joins and sql fragment strings.
133
+ # # It should work, but didn't and required some manual
134
+ # # tweaking.
135
+ # test "should work with both dust_kit string and race symbol" do
136
+ # subject1 = create_study_subject
137
+ # dust_kit = create_dust_kit(:study_subject_id => subject1.id)
138
+ # subject2 = create_study_subject
139
+ # study_subjects = StudySubject.search(:dust_kit => 'none',
140
+ # :races => [subject2.race.name] )
141
+ # assert study_subjects.include?(subject2)
142
+ # assert !study_subjects.include?(subject1)
143
+ # end
144
+
145
+ test "should include study_subject by having project" do
146
+ e1 = Factory(:enrollment)
147
+ e2 = Factory(:enrollment)
148
+ study_subjects = StudySubject.search(
149
+ :projects => {e1.project.id => ''})
150
+ assert study_subjects.include?(e1.study_subject)
151
+ assert !study_subjects.include?(e2.study_subject)
152
+ end
153
+
154
+ test "should include study_subject by multiple projects" do
155
+ e1 = Factory(:enrollment)
156
+ e2 = Factory(:enrollment,:study_subject => e1.study_subject)
157
+ e3 = Factory(:enrollment,:project => e2.project)
158
+ study_subjects = StudySubject.search(:projects => {
159
+ e1.project.id => '',
160
+ e2.project.id => ''
161
+ })
162
+ assert study_subjects.include?(e1.study_subject)
163
+ assert !study_subjects.include?(e3.study_subject)
164
+ end
165
+
166
+ test "should include study_subject by project indifferent completed" do
167
+ e1 = Factory(:enrollment, :completed_on => nil,
168
+ :is_complete => YNDK[:no])
169
+ e2 = Factory(:enrollment, :completed_on => Time.now,
170
+ :is_complete => YNDK[:yes],
171
+ :project => e1.project )
172
+ study_subjects = StudySubject.search(:projects => {
173
+ e1.project.id => { :completed => [true,false] }
174
+ })
175
+ assert study_subjects.include?(e1.study_subject)
176
+ assert study_subjects.include?(e2.study_subject)
177
+ end
178
+
179
+ test "should include study_subject by project not completed" do
180
+ e1 = Factory(:enrollment, :completed_on => nil,
181
+ :is_complete => YNDK[:no])
182
+ e2 = Factory(:enrollment, :completed_on => Time.now,
183
+ :is_complete => YNDK[:yes],
184
+ :project => e1.project )
185
+ study_subjects = StudySubject.search(:projects => {
186
+ e1.project.id => { :completed => false }
187
+ })
188
+ assert study_subjects.include?(e1.study_subject)
189
+ assert !study_subjects.include?(e2.study_subject)
190
+ end
191
+
192
+ test "should include study_subject by project is completed" do
193
+ e1 = Factory(:enrollment, :completed_on => nil,
194
+ :is_complete => YNDK[:no])
195
+ e2 = Factory(:enrollment, :completed_on => Time.now,
196
+ :is_complete => YNDK[:yes],
197
+ :project => e1.project )
198
+ study_subjects = StudySubject.search(:projects => {
199
+ e1.project.id => { :completed => true }
200
+ })
201
+ assert !study_subjects.include?(e1.study_subject)
202
+ assert study_subjects.include?(e2.study_subject)
203
+ end
204
+
205
+ test "should include study_subject by project indifferent closed" do
206
+ e1 = Factory(:enrollment, :is_closed => false)
207
+ e2 = Factory(:enrollment, :is_closed => true,
208
+ :project => e1.project )
209
+ study_subjects = StudySubject.search(:projects => {
210
+ e1.project.id => { :closed => [true,false] }
211
+ })
212
+ assert study_subjects.include?(e1.study_subject)
213
+ assert study_subjects.include?(e2.study_subject)
214
+ end
215
+
216
+ test "should include study_subject by project not closed" do
217
+ e1 = Factory(:enrollment, :is_closed => false)
218
+ e2 = Factory(:enrollment, :is_closed => true,
219
+ :project => e1.project )
220
+ study_subjects = StudySubject.search(:projects => {
221
+ e1.project.id => { :closed => false }
222
+ })
223
+ assert study_subjects.include?(e1.study_subject)
224
+ assert !study_subjects.include?(e2.study_subject)
225
+ end
226
+
227
+ test "should include study_subject by project is closed" do
228
+ e1 = Factory(:enrollment, :is_closed => false)
229
+ e2 = Factory(:enrollment, :is_closed => true,
230
+ :project => e1.project )
231
+ study_subjects = StudySubject.search(:projects => {
232
+ e1.project.id => { :closed => true }
233
+ })
234
+ assert !study_subjects.include?(e1.study_subject)
235
+ assert study_subjects.include?(e2.study_subject)
236
+ end
237
+
238
+ test "should include study_subject by project indifferent terminated" do
239
+ e1 = Factory(:enrollment, :terminated_participation => YNDK[:no])
240
+ e2 = Factory(:enrollment, :terminated_participation => YNDK[:yes],
241
+ :terminated_reason => 'unknown',
242
+ :project => e1.project )
243
+ study_subjects = StudySubject.search(:projects => {
244
+ e1.project.id => { :terminated => [true,false] }
245
+ })
246
+ assert study_subjects.include?(e1.study_subject)
247
+ assert study_subjects.include?(e2.study_subject)
248
+ end
249
+
250
+ test "should include study_subject by project not terminated" do
251
+ e1 = Factory(:enrollment, :terminated_participation => YNDK[:no])
252
+ e2 = Factory(:enrollment, :terminated_participation => YNDK[:yes],
253
+ :terminated_reason => 'unknown',
254
+ :project => e1.project )
255
+ study_subjects = StudySubject.search(:projects => {
256
+ e1.project.id => { :terminated => false }
257
+ })
258
+ assert study_subjects.include?(e1.study_subject)
259
+ assert !study_subjects.include?(e2.study_subject)
260
+ end
261
+
262
+ test "should include study_subject by project is terminated" do
263
+ e1 = Factory(:enrollment, :terminated_participation => YNDK[:no])
264
+ e2 = Factory(:enrollment, :terminated_participation => YNDK[:yes],
265
+ :terminated_reason => 'unknown',
266
+ :project => e1.project )
267
+ study_subjects = StudySubject.search(:projects => {
268
+ e1.project.id => { :terminated => true }
269
+ })
270
+ assert !study_subjects.include?(e1.study_subject)
271
+ assert study_subjects.include?(e2.study_subject)
272
+ end
273
+
274
+ test "should include study_subject by project indifferent consented" do
275
+ e1 = Factory(:consented_enrollment, :consented => YNDK[:no],
276
+ :refusal_reason_id => RefusalReason.first.id)
277
+ e2 = Factory(:consented_enrollment, :consented => YNDK[:yes],
278
+ :project => e1.project )
279
+ study_subjects = StudySubject.search(:projects => {
280
+ e1.project.id => { :consented => [true,false] }
281
+ })
282
+ assert study_subjects.include?(e1.study_subject)
283
+ assert study_subjects.include?(e2.study_subject)
284
+ end
285
+
286
+ test "should include study_subject by project not consented" do
287
+ e1 = Factory(:consented_enrollment, :consented => YNDK[:no],
288
+ :refusal_reason_id => RefusalReason.first.id)
289
+ e2 = Factory(:consented_enrollment, :consented => YNDK[:yes],
290
+ :project => e1.project )
291
+ study_subjects = StudySubject.search(:projects => {
292
+ e1.project.id => { :consented => YNDK[:no] }
293
+ })
294
+ assert study_subjects.include?(e1.study_subject)
295
+ assert !study_subjects.include?(e2.study_subject)
296
+ end
297
+
298
+ test "should include study_subject by project is consented" do
299
+ e1 = Factory(:consented_enrollment, :consented => YNDK[:no],
300
+ :refusal_reason_id => RefusalReason.first.id)
301
+ e2 = Factory(:consented_enrollment, :consented => YNDK[:yes],
302
+ :project => e1.project )
303
+ study_subjects = StudySubject.search(:projects => {
304
+ e1.project.id => { :consented => true }
305
+ })
306
+ assert !study_subjects.include?(e1.study_subject)
307
+ assert study_subjects.include?(e2.study_subject)
308
+ end
309
+
310
+ test "should include study_subject by project indifferent candidate" do
311
+ e1 = Factory(:enrollment, :is_candidate => YNDK[:no])
312
+ e2 = Factory(:enrollment, :is_candidate => YNDK[:yes],
313
+ :project => e1.project )
314
+ study_subjects = StudySubject.search(:projects => {
315
+ e1.project.id => { :candidate => [true,false] }
316
+ })
317
+ assert study_subjects.include?(e1.study_subject)
318
+ assert study_subjects.include?(e2.study_subject)
319
+ end
320
+
321
+ test "should include study_subject by project not candidate" do
322
+ e1 = Factory(:enrollment, :is_candidate => YNDK[:no])
323
+ e2 = Factory(:enrollment, :is_candidate => YNDK[:yes],
324
+ :project => e1.project )
325
+ study_subjects = StudySubject.search(:projects => {
326
+ e1.project.id => { :candidate => false }
327
+ })
328
+ assert study_subjects.include?(e1.study_subject)
329
+ assert !study_subjects.include?(e2.study_subject)
330
+ end
331
+
332
+ test "should include study_subject by project is candidate" do
333
+ e1 = Factory(:enrollment, :is_candidate => YNDK[:no])
334
+ e2 = Factory(:enrollment, :is_candidate => YNDK[:yes],
335
+ :project => e1.project )
336
+ study_subjects = StudySubject.search(:projects => {
337
+ e1.project.id => { :candidate => true }
338
+ })
339
+ assert !study_subjects.include?(e1.study_subject)
340
+ assert study_subjects.include?(e2.study_subject)
341
+ end
342
+
343
+ test "should include study_subject by project indifferent chosen" do
344
+ e1 = Factory(:enrollment, :is_chosen => YNDK[:no],
345
+ :reason_not_chosen => 'unknown')
346
+ e2 = Factory(:enrollment, :is_chosen => YNDK[:yes],
347
+ :project => e1.project )
348
+ study_subjects = StudySubject.search(:projects => {
349
+ e1.project.id => { :chosen => [true,false] }
350
+ })
351
+ assert study_subjects.include?(e1.study_subject)
352
+ assert study_subjects.include?(e2.study_subject)
353
+ end
354
+
355
+ test "should include study_subject by project not chosen" do
356
+ e1 = Factory(:enrollment, :is_chosen => YNDK[:no],
357
+ :reason_not_chosen => 'unknown')
358
+ e2 = Factory(:enrollment, :is_chosen => YNDK[:yes],
359
+ :project => e1.project )
360
+ study_subjects = StudySubject.search(:projects => {
361
+ e1.project.id => { :chosen => false }
362
+ })
363
+ assert study_subjects.include?(e1.study_subject)
364
+ assert !study_subjects.include?(e2.study_subject)
365
+ end
366
+
367
+ test "should include study_subject by project is chosen" do
368
+ e1 = Factory(:enrollment, :is_chosen => YNDK[:no],
369
+ :reason_not_chosen => 'unknown')
370
+ e2 = Factory(:enrollment, :is_chosen => YNDK[:yes],
371
+ :project => e1.project )
372
+ study_subjects = StudySubject.search(:projects => {
373
+ e1.project.id => { :chosen => true }
374
+ })
375
+ assert !study_subjects.include?(e1.study_subject)
376
+ assert study_subjects.include?(e2.study_subject)
377
+ end
378
+
379
+ test "should include study_subject by project indifferent eligible" do
380
+ e1 = Factory(:enrollment, :is_eligible => YNDK[:no],
381
+ :ineligible_reason_id => IneligibleReason.first.id)
382
+ e2 = Factory(:enrollment, :is_eligible => YNDK[:yes],
383
+ :project => e1.project )
384
+ study_subjects = StudySubject.search(:projects => {
385
+ e1.project.id => { :eligible => [true,false] }
386
+ })
387
+ assert study_subjects.include?(e1.study_subject)
388
+ assert study_subjects.include?(e2.study_subject)
389
+ end
390
+
391
+ test "should include study_subject by project not eligible" do
392
+ e1 = Factory(:enrollment, :is_eligible => YNDK[:no],
393
+ :ineligible_reason_id => IneligibleReason.first.id)
394
+ e2 = Factory(:enrollment, :is_eligible => YNDK[:yes],
395
+ :project => e1.project )
396
+ study_subjects = StudySubject.search(:projects => {
397
+ e1.project.id => { :eligible => false }
398
+ })
399
+ assert study_subjects.include?(e1.study_subject)
400
+ assert !study_subjects.include?(e2.study_subject)
401
+ end
402
+
403
+ test "should include study_subject by project is eligible" do
404
+ e1 = Factory(:enrollment, :is_eligible => YNDK[:no],
405
+ :ineligible_reason_id => IneligibleReason.first.id)
406
+ e2 = Factory(:enrollment, :is_eligible => YNDK[:yes],
407
+ :project => e1.project )
408
+ study_subjects = StudySubject.search(:projects => {
409
+ e1.project.id => { :eligible => true }
410
+ })
411
+ assert !study_subjects.include?(e1.study_subject)
412
+ assert study_subjects.include?(e2.study_subject)
413
+ end
414
+
415
+ test "should include study_subject by complete patid" do
416
+ s1,s2,s3 = create_study_subjects_with_patids(1234,5678,9)
417
+ study_subjects = StudySubject.search(:patid => 5678)
418
+ assert !study_subjects.include?(s1)
419
+ assert study_subjects.include?(s2)
420
+ assert !study_subjects.include?(s3)
421
+ end
422
+
423
+ test "should NOT order by bogus column with dir" do
424
+ s1,s2,s3 = create_study_subjects(3)
425
+ study_subjects = StudySubject.search(
426
+ :order => 'whatever', :dir => 'asc')
427
+ assert_equal [s1,s2,s3], study_subjects
428
+ end
429
+
430
+ test "should NOT order by bogus column" do
431
+ s1,s2,s3 = create_study_subjects(3)
432
+ study_subjects = StudySubject.search(:order => 'whatever')
433
+ assert_equal [s1,s2,s3], study_subjects
434
+ end
435
+
436
+ test "should order by priority asc by default" do
437
+ project,s1,s2,s3 = create_study_subjects_with_recruitment_priorities(9,3,6)
438
+ study_subjects = StudySubject.search(:order => 'priority',
439
+ :projects=>{ project.id => {} })
440
+ assert_equal [s2,s3,s1], study_subjects
441
+ end
442
+
443
+ test "should order by priority asc" do
444
+ project,s1,s2,s3 = create_study_subjects_with_recruitment_priorities(9,3,6)
445
+ study_subjects = StudySubject.search(:order => 'priority',
446
+ :dir => 'asc',
447
+ :projects=>{ project.id => {} })
448
+ assert_equal [s2,s3,s1], study_subjects
449
+ end
450
+
451
+ test "should order by priority desc" do
452
+ project,s1,s2,s3 = create_study_subjects_with_recruitment_priorities(9,3,6)
453
+ study_subjects = StudySubject.search(:order => 'priority',:dir => 'desc',
454
+ :projects=>{ project.id => {} })
455
+ assert_equal [s1,s3,s2], study_subjects
456
+ end
457
+
458
+ test "should order by id asc by default" do
459
+ s1,s2,s3 = create_study_subjects_with_childids(9,3,6)
460
+ study_subjects = StudySubject.search(
461
+ :order => 'id')
462
+ assert_equal [s1,s2,s3], study_subjects
463
+ end
464
+
465
+ test "should order by id asc" do
466
+ s1,s2,s3 = create_study_subjects_with_childids(9,3,6)
467
+ study_subjects = StudySubject.search(
468
+ :order => 'id', :dir => 'asc')
469
+ assert_equal [s1,s2,s3], study_subjects
470
+ end
471
+
472
+ test "should order by id desc" do
473
+ s1,s2,s3 = create_study_subjects_with_childids(9,3,6)
474
+ study_subjects = StudySubject.search(
475
+ :order => 'id', :dir => 'desc')
476
+ assert_equal [s3,s2,s1], study_subjects
477
+ end
478
+
479
+
480
+ # TODO put these back if necessary
481
+ # sent_to_subject_on received_by_ccls_at
482
+ # will need a rather complex join added though.
483
+
484
+ %w( childid patid studyid dob first_name last_name
485
+ sample_outcome interview_outcome_on
486
+ sample_outcome_on
487
+ ).each do |column|
488
+ test "should order by #{column} asc by default" do
489
+ s1,s2,s3 = send("three_study_subjects_with_#{column}")
490
+ study_subjects = StudySubject.search(:order => column)
491
+ assert_equal 3, study_subjects.length
492
+ assert_equal [s2,s3,s1], study_subjects
493
+ end
494
+
495
+ test "should order by #{column} asc" do
496
+ s1,s2,s3 = send("three_study_subjects_with_#{column}")
497
+ study_subjects = StudySubject.search(:order => column, :dir => 'asc')
498
+ assert_equal 3, study_subjects.length
499
+ assert_equal [s2,s3,s1], study_subjects
500
+ end
501
+
502
+ test "should order by #{column} desc" do
503
+ s1,s2,s3 = send("three_study_subjects_with_#{column}")
504
+ study_subjects = StudySubject.search(:order => column, :dir => 'desc')
505
+ assert_equal 3, study_subjects.length
506
+ assert_equal [s1,s3,s2], study_subjects
507
+ end
508
+ end
509
+
510
+ # # There was a problem doing finds which included joins
511
+ # # which included both sql join fragment strings and an order.
512
+ # test "should work with both dust_kit string and order" do
513
+ # subject1 = create_study_subject
514
+ # dust_kit = create_dust_kit(:study_subject_id => subject1.id)
515
+ # subject2 = create_study_subject
516
+ # study_subjects = StudySubject.search(:dust_kit => 'none',
517
+ # :order => 'childid')
518
+ # assert study_subjects.include?(subject2)
519
+ # assert !study_subjects.include?(subject1)
520
+ # end
521
+
522
+ test "should include study_subject by q first_name" do
523
+ s1,s2 = create_study_subjects_with_first_names('Michael','Bob')
524
+ study_subjects = StudySubject.search(:q => 'mi ch ha')
525
+ assert study_subjects.include?(s1)
526
+ assert !study_subjects.include?(s2)
527
+ end
528
+
529
+ test "should include study_subject by q last_name" do
530
+ s1,s2 = create_study_subjects_with_last_names('Michael','Bob')
531
+ study_subjects = StudySubject.search(:q => 'cha ael')
532
+ assert study_subjects.include?(s1)
533
+ assert !study_subjects.include?(s2)
534
+ end
535
+
536
+ test "should include study_subject by q childid" do
537
+ s1,s2 = create_study_subjects_with_childids(999999,'1')
538
+ study_subjects = StudySubject.search(:q => s1.childid)
539
+ assert study_subjects.include?(s1)
540
+ assert !study_subjects.include?(s2)
541
+ end
542
+
543
+ test "should include study_subject by q patid" do
544
+ s1,s2 = create_study_subjects_with_patids(999999,'1')
545
+ study_subjects = StudySubject.search(:q => s1.reload.patid)
546
+ assert study_subjects.include?(s1)
547
+ assert !study_subjects.include?(s2)
548
+ end
549
+
550
+ test "should include study_subject by q gift_card" do
551
+ s1,s2 = create_study_subjects_with_gift_card_numbers('9999','1111')
552
+ study_subjects = StudySubject.search(:q => s1.gift_cards.first.number,
553
+ :search_gift_cards => true)
554
+ assert study_subjects.include?(s1)
555
+ assert !study_subjects.include?(s2)
556
+ end
557
+
558
+ test "should include study_subject by has_gift_card == true" do
559
+ s1 = create_study_subject_with_gift_card_number('9999')
560
+ s2 = create_study_subject
561
+ study_subjects = StudySubject.search(:has_gift_card => true,
562
+ :search_gift_cards => true)
563
+ assert study_subjects.include?(s1)
564
+ assert !study_subjects.include?(s2)
565
+ end
566
+
567
+ test "should include study_subject by has_gift_card == false" do
568
+ s1 = create_study_subject_with_gift_card_number('9999')
569
+ s2 = create_study_subject
570
+ study_subjects = StudySubject.search(:has_gift_card => false,
571
+ :search_gift_cards => true)
572
+ assert !study_subjects.include?(s1)
573
+ assert study_subjects.include?(s2)
574
+ end
575
+
576
+ # test "should return dust_kit_status of None" do
577
+ # study_subject = create_study_subject
578
+ # assert_equal 'None', study_subject.dust_kit_status
579
+ # end
580
+
581
+ # test "should return dust_kit_status of New" do
582
+ # study_subject = create_study_subject
583
+ # dust_kit = create_dust_kit(:study_subject_id => study_subject.id)
584
+ # assert_equal 'New', study_subject.dust_kit_status
585
+ # end
586
+
587
+ test "should include study_subjects with complete sample" do
588
+ s1 = create_hx_study_subject
589
+ s1.create_homex_outcome(
590
+ :sample_outcome_on => Date.today,
591
+ :sample_outcome => SampleOutcome['Complete'])
592
+ s2 = create_study_subject
593
+ s2.create_homex_outcome(
594
+ :sample_outcome_on => Date.today,
595
+ :sample_outcome => SampleOutcome['Pending'])
596
+ s3 = create_study_subject
597
+ study_subjects = StudySubject.search(:sample_outcome => 'Complete')
598
+ assert study_subjects.include?(s1)
599
+ assert !study_subjects.include?(s2)
600
+ assert !study_subjects.include?(s3)
601
+ end
602
+
603
+ test "should include study_subjects with incomplete sample" do
604
+ s1 = create_hx_study_subject
605
+ s1.create_homex_outcome(
606
+ :sample_outcome_on => Date.today,
607
+ :sample_outcome => SampleOutcome['Complete'])
608
+ s2 = create_study_subject
609
+ s2.create_homex_outcome(
610
+ :sample_outcome_on => Date.today,
611
+ :sample_outcome => SampleOutcome['Pending'])
612
+ s3 = create_study_subject
613
+ study_subjects = StudySubject.search(:sample_outcome => 'Incomplete')
614
+ assert !study_subjects.include?(s1)
615
+ assert study_subjects.include?(s2)
616
+ assert study_subjects.include?(s3)
617
+ end
618
+
619
+ test "should include study_subjects with complete interview" do
620
+ s1 = create_hx_study_subject
621
+ s1.create_homex_outcome(
622
+ :interview_outcome_on => Date.today,
623
+ :interview_outcome => InterviewOutcome['Complete'])
624
+ s2 = create_study_subject
625
+ s2.create_homex_outcome(
626
+ :interview_outcome_on => Date.today,
627
+ :interview_outcome => InterviewOutcome['Incomplete'])
628
+ s3 = create_study_subject
629
+ study_subjects = StudySubject.search(:interview_outcome => 'Complete')
630
+ assert study_subjects.include?(s1)
631
+ assert !study_subjects.include?(s2)
632
+ assert !study_subjects.include?(s3)
633
+ end
634
+
635
+ test "should include study_subjects with incomplete interview" do
636
+ s1 = create_hx_study_subject
637
+ s1.create_homex_outcome(
638
+ :interview_outcome_on => Date.today,
639
+ :interview_outcome => InterviewOutcome['Complete'])
640
+ s2 = create_study_subject
641
+ s2.create_homex_outcome(
642
+ :interview_outcome_on => Date.today,
643
+ :interview_outcome => InterviewOutcome['Incomplete'])
644
+ s3 = create_study_subject
645
+ study_subjects = StudySubject.search(:interview_outcome => 'Incomplete')
646
+ assert !study_subjects.include?(s1)
647
+ assert study_subjects.include?(s2)
648
+ assert study_subjects.include?(s3)
649
+ end
650
+
651
+
652
+
653
+
654
+ test "should include study_subjects by abstracts_count = 0" do
655
+ s1 = Factory(:case_study_subject)
656
+ assert_equal 0, s1.abstracts_count
657
+ s2 = Factory(:study_subject)
658
+ assert_equal 0, s2.abstracts_count
659
+ study_subjects = StudySubject.search(:abstracts_count => 0, :types => 'Case')
660
+ assert study_subjects.include?(s1)
661
+ assert !study_subjects.include?(s2)
662
+ end
663
+
664
+ test "should include study_subjects by abstracts_count = 1" do
665
+ s1 = Factory(:case_study_subject)
666
+ assert_equal 0, s1.abstracts_count
667
+ Factory(:abstract, :study_subject => s1)
668
+ assert_equal 1, s1.reload.abstracts_count
669
+ s2 = Factory(:case_study_subject)
670
+ assert_equal 0, s2.abstracts_count
671
+ study_subjects = StudySubject.search(:abstracts_count => 1, :types => 'Case')
672
+ assert study_subjects.include?(s1)
673
+ assert !study_subjects.include?(s2)
674
+ end
675
+
676
+ test "should include study_subjects by abstracts_count = 2" do
677
+ s1 = Factory(:case_study_subject)
678
+ assert_equal 0, s1.abstracts_count
679
+ Factory(:abstract, :study_subject => s1)
680
+ assert_equal 1, s1.reload.abstracts_count
681
+ Factory(:abstract, :study_subject => s1)
682
+ assert_equal 2, s1.reload.abstracts_count
683
+ s2 = Factory(:case_study_subject)
684
+ assert_equal 0, s2.abstracts_count
685
+ Factory(:abstract, :study_subject => s2)
686
+ assert_equal 1, s2.reload.abstracts_count
687
+ study_subjects = StudySubject.search(:abstracts_count => 2, :types => 'Case')
688
+ assert study_subjects.include?(s1)
689
+ assert !study_subjects.include?(s2)
690
+ end
691
+
692
+
693
+
694
+ protected
695
+
696
+ # def create_survey_response_sets
697
+ # survey = Survey.find_by_access_code("home_exposure_survey")
698
+ # rs1 = fill_out_survey(:survey => survey)
699
+ # rs2 = fill_out_survey(:survey => survey,
700
+ # :study_subject => rs1.study_subject)
701
+ # [rs1.reload,rs2.reload]
702
+ # end
703
+
704
+ end