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
33
34
35
36
37
38
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 33
def cc_recipients
@cc_recipients ||= begin
recipients = build_cc_recipients
present_cc_recipients(recipients)
end
end
|
#content ⇒ Object
rubocop:enable Rails/OutputSafety
75
76
77
78
79
80
81
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 75
def content
if archived?
archive.content
else
@content ||= HTMLRenderer.new.call(self)
end
end
|
#description ⇒ Object
45
46
47
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 45
def description
"(#{letterhead.site_code}) #{super}"
end
|
#electronic_cc_receipts ⇒ Object
40
41
42
43
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 40
def electronic_cc_receipts
@electronic_cc_receipts ||=
CollectionPresenter.new(super, Letters::ElectonicReceiptPresenter)
end
|
#event_description ⇒ Object
25
26
27
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 25
def event_description
letter_event.description
end
|
#hospital_unit_code ⇒ Object
83
84
85
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 83
def hospital_unit_code
letterhead.site_code
end
|
#main_recipient ⇒ Object
29
30
31
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 29
def main_recipient
@main_recipient ||= recipient_presenter_class.new(super)
end
|
#part_for(part_name) ⇒ Object
63
64
65
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 63
def part_for(part_name)
letter_event.part_classes[part_name].new(patient, self, letter_event)
end
|
#parts ⇒ Object
53
54
55
56
57
58
59
60
61
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 53
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
21
22
23
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 21
def patient
@patient ||= PatientPresenter.new(super)
end
|
#pdf_filename ⇒ Object
91
92
93
94
95
96
97
98
99
100
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 91
def pdf_filename
build_filename_from(
[
patient.family_name,
patient.local_patient_id,
id,
state
]
)
end
|
#pdf_stateless_filename ⇒ Object
102
103
104
105
106
107
108
109
110
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 102
def pdf_stateless_filename
build_filename_from(
[
patient.family_name,
patient.local_patient_id,
id
]
)
end
|
#state_description ⇒ Object
112
113
114
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 112
def state_description
::I18n.t(state.to_sym, scope: "enums.letter.state")
end
|
#title ⇒ Object
87
88
89
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 87
def title
pdf_stateless_filename
end
|
#to_html(adhoc_printing: false) ⇒ Object
rubocop:disable Rails/OutputSafety
68
69
70
71
72
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 68
def to_html(adhoc_printing: false)
html = content
html << ADHOC_PRINTING_CSS.html_safe if adhoc_printing
html
end
|
#type ⇒ Object
17
18
19
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 17
def type
letter_event.to_link.call(patient)
end
|
#typist ⇒ Object
116
117
118
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 116
def typist
created_by
end
|
#view_label ⇒ Object
49
50
51
|
# File 'app/presenters/renalware/letters/letter_presenter.rb', line 49
def view_label
"Preview"
end
|