renalware-core 2.0.0.pre.beta6 → 2.0.0.pre.beta7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (199) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +20 -0
  3. data/lib/renalware/version.rb +1 -1
  4. data/spec/factories/accesses/patients.rb +3 -0
  5. data/spec/factories/accesses/plans.rb +11 -0
  6. data/spec/factories/accesses/plans_types.rb +5 -0
  7. data/spec/factories/accesses/procedures.rb +7 -0
  8. data/spec/factories/accesses/profiles.rb +14 -0
  9. data/spec/factories/accesses/sites.rb +6 -0
  10. data/spec/factories/accesses/types.rb +8 -0
  11. data/spec/factories/clinical/allergies.rb +7 -0
  12. data/spec/factories/clinical/body_compositions.rb +23 -0
  13. data/spec/factories/clinical/dry_weights.rb +11 -0
  14. data/spec/factories/clinical/patients.rb +3 -0
  15. data/spec/factories/clinics/appointments.rb +8 -0
  16. data/spec/factories/clinics/clinic_visits.rb +16 -0
  17. data/spec/factories/clinics/clinics.rb +6 -0
  18. data/spec/factories/deaths/cause.rb +6 -0
  19. data/spec/factories/deaths/modality_descriptions.rb +5 -0
  20. data/spec/factories/directory/people.rb +9 -0
  21. data/spec/factories/drugs/drug.rb +5 -0
  22. data/spec/factories/drugs/drug_types.rb +6 -0
  23. data/spec/factories/events/events.rb +26 -0
  24. data/spec/factories/events/events_types.rb +16 -0
  25. data/spec/factories/hd/cannulation_types.rb +5 -0
  26. data/spec/factories/hd/dialysers.rb +6 -0
  27. data/spec/factories/hd/hd_session_document.rb +69 -0
  28. data/spec/factories/hd/modality_descriptions.rb +5 -0
  29. data/spec/factories/hd/patient_statistics.rb +8 -0
  30. data/spec/factories/hd/patients.rb +3 -0
  31. data/spec/factories/hd/preference_sets.rb +10 -0
  32. data/spec/factories/hd/profiles.rb +18 -0
  33. data/spec/factories/hd/sessions.rb +34 -0
  34. data/spec/factories/hd/stations.rb +5 -0
  35. data/spec/factories/hospitals/centres.rb +6 -0
  36. data/spec/factories/hospitals/units.rb +15 -0
  37. data/spec/factories/letters/archives.rb +5 -0
  38. data/spec/factories/letters/contact_descriptions.rb +16 -0
  39. data/spec/factories/letters/contacts.rb +5 -0
  40. data/spec/factories/letters/descriptions.rb +5 -0
  41. data/spec/factories/letters/letterheads.rb +10 -0
  42. data/spec/factories/letters/letters.rb +25 -0
  43. data/spec/factories/letters/patients.rb +3 -0
  44. data/spec/factories/letters/primary_care_physicians.rb +5 -0
  45. data/spec/factories/letters/recipients.rb +11 -0
  46. data/spec/factories/medications/medication_route.rb +11 -0
  47. data/spec/factories/medications/prescription.rb +17 -0
  48. data/spec/factories/medications/prescription_terminations.rb +7 -0
  49. data/spec/factories/medications/prescription_version.rb +4 -0
  50. data/spec/factories/messaging/authors.rb +5 -0
  51. data/spec/factories/messaging/message.rb +11 -0
  52. data/spec/factories/messaging/patients.rb +5 -0
  53. data/spec/factories/messaging/receipt.rb +7 -0
  54. data/spec/factories/messaging/recipients.rb +5 -0
  55. data/spec/factories/modalities/modalities.rb +27 -0
  56. data/spec/factories/modalities/modality_descriptions.rb +34 -0
  57. data/spec/factories/modalities/modality_reasons.rb +20 -0
  58. data/spec/factories/pathology/consultant.rb +3 -0
  59. data/spec/factories/pathology/lab.rb +5 -0
  60. data/spec/factories/pathology/measurement_units.rb +8 -0
  61. data/spec/factories/pathology/observation_descriptions.rb +7 -0
  62. data/spec/factories/pathology/observation_requests.rb +8 -0
  63. data/spec/factories/pathology/observations.rb +8 -0
  64. data/spec/factories/pathology/patients.rb +3 -0
  65. data/spec/factories/pathology/request_descriptions.rb +6 -0
  66. data/spec/factories/pathology/requests/drug_category.rb +6 -0
  67. data/spec/factories/pathology/requests/global_rule.rb +7 -0
  68. data/spec/factories/pathology/requests/global_rule_set.rb +6 -0
  69. data/spec/factories/pathology/requests/patient_rule.rb +13 -0
  70. data/spec/factories/pathology/requests/request.rb +10 -0
  71. data/spec/factories/patients/alerts.rb +8 -0
  72. data/spec/factories/patients/bookmarks.rb +6 -0
  73. data/spec/factories/patients/ethnicities.rb +6 -0
  74. data/spec/factories/patients/languages.rb +5 -0
  75. data/spec/factories/patients/patients.rb +32 -0
  76. data/spec/factories/patients/practices.rb +17 -0
  77. data/spec/factories/patients/primary_care_physicians.rb +21 -0
  78. data/spec/factories/patients/religions.rb +5 -0
  79. data/spec/factories/patients/users.rb +3 -0
  80. data/spec/factories/pd/assessments.rb +22 -0
  81. data/spec/factories/pd/bag_types.rb +17 -0
  82. data/spec/factories/pd/episode_types.rb +6 -0
  83. data/spec/factories/pd/exit_site_infections.rb +9 -0
  84. data/spec/factories/pd/fluid_descriptions.rb +6 -0
  85. data/spec/factories/pd/infection_organisms.rb +10 -0
  86. data/spec/factories/pd/modality_descriptions.rb +5 -0
  87. data/spec/factories/pd/organism_codes.rb +6 -0
  88. data/spec/factories/pd/patients.rb +3 -0
  89. data/spec/factories/pd/pd_regimes.rb +36 -0
  90. data/spec/factories/pd/peritonitis_episode_type_descriptions.rb +8 -0
  91. data/spec/factories/pd/peritonitis_episodes.rb +20 -0
  92. data/spec/factories/pd/pet_adequacies.rb +38 -0
  93. data/spec/factories/pd/regime_bags.rb +44 -0
  94. data/spec/factories/pd/systems.rb +11 -0
  95. data/spec/factories/pd/training_sessions.rb +16 -0
  96. data/spec/factories/pd/training_sites.rb +6 -0
  97. data/spec/factories/pd/training_types.rb +5 -0
  98. data/spec/factories/problems/problems.rb +7 -0
  99. data/spec/factories/renal/patients.rb +3 -0
  100. data/spec/factories/renal/prd_description.rb +6 -0
  101. data/spec/factories/renal/profiles.rb +5 -0
  102. data/spec/factories/reporting/audits.rb +8 -0
  103. data/spec/factories/snippets/snippets.rb +6 -0
  104. data/spec/factories/snippets/users.rb +4 -0
  105. data/spec/factories/system/addresses.rb +11 -0
  106. data/spec/factories/system/roles.rb +27 -0
  107. data/spec/factories/system/templates.rb +15 -0
  108. data/spec/factories/system/users.rb +58 -0
  109. data/spec/factories/transplants/donations.rb +8 -0
  110. data/spec/factories/transplants/donor_stage.rb +12 -0
  111. data/spec/factories/transplants/donor_stage_position.rb +5 -0
  112. data/spec/factories/transplants/donor_stage_status.rb +5 -0
  113. data/spec/factories/transplants/live_donor_modality_description.rb +6 -0
  114. data/spec/factories/transplants/modality_descriptions.rb +10 -0
  115. data/spec/factories/transplants/patients.rb +3 -0
  116. data/spec/factories/transplants/recipient_followups.rb +4 -0
  117. data/spec/factories/transplants/recipient_operations.rb +15 -0
  118. data/spec/factories/transplants/registration_status_descriptions.rb +7 -0
  119. data/spec/factories/transplants/registration_statuses.rb +9 -0
  120. data/spec/factories/transplants/registrations.rb +46 -0
  121. data/spec/support/capybara_helper.rb +9 -0
  122. data/spec/support/database_cleaner.rb +18 -0
  123. data/spec/support/date_helpers.rb +9 -0
  124. data/spec/support/devise_spec_helper.rb +29 -0
  125. data/spec/support/drugs_spec_helper.rb +49 -0
  126. data/spec/support/factory_girl.rb +29 -0
  127. data/spec/support/json_helpers.rb +5 -0
  128. data/spec/support/letters_spec_helper.rb +36 -0
  129. data/spec/support/login_macros.rb +26 -0
  130. data/spec/support/matchers/document.rb +5 -0
  131. data/spec/support/matchers/validate_timeliness_of.rb +16 -0
  132. data/spec/support/pathology_spec_helper.rb +37 -0
  133. data/spec/support/patients_spec_helper.rb +16 -0
  134. data/spec/support/poltergeist.rb +2 -0
  135. data/spec/support/pundit_matcher.rb +13 -0
  136. data/spec/support/roles_spec_helper.rb +7 -0
  137. data/spec/support/select2_spec_helper.rb +13 -0
  138. data/spec/support/select_date_spec_helper.rb +11 -0
  139. data/spec/support/shared_contexts/a_global_rule_set.rb +19 -0
  140. data/spec/support/translations.rb +12 -0
  141. data/spec/support/travel.rb +7 -0
  142. data/spec/support/webmock.rb +3 -0
  143. metadata +142 -58
  144. data/vendor/xsd/ukrdc/README.md +0 -9
  145. data/vendor/xsd/ukrdc/Schema/Allergies/Allergy.xsd +0 -69
  146. data/vendor/xsd/ukrdc/Schema/ClinicalRelationships/ClinicalRelationship.xsd +0 -27
  147. data/vendor/xsd/ukrdc/Schema/Diagnoses/CauseOfDeath.xsd +0 -32
  148. data/vendor/xsd/ukrdc/Schema/Diagnoses/Diagnosis.xsd +0 -41
  149. data/vendor/xsd/ukrdc/Schema/Diagnoses/RenalDiagnosis.xsd +0 -41
  150. data/vendor/xsd/ukrdc/Schema/Documents/Document.xsd +0 -72
  151. data/vendor/xsd/ukrdc/Schema/Encounters/Encounter.xsd +0 -121
  152. data/vendor/xsd/ukrdc/Schema/Encounters/TransplantList.xsd +0 -108
  153. data/vendor/xsd/ukrdc/Schema/Encounters/Treatment.xsd +0 -207
  154. data/vendor/xsd/ukrdc/Schema/FamilyHistories/FamilyHistory.xsd +0 -42
  155. data/vendor/xsd/ukrdc/Schema/LabOrders/LabOrder.xsd +0 -181
  156. data/vendor/xsd/ukrdc/Schema/Medications/Medication.xsd +0 -88
  157. data/vendor/xsd/ukrdc/Schema/Observations/Observation.xsd +0 -65
  158. data/vendor/xsd/ukrdc/Schema/Patient.xsd +0 -87
  159. data/vendor/xsd/ukrdc/Schema/Procedures/DialysisSession.xsd +0 -61
  160. data/vendor/xsd/ukrdc/Schema/Procedures/Procedure.xsd +0 -38
  161. data/vendor/xsd/ukrdc/Schema/Procedures/Transplant.xsd +0 -160
  162. data/vendor/xsd/ukrdc/Schema/Procedures/VascularAccess.xsd +0 -49
  163. data/vendor/xsd/ukrdc/Schema/ProgramMemberships/ProgramMembership.xsd +0 -46
  164. data/vendor/xsd/ukrdc/Schema/README.md +0 -1
  165. data/vendor/xsd/ukrdc/Schema/SocialHistories/SocialHistory.xsd +0 -15
  166. data/vendor/xsd/ukrdc/Schema/Surveys/Survey.xsd +0 -143
  167. data/vendor/xsd/ukrdc/Schema/Types/ActionCode.xsd +0 -37
  168. data/vendor/xsd/ukrdc/Schema/Types/Address.xsd +0 -67
  169. data/vendor/xsd/ukrdc/Schema/Types/CF_DMD.xsd +0 -27
  170. data/vendor/xsd/ukrdc/Schema/Types/CF_EDTA_COD.xsd +0 -343
  171. data/vendor/xsd/ukrdc/Schema/Types/CF_EDTA_PRD.xsd +0 -356
  172. data/vendor/xsd/ukrdc/Schema/Types/CF_HL7_0004.xsd +0 -76
  173. data/vendor/xsd/ukrdc/Schema/Types/CF_HL7_00204.xsd +0 -46
  174. data/vendor/xsd/ukrdc/Schema/Types/CF_HL7_00206.xsd +0 -41
  175. data/vendor/xsd/ukrdc/Schema/Types/CF_RR1.xsd +0 -567
  176. data/vendor/xsd/ukrdc/Schema/Types/CF_RR23.xsd +0 -82
  177. data/vendor/xsd/ukrdc/Schema/Types/CF_RR7_Discharge.xsd +0 -80
  178. data/vendor/xsd/ukrdc/Schema/Types/CF_RR7_Treatment.xsd +0 -241
  179. data/vendor/xsd/ukrdc/Schema/Types/CF_SNOMED.xsd +0 -27
  180. data/vendor/xsd/ukrdc/Schema/Types/Clinician.xsd +0 -27
  181. data/vendor/xsd/ukrdc/Schema/Types/CodeTableDetail.xsd +0 -27
  182. data/vendor/xsd/ukrdc/Schema/Types/CodedField.xsd +0 -27
  183. data/vendor/xsd/ukrdc/Schema/Types/CommonMetadata.xsd +0 -23
  184. data/vendor/xsd/ukrdc/Schema/Types/ContactDetail.xsd +0 -55
  185. data/vendor/xsd/ukrdc/Schema/Types/DrugProduct.xsd +0 -41
  186. data/vendor/xsd/ukrdc/Schema/Types/EthnicGroup.xsd +0 -114
  187. data/vendor/xsd/ukrdc/Schema/Types/FamilyDoctor.xsd +0 -21
  188. data/vendor/xsd/ukrdc/Schema/Types/LabResultItem.xsd +0 -160
  189. data/vendor/xsd/ukrdc/Schema/Types/LabTestItem.xsd +0 -24
  190. data/vendor/xsd/ukrdc/Schema/Types/Language.xsd +0 -981
  191. data/vendor/xsd/ukrdc/Schema/Types/Location.xsd +0 -27
  192. data/vendor/xsd/ukrdc/Schema/Types/NV_RR14.xsd +0 -39
  193. data/vendor/xsd/ukrdc/Schema/Types/Name.xsd +0 -51
  194. data/vendor/xsd/ukrdc/Schema/Types/Occupation.xsd +0 -75
  195. data/vendor/xsd/ukrdc/Schema/Types/Order.xsd +0 -48
  196. data/vendor/xsd/ukrdc/Schema/Types/PatientNumber.xsd +0 -90
  197. data/vendor/xsd/ukrdc/Schema/Types/PersonalContactType.xsd +0 -11
  198. data/vendor/xsd/ukrdc/Schema/Types/Result.xsd +0 -178
  199. data/vendor/xsd/ukrdc/Schema/UKRDC.xsd +0 -148
@@ -0,0 +1,8 @@
1
+ FactoryGirl.define do
2
+ factory :audit, class: "Renalware::Reporting::Audit" do
3
+ name "Letters Authors"
4
+ materialized_view_name "audit_letter_authors"
5
+ refresh_schedule "1 0 * * *"
6
+ display_configuration "{}"
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+ FactoryGirl.define do
2
+ factory :snippet, class: "Renalware::Snippets::Snippet" do
3
+ title { Faker::Lorem.sentence }
4
+ body { Faker::Lorem.paragraph }
5
+ end
6
+ end
@@ -0,0 +1,4 @@
1
+ FactoryGirl.define do
2
+ factory :snippets_user, class: "Renalware::Snippets::User", parent: :user do
3
+ end
4
+ end
@@ -0,0 +1,11 @@
1
+ FactoryGirl.define do
2
+ factory :address, class: "Renalware::Address" do
3
+ street_1 "123 Legoland"
4
+ street_2 "Brewster Road"
5
+ street_3 "Brownswater"
6
+ town "Windsor"
7
+ county "Berkshire"
8
+ country "England"
9
+ postcode "NW1 6BB"
10
+ end
11
+ end
@@ -0,0 +1,27 @@
1
+ FactoryGirl.define do
2
+ factory :role, class: "Renalware::Role" do
3
+ name :super_admin
4
+ hidden false
5
+
6
+ trait :super_admin do
7
+ name :super_admin
8
+ hidden true
9
+ end
10
+
11
+ trait :admin do
12
+ name :admin
13
+ end
14
+
15
+ trait :clinician do
16
+ name :clinician
17
+ end
18
+
19
+ trait :read_only do
20
+ name :read_only
21
+ end
22
+ end
23
+ end
24
+
25
+ def find_or_create_role(name = :clinician)
26
+ Renalware::Role.find_by(name: name) || create(:role, name)
27
+ end
@@ -0,0 +1,15 @@
1
+ FactoryGirl.define do
2
+ factory :esi_printable_form_template, class: "Renalware::System::Template" do
3
+ name "esi_printable_form"
4
+ title "ESI Printable Form"
5
+ description "Description"
6
+ body "{{ patient.name }} {{ patient.hospital_identifier }}"
7
+ end
8
+
9
+ factory :peritonitis_episode_printable_form_template, class: "Renalware::System::Template" do
10
+ name "peritonitis_episode_printable_form"
11
+ title "Peritonitis Episode Printable form"
12
+ description "Description"
13
+ body "{{ patient.name }} {{ patient.hospital_identifier }}"
14
+ end
15
+ end
@@ -0,0 +1,58 @@
1
+ FactoryGirl.define do
2
+ sequence :email do |n|
3
+ "renalware.user-#{n}@nhs.net"
4
+ end
5
+
6
+ sequence :username do |n|
7
+ "renalwareuser-#{n}"
8
+ end
9
+
10
+ factory :user, class: "Renalware::User" do
11
+ given_name { Faker::Name.first_name }
12
+ family_name { Faker::Name.last_name }
13
+ username
14
+ email
15
+ password "supersecret"
16
+ approved false
17
+ professional_position "Health Minister"
18
+
19
+ trait :author do
20
+ signature { Faker::Name.name }
21
+ end
22
+
23
+ trait :approved do
24
+ approved true
25
+ after(:create) do |user|
26
+ user.roles = [find_or_create_role(:clinician)]
27
+ end
28
+ end
29
+ trait :expired do
30
+ last_activity_at 60.days.ago
31
+ expired_at Time.zone.now
32
+ end
33
+ trait :super_admin do
34
+ after(:create) do |user|
35
+ user.roles = [find_or_create_role(:super_admin)]
36
+ end
37
+ end
38
+ trait :admin do
39
+ after(:create) do |user|
40
+ user.roles = [find_or_create_role(:admin)]
41
+ end
42
+ end
43
+ trait :clinician do
44
+ given_name "Aneurin"
45
+ family_name "Bevan"
46
+ signature "Aneurin Bevan"
47
+
48
+ after(:create) do |user|
49
+ user.roles = [find_or_create_role(:clinician)]
50
+ end
51
+ end
52
+ trait :read_only do
53
+ after(:create) do |user|
54
+ user.roles = [find_or_create_role(:read_only)]
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,8 @@
1
+ FactoryGirl.define do
2
+ factory :transplant_donation, class: Renalware::Transplants::Donation do
3
+ patient
4
+
5
+ state :volunteered
6
+ relationship_with_recipient :sibling
7
+ end
8
+ end
@@ -0,0 +1,12 @@
1
+ FactoryGirl.define do
2
+ factory :donor_stage, class: "Renalware::Transplants::DonorStage" do
3
+ patient
4
+ stage_position factory: :donor_stage_position
5
+ stage_status factory: :donor_stage_status
6
+ started_on ->{ Time.zone.now }
7
+ notes "Some notes"
8
+ terminated_on nil
9
+ association :created_by, factory: :user
10
+ association :updated_by, factory: :user
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ FactoryGirl.define do
2
+ factory :donor_stage_position, class: "Renalware::Transplants::DonorStagePosition" do
3
+ name { Faker::Lorem.word }
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ FactoryGirl.define do
2
+ factory :donor_stage_status, class: "Renalware::Transplants::DonorStageStatus" do
3
+ name { Faker::Lorem.word }
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ FactoryGirl.define do
2
+ factory :live_donor_modality_description,
3
+ class: "Renalware::Transplants::DonorModalityDescription" do
4
+ name "Live Donor"
5
+ end
6
+ end
@@ -0,0 +1,10 @@
1
+ FactoryGirl.define do
2
+ factory :transplant_donor_modality_description,
3
+ class: "Renalware::Transplants::DonorModalityDescription" do
4
+ name "Live Donor"
5
+ end
6
+
7
+ factory :transplant_modality_description, class: "Renalware::HD::ModalityDescription" do
8
+ initialize_with { Renalware::HD::ModalityDescription.find_or_create_by(name: "Transplant") }
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ FactoryGirl.define do
2
+ factory :transplant_patient, class: "Renalware::Transplants::Patient", parent: :patient
3
+ end
@@ -0,0 +1,4 @@
1
+ FactoryGirl.define do
2
+ factory :transplant_recipient_followup, class: Renalware::Transplants::RecipientFollowup do
3
+ end
4
+ end
@@ -0,0 +1,15 @@
1
+ FactoryGirl.define do
2
+ factory :transplant_recipient_operation, class: Renalware::Transplants::RecipientOperation do
3
+ patient { build(:transplant_patient) }
4
+
5
+ performed_on 1.week.ago
6
+ theatre_case_start_time "11:00"
7
+ donor_kidney_removed_from_ice_at 1.week.ago
8
+ kidney_perfused_with_blood_at 1.week.ago
9
+ operation_type :kidney
10
+ cold_ischaemic_time "00:45"
11
+ warm_ischaemic_time "00:12"
12
+
13
+ association :hospital_centre, factory: :hospital_centre
14
+ end
15
+ end
@@ -0,0 +1,7 @@
1
+ FactoryGirl.define do
2
+ factory :transplant_registration_status_description,
3
+ class: Renalware::Transplants::RegistrationStatusDescription do
4
+ code "active"
5
+ name "Active"
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ FactoryGirl.define do
2
+ factory :transplant_registration_status,
3
+ class: Renalware::Transplants::RegistrationStatus do
4
+ description { create(:transplant_registration_status_description) }
5
+ started_on Time.zone.today
6
+ association :created_by, factory: :user
7
+ association :updated_by, factory: :user
8
+ end
9
+ end
@@ -0,0 +1,46 @@
1
+ FactoryGirl.define do
2
+ factory :transplant_registration, class: Renalware::Transplants::Registration do
3
+ patient { build(:transplant_patient) }
4
+
5
+ trait :with_statuses do
6
+ after(:create) do |registration|
7
+ 10.downto(8).each do |day|
8
+ start_date = day.days.ago
9
+ create(
10
+ :transplant_registration_status,
11
+ registration: registration,
12
+ started_on: start_date,
13
+ terminated_on: start_date + 1.day
14
+ )
15
+ end
16
+ create(
17
+ :transplant_registration_status,
18
+ registration: registration,
19
+ started_on: 7.days.ago
20
+ )
21
+ end
22
+ end
23
+
24
+ trait :in_status do
25
+ transient do
26
+ status "active"
27
+ end
28
+
29
+ after(:create) do |registration, evaluator|
30
+ create(
31
+ :transplant_registration_status,
32
+ registration: registration,
33
+ started_on: 7.days.ago,
34
+ description: create(:transplant_registration_status_description,
35
+ name: evaluator.status.humanize, code: evaluator.status)
36
+ )
37
+ create(
38
+ :transplant_registration_status,
39
+ registration: registration,
40
+ started_on: 10.days.ago,
41
+ terminated_on: 7.days.ago
42
+ )
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,9 @@
1
+ module CapybaraHelper
2
+ def select_nth_option_from(selector, number = 1)
3
+ all("#{selector} option")[number - 1].select_option
4
+ end
5
+
6
+ def select_first_option_from(selector)
7
+ select_nth_option_from(selector)
8
+ end
9
+ end
@@ -0,0 +1,18 @@
1
+ RSpec.configure do |config|
2
+
3
+ # config.use_transactional_fixtures = false
4
+
5
+ config.before(:suite) do
6
+ DatabaseCleaner.clean_with :truncation, except: %w(ar_internal_metadata)
7
+ end
8
+
9
+ config.before(:each) do |example|
10
+ DatabaseCleaner.strategy = example.metadata[:js] ? :truncation : :transaction
11
+ DatabaseCleaner.start
12
+ end
13
+
14
+ config.after(:each) do
15
+ DatabaseCleaner.clean
16
+ end
17
+
18
+ end
@@ -0,0 +1,9 @@
1
+ module DateHelpers
2
+ def todays_date
3
+ I18n.l(Time.zone.today)
4
+ end
5
+
6
+ def todays_date_and_time
7
+ I18n.l(Time.zone)
8
+ end
9
+ end
@@ -0,0 +1,29 @@
1
+ require "devise"
2
+ require_relative "./login_macros"
3
+
4
+ RSpec.configure do |config|
5
+ config.include Devise::Test::ControllerHelpers, type: :controller
6
+ config.include LoginMacros, type: :controller
7
+
8
+ config.include Warden::Test::Helpers, type: :feature
9
+ config.include LoginMacros, type: :feature
10
+
11
+ config.include Warden::Test::Helpers, type: :request
12
+ config.include LoginMacros, type: :request
13
+
14
+ config.before(:each, type: :controller) do
15
+ login_as_super_admin
16
+ end
17
+
18
+ config.before(:each, type: :request) do
19
+ login_as_super_admin
20
+ end
21
+
22
+ config.before :suite do
23
+ Warden.test_mode!
24
+ end
25
+
26
+ config.after :each do
27
+ Warden.test_reset!
28
+ end
29
+ end
@@ -0,0 +1,49 @@
1
+ module DrugsSpecHelper
2
+ def load_drugs(*names)
3
+ names.each do |name|
4
+ drug = create(:drug, name: name)
5
+ instance_variable_set(:"@#{name.downcase}", drug)
6
+ end
7
+ end
8
+
9
+ # { 'Amoxicillin' => ['Antibiotic', 'Peritonitis'], 'Penicillin' => ['Foo', ...] }
10
+ def load_drugs_by_type(drugs_by_type)
11
+ drugs_by_type.each do |drug_name, drug_type_names|
12
+ drug = assign_drug(drug_name)
13
+ drug_type_names.each { |name| assign_drug_type(drug, name) }
14
+ end
15
+ end
16
+
17
+ def load_med_routes
18
+ medication_routes = {
19
+ "PO" => "Per Oral",
20
+ "IV" => "Intravenous",
21
+ "SC" => "Subcutaneous",
22
+ "IM" => "Intramuscular",
23
+ "Other" => "Other (Refer to notes)"
24
+ }
25
+
26
+ medication_routes.map do |code, name|
27
+ route = create(:medication_route, code: code, name: name)
28
+ instance_variable_set(:"@#{code.downcase}", route)
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ def assign_drug(name)
35
+ drug = create(:drug, name: name)
36
+ instance_variable_set(:"@#{name.downcase}", drug)
37
+ end
38
+
39
+ def assign_drug_type(drug, name)
40
+ drug_type = Renalware::Drugs::Type.find_by(code: name.downcase)
41
+
42
+ if drug_type.blank?
43
+ drug_type = create(:drug_type, code: name.downcase, name: name)
44
+ instance_variable_set(:"@#{name.downcase}", drug_type)
45
+ end
46
+
47
+ drug.drug_types << drug_type
48
+ end
49
+ end
@@ -0,0 +1,29 @@
1
+ RSpec.configure do |config|
2
+ config.include FactoryGirl::Syntax::Methods
3
+ end
4
+
5
+ # Use this strategy to get Hash output from factories defined using class: OpenStruct.
6
+ # Useful for working with jsonb-based Document objects.
7
+ #
8
+ # Example usage
9
+ #
10
+ # factory :some_document, class: OpenStruct do
11
+ # pulse 37
12
+ # end
13
+ #
14
+ # factory :something do
15
+ # document factory: :some_document, strategy: :marshal_dump
16
+ # end
17
+ #
18
+ class MarshalDumpStrategy
19
+ def initialize
20
+ @strategy = FactoryGirl.strategy_by_name(:create).new
21
+ end
22
+
23
+ delegate :association, to: :@strategy
24
+
25
+ def result(evaluation)
26
+ @strategy.result(evaluation).marshal_dump
27
+ end
28
+ end
29
+ FactoryGirl.register_strategy(:marshal_dump, MarshalDumpStrategy)