renalware-core 2.0.22 → 2.0.23

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c9df5d0937aca9913d07516b1d59836215499b54f8160d4a9fa5d6d811a5eb8
4
- data.tar.gz: 4afe4555a5821f3c8464d95137fe5a28b8341f1db3e996083216c73b4780f85a
3
+ metadata.gz: 3ac09f0c3708048edefc8c1040650e7efee4de9209837d547e97bdf06e30ae38
4
+ data.tar.gz: 1029728c82c3f5cfe5c782fcebae7247fb5401815c2e2afbe8fb9ab35c230b15
5
5
  SHA512:
6
- metadata.gz: e8f02ea880a57bc537775cc5addd1bea2d6fcf5bf3beae5c647d2cb36a88c6dc0007bed2d76215651d24a29e9cc9e30550fd77785ff3e9bfafbcd8cfdd0d1800
7
- data.tar.gz: 9d7ba211614d195aff1d88d4faf32a6a83669c130fae96ecbedc69d5ec1be197cbf24749a6b05e3a148534e83fd1694e96a10d7ba246eb6a51699aadf21f78bd
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
@@ -17,7 +17,7 @@ module Renalware
17
17
  end
18
18
 
19
19
  def call
20
- patient.prescriptions.each do |prescription|
20
+ patient.prescriptions.current.each do |prescription|
21
21
  prescription.terminate(by: by).save!
22
22
  end
23
23
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Renalware
4
- VERSION = "2.0.22"
4
+ VERSION = "2.0.23"
5
5
  end
@@ -1,8 +1,28 @@
1
1
  begin
2
2
  namespace :audit do
3
- desc "Queues a delayed job to generate and store monthly patient HD Session statistics"
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
- Renalware::HD::GenerateMonthlyStatisticsJob.perform_later
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.22
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-02 00:00:00.000000000 Z
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