From a7f4293ce45b3efca8217e07108d4db03c97990b Mon Sep 17 00:00:00 2001 From: Samuel Johnson Date: Tue, 28 Jul 2026 14:09:22 -0400 Subject: [PATCH 1/3] fixes --- CORE-Report-2026-07-28T14-00-32.csv | 4 ++++ CORE-Report-2026-07-28T14-02-25.csv | 7 +++++++ cdisc_rules_engine/utilities/data_processor.py | 15 +++++++++------ 3 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 CORE-Report-2026-07-28T14-00-32.csv create mode 100644 CORE-Report-2026-07-28T14-02-25.csv diff --git a/CORE-Report-2026-07-28T14-00-32.csv b/CORE-Report-2026-07-28T14-00-32.csv new file mode 100644 index 000000000..ccd524a8f --- /dev/null +++ b/CORE-Report-2026-07-28T14-00-32.csv @@ -0,0 +1,4 @@ +Dataset,Record,Variable,Value +CM,3,CMDECOD, +CM,3,CMTRT,"HYDROCORTISONE, TOPICAL" +CM,3,RELREC.FAOBJ,ERYTHEMA diff --git a/CORE-Report-2026-07-28T14-02-25.csv b/CORE-Report-2026-07-28T14-02-25.csv new file mode 100644 index 000000000..822ee634b --- /dev/null +++ b/CORE-Report-2026-07-28T14-02-25.csv @@ -0,0 +1,7 @@ +Dataset,Record,Variable,Value +CM,1,CMDECOD, +CM,1,CMTRT,ASPIRIN +CM,1,RELREC.FAOBJ,ASPIRINA +CM,3,CMDECOD, +CM,3,CMTRT,"HYDROCORTISONE, TOPICAL" +CM,3,RELREC.FAOBJ,ERYTHEMA diff --git a/cdisc_rules_engine/utilities/data_processor.py b/cdisc_rules_engine/utilities/data_processor.py index c7c846bd0..445aa265e 100644 --- a/cdisc_rules_engine/utilities/data_processor.py +++ b/cdisc_rules_engine/utilities/data_processor.py @@ -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 ) @@ -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( @@ -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") ] result = ( objs[0].concat(objs[1:], ignore_index=True) From c564ace010238247ee02067740d069c08482961f Mon Sep 17 00:00:00 2001 From: Samuel Johnson Date: Wed, 29 Jul 2026 09:34:59 -0400 Subject: [PATCH 2/3] csv --- .gitignore | 1 + CORE-Report-2026-07-28T14-00-32.csv | 4 ---- CORE-Report-2026-07-28T14-02-25.csv | 7 ------- 3 files changed, 1 insertion(+), 11 deletions(-) delete mode 100644 CORE-Report-2026-07-28T14-00-32.csv delete mode 100644 CORE-Report-2026-07-28T14-02-25.csv diff --git a/.gitignore b/.gitignore index 67ce5235a..55283e5d8 100644 --- a/.gitignore +++ b/.gitignore @@ -129,6 +129,7 @@ dmypy.json # CORE reports CORE-Report*.xlsx CORE-Report*.json +CORE-Report*.csv # Pyre type checker .pyre/ diff --git a/CORE-Report-2026-07-28T14-00-32.csv b/CORE-Report-2026-07-28T14-00-32.csv deleted file mode 100644 index ccd524a8f..000000000 --- a/CORE-Report-2026-07-28T14-00-32.csv +++ /dev/null @@ -1,4 +0,0 @@ -Dataset,Record,Variable,Value -CM,3,CMDECOD, -CM,3,CMTRT,"HYDROCORTISONE, TOPICAL" -CM,3,RELREC.FAOBJ,ERYTHEMA diff --git a/CORE-Report-2026-07-28T14-02-25.csv b/CORE-Report-2026-07-28T14-02-25.csv deleted file mode 100644 index 822ee634b..000000000 --- a/CORE-Report-2026-07-28T14-02-25.csv +++ /dev/null @@ -1,7 +0,0 @@ -Dataset,Record,Variable,Value -CM,1,CMDECOD, -CM,1,CMTRT,ASPIRIN -CM,1,RELREC.FAOBJ,ASPIRINA -CM,3,CMDECOD, -CM,3,CMTRT,"HYDROCORTISONE, TOPICAL" -CM,3,RELREC.FAOBJ,ERYTHEMA From df3a9419831a44d329f1f4ab71b72403913b9f98 Mon Sep 17 00:00:00 2001 From: Samuel Johnson Date: Wed, 29 Jul 2026 09:38:20 -0400 Subject: [PATCH 3/3] type --- cdisc_rules_engine/utilities/data_processor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdisc_rules_engine/utilities/data_processor.py b/cdisc_rules_engine/utilities/data_processor.py index 445aa265e..d85c00533 100644 --- a/cdisc_rules_engine/utilities/data_processor.py +++ b/cdisc_rules_engine/utilities/data_processor.py @@ -97,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,