@@ -55,24 +55,24 @@ def get_person_record(self, nhs_hash: str | None) -> Any:
5555 return None
5656
5757 def get_eligibility_data (self , nhs_number : NHSNumber ) -> Person :
58- # AWSCURRENT secret
59- nhs_hash = self ._hashing_service .hash_with_current_secret (nhs_number )
60- items = self .get_person_record (nhs_hash )
61-
58+ # Hash using AWSCURRENT secret and fetch items
59+ items = None
60+ nhs_hashed_with_current = self ._hashing_service .hash_with_current_secret (nhs_number )
61+ if nhs_hashed_with_current :
62+ items = self .get_person_record (nhs_hashed_with_current )
6263 if not items :
63- logger .error ("No person record found for hashed nhs_number using secret AWSCURRENT" )
64-
65- # AWSPREVIOUS secret
66- nhs_hash = self ._hashing_service .hash_with_previous_secret (nhs_number )
64+ logger .warning ("No person record found for hashed nhs_number using secret AWSCURRENT" )
6765
68- if nhs_hash is not None :
69- items = self .get_person_record (nhs_hash )
66+ # Hash using AWSPREVIOUS secret and fetch items
67+ nhs_hashed_with_previous = self ._hashing_service .hash_with_previous_secret (nhs_number )
68+ if nhs_hashed_with_previous :
69+ items = self .get_person_record (nhs_hashed_with_previous )
7070 if not items :
71- logger .error ("No person record found for hashed nhs_number using secret AWSPREVIOUS" )
71+ logger .warning ("No person record found for hashed nhs_number using secret AWSPREVIOUS" )
7272 message = "Person not found after checking AWSCURRENT and AWSPREVIOUS."
7373 raise NotFoundError (message )
7474 else :
75- # fallback not hashed NHS number
75+ # fallback : Fetch using Raw NHS number
7676 items = self .get_person_record (nhs_number )
7777 if not items :
7878 logger .error ("No person record found for not hashed nhs_number" )
0 commit comments