renalware-core 2.0.0.pre.rc8 → 2.0.0.pre.rc9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/renalware/modules/_clinical.scss +73 -0
  3. data/app/models/concerns/renalware/clinics/most_recent_measurement_scopes.rb.dead +43 -0
  4. data/app/models/renalware/clinics/clinic_visit.rb +2 -2
  5. data/app/models/renalware/clinics/current_observations.rb +57 -0
  6. data/app/models/renalware/letters/letter.rb +5 -1
  7. data/app/models/renalware/pathology/current_observation_set.rb +6 -0
  8. data/app/models/renalware/pathology/observation.rb +1 -0
  9. data/app/models/renalware/pathology/observation_request.rb +3 -0
  10. data/app/models/renalware/pathology/observations_jsonb_serializer.rb +7 -6
  11. data/app/models/renalware/pathology/{view_current_observation_results.rb → view_current_observation_results.rb.dead} +0 -0
  12. data/app/presenters/renalware/clinical/header_presenter.rb +33 -0
  13. data/app/presenters/renalware/letters/letter_presenter.rb +5 -1
  14. data/app/presenters/renalware/letters/part_class_filter.rb +36 -0
  15. data/app/presenters/renalware/renal/clinical_summary_presenter.rb +0 -1
  16. data/app/presenters/renalware/ukrdc/patient_presenter.rb +8 -2
  17. data/app/values/renalware/bmi.rb +20 -0
  18. data/app/views/renalware/admissions/consults/_table.html.slim +1 -1
  19. data/app/views/renalware/api/ukrdc/patients/_clinic_visit_observation.xml.builder +1 -1
  20. data/app/views/renalware/api/ukrdc/patients/_lab_orders.xml.builder +3 -3
  21. data/app/views/renalware/api/ukrdc/patients/_observations.xml.builder +3 -1
  22. data/app/views/renalware/api/ukrdc/patients/lab_orders/_lab_order.xml.builder +2 -2
  23. data/app/views/renalware/api/ukrdc/patients/lab_orders/_result_item.xml.builder +7 -2
  24. data/app/views/renalware/clinical/_header.html.slim +47 -0
  25. data/app/views/renalware/clinics/clinic_visits/_table.html.slim +0 -1
  26. data/app/views/renalware/clinics/visits/_table.html.slim +4 -1
  27. data/app/views/renalware/events/events/_event.html.slim +1 -1
  28. data/app/views/renalware/events/events/_table.html.slim +3 -0
  29. data/app/views/renalware/layouts/_patient.html.slim +1 -0
  30. data/app/views/renalware/letters/letters/_form.html.slim +1 -1
  31. data/app/views/renalware/letters/letters/_pathology.html.slim +0 -1
  32. data/app/views/renalware/mdm_patients/_table.html.slim +1 -1
  33. data/app/views/renalware/pathology/_navigation.html.slim +1 -1
  34. data/app/views/renalware/patients/patients/_table.html.slim +2 -2
  35. data/config/initializers/core_extensions.rb +1 -0
  36. data/config/initializers/inflections.rb +1 -0
  37. data/config/locales/renalware/clinical/allergies.en.yml +0 -2
  38. data/config/locales/renalware/clinical/{dry_weight.yml → dry_weight.en.yml} +0 -0
  39. data/config/locales/renalware/clinical/header.en.yml +14 -0
  40. data/db/functions/audit_view_as_json_v01.sql +25 -0
  41. data/db/functions/count_estimate_v01.sql +20 -0
  42. data/db/functions/generate_patient_secure_id_v01.sql +21 -0
  43. data/db/functions/generate_secure_id_v01.sql +18 -0
  44. data/db/functions/import_gps_csv_v01.sql +129 -0
  45. data/db/functions/import_practice_memberships_csv_v01.sql +48 -0
  46. data/db/functions/import_practices_csv_v01.sql +109 -0
  47. data/db/functions/preprocess_hl7_message_v01.sql +29 -0
  48. data/db/functions/preprocess_hl7_message_v02.sql +31 -0
  49. data/db/functions/refresh_all_matierialized_views_v01.sql +32 -0
  50. data/db/functions/refresh_current_observation_set_v01.sql +39 -0
  51. data/db/functions/update_current_observation_set_from_trigger_v01.sql +88 -0
  52. data/db/functions/update_current_observation_set_from_trigger_v02.sql +90 -0
  53. data/db/migrate/20161124152732_add_deleted_at_to_patient_bookmarks.rb +1 -1
  54. data/db/migrate/20170608135553_create_functions_to_generate_secure_patient_id.rb +4 -48
  55. data/db/migrate/20170705090219_create_refresh_all_materialized_views_fn.rb +2 -37
  56. data/db/migrate/20170707110155_rename_access_plans_to_access_plan_types.rb +1 -1
  57. data/db/migrate/20170831142819_enable_crosstab_extension.rb +2 -2
  58. data/db/migrate/20170911133224_add_type_to_messaging_messages.rb +1 -1
  59. data/db/migrate/20170915115228_add_schedule_diurnal_period_id_to_hd_profiles.rb +1 -1
  60. data/db/migrate/20171013145849_set_patients_secure_id.rb +1 -1
  61. data/db/migrate/20171101121130_create_function_to_render_audit_view_as_json.rb +2 -29
  62. data/db/migrate/20171127092158_create_function_to_import_practices.rb +4 -118
  63. data/db/migrate/20171127092359_create_fn_to_insert_gps.rb +3 -139
  64. data/db/migrate/20171206140738_create_fn_to_load_practice_memberships_csv.rb +2 -53
  65. data/db/migrate/20171213111513_create_fn_to_refresh_current_obs.rb +2 -43
  66. data/db/migrate/20171214141335_create_trigger_to_update_current_observation_sets.rb +3 -101
  67. data/db/migrate/20180119121243_create_trigger_to_preprocess_hl7_msg.rb +2 -41
  68. data/db/migrate/20180121115246_add_include_pathology_in_letter_to_letters_letterheads.rb +5 -0
  69. data/db/migrate/20180125201356_make_obs_set_trigger_change_updated_at.rb +2 -184
  70. data/db/migrate/20180130165803_add_deleted_at_indexes.rb +16 -0
  71. data/db/migrate/20180201090444_add_created_at_to_delayed_jobs_in_hl7_trig_fn.rb +9 -0
  72. data/db/migrate/20180207082540_create_count_estimate_function.rb +9 -0
  73. data/db/triggers/feed_messages_preprocessing_trigger_v01.sql +5 -0
  74. data/db/triggers/update_current_observation_set_trigger_v01.sql +7 -0
  75. data/lib/core_extensions/active_record/migration_helpers.rb +43 -0
  76. data/lib/renalware/engine.rb +6 -4
  77. data/lib/renalware/version.rb +1 -1
  78. data/spec/factories/pathology/observation_descriptions.rb +7 -1
  79. data/spec/support/shared_examples/accountable_examples.rb +6 -0
  80. data/spec/support/shared_examples/supersedable_examples.rb +12 -0
  81. metadata +33 -10
  82. data/app/models/renalware/letters/delivery/deliver_letter.rb.dead +0 -41
  83. data/app/models/renalware/pathology/current_key_observation_set.rb.dead +0 -10
  84. data/app/models/renalware/pathology/update_current_observations.rb.dead +0 -25
  85. data/app/presenters/renalware/pathology/current_observation_results.dead/presenter.rb.dead +0 -54
  86. data/app/views/renalware/letters/formatted_letters/show.rtf.slim.ol +0 -1
  87. data/app/views/renalware/patients/_prescriptions.html.slim.dead +0 -23
@@ -0,0 +1,16 @@
1
+ class AddDeletedAtIndexes < ActiveRecord::Migration[5.1]
2
+ def change
3
+ add_index :research_studies, :deleted_at
4
+ add_index :research_study_participants, :deleted_at
5
+ add_index :admission_consults, :deleted_at
6
+ add_index :clinical_allergies, :deleted_at
7
+ add_index :patient_alerts, :deleted_at
8
+ add_index :access_plan_types, :deleted_at
9
+ add_index :drugs, :deleted_at
10
+ add_index :event_types, :deleted_at
11
+ add_index :hd_cannulation_types, :deleted_at
12
+ add_index :modality_descriptions, :deleted_at
13
+ add_index :pd_systems, :deleted_at
14
+ add_index :hd_profiles, :deactivated_at
15
+ end
16
+ end
@@ -0,0 +1,9 @@
1
+ class AddCreatedAtToDelayedJobsInHL7TrigFn < ActiveRecord::Migration[5.1]
2
+ def up
3
+ load_function("preprocess_hl7_message_v02.sql")
4
+ end
5
+
6
+ def down
7
+ load_function("preprocess_hl7_message_v01.sql")
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class CreateCountEstimateFunction < ActiveRecord::Migration[5.1]
2
+ def up
3
+ load_function "count_estimate_v01.sql"
4
+ end
5
+
6
+ def down
7
+ connection.execute("DROP FUNCTION count_estimate(text);")
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ CREATE TRIGGER feed_messages_preprocessing_trigger
2
+ BEFORE INSERT
3
+ ON delayed_jobs
4
+ FOR EACH ROW
5
+ EXECUTE PROCEDURE preprocess_hl7_message();
@@ -0,0 +1,7 @@
1
+ -- Create the trigger which will call out function every time a row in pathology_observations
2
+ -- is inserted or updated
3
+ DROP TRIGGER IF EXISTS update_current_observation_set_trigger ON pathology_observations;
4
+ CREATE TRIGGER update_current_observation_set_trigger
5
+ AFTER INSERT OR UPDATE
6
+ ON pathology_observations
7
+ FOR EACH ROW EXECUTE PROCEDURE update_current_observation_set_from_trigger();
@@ -0,0 +1,43 @@
1
+ module CoreExtensions
2
+ module ActiveRecord
3
+ module MigrationHelpers
4
+ # Can be called from a migration to load in a function from a sql file
5
+ # at e.g. db/functions/my_function_v01.sql
6
+ #
7
+ # Example usage:
8
+ # load_function("my_function_v01.sql")
9
+ #
10
+ def load_function(filename)
11
+ load_sql_file(DatabaseObjectPaths.functions, filename)
12
+ end
13
+
14
+ # Can be called from a migration to load in a trigger from a sql file
15
+ # at e.g. db/functions/my_trigger_v01.sql
16
+ #
17
+ # Example usage:
18
+ # load_trigger("my_trigger_v01.sql")
19
+ #
20
+ def load_trigger(filename)
21
+ load_sql_file(DatabaseObjectPaths.triggers, filename)
22
+ end
23
+
24
+ def load_sql_file(path, filename)
25
+ connection.execute(File.read(path.join(filename)))
26
+ end
27
+
28
+ class DatabaseObjectPaths
29
+ class << self
30
+ def triggers
31
+ Renalware::Engine.root.join("db", "triggers")
32
+ end
33
+
34
+ def functions
35
+ Renalware::Engine.root.join("db", "functions")
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ ActiveRecord::Migration[5.1].send(:prepend, CoreExtensions::ActiveRecord::MigrationHelpers)
@@ -152,12 +152,14 @@ module Renalware
152
152
  end
153
153
 
154
154
  initializer :resolve_scenic_views_inside_engine do |app|
155
- # Set app.config.paths["db/views"] to the engine's db/views path so (out monkey-patched)
156
- # scenic will load views from the engine (otherwise not supported un;es manually copies in
155
+ # Set app.config.paths["db/views"] to the engine's db/views path so (our monkey-patched)
156
+ # scenic will load views from the engine (otherwise not supported unless manually copies in
157
157
  # a rake task, which I am keen to avoid)
158
158
  # See lib/core_extensions/scenic.rb
159
- view_dir = Rails.root.join(config.root, "db", "views")
160
- app.config.paths.add("db/views", with: view_dir)
159
+ %w(views functions triggers).each do |db_thing|
160
+ dir = Rails.root.join(config.root, "db", db_thing)
161
+ app.config.paths.add("db/#{db_thing}", with: dir)
162
+ end
161
163
  end
162
164
 
163
165
  initializer :general do |app|
@@ -1,3 +1,3 @@
1
1
  module Renalware
2
- VERSION = "2.0.0.pre.rc8".freeze
2
+ VERSION = "2.0.0.pre.rc9".freeze
3
3
  end
@@ -1,6 +1,12 @@
1
1
  FactoryBot.define do
2
2
  factory :pathology_observation_description,
3
- class: "Renalware::Pathology::ObservationDescription" do
3
+ class: "Renalware::Pathology::ObservationDescription" do
4
+ initialize_with do
5
+ Renalware::Pathology::ObservationDescription.find_or_create_by!(code: code)
6
+ end
7
+
8
+ before(:create){ |desc| desc.loinc_code ||= desc.code.downcase }
9
+
4
10
  code "WBR"
5
11
  association :measurement_unit, factory: :pathology_measurement_unit
6
12
  end
@@ -0,0 +1,6 @@
1
+ shared_examples_for "an Accountable model" do
2
+ it { is_expected.to respond_to(:by=) }
3
+ it { is_expected.to respond_to(:save_by!) }
4
+ it { is_expected.to have_db_index(:created_by_id) }
5
+ it { is_expected.to have_db_index(:updated_by_id) }
6
+ end
@@ -0,0 +1,12 @@
1
+ shared_examples_for "a Supersedable model" do
2
+ it { is_expected.to have_db_column(:deactivated_at) }
3
+ it { is_expected.to have_db_index(:deactivated_at) }
4
+
5
+ it "adds a deactivated_at where clause" do
6
+ expect(described_class.all.where_sql).to include(".\"deactivated_at\" IS NULL")
7
+ end
8
+
9
+ it "skips adding the deactivated_at where clause when unscoped" do
10
+ expect(described_class.unscoped.where_sql.to_s).not_to include("\"deactivated_at\"")
11
+ end
12
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: renalware-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.pre.rc8
4
+ version: 2.0.0.pre.rc9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Airslie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-30 00:00:00.000000000 Z
11
+ date: 2018-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -1248,6 +1248,7 @@ files:
1248
1248
  - app/models/application_record.rb
1249
1249
  - app/models/concerns/renalware/accountable.rb
1250
1250
  - app/models/concerns/renalware/broadcasting.rb
1251
+ - app/models/concerns/renalware/clinics/most_recent_measurement_scopes.rb.dead
1251
1252
  - app/models/concerns/renalware/deviseable.rb
1252
1253
  - app/models/concerns/renalware/explicit_state_model.rb
1253
1254
  - app/models/concerns/renalware/feeds/job.rb
@@ -1305,6 +1306,7 @@ files:
1305
1306
  - app/models/renalware/clinics/clinic_visit.rb
1306
1307
  - app/models/renalware/clinics/consultant.rb
1307
1308
  - app/models/renalware/clinics/create_clinic_visit.rb
1309
+ - app/models/renalware/clinics/current_observations.rb
1308
1310
  - app/models/renalware/clinics/patient.rb
1309
1311
  - app/models/renalware/clinics/remembered_clinic_visit_preferences.rb
1310
1312
  - app/models/renalware/clinics/version.rb
@@ -1410,7 +1412,6 @@ files:
1410
1412
  - app/models/renalware/letters/complete_letter.rb
1411
1413
  - app/models/renalware/letters/contact.rb
1412
1414
  - app/models/renalware/letters/contact_description.rb
1413
- - app/models/renalware/letters/delivery/deliver_letter.rb.dead
1414
1415
  - app/models/renalware/letters/delivery/delivery_policy.rb
1415
1416
  - app/models/renalware/letters/delivery/email_letter_to_practice.rb
1416
1417
  - app/models/renalware/letters/delivery/practice_email.rb
@@ -1496,7 +1497,6 @@ files:
1496
1497
  - app/models/renalware/pathology/clinic.rb
1497
1498
  - app/models/renalware/pathology/consultant.rb
1498
1499
  - app/models/renalware/pathology/create_observation_requests.rb
1499
- - app/models/renalware/pathology/current_key_observation_set.rb.dead
1500
1500
  - app/models/renalware/pathology/current_observation.rb
1501
1501
  - app/models/renalware/pathology/current_observation_set.rb
1502
1502
  - app/models/renalware/pathology/current_observations_for_descriptions_query.rb
@@ -1557,8 +1557,7 @@ files:
1557
1557
  - app/models/renalware/pathology/requests/request_query.rb
1558
1558
  - app/models/renalware/pathology/requests/requests_factory.rb
1559
1559
  - app/models/renalware/pathology/results.rb
1560
- - app/models/renalware/pathology/update_current_observations.rb.dead
1561
- - app/models/renalware/pathology/view_current_observation_results.rb
1560
+ - app/models/renalware/pathology/view_current_observation_results.rb.dead
1562
1561
  - app/models/renalware/pathology/view_observation_results.rb
1563
1562
  - app/models/renalware/patient.rb
1564
1563
  - app/models/renalware/patients.rb
@@ -1757,6 +1756,7 @@ files:
1757
1756
  - app/presenters/renalware/clinical/body_composition_presenter.rb
1758
1757
  - app/presenters/renalware/clinical/dry_weight_presenter.rb
1759
1758
  - app/presenters/renalware/clinical/dry_weights_presenter.rb
1759
+ - app/presenters/renalware/clinical/header_presenter.rb
1760
1760
  - app/presenters/renalware/clinical/profile_presenter.rb
1761
1761
  - app/presenters/renalware/country_presenter.rb
1762
1762
  - app/presenters/renalware/dashboard/dashboard_presenter.rb
@@ -1784,6 +1784,7 @@ files:
1784
1784
  - app/presenters/renalware/letters/letter_form_presenter.rb
1785
1785
  - app/presenters/renalware/letters/letter_presenter.rb
1786
1786
  - app/presenters/renalware/letters/letter_presenter_factory.rb
1787
+ - app/presenters/renalware/letters/part_class_filter.rb
1787
1788
  - app/presenters/renalware/letters/practice_email_meta_data.rb
1788
1789
  - app/presenters/renalware/letters/recipient_presenter.rb
1789
1790
  - app/presenters/renalware/low_clearance/dashboard_presenter.rb
@@ -1798,7 +1799,6 @@ files:
1798
1799
  - app/presenters/renalware/messaging/internal/message_presenter.rb
1799
1800
  - app/presenters/renalware/messaging/internal/receipt_presenter.rb
1800
1801
  - app/presenters/renalware/pathology/current_observation_results.dead/html_table_view.rb.dead
1801
- - app/presenters/renalware/pathology/current_observation_results.dead/presenter.rb.dead
1802
1802
  - app/presenters/renalware/pathology/historical_observation_results/html_table_view.rb
1803
1803
  - app/presenters/renalware/pathology/historical_observation_results/presenter.rb
1804
1804
  - app/presenters/renalware/pathology/observation_presenter.rb
@@ -1850,6 +1850,7 @@ files:
1850
1850
  - app/validators/renalware/patients/temperature_validator.rb
1851
1851
  - app/validators/renalware/patients/weight_validator.rb
1852
1852
  - app/values/renalware/address.rb
1853
+ - app/values/renalware/bmi.rb
1853
1854
  - app/values/renalware/duration.rb
1854
1855
  - app/values/renalware/gender.rb
1855
1856
  - app/values/renalware/time_of_day.rb
@@ -1945,6 +1946,7 @@ files:
1945
1946
  - app/views/renalware/api/ukrdc/patients/show.xml.builder
1946
1947
  - app/views/renalware/base/_black_hole.html.slim
1947
1948
  - app/views/renalware/base/_modality_missing_warning.html.slim
1949
+ - app/views/renalware/clinical/_header.html.slim
1948
1950
  - app/views/renalware/clinical/allergies/_list.html.slim
1949
1951
  - app/views/renalware/clinical/allergies/_mini.html.slim
1950
1952
  - app/views/renalware/clinical/allergies/_new.html.slim
@@ -2166,7 +2168,6 @@ files:
2166
2168
  - app/views/renalware/letters/formatted_letters/show.html.slim
2167
2169
  - app/views/renalware/letters/formatted_letters/show.inlinepdf.slim
2168
2170
  - app/views/renalware/letters/formatted_letters/show.pdf.slim
2169
- - app/views/renalware/letters/formatted_letters/show.rtf.slim.ol
2170
2171
  - app/views/renalware/letters/letters/_actions.html.slim
2171
2172
  - app/views/renalware/letters/letters/_add_contact.html.slim
2172
2173
  - app/views/renalware/letters/letters/_additional_ccs.html.slim
@@ -2311,7 +2312,6 @@ files:
2311
2312
  - app/views/renalware/patients/_layout.html.slim
2312
2313
  - app/views/renalware/patients/_mini_profile.html.slim
2313
2314
  - app/views/renalware/patients/_person_form_fields.html.slim
2314
- - app/views/renalware/patients/_prescriptions.html.slim.dead
2315
2315
  - app/views/renalware/patients/_search_form.html.slim
2316
2316
  - app/views/renalware/patients/_side_menu.html.slim
2317
2317
  - app/views/renalware/patients/alerts/_alert.html.slim
@@ -2654,7 +2654,8 @@ files:
2654
2654
  - config/locales/renalware/blood_pressure.en.yml
2655
2655
  - config/locales/renalware/clinical/allergies.en.yml
2656
2656
  - config/locales/renalware/clinical/body_composition.yml
2657
- - config/locales/renalware/clinical/dry_weight.yml
2657
+ - config/locales/renalware/clinical/dry_weight.en.yml
2658
+ - config/locales/renalware/clinical/header.en.yml
2658
2659
  - config/locales/renalware/clinics/visit.yml
2659
2660
  - config/locales/renalware/dashboard/dashboard.yml
2660
2661
  - config/locales/renalware/dates_test.yml
@@ -2736,6 +2737,19 @@ files:
2736
2737
  - config/routes.rb
2737
2738
  - config/schedule.rb
2738
2739
  - config/spring.rb
2740
+ - db/functions/audit_view_as_json_v01.sql
2741
+ - db/functions/count_estimate_v01.sql
2742
+ - db/functions/generate_patient_secure_id_v01.sql
2743
+ - db/functions/generate_secure_id_v01.sql
2744
+ - db/functions/import_gps_csv_v01.sql
2745
+ - db/functions/import_practice_memberships_csv_v01.sql
2746
+ - db/functions/import_practices_csv_v01.sql
2747
+ - db/functions/preprocess_hl7_message_v01.sql
2748
+ - db/functions/preprocess_hl7_message_v02.sql
2749
+ - db/functions/refresh_all_matierialized_views_v01.sql
2750
+ - db/functions/refresh_current_observation_set_v01.sql
2751
+ - db/functions/update_current_observation_set_from_trigger_v01.sql
2752
+ - db/functions/update_current_observation_set_from_trigger_v02.sql
2739
2753
  - db/migrate/20141004150240_create_ethnicities.rb
2740
2754
  - db/migrate/20141010170329_create_death_causes.rb
2741
2755
  - db/migrate/20141020170329_create_patients.rb
@@ -3067,8 +3081,12 @@ files:
3067
3081
  - db/migrate/20180112151706_create_low_clearance_profiles.rb
3068
3082
  - db/migrate/20180112151813_create_low_clearance_versions.rb
3069
3083
  - db/migrate/20180119121243_create_trigger_to_preprocess_hl7_msg.rb
3084
+ - db/migrate/20180121115246_add_include_pathology_in_letter_to_letters_letterheads.rb
3070
3085
  - db/migrate/20180125201356_make_obs_set_trigger_change_updated_at.rb
3071
3086
  - db/migrate/20180126142314_add_uuid_to_letters.rb
3087
+ - db/migrate/20180130165803_add_deleted_at_indexes.rb
3088
+ - db/migrate/20180201090444_add_created_at_to_delayed_jobs_in_hl7_trig_fn.rb
3089
+ - db/migrate/20180207082540_create_count_estimate_function.rb
3072
3090
  - db/seeds.rb
3073
3091
  - db/seeds/default/accesses/access_pd_catheter_insertion_techniques.csv
3074
3092
  - db/seeds/default/accesses/access_pd_catheter_insertion_techniques.rb
@@ -3151,6 +3169,8 @@ files:
3151
3169
  - db/seeds/default/transplants/transplant_registration_statuses.rb
3152
3170
  - db/seeds/seeds_helper.rb
3153
3171
  - db/static.obsolete/medication_routes.yml
3172
+ - db/triggers/feed_messages_preprocessing_trigger_v01.sql
3173
+ - db/triggers/update_current_observation_set_trigger_v01.sql
3154
3174
  - db/views/medication_current_prescriptions_v01.sql
3155
3175
  - db/views/pathology_current_key_observation_sets_v01.sql
3156
3176
  - db/views/pathology_current_key_observation_sets_v02.sql
@@ -3174,6 +3194,7 @@ files:
3174
3194
  - lib/array_stringifier.rb
3175
3195
  - lib/breadcrumb.rb
3176
3196
  - lib/collection_presenter.rb
3197
+ - lib/core_extensions/active_record/migration_helpers.rb
3177
3198
  - lib/core_extensions/active_record/sort.rb
3178
3199
  - lib/core_extensions/active_support/duration.rb
3179
3200
  - lib/core_extensions/date.rb
@@ -3381,7 +3402,9 @@ files:
3381
3402
  - spec/support/select2_spec_helper.rb
3382
3403
  - spec/support/select_date_spec_helper.rb
3383
3404
  - spec/support/shared_contexts/a_global_rule_set.rb
3405
+ - spec/support/shared_examples/accountable_examples.rb
3384
3406
  - spec/support/shared_examples/paranoia_examples.rb
3407
+ - spec/support/shared_examples/supersedable_examples.rb
3385
3408
  - spec/support/translations.rb
3386
3409
  - spec/support/travel.rb
3387
3410
  - spec/support/webmock.rb
@@ -1,41 +0,0 @@
1
- require "renalware/letters"
2
- require "attr_extras"
3
-
4
- module Renalware
5
- module Letters
6
- module Delivery
7
- # Responsible for delivering the letter according to the recipient's preferred method:
8
- # - Email letter to practice if GP is a recipient and the practice has an email address;
9
- # - Currently no other action taken, but this class could be extended to for example to
10
- # email the letter contacts who wanted it delivered that way etc.
11
- class DeliverLetter
12
- pattr_initialize [:letter!]
13
- delegate :email_letter_to_practice?, :gp_recipient, to: :policy
14
-
15
- def call
16
- if email_letter_to_practice?
17
- email_letter_to_the_patients_practice_and_flag_as_sent
18
- end
19
- end
20
-
21
- private
22
-
23
- def email_letter_to_the_patients_practice_and_flag_as_sent
24
- Letter.transaction do
25
- mail = PracticeMailer.patient_letter(letter: letter, to: practice_email_address)
26
- mail.deliver_later
27
- gp_recipient.update(emailed_at: Time.zone.now)
28
- end
29
- end
30
-
31
- def practice_email_address
32
- PracticeEmail.new(letter).address
33
- end
34
-
35
- def policy
36
- @policy ||= DeliveryPolicy.new(letter)
37
- end
38
- end
39
- end
40
- end
41
- end
@@ -1,10 +0,0 @@
1
- require_dependency "renalware/pathology"
2
-
3
- module Renalware
4
- module Pathology
5
- class CurrentKeyObservationSet < ApplicationRecord
6
- belongs_to :patient, class_name: "Renalware::Pathology::Patient"
7
- self.primary_key = :patient_id
8
- end
9
- end
10
- end
@@ -1,25 +0,0 @@
1
- require_dependency "renalware/pathology"
2
-
3
- module Renalware
4
- module Pathology
5
- class UpdateCurrentObservations
6
- def call(params)
7
- patient = find_patient(params[:patient_id])
8
- set = patient.fetch_current_observation_set
9
-
10
- params[:observation_request][:observations_attributes].each do |new_obs|
11
- description = ObservationDescription.select(:code).find(new_obs[:description_id])
12
- set.values[description.code] = new_obs.slice(:result, :observed_at)
13
- end
14
-
15
- set.save!
16
- end
17
-
18
- private
19
-
20
- def find_patient(id)
21
- Pathology::Patient.find_by(id: id)
22
- end
23
- end
24
- end
25
- end
@@ -1,54 +0,0 @@
1
- require_dependency "renalware/pathology"
2
-
3
- module Renalware
4
- module Pathology
5
- class CurrentObservationResults::Presenter
6
- attr_reader :view_model
7
-
8
- def present(results)
9
- @view_model = [build_header] + build_body(results)
10
- end
11
-
12
- private
13
-
14
- def build_header
15
- %w(description result date)
16
- end
17
-
18
- def build_body(results)
19
- results.map do |result|
20
- [build_description(result), ObservationPresenter.new(result), format_date(result)]
21
- end
22
- end
23
-
24
- def build_description(result)
25
- description = ObservationDescription.new(
26
- code: result.description_code, name: result.description_name)
27
- ResultPresenter.new(description)
28
- end
29
-
30
- def format_date(result)
31
- date = I18n.l(result.observed_at.try(:to_date))
32
- DatePresenter.new(date)
33
- end
34
-
35
- class DatePresenter < SimpleDelegator
36
- def content
37
- to_s
38
- end
39
- end
40
-
41
- class ResultPresenter < SimpleDelegator
42
- def content
43
- name
44
- end
45
- end
46
-
47
- class ObservationPresenter < SimpleDelegator
48
- def content
49
- to_s
50
- end
51
- end
52
- end
53
- end
54
- end