renalware-core 2.0.39 → 2.0.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -2
  3. data/app/assets/javascripts/renalware/clockpicker.js +2 -2
  4. data/app/assets/javascripts/renalware/letters.js +1 -1
  5. data/app/assets/javascripts/renalware/messaging.js +1 -1
  6. data/app/assets/javascripts/renalware/patient_ajax_search.js +1 -1
  7. data/app/assets/javascripts/renalware/pd.js +1 -1
  8. data/app/assets/javascripts/renalware/primary_care_physician_search.js +1 -2
  9. data/app/assets/javascripts/renalware/primary_care_physicians.js +1 -1
  10. data/app/assets/javascripts/renalware/renal.js +1 -1
  11. data/app/assets/javascripts/renalware/research.js +1 -1
  12. data/app/assets/javascripts/renalware/select2-ajax-search.js +1 -1
  13. data/app/assets/stylesheets/renalware/partials/_lists.scss +8 -0
  14. data/app/assets/stylesheets/renalware/partials/_mdm.scss +11 -20
  15. data/app/assets/stylesheets/renalware/protocol_pdf.scss +2 -7
  16. data/app/controllers/renalware/events/events_controller.rb +1 -0
  17. data/app/controllers/renalware/hd/diary_slots_controller.rb +1 -0
  18. data/app/controllers/renalware/hd/mdm_patients_controller.rb +19 -5
  19. data/app/controllers/renalware/letters/letters_controller.rb +1 -0
  20. data/app/controllers/renalware/mdm_patients_controller.rb +1 -1
  21. data/app/controllers/renalware/modalities/modalities_controller.rb +1 -0
  22. data/app/controllers/renalware/virology/profiles_controller.rb +1 -0
  23. data/app/documents/renalware/hd/profile_document.rb +1 -0
  24. data/app/documents/renalware/virology/profile_document.rb +1 -0
  25. data/app/models/renalware/accesses/patient.rb +22 -4
  26. data/app/models/renalware/clinical/patient.rb +1 -1
  27. data/app/models/renalware/feeds/file_type.rb +1 -1
  28. data/app/models/renalware/feeds/files/practices/convert_xml_to_csv.rb +2 -1
  29. data/app/models/renalware/feeds/files/practices/xml_parser.rb +2 -0
  30. data/app/models/renalware/hd/mdm_patients_form.rb +34 -0
  31. data/app/models/renalware/hd/mdm_patients_query.rb +43 -8
  32. data/app/models/renalware/hd/schedule_definition_filter.rb +15 -0
  33. data/app/models/renalware/hd/sessions/auditable_session_collection.rb +1 -0
  34. data/app/models/renalware/letters/author.rb +1 -1
  35. data/app/models/renalware/letters/description.rb +1 -1
  36. data/app/models/renalware/letters/part/problems.rb +5 -0
  37. data/app/models/renalware/letters/patient.rb +2 -2
  38. data/app/models/renalware/letters/primary_care_physician.rb +1 -1
  39. data/app/models/renalware/low_clearance/mdm_patients_query.rb +6 -1
  40. data/app/models/renalware/low_clearance.rb +1 -1
  41. data/app/models/renalware/medications/medication_route.rb +1 -1
  42. data/app/models/renalware/messaging/internal/author.rb +1 -1
  43. data/app/models/renalware/messaging/internal/message.rb +1 -1
  44. data/app/models/renalware/messaging/internal/recipient.rb +1 -1
  45. data/app/models/renalware/messaging/patient.rb +1 -1
  46. data/app/models/renalware/pathology/patient.rb +1 -1
  47. data/app/models/renalware/patient.rb +1 -0
  48. data/app/models/renalware/patients/practice.rb +1 -1
  49. data/app/models/renalware/patients/primary_care_physician.rb +2 -2
  50. data/app/models/renalware/patients/user.rb +1 -1
  51. data/app/models/renalware/pd/fluid_description.rb +1 -1
  52. data/app/models/renalware/pd/organism_code.rb +1 -1
  53. data/app/models/renalware/pd/patient.rb +1 -1
  54. data/app/models/renalware/pd/pet_adequacy_result.rb +1 -0
  55. data/app/models/renalware/transplants/donor_operation.rb +4 -1
  56. data/app/models/renalware/transplants/patient.rb +18 -4
  57. data/app/policies/renalware/base_policy.rb +3 -3
  58. data/app/presenters/renalware/dashboard/dashboard_presenter.rb +2 -1
  59. data/app/presenters/renalware/hd/diary_slot_presenter.rb +1 -0
  60. data/app/presenters/renalware/hd/mdm_presenter.rb +0 -11
  61. data/app/presenters/renalware/hd/patient_presenter.rb +1 -0
  62. data/app/presenters/renalware/mdm_presenter.rb +18 -0
  63. data/app/views/renalware/hd/mdm_patients/_filters.html.slim +7 -5
  64. data/app/views/renalware/hd/mdm_patients/_patient.html.slim +1 -0
  65. data/app/views/renalware/hd/mdm_patients/_table.html.slim +5 -4
  66. data/app/views/renalware/hd/mdm_patients/index.html.slim +1 -1
  67. data/app/views/renalware/hd/protocols/_virology.html.slim +1 -1
  68. data/app/views/renalware/hd/sessions/_row.html.slim +3 -2
  69. data/app/views/renalware/letters/letters/_form.html.slim +3 -0
  70. data/app/views/renalware/letters/letters/_problems_prescriptions.html.slim +22 -0
  71. data/app/views/renalware/letters/parts/_problems.html.slim +1 -1
  72. data/app/views/renalware/low_clearance/mdm/_summary.html.slim +9 -0
  73. data/app/views/renalware/low_clearance/mdm/_top.html.slim +10 -0
  74. data/app/views/renalware/patients/side_menu/_transplants.html.slim +1 -1
  75. data/app/views/renalware/transplants/recipient_dashboards/_page_actions.html.slim +3 -3
  76. data/app/views/renalware/virology/profiles/_summary.html.slim +8 -1
  77. data/app/views/renalware/virology/profiles/edit.html.slim +1 -0
  78. data/config/locales/renalware/hd/mdm_patients.yml +1 -0
  79. data/config/locales/renalware/low_clearance/low_clearance.en.yml +1 -0
  80. data/config/locales/renalware/virology/virology.en.yml +1 -0
  81. data/db/migrate/20180725132557_add_days_text_to_hd_schedule_definitions.rb +27 -0
  82. data/db/migrate/20180725132808_create_hd_schedule_definition_filters_view.rb +5 -0
  83. data/db/migrate/20180802103013_add_hd_mdm_missing_indexes.rb +8 -0
  84. data/db/views/hd_schedule_definition_filters_v01.sql +47 -0
  85. data/lib/renalware/version.rb +1 -1
  86. data/spec/factories/hd/schedule_definitions.rb +2 -0
  87. metadata +24 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68409a0a75c780847c2cdf55ab44325dd993b74fd850090e86f5925efd592eee
4
- data.tar.gz: a69a86d2c84b6db5e7b7e5823fac9a37d41c8f19fda3af2810b1216b4ae631fb
3
+ metadata.gz: 4c3d9338a0d4d5c869623f1f05fae525bb69315935feaa19bcb144a6816c2bd5
4
+ data.tar.gz: 6b0726dc261af4365e1fc62a01103e98d57c0569276b8269ccf547bdac0ece5b
5
5
  SHA512:
6
- metadata.gz: 2e4088f788a4da2c0a309045d83ba2d01644b6b1064108ec59b3fc8b1213f2d56a506a034250fdf9986c3024f5d49b4e21d2f05a1cc64200ac0394839ccaf079
7
- data.tar.gz: 2fcfebba60f4b399ac10f134fe846946bccaaf89dc11089acd8553b396343af99b8d13bd7efcb9430c45156da7be74e50ab92e412384da1da56d446d99e6fada
6
+ metadata.gz: 169887f515113d57a0af78685994267dc4d64621b2d03fc6d8ea6661f6baf64f567cb147f9b76fa98d13d180450523fc68da58118b984574e3eac8e26b48481b
7
+ data.tar.gz: '0859821f1051c9cf0fe83f73c8e9fb5a691e819a0e1a9068a35a0bdd07d0910f354c007e7fa5fa9f848fe203c8b084f869d0bee8a398522bd11c8e492e2e9353'
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # Renalware
2
2
 
3
- [![Code Climate](https://codeclimate.com/repos/58beee3ed41d600266000147/badges/50451f89d7aad6c2d200/gpa.svg)](https://codeclimate.com/repos/58beee3ed41d600266000147/feed)
3
+ [![Maintainability](https://api.codeclimate.com/v1/badges/644897239eebaf83f564/maintainability)](https://codeclimate.com/github/airslie/renalware-core/maintainability)
4
4
  [![Test Coverage](https://codeclimate.com/repos/58beee3ed41d600266000147/badges/50451f89d7aad6c2d200/coverage.svg)](https://codeclimate.com/repos/58beee3ed41d600266000147/coverage)
5
- [![Dependency Status](https://gemnasium.com/badges/github.com/airslie/renalware-core.svg)](https://gemnasium.com/github.com/airslie/renalware-core)
6
5
  [![Gem Version](https://badge.fury.io/rb/renalware-core.svg)](https://badge.fury.io/rb/renalware-core)
7
6
 
8
7
  Renalware uses demographic, clinical, pathology, and nephrology datasets to improve patient care,
@@ -24,7 +24,7 @@
24
24
  supported = (el.firstChild && el.firstChild.namespaceURI) == svgNS;
25
25
  el.innerHTML = '';
26
26
  return supported;
27
- })();
27
+ }());
28
28
 
29
29
  // Can I use transition ?
30
30
  var transitionSupported = (function(){
@@ -34,7 +34,7 @@
34
34
  'MozTransition' in style ||
35
35
  'msTransition' in style ||
36
36
  'OTransition' in style;
37
- })();
37
+ }());
38
38
 
39
39
  // Listen touch events in touch screen device, instead of mouse events in desktop.
40
40
  var touchSupported = 'ontouchstart' in window,
@@ -104,6 +104,6 @@ Renalware.Letters = (function() {
104
104
  bindOnLetterAboutToPrint();
105
105
  }
106
106
  };
107
- })();
107
+ }());
108
108
 
109
109
  $(document).ready(Renalware.Letters.init);
@@ -10,6 +10,6 @@ Renalware.Messaging = (function() {
10
10
  focusRecipientSearchInput()
11
11
  }
12
12
  };
13
- })();
13
+ }());
14
14
 
15
15
  $(document).on('opened.fndtn.reveal', '#send-message-modal', Renalware.Messaging.init);
@@ -40,7 +40,7 @@ Renalware.PatientSearch = (function() {
40
40
  initPatientSearch()
41
41
  }
42
42
  };
43
- })();
43
+ }());
44
44
 
45
45
  $(document).ready(Renalware.PatientSearch.init);
46
46
  $(document).on('opened.fndtn.reveal', '[data-reveal]', function() {
@@ -47,7 +47,7 @@ Renalware.PdRegimes = (function () {
47
47
  $('a.remove-bag').show();
48
48
  }
49
49
  }
50
- })();
50
+ }());
51
51
  // Bind DOM ready and nested_form:fieldAdded events
52
52
  // so that buttons are toggled when JS is active.
53
53
  $(document).ready(Renalware.PdRegimes.init);
@@ -75,7 +75,6 @@ Renalware.PrimaryCarePhysicianSearch = (function() {
75
75
  initPracticeAutocomplete()
76
76
  }
77
77
  };
78
- })();
78
+ }());
79
79
 
80
80
  $(document).on('opened.fndtn.reveal', '[data-reveal]', Renalware.PrimaryCarePhysicianSearch.init);
81
-
@@ -20,6 +20,6 @@ Renalware.PrimaryCarePhysicians = (function () {
20
20
  bindAddressFormToggle();
21
21
  }
22
22
  }
23
- })();
23
+ }());
24
24
 
25
25
  $(document).ready(Renalware.PrimaryCarePhysicians.init);
@@ -29,6 +29,6 @@ Renalware.Renal = (function () {
29
29
  wireUpUseCurrentAddressButton();
30
30
  }
31
31
  }
32
- })();
32
+ }());
33
33
 
34
34
  $(document).ready(Renalware.Renal.init);
@@ -13,6 +13,6 @@ Renalware.Research = (function() {
13
13
  focusPatientInput();
14
14
  }
15
15
  };
16
- })();
16
+ }());
17
17
 
18
18
  $(document).on('opened.fndtn.reveal', '#study-participant-modal', Renalware.Research.init);
@@ -78,7 +78,7 @@ Renalware.AjaxSearch = (function() {
78
78
  initAjaxSearch()
79
79
  }
80
80
  };
81
- })();
81
+ }());
82
82
 
83
83
  $(document).ready(Renalware.AjaxSearch.init);
84
84
  $(document).on('opened.fndtn.reveal', '[data-reveal]', function() {
@@ -83,3 +83,11 @@
83
83
  }
84
84
  }
85
85
  }
86
+
87
+ ul.indented {
88
+ li {
89
+ text-indent: -1.5em;
90
+ list-style-position: outside;
91
+ padding-left: 1.5em;
92
+ }
93
+ }
@@ -26,25 +26,16 @@
26
26
  }
27
27
  }
28
28
 
29
- .mdm-page {
30
- article {
31
- &.events {
32
- .created_at,
33
- .created_by {
34
-
35
- }
36
- }
37
- }
38
-
39
- .expandable {
40
- clear: both;
41
- height: 0;
42
- opacity: 0;
43
-
44
- &.expanded {
45
- height: auto;
46
- opacity: 1;
47
- transition: all .3s ease .15s;
48
- }
29
+ .expandable {
30
+ clear: both;
31
+ height: 0;
32
+ opacity: 0;
33
+ float: left;
34
+ width: 100%;
35
+
36
+ &.expanded {
37
+ height: auto;
38
+ opacity: 1;
39
+ transition: all .2s; // ease .15s;
49
40
  }
50
41
  }
@@ -134,13 +134,8 @@ h1 {
134
134
  }
135
135
 
136
136
  &.col-width-date {
137
- min-width: 5.6rem;
138
- width: 5.6px;
139
- }
140
-
141
- &.col-width-date {
142
- min-width: 5.6rem;
143
- width: 5.6rem;
137
+ min-width: 6rem;
138
+ width: 6rem;
144
139
  }
145
140
 
146
141
  &.col-width-time {
@@ -183,3 +183,4 @@ module Renalware
183
183
  end
184
184
  end
185
185
  end
186
+ # rubocop:enable Metrics/ClassLength
@@ -171,3 +171,4 @@ module Renalware
171
171
  end
172
172
  end
173
173
  end
174
+ # rubocop:enable Metrics/ClassLength
@@ -6,11 +6,14 @@ module Renalware
6
6
  module HD
7
7
  class MDMPatientsController < Renalware::MDMPatientsController
8
8
  def index
9
+ filter_form = HD::MDMPatientsForm.new(filter_form_params)
10
+
9
11
  query = HD::MDMPatientsQuery.new(
10
- relation: HD::Patient.eager_load(hd_profile: [:hospital_unit]),
11
- q: params[:q]
12
+ params: filter_form.ransacked_parameters.merge(query_params).with_indifferent_access
12
13
  )
13
- render_index(query: query,
14
+
15
+ render_index(filter_form: filter_form,
16
+ query: query,
14
17
  page_title: t(".page_title"),
15
18
  view_proc: ->(patient) { patient_hd_mdm_path(patient) },
16
19
  patient_presenter_class: HD::PatientPresenter)
@@ -18,10 +21,21 @@ module Renalware
18
21
 
19
22
  private
20
23
 
21
- def render_index(**args)
24
+ def filter_form_params
25
+ params.fetch(:filter, {}).permit!
26
+ end
27
+
28
+ def query_params
29
+ params.fetch(:q, {}).permit!
30
+ end
31
+
32
+ def render_index(filter_form:, **args)
22
33
  presenter = build_presenter(params: params, **args)
23
34
  authorize presenter.patients
24
- render :index, locals: { presenter: presenter }
35
+ render(
36
+ :index,
37
+ locals: { presenter: presenter, filter_form: filter_form }
38
+ )
25
39
  end
26
40
  end
27
41
  end
@@ -224,3 +224,4 @@ module Renalware
224
224
  end
225
225
  end
226
226
  end
227
+ # rubocop:enable Metrics/ClassLength
@@ -23,7 +23,7 @@ module Renalware
23
23
  query = args.fetch(:query)
24
24
 
25
25
  MDMPatientsPresenter.new(
26
- patients: query.call.page(page),
26
+ patients: query.call.page(page).per(per_page),
27
27
  page_title: args.fetch(:page_title),
28
28
  view_proc: args.fetch(:view_proc),
29
29
  q: query.search,
@@ -65,6 +65,7 @@ module Renalware
65
65
  notice: t(".success", model_name: "modality")
66
66
  end
67
67
  end
68
+ # rubocop:enable Metrics/MethodLength
68
69
  end
69
70
  end
70
71
  end
@@ -37,6 +37,7 @@ module Renalware
37
37
  document.hiv = YearDatedDiagnosis.new(document_params[:hiv])
38
38
  document.hepatitis_b = YearDatedDiagnosis.new(document_params[:hepatitis_b])
39
39
  document.hepatitis_c = YearDatedDiagnosis.new(document_params[:hepatitis_c])
40
+ document.htlv = YearDatedDiagnosis.new(document_params[:htlv])
40
41
  profile.save_by(current_user)
41
42
  end
42
43
 
@@ -77,3 +77,4 @@ module Renalware
77
77
  end
78
78
  end
79
79
  end
80
+ # rubocop:enable Layout/EmptyLineBetweenDefs, Style/SingleLineMethods
@@ -9,6 +9,7 @@ module Renalware
9
9
  attribute :hiv, YearDatedDiagnosis
10
10
  attribute :hepatitis_b, YearDatedDiagnosis
11
11
  attribute :hepatitis_c, YearDatedDiagnosis
12
+ attribute :htlv, YearDatedDiagnosis
12
13
  end
13
14
  end
14
15
  end
@@ -5,10 +5,10 @@ require_dependency "renalware/accesses"
5
5
  module Renalware
6
6
  module Accesses
7
7
  class Patient < ActiveType::Record[Renalware::Patient]
8
- has_many :profiles
9
- has_many :plans
10
- has_many :procedures
11
- has_many :assessments
8
+ has_many :profiles, dependent: :destroy
9
+ has_many :plans, dependent: :destroy
10
+ has_many :procedures, dependent: :destroy
11
+ has_many :assessments, dependent: :destroy
12
12
 
13
13
  def current_profile
14
14
  profiles.current.first
@@ -17,6 +17,24 @@ module Renalware
17
17
  def current_plan
18
18
  plans.current.first
19
19
  end
20
+
21
+ scope :with_current_plan, lambda {
22
+ joins(<<-SQL)
23
+ left outer join access_plans on access_plans.patient_id = patients.id
24
+ and access_plans.terminated_at is null
25
+ left outer join access_plan_types
26
+ on access_plans.plan_type_id = access_plan_types.id
27
+ SQL
28
+ }
29
+
30
+ scope :with_profile, lambda {
31
+ joins(<<-SQL)
32
+ left outer join access_profiles on (access_profiles.patient_id = patients.id
33
+ and access_profiles.terminated_on is not null
34
+ and access_profiles.started_on <= current_date)
35
+ left outer join access_types on access_types.id = access_profiles.type_id
36
+ SQL
37
+ }
20
38
  end
21
39
  end
22
40
  end
@@ -5,7 +5,7 @@ require_dependency "renalware/clinical"
5
5
  module Renalware
6
6
  module Clinical
7
7
  class Patient < ActiveType::Record[Renalware::Patient]
8
- has_many :allergies
8
+ has_many :allergies, dependent: :restrict_with_exception
9
9
 
10
10
  # These statuses match NHS standards for the display of recorded allergy status.
11
11
  # Note that
@@ -9,7 +9,7 @@ module Renalware
9
9
  validates :description, presence: true
10
10
  validates :prompt, presence: true
11
11
 
12
- has_many :files
12
+ has_many :files, dependent: :destroy
13
13
  end
14
14
  end
15
15
  end
@@ -144,7 +144,8 @@ module Renalware
144
144
 
145
145
  class CountryNotFoundError < StandardError; end
146
146
  end
147
- # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
147
+ # rubocop:enable Metrics/MethodLength, Metrics/AbcSize, Metrics/PerceivedComplexity
148
+ # rubocop:enable Metrics/CyclomaticComplexity
148
149
  end
149
150
  end
150
151
  end
@@ -96,3 +96,5 @@ module Renalware
96
96
  end
97
97
  end
98
98
  end
99
+ # rubocop:enable Metrics/PerceivedComplexity
100
+ # rubocop:enable Metrics/AbcSize
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Renalware
4
+ module HD
5
+ # Form object to help us map chosen input values in the HD MDM patient list filters form
6
+ # into ransack predicates. Used in this instance because mapping the form's
7
+ # schedule_definition_ids dropdown value in the format of e.g "[1, 3, 6]" into the
8
+ # integer arry [1, 3, 6] is not something Ransack can do - hence this intermediate form object
9
+ # to do the mapping.
10
+ class MDMPatientsForm
11
+ include ActiveModel::Model
12
+ include Virtus::Model
13
+
14
+ attribute :hospital_unit_id, Integer
15
+ attribute :schedule_definition_ids, String # an Integer array in string form e.g. "[1 ,2]"
16
+
17
+ # The hash returned here is passed into the Ransack #search method later i the ouery object.
18
+ def ransacked_parameters
19
+ {
20
+ hd_profile_hospital_unit_id_eq: hospital_unit_id,
21
+ hd_profile_schedule_definition_id_in: schedule_definition_ids_array
22
+ }
23
+ end
24
+
25
+ private
26
+
27
+ # Convert e.g. "[1,2,3]" to [1,2,3]
28
+ def schedule_definition_ids_array
29
+ return if schedule_definition_ids.blank?
30
+ schedule_definition_ids.scan(/\d+/).map(&:to_i)
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # TODO: code here bleeds across modules
4
+
3
5
  module Renalware
4
6
  module HD
5
7
  class MDMPatientsQuery
@@ -7,27 +9,60 @@ module Renalware
7
9
  include PatientPathologyScopes
8
10
  MODALITY_NAMES = "HD"
9
11
  DEFAULT_SEARCH_PREDICATE = "hgb_date desc"
10
- attr_reader :q, :relation
12
+ attr_reader :params
11
13
 
12
- def initialize(relation: HD::Patient.all, q:)
13
- @q = q || {}
14
- @q[:s] = DEFAULT_SEARCH_PREDICATE if @q[:s].blank?
15
- @relation = relation
14
+ def initialize(params:)
15
+ @params = params || {}
16
+ @params[:s] = DEFAULT_SEARCH_PREDICATE if @params[:s].blank?
16
17
  end
17
18
 
18
19
  def call
19
20
  search.result
20
21
  end
21
22
 
23
+ # rubocop:disable Metrics/MethodLength
22
24
  def search
23
25
  @search ||= begin
24
- relation
25
- .includes(:hd_profile)
26
+ HD::Patient
27
+ .include(QueryablePatient)
28
+ .merge(Accesses::Patient.with_current_plan)
29
+ .merge(Accesses::Patient.with_profile)
30
+ .merge(Transplants::Patient.with_registration_statuses)
31
+ .eager_load(hd_profile: [:hospital_unit])
26
32
  .extending(ModalityScopes)
27
33
  .extending(PatientPathologyScopes)
28
34
  .with_current_pathology
29
35
  .with_current_modality_matching(MODALITY_NAMES)
30
- .search(q)
36
+ .search(params)
37
+ end
38
+ end
39
+ # rubocop:enable Metrics/MethodLength
40
+
41
+ # Module to allow us to mixin ransackers
42
+ module QueryablePatient
43
+ extend ActiveSupport::Concern
44
+ included do
45
+ # Using a custom ransacker to be able to order by access plan create_at
46
+ # becuase I believe using an implcit :access_plan_create_at in the sort_link
47
+ # will not work because there is no belongs_to access_plan on HD::Patient
48
+ # and even adding a custom join to access_plans as we do, Ransack will not resolve
49
+ # :access_plans_created_at. Still this seens a reasonable solution.
50
+ # We mix this module into HD::Patient at runtime.
51
+ ransacker :access_plan_date, type: :date do
52
+ Arel.sql("coalesce(access_plans.created_at, '1900-01-01'::timestamp)")
53
+ end
54
+
55
+ ransacker :access_plan_type, type: :string do
56
+ Arel.sql("coalesce(access_plan_types.name, '')")
57
+ end
58
+
59
+ ransacker :current_access, type: :string do
60
+ Arel.sql("access_types.name")
61
+ end
62
+
63
+ ransacker :transplant_registration_status do
64
+ Arel.sql("transplant_registration_status_descriptions.name")
65
+ end
31
66
  end
32
67
  end
33
68
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_dependency "renalware/hd"
4
+
5
+ module Renalware
6
+ module HD
7
+ # Backed by a Postgres view which defines all the possible permutations of
8
+ # filter that can be selected in a schedule definition filter dropdown, for example
9
+ # days: "Mon Wed Fri", ids: [1,3,4]
10
+ # days: "Mon Wed Fri PM", ids: [3]
11
+ # See also HD::MDMPatientsForm and db/views/hd_schedule_definition_filters_*.sql
12
+ class ScheduleDefinitionFilter < ApplicationRecord
13
+ end
14
+ end
15
+ end
@@ -204,3 +204,4 @@ module Renalware
204
204
  end
205
205
  end
206
206
  end
207
+ # rubocop:enable Metrics/ClassLength
@@ -5,7 +5,7 @@ require_dependency "renalware/letters"
5
5
  module Renalware
6
6
  module Letters
7
7
  class Author < ActiveType::Record[Renalware::User]
8
- has_many :letters
8
+ has_many :letters, dependent: :restrict_with_exception
9
9
  end
10
10
  end
11
11
  end
@@ -7,7 +7,7 @@ module Renalware
7
7
  class Description < ApplicationRecord
8
8
  validates :text, presence: true
9
9
 
10
- has_many :letters
10
+ has_many :letters, dependent: :restrict_with_exception
11
11
  end
12
12
  end
13
13
  end
@@ -10,6 +10,11 @@ module Renalware
10
10
  super(patient.problems.includes(:notes))
11
11
  end
12
12
 
13
+ # If you are wondering why #to_partial_path is not getting called when doing 'render part'
14
+ # in a view, note this object is array-like so Rails' render only looks for #to_partial_path
15
+ # on the array elements, not the top level arrary object. To render a single instance of
16
+ # this part class, wrap it in an array like so:
17
+ # = render [part]
13
18
  def to_partial_path
14
19
  "renalware/letters/parts/problems"
15
20
  end
@@ -5,8 +5,8 @@ require_dependency "renalware/letters"
5
5
  module Renalware
6
6
  module Letters
7
7
  class Patient < ActiveType::Record[Renalware::Patient]
8
- has_many :letters
9
- has_many :contacts
8
+ has_many :letters, dependent: :restrict_with_exception
9
+ has_many :contacts, dependent: :restrict_with_exception
10
10
  belongs_to :primary_care_physician, class_name: "Renalware::Letters::PrimaryCarePhysician"
11
11
 
12
12
  def cc_on_letter?(letter)
@@ -5,7 +5,7 @@ require_dependency "renalware/letters"
5
5
  module Renalware
6
6
  module Letters
7
7
  class PrimaryCarePhysician < ActiveType::Record[Renalware::Patients::PrimaryCarePhysician]
8
- has_many :patients
8
+ has_many :patients, dependent: :restrict_with_exception
9
9
  has_many :letters, through: :patients
10
10
 
11
11
  def cc_on_letter?(letter)
@@ -9,7 +9,7 @@ module Renalware
9
9
  DEFAULT_SEARCH_PREDICATE = "hgb_date DESC"
10
10
  attr_reader :query, :relation, :named_filter
11
11
 
12
- def initialize(relation: Patient.all, query: nil, named_filter: nil)
12
+ def initialize(relation: LowClearance::Patient.all, query: nil, named_filter: nil)
13
13
  @query = query || {}
14
14
  @named_filter = named_filter || :none
15
15
  @query[:s] = DEFAULT_SEARCH_PREDICATE if @query[:s].blank?
@@ -39,6 +39,11 @@ module Renalware
39
39
  self # NOOP
40
40
  end
41
41
 
42
+ def supportive_care
43
+ joins(:profile)
44
+ .where("low_clearance_profiles.document ->> 'dialysis_plan' LIKE 'not_for_dial%'")
45
+ end
46
+
42
47
  def on_worryboard
43
48
  joins("RIGHT OUTER JOIN patient_worries ON patient_worries.patient_id = patients.id")
44
49
  end
@@ -4,7 +4,7 @@ require_dependency "renalware"
4
4
 
5
5
  module Renalware
6
6
  module LowClearance
7
- MDM_FILTERS = %w(urea hgb_low hgb_high on_worryboard).freeze # tx_candidates
7
+ MDM_FILTERS = %w(urea hgb_low hgb_high on_worryboard supportive_care).freeze
8
8
 
9
9
  def self.table_name_prefix
10
10
  "low_clearance_"
@@ -9,7 +9,7 @@ module Renalware
9
9
  "medication_routes"
10
10
  end
11
11
 
12
- has_many :prescriptions
12
+ has_many :prescriptions, dependent: :restrict_with_exception
13
13
  has_many :patients, through: :prescriptions
14
14
  has_many :exit_site_infections,
15
15
  through: :prescriptions,
@@ -7,7 +7,7 @@ module Renalware
7
7
  # TODO: Document the Internal module
8
8
  module Internal
9
9
  class Author < ActiveType::Record[Renalware::User]
10
- has_many :messages
10
+ has_many :messages, dependent: :destroy
11
11
  end
12
12
  end
13
13
  end
@@ -7,7 +7,7 @@ module Renalware
7
7
  module Internal
8
8
  class Message < Renalware::Messaging::Message
9
9
  belongs_to :author, class_name: "Internal::Author"
10
- has_many :receipts
10
+ has_many :receipts, dependent: :destroy
11
11
  has_many :recipients, through: :receipts
12
12
  belongs_to :replying_to_message, class_name: name
13
13
  scope :ordered, ->{ order(sent_at: :desc) }
@@ -6,7 +6,7 @@ module Renalware
6
6
  module Messaging
7
7
  module Internal
8
8
  class Recipient < ActiveType::Record[Renalware::User]
9
- has_many :receipts
9
+ has_many :receipts, dependent: :destroy
10
10
  has_many :messages, through: :receipts
11
11
  end
12
12
  end
@@ -5,7 +5,7 @@ require_dependency "renalware/messaging"
5
5
  module Renalware
6
6
  module Messaging
7
7
  class Patient < ActiveType::Record[Renalware::Patient]
8
- has_many :messages
8
+ has_many :messages, dependent: :restrict_with_exception
9
9
 
10
10
  def to_s(format = :long)
11
11
  super(format)