|
2 | 2 |
|
3 | 3 | class TimelineRecords
|
4 | 4 | DEFAULT_DETAILS_CONFIG = {
|
5 |
| - cohort_imports: [], |
6 |
| - class_imports: [], |
7 |
| - patient_sessions: %i[session_id], |
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 | + organisation: %i[], |
| 11 | + cohort_imports: %i[], |
| 12 | + class_imports: %i[], |
| 13 | + parents: %i[], |
| 14 | + patient_sessions: %i[session_id], |
| 15 | + gillick_assessments: %i[], |
| 16 | + parent_relationships: %i[], |
| 17 | + school_moves: %i[school_id source], |
| 18 | + school_move_log_entries: %i[school_id user_id] |
13 | 19 | }.freeze
|
14 | 20 |
|
15 | 21 | 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 session_id], |
18 |
| - patient_sessions: %i[session_id], |
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 |
| 22 | + consents: %i[response route updated_at withdrawn_at invalidated_at], |
| 23 | + sessions: %i[slug academic_year], |
| 24 | + session_attendances: %i[attending updated_at], |
| 25 | + triages: %i[status updated_at invalidated_at performed_by_user_id], |
| 26 | + vaccination_records: %i[ |
| 27 | + outcome |
| 28 | + performed_at |
| 29 | + updated_at |
| 30 | + discarded_at |
| 31 | + uuid |
| 32 | + session_id |
| 33 | + ], |
| 34 | + organisation: %i[name ods_code], |
| 35 | + cohort_imports: %i[ |
| 36 | + csv_filename |
| 37 | + processed_at |
| 38 | + status |
| 39 | + rows_count |
| 40 | + new_record_count |
| 41 | + exact_duplicate_record_count |
| 42 | + changed_record_count |
28 | 43 | ],
|
29 |
| - triages: %i[status performed_by_user_id programme_id invalidated_at], |
| 44 | + class_imports: %i[ |
| 45 | + csv_filename |
| 46 | + processed_at |
| 47 | + status |
| 48 | + rows_count |
| 49 | + new_record_count |
| 50 | + exact_duplicate_record_count |
| 51 | + changed_record_count |
| 52 | + year_groups |
| 53 | + ], |
| 54 | + parents: %i[], |
| 55 | + patient_sessions: %i[], |
| 56 | + gillick_assessments: %i[], |
| 57 | + parent_relationships: %i[], |
| 58 | + school_moves: %i[school_id source], |
| 59 | + school_move_log_entries: %i[school_id user_id] |
| 60 | + }.freeze |
| 61 | + |
| 62 | + AVAILABLE_DETAILS_CONFIG_WITH_PII = { |
| 63 | + consents: %i[response route updated_at withdrawn_at invalidated_at], |
| 64 | + sessions: %i[slug academic_year], |
| 65 | + session_attendances: %i[attending updated_at], |
| 66 | + triages: %i[status updated_at invalidated_at performed_by_user_id], |
30 | 67 | vaccination_records: %i[
|
31 | 68 | outcome
|
32 |
| - performed_by_user_id |
33 |
| - programme_id |
| 69 | + performed_at |
| 70 | + updated_at |
| 71 | + discarded_at |
| 72 | + uuid |
34 | 73 | session_id
|
35 |
| - vaccine_id |
36 |
| - ] |
| 74 | + ], |
| 75 | + organisation: %i[name ods_code], |
| 76 | + cohort_imports: %i[ |
| 77 | + csv_filename |
| 78 | + processed_at |
| 79 | + status |
| 80 | + rows_count |
| 81 | + new_record_count |
| 82 | + exact_duplicate_record_count |
| 83 | + changed_record_count |
| 84 | + ], |
| 85 | + class_imports: %i[ |
| 86 | + csv_filename |
| 87 | + processed_at |
| 88 | + status |
| 89 | + rows_count |
| 90 | + new_record_count |
| 91 | + exact_duplicate_record_count |
| 92 | + changed_record_count |
| 93 | + year_groups |
| 94 | + ], |
| 95 | + parents: %i[full_name email phone], |
| 96 | + patient_sessions: %i[session_id], |
| 97 | + gillick_assessments: %i[ |
| 98 | + knows_vaccination |
| 99 | + knows_disease |
| 100 | + knows_consequences |
| 101 | + knows_delivery |
| 102 | + knows_side_effects |
| 103 | + ], |
| 104 | + parent_relationships: %i[type other_name], |
| 105 | + school_moves: %i[school_id source], |
| 106 | + school_move_log_entries: %i[school_id user_id] |
37 | 107 | }.freeze
|
38 | 108 |
|
39 | 109 | DEFAULT_AUDITS_CONFIG = {
|
@@ -67,14 +137,57 @@ class TimelineRecords
|
67 | 137 | source
|
68 | 138 | ].freeze
|
69 | 139 |
|
70 |
| - def initialize(patient, detail_config: {}, audit_config: {}) |
| 140 | + ALLOWED_AUDITED_CHANGES_WITH_PII = %i[ |
| 141 | + full_name |
| 142 | + email |
| 143 | + phone |
| 144 | + nhs_number |
| 145 | + given_name |
| 146 | + family_name |
| 147 | + date_of_birth |
| 148 | + address_line_1 |
| 149 | + address_line_2 |
| 150 | + address_town |
| 151 | + address_postcode |
| 152 | + home_educated |
| 153 | + updated_from_pds_at |
| 154 | + restricted_at |
| 155 | + date_of_death |
| 156 | + pending_changes |
| 157 | + patient_id |
| 158 | + session_id |
| 159 | + programme_id |
| 160 | + vaccine_id |
| 161 | + organisation_id |
| 162 | + school_id |
| 163 | + gp_practice_id |
| 164 | + uploaded_by_user_id |
| 165 | + performed_by_user_id |
| 166 | + user_id |
| 167 | + parent_id |
| 168 | + status |
| 169 | + outcome |
| 170 | + response |
| 171 | + route |
| 172 | + date_of_death_recorded_at |
| 173 | + restricted_at |
| 174 | + invalidated_at |
| 175 | + withdrawn_at |
| 176 | + rows_count |
| 177 | + year_groups |
| 178 | + home_educated |
| 179 | + source |
| 180 | + ].freeze |
| 181 | + |
| 182 | + def initialize(patient, detail_config: {}, audit_config: {}, show_pii: false) |
71 | 183 | @patient = patient
|
72 | 184 | @patient_id = @patient.id
|
73 | 185 | @patient_events = patient_events(@patient)
|
74 | 186 | @additional_events = additional_events(@patient)
|
75 | 187 | @detail_config = extract_detail_config(detail_config)
|
76 | 188 | @events = []
|
77 | 189 | @audit_config = audit_config
|
| 190 | + @show_pii = show_pii |
78 | 191 | end
|
79 | 192 |
|
80 | 193 | def render_timeline(*event_names, truncate_columns: false)
|
@@ -213,12 +326,15 @@ def audits_events
|
213 | 326 | end
|
214 | 327 | ).reject { it.audited_changes.keys == ["updated_from_pds_at"] }
|
215 | 328 |
|
| 329 | + allowed_changes = |
| 330 | + @show_pii ? ALLOWED_AUDITED_CHANGES_WITH_PII : ALLOWED_AUDITED_CHANGES |
| 331 | + |
216 | 332 | audit_events.map do |audit|
|
217 | 333 | filtered_changes =
|
218 | 334 | audit
|
219 | 335 | .audited_changes
|
220 | 336 | .each_with_object({}) do |(key, value), hash|
|
221 |
| - if ALLOWED_AUDITED_CHANGES.include?(key.to_sym) |
| 337 | + if allowed_changes.include?(key.to_sym) |
222 | 338 | hash[key] = value
|
223 | 339 | elsif audits[:include_filtered_audit_changes]
|
224 | 340 | hash[key] = "[FILTERED]"
|
|
0 commit comments