Class: Renalware::Letters::LetterPresenter
Defined Under Namespace
Classes: Approved, Completed, Draft, PendingReview
Constant Summary
collapse
- ADHOC_PRINTING_CSS =
<<-STYLE
<style>
.footer .ccs h3 { margin-bottom: 4rem !important; }
.footer .ccs .address { margin-bottom: 6rem !important; }
</style>
STYLE
Instance Method Summary
collapse
#inspect, #public_send, #send, #try, #try!
Instance Method Details
#cc_recipients ⇒ Object
32
33
34
35
36
37
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 32
def cc_recipients
@cc_recipients ||= begin
recipients = build_cc_recipients
present_cc_recipients(recipients)
end
end
|
#content ⇒ Object
rubocop:enable Rails/OutputSafety
74
75
76
77
78
79
80
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 74
def content
if archived?
archive.content
else
@content ||= HTMLRenderer.new.call(self)
end
end
|
#description ⇒ Object
44
45
46
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 44
def description
"(#{letterhead.site_code}) #{super}"
end
|
#electronic_cc_receipts ⇒ Object
39
40
41
42
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 39
def electronic_cc_receipts
@electronic_cc_receipts ||=
CollectionPresenter.new(super, Letters::ElectonicReceiptPresenter)
end
|
#event_description ⇒ Object
24
25
26
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 24
def event_description
letter_event.description
end
|
#hospital_unit_code ⇒ Object
82
83
84
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 82
def hospital_unit_code
letterhead.site_code
end
|
#main_recipient ⇒ Object
28
29
30
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 28
def main_recipient
@main_recipient ||= recipient_presenter_class.new(super)
end
|
#part_for(part_name) ⇒ Object
62
63
64
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 62
def part_for(part_name)
letter_event.part_classes[part_name].new(patient, self, letter_event)
end
|
#parts ⇒ Object
52
53
54
55
56
57
58
59
60
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 52
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
|
#patient ⇒ Object
20
21
22
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 20
def patient
@patient ||= PatientPresenter.new(super)
end
|
#pdf_filename ⇒ Object
90
91
92
93
94
95
96
97
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 90
def pdf_filename
[
patient.family_name,
patient.local_patient_id,
id,
state
].join("-").upcase.concat(".pdf")
end
|
#state_description ⇒ Object
99
100
101
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 99
def state_description
::I18n.t(state.to_sym, scope: "enums.letter.state")
end
|
#title ⇒ Object
86
87
88
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 86
def title
"TBC"
end
|
#to_html(adhoc_printing: false) ⇒ Object
rubocop:disable Rails/OutputSafety
67
68
69
70
71
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 67
def to_html(adhoc_printing: false)
html = content
html << ADHOC_PRINTING_CSS.html_safe if adhoc_printing
html
end
|
#type ⇒ Object
16
17
18
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 16
def type
letter_event.to_link.call(patient)
end
|
#typist ⇒ Object
103
104
105
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 103
def typist
created_by
end
|
#view_label ⇒ Object
48
49
50
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 48
def view_label
"Preview"
end
|