Skip to content

Commit

Permalink
added in pds_model changes to retunr defaults on array items as None …
Browse files Browse the repository at this point in the history
…rather than empty arrays
  • Loading branch information
Scott Alexander committed Apr 25, 2024
1 parent 754982b commit 2a44535
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
15 changes: 8 additions & 7 deletions lambdas/models/pds_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class GeneralPractitioner(BaseModel):
class PatientDetails(BaseModel):
model_config = conf

given_Name: Optional[list[str]] = []
given_Name: Optional[list[str]] = None
family_name: Optional[str] = ""
birth_date: Optional[date] = None
postal_code: Optional[str] = ""
Expand All @@ -66,10 +66,10 @@ class Patient(BaseModel):

id: str
birth_date: date
address: Optional[list[Address]] = []
address: Optional[list[Address]] = None
name: list[Name]
meta: Meta
general_practitioner: Optional[list[GeneralPractitioner]] = []
general_practitioner: Optional[list[GeneralPractitioner]] = None

def get_security(self) -> Security:
security = self.meta.security[0] if self.meta.security[0] else None
Expand All @@ -96,10 +96,11 @@ def get_current_home_address(self) -> Optional[Address]:
return entry

def get_active_ods_code_for_gp(self) -> str:
for entry in self.general_practitioner:
gp_end_date = entry.identifier.period.end
if not gp_end_date or gp_end_date >= date.today():
return entry.identifier.value
if self.general_practitioner is not None:
for entry in self.general_practitioner:
gp_end_date = entry.identifier.period.end
if not gp_end_date or gp_end_date >= date.today():
return entry.identifier.value
return ""

def get_is_active_status(self) -> bool:
Expand Down
10 changes: 6 additions & 4 deletions lambdas/utils/lloyd_george_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,12 @@ def validate_with_pds_service(
logger.info("Verifying patient name against the record in PDS...")

is_file_first_name_in_patient_details = False
for patient_name in patient_details.given_Name:
if names_are_matching(file_patient_first_name, patient_name):
is_file_first_name_in_patient_details = True
break

if patient_details.given_Name is not None:
for patient_name in patient_details.given_Name:
if names_are_matching(file_patient_first_name, patient_name):
is_file_first_name_in_patient_details = True
break

if not is_file_first_name_in_patient_details or not names_are_matching(
file_patient_last_name, patient_details.family_name
Expand Down

0 comments on commit 2a44535

Please sign in to comment.