Skip to content

Commit 4bb330a

Browse files
committed
VED-755: remove duplication
1 parent 0644072 commit 4bb330a

File tree

2 files changed

+3
-22
lines changed

2 files changed

+3
-22
lines changed

lambdas/id_sync/src/pds_details.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,3 @@ def pds_get_patient_id(nhs_number: str) -> str:
5555
logger.exception(msg)
5656
raise IdSyncException(message=msg, exception=e)
5757

58-
59-
def normalize_name_from_pds(pds_get_patient_details: dict) -> str | None:
60-
"""Return a normalized full name (given + family) from PDS patient details or None."""
61-
try:
62-
name = pds_get_patient_details.get("name")
63-
if not name:
64-
return None
65-
name_entry = name[0] if isinstance(name, list) else name
66-
given = name_entry.get("given")
67-
given_str = None
68-
if isinstance(given, list) and given:
69-
given_str = given[0]
70-
elif isinstance(given, str):
71-
given_str = given
72-
family = name_entry.get("family")
73-
parts = [p for p in [given_str, family] if p]
74-
return " ".join(parts).strip().lower() if parts else None
75-
except Exception:
76-
return None

lambdas/id_sync/src/record_processor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from common.clients import logger
22
from typing import Dict, Any
3-
from pds_details import pds_get_patient_id, pds_get_patient_details, normalize_name_from_pds
3+
from pds_details import pds_get_patient_id, pds_get_patient_details
44
from ieds_db_operations import (
55
ieds_check_exist,
66
ieds_update_patient_id,
@@ -138,7 +138,7 @@ def normalize_strings(item: Any) -> str | None:
138138
return str(item).strip().lower() if item else None
139139

140140
# Retrieve patient resource from PDS
141-
pds_name = normalize_strings(normalize_name_from_pds(pds_details))
141+
pds_name = normalize_strings(extract_normalized_name_from_patient(pds_details))
142142
pds_gender = normalize_strings(pds_details.get("gender"))
143143
pds_birth = normalize_strings(pds_details.get("birthDate"))
144144

@@ -149,7 +149,7 @@ def normalize_strings(item: Any) -> str | None:
149149
return False
150150

151151
# normalize patient name
152-
ieds_name = extract_normalized_name_from_patient(patient)
152+
ieds_name = normalize_strings(extract_normalized_name_from_patient(patient))
153153

154154
ieds_gender = normalize_strings(patient.get("gender"))
155155
ieds_birth = patient.get("birthDate")

0 commit comments

Comments
 (0)