Skip to content
This repository was archived by the owner on Dec 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #168 from umccr/bugfix/refactor-validation-lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
alexiswl authored Nov 7, 2023
2 parents 4af192a + 8deefbe commit c59f11d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,22 @@ def lambda_handler(event, context):
axis="columns"
)

# Convert times to utc time and strings
for date_column in ["date_received", "date_collected", "date_of_birth"]:
sample_df[date_column] = sample_df[date_column].apply(
lambda x: datetime_obj_to_utc_isoformat(handle_date(x))
)

# Assert expected values exist
logger.info("Check we have all of the expected information")
for expected_column in EXPECTED_ATTRIBUTES:
if expected_column not in sample_df.columns.tolist():
logger.error(
f"Expected column {expected_column} but "
f"did not find it in columns {', '.join(sample_df.columns.tolist())}"
)
raise ValueError

# For identified - we rename external subject id as the medical record number
if all(sample_df["is_identified"]):
sample_df["first_name"] = VALIDATION_DEFAULTS["first_name"]
Expand All @@ -179,22 +195,6 @@ def lambda_handler(event, context):
}
)

# Convert times to utc time and strings
for date_column in ["date_received", "date_collected", "date_of_birth"]:
sample_df[date_column] = sample_df[date_column].apply(
lambda x: datetime_obj_to_utc_isoformat(handle_date(x))
)

# Assert expected values exist
logger.info("Check we have all of the expected information")
for expected_column in EXPECTED_ATTRIBUTES:
if expected_column not in sample_df.columns.tolist():
logger.error(
f"Expected column {expected_column} but "
f"did not find it in columns {', '.join(sample_df.columns.tolist())}"
)
raise ValueError

# Launch batch lambda function
accession_json: Dict = sample_df.to_dict(orient="records")[0]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def lambda_handler(event, context):
"allow_missing_redcap_entry": false,
"panel_type": "main",
"sample_type": "patient_care_sample",
"is_identified": true,
"is_identified": true, | is_identified="identified"
}
"""

Expand Down

0 comments on commit c59f11d

Please sign in to comment.