@@ -4,55 +4,39 @@ class AppNoticesTableComponent < ViewComponent::Base
44 def initialize (
55 deceased_patients :,
66 invalidated_patients :,
7- restricted_patients :
7+ restricted_patients :,
8+ has_vaccination_records_dont_notify_parents_patients :
89 )
910 super
1011
1112 @deceased_patients = deceased_patients
1213 @invalidated_patients = invalidated_patients
1314 @restricted_patients = restricted_patients
15+ @has_vaccination_records_dont_notify_parents_patients =
16+ has_vaccination_records_dont_notify_parents_patients
1417 end
1518
1619 def render?
1720 @deceased_patients . present? || @invalidated_patients . present? ||
18- @restricted_patients . present?
21+ @restricted_patients . present? ||
22+ @has_vaccination_records_dont_notify_parents_patients . present?
1923 end
2024
2125 private
2226
2327 def notices
24- ( deceased_notices + invalidated_notices + restricted_notices )
25- . sort_by { _1 [ :date ] }
26- . reverse
27- end
28-
29- def deceased_notices
30- @deceased_patients . map do |patient |
31- {
32- patient :,
33- date_time : patient . date_of_death_recorded_at ,
34- message : "Record updated with child’s date of death"
35- }
36- end
37- end
38-
39- def invalidated_notices
40- @invalidated_patients . map do |patient |
41- {
42- patient :,
43- date_time : patient . invalidated_at ,
44- message : "Record flagged as invalid"
45- }
46- end
47- end
48-
49- def restricted_notices
50- @restricted_patients . map do |patient |
51- {
52- patient :,
53- date_time : patient . restricted_at ,
54- message : "Record flagged as sensitive"
55- }
56- end
28+ all_patients =
29+ (
30+ @deceased_patients + @invalidated_patients + @restricted_patients +
31+ @has_vaccination_records_dont_notify_parents_patients
32+ ) . uniq
33+
34+ notices =
35+ all_patients . flat_map do |patient |
36+ helpers
37+ . patient_important_notices ( patient )
38+ . map { |notification | notification . merge ( patient :) }
39+ end
40+ notices . sort_by { it [ :date_time ] } . reverse
5741 end
5842end
0 commit comments