# frozen_string_literal: true

module Renalware
  module UKRDC
    module Outgoing
      module Rendering
        class PatientNumber < Rendering::Base
          pattr_initialize [:number!, :organisation!, :type!]

          def xml
            name_element
          end

          private

          def name_element
            create_node("PatientNumber") do |elem|
              elem << create_node("Number", number)
              elem << create_node("Organization", organisation)
              elem << create_node("NumberType", type)
            end
          end
        end
      end
    end
  end
end

# frozen_string_literal: true

module Renalware
  module UKRDC
    module Outgoing
      module Rendering
        class PatientNumber < Rendering::Base
          pattr_initialize [:number!, :organisation!, :type!]

          def xml
            name_element
          end

          private

          def name_element
            create_node("PatientNumber") do |elem|
              elem << create_node("Number", number&.delete(" "))
              elem << create_node("Organization", organisation)
              elem << create_node("NumberType", type)
            end
          end
        end
      end
    end
  end
end

Delete spaces from UKRDC NHS numbers
Delete spaces from UKRDC NHS numbers

There maybe be some patients with a space in their
NHS number and this can causes issues at the UKRDC,
so remove the spaces when generating the XML.
