Class: Renalware::Letters::LetterPresenter

Inherits:
DumbDelegator show all
Defined in:
app/presenters/renalware/letters/letter_presenter.rb

Direct Known Subclasses

Approved, Completed, Draft, PendingReview

Defined Under Namespace

Classes: Approved, Completed, Draft, PendingReview

Instance Method Summary collapse

Methods inherited from DumbDelegator

#inspect, #public_send, #send, #try, #try!

Instance Method Details

#cc_recipientsObject



25
26
27
28
29
30
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 25

def cc_recipients
  @cc_recipients_with_counterparts ||= begin
    recipients = build_cc_recipients
    present_cc_recipients(recipients)
  end
end

#contentObject



63
64
65
66
67
68
69
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 63

def content
  if archived?
    archive.content
  else
    @content ||= HTMLRenderer.new.call(self)
  end
end

#descriptionObject



37
38
39
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 37

def description
  "(#{letterhead.site_code}) #{super}"
end

#electronic_cc_receiptsObject



32
33
34
35
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 32

def electronic_cc_receipts
  @electronic_cc_receipts ||=
    CollectionPresenter.new(super, Letters::ElectonicReceiptPresenter)
end

#event_descriptionObject



17
18
19
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 17

def event_description
  letter_event.description
end

#hospital_unit_codeObject



71
72
73
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 71

def hospital_unit_code
  letterhead.site_code
end

#main_recipientObject



21
22
23
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 21

def main_recipient
  @main_recipient_presenter ||= recipient_presenter_class.new(super)
end

#part_for(part_name) ⇒ Object



55
56
57
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 55

def part_for(part_name)
  letter_event.part_classes[part_name].new(patient, self, letter_event)
end

#partsObject



45
46
47
48
49
50
51
52
53
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 45

def parts
  filtered_part_classes = PartClassFilter.new(
    part_classes: letter_event.part_classes,
    include_pathology_in_letter_body: letterhead.include_pathology_in_letter_body?
  )
  filtered_part_classes.to_h.values.map do |part_class|
    part_class.new(patient, self, letter_event)
  end
end

#patientObject



13
14
15
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 13

def patient
  @patient_presenter ||= PatientPresenter.new(super)
end

#pdf_filenameObject



79
80
81
82
83
84
85
86
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 79

def pdf_filename
  [
    patient.family_name,
    patient.local_patient_id,
    id,
    state
  ].join("-").upcase.concat(".pdf")
end

#state_descriptionObject



88
89
90
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 88

def state_description
  ::I18n.t(state.to_sym, scope: "enums.letter.state")
end

#titleObject



75
76
77
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 75

def title
  "TBC"
end

#to_htmlObject



59
60
61
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 59

def to_html
  content
end

#typeObject



9
10
11
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 9

def type
  letter_event.to_link.call(patient)
end

#typistObject



92
93
94
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 92

def typist
  created_by
end

#view_labelObject



41
42
43
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 41

def view_label
  "Preview"
end