renalware-core 2.0.124 → 2.0.125

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/renalware/icons/more-horizontal.svg +1 -0
  3. data/app/assets/images/renalware/icons/more-vertical.svg +1 -0
  4. data/app/assets/stylesheets/renalware/modules/_surveys.scss +58 -0
  5. data/app/controllers/renalware/medications/prescriptions_controller.rb +1 -0
  6. data/app/controllers/renalware/pathology/requests/requests_controller.rb +1 -0
  7. data/app/controllers/renalware/pd/peritonitis_episodes_controller.rb +1 -1
  8. data/app/helpers/renalware/layout_helper.rb +1 -1
  9. data/app/helpers/renalware/primary_care_physicians_helper.rb +2 -1
  10. data/app/helpers/renalware/toggle_helper.rb +12 -0
  11. data/app/models/renalware/feeds/files/practice_memberships/import_job.rb +2 -2
  12. data/app/models/renalware/letters/letter_query.rb +1 -1
  13. data/app/models/renalware/pathology/observation_for_patient_observation_description_using_set_query.rb +2 -2
  14. data/app/models/renalware/pathology/observation_for_patient_request_description_query.rb +19 -5
  15. data/app/models/renalware/pathology/patient.rb +4 -0
  16. data/app/models/renalware/pathology/request_for_patient_request_description_query.rb +4 -2
  17. data/app/models/renalware/pathology/requests/global_algorithm.rb +4 -1
  18. data/app/models/renalware/pathology/requests/global_rule/observation_result.rb +21 -9
  19. data/app/models/renalware/pathology/requests/global_rule/prescription_drug.rb +1 -1
  20. data/app/models/renalware/pathology/requests/global_rule/prescription_drug_category.rb +2 -2
  21. data/app/models/renalware/pathology/requests/global_rule/prescription_drug_type.rb +1 -3
  22. data/app/models/renalware/pathology/requests/global_rule/request_result.rb +1 -1
  23. data/app/models/renalware/pathology/requests/global_rule_set/patient_rule_set_decision.rb +14 -5
  24. data/app/models/renalware/pd/create_regime.rb +2 -2
  25. data/app/models/renalware/ukrdc/incoming/import_surveys.rb +2 -2
  26. data/app/models/renalware/ukrdc/transmission_log.rb +1 -1
  27. data/app/models/renalware/ukrdc/treatment_timeline/hd/generator.rb +0 -3
  28. data/app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb +1 -1
  29. data/app/presenters/renalware/hd/protocol_presenter.rb +1 -1
  30. data/app/views/renalware/accesses/assessments/_list.html.slim +1 -2
  31. data/app/views/renalware/accesses/procedures/_list.html.slim +3 -4
  32. data/app/views/renalware/accesses/profiles/_list.html.slim +1 -2
  33. data/app/views/renalware/admissions/consults/_table.html.slim +3 -5
  34. data/app/views/renalware/drugs/drugs/index.html.slim +1 -2
  35. data/app/views/renalware/events/types/_table.html.slim +1 -2
  36. data/app/views/renalware/hd/cannulation_types/index.html.slim +1 -2
  37. data/app/views/renalware/hd/mdm/_top.html.slim +6 -4
  38. data/app/views/renalware/hd/scheduling/diary_slots/edit.html.slim +6 -1
  39. data/app/views/renalware/layouts/_patient.html.slim +1 -6
  40. data/app/views/renalware/letters/formatted_letters/_enclosures.html.slim +2 -0
  41. data/app/views/renalware/letters/formatted_letters/_letter.html.slim +2 -0
  42. data/app/views/renalware/letters/letters/_letter.html.slim +2 -2
  43. data/app/views/renalware/letters/letters/_table.html.slim +2 -2
  44. data/app/views/renalware/letters/lists/_letter.html.slim +1 -1
  45. data/app/views/renalware/low_clearance/mdm/_top.html.slim +1 -0
  46. data/app/views/renalware/mdm/_worryboard.html.slim +10 -0
  47. data/app/views/renalware/mdm/show.html.slim +3 -1
  48. data/app/views/renalware/modalities/descriptions/index.html.slim +1 -2
  49. data/app/views/renalware/pathology/required_observations/index.html.slim +1 -1
  50. data/app/views/renalware/patients/primary_care_physicians/_primary_care_physician.html.slim +1 -2
  51. data/app/views/renalware/pd/_pet_adequacies.html.slim +1 -2
  52. data/app/views/renalware/pd/_regimes.html.slim +1 -2
  53. data/app/views/renalware/pd/assessments/_list.html.slim +1 -2
  54. data/app/views/renalware/pd/bag_types/index.html.slim +1 -2
  55. data/app/views/renalware/pd/mdm/_top.html.slim +2 -1
  56. data/app/views/renalware/pd/training_sessions/_list.html.slim +1 -2
  57. data/app/views/renalware/renal/aki_alerts/_aki_alert.html.slim +3 -6
  58. data/app/views/renalware/renal/aki_alerts/_table.html.slim +2 -1
  59. data/app/views/renalware/reporting/audits/index.html.slim +1 -2
  60. data/app/views/renalware/surveys/_pos_s_summary_part.html.slim +14 -1
  61. data/app/views/renalware/surveys/dashboards/show.html.slim +1 -0
  62. data/app/views/renalware/system/messages/index.html.slim +1 -2
  63. data/app/views/renalware/transplants/mdm/_top.html.slim +1 -0
  64. data/config/initializers/simple_form_foundation.rb +10 -10
  65. data/db/functions/update_current_observation_set_from_trigger_v04.sql +1 -1
  66. data/lib/collection_presenter.rb +1 -1
  67. data/lib/renalware/version.rb +1 -1
  68. metadata +17 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 965f9e69a6b55986cb882e50b82928bb99b2208966d7258a0fe5856d9a593db1
4
- data.tar.gz: f93fa7318de181ff6177f5427570ad2fe005dad29845599ac7f27f606e49cd56
3
+ metadata.gz: f02d9c6095c5d84a50a76fb8b2b1a5c0167a5fbad53fbfdf886ac610e162dca3
4
+ data.tar.gz: fd8ac6bdca0f0b55ebb66c490ef77db34efca9f644ea88594d38fd74bb30d593
5
5
  SHA512:
6
- metadata.gz: 4000b4914976fb5c97455c8301b81e2076c32cf0400bc566f4613842f01570583a30b89f4aceda79c84dd478f57f55151b280859866fa8b8277317d4cad505aa
7
- data.tar.gz: 265d952f82bd209271be9b36abf72c2c556f5cbe729e3e0e74c6346d27c0bb82ca9425324fcc359199078811e34bca7de5d36a249c8fc33f6e5cfdd5399092d1
6
+ metadata.gz: 8ec5256950daad498967c57453f259a84fcace23c47006316c1e1a838d93db7edf0ea70353a875bece3dbd3c60c9fcafeab3c13c68a91f3ae3bb9897eab70da0
7
+ data.tar.gz: ac3ceff3c0f484bab79c5b00ca2bb78d64b6132455bb39e0eedad01163717be0b488c4107596ab0d93e8a0280fd835b3ad4940d80f37b147621b0780df294b67
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-more-horizontal"><circle cx="12" cy="12" r="1"></circle><circle cx="19" cy="12" r="1"></circle><circle cx="5" cy="12" r="1"></circle></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-more-vertical"><circle cx="12" cy="12" r="1"></circle><circle cx="12" cy="5" r="1"></circle><circle cx="12" cy="19" r="1"></circle></svg>
@@ -0,0 +1,58 @@
1
+ $survey-0: #fff;
2
+ $survey-1: #FFF8E8;
3
+ $survey-2: #FFE8B4;
4
+ $survey-3: #FFB81C;
5
+ $survey-4: #ED8B00;
6
+
7
+ dl.pos-s-key {
8
+ font-size: .9rem;
9
+ margin-top: 2rem;
10
+
11
+ dt, dd {
12
+ display: inline-block;
13
+ padding-right: .2rem;
14
+ }
15
+
16
+ dd {
17
+ padding: 0 .2rem;
18
+ margin-right: 1rem;
19
+ }
20
+
21
+ dt {
22
+ padding: 0 .5rem;
23
+ text-align: center;
24
+ border-radius: 3px;
25
+ border: solid 1px #DDD;
26
+ margin-right: .2rem;
27
+ }
28
+ }
29
+
30
+ .pos-s--0 {
31
+ background-color: $survey-0;
32
+ }
33
+
34
+ .pos-s--1 {
35
+ background-color: $survey-1;
36
+ }
37
+
38
+ .pos-s--2 {
39
+ background-color: $survey-2;
40
+ }
41
+
42
+ .pos-s--3 {
43
+ background-color: $survey-3;
44
+ }
45
+
46
+ .pos-s--4 {
47
+ background-color: $survey-4;
48
+ }
49
+
50
+ .summary-part--pos_s table {
51
+ td {
52
+ text-align: center;
53
+
54
+ &:first-child {
55
+ text-align: left;
56
+ }
57
+ }
58
+ }
@@ -65,6 +65,7 @@ module Renalware
65
65
  gp_provider_code = Provider.codes.find { |code| code == :gp }
66
66
  prescription = Prescription.new(treatable: treatable, provider: gp_provider_code)
67
67
  prescription.build_termination
68
+ prescription.prescribed_on = Date.current
68
69
  prescription
69
70
  end
70
71
 
@@ -104,6 +104,7 @@ module Renalware
104
104
  Pathology::OrderedPatientQuery
105
105
  .new(patient_ids)
106
106
  .call
107
+ .includes(:current_observation_set, :rules)
107
108
  authorize Renalware::Patient
108
109
  end
109
110
 
@@ -124,7 +124,7 @@ module Renalware
124
124
  :catheter_removed, :line_break, :exit_site_infection,
125
125
  :diarrhoea, :abdominal_pain, :fluid_description_id, :white_cell_total,
126
126
  :white_cell_neutro, :white_cell_lympho, :white_cell_degen,
127
- :white_cell_other, :notes, { episode_types: [] }
127
+ :white_cell_other, :notes, episode_types: []
128
128
  )
129
129
  end
130
130
  end
@@ -69,7 +69,7 @@ module Renalware
69
69
  old_formats = formats
70
70
  begin
71
71
  self.formats = [format]
72
- return yield
72
+ yield
73
73
  ensure
74
74
  self.formats = old_formats
75
75
  end
@@ -13,8 +13,9 @@ module Renalware
13
13
  if primary_care_physician.practices.any?
14
14
  return practices_list(primary_care_physician.practices)
15
15
  end
16
+
16
17
  if primary_care_physician.address.present?
17
- return format_address(primary_care_physician.address)
18
+ format_address(primary_care_physician.address)
18
19
  end
19
20
  end
20
21
 
@@ -30,5 +30,17 @@ module Renalware
30
30
  content_tag(:i)
31
31
  end
32
32
  end
33
+
34
+ def th_toggle_all_rows
35
+ content_tag(:th, class: "noprint togglers") do
36
+ table_toggler(link_title: "Toggle all rows")
37
+ end
38
+ end
39
+
40
+ def td_toggle_row(row_selector)
41
+ content_tag(:td, class: "noprint") do
42
+ toggler(row_selector)
43
+ end
44
+ end
33
45
  end
34
46
  end
@@ -11,7 +11,7 @@ module Renalware
11
11
  include Feeds::Job
12
12
  FILE_TO_EXTRACT_FROM_ARCHIVE = /epracmem.csv/.freeze
13
13
 
14
- # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
14
+ # rubocop:disable Metrics/AbcSize
15
15
  # TODO: refactor
16
16
  def perform(file)
17
17
  logging_to_stringio(strio = StringIO.new)
@@ -27,7 +27,7 @@ module Renalware
27
27
  ensure
28
28
  file.update!(status: status, result: strio.string, time_taken: elapsed_ms)
29
29
  end
30
- # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
30
+ # rubocop:enable Metrics/AbcSize
31
31
 
32
32
  private
33
33
 
@@ -7,7 +7,7 @@ module Renalware
7
7
  module QueryableLetter
8
8
  extend ActiveSupport::Concern
9
9
  included do
10
- self.ransacker :effective_date, type: :date do
10
+ ransacker :effective_date, type: :date do
11
11
  Arel.sql(Letter.effective_date_sort)
12
12
  end
13
13
 
@@ -5,7 +5,7 @@ require_dependency "renalware/pathology"
5
5
  module Renalware
6
6
  module Pathology
7
7
  class ObservationForPatientObservationDescriptionUsingSetQuery
8
- pattr_initialize :patient, :observation_description
8
+ pattr_initialize :patient, :observation_description_code
9
9
 
10
10
  # Fetches the patient's most recent observation for the supplied observation_description.code
11
11
  # (eg 'HGB') using the patient's current_observation_set jsonb hash and returnd something
@@ -13,7 +13,7 @@ module Renalware
13
13
  def call
14
14
  return {} unless patient.current_observation_set
15
15
 
16
- patient.current_observation_set.values.fetch(observation_description.code, {})
16
+ patient.current_observation_set.values.fetch(observation_description_code, {})
17
17
  end
18
18
  end
19
19
  end
@@ -10,12 +10,26 @@ module Renalware
10
10
  @observation_description = request_description.required_observation_description
11
11
  end
12
12
 
13
+ # I tried to switch over here to pulling the results from current_observation_set but]
14
+ # the dates seemed to be one year ahead in the test suite
13
15
  def call
14
- @patient
15
- .observations
16
- .where(description: @observation_description)
17
- .order(observed_at: :desc)
18
- .first
16
+ return if @observation_description.nil?
17
+
18
+ return if @patient.current_observation_set.nil?
19
+
20
+ result = @patient.current_observation_set.values[@observation_description.code]
21
+ if result
22
+ OpenStruct.new(
23
+ observed_on: Time.zone.parse(result["observed_at"]).to_date,
24
+ result: result["result"].to_f
25
+ )
26
+ end
27
+
28
+ # @patient
29
+ # .observations
30
+ # .where(description: @observation_description)
31
+ # .order(observed_at: :desc)
32
+ # .first
19
33
  end
20
34
  end
21
35
  end
@@ -40,6 +40,10 @@ module Renalware
40
40
  current_observation_set || build_current_observation_set
41
41
  end
42
42
 
43
+ def current_drug_ids
44
+ @current_drug_ids ||= prescriptions.current.pluck(:drug_id).uniq
45
+ end
46
+
43
47
  private
44
48
 
45
49
  def date_for_algorithms
@@ -7,19 +7,21 @@ module Renalware
7
7
  class RequestForPatientRequestDescriptionQuery
8
8
  def initialize(patient, request_description)
9
9
  @patient = patient
10
- @request_description = Renalware::Pathology::RequestDescription.find(request_description.id)
10
+ @request_description = request_description
11
11
  end
12
12
 
13
13
  def call
14
14
  @patient
15
15
  .requests
16
- .eager_load(:request_descriptions)
16
+ .includes(request_descriptions: :required_observation_description)
17
17
  .where(
18
18
  pathology_request_descriptions_requests_requests: {
19
19
  request_description_id: @request_description.id
20
20
  }
21
21
  )
22
22
  .order(created_at: :desc)
23
+ .limit(1)
24
+ .pluck(:created_at)
23
25
  .first
24
26
  end
25
27
  end
@@ -22,7 +22,10 @@ module Renalware
22
22
  private
23
23
 
24
24
  def rule_sets
25
- GlobalRuleSet.for_clinic(@clinic).ordered
25
+ GlobalRuleSet
26
+ .for_clinic(@clinic)
27
+ .ordered
28
+ .eager_load(:rules, request_description: :required_observation_description)
26
29
  end
27
30
  end
28
31
  end
@@ -17,19 +17,25 @@ module Renalware
17
17
  end
18
18
 
19
19
  def to_s
20
- "#{observation_description.code} " \
20
+ "#{observation_description_code} " \
21
21
  " #{param_comparison_operator} " \
22
22
  "#{param_comparison_value}"
23
23
  end
24
24
 
25
- def observation_description
26
- @observation_description ||= ObservationDescription.find_by(id: param_id)
25
+ # def observation_description
26
+ # @observation_description ||= ObservationDescription.where(id: param_id).first
27
+ # end
28
+
29
+ def observation_description_code
30
+ @observation_description_code ||= begin
31
+ ObservationDescription.where(id: param_id).pluck(:code).first
32
+ end
27
33
  end
28
34
 
29
35
  private
30
36
 
31
37
  def observation_description_present
32
- return if observation_description.present?
38
+ return if observation_description_code.present?
33
39
 
34
40
  errors.add(:param_id, "param_id must be the id of an ObservationDescription")
35
41
  end
@@ -37,7 +43,13 @@ module Renalware
37
43
 
38
44
  class PatientGlobalRuleDecision
39
45
  pattr_initialize :patient, :rule
40
- delegate :param_comparison_operator, :param_comparison_value, :param_id, to: :rule
46
+ delegate(
47
+ :param_comparison_operator,
48
+ :param_comparison_value,
49
+ :param_id,
50
+ :observation_description_code,
51
+ to: :rule
52
+ )
41
53
 
42
54
  def observation_required_for_patient?
43
55
  return true if observation.blank?
@@ -63,7 +75,7 @@ module Renalware
63
75
  # The call returns eg { "result" => "123", "observed_on" => "2019-01-01" }
64
76
  ObservationForPatientObservationDescriptionUsingSetQuery.new(
65
77
  patient,
66
- observation_description
78
+ observation_description_code
67
79
  ).call["result"]
68
80
 
69
81
  # ObservationForPatientObservationDescriptionQuery.new(
@@ -73,9 +85,9 @@ module Renalware
73
85
  end
74
86
  end
75
87
 
76
- def observation_description
77
- rule.observation_description ||= ObservationDescription.new(id: param_id)
78
- end
88
+ # def observation_description_code
89
+ # rule.observation_description_code # ||= ObservationDescription.new(id: param_id)
90
+ # end
79
91
  end
80
92
  end
81
93
  end
@@ -10,7 +10,7 @@ module Renalware
10
10
  validate :drug_present
11
11
 
12
12
  def observation_required_for_patient?(patient, _date)
13
- patient.drugs.exists?(id: param_id)
13
+ patient.current_drug_ids.include?(param_id.to_i)
14
14
  end
15
15
 
16
16
  def to_s
@@ -10,7 +10,7 @@ module Renalware
10
10
  validate :drug_category_present
11
11
 
12
12
  def observation_required_for_patient?(patient, _date)
13
- (patient.drugs.pluck(&:id) & drug_ids).any?
13
+ (patient.current_drug_ids & drug_ids).any?
14
14
  end
15
15
 
16
16
  def to_s
@@ -20,7 +20,7 @@ module Renalware
20
20
  private
21
21
 
22
22
  def drug_ids
23
- drug_category.drugs.pluck(&:id)
23
+ drug_category.drugs.pluck(:id)
24
24
  end
25
25
 
26
26
  def drug_category
@@ -11,9 +11,7 @@ module Renalware
11
11
 
12
12
  def observation_required_for_patient?(patient, _date)
13
13
  patient
14
- .drugs
15
- .select(:id)
16
- .joins(:classifications)
14
+ .prescriptions.current.joins(drug: :classifications)
17
15
  .where("drug_types_drugs.drug_type_id = ?", param_id)
18
16
  .count > 0
19
17
  end
@@ -36,7 +36,7 @@ module Renalware
36
36
  end
37
37
 
38
38
  def request_description
39
- RequestDescription.find_by(id: param_id)
39
+ RequestDescription.eager_load(:required_observation_description).find_by(id: param_id)
40
40
  end
41
41
 
42
42
  def request_description_present
@@ -32,14 +32,14 @@ module Renalware
32
32
  end
33
33
 
34
34
  def last_request_still_being_processed?
35
- return false if last_request.nil? || last_request_has_an_observation_result?
35
+ return false if last_request_date.nil? || last_request_has_an_observation_result?
36
36
 
37
37
  expiration_days = rule_set.request_description.expiration_days
38
38
  return false if expiration_days == 0
39
39
 
40
40
  # This subtraction works because ActiveSupport::TimeWithZone works in days
41
41
  # e.g. TimeWithZone1 - TimeWithZone2 = 3 days
42
- requested_days_ago = date - last_request.requested_on
42
+ requested_days_ago = date - last_request_date.to_date
43
43
  requested_days_ago < expiration_days
44
44
  end
45
45
 
@@ -53,7 +53,7 @@ module Renalware
53
53
  # NB request.requested_on == request.created_at
54
54
  def last_request_has_an_observation_result?
55
55
  last_observation.present? &&
56
- last_observation.observed_on > last_request.requested_on
56
+ last_observation.observed_on > last_request_date
57
57
  end
58
58
 
59
59
  def last_observation
@@ -64,8 +64,17 @@ module Renalware
64
64
  ).call
65
65
  end
66
66
 
67
- def last_request
68
- @last_request ||=
67
+ # def last_request
68
+ # raise 'u'
69
+ # @last_request ||=
70
+ # RequestForPatientRequestDescriptionQuery.new(
71
+ # patient,
72
+ # rule_set.request_description
73
+ # ).call
74
+ # end
75
+
76
+ def last_request_date
77
+ @last_request_date ||=
69
78
  RequestForPatientRequestDescriptionQuery.new(
70
79
  patient,
71
80
  rule_set.request_description
@@ -14,9 +14,9 @@ module Renalware
14
14
  def call(by:, params:)
15
15
  regime = patient.pd_regimes.new(params)
16
16
  if regime.valid? && save_regime(regime, by)
17
- return ::Renalware::Success.new(regime)
17
+ ::Renalware::Success.new(regime)
18
18
  else
19
- return ::Renalware::Failure.new(regime)
19
+ ::Renalware::Failure.new(regime)
20
20
  end
21
21
  end
22
22