Skip to content
Merged

fixes #1813

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ dmypy.json
# CORE reports
CORE-Report*.xlsx
CORE-Report*.json
CORE-Report*.csv
# Pyre type checker
.pyre/

Expand Down
17 changes: 10 additions & 7 deletions cdisc_rules_engine/utilities/data_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,16 @@ def filter_if_present(df: DatasetInterface, col: str, filter_value):
pass
except ValueError:
pass
has_filter = bool(filter_value) and not (
isinstance(filter_value, float) and pd.isna(filter_value)
)
return (
df.from_dict(
df[
DataProcessor.convert_float_merge_keys(df[col]) == str(filter_value)
].to_dict()
)
if filter_value
if has_filter
else df
)

Expand Down Expand Up @@ -94,7 +97,7 @@ def filter_relrec_for_domain(

@staticmethod
def merge_on_relrec_record(
relrec_row: pd.Series,
relrec_row: dict,
left_dataset: DatasetInterface,
datasets: List[dict],
dataset_preprocessor: DatasetPreprocessor,
Expand Down Expand Up @@ -178,15 +181,15 @@ def merge_relrec_datasets(
) -> DatasetInterface:
"""
1. Find each record within relrec_dataset where RDOMAIN matches the
left_dataset_domain_name
left_dataset_domain_name
2. Join each of these (left) records with all other (right) records in
relrec_dataset sharing the same STUDYID, USUBJID, RELID
relrec_dataset sharing the same STUDYID, USUBJID, RELID
3. For each record in this new dataset:
1. Filter the left and right datasets by the criteria
2. Rename the right dataset columns with wildcards and a "RELREC." dataset
specifier
specifier
3. Join the records referenced by the left side with the records referenced
by the right side
by the right side
4. Union the results
"""
relrec_for_domain = DataProcessor.filter_relrec_for_domain(
Expand All @@ -196,7 +199,7 @@ def merge_relrec_datasets(
DataProcessor.merge_on_relrec_record(
relrec_row, left_dataset, datasets, dataset_preprocessor, wildcard
)
for _, relrec_row in relrec_for_domain.iterrows()
for relrec_row in relrec_for_domain.to_dict("records")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The merge on relrec record function still has
def merge_on_relrec_record( relrec_row: pd.Series, ...

the type hint is outdated as it is changed to type dict here now.

]
result = (
objs[0].concat(objs[1:], ignore_index=True)
Expand Down
Loading