2323from models .utils .generic_utils import nhs_number_mod11_check , get_occurrence_datetime , create_diagnostics , form_json , get_contained_patient
2424from models .constants import Constants
2525from models .errors import MandatoryError
26- from pds_service import PdsService
2726from timer import timed
2827from 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,28 +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" )
363- return contained_patient
364-
365- # JW: PoC
366- # the above pre-validation code is valid I think, it's just a question of
367- # removing the PDS call below
368- # TODO: we then have to tweak the tests, possibly write new ones
369- # -
370358 if nhs_number_mod11_check (nhs_number ):
371359 return contained_patient
372360
373- '''
374- patient = self.pds_service.get_patient_details(nhs_number)
375- # To check whether the Superseded NHS number present in PDS
376- if patient:
377- pds_nhs_number = patient["identifier"][0]["value"]
378- if pds_nhs_number != nhs_number:
379- diagnostics_error = create_diagnostics()
380- return diagnostics_error
381-
382- return patient
383- '''
384-
385361 raise InvalidPatientId (patient_identifier = nhs_number )
0 commit comments