|
2 | 2 |
|
3 | 3 | class TimelineRecords
|
4 | 4 | DEFAULT_DETAILS_CONFIG = {
|
5 |
| - cohort_imports: [], |
6 |
| - class_imports: [], |
7 |
| - sessions: %i[], |
8 |
| - school_moves: %i[school_id source], |
9 |
| - school_move_log_entries: %i[school_id user_id], |
10 | 5 | consents: %i[response route],
|
| 6 | + sessions: %i[], |
| 7 | + session_attendances: %i[], |
11 | 8 | triages: %i[status performed_by_user_id],
|
12 |
| - vaccination_records: %i[outcome session_id] |
| 9 | + vaccination_records: %i[outcome session_id], |
| 10 | + cohort_imports: %i[], |
| 11 | + class_imports: %i[], |
| 12 | + parents: %i[], |
| 13 | + gillick_assessments: %i[], |
| 14 | + parent_relationships: %i[], |
| 15 | + school_moves: %i[school_id source], |
| 16 | + school_move_log_entries: %i[school_id user_id] |
13 | 17 | }.freeze
|
14 | 18 |
|
15 | 19 | AVAILABLE_DETAILS_CONFIG = {
|
16 |
| - cohort_imports: %i[rows_count status uploaded_by_user_id], |
17 |
| - class_imports: %i[rows_count year_groups uploaded_by_user_id location_id], |
18 |
| - sessions: %i[], |
19 |
| - school_moves: %i[source school_id home_educated], |
20 |
| - school_move_log_entries: %i[user_id school_id home_educated], |
21 |
| - consents: %i[ |
22 |
| - programme_id |
23 |
| - response |
24 |
| - route |
25 |
| - parent_id |
26 |
| - withdrawn_at |
27 |
| - invalidated_at |
| 20 | + consents: %i[response route updated_at withdrawn_at invalidated_at], |
| 21 | + sessions: %i[slug academic_year], |
| 22 | + session_attendances: %i[attending updated_at], |
| 23 | + triages: %i[status updated_at invalidated_at performed_by_user_id], |
| 24 | + vaccination_records: %i[ |
| 25 | + outcome |
| 26 | + performed_at |
| 27 | + updated_at |
| 28 | + discarded_at |
| 29 | + uuid |
| 30 | + session_id |
| 31 | + ], |
| 32 | + cohort_imports: %i[ |
| 33 | + csv_filename |
| 34 | + processed_at |
| 35 | + status |
| 36 | + rows_count |
| 37 | + new_record_count |
| 38 | + exact_duplicate_record_count |
| 39 | + changed_record_count |
28 | 40 | ],
|
29 |
| - triages: %i[status performed_by_user_id programme_id invalidated_at], |
| 41 | + class_imports: %i[ |
| 42 | + csv_filename |
| 43 | + processed_at |
| 44 | + status |
| 45 | + rows_count |
| 46 | + new_record_count |
| 47 | + exact_duplicate_record_count |
| 48 | + changed_record_count |
| 49 | + year_groups |
| 50 | + ], |
| 51 | + parents: %i[], |
| 52 | + gillick_assessments: %i[], |
| 53 | + parent_relationships: %i[], |
| 54 | + school_moves: %i[school_id source], |
| 55 | + school_move_log_entries: %i[school_id user_id] |
| 56 | + }.freeze |
| 57 | + |
| 58 | + AVAILABLE_DETAILS_CONFIG_WITH_PII = { |
| 59 | + consents: %i[response route updated_at withdrawn_at invalidated_at], |
| 60 | + sessions: %i[slug academic_year], |
| 61 | + session_attendances: %i[attending updated_at], |
| 62 | + triages: %i[status updated_at invalidated_at performed_by_user_id], |
30 | 63 | vaccination_records: %i[
|
31 | 64 | outcome
|
32 |
| - performed_by_user_id |
33 |
| - programme_id |
| 65 | + performed_at |
| 66 | + updated_at |
| 67 | + discarded_at |
| 68 | + uuid |
34 | 69 | session_id
|
35 |
| - vaccine_id |
36 |
| - ] |
| 70 | + ], |
| 71 | + cohort_imports: %i[ |
| 72 | + csv_filename |
| 73 | + processed_at |
| 74 | + status |
| 75 | + rows_count |
| 76 | + new_record_count |
| 77 | + exact_duplicate_record_count |
| 78 | + changed_record_count |
| 79 | + ], |
| 80 | + class_imports: %i[ |
| 81 | + csv_filename |
| 82 | + processed_at |
| 83 | + status |
| 84 | + rows_count |
| 85 | + new_record_count |
| 86 | + exact_duplicate_record_count |
| 87 | + changed_record_count |
| 88 | + year_groups |
| 89 | + ], |
| 90 | + parents: %i[full_name email phone], |
| 91 | + gillick_assessments: %i[ |
| 92 | + knows_vaccination |
| 93 | + knows_disease |
| 94 | + knows_consequences |
| 95 | + knows_delivery |
| 96 | + knows_side_effects |
| 97 | + ], |
| 98 | + parent_relationships: %i[type other_name], |
| 99 | + school_moves: %i[school_id source], |
| 100 | + school_move_log_entries: %i[school_id user_id] |
37 | 101 | }.freeze
|
38 | 102 |
|
39 | 103 | DEFAULT_AUDITS_CONFIG = {
|
@@ -69,14 +133,59 @@ class TimelineRecords
|
69 | 133 | source
|
70 | 134 | ].freeze
|
71 | 135 |
|
72 |
| - def initialize(patient, detail_config: {}, audit_config: {}) |
| 136 | + ALLOWED_AUDITED_CHANGES_WITH_PII = %i[ |
| 137 | + full_name |
| 138 | + email |
| 139 | + phone |
| 140 | + nhs_number |
| 141 | + given_name |
| 142 | + family_name |
| 143 | + date_of_birth |
| 144 | + address_line_1 |
| 145 | + address_line_2 |
| 146 | + address_town |
| 147 | + address_postcode |
| 148 | + home_educated |
| 149 | + updated_from_pds_at |
| 150 | + restricted_at |
| 151 | + date_of_death |
| 152 | + pending_changes |
| 153 | + patient_id |
| 154 | + session_id |
| 155 | + location_id |
| 156 | + programme_id |
| 157 | + vaccine_id |
| 158 | + organisation_id |
| 159 | + team_id |
| 160 | + school_id |
| 161 | + gp_practice_id |
| 162 | + uploaded_by_user_id |
| 163 | + performed_by_user_id |
| 164 | + user_id |
| 165 | + parent_id |
| 166 | + status |
| 167 | + outcome |
| 168 | + response |
| 169 | + route |
| 170 | + date_of_death_recorded_at |
| 171 | + restricted_at |
| 172 | + invalidated_at |
| 173 | + withdrawn_at |
| 174 | + rows_count |
| 175 | + year_groups |
| 176 | + home_educated |
| 177 | + source |
| 178 | + ].freeze |
| 179 | + |
| 180 | + def initialize(patient, detail_config: {}, audit_config: {}, show_pii: false) |
73 | 181 | @patient = patient
|
74 | 182 | @patient_id = @patient.id
|
75 | 183 | @patient_events = patient_events(@patient)
|
76 | 184 | @additional_events = additional_events(@patient)
|
77 | 185 | @detail_config = extract_detail_config(detail_config)
|
78 | 186 | @events = []
|
79 | 187 | @audit_config = audit_config
|
| 188 | + @show_pii = show_pii |
80 | 189 | end
|
81 | 190 |
|
82 | 191 | def render_timeline(*event_names, truncate_columns: false)
|
@@ -240,12 +349,15 @@ def audits_events
|
240 | 349 | end
|
241 | 350 | ).reject { it.audited_changes.keys == ["updated_from_pds_at"] }
|
242 | 351 |
|
| 352 | + allowed_changes = |
| 353 | + @show_pii ? ALLOWED_AUDITED_CHANGES_WITH_PII : ALLOWED_AUDITED_CHANGES |
| 354 | + |
243 | 355 | audit_events.map do |audit|
|
244 | 356 | filtered_changes =
|
245 | 357 | audit
|
246 | 358 | .audited_changes
|
247 | 359 | .each_with_object({}) do |(key, value), hash|
|
248 |
| - if ALLOWED_AUDITED_CHANGES.include?(key.to_sym) |
| 360 | + if allowed_changes.include?(key.to_sym) |
249 | 361 | hash[key] = value
|
250 | 362 | elsif audits[:include_filtered_audit_changes]
|
251 | 363 | hash[key] = "[FILTERED]"
|
|
0 commit comments