renalware-core 2.0.22 → 2.0.23
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.
- checksums.yaml +4 -4
- data/app/jobs/renalware/hd/generate_monthly_statistics.rb +63 -0
- data/app/models/renalware/medications/terminate_all_patient_prescriptions.rb +1 -1
- data/lib/renalware/version.rb +1 -1
- data/lib/tasks/audit.rake +22 -2
- metadata +3 -3
- data/app/jobs/renalware/hd/generate_monthly_statistics_job.rb +0 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ac09f0c3708048edefc8c1040650e7efee4de9209837d547e97bdf06e30ae38
|
4
|
+
data.tar.gz: 1029728c82c3f5cfe5c782fcebae7247fb5401815c2e2afbe8fb9ab35c230b15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48522cd5f0e8569574ea14b1933169821b1768c548b139cf14935a8c26839dd476a397cc2ba397291ba049091f9118e12f4ad32310741089da6a4a942eed8de7
|
7
|
+
data.tar.gz: fdff52784eba369df4e5dc806e9c083302372bdb327ba4c9df3adf057cee64396421e962d217a7b9593947a56f80ac8c1f3148c6de4cec2d46017a24f42ba0bc
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "month_period"
|
4
|
+
|
5
|
+
# This job when executed will store a snapshot of last month's HD session statistics
|
6
|
+
# for each HD patient.
|
7
|
+
module Renalware
|
8
|
+
module HD
|
9
|
+
class GenerateMonthlyStatistics < ApplicationJob
|
10
|
+
attr_reader :period
|
11
|
+
|
12
|
+
def initialize(month: nil, year: nil)
|
13
|
+
validate_args(month: month, year: year)
|
14
|
+
|
15
|
+
@period = Renalware::MonthPeriod.new(
|
16
|
+
month: (month || default_month).to_i,
|
17
|
+
year: (year || default_year).to_i
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
# :reek:UtilityFunction
|
22
|
+
def call
|
23
|
+
patients_with_a_closed_hd_session_in_period.each do |patient|
|
24
|
+
GenerateMonthlyStatisticsForPatientJob.perform_later(
|
25
|
+
patient: patient,
|
26
|
+
month: period.month,
|
27
|
+
year: period.year
|
28
|
+
)
|
29
|
+
end
|
30
|
+
Rails.logger.info(
|
31
|
+
"Enqueued GenerateMonthlyStatisticsForPatientJob jobs for "\
|
32
|
+
"#{patients_with_a_closed_hd_session_in_period.length} patients"
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def validate_args(month:, year:)
|
39
|
+
if (month.present? && year.blank?) || (month.blank? && year.present?)
|
40
|
+
raise(ArgumentError, "Must supply both month and year if supplying one or the other")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def patients_with_a_closed_hd_session_in_period
|
45
|
+
@patients_with_a_closed_hd_session_in_period ||= begin
|
46
|
+
Sessions::AuditablePatientsInPeriodQuery.new(period: period).call
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def default_month
|
51
|
+
date_falling_in_the_previous_month.month
|
52
|
+
end
|
53
|
+
|
54
|
+
def default_year
|
55
|
+
date_falling_in_the_previous_month.year
|
56
|
+
end
|
57
|
+
|
58
|
+
def date_falling_in_the_previous_month
|
59
|
+
@date_falling_in_the_previous_month ||= Time.zone.today - 1.month
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/lib/renalware/version.rb
CHANGED
data/lib/tasks/audit.rake
CHANGED
@@ -1,8 +1,28 @@
|
|
1
1
|
begin
|
2
2
|
namespace :audit do
|
3
|
-
desc
|
3
|
+
desc <<-DESC
|
4
|
+
Queues delayed jobs to generate monthly HD audits for each patient with a signed-off HD
|
5
|
+
Session in the specified month and year. If no year or month supplied, it will generate
|
6
|
+
stats for last month for each patient.
|
7
|
+
|
8
|
+
Example usage:
|
9
|
+
|
10
|
+
To generate monthly stats for last month:
|
11
|
+
bundle exec rake audit:patient_hd_statistics
|
12
|
+
|
13
|
+
To generate monthly stats for a specific month:
|
14
|
+
bundle exec rake audit:patient_hd_statistics year=2018 month=5
|
15
|
+
|
16
|
+
DESC
|
4
17
|
task patient_hd_statistics: :environment do
|
5
|
-
|
18
|
+
logger = Logger.new(STDOUT)
|
19
|
+
logger.level = Logger::INFO
|
20
|
+
Rails.logger = logger
|
21
|
+
|
22
|
+
Renalware::HD::GenerateMonthlyStatistics.new(
|
23
|
+
month: ENV["month"],
|
24
|
+
year: ENV["year"]
|
25
|
+
).call
|
6
26
|
end
|
7
27
|
end
|
8
28
|
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.
|
4
|
+
version: 2.0.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Airslie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_type
|
@@ -1277,8 +1277,8 @@ files:
|
|
1277
1277
|
- app/jobs/application_job.rb
|
1278
1278
|
- app/jobs/feed_job.rb
|
1279
1279
|
- app/jobs/hl7_message_example.yml
|
1280
|
+
- app/jobs/renalware/hd/generate_monthly_statistics.rb
|
1280
1281
|
- app/jobs/renalware/hd/generate_monthly_statistics_for_patient_job.rb
|
1281
|
-
- app/jobs/renalware/hd/generate_monthly_statistics_job.rb
|
1282
1282
|
- app/jobs/renalware/hd/update_rolling_patient_statistics_job.rb
|
1283
1283
|
- app/jobs/renalware/letters/save_pdf_letter_to_file_job.rb
|
1284
1284
|
- app/jobs/renalware/reporting/refresh_audit_data_job.rb
|
@@ -1,46 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "month_period"
|
4
|
-
|
5
|
-
# This job when executed will store a snapshot of last month's HD session statistics
|
6
|
-
# for each HD patient.
|
7
|
-
module Renalware
|
8
|
-
module HD
|
9
|
-
class GenerateMonthlyStatisticsJob < ApplicationJob
|
10
|
-
queue_as :hd_patient_statistics
|
11
|
-
|
12
|
-
# :reek:UtilityFunction
|
13
|
-
def perform
|
14
|
-
patients.each do |patient|
|
15
|
-
GenerateMonthlyStatisticsForPatientJob.perform_later(
|
16
|
-
patient: patient,
|
17
|
-
month: month,
|
18
|
-
year: year
|
19
|
-
)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def patients
|
26
|
-
@patients ||= Sessions::AuditablePatientsInPeriodQuery.new(period: period).call
|
27
|
-
end
|
28
|
-
|
29
|
-
def period
|
30
|
-
@period ||= Renalware::MonthPeriod.new(month: month, year: year)
|
31
|
-
end
|
32
|
-
|
33
|
-
def month
|
34
|
-
date_falling_in_the_previous_month.month
|
35
|
-
end
|
36
|
-
|
37
|
-
def year
|
38
|
-
date_falling_in_the_previous_month.year
|
39
|
-
end
|
40
|
-
|
41
|
-
def date_falling_in_the_previous_month
|
42
|
-
@date_falling_in_the_previous_month ||= Time.zone.today - 1.month
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|