-
Notifications
You must be signed in to change notification settings - Fork 27
890: column should consist of delimited codelists #1430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
gerrycampion
merged 7 commits into
main
from
890-column-should-consist-of-delimited-codelists
Nov 13, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
faf7c83
implement split_by operation and update contains_all to handle lists
alexfurmenkov f5d3db6
add regression tests
alexfurmenkov 6840726
add unit test for split_by operation
alexfurmenkov fd60dbe
add split_by operation docs
alexfurmenkov dbe3f6c
change operator direction
alexfurmenkov e582570
update operator unit tests
alexfurmenkov 33a30d7
update operator docs
alexfurmenkov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| from cdisc_rules_engine.operations.base_operation import BaseOperation | ||
|
|
||
|
|
||
| class SplitBy(BaseOperation): | ||
| def _execute_operation(self): | ||
| if not all((self.params.target, self.params.delimiter)): | ||
| raise ValueError( | ||
| f"name and delimiter are required params for operation {self.params.operation_name}" | ||
| ) | ||
|
|
||
| return self.evaluation_dataset[self.params.target].str.split( | ||
| self.params.delimiter | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
162 changes: 162 additions & 0 deletions
162
tests/QARegressionTests/test_Issues/test_CoreIssue890.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,162 @@ | ||
| import os | ||
| import subprocess | ||
| import unittest | ||
| import openpyxl | ||
| import pytest | ||
| from conftest import get_python_executable | ||
| from QARegressionTests.globals import ( | ||
| issue_datails_sheet, | ||
| rules_report_sheet, | ||
| issue_sheet_record_column, | ||
| issue_sheet_variable_column, | ||
| issue_sheet_values_column, | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.regression | ||
| class TestColumnConsistsOfDelimitedCodelists(unittest.TestCase): | ||
| def test_positive_dataset(self): | ||
| # Run the command in the terminal | ||
| command = [ | ||
| f"{get_python_executable()}", | ||
| "-m", | ||
| "core", | ||
| "validate", | ||
| "-s", | ||
| "send", | ||
| "-v", | ||
| "1-0", | ||
| "-dp", | ||
| os.path.join( | ||
| "tests", | ||
| "resources", | ||
| "CoreIssue890", | ||
| "unit-test-coreid-SENDIG282-positive.json", | ||
| ), | ||
| "-lr", | ||
| os.path.join("tests", "resources", "CoreIssue890", "Rule.yml"), | ||
| "-ct", | ||
| "sendct-2025-09-26", | ||
| ] | ||
| subprocess.run(command, check=True) | ||
|
|
||
| # Get the latest created Excel file | ||
| files = os.listdir() | ||
| excel_files = [ | ||
| file | ||
| for file in files | ||
| if file.startswith("CORE-Report-") and file.endswith(".xlsx") | ||
| ] | ||
| excel_file_path = sorted(excel_files)[-1] | ||
| # # Open the Excel file | ||
| workbook = openpyxl.load_workbook(excel_file_path) | ||
|
|
||
| # Go to the "Issue Details" sheet | ||
| sheet = workbook[issue_datails_sheet] | ||
|
|
||
| record_column = sheet[issue_sheet_record_column] | ||
| variables_column = sheet[issue_sheet_variable_column] | ||
| values_column = sheet[issue_sheet_values_column] | ||
|
|
||
| record_values = [cell.value for cell in record_column[1:]] | ||
| variables_values = [cell.value for cell in variables_column[1:]] | ||
| values_column_values = [cell.value for cell in values_column[1:]] | ||
|
|
||
| # Remove None values using list comprehension | ||
| record_values = [value for value in record_values if value is not None] | ||
| variables_values = [value for value in variables_values if value is not None] | ||
| values_column_values = [ | ||
| value for value in values_column_values if value is not None | ||
| ] | ||
| rules_values = [ | ||
| row for row in workbook[rules_report_sheet].iter_rows(values_only=True) | ||
| ][1:] | ||
| rules_values = [row for row in rules_values if any(row)] | ||
| # Perform the assertion | ||
| # Ensure only two negative values are caught | ||
| assert rules_values[0][0] == "CDISC.SENDIG.SEND282" | ||
| assert len(record_values) == 0 | ||
| assert len(variables_values) == 0 | ||
| assert len(values_column_values) == 0 | ||
| if os.path.exists(excel_file_path): | ||
| os.remove(excel_file_path) | ||
|
|
||
| def test_negaive_dataset(self): | ||
| # Run the command in the terminal | ||
| command = [ | ||
| f"{get_python_executable()}", | ||
| "-m", | ||
| "core", | ||
| "validate", | ||
| "-s", | ||
| "send", | ||
| "-v", | ||
| "1-0", | ||
| "-dp", | ||
| os.path.join( | ||
| "tests", | ||
| "resources", | ||
| "CoreIssue890", | ||
| "unit-test-coreid-SENDIG282-negative.json", | ||
| ), | ||
| "-lr", | ||
| os.path.join("tests", "resources", "CoreIssue890", "Rule.yml"), | ||
| "-ct", | ||
| "sendct-2025-09-26", | ||
| ] | ||
| subprocess.run(command, check=True) | ||
|
|
||
| # Get the latest created Excel file | ||
| files = os.listdir() | ||
| excel_files = [ | ||
| file | ||
| for file in files | ||
| if file.startswith("CORE-Report-") and file.endswith(".xlsx") | ||
| ] | ||
| excel_file_path = sorted(excel_files)[-1] | ||
| # Open the Excel file | ||
| workbook = openpyxl.load_workbook(excel_file_path) | ||
|
|
||
| # --- Dataset Details --- | ||
| dataset_sheet = workbook["Dataset Details"] | ||
| dataset_values = [row for row in dataset_sheet.iter_rows(values_only=True)][1:] | ||
| dataset_values = [row for row in dataset_values if any(row)] | ||
| assert len(dataset_values) > 0 | ||
| assert dataset_values[0][0] == "pp.xpt" | ||
| assert dataset_values[0][1] == "Pharmacokinetics Parameters" | ||
| assert dataset_values[0][-1] == 4 | ||
|
|
||
| # --- Issue Summary --- | ||
| issue_summary_sheet = workbook["Issue Summary"] | ||
| summary_values = [ | ||
| row for row in issue_summary_sheet.iter_rows(values_only=True) | ||
| ][1:] | ||
| summary_values = [row for row in summary_values if any(row)] | ||
| assert len(summary_values) > 0 | ||
| assert summary_values[0][0] == "pp.xpt" | ||
| assert summary_values[0][1] == "CDISC.SENDIG.SEND282" | ||
| assert summary_values[0][3] == 2 | ||
|
|
||
| # --- Issue Details --- | ||
| issue_details_sheet = workbook["Issue Details"] | ||
| details_values = [ | ||
| row for row in issue_details_sheet.iter_rows(values_only=True) | ||
| ][1:] | ||
| details_values = [row for row in details_values if any(row)] | ||
| assert all(row[0] == "CDISC.SENDIG.SEND282" for row in details_values) | ||
| assert len(details_values) == 2 | ||
|
|
||
| # --- Rules Report --- | ||
| rules_values = [ | ||
| row for row in workbook["Rules Report"].iter_rows(values_only=True) | ||
| ][1:] | ||
| rules_values = [row for row in rules_values if any(row)] | ||
| assert len(rules_values) > 0 | ||
| assert rules_values[0][0] == "CDISC.SENDIG.SEND282" | ||
|
|
||
| if os.path.exists(excel_file_path): | ||
| os.remove(excel_file_path) | ||
|
|
||
|
|
||
| # if __name__ == "__main__": | ||
| # unittest.main() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.