Skip to content

Commit 2aea793

Browse files
authored
VED-253 Remove PDS calls (#707)
* init: PoC * removed PDS * sonar issues * TEMP: removed MNS subscription * restored * e2e: test_bad_nhs_number -> test_invalid_nhs_number * e2e: test_bad_nhs_number -> test_invalid_nhs_number II * e2e: test_bad_nhs_number -> test_invalid_nhs_number III
1 parent 7c01561 commit 2aea793

File tree

10 files changed

+59
-514
lines changed

10 files changed

+59
-514
lines changed

backend/src/authentication.py

Lines changed: 0 additions & 76 deletions
This file was deleted.

backend/src/fhir_controller.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,14 @@
44
import os
55
import re
66
import uuid
7-
from botocore.config import Config
87
from decimal import Decimal
98
from typing import Optional
10-
from authentication import AppRestrictedAuth, Service
119
import boto3
1210
from aws_lambda_typing.events import APIGatewayProxyEventV1
13-
from botocore.config import Config
1411
from fhir.resources.R4B.immunization import Immunization
1512
from boto3 import client as boto3_client
1613

1714
from authorization import Authorization, UnknownPermission
18-
from cache import Cache
1915
from fhir_repository import ImmunizationRepository, create_table
2016
from fhir_service import FhirService, UpdateOutcome, get_service_url
2117
from models.errors import (
@@ -36,7 +32,6 @@
3632
from models.utils.generic_utils import check_keys_in_sources
3733
from models.utils.permissions import get_supplier_permissions
3834
from models.utils.permission_checker import ApiOperationCode, validate_permissions, _expand_permissions
39-
from pds_service import PdsService
4035
from parameter_parser import process_params, process_search_params, create_query_string
4136
import urllib.parse
4237

@@ -45,23 +40,13 @@
4540

4641

4742
def make_controller(
48-
pds_env: str = os.getenv("PDS_ENV", "int"),
4943
immunization_env: str = os.getenv("IMMUNIZATION_ENV"),
5044
):
5145
endpoint_url = "http://localhost:4566" if immunization_env == "local" else None
5246
imms_repo = ImmunizationRepository(create_table(endpoint_url=endpoint_url))
53-
boto_config = Config(region_name="eu-west-2")
54-
cache = Cache(directory="/tmp")
55-
authenticator = AppRestrictedAuth(
56-
service=Service.PDS,
57-
secret_manager_client=boto3.client("secretsmanager", config=boto_config),
58-
environment=pds_env,
59-
cache=cache,
60-
)
61-
pds_service = PdsService(authenticator, pds_env)
6247

6348
authorizer = Authorization()
64-
service = FhirService(imms_repo=imms_repo, pds_service=pds_service)
49+
service = FhirService(imms_repo=imms_repo)
6550

6651
return FhirController(authorizer=authorizer, fhir_service=service)
6752

backend/src/fhir_service.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
from models.utils.generic_utils import nhs_number_mod11_check, get_occurrence_datetime, create_diagnostics, form_json, get_contained_patient
2424
from models.constants import Constants
2525
from models.errors import MandatoryError
26-
from pds_service import PdsService
2726
from timer import timed
2827
from filter import Filter
2928

@@ -53,11 +52,9 @@ class FhirService:
5352
def __init__(
5453
self,
5554
imms_repo: ImmunizationRepository,
56-
pds_service: PdsService,
5755
validator: ImmunizationValidator = ImmunizationValidator(),
5856
):
5957
self.immunization_repo = imms_repo
60-
self.pds_service = pds_service
6158
self.validator = validator
6259

6360
def get_immunization_by_identifier(
@@ -344,10 +341,10 @@ def search_immunizations(
344341
@timed
345342
def _validate_patient(self, imms: dict) -> dict:
346343
"""
347-
Get the NHS number from the contained Patient resource and validate it with PDS.
344+
Get the NHS number from the contained Patient resource and validate it.
348345
349346
If the NHS number doesn't exist, return an empty dict.
350-
If the NHS number exists, get the patient details from PDS and return the patient details.
347+
If the NHS number exists, check it's valid, and return the patient details.
351348
"""
352349
try:
353350
contained_patient = get_contained_patient(imms)
@@ -358,18 +355,7 @@ def _validate_patient(self, imms: dict) -> dict:
358355
if not nhs_number:
359356
return {}
360357

361-
if os.getenv("PDS_CHECK_ENABLED") == "false":
362-
logger.warning("Skipping PDS check")
358+
if nhs_number_mod11_check(nhs_number):
363359
return contained_patient
364360

365-
patient = self.pds_service.get_patient_details(nhs_number)
366-
# To check whether the Superseded NHS number present in PDS
367-
if patient:
368-
pds_nhs_number = patient["identifier"][0]["value"]
369-
if pds_nhs_number != nhs_number:
370-
diagnostics_error = create_diagnostics()
371-
return diagnostics_error
372-
373-
return patient
374-
375361
raise InvalidPatientId(patient_identifier=nhs_number)

backend/src/pds_service.py

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)