renalware-core 2.0.99 → 2.0.100
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/renalware/ukrdc/create_encrypted_patient_xml_files.rb +2 -4
- data/app/models/renalware/ukrdc/housekeeping/remove_old_export_archive_folders.rb +89 -0
- data/app/views/renalware/accesses/procedures/_form.html.slim +2 -1
- data/app/views/renalware/pd/exit_site_infections/_details.html.slim +1 -1
- data/app/views/renalware/pd/peritonitis_episodes/_details.html.slim +1 -1
- data/db/seeds.rb +1 -0
- data/db/seeds/seeds_helper.rb +3 -4
- data/lib/renalware/configuration.rb +3 -0
- data/lib/renalware/version.rb +1 -1
- data/lib/tasks/ukrdc.rake +8 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8aa7d57a0adfff2d76fadc4c11c9442fa83d82ca6dd5f01dcca5cfbf4226e0a9
|
4
|
+
data.tar.gz: 7a7c0329c9a32aac0da27b4165ab2bb1f1c9dd111729d4d86cbfaacab46040d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f73fec51538a54fa18a57c9f3d2b009f8f64ce1253d7c9a43eb5cc1d19164fcba654b9ec43a976733359a833873299c1c7b199abe75e54d3baf9f3bb8478118
|
7
|
+
data.tar.gz: f9117254aad358aa7d265db64cfeeba583be6a8cac7c707e33440e8827659abe75529c4c8bcf17e92f4532d1eb10790fb3a498aaba4018f9ed39b9f82a8ef1cd
|
@@ -36,13 +36,11 @@ module Renalware
|
|
36
36
|
|
37
37
|
def call
|
38
38
|
logger.tagged(request_uuid) do
|
39
|
-
# ActiveRecord::Base.transaction do
|
40
39
|
summary.milliseconds_taken = Benchmark.ms do
|
41
40
|
create_patient_xml_files
|
42
41
|
encrypt_patient_xml_files
|
43
42
|
copy_encrypted_xml_files_into_the_outgoing_folder
|
44
43
|
end
|
45
|
-
# end
|
46
44
|
paths.create_symlink_to_latest_timestamped_folder_so_it_is_easier_to_eyeball
|
47
45
|
build_summary
|
48
46
|
print_summary
|
@@ -93,7 +91,7 @@ module Renalware
|
|
93
91
|
summary.results = export_results
|
94
92
|
end
|
95
93
|
|
96
|
-
# rubocop:disable Metrics/AbcSize
|
94
|
+
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
97
95
|
def ukrdc_patients_who_have_changed_since_last_send
|
98
96
|
@ukrdc_patients_who_have_changed_since_last_send ||= begin
|
99
97
|
logger.info("Finding #{patient_ids&.any? ? patient_ids : 'all ukrdc'} patients")
|
@@ -115,7 +113,7 @@ module Renalware
|
|
115
113
|
query.all
|
116
114
|
end
|
117
115
|
end
|
118
|
-
# rubocop:enable Metrics/AbcSize
|
116
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
119
117
|
|
120
118
|
# rubocop:disable Metrics/AbcSize
|
121
119
|
def print_summary
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_dependency "renalware/ukrdc"
|
4
|
+
require "attr_extras"
|
5
|
+
|
6
|
+
module Renalware
|
7
|
+
module UKRDC
|
8
|
+
module Housekeeping
|
9
|
+
# Responsible for cleaning up old archive folders that are created each time the
|
10
|
+
# ukrdc:export task has run. Each archive folder's name has a batch number in it which is the
|
11
|
+
# id of the UKRDC::BatchNumber model created at the start of each export. We can find the
|
12
|
+
# folders to remove by extracting the batch number from the folder name and deleting the
|
13
|
+
# folder if that batch is no longer 'recent'.
|
14
|
+
# Called from a housekeeping rake task.
|
15
|
+
class RemoveOldExportArchiveFolders
|
16
|
+
def self.call
|
17
|
+
new.call
|
18
|
+
end
|
19
|
+
|
20
|
+
def call
|
21
|
+
remove_old_archives
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
class ArchiveFolder
|
27
|
+
pattr_initialize :folder
|
28
|
+
|
29
|
+
# Returns the integer batch number from the folder name
|
30
|
+
# e.g. 13 from /var/ukrdc/archive/000013_20190827081107620
|
31
|
+
def batch_number
|
32
|
+
matches = folder.match(%r(\/(\d{6})_))
|
33
|
+
return unless matches
|
34
|
+
|
35
|
+
matches[1].to_i
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def remove_old_archives
|
40
|
+
log "Remove old archives"
|
41
|
+
log "Keeping archived batches #{batch_numbers_to_keep.join(', ')}"
|
42
|
+
|
43
|
+
Dir.glob(glob_pattern).each do |folder|
|
44
|
+
archive_folder = ArchiveFolder.new(folder)
|
45
|
+
next unless archive_folder.batch_number
|
46
|
+
|
47
|
+
if remove_folder?(archive_folder)
|
48
|
+
log "Removing #{folder}"
|
49
|
+
FileUtils.rm_rf folder
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Pattern to use to find batch-numbered folders in the archive directory
|
55
|
+
def glob_pattern
|
56
|
+
archive_path.join("??????_*")
|
57
|
+
end
|
58
|
+
|
59
|
+
def archive_path
|
60
|
+
Pathname(Renalware.config.ukrdc_working_path).join("archive")
|
61
|
+
end
|
62
|
+
|
63
|
+
def number_of_archived_folders_to_keep
|
64
|
+
Renalware.config.ukrdc_number_of_archived_folders_to_keep.to_i
|
65
|
+
end
|
66
|
+
|
67
|
+
# Returns the ids of a few of the most recent BatchNumbers rows (ie the batch number) that
|
68
|
+
# we should not delete - these being the most recent ones we want to stick around in case we
|
69
|
+
# need to inspect what was sent.
|
70
|
+
def batch_numbers_to_keep
|
71
|
+
@batch_numbers_to_keep ||= begin
|
72
|
+
BatchNumber
|
73
|
+
.limit(number_of_archived_folders_to_keep)
|
74
|
+
.order(created_at: :desc)
|
75
|
+
.pluck(:id)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def remove_folder?(archive_folder)
|
80
|
+
!batch_numbers_to_keep.include?(archive_folder.batch_number)
|
81
|
+
end
|
82
|
+
|
83
|
+
def log(msg)
|
84
|
+
Rails.logger.info(" " + msg)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -16,7 +16,8 @@ ruby:
|
|
16
16
|
= f.association :type,
|
17
17
|
collection: Renalware::Accesses::Type.ordered,
|
18
18
|
label_method: :long_name,
|
19
|
-
wrapper: :horizontal_medium
|
19
|
+
wrapper: :horizontal_medium,
|
20
|
+
input_html: { class: "searchable_select" }
|
20
21
|
= f.input :side, wrapper: :horizontal_small
|
21
22
|
= f.association :pd_catheter_insertion_technique,
|
22
23
|
collection: Renalware::Accesses::CatheterInsertionTechnique.ordered,
|
@@ -9,7 +9,7 @@
|
|
9
9
|
dt Treatment:
|
10
10
|
dd= exit_site_infection.treatment
|
11
11
|
dt Notes:
|
12
|
-
dd= exit_site_infection.notes
|
12
|
+
dd= simple_format(exit_site_infection.notes)
|
13
13
|
dt= attr_name(exit_site_infection, :clinical_presentation)
|
14
14
|
dd= exit_site_infection.clinical_presentation&.texts&.join(", ")
|
15
15
|
- %i(recurrent cleared catheter_removed).each do |option|
|
data/db/seeds.rb
CHANGED
data/db/seeds/seeds_helper.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module SeedsHelper
|
4
|
-
def without_papertrail_versioning_for(
|
5
|
-
|
6
|
-
klass.paper_trail.disable
|
4
|
+
def without_papertrail_versioning_for(klasses)
|
5
|
+
Array(klasses).each { |klass| klass.paper_trail.disable }
|
7
6
|
yield
|
8
|
-
klass.paper_trail.enable
|
7
|
+
Array(klasses).each { |klass| klass.paper_trail.enable }
|
9
8
|
end
|
10
9
|
end
|
@@ -66,6 +66,9 @@ module Renalware
|
|
66
66
|
ENV.fetch("UKRDC_WORKING_PATH", File.join("/var", "ukrdc"))
|
67
67
|
end
|
68
68
|
config_accessor(:ukrdc_site_code) { ENV.fetch("UKRDC_PREFIX", "RJZ") }
|
69
|
+
config_accessor(:ukrdc_number_of_archived_folders_to_keep) do
|
70
|
+
ENV.fetch("UKRDC_NUMBER_OF_ARCHIVED_FOLDERS_TO_KEEP", "3")
|
71
|
+
end
|
69
72
|
|
70
73
|
# To use a date other that the default changes_since date when
|
71
74
|
# compiling pathology to send to UKRDC, you can set an ENV var as follows:
|
data/lib/renalware/version.rb
CHANGED
data/lib/tasks/ukrdc.rake
CHANGED
@@ -47,4 +47,12 @@ namespace :ukrdc do
|
|
47
47
|
Rails.logger = logger
|
48
48
|
Renalware::UKRDC::TreatmentTimeline::GenerateTreatments.call
|
49
49
|
end
|
50
|
+
|
51
|
+
task housekeeping: :environment do
|
52
|
+
logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
|
53
|
+
logger.level = Logger::INFO
|
54
|
+
Rails.logger = logger
|
55
|
+
logger.info "UKRDC housekeeping"
|
56
|
+
Renalware::UKRDC::Housekeeping::RemoveOldExportArchiveFolders.call
|
57
|
+
end
|
50
58
|
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.100
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Airslie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_type
|
@@ -1840,6 +1840,7 @@ files:
|
|
1840
1840
|
- app/models/renalware/ukrdc/create_patient_xml_file.rb
|
1841
1841
|
- app/models/renalware/ukrdc/export_summary.rb
|
1842
1842
|
- app/models/renalware/ukrdc/filename.rb
|
1843
|
+
- app/models/renalware/ukrdc/housekeeping/remove_old_export_archive_folders.rb
|
1843
1844
|
- app/models/renalware/ukrdc/modality_code.rb
|
1844
1845
|
- app/models/renalware/ukrdc/pathology_observation_requests_query.rb
|
1845
1846
|
- app/models/renalware/ukrdc/paths.rb
|