renalware-core 2.0.34 → 2.0.35

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9f1d61c7f654e5dd89e867056ea4e272b89749a6713977cb6d7e46d09661e3e
4
- data.tar.gz: c58ace6f98d24326bae07fff01d57f8fc6cf2e1058d278c6986d526d65a89463
3
+ metadata.gz: a779b18871bd5f31fe4baa1fc6a868aac2861668a743389e5815729922f1fca3
4
+ data.tar.gz: ada4dd9150fdfb89dd42dc995516895c133393bd4974c0bbd7981e04bc33d60e
5
5
  SHA512:
6
- metadata.gz: 145c983783938cd21ed54a380620e51ef7bf7a2c9cc9b4f5d622c1afda2df505ccbac665a5e8b24682dd7bb3b2f6f5b82da52ec4a29e4cb2c21994a26acf440c
7
- data.tar.gz: 3d15d1971d32dadfb74b35b387dbc9969f29facec45a33732bcdfa4453fb007a18d61affaaa7a03e624f049f8dcefec70cc101b6dae48f12dd1dfda5dbdf3eee
6
+ metadata.gz: 1fb542eadec8a2362be78fa93f34d9a399c04aeb9337106edcc69934d00a679a999dea68e5464a5768c41d4ebba119cbb5216dc0e6e752d879e0e83d01f2a1b5
7
+ data.tar.gz: e91844cdde10cb7044a6ca6a39ebb9b277f68f38d4c8606e3211fb646ac851d791e77b609c210d541e267e58e83bce8c171b156a8cdf2e99a46d2f87d871a22f
@@ -9,10 +9,11 @@ module Renalware
9
9
  # patients who have changed since the last time they were exported.
10
10
  class PatientsQuery
11
11
  def call(changed_since: nil)
12
+
12
13
  if changed_since.present?
13
14
  rpv_patients.where("updated_at > ?", changed_since)
14
15
  else
15
- rpv_patients.where("updated_at > sent_to_ukrdc_at")
16
+ rpv_patients.where("(sent_to_ukrdc_at is null) or (updated_at > sent_to_ukrdc_at)")
16
17
  end
17
18
  end
18
19
 
@@ -13,9 +13,16 @@ module Renalware
13
13
  logger.info " Patient #{patient.to_param}"
14
14
  xml_payload = build_payload(log)
15
15
  if xml_payload_same_as_last_sent_payload?(xml_payload)
16
+ logger.info " skipping as no change in XML file"
16
17
  log.unsent_no_change_since_last_send!
17
18
  else
18
19
  send_file(xml_payload, log)
20
+ # Important we use update_column here so we don't trigger updated_at to change
21
+ # on the patient, which affects the results of PatientsQuery next time.
22
+ patient.update_column(:sent_to_ukrdc_at, Time.zone.now)
23
+ logger.info(
24
+ " sending file and setting patient.sent_to_ukrdc_at = #{patient.sent_to_ukrdc_at}"
25
+ )
19
26
  end
20
27
  logger.info " Status: #{log.status}"
21
28
  end
@@ -58,7 +65,10 @@ module Renalware
58
65
  end
59
66
 
60
67
  def presenter_for(patient)
61
- Renalware::UKRDC::PatientPresenter.new(patient, changes_since: changes_since)
68
+ Renalware::UKRDC::PatientPresenter.new(
69
+ patient,
70
+ changes_since: changes_since
71
+ )
62
72
  end
63
73
 
64
74
  # Note a test might have passed in a mock renderer
@@ -80,8 +90,6 @@ module Renalware
80
90
  @to_md5_hash ||= Digest::MD5.hexdigest(time_neutral_payload)
81
91
  end
82
92
 
83
- private
84
-
85
93
  # Remove the time elements from SendingFacility
86
94
  # e.g.
87
95
  # <SendingFacility channelName='Renalware' time='2018-02-26T13:18:02+00:00'/>
@@ -92,6 +100,7 @@ module Renalware
92
100
  payload
93
101
  .gsub(/<Stream>[^<]*<\/Stream>/, "<Stream>removed</Stream>")
94
102
  .gsub(/ (time|start|stop)=["'][^'"]*['"]/, '')
103
+ .gsub(/<UpdatedOn>[^<]*<\/UpdatedOn>/, "<UpdatedOn>removed</UpdatedOn>")
95
104
  end
96
105
  end
97
106
  end
@@ -68,7 +68,7 @@ module Renalware
68
68
  end
69
69
 
70
70
  def within_new_folder
71
- dir = Rails.root.join("tmp", timestamp)
71
+ dir = Pathname(File.join("/var", "ukrdc", timestamp))
72
72
  FileUtils.mkdir_p dir
73
73
  FileUtils.mkdir_p File.join(dir, "xml")
74
74
  FileUtils.mkdir_p File.join(dir, "encrypted")
@@ -19,6 +19,7 @@ module Renalware
19
19
  log.error = formatted_exception(error)
20
20
  log.status = :error
21
21
  log.save!
22
+ raise error
22
23
  end
23
24
 
24
25
  def self.formatted_exception(error)
@@ -15,7 +15,10 @@ module Renalware
15
15
  if changes_since.present? && changes_since.is_a?(String)
16
16
  changes_since = Time.zone.parse(changes_since)
17
17
  end
18
- @changes_since = changes_since || patient.sent_to_ukrdc_at
18
+ # TODO: document what's happening here with dates
19
+ @changes_since = changes_since ||
20
+ patient.sent_to_ukrdc_at ||
21
+ Renalware.config.ukrdc_default_changes_since_date
19
22
  if @changes_since.blank?
20
23
  raise(
21
24
  ArgumentError,
@@ -114,7 +117,7 @@ module Renalware
114
117
  end
115
118
 
116
119
  def clinics_patient
117
- @clinic_patient ||= Renalware::Clinics.cast_patient(__getobj__)
120
+ @clinics_patient ||= Renalware::Clinics.cast_patient(__getobj__)
118
121
  end
119
122
 
120
123
  def letters_patient
@@ -53,6 +53,9 @@ module Renalware
53
53
  ENV["FALLBACK_EMAIL_ADDRESS_FOR_TEST_MESSAGES"]
54
54
  end
55
55
  config_accessor(:ukrdc_sending_facility_name) { ENV["UKRDC_SENDING_FACILITY_NAME"] }
56
+ config_accessor(:ukrdc_default_changes_since_date) {
57
+ Date.parse(ENV.fetch("UKRDC_DEFAULT_CHANGES_SINCE_DATE", "2018-01-01"))
58
+ }
56
59
 
57
60
  # We override this in some tests as a means of getting wicked_Pdf to generate an HTML version
58
61
  # of the PDF so we can examine its content
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Renalware
4
- VERSION = "2.0.34"
4
+ VERSION = "2.0.35"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: renalware-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.34
4
+ version: 2.0.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - Airslie