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,6 +1,8 @@
1
1
  class AddLegacyPatientIdToPatients < ActiveRecord::Migration[5.1]
2
2
  def change
3
- add_column :patients, :legacy_patient_id, :integer, null: true
4
- add_index :patients, :legacy_patient_id, unique: true
3
+ within_renalware_schema do
4
+ add_column :patients, :legacy_patient_id, :integer, null: true
5
+ add_index :patients, :legacy_patient_id, unique: true
6
+ end
5
7
  end
6
8
  end
@@ -1,8 +1,10 @@
1
1
  class AddColumnsToDrugDrugs < ActiveRecord::Migration[5.1]
2
2
  def change
3
- # limit: 5 signals a bigint so we can store values like 3546611000001108
4
- add_column :drugs, :vmpid, :integer, limit: 5
5
- add_column :drugs, :description, :string
6
- add_index :drugs, :vmpid, unique: true, name: "idx_drugs_vmpid"
3
+ within_renalware_schema do
4
+ # limit: 5 signals a bigint so we can store values like 3546611000001108
5
+ add_column :drugs, :vmpid, :integer, limit: 5
6
+ add_column :drugs, :description, :string
7
+ add_index :drugs, :vmpid, unique: true, name: "idx_drugs_vmpid"
8
+ end
7
9
  end
8
10
  end
@@ -1,22 +1,24 @@
1
1
  class CreateResearchStudies < ActiveRecord::Migration[5.1]
2
2
  def change
3
- create_table :research_studies do |t|
4
- t.string :code, null: false
5
- t.string :description, null: false, index: true
6
- t.string :leader, index: true
7
- t.text :notes
8
- t.date :started_on
9
- t.date :terminated_on
10
- t.datetime :deleted_at
11
- t.references :updated_by, foreign_key: { to_table: :users }, index: true
12
- t.references :created_by, foreign_key: { to_table: :users }, index: true
13
- t.timestamps null: false
14
- end
3
+ within_renalware_schema do
4
+ create_table :research_studies do |t|
5
+ t.string :code, null: false
6
+ t.string :description, null: false, index: true
7
+ t.string :leader, index: true
8
+ t.text :notes
9
+ t.date :started_on
10
+ t.date :terminated_on
11
+ t.datetime :deleted_at
12
+ t.references :updated_by, foreign_key: { to_table: :users }, index: true
13
+ t.references :created_by, foreign_key: { to_table: :users }, index: true
14
+ t.timestamps null: false
15
+ end
15
16
 
16
- # This create a postgres partial index
17
- add_index :research_studies,
18
- :code,
19
- unique: true,
20
- where: "deleted_at IS NULL"
17
+ # This create a postgres partial index
18
+ add_index :research_studies,
19
+ :code,
20
+ unique: true,
21
+ where: "deleted_at IS NULL"
22
+ end
21
23
  end
22
24
  end
@@ -1,30 +1,32 @@
1
1
  class CreateResearchStudyParticipants < ActiveRecord::Migration[5.1]
2
2
  def change
3
- create_table :research_study_participants do |t|
4
- t.references :participant,
5
- null: false,
6
- foreign_key: { to_table: :patients },
7
- index: true
8
- t.references :study,
9
- null: false,
10
- foreign_key: { to_table: :research_studies },
11
- index: true
12
- t.date :joined_on, null: false
13
- t.date :left_on
14
- t.datetime :deleted_at
15
- t.references :updated_by, foreign_key: { to_table: :users }, index: true
16
- t.references :created_by, foreign_key: { to_table: :users }, index: true
17
- t.timestamps null: false
18
- end
3
+ within_renalware_schema do
4
+ create_table :research_study_participants do |t|
5
+ t.references :participant,
6
+ null: false,
7
+ foreign_key: { to_table: :patients },
8
+ index: true
9
+ t.references :study,
10
+ null: false,
11
+ foreign_key: { to_table: :research_studies },
12
+ index: true
13
+ t.date :joined_on, null: false
14
+ t.date :left_on
15
+ t.datetime :deleted_at
16
+ t.references :updated_by, foreign_key: { to_table: :users }, index: true
17
+ t.references :created_by, foreign_key: { to_table: :users }, index: true
18
+ t.timestamps null: false
19
+ end
19
20
 
20
- # This create a postgres partial index
21
- # A participant can only be enrolled once in a study must be unique in for any unit
22
- # Ignoring any times there were deleted (for example because they were added in error and so
23
- # removed, but subsequently added again)
24
- add_index :research_study_participants,
25
- [:participant_id, :study_id],
26
- name: :unique_study_participants,
27
- unique: true,
28
- where: "deleted_at IS NULL"
21
+ # This create a postgres partial index
22
+ # A participant can only be enrolled once in a study must be unique in for any unit
23
+ # Ignoring any times there were deleted (for example because they were added in error and so
24
+ # removed, but subsequently added again)
25
+ add_index :research_study_participants,
26
+ [:participant_id, :study_id],
27
+ name: :unique_study_participants,
28
+ unique: true,
29
+ where: "deleted_at IS NULL"
30
+ end
29
31
  end
30
32
  end
@@ -1,17 +1,19 @@
1
1
  class SetPatientsSecureId < ActiveRecord::Migration[5.1]
2
2
  def change
3
- remove_column :patients, :secure_id, :string
4
- add_column :patients, :secure_id, :uuid, default: 'uuid_generate_v4()', null: false
5
- add_index :patients, :secure_id, using: :btree, unique: true
3
+ within_renalware_schema do
4
+ remove_column :patients, :secure_id, :string
5
+ add_column :patients, :secure_id, :uuid, default: "uuid_generate_v4()", null: false
6
+ add_index :patients, :secure_id, using: :btree, unique: true
6
7
 
7
- reversible do |direction|
8
- direction.up do
9
- connection.execute(
10
- "DROP FUNCTION IF EXISTS generate_secure_id(integer); \
11
- DROP FUNCTION IF EXISTS generate_patient_secure_id();"
12
- )
8
+ reversible do |direction|
9
+ direction.up do
10
+ connection.execute(
11
+ "DROP FUNCTION IF EXISTS generate_secure_id(integer); \
12
+ DROP FUNCTION IF EXISTS generate_patient_secure_id();"
13
+ )
14
+ end
15
+ # down (reinstating the 2 functions) is not implemented...
13
16
  end
14
- # down (reinstating the 2 functions) is not implemented...
15
17
  end
16
18
  end
17
19
  end
@@ -1,17 +1,19 @@
1
1
  class AddIndexToDiarySlots < ActiveRecord::Migration[5.1]
2
2
  def change
3
- # Scoped to a diary, the combination of day + station + diurnal_period is unique
4
- add_index :hd_diary_slots,
5
- [:diary_id, :station_id, :day_of_week, :diurnal_period_code_id],
6
- name: :hd_diary_slots_unique_by_station_day_period,
7
- unique: true,
8
- where: "deleted_at IS NULL"
3
+ within_renalware_schema do
4
+ # Scoped to a diary, the combination of day + station + diurnal_period is unique
5
+ add_index :hd_diary_slots,
6
+ [:diary_id, :station_id, :day_of_week, :diurnal_period_code_id],
7
+ name: :hd_diary_slots_unique_by_station_day_period,
8
+ unique: true,
9
+ where: "deleted_at IS NULL"
9
10
 
10
- # Scoped to a diary, a patient can only occur once in any combination of day + diurnal_period
11
- add_index :hd_diary_slots,
12
- [:diary_id, :day_of_week, :diurnal_period_code_id, :patient_id],
13
- name: :hd_diary_slots_unique_by_day_period_patient,
14
- unique: true,
15
- where: "deleted_at IS NULL"
11
+ # Scoped to a diary, a patient can only occur once in any combination of day + diurnal_period
12
+ add_index :hd_diary_slots,
13
+ [:diary_id, :day_of_week, :diurnal_period_code_id, :patient_id],
14
+ name: :hd_diary_slots_unique_by_day_period_patient,
15
+ unique: true,
16
+ where: "deleted_at IS NULL"
17
+ end
16
18
  end
17
19
  end
@@ -1,13 +1,15 @@
1
1
  class AddUniqueIndexesToLocalPatientIds < ActiveRecord::Migration[5.1]
2
2
  def change
3
- columns = %i(
4
- local_patient_id
5
- local_patient_id_2
6
- local_patient_id_3
7
- local_patient_id_4
8
- local_patient_id_5
9
- )
10
- columns.each{ |column| remove_index(:patients, column) }
11
- columns.each{ |column| add_index(:patients, column, unique: true) }
3
+ within_renalware_schema do
4
+ columns = %i(
5
+ local_patient_id
6
+ local_patient_id_2
7
+ local_patient_id_3
8
+ local_patient_id_4
9
+ local_patient_id_5
10
+ )
11
+ columns.each{ |column| remove_index(:patients, column) }
12
+ columns.each{ |column| add_index(:patients, column, unique: true) }
13
+ end
12
14
  end
13
15
  end
@@ -1,8 +1,10 @@
1
1
  class UpdateHDOverallAuditView < ActiveRecord::Migration[5.1]
2
2
  def change
3
- update_view :reporting_hd_overall_audit,
4
- materialized: true,
5
- version: 5,
6
- revert_to_version: 4
7
- end
3
+ within_renalware_schema do
4
+ update_view :reporting_hd_overall_audit,
5
+ materialized: true,
6
+ version: 5,
7
+ revert_to_version: 4
8
+ end
9
+ end
8
10
  end
@@ -1,11 +1,13 @@
1
1
  class CreateFunctionToRenderAuditViewAsJson < ActiveRecord::Migration[5.1]
2
2
  def up
3
- load_function("audit_view_as_json_v01.sql")
3
+ within_renalware_schema do
4
+ load_function("audit_view_as_json_v01.sql")
5
+ end
4
6
  end
5
7
 
6
8
  def down
7
- connection.execute(
8
- "DROP FUNCTION IF EXISTS audit_view_as_json(text);"
9
- )
9
+ within_renalware_schema do
10
+ connection.execute("DROP FUNCTION IF EXISTS audit_view_as_json(text);")
11
+ end
10
12
  end
11
13
  end
@@ -1,24 +1,26 @@
1
1
  class CreateConsults < ActiveRecord::Migration[5.1]
2
2
  def change
3
- create_table :admission_consults do |t|
4
- t.references :hospital_unit, foreign_key: true, index: true
5
- t.references :hospital_ward, foreign_key: true, index: true
6
- t.references :patient, foreign_key: true, index: true, null: false
7
- t.references :seen_by, foreign_key: { to_table: :users }, index: true
8
- t.date :started_on
9
- t.date :ended_on
10
- t.date :decided_on
11
- t.date :transferred_on
12
- t.string :transfer_priority
13
- t.string :aki_risk
14
- t.string :consult_type
15
- t.string :contact_number
16
- t.boolean :requires_aki_nurse, default: false, null: false
17
- t.text :description
18
- t.references :updated_by, foreign_key: { to_table: :users }, index: true, null: false
19
- t.references :created_by, foreign_key: { to_table: :users }, index: true, null: false
20
- t.datetime :deleted_at
21
- t.timestamps null: false
3
+ within_renalware_schema do
4
+ create_table :admission_consults do |t|
5
+ t.references :hospital_unit, foreign_key: true, index: true
6
+ t.references :hospital_ward, foreign_key: true, index: true
7
+ t.references :patient, foreign_key: true, index: true, null: false
8
+ t.references :seen_by, foreign_key: { to_table: :users }, index: true
9
+ t.date :started_on
10
+ t.date :ended_on
11
+ t.date :decided_on
12
+ t.date :transferred_on
13
+ t.string :transfer_priority
14
+ t.string :aki_risk
15
+ t.string :consult_type
16
+ t.string :contact_number
17
+ t.boolean :requires_aki_nurse, default: false, null: false
18
+ t.text :description
19
+ t.references :updated_by, foreign_key: { to_table: :users }, index: true, null: false
20
+ t.references :created_by, foreign_key: { to_table: :users }, index: true, null: false
21
+ t.datetime :deleted_at
22
+ t.timestamps null: false
23
+ end
22
24
  end
23
25
  end
24
26
  end
@@ -1,5 +1,7 @@
1
1
  class CreatePDAuditView < ActiveRecord::Migration[5.1]
2
2
  def change
3
- create_view :reporting_pd_audit
3
+ within_renalware_schema do
4
+ create_view :reporting_pd_audit
5
+ end
4
6
  end
5
7
  end
@@ -1,13 +1,15 @@
1
1
  class RemoveLocalPatientIdUniqueIdx < ActiveRecord::Migration[5.1]
2
2
  def change
3
- columns = %i(
4
- local_patient_id
5
- local_patient_id_2
6
- local_patient_id_3
7
- local_patient_id_4
8
- local_patient_id_5
9
- )
10
- columns.each{ |column| remove_index(:patients, column) }
11
- columns.each{ |column| add_index(:patients, column, unique: false) }
3
+ within_renalware_schema do
4
+ columns = %i(
5
+ local_patient_id
6
+ local_patient_id_2
7
+ local_patient_id_3
8
+ local_patient_id_4
9
+ local_patient_id_5
10
+ )
11
+ columns.each{ |column| remove_index(:patients, column) }
12
+ columns.each{ |column| add_index(:patients, column, unique: false) }
13
+ end
12
14
  end
13
15
  end
@@ -1,6 +1,8 @@
1
1
  class AddUuidToHDSessions < ActiveRecord::Migration[5.1]
2
2
  def change
3
- add_column :hd_sessions, :uuid, :uuid, default: 'uuid_generate_v4()', null: false
4
- add_index :hd_sessions, :uuid
3
+ within_renalware_schema do
4
+ add_column :hd_sessions, :uuid, :uuid, default: "uuid_generate_v4()", null: false
5
+ add_index :hd_sessions, :uuid
6
+ end
5
7
  end
6
8
  end
@@ -1,5 +1,7 @@
1
1
  class AddPathologySnapshotToLetters < ActiveRecord::Migration[5.1]
2
2
  def change
3
- add_column :letter_letters, :pathology_timestamp, :datetime
3
+ within_renalware_schema do
4
+ add_column :letter_letters, :pathology_timestamp, :datetime
5
+ end
4
6
  end
5
7
  end
@@ -1,5 +1,7 @@
1
1
  class AddTagsToPatientBookmarks < ActiveRecord::Migration[5.1]
2
2
  def change
3
- add_column :patient_bookmarks, :tags, :string
3
+ within_renalware_schema do
4
+ add_column :patient_bookmarks, :tags, :string
5
+ end
4
6
  end
5
7
  end
@@ -1,5 +1,7 @@
1
1
  class AddIdToRolesUsers < ActiveRecord::Migration[5.1]
2
2
  def change
3
- add_column :roles_users, :id, :primary_key
3
+ within_renalware_schema do
4
+ add_column :roles_users, :id, :primary_key
5
+ end
4
6
  end
5
7
  end
@@ -1,18 +1,19 @@
1
1
  class AddPkToDrugTypesDrugs < ActiveRecord::Migration[5.1]
2
2
  def change
3
-
4
- # Remove the old PK
5
- reversible do |direction|
6
- direction.up do
7
- execute "ALTER TABLE drug_types_drugs DROP CONSTRAINT IF EXISTS drug_types_drugs_pkey"
8
- end
9
- direction.down do
10
- # noop
11
- # ok was on drug_type_id, which is incorrect (duplicates will be found) so leaving
3
+ within_renalware_schema do
4
+ # Remove the old PK
5
+ reversible do |direction|
6
+ direction.up do
7
+ execute "ALTER TABLE drug_types_drugs DROP CONSTRAINT IF EXISTS drug_types_drugs_pkey"
8
+ end
9
+ direction.down do
10
+ # noop
11
+ # ok was on drug_type_id, which is incorrect (duplicates will be found) so leaving
12
+ end
12
13
  end
14
+ add_column :drug_types_drugs, :id, :primary_key
15
+ add_index :drug_types_drugs, [:drug_id, :drug_type_id], unique: true
16
+ add_timestamps :drug_types_drugs, null: true
13
17
  end
14
- add_column :drug_types_drugs, :id, :primary_key
15
- add_index :drug_types_drugs, [:drug_id, :drug_type_id], unique: true
16
- add_timestamps :drug_types_drugs, null: true
17
18
  end
18
19
  end
@@ -1,14 +1,16 @@
1
1
  class CreateRenalVersions < ActiveRecord::Migration[5.1]
2
2
  def change
3
- create_table :renal_versions do |t|
4
- t.string :item_type, :null => false
5
- t.integer :item_id, :null => false
6
- t.string :event, :null => false
7
- t.string :whodunnit
8
- t.jsonb :object
9
- t.jsonb :object_changes
10
- t.datetime :created_at
3
+ within_renalware_schema do
4
+ create_table :renal_versions do |t|
5
+ t.string :item_type, null: false
6
+ t.integer :item_id, null: false
7
+ t.string :event, null: false
8
+ t.string :whodunnit
9
+ t.jsonb :object
10
+ t.jsonb :object_changes
11
+ t.datetime :created_at
12
+ end
13
+ add_index :renal_versions, [:item_type, :item_id]
11
14
  end
12
- add_index :renal_versions, [:item_type, :item_id]
13
15
  end
14
16
  end
@@ -1,5 +1,7 @@
1
1
  class AddRegionToAddresses < ActiveRecord::Migration[5.1]
2
2
  def change
3
- add_column :addresses, :region, :text, index: true
3
+ within_renalware_schema do
4
+ add_column :addresses, :region, :text, index: true
5
+ end
4
6
  end
5
7
  end