@@ -288,11 +288,16 @@ def search_immunizations(
288288 Finds all instances of Immunization(s) for a specified patient which are for the specified vaccine type(s).
289289 Bundles the resources with the relevant patient resource and returns the bundle.
290290 """
291+ logger .info ("SAW: search_immunizations for nhs_number: %s, vaccine_types: %s, date_from: %s, date_to: %s" ,)
291292 # TODO: is disease type a mandatory field? (I assumed it is)
292293 # i.e. Should we provide a search option for getting Patient's entire imms history?
294+
295+ logger .info ("checking nhs_number_mod11_check for nhs_number: %s" , nhs_number )
293296 if not nhs_number_mod11_check (nhs_number ):
294297 return create_diagnostics ()
295298
299+ logger .info ("SAW:obtain resources for nhs_number: %s, vaccine_types: %s, date_from: %s, date_to: %s" ,
300+ nhs_number , vaccine_types , date_from , date_to )
296301 # Obtain all resources which are for the requested nhs number and vaccine type(s) and within the date range
297302 resources = [
298303 r
@@ -307,21 +312,27 @@ def search_immunizations(
307312 # patient resource. This is as agreed with VDS team for backwards compatibility with Immunisation History API.
308313 patient_full_url = f"urn:uuid:{ str (uuid4 ())} "
309314
315+ logger .info ("SAW: call get_contained_patient" )
310316 imms_patient_record = get_contained_patient (resources [- 1 ]) if resources else None
311317
318+ logger .info ("SAW: filter resources for search" )
312319 # Filter and amend the immunization resources for the SEARCH response
313320 resources_filtered_for_search = [Filter .search (imms , patient_full_url ) for imms in resources ]
314-
321+ logger . info ( "SAW: no of items in filtered resources: %d" , len ( resources_filtered_for_search ))
315322 # Add bundle entries for each of the immunization resources
316323 entries = [
317324 BundleEntry (
318325 resource = Immunization .parse_obj (imms ),
319326 search = BundleEntrySearch (mode = "match" ),
320327 fullUrl = f"https://api.service.nhs.uk/immunisation-fhir-api/Immunization/{ imms ['id' ]} " ,
321328 )
322- for imms in resources_filtered_for_search
329+ # get imms and log for debug
330+ for imms in resources_filtered_for_search :
331+ logger .debug ("SAW: filtered immunization resource: %s" , imms )
323332 ]
324333
334+
335+ logger .info ("SAW: entries created for bundle: %d" , len (entries ))
325336 # Add patient resource if there is at least one immunization resource
326337 if len (resources ) > 0 :
327338 entries .append (
0 commit comments