Skip to content

Commit a72e550

Browse files
committed
debug
1 parent 3137113 commit a72e550

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

backend/src/fhir_controller.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from aws_lambda_typing.events import APIGatewayProxyEventV1
1111
from fhir.resources.R4B.immunization import Immunization
1212
from boto3 import client as boto3_client
13+
from clients import logger
1314

1415
from authorization import Authorization, UnknownPermission
1516
from fhir_repository import ImmunizationRepository, create_table
@@ -391,10 +392,13 @@ def delete_immunization(self, aws_event):
391392
return self.create_response(403, unauthorized.to_operation_outcome())
392393

393394
def search_immunizations(self, aws_event: APIGatewayProxyEventV1) -> dict:
395+
logger.info("SAW: search_immunizations")
396+
394397
if response := self.authorize_request(aws_event):
395398
return response
396-
399+
logger.info("SAW: Authorised request")
397400
try:
401+
logger.info("SAW: Processing search parameters")
398402
search_params = process_search_params(process_params(aws_event))
399403
except ParameterException as e:
400404
return self._create_bad_request(e.message)
@@ -427,7 +431,7 @@ def search_immunizations(self, aws_event: APIGatewayProxyEventV1) -> dict:
427431
except UnauthorizedVaxError as unauthorized:
428432
return self.create_response(403, unauthorized.to_operation_outcome())
429433
# Check vaxx type permissions on the existing record - end
430-
434+
logger.info("SAW: Searching immunizations...")
431435
result = self.fhir_service.search_immunizations(
432436
search_params.patient_identifier,
433437
vax_type_perm,

backend/src/fhir_service.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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(

backend/src/search_imms_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def search_imms_handler(event: events.APIGatewayProxyEventV1, _context: context_
2525

2626
def search_imms(event: events.APIGatewayProxyEventV1, controller: FhirController):
2727
try:
28-
logger.info("SAW: Search event: %s", json.dumps(event, indent=2))
28+
logger.info("SAW: Search event") # %s", json.dumps(event, indent=2))
2929
query_params = event.get("queryStringParameters", {})
3030
body = event.get("body")
3131
logger.info("SAW: Query parameters: %s", query_params)

0 commit comments

Comments
 (0)