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

Commit

Permalink
Added snomed term to submission df
Browse files Browse the repository at this point in the history
  • Loading branch information
alexiswl committed Nov 7, 2023
1 parent fba4d3f commit 051f2d0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def lambda_handler(event, context):
"ica_workflow_run_id": "wfr.123abc",
"panel_type": "main",
"sample_type": "validation",
"is_identified": False
"is_identified": False | "deidentified",
"disease_name": ""Disseminated malignancy of unknown primary""
}
"""

Expand Down Expand Up @@ -93,13 +94,16 @@ def lambda_handler(event, context):
if (is_identified := event.get("is_identified", None)) is None:
is_identified = VALIDATION_DEFAULTS["is_identified"]

# Check disease name
if (disease_name := event.get("disease_name", None)) is None:
disease_name = VALIDATION_DEFAULTS["disease_name"]

# Update sample_df with validation defaults
sample_df["sample_type"] = sample_type
sample_df["panel_type"] = panel_type
sample_df["is_identified"] = is_identified
sample_df["disease_name"] = disease_name
sample_df["indication"] = VALIDATION_DEFAULTS["indication"]
sample_df["disease_id"] = VALIDATION_DEFAULTS["disease_id"]
sample_df["disease_name"] = VALIDATION_DEFAULTS["disease_name"]
sample_df["requesting_physicians_first_name"] = VALIDATION_DEFAULTS["requesting_physicians_first_name"]
sample_df["requesting_physicians_last_name"] = VALIDATION_DEFAULTS["requesting_physicians_last_name"]
sample_df["specimen_type"] = VALIDATION_DEFAULTS["specimen_type"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ def get_libraries_for_processing(merged_df) -> pd.DataFrame:
* is_identified
* needs_redcap
* redcap_is_complete
* default_snomed_term
"""

# Initialise
Expand All @@ -206,7 +207,8 @@ def get_libraries_for_processing(merged_df) -> pd.DataFrame:
"sample_type",
"is_identified",
"needs_redcap",
"redcap_is_complete"
"redcap_is_complete",
"default_snomed_term"
]

# Processing libraries must meet the following criteria
Expand Down Expand Up @@ -273,6 +275,7 @@ def get_libraries_for_processing(merged_df) -> pd.DataFrame:
"sample_type",
"is_identified",
"needs_redcap"
"default_snomed_term"
]

for column_name in new_column_names:
Expand All @@ -284,14 +287,17 @@ def get_libraries_for_processing(merged_df) -> pd.DataFrame:
]


def submit_library_to_pieriandx(subject_id: str, library_id: str, workflow_run_id: str, lambda_arn: str, panel_type: str, sample_type: str, is_identified: bool):
def submit_library_to_pieriandx(subject_id: str, library_id: str, workflow_run_id: str, lambda_arn: str, panel_type: str, sample_type: str, is_identified: Union[bool | str], default_snomed_term: str):
"""
Submit library to pieriandx
:param is_identified:
:param sample_type:
:param subject_id:
:param library_id:
:param workflow_run_id:
:param lambda_arn:
:param panel_type:
:param default_snomed_term
:return:
"""
lambda_client: LambdaClient = get_boto3_lambda_client()
Expand All @@ -302,7 +308,8 @@ def submit_library_to_pieriandx(subject_id: str, library_id: str, workflow_run_i
"ica_workflow_run_id": workflow_run_id,
"panel_type": panel_type,
"sample_type": sample_type,
"is_identified": is_identified
"is_identified": is_identified,
"disease_name": default_snomed_term
}

logger.info(f"Launching lambda function {lambda_arn} with the following payload {json.dumps(lambda_payload)}")
Expand Down Expand Up @@ -361,6 +368,7 @@ def submit_libraries_to_pieriandx(processing_df: pd.DataFrame) -> pd.DataFrame:
* is_identified
* needs_redcap
* redcap_is_complete
* default_snomed_term
:return:
A pandas dataframe with the following columns
* subject_id
Expand Down Expand Up @@ -411,7 +419,8 @@ def submit_libraries_to_pieriandx(processing_df: pd.DataFrame) -> pd.DataFrame:
lambda_arn=row.submission_arn,
panel_type=row.panel,
sample_type=row.sample_type,
is_identified=row.is_identified
is_identified=row.is_identified,
default_snomed_term=row.default_snomed_term
)
except ValueError:
pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ class SampleType(Enum):
"sample_type": "validation",
"panel_type": PanelType.MAIN,
"indication": "NA",
"disease_id": 285645000,
"disease_name": "Disseminated malignancy of unknown primary",
"is_identified": True,
"requesting_physicians_first_name": "Sean",
Expand Down Expand Up @@ -175,7 +174,7 @@ class SampleType(Enum):

EXPECTED_ATTRIBUTES = [
"sample_type",
"disease_id",
"disease_name",
"indication",
"accession_number",
"external_specimen_id",
Expand Down

0 comments on commit 051f2d0

Please sign in to comment.