Skip to content
Merged

update #1512

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
13 changes: 12 additions & 1 deletion cdisc_rules_engine/check_operators/dataframe_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -998,8 +998,19 @@ def split_parts_have_unequal_length(self, other_value: dict):
@type_operator(FIELD_DATAFRAME)
def empty(self, other_value: dict):
target = self.replace_prefix(other_value.get("target"))
series = self.value[target]

def check_empty(x):
return isinstance(x, (set, list, dict)) and len(x) == 0

if hasattr(series, "map_partitions"):
is_empty_collection = series.map(check_empty, meta=("x", "bool"))
else:
is_empty_collection = series.map(check_empty)
results = np.where(
self.value[target].isin(NULL_FLAVORS) | pd.isna(self.value[target]),
self.value[target].isin(NULL_FLAVORS)
| pd.isna(self.value[target])
| is_empty_collection,
True,
False,
)
Expand Down
12 changes: 1 addition & 11 deletions resources/schema/Operations.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,7 @@
"properties": {
"operator": { "const": "get_codelist_attributes" }
},
"required": [
"id",
"operator",
"name",
"ct_attribute",
"version",
"target"
],
"required": ["id", "operator", "name", "ct_attribute", "version"],
"type": "object"
},
{
Expand Down Expand Up @@ -557,9 +550,6 @@
"type": "string",
"enum": ["code", "value", "pref_term"]
},
"target": {
"type": "string"
},
"term_value": {
"type": "string"
},
Expand Down
7 changes: 4 additions & 3 deletions resources/schema/Operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ Returns a list of valid extensible codelist term's submission values. Used for e

### get_codelist_attributes

Fetches controlled terminology attribute values from CT packages based on row-specific CT package and version references.
Fetches controlled terminology attribute values from CT packages based on row-specific CT package and version references. The operation constructs CT package names based on the standard being validated and the values in the `name` and `version` columns (e.g., SDTMIG → "sdtmct-{version}"). When the `name` column contains "CDISC" or "CDISC CT", it uses the validation run's standard to determine the package prefix and the version found in the cell of the specified column. The operation extracts all codes matching the specified ct_attribute from the package.

**Required Parameters:**

- `ct_attribute`: Attribute to extract - `"Term CCODE"`, `"Codelist CCODE"`, `"Term Value"`, `"Codelist Value"`, or `"Term Preferred Term"`
- `target`: Column containing CT reference (e.g., "TSVCDREF")
- `name`: Column containing CT reference (e.g., "TSVCDREF") - identifies which terminology system is referenced
- `version`: Column containing CT version (e.g., "TSVCDVER")

```yaml
Expand All @@ -166,9 +166,10 @@ Fetches controlled terminology attribute values from CT packages based on row-sp
operator: get_codelist_attributes
ct_attribute: Term CCODE
version: TSVCDVER
target: TSVCDREF
```

**Note:** due to editor not containing the cache, if using this operator in rule editor, you must put the ctpackage versions contained within your data in the library tab for it work properly in editor.

### valid_codelist_dates

Returns the valid terminology package dates for a given standard.
Expand Down
177 changes: 86 additions & 91 deletions tests/resources/COREIssue329/rule-286.json
Original file line number Diff line number Diff line change
@@ -1,101 +1,96 @@
{
"Authorities": [
"Authorities": [
{
"Organization": "CDISC",
"Standards": [
{
"Organization": "CDISC",
"Standards": [
{
"Name": "SDTMIG",
"Version": "3.2",
"References": [
{
"Origin": "SDTM and SDTMIG Conformance Rules",
"Version": "2.0",
"Citations": [
{
"Document": "IG v3.2",
"Item": "Assumption 3",
"Section": "7.4",
"Cited_Guidance": "Further information about the parameters is included below in Table 1. TSVAL may have controlled terminology depending on the value of TSPARMCD"
}
],
"Rule_Identifier": {
"Id": "CG0286",
"Version": "1"
}
}
]
},
"Name": "SDTMIG",
"Version": "3.2",
"References": [
{
"Origin": "SDTM and SDTMIG Conformance Rules",
"Version": "2.0",
"Citations": [
{
"Name": "SDTMIG",
"Version": "3.3",
"References": [
{
"Origin": "SDTM and SDTMIG Conformance Rules",
"Version": "2.0",
"Citations": [
{
"Document": "IG v3.3",
"Item": "Assumption 3",
"Section": "7.4",
"Cited_Guidance": "Further information about the parameters is included Appendix C1, Trial Summary Codes. TSVAL may have controlled terminology depending on the value of TSPARMCD. Conditions for including parameters are included in Appendix C1, Trial Summary Codes."
}
],
"Rule_Identifier": {
"Id": "CG0286",
"Version": "1"
}
}
]
"Document": "IG v3.2",
"Item": "Assumption 3",
"Section": "7.4",
"Cited_Guidance": "Further information about the parameters is included below in Table 1. TSVAL may have controlled terminology depending on the value of TSPARMCD"
}
]
}
],
"Core": {
"Id": "CDISC.SDTMIG.CG0286",
"Version": "1",
"Status": "Draft"
},
"Description": "",
"Outcome": {
"Message": ""
},
"Sensitivity": "Record",
"Scope": {
"Classes": {
"Include": [
"TRIAL DESIGN"
]
],
"Rule_Identifier": {
"Id": "CG0286",
"Version": "1"
}
}
]
},
"Domains": {
"Include": [
"TS"
]
}
},
"Executability": "Fully Executable",
"Check": {
"all": [
{
"name": "TSVCDREF",
"operator": "equal_to",
"value": "CDISC",
"value_is_literal": true
},
{
"Name": "SDTMIG",
"Version": "3.3",
"References": [
{
"name": "TSVALCD",
"operator": "is_not_contained_by",
"value": "$all_ct_term_codes"
"Origin": "SDTM and SDTMIG Conformance Rules",
"Version": "2.0",
"Citations": [
{
"Document": "IG v3.3",
"Item": "Assumption 3",
"Section": "7.4",
"Cited_Guidance": "Further information about the parameters is included Appendix C1, Trial Summary Codes. TSVAL may have controlled terminology depending on the value of TSPARMCD. Conditions for including parameters are included in Appendix C1, Trial Summary Codes."
}
],
"Rule_Identifier": {
"Id": "CG0286",
"Version": "1"
}
}
]
},
"Rule_Type": "Record Data",
"Operations": [
{
"id": "$all_ct_term_codes",
"name": "TSVCDREF",
"operator": "get_codelist_attributes",
"version": "TSVCDVER",
"attribute": "TSVALCD"
]
}
]
}
],
"Core": {
"Id": "CDISC.SDTMIG.CG0286",
"Version": "1",
"Status": "Draft"
},
"Description": "",
"Outcome": {
"Message": ""
},
"Sensitivity": "Record",
"Scope": {
"Classes": {
"Include": ["TRIAL DESIGN"]
},
"Domains": {
"Include": ["TS"]
}
},
"Executability": "Fully Executable",
"Check": {
"all": [
{
"name": "TSVCDREF",
"operator": "equal_to",
"value": "CDISC",
"value_is_literal": true
},
{
"name": "TSVALCD",
"operator": "is_not_contained_by",
"value": "$all_ct_term_codes"
}
]
},
"Rule_Type": "Record Data",
"Operations": [
{
"id": "$all_ct_term_codes",
"name": "TSVCDREF",
"operator": "get_codelist_attributes",
"version": "TSVCDVER"
}
]
}
Loading