renalware-core 2.0.113 → 2.0.115

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +0 -2
  3. data/app/assets/javascripts/renalware/application.js.erb +0 -1
  4. data/app/assets/javascripts/renalware/feed_only_inputs.js.erb +26 -0
  5. data/app/assets/javascripts/renalware/feeds.js +50 -0
  6. data/app/assets/javascripts/renalware/person_ajax_search.js +43 -0
  7. data/app/assets/stylesheets/renalware/application.scss +0 -1
  8. data/app/assets/stylesheets/renalware/modules/_admin.scss +7 -0
  9. data/app/assets/stylesheets/renalware/modules/_pathology.scss +1 -1
  10. data/app/assets/stylesheets/renalware/modules/_patients.scss +6 -0
  11. data/app/assets/stylesheets/renalware/modules/_snippets.scss +2 -2
  12. data/app/assets/stylesheets/renalware/partials/_forms.scss +5 -1
  13. data/app/assets/stylesheets/renalware/partials/_layout.scss +4 -0
  14. data/app/{views/renalware/patients/_side_menu.html.slim → components/renalware/patients/side_menu_component.html.slim} +0 -0
  15. data/app/components/renalware/patients/side_menu_component.rb +18 -0
  16. data/app/controllers/renalware/clinical/body_compositions_controller.rb +6 -0
  17. data/app/controllers/renalware/feeds/hl7_test_messages_controller.rb +60 -0
  18. data/app/controllers/renalware/hd/mdm_patients_controller.rb +16 -6
  19. data/app/controllers/renalware/hd/scheduling/diaries_controller.rb +91 -0
  20. data/app/controllers/renalware/hd/scheduling/diary_slots_controller.rb +169 -0
  21. data/app/controllers/renalware/hd/session_forms/batches_controller.rb +1 -1
  22. data/app/controllers/renalware/pathology/observation_requests_controller.rb +23 -4
  23. data/app/controllers/renalware/pathology/requests/requests_controller.rb +0 -4
  24. data/app/controllers/renalware/patients/abridgements_controller.rb +39 -0
  25. data/app/controllers/renalware/pd/regimes_controller.rb +26 -0
  26. data/app/controllers/renalware/problems/problems_controller.rb +2 -2
  27. data/app/helpers/renalware/application_helper.rb +9 -0
  28. data/app/helpers/renalware/article_helper.rb +18 -0
  29. data/app/helpers/renalware/form_helper.rb +3 -2
  30. data/app/helpers/renalware/users_helper.rb +5 -1
  31. data/app/javascript/controllers/clipboard_controller.js +16 -0
  32. data/app/javascript/packs/renalware_core.js +20 -0
  33. data/app/jobs/feed_job.rb +1 -3
  34. data/app/jobs/hl7_message_example.yml +2 -2
  35. data/app/models/renalware/feeds/files/practice_memberships/import_job.rb +3 -0
  36. data/app/models/renalware/feeds/files/primary_care_physicians/import_job.rb +2 -0
  37. data/app/models/renalware/feeds/hl7_message.rb +57 -6
  38. data/app/models/renalware/feeds/hl7_test_form.rb +10 -0
  39. data/app/models/renalware/feeds/hl7_test_message.rb +11 -0
  40. data/app/models/renalware/feeds/message_parser.rb +6 -2
  41. data/app/models/renalware/feeds/message_processor.rb +44 -32
  42. data/app/models/renalware/feeds/persist_message.rb +9 -3
  43. data/app/models/renalware/feeds.rb +2 -0
  44. data/app/models/renalware/hd/scheduling/archive_arguments.rb +19 -0
  45. data/app/models/renalware/hd/scheduling/diary.rb +54 -0
  46. data/app/models/renalware/hd/scheduling/diary_housekeeping_job.rb +84 -0
  47. data/app/models/renalware/hd/scheduling/diary_range.rb +69 -0
  48. data/app/models/renalware/hd/scheduling/diary_slot.rb +88 -0
  49. data/app/models/renalware/hd/scheduling/find_or_create_diary_by_week_query.rb +52 -0
  50. data/app/models/renalware/hd/scheduling/find_or_create_master_diary.rb +27 -0
  51. data/app/models/renalware/hd/scheduling/master_diary.rb +35 -0
  52. data/app/models/renalware/hd/scheduling/weekly_diary.rb +47 -0
  53. data/app/models/renalware/pathology/message_listener.rb +2 -2
  54. data/app/models/renalware/pathology/requests/global_rule/latest_crf_older_than_weeks.rb +38 -0
  55. data/app/models/renalware/pathology/requests/global_rule/patient_is_diabetic.rb +1 -1
  56. data/app/models/renalware/patient.rb +1 -1
  57. data/app/models/renalware/patients/abridgement.rb +18 -0
  58. data/app/models/renalware/patients/abridgement_search_form.rb +12 -0
  59. data/app/models/renalware/patients/ingestion/command.rb +25 -0
  60. data/app/models/renalware/patients/ingestion/command_factory.rb +135 -0
  61. data/app/models/renalware/patients/ingestion/commands/add_or_update_patient.rb +65 -0
  62. data/app/models/renalware/patients/ingestion/message_listener.rb +21 -0
  63. data/app/models/renalware/patients/ingestion/message_mapper.rb +26 -0
  64. data/app/models/renalware/patients/ingestion/message_mappers/patient.rb +73 -0
  65. data/app/models/renalware/patients/ingestion/update_master_patient_index.rb +60 -0
  66. data/app/models/renalware/patients/ingestion/update_master_patient_index_job.rb.dead +20 -0
  67. data/app/models/renalware/patients.rb +4 -3
  68. data/app/models/renalware/problems/problem.rb +6 -2
  69. data/app/models/renalware/ukrdc/incoming/paths.rb +6 -7
  70. data/app/policies/renalware/admin/devops_policy.rb +18 -0
  71. data/app/policies/renalware/hd/{diary_policy.rb → scheduling/diary_policy.rb} +3 -1
  72. data/app/presenters/renalware/clinical/profile_presenter.rb +2 -1
  73. data/app/presenters/renalware/directory/person_auto_complete_presenter.rb +1 -1
  74. data/app/presenters/renalware/hd/scheduling/diary_presenter.rb +84 -0
  75. data/app/presenters/renalware/hd/scheduling/diary_slot_presenter.rb +74 -0
  76. data/app/presenters/renalware/hd/scheduling/null_slot.rb +42 -0
  77. data/app/presenters/renalware/pd/dashboard_presenter.rb +3 -2
  78. data/app/views/renalware/accesses/procedures/_form.html.slim +5 -1
  79. data/app/views/renalware/accesses/procedures/_list.html.slim +11 -4
  80. data/app/views/renalware/accesses/procedures/show.html.slim +17 -19
  81. data/app/views/renalware/addresses/_form.html.slim +17 -12
  82. data/app/views/renalware/admin/cache/show.html.slim +24 -0
  83. data/app/views/renalware/clinical/body_compositions/_list.html.slim +7 -43
  84. data/app/views/renalware/clinical/body_compositions/_table.html.slim +42 -0
  85. data/app/views/renalware/clinical/body_compositions/index.html.slim +9 -0
  86. data/app/views/renalware/clinical/dry_weights/_list.html.slim +2 -8
  87. data/app/views/renalware/clinical/dry_weights/_table.html.slim +7 -0
  88. data/app/views/renalware/clinical/profiles/show.html.slim +4 -2
  89. data/app/views/renalware/feeds/hl7_test_messages/create.js.erb +10 -0
  90. data/app/views/renalware/feeds/hl7_test_messages/new.slim +18 -0
  91. data/app/views/renalware/hd/mdm_patients/_filters.html.slim +0 -11
  92. data/app/views/renalware/hd/mdm_patients/_page_actions.html.slim +29 -0
  93. data/app/views/renalware/hd/mdm_patients/index.html.slim +7 -4
  94. data/app/views/renalware/hd/{diaries → scheduling/diaries}/_page_actions.html.slim +4 -4
  95. data/app/views/renalware/hd/{diaries → scheduling/diaries}/_table.html.slim +0 -0
  96. data/app/views/renalware/hd/{diaries → scheduling/diaries}/_weekly_diary.html.slim +1 -1
  97. data/app/views/renalware/hd/{diaries → scheduling/diaries}/edit.html.slim +6 -6
  98. data/app/views/renalware/hd/{diaries → scheduling/diaries}/index.html.slim +0 -0
  99. data/app/views/renalware/hd/{diaries → scheduling/diaries}/show.pdf.slim +0 -0
  100. data/app/views/renalware/hd/{diary_slots → scheduling/diary_slots}/_form.html.slim +15 -6
  101. data/app/views/renalware/hd/{diary_slots → scheduling/diary_slots}/_slot.html.slim +2 -2
  102. data/app/views/renalware/hd/{diary_slots → scheduling/diary_slots}/_tab.html.slim +1 -1
  103. data/app/views/renalware/hd/{diary_slots → scheduling/diary_slots}/create.js.erb +1 -1
  104. data/app/views/renalware/hd/{diary_slots → scheduling/diary_slots}/destroy.js.erb +1 -1
  105. data/app/views/renalware/hd/{diary_slots → scheduling/diary_slots}/edit.html.slim +2 -2
  106. data/app/views/renalware/hd/{diary_slots → scheduling/diary_slots}/new.html.slim +0 -0
  107. data/app/views/renalware/hd/{diary_slots → scheduling/diary_slots}/new.js.erb +0 -0
  108. data/app/views/renalware/hd/{diary_slots → scheduling/diary_slots}/show.js.erb +0 -0
  109. data/app/views/renalware/hd/{diary_slots → scheduling/diary_slots}/update.js.erb +1 -1
  110. data/app/views/renalware/hospitals/units/index.html.slim +2 -2
  111. data/app/views/renalware/layouts/_patient.html.slim +2 -1
  112. data/app/views/renalware/letters/contacts/_form.html.slim +10 -13
  113. data/app/views/renalware/letters/letters/_form.html.slim +2 -9
  114. data/app/views/renalware/navigation/_developer.html.slim +4 -0
  115. data/app/views/renalware/navigation/_menu.html.slim +2 -0
  116. data/app/views/renalware/pathology/observation_requests/_filters.html.slim +17 -0
  117. data/app/views/renalware/pathology/observation_requests/index.html.slim +2 -1
  118. data/app/views/renalware/patients/_layout.html.slim +1 -1
  119. data/app/views/renalware/patients/_side_menu.html.slim.dead +7 -0
  120. data/app/views/renalware/patients/abridgements/_abridgement.html.slim +8 -0
  121. data/app/views/renalware/patients/abridgements/_table.html.slim +12 -0
  122. data/app/views/renalware/patients/abridgements/index.html.slim +22 -0
  123. data/app/views/renalware/patients/alerts/create.json +3 -0
  124. data/app/views/renalware/patients/patients/_form.html.slim +36 -17
  125. data/app/views/renalware/patients/patients/edit.html.slim +1 -1
  126. data/app/views/renalware/patients/patients/new.html.slim +1 -1
  127. data/app/views/renalware/patients/side_menu/_actions.html.slim +2 -0
  128. data/app/views/renalware/pd/_apd_regimes.html.slim +1 -1
  129. data/app/views/renalware/pd/_capd_regimes.html.slim +1 -1
  130. data/app/views/renalware/pd/dashboards/show/_apd_regimes.html.slim +11 -2
  131. data/app/views/renalware/pd/dashboards/show/_capd_regimes.html.slim +11 -2
  132. data/app/views/renalware/pd/regimes/index.html.slim +7 -0
  133. data/app/views/renalware/renal/profiles/_form.html.slim +7 -24
  134. data/app/views/renalware/shared/documents/_binary_marker_input.html.slim +2 -2
  135. data/app/views/renalware/shared/documents/_blood_group_input.html.slim +4 -2
  136. data/app/views/renalware/transplants/registrations/_form.html.slim +22 -17
  137. data/config/locales/renalware/clinical/body_composition.yml +6 -3
  138. data/config/locales/renalware/clinical/dry_weight.en.yml +4 -3
  139. data/config/locales/renalware/hd/diary_slots.en.yml +3 -2
  140. data/config/locales/renalware/letters/contact.en.yml +0 -2
  141. data/config/routes/feeds.rb +5 -0
  142. data/config/routes/hd.rb +11 -7
  143. data/config/routes/letters.rb +0 -5
  144. data/config/routes/patients.rb +1 -0
  145. data/config/routes/pd.rb +2 -2
  146. data/config/routes/renal.rb +0 -5
  147. data/config/routes.rb +1 -0
  148. data/config/webpack/development.js +5 -0
  149. data/config/webpack/environment.js +3 -0
  150. data/config/webpack/production.js +5 -0
  151. data/config/webpack/test.js +5 -0
  152. data/config/webpacker.yml +103 -0
  153. data/db/functions/hd_diary_archive_elapsed_master_slots_v01.sql +40 -0
  154. data/db/migrate/20190322120025_create_feed_hl7_test_messages.rb +12 -0
  155. data/db/migrate/20190325134823_create_patients_master_index.rb +24 -0
  156. data/db/migrate/20190327100851_add_handled_to_feed_messages.rb +5 -0
  157. data/db/migrate/20191012121433_add_consultant_to_users.rb +7 -0
  158. data/db/migrate/20191018143635_create_hd_diary_matrix_view.rb +7 -0
  159. data/db/migrate/20191018144917_create_fn_to_archive_master_slots.rb +9 -0
  160. data/db/views/hd_diary_matrix_v01.sql +38 -0
  161. data/lib/core_extensions/active_record/sort.rb +27 -9
  162. data/lib/renalware/configuration.rb +3 -0
  163. data/lib/renalware/engine.rb +31 -0
  164. data/lib/renalware/version.rb +1 -1
  165. data/lib/renalware/week_period.rb +8 -7
  166. data/lib/renalware.rb +13 -1
  167. data/lib/tasks/hd.rake +7 -0
  168. data/lib/tasks/pathology.rake +1 -1
  169. data/lib/tasks/renalware.rake +89 -4
  170. data/spec/factories/hd/scheduling/diaries.rb +18 -0
  171. data/spec/factories/hd/{slots.rb → scheduling/slots.rb} +1 -1
  172. data/spec/factories/patients/abridgements.rb +9 -0
  173. data/spec/support/hl7_helpers.rb +13 -0
  174. data/spec/support/pages/letters/form.rb +4 -1
  175. metadata +126 -50
  176. data/app/assets/javascripts/renalware/auto_complete.js +0 -63
  177. data/app/controllers/renalware/hd/diaries_controller.rb +0 -89
  178. data/app/controllers/renalware/hd/diary_slots_controller.rb +0 -175
  179. data/app/controllers/renalware/letters/descriptions_controller.rb +0 -22
  180. data/app/controllers/renalware/renal/prd_descriptions_controller.rb +0 -15
  181. data/app/models/renalware/hd/archive_yesterdays_slots_job.rb +0 -69
  182. data/app/models/renalware/hd/diary.rb +0 -41
  183. data/app/models/renalware/hd/diary_slot.rb +0 -83
  184. data/app/models/renalware/hd/find_or_create_diary_by_week_query.rb +0 -50
  185. data/app/models/renalware/hd/find_or_create_master_diary.rb +0 -26
  186. data/app/models/renalware/hd/master_diary.rb +0 -32
  187. data/app/models/renalware/hd/weekly_diary.rb +0 -45
  188. data/app/models/renalware/renal/prd_descriptions/search_query.rb +0 -35
  189. data/app/presenters/renalware/hd/diary_presenter.rb +0 -79
  190. data/app/presenters/renalware/hd/diary_slot_presenter.rb +0 -72
  191. data/app/presenters/renalware/hd/null_slot.rb +0 -40
  192. data/app/views/renalware/renal/prd_descriptions/search.json.jbuilder +0 -6
  193. data/lib/test_support/autocomplete_helpers.rb +0 -14
  194. data/spec/factories/hd/diaries.rb +0 -14
data/config/routes/hd.rb CHANGED
@@ -41,14 +41,18 @@ namespace :hd do
41
41
  resources :stations do
42
42
  post :sort, on: :collection
43
43
  end
44
- resources :diaries, only: [:index, :show]
45
- get "diaries/:year/:week_number/edit", to: "diaries#edit", as: :edit_diary
46
44
  end
47
- resources :diaries, only: [] do
48
- resources :slots, except: :show, controller: :diary_slots
49
- get "slots/day/:day_of_week/period/:diurnal_period_code_id/station/:station_id",
50
- to: "diary_slots#show",
51
- as: :refresh_slot
45
+ namespace :scheduling do
46
+ resources :units, only: [] do
47
+ resources :diaries, only: [:index, :show]
48
+ get "diaries/:year/:week_number/edit", to: "diaries#edit", as: :edit_diary
49
+ end
50
+ resources :diaries, only: [] do
51
+ resources :slots, except: :show, controller: :diary_slots
52
+ get "slots/day/:day_of_week/period/:diurnal_period_code_id/station/:station_id",
53
+ to: "diary_slots#show",
54
+ as: :refresh_slot
55
+ end
52
56
  end
53
57
  namespace :session_forms do
54
58
  resources :batches, only: [:create, :show] do
@@ -27,11 +27,6 @@ namespace :letters do
27
27
  resources :completions, only: [:new, :create], controller: "completed_batches"
28
28
  end
29
29
  resource :pdf_letter_cache, only: [:destroy], controller: "pdf_letter_cache"
30
- resources :descriptions, only: :search do
31
- collection do
32
- get :search
33
- end
34
- end
35
30
 
36
31
  # Letters::ListsController displays prefined lists of letters. The default list is :all
37
32
  # We want to support dynamic urls with letters_list_path(named_parameeter: :all)
@@ -10,6 +10,7 @@ namespace :patients do
10
10
  only: :index,
11
11
  controller: "practices/primary_care_physicians"
12
12
  end
13
+ resources :abridgements, only: :index
13
14
  end
14
15
 
15
16
  resources :bookmarks, controller: "patients/bookmarks", only: [:destroy, :index]
data/config/routes/pd.rb CHANGED
@@ -6,11 +6,11 @@ resources :patients, only: [] do
6
6
  resources :apd_regimes,
7
7
  controller: "regimes",
8
8
  type: "PD::APDRegime",
9
- only: [:new, :create, :edit, :update, :show]
9
+ only: [:new, :create, :edit, :update, :show, :index]
10
10
  resources :capd_regimes,
11
11
  controller: "regimes",
12
12
  type: "PD::CAPDRegime",
13
- only: [:new, :create, :edit, :update, :show]
13
+ only: [:new, :create, :edit, :update, :show, :index]
14
14
  resources :regimes, only: [:new, :create, :edit, :update, :show]
15
15
  resources :peritonitis_episodes, only: [:new, :create, :show, :edit, :update]
16
16
  resources :exit_site_infections, only: [:new, :create, :show, :edit, :update]
@@ -7,11 +7,6 @@ resources :patients, only: [] do
7
7
  end
8
8
 
9
9
  namespace :renal do
10
- resources :prd_descriptions, only: [:search] do
11
- collection do
12
- get :search
13
- end
14
- end
15
10
  resources :aki_alerts, only: [:edit, :update, :index]
16
11
  resources :registry_preflight_checks, only: [] do
17
12
  collection do
data/config/routes.rb CHANGED
@@ -11,6 +11,7 @@ Renalware::Engine.routes.draw do
11
11
  draw :directory
12
12
  draw :drugs
13
13
  draw :events
14
+ draw :feeds
14
15
  draw :hd
15
16
  draw :hospitals
16
17
  draw :letters
@@ -0,0 +1,5 @@
1
+ process.env.NODE_ENV = process.env.NODE_ENV || 'development'
2
+
3
+ const environment = require('./environment')
4
+
5
+ module.exports = environment.toWebpackConfig()
@@ -0,0 +1,3 @@
1
+ const { environment } = require('@rails/webpacker')
2
+
3
+ module.exports = environment
@@ -0,0 +1,5 @@
1
+ process.env.NODE_ENV = process.env.NODE_ENV || 'production'
2
+
3
+ const environment = require('./environment')
4
+
5
+ module.exports = environment.toWebpackConfig()
@@ -0,0 +1,5 @@
1
+ process.env.NODE_ENV = process.env.NODE_ENV || 'development'
2
+
3
+ const environment = require('./environment')
4
+
5
+ module.exports = environment.toWebpackConfig()
@@ -0,0 +1,103 @@
1
+ # Note: You must restart bin/webpack-dev-server for changes to take effect
2
+
3
+ default: &default
4
+ source_path: app/javascript
5
+ source_entry_path: packs
6
+ # public_root_path: /Users/tim/Sites/airslie/renalware/renalwarev2/spec/dummy/public
7
+ public_root_path: public
8
+ public_output_path: renalware-core-packs
9
+ cache_path: tmp/cache/webpacker
10
+ check_yarn_integrity: false
11
+ webpack_compile_output: true
12
+
13
+ # Additional paths webpack should lookup modules
14
+ # ['app/assets', 'engine/foo/app/assets']
15
+ resolved_paths: []
16
+
17
+ # Reload manifest.json on all requests so we reload latest compiled packs
18
+ cache_manifest: false
19
+
20
+ # Extract and emit a css file
21
+ extract_css: false
22
+
23
+ static_assets_extensions:
24
+ - .jpg
25
+ - .jpeg
26
+ - .png
27
+ - .gif
28
+ - .tiff
29
+ - .ico
30
+ - .svg
31
+ - .eot
32
+ - .otf
33
+ - .ttf
34
+ - .woff
35
+ - .woff2
36
+
37
+ extensions:
38
+ - .mjs
39
+ - .js
40
+ - .sass
41
+ - .scss
42
+ - .css
43
+ - .module.sass
44
+ - .module.scss
45
+ - .module.css
46
+ - .png
47
+ - .svg
48
+ - .gif
49
+ - .jpeg
50
+ - .jpg
51
+
52
+ development:
53
+ <<: *default
54
+ compile: true
55
+
56
+ # Verifies that correct packages and versions are installed by inspecting package.json, yarn.lock, and node_modules
57
+ check_yarn_integrity: false
58
+
59
+ # Reference: https://webpack.js.org/configuration/dev-server/
60
+ dev_server:
61
+ https: false
62
+ host: localhost
63
+ port: 3035
64
+ public: localhost:3035
65
+ hmr: false
66
+ # Inline should be set to true if using HMR
67
+ inline: true
68
+ overlay: true
69
+ compress: true
70
+ disable_host_check: true
71
+ use_local_ip: false
72
+ quiet: false
73
+ headers:
74
+ 'Access-Control-Allow-Origin': '*'
75
+ watch_options:
76
+ ignored: '**/node_modules/**'
77
+
78
+
79
+ test:
80
+ <<: *default
81
+ compile: true
82
+
83
+ # Compile test packs to a separate directory
84
+ # public_output_path: packs-test
85
+
86
+ staging:
87
+ <<: *default
88
+
89
+ compile: false
90
+ extract_css: true
91
+ cache_manifest: true
92
+
93
+ production:
94
+ <<: *default
95
+
96
+ # Production depends on precompilation of packs prior to booting for performance.
97
+ compile: false
98
+
99
+ # Extract and emit a css file
100
+ extract_css: true
101
+
102
+ # Cache manifest.json for performance
103
+ cache_manifest: true
@@ -0,0 +1,40 @@
1
+ CREATE OR REPLACE FUNCTION renalware.hd_diary_archive_elapsed_master_slots()
2
+ RETURNS void
3
+ AS $$
4
+ BEGIN
5
+
6
+ INSERT into hd_diary_slots
7
+ (
8
+ diary_id,
9
+ station_id,
10
+ day_of_week,
11
+ diurnal_period_code_id,
12
+ patient_id,
13
+ created_by_id,
14
+ updated_by_id,
15
+ created_at,
16
+ updated_at,
17
+ deleted_at
18
+ )
19
+ (
20
+ select
21
+ weekly_diary_id,
22
+ station_id,
23
+ day_of_week,
24
+ diurnal_period_code_id,
25
+ patient_id,
26
+ master_slot_created_by_id,
27
+ master_slot_updated_by_id,
28
+ master_slot_created_at,
29
+ master_slot_updated_at,
30
+ deleted_at
31
+ from renalware.hd_diary_matrix -- a SQL view
32
+ where
33
+ weekly_slot_id is null
34
+ and master_slot_id is not null
35
+ and master_slot_created_at <= slot_date
36
+ and slot_date >= now() - interval '3 months'
37
+ );
38
+
39
+ END;
40
+ $$ LANGUAGE plpgsql;
@@ -0,0 +1,12 @@
1
+ class CreateFeedHL7TestMessages < ActiveRecord::Migration[5.2]
2
+ def change
3
+ within_renalware_schema do
4
+ create_table :feed_hl7_test_messages do |t|
5
+ t.string :name, null: false, index: true
6
+ t.string :description
7
+ t.text :body, null: false
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,24 @@
1
+ class CreatePatientsMasterIndex < ActiveRecord::Migration[5.2]
2
+ def change
3
+ create_table :patient_master_index do |t|
4
+ t.references :patient, null: true, foreign_key: true
5
+ t.timestamps null: false
6
+ t.string :nhs_number, index: true
7
+ t.string :hospital_number, index: true
8
+ t.string :title
9
+ t.string :family_name
10
+ t.string :middle_name
11
+ t.string :given_name
12
+ t.string :suffix
13
+ t.string :sex
14
+ t.date :born_on
15
+ t.datetime :died_at
16
+ t.string :ethnicity
17
+ t.string :practice_code
18
+ t.string :gp_code
19
+ t.timestamps null: false
20
+ end
21
+
22
+ add_index :patient_master_index, [:family_name, :given_name]
23
+ end
24
+ end
@@ -0,0 +1,5 @@
1
+ class AddHandledToFeedMessages < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_column :feed_messages, :processed, :boolean, default: false
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ class AddConsultantToUsers < ActiveRecord::Migration[5.2]
2
+ def change
3
+ within_renalware_schema do
4
+ add_column :users, :consultant, :boolean, default: false, null: false, index: true
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ class CreateHDDiaryMatrixView < ActiveRecord::Migration[5.2]
2
+ def change
3
+ within_renalware_schema do
4
+ create_view :hd_diary_matrix
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ class CreateFnToArchiveMasterSlots < ActiveRecord::Migration[5.2]
2
+ def up
3
+ load_function("hd_diary_archive_elapsed_master_slots_v01.sql")
4
+ end
5
+
6
+ def down
7
+ connection.execute("DROP FUNCTION IF EXISTS hd_diary_archive_elapsed_master_slots();")
8
+ end
9
+ end
@@ -0,0 +1,38 @@
1
+ -- First build a matrix of 'virtual' empty slots - by creating a cartesian product
2
+ -- of weeks in the last year, unit, stations, days and periods (am pm eve)
3
+ -- This can creates 50,0000+ rows
4
+ with hd_empty_diary_matrix as (
5
+ SELECT
6
+ extract(YEAR from the_date) as year,
7
+ extract(WEEK from the_date) as week_number,
8
+ h.id as hospital_unit_id,
9
+ s.id as station_id,
10
+ day_of_week,
11
+ period.id as diurnal_period_code_id
12
+ from generate_series(now() - interval '1 year', now() - interval '1 week', '1 week') as the_date
13
+ cross join hospital_units h
14
+ cross join hd_stations s
15
+ CROSS JOIN (SELECT generate_series(1, 7) AS day_of_week) as A
16
+ CROSS JOIN hd_diurnal_period_codes period
17
+ where h.is_hd_site = TRUE
18
+ order by year, week_number, hospital_unit_id, station_id, day_of_week, diurnal_period_code_id
19
+ )
20
+ -- Now decorate the previous query by adding columns for the slots (master and weekly) that we actually have
21
+ select
22
+ M.*
23
+ ,WD.id as weekly_diary_id
24
+ ,MD.id as master_diary_id
25
+ ,WS.id as weekly_slot_id
26
+ ,MS.id as master_slot_id
27
+ ,coalesce(WS.patient_id, MS.patient_id) as patient_id
28
+ ,MS.deleted_at
29
+ ,MS.created_by_id as master_slot_created_by_id
30
+ ,MS.updated_by_id as master_slot_updated_by_id
31
+ ,MS.created_at::date as master_slot_created_at
32
+ ,MS.updated_at::date as master_slot_updated_at
33
+ ,to_date(WD.year::text || '-' || WD.week_number::text || '-' || MS.day_of_week::text , 'iyyy-iw-ID') slot_date
34
+ from hd_empty_diary_matrix M
35
+ left outer join hd_diaries WD on WD.hospital_unit_id = M.hospital_unit_id AND WD.year = M.year AND WD.week_number = M.week_number AND WD.master = false
36
+ left outer join hd_diaries MD on MD.hospital_unit_id = M.hospital_unit_id AND MD.master = true
37
+ left outer join hd_diary_slots WS on WS.diary_id = WD.id AND WS.station_id = M.station_id and WS.day_of_week = M.day_of_week AND WS.diurnal_period_code_id = M.diurnal_period_code_id
38
+ left outer join hd_diary_slots MS on MS.diary_id = MD.id AND MS.station_id = M.station_id and MS.day_of_week = M.day_of_week AND MS.diurnal_period_code_id = M.diurnal_period_code_id
@@ -1,14 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Adds a sort method to ActiveRecord class. Given a list of IDs, it will sort
4
- # the records in the order of the ids. Assumes that the model has the :position attribute.
5
- #
6
- # ActiveRecord::Base.class_eval do
7
- # include RailsExtensions::ActiveRecord::Sort
8
- # end
9
-
10
3
  module CoreExtensions
11
4
  module ActiveRecord
5
+ # Assumes that the model has the #position attribute and adds 2 features to a model that
6
+ # includes it:
7
+ # 1. Set the :position to the next highest value when a new row is added. If the model has a
8
+ # position_sorting_scope scope or class method, this is used to narrow the range of records
9
+ # searched when finding the current max position
10
+ # 2. Add ability to sort rows based on an array of ids.
11
+ #
12
+ # TODO: move to a model concern and include selectively rather than globally.
12
13
  module Sort
13
14
  def self.included(base)
14
15
  base.extend ClassMethods
@@ -17,17 +18,34 @@ module CoreExtensions
17
18
  end
18
19
 
19
20
  module ClassMethods
21
+ # A controller #sort action might for instance invoke this class method on an object.
22
+ # The array of ids are the model to sort, and sorting is done by updating each model's
23
+ # position to reflect their place in the array.
20
24
  def sort(ids)
21
- ids.each_with_index do |id, index|
25
+ Array(ids).each_with_index do |id, index|
22
26
  where(id: id).update_all(["position=?", index + 1])
23
27
  end
24
28
  end
25
29
  end
26
30
 
31
+ # Invoked by the callback when a record is created to set the initial value of #position.
32
+ # If no position_sorting_scope is defined on the model class, we set position to the max
33
+ # position in the whole table. If position_sorting_scope is provided we use it to refine the
34
+ # grouping and hence the max(position) found - for example to get the max position where
35
+ # patient_id = 123
36
+ #
37
+ # Example scope in a model:
38
+ # scope :position_sorting_scope, ->(problem) { where(patient_id: problem.patient.id) }
39
+ #
27
40
  def set_position
28
41
  return unless respond_to?(:position)
29
42
 
30
- self.position = (self.class.where("position < 99999").maximum(:position) || 0) + 1
43
+ scope = if self.class.respond_to?(:position_sorting_scope)
44
+ self.class.position_sorting_scope(self)
45
+ else
46
+ self.class
47
+ end
48
+ self.position = (scope.maximum(:position) || 0) + 1
31
49
  end
32
50
  end
33
51
  end
@@ -86,6 +86,9 @@ module Renalware
86
86
 
87
87
  config_accessor(:hd_session_prescriptions_require_signoff) { true }
88
88
  config_accessor(:batch_printing_enabled) { true }
89
+ config_accessor(:generate_pathology_request_forms_from_hd_mdm_listing) { true }
90
+ config_accessor(:disable_inputs_controlled_by_tissue_typing_feed) { false }
91
+ config_accessor(:disable_inputs_controlled_by_demographics_feed) { false }
89
92
 
90
93
  # A host app can override this to add/remove/re-order the clinical summary display
91
94
  # Note these have to be strings - they mapped to constants in ClinicalSummaryPresenter.
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "rubygems"
4
+ require "action_view/component/base"
4
5
  require "active_type"
5
6
  require "activerecord-import"
6
7
  require "ahoy"
@@ -49,8 +50,10 @@ require "sass-rails"
49
50
  require "scenic"
50
51
  require "slim-rails"
51
52
  require "trix"
53
+ require "uglifier"
52
54
  require "validates_timeliness"
53
55
  require "virtus"
56
+ require "webpacker"
54
57
  require "wicked_pdf"
55
58
  require "wisper"
56
59
  require "wisper/activejob"
@@ -62,9 +65,36 @@ module Renalware
62
65
  # This will keep Rails Engine from generating all table prefixes with the engines name
63
66
  def self.table_name_prefix; end
64
67
 
68
+ # rubocop:disable Metrics/ClassLength
65
69
  class Engine < ::Rails::Engine
66
70
  isolate_namespace Renalware
67
71
 
72
+ # Configure webpacker dev server proxy
73
+ # rubocop:disable Style/RescueStandardError
74
+ initializer "webpacker.proxy" do |app|
75
+ insert_middleware = begin
76
+ Renalware.webpacker.config.dev_server.present?
77
+ rescue
78
+ nil
79
+ end
80
+ next unless insert_middleware
81
+
82
+ app.middleware.insert_before(
83
+ 0, Webpacker::DevServerProxy, # "Webpacker::DevServerProxy" if Rails version < 5
84
+ ssl_verify_none: true,
85
+ webpacker: Renalware.webpacker
86
+ )
87
+ end
88
+ # rubocop:enable Style/RescueStandardError
89
+
90
+ # Allow the host app to consume webpacker-compiled packs in the engine's public folder.
91
+ initializer :packs do |_app|
92
+ config.app_middleware.use(
93
+ Rack::Static,
94
+ urls: ["/renalware-core-packs"], root: Engine.root.join("public")
95
+ )
96
+ end
97
+
68
98
  # Define a attr on the Engine's eigenclass so a host application
69
99
  # can set an exception handler instance. It must accept a .notify(excetion) method.
70
100
  # We use the exception handler when logging errors in background jobs only.
@@ -192,3 +222,4 @@ module Renalware
192
222
  end
193
223
  end
194
224
  end
225
+ # rubocop:enable Metrics/ClassLength
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Renalware
4
- VERSION = "2.0.113"
4
+ VERSION = "2.0.115"
5
5
  end
@@ -2,11 +2,11 @@
2
2
 
3
3
  module Renalware
4
4
  class WeekPeriod
5
- attr_reader :year, :week_number, :first_day_of_week
5
+ attr_reader :year, :week_number, :date_on_first_day_of_week
6
6
 
7
7
  def self.from_date(date)
8
8
  date = date.to_date
9
- new(week_number: date.cweek, year: date.year)
9
+ new(week_number: date.cweek, year: date.cwyear)
10
10
  end
11
11
 
12
12
  def initialize(week_number:, year:)
@@ -14,15 +14,15 @@ module Renalware
14
14
  @year = year.to_i
15
15
  validate_week_number
16
16
  validate_year
17
- @first_day_of_week = Date.commercial(@year, @week_number)
17
+ @date_on_first_day_of_week = Date.commercial(@year, @week_number)
18
18
  end
19
19
 
20
20
  def next
21
- self.class.from_date(first_day_of_week + 1.week)
21
+ self.class.from_date(date_on_first_day_of_week + 1.week)
22
22
  end
23
23
 
24
24
  def previous
25
- self.class.from_date(first_day_of_week - 1.week)
25
+ self.class.from_date(date_on_first_day_of_week - 1.week)
26
26
  end
27
27
 
28
28
  def to_a
@@ -30,12 +30,13 @@ module Renalware
30
30
  end
31
31
 
32
32
  def to_s
33
- "#{I18n.l(first_day_of_week, format: :long)} to #{I18n.l(last_day_of_week, format: :long)}"
33
+ "#{I18n.l(date_on_first_day_of_week, format: :long)} " \
34
+ "to #{I18n.l(last_day_of_week, format: :long)}"
34
35
  end
35
36
 
36
37
  # The date of last day of the week (a Sunday)
37
38
  def last_day_of_week
38
- @last_day_of_week ||= (first_day_of_week + 1.week - 1.minute).to_date
39
+ @last_day_of_week ||= (date_on_first_day_of_week + 1.week - 1.minute).to_date
39
40
  end
40
41
 
41
42
  def validate_week_number
data/lib/renalware.rb CHANGED
@@ -4,5 +4,17 @@ require "renalware/engine"
4
4
  require "renalware/configuration"
5
5
 
6
6
  module Renalware
7
- # Your code goes here...
7
+ # Configure Webpacker instance.
8
+ # See https://github.com/rails/webpacker/blob/master/docs/engines.md
9
+ class << self
10
+ def webpacker
11
+ @webpacker ||= begin
12
+ root_path = Pathname.new(File.join(__dir__, ".."))
13
+ ::Webpacker::Instance.new(
14
+ root_path: root_path,
15
+ config_path: root_path.join("config/webpacker.yml")
16
+ )
17
+ end
18
+ end
19
+ end
8
20
  end
data/lib/tasks/hd.rake CHANGED
@@ -12,4 +12,11 @@ namespace :hd do
12
12
  performed_before: 3.days.ago
13
13
  )
14
14
  end
15
+
16
+ namespace :diary do
17
+ task housekeeping: :environment do
18
+ Rails.logger = Logger.new(STDOUT)
19
+ Delayed::Job.enqueue Renalware::HD::Scheduling::ArchiveYesterdaysSlotsJob.new
20
+ end
21
+ end
15
22
  end
@@ -23,7 +23,7 @@ namespace :pathology do
23
23
  # Load the message into a hash as delayed_Job would do and splat the hash keys as keyword args
24
24
  # into the FeedJob ctor.
25
25
  hash = YAML.safe_load(*raw_message).symbolize_keys
26
- FeedJob.new(hash[:raw_message]).perform
26
+ Delayed::Job.enqueue FeedJob.new(hash[:raw_message])
27
27
  end
28
28
 
29
29
  desc "In development only, enqueue a test HL7 message"