Skip to content

Commit 487da0c

Browse files
SFJohnson24RamilCDISCgerrycampion
authored
normalize standards (#1733)
Co-authored-by: RamilCDISC <113539111+RamilCDISC@users.noreply.github.com> Co-authored-by: gerrycampion <85252124+gerrycampion@users.noreply.github.com>
1 parent a07fd18 commit 487da0c

3 files changed

Lines changed: 36 additions & 23 deletions

File tree

TestRule/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from cdisc_rules_engine.services.cache.in_memory_cache_service import (
33
InMemoryCacheService,
44
)
5-
from cdisc_rules_engine.utilities.utils import normalize_adam_input
5+
from cdisc_rules_engine.utilities.utils import normalize_standard_input
66
from cdisc_rules_engine.services.cdisc_library_service import CDISCLibraryService
77
from cdisc_rules_engine.services.cache.cache_populator_service import CachePopulator
88
from scripts.run_validation import run_single_rule_validation
@@ -119,7 +119,9 @@ def main(req: func.HttpRequest, context: func.Context) -> func.HttpResponse: #
119119
standard_version = standards_data.get("version")
120120
standard_substandard = standards_data.get("substandard")
121121
use_case = standards_data.get("use_case")
122-
standard, standard_version = normalize_adam_input(standard, standard_version)
122+
standard, standard_version = normalize_standard_input(
123+
standard, standard_version
124+
)
123125
codelists = json_data.get("codelists", [])
124126
cache = InMemoryCacheService()
125127
library_service = CDISCLibraryService(api_key, cache)

cdisc_rules_engine/enums/standard_types.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ class StandardTypes(BaseEnum):
66

77
SDTMIG = "sdtmig"
88
SENDIG = "sendig"
9-
ADAM = "adam"
9+
SENDIG_AR = "sendig-ar"
10+
SENDIG_DART = "sendig-dart"
11+
SENDIG_GENETOX = "sendig-genetox"
12+
ADAMIG = "adamig"
1013
TIG = "tig"
1114
USDM = "usdm"

cdisc_rules_engine/utilities/utils.py

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def get_execution_status(results):
9898

9999

100100
def get_standard_codelist_cache_key(standard: str, version: str) -> str:
101-
standard, version = normalize_adam_input(standard, version)
101+
standard, version = normalize_standard_input(standard, version)
102102
return f"{standard.lower()}-{version.replace('.', '-')}-codelists"
103103

104104

@@ -115,7 +115,7 @@ def get_library_variables_metadata_cache_key(
115115
standard_type: str, standard_version: str, standard_substandard: str
116116
) -> str:
117117
if not standard_substandard:
118-
standard_type, standard_version = normalize_adam_input(
118+
standard_type, standard_version = normalize_standard_input(
119119
standard_type, standard_version
120120
)
121121
return f"library_variables_metadata/{standard_type}/{standard_version}"
@@ -126,7 +126,7 @@ def get_library_variables_metadata_cache_key(
126126
def get_standard_details_cache_key(
127127
standard_type: str, standard_version: str, standard_substandard: str = None
128128
) -> str:
129-
standard_type, standard_version = normalize_adam_input(
129+
standard_type, standard_version = normalize_standard_input(
130130
standard_type, standard_version
131131
)
132132
if not standard_substandard:
@@ -135,24 +135,32 @@ def get_standard_details_cache_key(
135135
return f"standards/{standard_type}/{standard_version}/{standard_substandard.lower()}"
136136

137137

138-
def normalize_adam_input(standard: str, version: str) -> tuple:
138+
def normalize_standard_input(standard: str, version: str) -> tuple:
139139
"""
140-
Normalizes ADAM user input to the expected internal format.
141-
Args:
142-
standard: User input like 'adamig', 'adam-adae'
143-
version: User input like '1-0'
144-
Returns:
145-
Tuple of (normalized_standard, normalized_version)
146-
Examples:
147-
- ('adamig', '1-0') -> ('adam', 'adamig-1-0')
148-
- ('adam-adae', '1-0') -> ('adam', 'adam-adae-1-0')
149-
- ('sdtm', '3-4') -> ('sdtm', '3-4')
140+
Normalizes user CLI input for standards that have sub-variant prefixes,
141+
translating them into the internal library path format used in the cache.
142+
143+
The CDISC Library API stores sub-variants with the variant name folded
144+
into the version field.
145+
146+
Examples:
147+
('adamig', '1-3') -> ('adam', 'adamig-1-3')
148+
('adam-adae', '1-0') -> ('adam', 'adam-adae-1-0')
149+
('sendig-dart', '1-1') -> ('sendig', 'dart-1-1')
150+
('sendig-ar', '1-0') -> ('sendig', 'ar-1-0')
151+
('sendig-genetox', '1-0') -> ('sendig', 'genetox-1-0')
152+
('sdtmig-ap', '1-0') -> ('sdtmig', 'ap-1-0')
153+
('sdtmig-md', '1-0') -> ('sdtmig', 'md-1-0')
150154
"""
151-
if standard:
152-
standard_lower = standard.lower()
153-
if standard_lower in ADAM_PRODUCTS:
154-
return "adam", f"{standard_lower}-{version}"
155-
# Non-ADAM standard - keep as is
155+
if not standard:
156+
return standard, version
157+
standard_lower = standard.lower()
158+
if standard_lower in ADAM_PRODUCTS:
159+
return "adam", f"{standard_lower}-{version}"
160+
for base in ("sendig", "sdtmig"):
161+
if standard_lower.startswith(f"{base}-"):
162+
sub = standard_lower[len(base) + 1 :]
163+
return base, f"{sub}-{version}"
156164
return standard, version
157165

158166

@@ -242,7 +250,7 @@ def get_variable_codelist_map_cache_key(standard: str, version: str, subversion)
242250
if subversion:
243251
return f"{standard}-{version}-{subversion}-codelists"
244252
else:
245-
standard, version = normalize_adam_input(standard, version)
253+
standard, version = normalize_standard_input(standard, version)
246254
return f"{standard}-{version}-codelists"
247255

248256

0 commit comments

Comments
 (0)