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.1.1 app/models/renalware/ukrdc/filename.rb
renalware-core-2.1.0 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.167 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.166 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.165 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.164 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.163 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.162 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.161 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.160 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.159 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.158 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.157 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.156 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.155 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.153 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.152 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.151 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.149 app/models/renalware/ukrdc/filename.rb
renalware-core-2.0.148 app/models/renalware/ukrdc/filename.rb