Class: Renalware::UKRDC::CreatePatientXMLFile

Inherits:
Object
  • Object
show all
Defined in:
app/models/renalware/ukrdc/create_patient_xml_file.rb

Defined Under Namespace

Classes: Payload

Instance Method Summary collapse

Instance Method Details

#callObject

rubocop:disable Metrics/AbcSize, Metrics/MethodLength If force_send is true then send all files even if they have not changed since the last send. This is primarily for debugging and testing phases with UKRDC



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/models/renalware/ukrdc/create_patient_xml_file.rb', line 24

def call
  update_patient_to_indicated_we_checked_them_for_any_relevant_changes
  UKRDC::TransmissionLog.with_logging(patient: patient, batch: batch) do |log|
    @log = log
    logger.info "  Patient #{patient.ukrdc_external_id}"
    xml_payload = build_payload(log)
    if xml_payload.present?
      if !force_send && xml_payload_same_as_last_sent_payload?(xml_payload)
        logger.info "    skipping as no change in XML file"
        log.unsent_no_change_since_last_send!
      else
        create_xml_file(xml_payload, log)
        update_patient_to_indicate_we_have_sent_their_data_to_ukrdc
      end
    end
    logger.info "    Status: #{log.status}"
  end
end