Sha256: c8037473bfc9d1115d9b33ab78d1eb5422b4947fd26fc37f153acfda296d0497

Contents?: true

Size: 1.59 KB

Versions: 35

Compression:

Stored size: 1.59 KB

Contents

# frozen_string_literal: true

module Renalware
  module UKRDC
    module Outgoing
      module Rendering
        class Document < Rendering::Base
          pattr_initialize [:letter!]

          def xml
            document_element
          end

          private

          # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
          def document_element
            create_node("Document") do |elem|
              elem << create_node("DocumentTime", letter.issued_on.to_time.iso8601)
              elem << Clinician.new(user: letter.author).xml
              elem << create_node("DocumentName", letter.title)
              elem << create_node("Status") do |status|
                status << create_node("Code", "ACTIVE")
              end
              elem << EnteredBy.new(user: letter.updated_by).xml
              if letter.hospital_unit_renal_registry_code.present?
                elem << create_node("EnteredAt") do |entered_at|
                  entered_at << create_node("CodingStandard", "LOCAL")
                  entered_at << create_node("Code", letter.hospital_unit_renal_registry_code)
                end
              end
              elem << create_node("FileType", "application/pdf")
              elem << create_node("FileName", letter.pdf_stateless_filename)
              elem << create_node("Stream", encoded_document_content)
            end
          end
          # rubocop:enable Metrics/MethodLength, Metrics/AbcSize

          def encoded_document_content
            Base64.encode64(Renalware::Letters::PdfRenderer.call(letter))
          end
        end
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
renalware-core-2.0.167 app/models/renalware/ukrdc/outgoing/rendering/document.rb
renalware-core-2.0.166 app/models/renalware/ukrdc/outgoing/rendering/document.rb
renalware-core-2.0.165 app/models/renalware/ukrdc/outgoing/rendering/document.rb
renalware-core-2.0.164 app/models/renalware/ukrdc/outgoing/rendering/document.rb
renalware-core-2.0.163 app/models/renalware/ukrdc/outgoing/rendering/document.rb
renalware-core-2.0.162 app/models/renalware/ukrdc/outgoing/rendering/document.rb
renalware-core-2.0.161 app/models/renalware/ukrdc/outgoing/rendering/document.rb
renalware-core-2.0.160 app/models/renalware/ukrdc/outgoing/rendering/document.rb
renalware-core-2.0.159 app/models/renalware/ukrdc/outgoing/rendering/document.rb
renalware-core-2.0.158 app/models/renalware/ukrdc/outgoing/rendering/document.rb
renalware-core-2.0.157 app/models/renalware/ukrdc/outgoing/rendering/document.rb
renalware-core-2.0.156 app/models/renalware/ukrdc/outgoing/rendering/document.rb
renalware-core-2.0.155 app/models/renalware/ukrdc/outgoing/rendering/document.rb
renalware-core-2.0.153 app/models/renalware/ukrdc/outgoing/rendering/document.rb
renalware-core-2.0.152 app/models/renalware/ukrdc/outgoing/rendering/document.rb
renalware-core-2.0.151 app/models/renalware/ukrdc/outgoing/rendering/document.rb
renalware-core-2.0.149 app/models/renalware/ukrdc/outgoing/rendering/document.rb
renalware-core-2.0.148 app/models/renalware/ukrdc/outgoing/rendering/document.rb
renalware-core-2.0.147 app/models/renalware/ukrdc/outgoing/rendering/document.rb
renalware-core-2.0.146 app/models/renalware/ukrdc/outgoing/rendering/document.rb