1
1
# frozen_string_literal: true
2
2
3
3
class AppChildSummaryComponent < ViewComponent ::Base
4
- def initialize ( child , show_parents : false , change_links : { } , remove_links : { } )
4
+ def initialize (
5
+ child ,
6
+ current_team : nil ,
7
+ show_parents : false ,
8
+ show_school_and_year_group : true ,
9
+ change_links : { } ,
10
+ remove_links : { }
11
+ )
5
12
super
6
13
7
14
@child = child
15
+ @current_team = current_team
8
16
@show_parents = show_parents
17
+ @show_school_and_year_group = show_school_and_year_group
9
18
@change_links = change_links
10
19
@remove_links = remove_links
11
20
end
@@ -25,6 +34,14 @@ def call
25
34
)
26
35
end
27
36
end
37
+
38
+ if archive_reason
39
+ summary_list . with_row do |row |
40
+ row . with_key { "Archive reason" }
41
+ row . with_value { format_archive_reason }
42
+ end
43
+ end
44
+
28
45
summary_list . with_row do |row |
29
46
row . with_key { "Full name" }
30
47
row . with_value { format_full_name }
@@ -57,14 +74,16 @@ def call
57
74
row . with_value { format_address }
58
75
end
59
76
end
60
- summary_list . with_row do |row |
61
- row . with_key { "School" }
62
- row . with_value { format_school }
63
- end
64
- if @child . respond_to? ( :year_group )
77
+ if @show_school_and_year_group
65
78
summary_list . with_row do |row |
66
- row . with_key { "Year group" }
67
- row . with_value { format_year_group }
79
+ row . with_key { "School" }
80
+ row . with_value { format_school }
81
+ end
82
+ if @child . respond_to? ( :year_group )
83
+ summary_list . with_row do |row |
84
+ row . with_key { "Year group" }
85
+ row . with_value { format_year_group }
86
+ end
68
87
end
69
88
end
70
89
if ( gp_practice = @child . try ( :gp_practice ) )
@@ -112,10 +131,27 @@ def call
112
131
113
132
def academic_year = AcademicYear . current
114
133
134
+ def archive_reason
135
+ @archive_reason ||=
136
+ if @current_team
137
+ ArchiveReason . find_by ( team : @current_team , patient : @child )
138
+ end
139
+ end
140
+
115
141
def format_nhs_number
116
142
highlight_if ( helpers . patient_nhs_number ( @child ) , @child . nhs_number_changed? )
117
143
end
118
144
145
+ def format_archive_reason
146
+ type_string = archive_reason . human_enum_name ( :type )
147
+
148
+ if archive_reason . other?
149
+ "#{ type_string } : #{ archive_reason . other_details } "
150
+ else
151
+ type_string
152
+ end
153
+ end
154
+
119
155
def format_full_name
120
156
highlight_if (
121
157
@child . full_name ,
0 commit comments