Class: Renalware::UKRDC::CreateEncryptedPatientXMLFiles
- Inherits:
-
Object
- Object
- Renalware::UKRDC::CreateEncryptedPatientXMLFiles
- Defined in:
- app/models/renalware/ukrdc/create_encrypted_patient_xml_files.rb
Overview
Using a working folder with a timestamp name, find matching patients and for each, generate an XML file (see UKRDC Schema) containing changes since the last time we sent the URDC data about them. Encrypt the xml files and copy to an outgoing folder which might for example be a symlink to an outgoing folder in /media/ukrdc which in turn is mount on a remote share for example on an SFTP server.
Instance Attribute Summary collapse
-
#batch_number ⇒ Object
readonly
Returns the value of attribute batch_number.
-
#changed_since ⇒ Object
readonly
Returns the value of attribute changed_since.
-
#force_send ⇒ Object
readonly
Returns the value of attribute force_send.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#patient_ids ⇒ Object
readonly
Returns the value of attribute patient_ids.
-
#request_uuid ⇒ Object
readonly
Returns the value of attribute request_uuid.
-
#summary ⇒ Object
readonly
Returns the value of attribute summary.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(changed_since: nil, patient_ids: nil, logger: nil, force_send: false) ⇒ CreateEncryptedPatientXMLFiles
constructor
A new instance of CreateEncryptedPatientXMLFiles.
Constructor Details
#initialize(changed_since: nil, patient_ids: nil, logger: nil, force_send: false) ⇒ CreateEncryptedPatientXMLFiles
Returns a new instance of CreateEncryptedPatientXMLFiles.
26 27 28 29 30 31 32 33 34 35 |
# File 'app/models/renalware/ukrdc/create_encrypted_patient_xml_files.rb', line 26 def initialize(changed_since: nil, patient_ids: nil, logger: nil, force_send: false) @changed_since = Time.zone.parse(changed_since) if changed_since.present? @patient_ids = Array(patient_ids) @logger = logger || Rails.logger @request_uuid = SecureRandom.uuid # helps group logs together @timestamp = Time.zone.now.strftime("%Y%m%d%H%M%S%L") @batch_number ||= BatchNumber.next.number @summary = ExportSummary.new @force_send = force_send end |
Instance Attribute Details
#batch_number ⇒ Object (readonly)
Returns the value of attribute batch_number.
15 16 17 |
# File 'app/models/renalware/ukrdc/create_encrypted_patient_xml_files.rb', line 15 def batch_number @batch_number end |
#changed_since ⇒ Object (readonly)
Returns the value of attribute changed_since.
15 16 17 |
# File 'app/models/renalware/ukrdc/create_encrypted_patient_xml_files.rb', line 15 def changed_since @changed_since end |
#force_send ⇒ Object (readonly)
Returns the value of attribute force_send.
15 16 17 |
# File 'app/models/renalware/ukrdc/create_encrypted_patient_xml_files.rb', line 15 def force_send @force_send end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
15 16 17 |
# File 'app/models/renalware/ukrdc/create_encrypted_patient_xml_files.rb', line 15 def logger @logger end |
#patient_ids ⇒ Object (readonly)
Returns the value of attribute patient_ids.
15 16 17 |
# File 'app/models/renalware/ukrdc/create_encrypted_patient_xml_files.rb', line 15 def patient_ids @patient_ids end |
#request_uuid ⇒ Object (readonly)
Returns the value of attribute request_uuid.
15 16 17 |
# File 'app/models/renalware/ukrdc/create_encrypted_patient_xml_files.rb', line 15 def request_uuid @request_uuid end |
#summary ⇒ Object (readonly)
Returns the value of attribute summary.
15 16 17 |
# File 'app/models/renalware/ukrdc/create_encrypted_patient_xml_files.rb', line 15 def summary @summary end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
15 16 17 |
# File 'app/models/renalware/ukrdc/create_encrypted_patient_xml_files.rb', line 15 def @timestamp end |
Instance Method Details
#call ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/models/renalware/ukrdc/create_encrypted_patient_xml_files.rb', line 37 def call logger.tagged(request_uuid) do summary.milliseconds_taken = Benchmark.ms do create_patient_xml_files encrypt_patient_xml_files copy_encrypted_xml_files_into_the_outgoing_folder end paths. build_summary print_summary email_summary end rescue StandardError => e # TODO: if fails before copying to outgoing then we should roll back BatchNumber Engine.exception_notifier.notify(e) raise e end |