Skip to content

Commit aa7aee6

Browse files
committed
PDS Debug
1 parent 7067e55 commit aa7aee6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lambdas/shared/src/common/pds_service.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from common.authentication import AppRestrictedAuth
55
from common.models.errors import UnhandledResponseError
6+
from common.clients import logger
67

78

89
class PdsService:
@@ -12,19 +13,28 @@ def __init__(self, authenticator: AppRestrictedAuth, environment):
1213
self.base_url = f"https://{environment}.api.service.nhs.uk/personal-demographics/FHIR/R4/Patient" \
1314
if environment != "prod" else "https://api.service.nhs.uk/personal-demographics/FHIR/R4/Patient"
1415

16+
logger.info(f"PDS Service URL: {self.base_url}")
17+
1518
def get_patient_details(self, patient_id) -> dict | None:
19+
logger.info(f"PDS. Get patient details for ID: {patient_id}")
1620
access_token = self.authenticator.get_access_token()
21+
logger.info(f"PDS. Access token: {access_token}")
1722
request_headers = {
1823
'Authorization': f'Bearer {access_token}',
1924
'X-Request-ID': str(uuid.uuid4()),
2025
'X-Correlation-ID': str(uuid.uuid4())
2126
}
27+
logger.info("PDS. Request get")
2228
response = requests.get(f"{self.base_url}/{patient_id}", headers=request_headers, timeout=5)
2329

2430
if response.status_code == 200:
31+
logger.info("PDS. Request successful")
32+
logger.debug(f"PDS. Response: {response.json()}")
2533
return response.json()
2634
elif response.status_code == 404:
35+
logger.info(f"PDS. Patient not found for ID: {patient_id}")
2736
return None
2837
else:
38+
logger.error(f"PDS. Error response: {response.status_code} - {response.text}")
2939
msg = "Downstream service failed to validate the patient"
3040
raise UnhandledResponseError(response=response.json(), message=msg)

0 commit comments

Comments
 (0)