Sha256: 611695ddcd6b6d4b78587ab03c4431c90760a6dd284c414a2e58bc6ee347cce6

Contents?: true

Size: 963 Bytes

Versions: 106

Compression:

Stored size: 963 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware/ukrdc"

module Renalware
  module UKRDC
    # Formats a UKRDC patient XML filename
    class Filename
      pattr_initialize [:patient!, :batch_number!]

      def to_s
        "#{site_code}_#{batch_number}_#{sanitized_patient_identifier}.xml"
      end

      private

      def sanitized_patient_identifier
        patient_identifier.strip.upcase
      end

      def site_code
        Renalware.config.ukrdc_site_code # e.g. RJZ
      end

      # For an patient identifer to put in the filename (to make it easierto look up the patient)
      # choose the NHS Number is there is one, falling back to local_patient_id(2,3,4) then
      # ukrdc_external_id - the latter at least is guaranteed to be present.
      def patient_identifier
        return patient.nhs_number if patient.nhs_number.present?

        patient.hospital_identifier&.id || patient.ukrdc_external_id
      end
    end
  end
end

Version data entries

106 entries across 106 versions & 1 rubygems

Version Path
renalware-core-2.0.104 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.103 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.102 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.101 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.100 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.99 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.98 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.97 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.96 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.95 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.94 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.93 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.92 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.91 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.90 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.89 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.88 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.87 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.86 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.85 app/models/renalware/ukrdc/filename.rb