renalware-core 2.0.18 → 2.0.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (25) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/renalware/events/events_controller.rb +1 -1
  3. data/app/jobs/renalware/hd/generate_monthly_statistics_job.rb +1 -1
  4. data/app/mailers/renalware/letters/delivery/errors.rb +1 -1
  5. data/app/mailers/renalware/letters/delivery/practice_mailer.rb +5 -1
  6. data/app/models/concerns/renalware/letters/letter_pathology.rb +0 -2
  7. data/app/models/renalware/admissions/consult_query.rb +1 -0
  8. data/app/models/renalware/hd/generate_monthly_statistics_for_patient.rb +37 -0
  9. data/app/models/renalware/letters/delivery/email_letter_to_practice.rb +10 -1
  10. data/app/models/renalware/renal/aki_alert_query.rb +1 -0
  11. data/app/presenters/renalware/letters/practice_email_meta_data.rb +5 -0
  12. data/app/views/renalware/admissions/consults/_filters.html.slim +0 -9
  13. data/app/views/renalware/admissions/consults/_table.html.slim +5 -8
  14. data/app/views/renalware/dashboard/bookmarks/_table.html.slim +1 -1
  15. data/app/views/renalware/renal/aki_alerts/_aki_alert.html.slim +1 -0
  16. data/app/views/renalware/renal/aki_alerts/_table.html.slim +3 -1
  17. data/db/migrate/20180419141524_add_cols_to_hd_patient_statistics.rb +10 -0
  18. data/db/migrate/20180422090043_update_hd_overall_audit_to_version_6.rb +91 -0
  19. data/db/seeds/default/reporting/audits.yml +30 -5
  20. data/db/views/reporting_hd_overall_audit_v06.sql +44 -0
  21. data/lib/renalware/version.rb +1 -1
  22. data/lib/tasks/ukrdc.rake +34 -7
  23. data/spec/factories/hd/patient_statistics.rb +21 -2
  24. data/spec/factories/pathology/observation_descriptions.rb +7 -0
  25. metadata +5 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d8f98055c0ba3c1fa08f211f731247951b6b819e62c828e743e96962ce7968c6
4
- data.tar.gz: 6e1bce7c200282e59707e523523f11de57cc8291abf707775fa3a33268c7c136
3
+ metadata.gz: 8e1fbdf118aac168c7b1662ba8514d197bc7dbb520cfea70c2db52120d1a8f35
4
+ data.tar.gz: ee61a87fbb969e571a1cd37d23446ce3d4c32ba439f768e73bcd6e1aeb2092de
5
5
  SHA512:
6
- metadata.gz: b1c3dca6e10fc4e86ea191ed1331c9aff394599238db64850c3a0b50cbfa5f530f0551a239d0bfb62393bf431f40e79970c96719f9066f772434132fa9eb9910
7
- data.tar.gz: ca427a97413003d6eaf1992ca8dcbd72b7fb74949232aed5714e3555ae2907439162a09af54de3e13951600b347864685aaea692ee00e9d368f67ba20944ac15
6
+ metadata.gz: ecb654a9c098a41bd8f50eb870312480b77655b6d5c19eba163d287c427cd19fa76b8747d98a198dff695c714b5331585f6eb3cfd3d7d2bf8426af6fb98caff2
7
+ data.tar.gz: 57de76f0a5b9eb77cea4655a171d0b1d9c03df7d2ec525f505372e6802e6cd66b36642343601173cf78d51cf586c3509f066451fbfaa9f44139cf3a3ff39b4f4
@@ -108,7 +108,7 @@ module Renalware
108
108
 
109
109
  def build_new_event
110
110
  event = new_event_for_patient
111
- event.date_time = Time.zone.now.beginning_of_hour
111
+ event.date_time = Time.zone.now
112
112
  event.event_type = event_type
113
113
  # disable_selection_of_event_type is a virtual attribute
114
114
  event.disable_selection_of_event_type = disable_selection_of_event_type?
@@ -37,7 +37,7 @@ module Renalware
37
37
  end
38
38
 
39
39
  def date_falling_in_the_previous_month
40
- @date ||= Time.zone.today - 1.month
40
+ @date_falling_in_the_previous_month ||= Time.zone.today - 1.month
41
41
  end
42
42
  end
43
43
  end
@@ -5,7 +5,7 @@ require_dependency "renalware/letters"
5
5
  module Renalware
6
6
  module Letters
7
7
  module Delivery
8
- class PatientHasNoPracticeError < StandardError; end
8
+ class LetterIsNotApprovedOrCompletedError < StandardError; end
9
9
  end
10
10
  end
11
11
  end
@@ -7,6 +7,8 @@ require_relative "./errors"
7
7
  module Renalware
8
8
  module Letters
9
9
  module Delivery
10
+ # Note PracticeMailer not the best name as we use this mailer to send a letter to any
11
+ # recipient (practices, hospital secretaries etc)
10
12
  class PracticeMailer < ApplicationMailer
11
13
  def patient_letter(letter:, to:)
12
14
  validate_letter(letter)
@@ -49,7 +51,9 @@ module Renalware
49
51
  end
50
52
 
51
53
  def validate_letter(letter)
52
- raise Delivery::PatientHasNoPracticeError if letter.patient&.practice.blank?
54
+ unless letter.approved? || letter.completed?
55
+ raise Delivery::LetterIsNotApprovedOrCompletedError, letter.id
56
+ end
53
57
  end
54
58
  end
55
59
  end
@@ -9,8 +9,6 @@ module Renalware
9
9
 
10
10
  # Filters a set of observations using a specific set of OBX codes
11
11
  class FilteredObservationSet
12
- EMPTY_SNAPSHOT = {}.freeze
13
-
14
12
  def initialize(observation_set:, codes: nil)
15
13
  @codes = codes || RelevantObservationDescription.all.map(&:code)
16
14
  @observation_set = observation_set
@@ -24,6 +24,7 @@ module Renalware
24
24
  @search ||= begin
25
25
  Consult
26
26
  .joins(:patient)
27
+ .eager_load(patient: [current_modality: :description])
27
28
  .includes(
28
29
  :created_by,
29
30
  :consult_site,
@@ -24,6 +24,7 @@ module Renalware
24
24
  stats.hospital_unit = most_recently_used_hospital_unit(sessions)
25
25
  stats.assign_attributes(auditable_sessions(sessions).to_h)
26
26
  stats.session_count = sessions.length
27
+ stats.pathology_snapshot = capture_pathology_snapshot
27
28
  stats.save!
28
29
  end
29
30
 
@@ -43,6 +44,42 @@ module Renalware
43
44
  def most_recently_used_hospital_unit(sessions)
44
45
  sessions.last&.hospital_unit
45
46
  end
47
+
48
+ def capture_pathology_snapshot
49
+ FilteredObservationSet.new(patient: patient).to_h
50
+ end
51
+
52
+ # Filters a set of observations using a specific set of OBX codes.
53
+ # The snapshot is stored on the hd_patient_statistics table - i.e. it represents
54
+ # the state of the patient's pathology *at the time the hd_stats row is created*.
55
+ # So for an hd_stats row for say Patient X in the month of April 2018, the
56
+ # pathology_snapshot is a frozen snapshot of their pathology at 30/4/2018 23:59
57
+ # TODO: de-dupe this with the other FilteredObservationSet in Letters::?
58
+ class FilteredObservationSet
59
+ # These are the codes for the results we want to store in
60
+ # hd_patient_statics.pathology_snapshot - we are only interested in these
61
+ # results. They will be used for instance in reporting_hd_overall_audit
62
+ CODES = %w(HGB PTH PHOS CRE URE URR).freeze
63
+
64
+ def initialize(patient:)
65
+ @observation_set = Pathology.cast_patient(patient).fetch_current_observation_set
66
+ end
67
+
68
+ # Returns a hash of the filtered observations e.g.
69
+ # {
70
+ # "HGB"=>{"result"=>"139", "observed_at"=>"2016-03-15T03:28:00"},
71
+ # "URR"=>{"result"=>"49", "observed_at"=>"2016-03-15T03:28:00"},
72
+ # ...
73
+ # }
74
+ def to_h
75
+ return {} if observation_set.blank?
76
+ observation_set.values.select { |code, _| CODES.include?(code.to_s) }
77
+ end
78
+
79
+ private
80
+
81
+ attr_reader :observation_set
82
+ end
46
83
  end
47
84
  end
48
85
  end
@@ -28,9 +28,18 @@ module Renalware
28
28
  private
29
29
 
30
30
  def email_letter_to_the_patients_practice
31
+ # Note we cast the letter back to the superclass Letters::Letter here to prevent
32
+ # GlobalID from trying to load the letter using e.g. Letters::Approved.find(123), because
33
+ # in the meantime the letter's class might have progressed to Letters::Completed in which
34
+ # case GlobalId/ ActiveJob would not be able to find the letter!
35
+ # Casting to Letters::Letter means in the delayed job the handler says e.g.
36
+ # - letter:
37
+ # _aj_globalid: gid://dummy/Renalware::Letters::Letter/3
38
+ # which it turns out works fine when the letter is loaded by GlobalId/ActiveJob;
39
+ # it correctly casts the letter to its STI type e.g. Letters::Approved in the job.
31
40
  Letter.transaction do
32
41
  PracticeMailer.patient_letter(
33
- letter: letter,
42
+ letter: letter.becomes(Letter),
34
43
  to: practice_email_address
35
44
  ).deliver_later
36
45
 
@@ -26,6 +26,7 @@ module Renalware
26
26
  AKIAlert
27
27
  .joins(:patient) # required for PatientsRansackHelper - see Admission
28
28
  .includes(:patient, :updated_by, :action, hospital_ward: :hospital_unit)
29
+ .eager_load(patient: [current_modality: :description])
29
30
  .public_send(query[:named_filter].to_s)
30
31
  .ransack(query)
31
32
  end
@@ -19,6 +19,7 @@ module Renalware
19
19
  #
20
20
  class PracticeEmailMetaData
21
21
  NullPrimaryCarePhysician = Naught.build(&:define_explicit_conversions)
22
+ NullPractice = Naught.build(&:define_explicit_conversions)
22
23
 
23
24
  pattr_initialize [
24
25
  :letter!,
@@ -82,6 +83,10 @@ module Renalware
82
83
  def primary_care_physician
83
84
  @primary_care_physician ||= NullPrimaryCarePhysician.new
84
85
  end
86
+
87
+ def practice
88
+ @practice ||= NullPractice.new
89
+ end
85
90
  end
86
91
  end
87
92
  end
@@ -11,10 +11,6 @@
11
11
  = f.input :consult_site_id_eq,
12
12
  collection: Renalware::Admissions::ConsultSite.pluck(:name, :id),
13
13
  label: "Site"
14
- .columns.medium-1.large-1
15
- = f.input :requires_aki_nurse_eq,
16
- collection: [["Yes", true], ["No", false]],
17
- label: "AKI Nurse?"
18
14
  .columns.medium-2.large-1
19
15
  = f.input :seen_by_id_eq,
20
16
  include_blank: false,
@@ -30,11 +26,6 @@
30
26
  include_blank: true,
31
27
  collection: [["Yes", true], ["No", false]],
32
28
  label: "Active"
33
- .columns.medium-1.large-1
34
- = f.input :rrt_eq,
35
- include_blank: true,
36
- collection: [["Yes", true], ["No", false]],
37
- label: "RRT"
38
29
  .columns.medium-2.large-2.actions.end
39
30
  = f.submit "Filter", class: "button"
40
31
  span= " or "
@@ -13,13 +13,12 @@
13
13
  "Location")
14
14
  th.col-width-date.noprint= sort_link(query, :started_on, "Started")
15
15
  th.col-width-date.noprint= sort_link(query, :ended_on, "Ended")
16
- th.col-width-small.show-for-large-up Modality
16
+ th.col-width-small.show-for-large-up
17
+ = sort_link([:renalware, query], :patient_current_modality_description_name, "Modality")
17
18
  th.col-width-tiny.show-for-large-up Sex
18
19
  th.col-width-date.show-for-large-up= sort_link(query, :patient_born_on, "DOB")
19
- th.col-width-tiny.show-for-large-up.noprint Age
20
- th.col-width-tiny RRT?
20
+ th.col-width-tiny.show-for-large-up Age
21
21
  th.col-width-tiny.noprint= sort_link(query, :aki_risk, "AKI Risk")
22
- th.col-width-tiny.noprint= sort_link(query, :requires_aki_nurse, " AKI Nurse?")
23
22
  /th.show-for-large-up Author
24
23
  /th.col-width-medium.show-for-xlarge-up Description
25
24
 
@@ -68,14 +67,12 @@
68
67
  td.show-for-large-up.col-width-medium-with-ellipsis= consult.patient_current_modality
69
68
  td.show-for-large-up= consult.patient_sex
70
69
  td.show-for-large-up= l(consult.patient.born_on)
71
- td.show-for-large-up.noprint= consult.patient_age
72
- td= yes_no(consult.rrt)
70
+ td.show-for-large-up= consult.patient_age
73
71
  td.noprint= consult.aki_risk&.text
74
- td.noprint= yes_no(consult.requires_aki_nurse)
75
72
  /td.show-for-xlarge-up.consult-author.col-width-medium-with-ellipsis(title=consult.created_by)= consult.created_by
76
73
  /td.col-width-medium-with-ellipsis(title=consult.description)= consult.description
77
74
  = content_tag(:tr, id: "consult-quick-preview-#{consult.id}", style: "display: none")
78
- td(colspan=12)
75
+ td(colspan=11)
79
76
  .quick-preview
80
77
  dl.dl-horizontal
81
78
  dt Author
@@ -7,7 +7,7 @@ table.auto-layout
7
7
  th.col-width-date= t(".born_on")
8
8
  th.col-width-tiny= t(".age")
9
9
  th.col-width-tiny= t(".sex")
10
- th.col-width-small= t(".modality")
10
+ th.col-width-medium= t(".modality")
11
11
  th= t(".notes")
12
12
  th= t(".tags")
13
13
  th.col-width-date-time= t(".bookmarked_on")
@@ -8,6 +8,7 @@ tr(class="#{'aki_alert--hotlist' if aki_alert.hotlist?}")
8
8
  data: { behaviour: "toggler" })
9
9
  td= default_patient_link(aki_alert.patient)
10
10
  td= aki_alert.patient.hospital_identifiers
11
+ td.show-for-large-up.col-width-medium-with-ellipsis= aki_alert.patient.current_modality
11
12
  td= aki_alert.patient.sex
12
13
  td= aki_alert.patient.age
13
14
  td= aki_alert.action
@@ -1,8 +1,10 @@
1
1
  table.aki-alerts
2
2
  thead
3
3
  th.col-width-small
4
- th.col-width-large Patient
4
+ th.col-width-large= sort_link(search, :patient_family_name, "Patient")
5
5
  th.col-width-reference-no Hosp. No.
6
+ th.col-width-small.show-for-large-up
7
+ = sort_link([:renalware, search], :patient_current_modality_description_name, "Modality")
6
8
  th.col-width-tiny Sex
7
9
  th.col-width-tiny Age
8
10
  th= sort_link(search, :action_name, "Action")
@@ -0,0 +1,10 @@
1
+ class AddColsToHDPatientStatistics < ActiveRecord::Migration[5.1]
2
+ def change
3
+ add_column :hd_patient_statistics,
4
+ :pathology_snapshot,
5
+ :jsonb,
6
+ index: { using: :gin },
7
+ default: {},
8
+ null: false
9
+ end
10
+ end
@@ -0,0 +1,91 @@
1
+ # rubocop:disable Metrics/MethodLength
2
+ class UpdateHDOverallAuditToVersion6 < ActiveRecord::Migration[5.1]
3
+ def change
4
+ update_view :reporting_hd_overall_audit,
5
+ materialized: true,
6
+ version: 6,
7
+ revert_to_version: 5
8
+
9
+ reversible do |direction|
10
+ direction.up do
11
+ connection.execute <<-SQL
12
+ update reporting_audits set display_configuration = '
13
+ {
14
+ "columnDefs": [
15
+ {
16
+ "title": "Unit",
17
+ "width": "300",
18
+ "data": "name"
19
+ },
20
+ {
21
+ "title": "Year",
22
+ "width": "100",
23
+ "data": "year"
24
+ },
25
+ {
26
+ "title": "Month",
27
+ "width": "100",
28
+ "data": "month"
29
+ },
30
+ {
31
+ "title": "No. patients",
32
+ "width": "100",
33
+ "data": "patient_count"
34
+ },
35
+ {
36
+ "title": "% HGB > 100",
37
+ "width": "120",
38
+ "data": "percentage_hgb_gt_100"
39
+ },
40
+ {
41
+ "title": "% HGB > 130",
42
+ "width": "120",
43
+ "data": "percentage_hgb_gt_130"
44
+ },
45
+ {
46
+ "title": "% Phosphate < 1.8",
47
+ "width": "120",
48
+ "data": "percentage_phosphate_lt_1_8"
49
+ },
50
+ {
51
+ "title": "% PTH < 300",
52
+ "width": "120",
53
+ "data": "percentage_pth_lt_300"
54
+ },
55
+ {
56
+ "title": "% URR > 64",
57
+ "width": "120",
58
+ "data": "percentage_urr_gt_64"
59
+ },
60
+ {
61
+ "title": "% URR > 69",
62
+ "width": "120",
63
+ "data": "percentage_urr_gt_69"
64
+ },
65
+ {
66
+ "title": "% w/fistula or graft",
67
+ "width": "120",
68
+ "data": "percentage_access_fistula_or_graft"
69
+ },
70
+ {
71
+ "title": "Avg. missed HD time",
72
+ "width": "120",
73
+ "data": "avg_missed_hd_time"
74
+ },
75
+ {
76
+ "title": "% sessions >5% dialysis time missed",
77
+ "width": "200",
78
+ "data": "pct_missed_sessions_gt_10_pct"
79
+ },
80
+ {
81
+ "title": "% missing >10% HD sessions",
82
+ "width": "150",
83
+ "data": "pct_shortfall_gt_5_pct"
84
+ }
85
+ ]
86
+ }';
87
+ SQL
88
+ end
89
+ end
90
+ end
91
+ end
@@ -84,6 +84,16 @@
84
84
  "width": "300",
85
85
  "data": "name"
86
86
  },
87
+ {
88
+ "title": "Year",
89
+ "width": "100",
90
+ "data": "year"
91
+ },
92
+ {
93
+ "title": "Month",
94
+ "width": "100",
95
+ "data": "month"
96
+ },
87
97
  {
88
98
  "title": "No. patients",
89
99
  "width": "120",
@@ -92,18 +102,33 @@
92
102
  {
93
103
  "title": "% HGB > 100",
94
104
  "width": "120",
95
- "data": "percentage_hb_gt_100"
105
+ "data": "percentage_hgb_gt_100"
96
106
  },
97
107
  {
98
- "title": "% URR > 65",
108
+ "title": "% HGB > 130",
99
109
  "width": "120",
100
- "data": "percentage_urr_gt_65"
110
+ "data": "percentage_hgb_gt_130"
101
111
  },
102
112
  {
103
113
  "title": "% Phosphate < 1.8",
104
114
  "width": "200",
105
115
  "data": "percentage_phosphate_lt_1_8"
106
116
  },
117
+ {
118
+ "title": "% PTH < 300",
119
+ "width": "200",
120
+ "data": "percentage_pth_lt_300"
121
+ },
122
+ {
123
+ "title": "% URR > 64",
124
+ "width": "120",
125
+ "data": "percentage_urr_gt_64"
126
+ },
127
+ {
128
+ "title": "% URR > 69",
129
+ "width": "120",
130
+ "data": "percentage_urr_gt_69"
131
+ },
107
132
  {
108
133
  "title": "% w/fistula or graft",
109
134
  "width": "200",
@@ -115,9 +140,9 @@
115
140
  "data": "avg_missed_hd_time"
116
141
  },
117
142
  {
118
- "title": "% missing >5% HD time",
143
+ "title": "% missing >10% HD time",
119
144
  "width": "200",
120
- "data": "pct_shortfall_gt_5_pct"
145
+ "data": "pct_shortfall_gt_10_pct"
121
146
  }
122
147
  ]
123
148
  }
@@ -0,0 +1,44 @@
1
+ with fistula_or_graft_access_types as (
2
+ select id
3
+ from access_types
4
+ where name ilike '%fistula%' or name ilike '%graft%'
5
+ ),
6
+ stats as (
7
+ select
8
+ s.patient_id,
9
+ s.hospital_unit_id,
10
+ s.month,
11
+ s.year,
12
+ s.session_count,
13
+ s.number_of_missed_sessions,
14
+ s.number_of_sessions_with_dialysis_minutes_shortfall_gt_5_pct,
15
+ ((number_of_missed_sessions::float / NULLIF(session_count::float, 0)) * 100.0) > 10.0 as missed_sessions_gt_10_pct,
16
+ s.dialysis_minutes_shortfall::float,
17
+ convert_to_float(s.pathology_snapshot -> 'HGB' ->> 'result') > 100 as hgb_gt_100,
18
+ convert_to_float(s.pathology_snapshot -> 'HGB' ->> 'result') > 130 as hgb_gt_130,
19
+ convert_to_float(s.pathology_snapshot -> 'PTH' ->> 'result') < 300 as pth_lt_300,
20
+ convert_to_float(s.pathology_snapshot -> 'URR' ->> 'result') > 64 as urr_gt_64,
21
+ convert_to_float(s.pathology_snapshot -> 'URR' ->> 'result') > 69 as urr_gt_69,
22
+ convert_to_float(s.pathology_snapshot -> 'PHOS' ->> 'result') < 1.8 as phos_lt_1_8
23
+ from hd_patient_statistics s
24
+ where s.rolling is null
25
+ )
26
+ select
27
+ hu.name,
28
+ stats.year,
29
+ stats.month,
30
+ count(*) as patient_count,
31
+ avg(stats.dialysis_minutes_shortfall) as avg_missed_hd_time,
32
+ avg(number_of_sessions_with_dialysis_minutes_shortfall_gt_5_pct) as pct_shortfall_gt_5_pct,
33
+ (count(*) filter(where missed_sessions_gt_10_pct = true))::float / count(*)::float * 100 as pct_missed_sessions_gt_10_pct,
34
+ (count(*) filter(where hgb_gt_100 = true))::float / count(*)::float * 100 as percentage_hgb_gt_100,
35
+ (count(*) filter(where hgb_gt_130 = true))::float / count(*)::float * 100 as percentage_hgb_gt_130,
36
+ (count(*) filter(where pth_lt_300 = true))::float / count(*)::float * 100 as percentage_pth_lt_300,
37
+ (count(*) filter(where urr_gt_64 = true))::float / count(*)::float * 100 as percentage_urr_gt_64,
38
+ (count(*) filter(where urr_gt_69 = true))::float / count(*)::float * 100 as percentage_urr_gt_69,
39
+ (count(*) filter(where phos_lt_1_8 = true))::float / count(*)::float * 100 as percentage_phosphate_lt_1_8,
40
+ 'TBC' as percentage_access_fistula_or_graft
41
+ from stats
42
+ inner join hospital_units hu on hu.id = stats.hospital_unit_id
43
+ group by hu.name, stats.year, stats.month
44
+ order by hu.name, stats.year asc, stats.month asc;
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Renalware
4
- VERSION = "2.0.18"
4
+ VERSION = "2.0.20"
5
5
  end
data/lib/tasks/ukrdc.rake CHANGED
@@ -1,16 +1,43 @@
1
1
  require "fileutils"
2
2
  require "gpgme"
3
3
 
4
- # Need to bear in mind we if we find a patient with changes, we still don't take everything
5
- # the patient has but only those bits modified since the last export or :since_date
6
- #
4
+ # Note you can print out the help for this task and others with `rake -D`
7
5
  namespace :ukrdc do
8
- desc "Creates a folder of UKRDC XML files containing any changes to PV patients since "\
9
- "their last export"
10
- task :export, [:changed_since, :patient_ids] => [:environment] do |t, args|
6
+ desc <<-DESC
7
+ Creates a folder of UKRDC XML files with any changes to PV patients since their last export
8
+ Notes:
9
+ 1. Running the rake task updates the sent_to_ukrdc_at for each patient exported.
10
+ If you don't want to do this you may need to edit this task to wrpt the code in a
11
+ transaction you can optionally roll back.
12
+ 2: If testing this inside the renalware-core gem, you will need to append app: e.g.
13
+ app:ukrdc:export ...
14
+
15
+ Example usage
16
+ 1. To get all patients with send_to_rpv=true who have changed since the last time they
17
+ were sent, or have not been sent to the UKRDC yet:
18
+
19
+ bundle exec rake ukrdc:export
20
+
21
+ 2. To get all patients with send_to_rpv=true who have changed since a certain date:
22
+
23
+ bundle exec rake ukrdc:export["2018-02-23"]
24
+ or in zsh shell
25
+ bundle exec rake ukrdc:export\["2018-02-23"\]
26
+
27
+ 3. To get only certain RPV patients (by their id eg ids 1 and 2) who with changes since
28
+ a certain time (not pass patient ids in a space delimited string:
29
+
30
+ bundle exec rake ukrdc:export["2018-02-23","1 2"]
31
+ or in the zsh shell
32
+ bundle exec rake ukrdc:export\["2018-02-23","1 2"\]
33
+ DESC
34
+ task :export, [:changed_since, :patient_ids] => [:environment] do |_task, args|
11
35
  logger = Logger.new(STDOUT)
12
36
  logger.level = Logger::INFO
13
37
  Rails.logger = logger
14
- Renalware::UKRDC::SendPatients.new(**args.to_h).call
38
+ Renalware::UKRDC::SendPatients.new(
39
+ changed_since: args[:changed_since],
40
+ patient_ids: args.fetch(:patient_ids, "").split(" ").map(&:to_i)
41
+ ).call
15
42
  end
16
43
  end
@@ -4,7 +4,26 @@ FactoryBot.define do
4
4
  factory :hd_patient_statistics, class: "Renalware::HD::PatientStatistics" do
5
5
  patient factory: :hd_patient
6
6
  association :hospital_unit, factory: :hospital_unit
7
- month 0 # rolling
8
- year 0 # rolling
7
+ month 1
8
+ year 2018
9
+ # rolling false
10
+ pre_mean_systolic_blood_pressure 0
11
+ pre_mean_diastolic_blood_pressure 0
12
+ post_mean_systolic_blood_pressure 0
13
+ post_mean_diastolic_blood_pressure 0
14
+ lowest_systolic_blood_pressure 0
15
+ highest_systolic_blood_pressure 0
16
+ mean_fluid_removal 0
17
+ mean_weight_loss 0
18
+ mean_machine_ktv 0
19
+ mean_blood_flow 0
20
+ mean_litres_processed 0
21
+ session_count 0
22
+ number_of_missed_sessions 0
23
+ dialysis_minutes_shortfall 0
24
+ dialysis_minutes_shortfall_percentage 0
25
+ mean_ufr 0
26
+ mean_weight_loss_as_percentage_of_body_weight 0
27
+ number_of_sessions_with_dialysis_minutes_shortfall_gt_5_pct 0
9
28
  end
10
29
  end
@@ -15,5 +15,12 @@ FactoryBot.define do
15
15
  display_order 1
16
16
  letter_group 1
17
17
  letter_order 1
18
+
19
+ %i(urr ure hgb cre phos pth).each do |code|
20
+ trait code do
21
+ code code.to_s.upcase
22
+ name code.to_s.upcase
23
+ end
24
+ end
18
25
  end
19
26
  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.18
4
+ version: 2.0.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Airslie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-24 00:00:00.000000000 Z
11
+ date: 2018-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_type
@@ -3213,6 +3213,8 @@ files:
3213
3213
  - db/migrate/20180326155400_add_admin_notes_to_system_user_feedback.rb
3214
3214
  - db/migrate/20180327100423_add_constraints_to_recipient_operations.rb
3215
3215
  - db/migrate/20180328210434_add_rrt_to_admission_consults.rb
3216
+ - db/migrate/20180419141524_add_cols_to_hd_patient_statistics.rb
3217
+ - db/migrate/20180422090043_update_hd_overall_audit_to_version_6.rb
3216
3218
  - db/seeds.rb
3217
3219
  - db/seeds/default/accesses/access_pd_catheter_insertion_techniques.csv
3218
3220
  - db/seeds/default/accesses/access_pd_catheter_insertion_techniques.rb
@@ -3315,6 +3317,7 @@ files:
3315
3317
  - db/views/reporting_hd_overall_audit_v02.sql
3316
3318
  - db/views/reporting_hd_overall_audit_v04.sql
3317
3319
  - db/views/reporting_hd_overall_audit_v05.sql
3320
+ - db/views/reporting_hd_overall_audit_v06.sql
3318
3321
  - db/views/reporting_main_authors_audit_v01.sql
3319
3322
  - db/views/reporting_main_authors_audit_v02.sql
3320
3323
  - db/views/reporting_pd_audit_v01.sql