renalware-core 2.0.64 → 2.0.67

Sign up to get free protection for your applications and to get access to all the features.
Files changed (216) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/renalware/application.js.erb +2 -2
  3. data/app/controllers/renalware/admin/users_controller.rb +1 -1
  4. data/app/controllers/renalware/api/ukrdc/patients_controller.rb +14 -67
  5. data/app/controllers/renalware/drugs/drugs_controller.rb +1 -1
  6. data/app/controllers/renalware/hd/protocols_controller.rb +1 -1
  7. data/app/controllers/renalware/patients/bookmarks_controller.rb +16 -5
  8. data/app/controllers/renalware/snippets/snippets_controller.rb +1 -1
  9. data/app/controllers/renalware/system/user_feedback_controller.rb +1 -1
  10. data/app/documents/renalware/hd/session_document.rb +1 -0
  11. data/app/models/renalware/admissions/consult_query.rb +1 -1
  12. data/app/models/renalware/clinical/dry_weight.rb +4 -0
  13. data/app/models/renalware/clinical/patient.rb +5 -0
  14. data/app/models/renalware/clinical/patient_dry_weights_query.rb +1 -1
  15. data/app/models/renalware/directory/person_query.rb +1 -1
  16. data/app/models/renalware/hd/mdm_patients_query.rb +1 -1
  17. data/app/models/renalware/hd/patient.rb +6 -0
  18. data/app/models/renalware/hd/patient_listener.rb +8 -0
  19. data/app/models/renalware/hd/sessions/ongoing_query.rb +1 -1
  20. data/app/models/renalware/hd/sessions/patient_query.rb +1 -1
  21. data/app/models/renalware/letters/descriptions/search_query.rb +1 -1
  22. data/app/models/renalware/letters/letter_factory.rb +55 -2
  23. data/app/models/renalware/letters/letter_query.rb +1 -1
  24. data/app/models/renalware/letters/recipient.rb +11 -0
  25. data/app/models/renalware/letters/resolve_default_electronic_ccs.rb +47 -0
  26. data/app/models/renalware/low_clearance/mdm_patients_query.rb +1 -1
  27. data/app/models/renalware/medications/prescriptions_by_drug_type_query.rb +1 -1
  28. data/app/models/renalware/medications/prescriptions_query.rb +1 -1
  29. data/app/models/renalware/patients/bookmarks_query.rb +49 -0
  30. data/app/models/renalware/patients/patient_search.rb +1 -1
  31. data/app/models/renalware/pd/mdm_patients_query.rb +1 -1
  32. data/app/models/renalware/renal/prd_descriptions/search_query.rb +1 -1
  33. data/app/models/renalware/transplants/live_donors_query.rb +1 -1
  34. data/app/models/renalware/transplants/mdm_patients_query.rb +1 -1
  35. data/app/models/renalware/transplants/registrations/wait_list_query.rb +1 -1
  36. data/app/models/renalware/ukrdc/create_encrypted_patient_xml_files.rb +13 -11
  37. data/app/models/renalware/ukrdc/create_patient_xml_file.rb +33 -21
  38. data/app/models/renalware/ukrdc/transmission_log.rb +1 -1
  39. data/app/models/renalware/ukrdc/xml_renderer.rb +126 -0
  40. data/app/presenters/renalware/clinical/dry_weight_presenter.rb +4 -0
  41. data/app/presenters/renalware/clinical/dry_weights_presenter.rb +15 -9
  42. data/app/presenters/renalware/ukrdc/modality_presenter.rb +8 -0
  43. data/app/presenters/renalware/ukrdc/patient_presenter.rb +9 -6
  44. data/app/views/renalware/api/ukrdc/patients/_clinical_relationships.xml.builder +4 -4
  45. data/app/views/renalware/api/ukrdc/patients/_encounters.xml.builder +9 -9
  46. data/app/views/renalware/api/ukrdc/patients/_family_histories.xml.builder +4 -4
  47. data/app/views/renalware/api/ukrdc/patients/_patient.xml.builder +1 -20
  48. data/app/views/renalware/api/ukrdc/patients/_program_memberships.xml.builder +4 -4
  49. data/app/views/renalware/api/ukrdc/patients/_surveys.xml.builder +4 -4
  50. data/app/views/renalware/api/ukrdc/patients/encounters/_hd_session.xml.builder +31 -31
  51. data/app/views/renalware/api/ukrdc/patients/encounters/_treatment.xml.builder +34 -0
  52. data/app/views/renalware/api/ukrdc/patients/lab_orders/_lab_order.xml.builder +1 -1
  53. data/app/views/renalware/api/ukrdc/patients/show.xml.builder +1 -1
  54. data/app/views/renalware/hd/mdm/_summary.html.slim +12 -4
  55. data/app/views/renalware/hd/protocols/_recent_pathology.html.slim +4 -0
  56. data/app/views/renalware/hd/sessions/_form.html.slim +1 -0
  57. data/app/views/renalware/mdm/_prescription_buttons.html.slim +15 -0
  58. data/app/views/renalware/mdm/_prescriptions.html.slim +1 -8
  59. data/app/views/renalware/patients/bookmarks/_bookmark.html.slim +16 -0
  60. data/app/views/renalware/patients/bookmarks/_table.html.slim +20 -0
  61. data/app/views/renalware/patients/bookmarks/index.html.slim +3 -1
  62. data/app/views/renalware/transplants/mdm/_prescriptions.html.slim +1 -8
  63. data/config/initializers/core_extensions.rb +1 -1
  64. data/config/initializers/renalware.rb +3 -0
  65. data/config/locales/renalware/hd/session.en.yml +7 -0
  66. data/config/locales/renalware/patients/bookmarks.en.yml +12 -0
  67. data/config/locales/renalware/patients/side_menu.en.yml +1 -1
  68. data/db/migrate/20150119160039_create_versions.rb +3 -3
  69. data/db/migrate/20150120155952_create_problem_versions.rb +3 -3
  70. data/db/migrate/20150203161438_create_medication_prescription_versions.rb +3 -3
  71. data/db/migrate/20150515155052_users_have_and_belong_to_many_roles.rb +3 -1
  72. data/db/migrate/20160120203747_create_access_versions.rb +3 -3
  73. data/db/migrate/20160121175711_create_hd_versions.rb +3 -3
  74. data/db/migrate/20170217141529_create_clinic_versions.rb +3 -3
  75. data/db/migrate/20170217161409_create_patient_versions.rb +3 -3
  76. data/db/migrate/20170605102519_create_clinical_versions.rb +3 -3
  77. data/db/migrate/20171002175804_add_rr_columns_to_transplant_registration_status_descriptions.rb +9 -7
  78. data/db/migrate/20171003093347_create_hospital_wards.rb +14 -12
  79. data/db/migrate/20171003111228_create_aki_alert_actions.rb +6 -4
  80. data/db/migrate/20171003122425_create_renal_aki_alerts.rb +18 -16
  81. data/db/migrate/20171004092235_create_hd_dialysates.rb +9 -7
  82. data/db/migrate/20171004110909_add_dialysate_id_to_profile_and_session.rb +6 -4
  83. data/db/migrate/20171005081224_create_reporting_bone_audit.rb +3 -1
  84. data/db/migrate/20171005091202_reporting_audit_changes.rb +5 -3
  85. data/db/migrate/20171005130109_create_medication_current_prescriptions.rb +3 -1
  86. data/db/migrate/20171005144505_create_reporting_anaemia_audit.rb +3 -1
  87. data/db/migrate/20171009104106_add_legacy_patient_id_to_patients.rb +4 -2
  88. data/db/migrate/20171009181615_add_columns_to_drug_drugs.rb +6 -4
  89. data/db/migrate/20171012110133_create_research_studies.rb +19 -17
  90. data/db/migrate/20171012143050_create_research_study_participants.rb +27 -25
  91. data/db/migrate/20171013145849_set_patients_secure_id.rb +12 -10
  92. data/db/migrate/20171016152223_add_index_to_diary_slots.rb +14 -12
  93. data/db/migrate/20171017132738_add_unique_indexes_to_local_patient_ids.rb +11 -9
  94. data/db/migrate/20171017171625_update_hd_overall_audit_view.rb +7 -5
  95. data/db/migrate/20171101121130_create_function_to_render_audit_view_as_json.rb +6 -4
  96. data/db/migrate/20171101162244_create_consults.rb +21 -19
  97. data/db/migrate/20171106100216_create_pd_audit_view.rb +3 -1
  98. data/db/migrate/20171109084751_remove_local_patient_id_unique_idx.rb +11 -9
  99. data/db/migrate/20171113120217_add_uuid_to_hd_sessions.rb +4 -2
  100. data/db/migrate/20171114120904_add_pathology_snapshot_to_letters.rb +3 -1
  101. data/db/migrate/20171118160030_add_tags_to_patient_bookmarks.rb +3 -1
  102. data/db/migrate/20171123123712_add_id_to_roles_users.rb +3 -1
  103. data/db/migrate/20171123143534_add_pk_to_drug_types_drugs.rb +13 -12
  104. data/db/migrate/20171123154116_create_renal_versions.rb +11 -9
  105. data/db/migrate/20171127082158_add_region_to_addresses.rb +3 -1
  106. data/db/migrate/20171127092158_create_function_to_import_practices.rb +6 -2
  107. data/db/migrate/20171127092359_create_fn_to_insert_gps.rb +6 -2
  108. data/db/migrate/20171128163543_add_more_missing_indexes.rb +14 -12
  109. data/db/migrate/20171204112150_create_consult_sites.rb +13 -9
  110. data/db/migrate/20171206121652_add_loinc_code_to_observation_descriptions.rb +3 -1
  111. data/db/migrate/20171206140738_create_fn_to_load_practice_memberships_csv.rb +9 -5
  112. data/db/migrate/20171208211206_create_user_feedback.rb +7 -5
  113. data/db/migrate/20171211130716_remove_unused_patients_cols.rb +4 -2
  114. data/db/migrate/20171211131918_remove_email_from_primary_care_physicians.rb +5 -3
  115. data/db/migrate/20171211161400_create_pathology_current_table.rb +9 -7
  116. data/db/migrate/20171213111513_create_fn_to_refresh_current_obs.rb +6 -2
  117. data/db/migrate/20171214141335_create_trigger_to_update_current_observation_sets.rb +10 -6
  118. data/db/migrate/20171214190849_enforce_request_id_on_observations.rb +3 -1
  119. data/db/migrate/20171215122454_add_pathology_observation_set_to_letters.rb +8 -6
  120. data/db/migrate/20171219154529_create_admission_admissions.rb +25 -23
  121. data/db/migrate/20180102155055_update_patient_summaries_to_version_5.rb +3 -1
  122. data/db/migrate/20180105132358_add_emailed_at_to_letter_recipients.rb +4 -2
  123. data/db/migrate/20180108185400_remove_null_constraint_from_letters_pathology_snapshot.rb +3 -1
  124. data/db/migrate/20180112151706_create_low_clearance_profiles.rb +43 -41
  125. data/db/migrate/20180112151813_create_low_clearance_versions.rb +11 -9
  126. data/db/migrate/20180119121243_create_trigger_to_preprocess_hl7_msg.rb +10 -6
  127. data/db/migrate/20180121115246_add_include_pathology_in_letter_to_letters_letterheads.rb +3 -1
  128. data/db/migrate/20180122173922_create_virology_profiles.rb +5 -1
  129. data/db/migrate/20180125201356_make_obs_set_trigger_change_updated_at.rb +6 -2
  130. data/db/migrate/20180126142314_add_uuid_to_letters.rb +4 -2
  131. data/db/migrate/20180130165803_add_deleted_at_indexes.rb +14 -12
  132. data/db/migrate/20180201090444_add_created_at_to_delayed_jobs_in_hl7_trig_fn.rb +6 -2
  133. data/db/migrate/20180202184954_create_view_pathology_observation_digests.rb +3 -1
  134. data/db/migrate/20180206225525_update_fn_update_current_observation_set_from_trigger.rb +6 -2
  135. data/db/migrate/20180207082540_create_count_estimate_function.rb +6 -2
  136. data/db/migrate/20180208150629_add_authentication_token_to_users.rb +3 -1
  137. data/db/migrate/20180213124203_add_cancelled_to_pathology_observations.rb +7 -5
  138. data/db/migrate/20180213125734_update_fn_update_current_obs_set_trgger.rb +6 -2
  139. data/db/migrate/20180213171805_add_display_order_cols_to_observation_descriptions.rb +10 -8
  140. data/db/migrate/20180214124317_add_cols_to_aki_alerts.rb +7 -5
  141. data/db/migrate/20180216132741_disable_some_audits.rb +6 -4
  142. data/db/migrate/20180221210458_add_state_index_on_modalities.rb +3 -1
  143. data/db/migrate/20180222090501_add_partial_index_to_bookmarks.rb +4 -2
  144. data/db/migrate/20180223100420_add_sent_to_ukrdc_at_to_patients.rb +3 -1
  145. data/db/migrate/20180226124724_add_patient_id_to_virology_profile.rb +9 -5
  146. data/db/migrate/20180226132410_create_ukrdc_transmission_logs.rb +12 -10
  147. data/db/migrate/20180301095040_update_fn_to_upsert_gp_practive_memberships.rb +7 -3
  148. data/db/migrate/20180305134959_add_display_group_to_observation_desriptions.rb +23 -22
  149. data/db/migrate/20180306071308_remove_rogue_aki_alerts_column.rb +3 -1
  150. data/db/migrate/20180306080518_add_state_tracking_cols_to_letters.rb +17 -15
  151. data/db/migrate/20180307191650_add_dwell_time_to_pd_regime.rb +3 -1
  152. data/db/migrate/20180307223111_create_system_visits_and_events.rb +42 -39
  153. data/db/migrate/20180309140316_add_unique_constraint_to_obr_requestor.rb +3 -1
  154. data/db/migrate/20180311104609_remove_unique_obr_requestor_order_number_index.rb +4 -2
  155. data/db/migrate/20180313114927_remove_deleted_at_from_admission_consults.rb +3 -1
  156. data/db/migrate/20180313124819_remove_tx_operation_constraints.rb +7 -5
  157. data/db/migrate/20180319191942_create_function_to_sort_without_failing_on_nonnumerics.rb +6 -2
  158. data/db/migrate/20180323150241_update_path_obs_descs_for_letter_groupings.rb +25 -23
  159. data/db/migrate/20180326155400_add_admin_notes_to_system_user_feedback.rb +4 -2
  160. data/db/migrate/20180327100423_add_constraints_to_recipient_operations.rb +3 -1
  161. data/db/migrate/20180328210434_add_rrt_to_admission_consults.rb +3 -1
  162. data/db/migrate/20180419141524_add_cols_to_hd_patient_statistics.rb +8 -6
  163. data/db/migrate/20180422090043_update_hd_overall_audit_to_version_6.rb +85 -84
  164. data/db/migrate/20180427133558_add_code_to_hospitals_wards.rb +3 -1
  165. data/db/migrate/20180502093256_add_document_to_virology_profiles.rb +22 -21
  166. data/db/migrate/20180502110638_create_virology_versions.rb +7 -5
  167. data/db/migrate/20180510151959_update_hd_overall_audit_to_version_7.rb +8 -4
  168. data/db/migrate/20180511100345_add_notes_to_transplant_registration_statuses.rb +3 -1
  169. data/db/migrate/20180511140415_add_message_hash_messaging_messages.rb +4 -2
  170. data/db/migrate/20180511171835_create_unique_indexes_on_obr_obr_codes.rb +5 -3
  171. data/db/migrate/20180514151627_create_system_messages.rb +10 -8
  172. data/db/migrate/20180516111411_create_view_patient_current_modalities.rb +3 -1
  173. data/db/migrate/20180524072633_add_columns_to_dialysates.rb +10 -8
  174. data/db/migrate/20180524074320_add_columns_to_hd_dialysers.rb +8 -6
  175. data/db/migrate/20180605114332_create_pseudo_encrypt_function.rb +6 -2
  176. data/db/migrate/20180605141806_add_external_id_to_research_study_participants.rb +33 -31
  177. data/db/migrate/20180605175211_add_application_url_to_research_studies.rb +3 -1
  178. data/db/migrate/20180622130552_add_external_id_to_hd_sessions.rb +4 -2
  179. data/db/migrate/20180625124431_add_patient_identifier_to_feed_messages.rb +3 -1
  180. data/db/migrate/20180628132323_add_letter_date_indexes.rb +9 -7
  181. data/db/migrate/20180702091222_create_hd_providers.rb +5 -3
  182. data/db/migrate/20180702091237_create_hd_provider_units.rb +8 -6
  183. data/db/migrate/20180702091352_create_hd_transmission_log.rb +15 -13
  184. data/db/migrate/20180712143314_add_hidden_to_modality_descriptions.rb +3 -1
  185. data/db/migrate/20180718172750_update_audit_letters_authors_to_version_3.rb +13 -11
  186. data/db/migrate/20180725132557_add_days_text_to_hd_schedule_definitions.rb +21 -19
  187. data/db/migrate/20180725132808_create_hd_schedule_definition_filters_view.rb +3 -1
  188. data/db/migrate/20180730154454_add_external_session_id_to_hd_transmission_logs.rb +7 -5
  189. data/db/migrate/20180802103013_add_hd_mdm_missing_indexes.rb +6 -4
  190. data/db/migrate/20180802132417_add_missing_indexes_2.rb +16 -14
  191. data/db/migrate/20180802144507_add_missing_foreign_key_indexes.rb +14 -12
  192. data/db/migrate/20180803131157_add_uuid_to_hd_transmission_logs.rb +7 -1
  193. data/db/migrate/20180814103916_create_index_on_lower_patient_family_name.rb +5 -3
  194. data/db/migrate/20180815144429_update_hd_overall_audit_to_version_8.rb +8 -4
  195. data/db/migrate/20180831134926_create_daily_reports.rb +3 -6
  196. data/db/migrate/20180907100545_add_page_count_to_letters.rb +3 -1
  197. data/db/migrate/20181001162513_add_active_to_hospital_wards.rb +3 -1
  198. data/db/migrate/20181008144324_update_daily_letters_report_view_to_version_2.rb +0 -2
  199. data/db/migrate/20181008145159_create_reporting_daily_ukrdc_view.rb +0 -4
  200. data/db/migrate/20181013115138_update_reporting_daily_pathology_view_to_v2.rb +0 -2
  201. data/db/migrate/20181025170410_add_ukrdc_helper_column_to_patients.rb +0 -2
  202. data/db/migrate/20181026145459_create_ukrdc_batch_numbers.rb +5 -3
  203. data/db/migrate/20181106133500_update_hd_overall_audit_to_version_9.rb +0 -2
  204. data/db/migrate/20181109110616_create_hd_grouped_transmission_logs_view.rb +0 -2
  205. data/db/migrate/20181126090401_add_warnings_to_hd_transmission_logs.rb +7 -0
  206. data/db/migrate/20181126123745_refresh_hd_grouped_transmission_logs_view.rb +8 -0
  207. data/db/migrate/20181217124025_change_ukrdc_transmission_log_error_type.rb +15 -0
  208. data/db/seeds/default/practices/nhs_practices_sample.csv +2 -2
  209. data/db/seeds/default/practices/primary_care_physicians_sample.csv +2 -2
  210. data/lib/core_extensions/active_record/migration_helpers.rb +43 -1
  211. data/lib/renalware/engine.rb +2 -0
  212. data/lib/renalware/version.rb +1 -1
  213. metadata +55 -19
  214. data/lib/migration_helper.rb +0 -11
  215. data/vendor/assets/javascripts/renalware/moment.min.js +0 -1
  216. data/vendor/assets/javascripts/renalware/mousetrap.js +0 -1044
@@ -1,17 +1,19 @@
1
1
  class UpdateAuditLettersAuthorsToVersion3 < ActiveRecord::Migration[5.1]
2
2
  def change
3
- update_view :reporting_main_authors_audit,
4
- materialized: true,
5
- version: 3,
6
- revert_to_version: 2
3
+ within_renalware_schema do
4
+ update_view :reporting_main_authors_audit,
5
+ materialized: true,
6
+ version: 3,
7
+ revert_to_version: 2
7
8
 
8
- reversible do |direction|
9
- direction.up {
10
- connection.execute("refresh materialized view reporting_main_authors_audit;")
11
- }
12
- direction.down {
13
- connection.execute("refresh materialized view reporting_main_authors_audit;")
14
- }
9
+ reversible do |direction|
10
+ direction.up {
11
+ connection.execute("refresh materialized view reporting_main_authors_audit;")
12
+ }
13
+ direction.down {
14
+ connection.execute("refresh materialized view reporting_main_authors_audit;")
15
+ }
16
+ end
15
17
  end
16
18
  end
17
19
  end
@@ -1,27 +1,29 @@
1
1
  class AddDaysTextToHDScheduleDefinitions < ActiveRecord::Migration[5.1]
2
2
  def change
3
- add_column :hd_schedule_definitions, :days_text, :text
4
- add_column :hd_schedule_definitions, :sort_order, :integer, null: false, default: 0
3
+ within_renalware_schema do
4
+ add_column :hd_schedule_definitions, :days_text, :text
5
+ add_column :hd_schedule_definitions, :sort_order, :integer, null: false, default: 0
5
6
 
6
- reversible do |direction|
7
- direction.up do
8
- sql = <<-SQL
9
- update hd_schedule_definitions set days_text = 'Mon Wed Fri' where days::text = '{1,3,5}';
10
- update hd_schedule_definitions set days_text = 'Tue Thu Sat' where days::text = '{2,4,6}';
11
- SQL
12
- connection.execute(sql)
7
+ reversible do |direction|
8
+ direction.up do
9
+ sql = <<-SQL
10
+ update hd_schedule_definitions set days_text = 'Mon Wed Fri' where days::text = '{1,3,5}';
11
+ update hd_schedule_definitions set days_text = 'Tue Thu Sat' where days::text = '{2,4,6}';
12
+ SQL
13
+ connection.execute(sql)
14
+ end
13
15
  end
14
- end
15
16
 
16
- add_column :hd_diurnal_period_codes, :sort_order, :integer, default: 0, null: false
17
- reversible do |direction|
18
- direction.up {
19
- connection.execute(<<-SQL)
20
- update hd_diurnal_period_codes set sort_order = 1 where code = 'am';
21
- update hd_diurnal_period_codes set sort_order = 2 where code = 'pm';
22
- update hd_diurnal_period_codes set sort_order = 3 where code = 'eve';
23
- SQL
24
- }
17
+ add_column :hd_diurnal_period_codes, :sort_order, :integer, default: 0, null: false
18
+ reversible do |direction|
19
+ direction.up {
20
+ connection.execute(<<-SQL)
21
+ update hd_diurnal_period_codes set sort_order = 1 where code = 'am';
22
+ update hd_diurnal_period_codes set sort_order = 2 where code = 'pm';
23
+ update hd_diurnal_period_codes set sort_order = 3 where code = 'eve';
24
+ SQL
25
+ }
26
+ end
25
27
  end
26
28
  end
27
29
  end
@@ -1,5 +1,7 @@
1
1
  class CreateHDScheduleDefinitionFiltersView < ActiveRecord::Migration[5.1]
2
2
  def change
3
- create_view :hd_schedule_definition_filters
3
+ within_renalware_schema do
4
+ create_view :hd_schedule_definition_filters
5
+ end
4
6
  end
5
7
  end
@@ -1,9 +1,11 @@
1
1
  class AddExternalSessionIdToHDTransmissionLogs < ActiveRecord::Migration[5.1]
2
2
  def change
3
- add_column :hd_transmission_logs,
4
- :external_session_id,
5
- :string,
6
- index: true
7
- add_reference :hd_transmission_logs, :session, index: true, null: true
3
+ within_renalware_schema do
4
+ add_column :hd_transmission_logs,
5
+ :external_session_id,
6
+ :string,
7
+ index: true
8
+ add_reference :hd_transmission_logs, :session, index: true, null: true
9
+ end
8
10
  end
9
11
  end
@@ -1,8 +1,10 @@
1
1
  class AddHDMDMMissingIndexes < ActiveRecord::Migration[5.1]
2
2
  def change
3
- add_index :modality_modalities, :ended_on
4
- add_index :modality_descriptions, :name
5
- add_index :transplant_registration_statuses, :terminated_on
6
- add_index :transplant_registration_statuses, :started_on
3
+ within_renalware_schema do
4
+ add_index :modality_modalities, :ended_on
5
+ add_index :modality_descriptions, :name
6
+ add_index :transplant_registration_statuses, :terminated_on
7
+ add_index :transplant_registration_statuses, :started_on
8
+ end
7
9
  end
8
10
  end
@@ -1,18 +1,20 @@
1
1
  class AddMissingIndexes2 < ActiveRecord::Migration[5.1]
2
2
  def change
3
- # These indexes where missed as we had used the add_column method passing in index: true
4
- # but that is not supported so no index was created
5
- add_index :addresses, :country_id
6
- add_index :patients, :country_of_birth_id
7
- add_index :patients, :sent_to_ukrdc_at
8
- add_index :patients, :send_to_renalreg
9
- add_index :patients, :send_to_rpv
10
- add_index :patient_bookmarks, :urgent
11
- add_index :letter_recipients, :emailed_at
12
- add_index :letter_recipients, :printed_at
13
- add_index :hospital_wards, :code
14
- add_index :feed_messages, :patient_identifier
15
- add_index :access_procedures, :performed_by
16
- add_index :patient_ethnicities, :cfh_name
3
+ within_renalware_schema do
4
+ # These indexes where missed as we had used the add_column method passing in index: true
5
+ # but that is not supported so no index was created
6
+ add_index :addresses, :country_id
7
+ add_index :patients, :country_of_birth_id
8
+ add_index :patients, :sent_to_ukrdc_at
9
+ add_index :patients, :send_to_renalreg
10
+ add_index :patients, :send_to_rpv
11
+ add_index :patient_bookmarks, :urgent
12
+ add_index :letter_recipients, :emailed_at
13
+ add_index :letter_recipients, :printed_at
14
+ add_index :hospital_wards, :code
15
+ add_index :feed_messages, :patient_identifier
16
+ add_index :access_procedures, :performed_by
17
+ add_index :patient_ethnicities, :cfh_name
18
+ end
17
19
  end
18
20
  end
@@ -1,17 +1,19 @@
1
1
  class AddMissingForeignKeyIndexes < ActiveRecord::Migration[5.1]
2
2
  # Found using https://github.com/gregnavis/active_record_doctor
3
3
  def change
4
- add_index :drug_types_drugs, :drug_type_id
5
- add_index :hd_stations, :location_id
6
- add_index :letter_contacts, :patient_id
7
- add_index :messaging_messages, :replying_to_message_id
8
- add_index :pathology_observation_descriptions, :measurement_unit_id
9
- add_index :patient_bookmarks, :user_id
10
- add_index(
11
- :pd_peritonitis_episode_types, :peritonitis_episode_type_description_id,
12
- name: "index_pd_peritonitis_episode_types_description_id"
13
- )
14
- add_index :pd_pet_adequacy_results, :patient_id
15
- add_index :roles_users, :role_id
4
+ within_renalware_schema do
5
+ add_index :drug_types_drugs, :drug_type_id
6
+ add_index :hd_stations, :location_id
7
+ add_index :letter_contacts, :patient_id
8
+ add_index :messaging_messages, :replying_to_message_id
9
+ add_index :pathology_observation_descriptions, :measurement_unit_id
10
+ add_index :patient_bookmarks, :user_id
11
+ add_index(
12
+ :pd_peritonitis_episode_types, :peritonitis_episode_type_description_id,
13
+ name: "index_pd_peritonitis_episode_types_description_id"
14
+ )
15
+ add_index :pd_pet_adequacy_results, :patient_id
16
+ add_index :roles_users, :role_id
17
+ end
16
18
  end
17
19
  end
@@ -1,5 +1,11 @@
1
1
  class AddUuidToHDTransmissionLogs < ActiveRecord::Migration[5.1]
2
2
  def change
3
- add_column :hd_transmission_logs, :uuid, :uuid, default: "uuid_generate_v4()", null: false
3
+ within_renalware_schema do
4
+ add_column :hd_transmission_logs,
5
+ :uuid,
6
+ :uuid,
7
+ default: "uuid_generate_v4()",
8
+ null: false
9
+ end
4
10
  end
5
11
  end
@@ -1,7 +1,9 @@
1
1
  class CreateIndexOnLowerPatientFamilyName < ActiveRecord::Migration[5.1]
2
2
  def change
3
- add_index :patients,
4
- "lower(family_name), given_name",
5
- name: "idx_patients_on_lower_family_name"
3
+ within_renalware_schema do
4
+ add_index :patients,
5
+ "lower(family_name), given_name",
6
+ name: "idx_patients_on_lower_family_name"
7
+ end
6
8
  end
7
9
  end
@@ -1,6 +1,10 @@
1
1
  class UpdateHDOverallAuditToVersion8 < ActiveRecord::Migration[5.1]
2
- update_view :reporting_hd_overall_audit,
3
- materialized: true,
4
- version: 8,
5
- revert_to_version: 7
2
+ def change
3
+ within_renalware_schema do
4
+ update_view :reporting_hd_overall_audit,
5
+ materialized: true,
6
+ version: 8,
7
+ revert_to_version: 7
8
+ end
9
+ end
6
10
  end
@@ -1,11 +1,8 @@
1
1
  class CreateDailyReports < ActiveRecord::Migration[5.1]
2
2
  def change
3
- reversible do |direction|
4
- direction.up { connection.execute("SET SEARCH_PATH=renalware,public;") }
5
- direction.down { connection.execute("SET SEARCH_PATH=renalware,public;") }
3
+ within_renalware_schema do
4
+ create_view :reporting_daily_pathology
5
+ create_view :reporting_daily_letters
6
6
  end
7
-
8
- create_view :reporting_daily_pathology
9
- create_view :reporting_daily_letters
10
7
  end
11
8
  end
@@ -1,5 +1,7 @@
1
1
  class AddPageCountToLetters < ActiveRecord::Migration[5.1]
2
2
  def change
3
- add_column :letter_letters, :page_count, :integer
3
+ within_renalware_schema do
4
+ add_column :letter_letters, :page_count, :integer
5
+ end
4
6
  end
5
7
  end
@@ -1,5 +1,7 @@
1
1
  class AddActiveToHospitalWards < ActiveRecord::Migration[5.1]
2
2
  def change
3
- add_column :hospital_wards, :active, :boolean, default: true, null: false
3
+ within_renalware_schema do
4
+ add_column :hospital_wards, :active, :boolean, default: true, null: false
5
+ end
4
6
  end
5
7
  end
@@ -1,6 +1,4 @@
1
1
  class UpdateDailyLettersReportViewToVersion2 < ActiveRecord::Migration[5.2]
2
- include MigrationHelper
3
-
4
2
  def change
5
3
  within_renalware_schema do
6
4
  update_view(
@@ -1,8 +1,4 @@
1
- require "migration_helper"
2
-
3
1
  class CreateReportingDailyUKRDCView < ActiveRecord::Migration[5.2]
4
- include MigrationHelper
5
-
6
2
  def change
7
3
  within_renalware_schema do
8
4
  create_view :reporting_daily_ukrdc
@@ -1,6 +1,4 @@
1
1
  class UpdateReportingDailyPathologyViewToV2 < ActiveRecord::Migration[5.2]
2
- include MigrationHelper
3
-
4
2
  def change
5
3
  within_renalware_schema do
6
4
  update_view(
@@ -1,6 +1,4 @@
1
1
  class AddUKRDCHelperColumnToPatients < ActiveRecord::Migration[5.2]
2
- include MigrationHelper
3
-
4
2
  def change
5
3
  within_renalware_schema do
6
4
  add_column :patients, :checked_for_ukrdc_changes_at, :datetime
@@ -1,8 +1,10 @@
1
1
  class CreateUKRDCBatchNumbers < ActiveRecord::Migration[5.2]
2
2
  def change
3
- create_table "renalware.ukrdc_batch_numbers" do |t|
4
- # no other columns, we just use the id as the batch number when sending data to the UKRDC.
5
- t.timestamps null: false
3
+ within_renalware_schema do
4
+ create_table :ukrdc_batch_numbers do |t|
5
+ # no other columns, we just use the id as the batch number when sending data to the UKRDC.
6
+ t.timestamps null: false
7
+ end
6
8
  end
7
9
  end
8
10
  end
@@ -1,6 +1,4 @@
1
1
  class UpdateHDOverallAuditToVersion9 < ActiveRecord::Migration[5.1]
2
- include MigrationHelper
3
-
4
2
  def change
5
3
  within_renalware_schema do
6
4
  update_view :reporting_hd_overall_audit,
@@ -1,6 +1,4 @@
1
1
  class CreateHDGroupedTransmissionLogsView < ActiveRecord::Migration[5.2]
2
- include MigrationHelper
3
-
4
2
  def change
5
3
  within_renalware_schema do
6
4
  create_view :hd_grouped_transmission_logs
@@ -0,0 +1,7 @@
1
+ class AddWarningsToHDTransmissionLogs < ActiveRecord::Migration[5.2]
2
+ def change
3
+ within_renalware_schema do
4
+ add_column :hd_transmission_logs, :warnings, :string, array: true, default: []
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ class RefreshHDGroupedTransmissionLogsView < ActiveRecord::Migration[5.2]
2
+ def change
3
+ within_renalware_schema do
4
+ drop_view :hd_grouped_transmission_logs
5
+ create_view :hd_grouped_transmission_logs
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,15 @@
1
+ class ChangeUKRDCTransmissionLogErrorType < ActiveRecord::Migration[5.2]
2
+ def up
3
+ within_renalware_schema do
4
+ change_column(:ukrdc_transmission_logs, :error, "text[] USING (string_to_array(error, ','))")
5
+ change_column_default(:ukrdc_transmission_logs, :error, [])
6
+ end
7
+ end
8
+
9
+ def down
10
+ within_renalware_schema do
11
+ change_column(:ukrdc_transmission_logs, :error, :text, array: false)
12
+ change_column_default(:ukrdc_transmission_logs, :error, nil)
13
+ end
14
+ end
15
+ end
@@ -1,6 +1,6 @@
1
1
  "code","name","street_1","street_2","town","postcode"
2
- "603698","GWENT FHSA","UNKNOWN","","","CF1 3PY"
3
- "608698","WEST GLAM FHSA","UNKNOWN","","","CF1 3PY"
2
+ "A03698","GWENT FHSA","UNKNOWN","","","CF1 3PY"
3
+ "A08698","WEST GLAM FHSA","UNKNOWN","","","CF1 3PY"
4
4
  "A81001","THE HEALTH CENTRE","LAWSON STREET","STOCKTON","CLEVELAND","TS18 1HU"
5
5
  "A81002","QUEENS PARK MEDICAL CTR","FARRER STREET","STOCKTON ON TEES","CLEVELAND","TS18 2AW"
6
6
  "A81003","THE HEALTH CENTRE","VICTORIA ROAD","HARTLEPOOL","CLEVELAND","TS26 8DB"
@@ -189,5 +189,5 @@
189
189
  61261,"A81020","G9809758","BARTON HR",22
190
190
  62169,"A81001","G9906600","OLIVER G",3
191
191
  62195,"A81012","G9906868","ADEBAYO AO",14
192
- 62558,603698,"G9986039","GWENT DOCTORS",1
193
- 62563,608698,"G9986084","WEST DOCTORS",2
192
+ 62558,A03698,"G9986039","GWENT DOCTORS",1
193
+ 62563,A08698,"G9986084","WEST DOCTORS",2
@@ -3,6 +3,48 @@
3
3
  module CoreExtensions
4
4
  module ActiveRecord
5
5
  module MigrationHelpers
6
+ # Used in migrations to ensure the objects created/updated/found are in the correct schema.
7
+ # We ensure that the original schema_search_path defined in the database.yml in the host app
8
+ # is restored - this particularyl important for migations in an engine.
9
+ #
10
+ # Within this renalware core engine, use:
11
+ #
12
+ # def change
13
+ # within_renalware_schema do
14
+ # ...make database changes
15
+ # ...any new objects will be created in the renalware schema
16
+ # end
17
+ # end
18
+ #
19
+ # Within another engine eg renalware-diaverum:
20
+ #
21
+ # def change
22
+ # within_renalware_schema(:diaverum) do
23
+ # ...make database changes
24
+ # ...any new objects will be created in the renalware_diaverum schema
25
+ # end
26
+ # end
27
+ #
28
+ # If using from a host app eg renalware_blt (actualy this is optional):
29
+ #
30
+ # def change
31
+ # within_renalware_schema(:blt) do
32
+ # ...make database changes
33
+ # ...any new objects will be created in the renalware_blt schema
34
+ # end
35
+ # end
36
+ def within_renalware_schema(suffix: nil)
37
+ schemas = if suffix.present?
38
+ "renalware_#{suffix},renalware,public"
39
+ else
40
+ "renalware,public"
41
+ end
42
+ original_schema_search_path = connection.schema_search_path
43
+ connection.schema_search_path = schemas
44
+ yield if block_given?
45
+ connection.schema_search_path = original_schema_search_path
46
+ end
47
+
6
48
  # Can be called from a migration to load in a function from a sql file
7
49
  # at e.g. db/functions/my_function_v01.sql
8
50
  #
@@ -59,4 +101,4 @@ module CoreExtensions
59
101
  end
60
102
  end
61
103
 
62
- ActiveRecord::Migration[5.1].send(:prepend, CoreExtensions::ActiveRecord::MigrationHelpers)
104
+ ActiveRecord::Migration.send(:prepend, CoreExtensions::ActiveRecord::MigrationHelpers)