@@ -32,6 +32,8 @@ def perform(patient, experiment_name)
32
32
if pds_patient
33
33
increment_counter ( experiment_name , "successful_lookups" )
34
34
35
+ store_nhs_number ( experiment_name , patient , pds_patient )
36
+
35
37
if patient . nhs_number . present? &&
36
38
patient . nhs_number != pds_patient . nhs_number
37
39
increment_counter ( experiment_name , "nhs_number_discrepancies" )
@@ -195,6 +197,19 @@ def store_nhs_discrepancy(experiment_name, patient, pds_patient)
195
197
Rails . cache . write ( discrepancy_key , discrepancies , expires_in : 7 . days )
196
198
end
197
199
200
+ def store_nhs_number ( experiment_name , patient , pds_patient )
201
+ discrepancy_key = "pds_experiment:#{ experiment_name } :nhs_numbers_returned"
202
+ discrepancies = Rails . cache . read ( discrepancy_key ) || [ ]
203
+
204
+ discrepancies << {
205
+ patient_id : patient . id ,
206
+ patient_nhs : patient . nhs_number || "" ,
207
+ pds_nhs : pds_patient . nhs_number
208
+ }
209
+
210
+ Rails . cache . write ( discrepancy_key , discrepancies , expires_in : 7 . days )
211
+ end
212
+
198
213
def store_array_of_ids ( experiment_name , array_name , patient_id )
199
214
request_key = "pds_experiment:#{ experiment_name } :#{ array_name } "
200
215
requests = Rails . cache . read ( request_key ) || [ ]
0 commit comments