@@ -37,7 +37,7 @@ class AppPatientSessionSearchResultCardComponent < ViewComponent::Base
37
37
end
38
38
end
39
39
40
- if ( note = patient_session . latest_note )
40
+ if context != :patient_specific_direction && ( note = patient_session . latest_note )
41
41
summary_list . with_row do |row |
42
42
row . with_key { "Notes" }
43
43
row . with_value { render note_to_log_event ( note ) }
@@ -57,7 +57,16 @@ class AppPatientSessionSearchResultCardComponent < ViewComponent::Base
57
57
def initialize ( patient_session , context :, programmes : [ ] )
58
58
super
59
59
60
- unless context . in? ( %i[ patients consent triage register record ] )
60
+ unless context . in? (
61
+ %i[
62
+ patients
63
+ consent
64
+ triage
65
+ register
66
+ record
67
+ patient_specific_direction
68
+ ]
69
+ )
61
70
raise "Unknown context: #{ context } "
62
71
end
63
72
@@ -157,6 +166,8 @@ def status_tags
157
166
[ consent_status_tag ]
158
167
when :triage
159
168
[ triage_status_tag ]
169
+ when :patient_specific_direction
170
+ [ patient_specific_direction_status_tag ]
160
171
else
161
172
[ vaccination_status_tag ]
162
173
end
@@ -203,8 +214,9 @@ def register_status_tag
203
214
key : :register ,
204
215
value :
205
216
render (
206
- AppRegisterStatusTagComponent . new (
207
- patient_session . registration_status &.status || "unknown"
217
+ AppStatusTagComponent . new (
218
+ patient_session . registration_status &.status || "unknown" ,
219
+ context : :register
208
220
)
209
221
)
210
222
}
@@ -240,6 +252,19 @@ def triage_status_value(triage_status, programme)
240
252
{ status : status }
241
253
end
242
254
255
+ def patient_specific_direction_status_tag
256
+ {
257
+ key : :patient_specific_direction ,
258
+ value :
259
+ render (
260
+ AppStatusTagComponent . new (
261
+ psd_exists? ( programmes . first ) ? :added : :not_added ,
262
+ context : :patient_specific_direction
263
+ )
264
+ )
265
+ }
266
+ end
267
+
243
268
def note_to_log_event ( note )
244
269
truncated_body = note . body . truncate_words ( 80 , omission : "…" )
245
270
@@ -260,4 +285,10 @@ def note_to_log_event(note)
260
285
261
286
AppLogEventComponent . new ( body :, at : note . created_at , by : note . created_by )
262
287
end
288
+
289
+ def psd_exists? ( programme )
290
+ patient . patient_specific_directions . any? do
291
+ it . programme_id == programme . id && it . academic_year == academic_year
292
+ end
293
+ end
263
294
end
0 commit comments