Skip to content

Commit 9247e2a

Browse files
committed
Update
1 parent e1efba8 commit 9247e2a

4 files changed

Lines changed: 39 additions & 29 deletions

File tree

src/define-xml/create_define_json.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ def build_vlm_lookup(self):
475475
tsparmcd_entry = {
476476
"dataType": "text",
477477
"length": 1,
478-
"codeList": "CL.YN",
478+
"codeList": "CL.NY",
479479
"originType": "Protocol",
480480
"originSource": "Sponsor",
481481
"WhereClause": [
@@ -677,7 +677,7 @@ def build_vlm_lookup(self):
677677
tsparmcd_entry = {
678678
"dataType": "text",
679679
"length": 1,
680-
"codeList": "CL.YN",
680+
"codeList": "CL.NY",
681681
"originType": "Protocol",
682682
"originSource": "Sponsor",
683683
"WhereClause": [
@@ -819,7 +819,7 @@ def build_vlm_lookup(self):
819819
tsparmcd_entry = {
820820
"dataType": "text",
821821
"length": 1,
822-
"codeList": "CL.YN",
822+
"codeList": "CL.NY",
823823
"originType": "Protocol",
824824
"originSource": "Sponsor",
825825
"WhereClause": [
@@ -844,7 +844,7 @@ def build_vlm_lookup(self):
844844
tsparmcd_entry = {
845845
"dataType": "text",
846846
"length": 1,
847-
"codeList": "CL.YN",
847+
"codeList": "CL.NY",
848848
"originType": "Protocol",
849849
"originSource": "Sponsor",
850850
"WhereClause": [
@@ -1373,7 +1373,7 @@ def build_vlm_lookup(self):
13731373
tsparmcd_entry = {
13741374
"dataType": "text",
13751375
"length": 1,
1376-
"codeList": "CL.YN",
1376+
"codeList": "CL.NY",
13771377
"originType": "Protocol",
13781378
"originSource": "Sponsor",
13791379
"WhereClause": [
@@ -1400,7 +1400,7 @@ def build_vlm_lookup(self):
14001400
tsparmcd_entry = {
14011401
"dataType": "text",
14021402
"length": 1,
1403-
"codeList": "CL.YN",
1403+
"codeList": "CL.NY",
14041404
"originType": "Protocol",
14051405
"originSource": "Sponsor",
14061406
"WhereClause": [
@@ -2097,6 +2097,10 @@ def update_datasets_dict(self):
20972097
"name": "Epoch",
20982098
"dataType": "text",
20992099
"standard": "STD.SDTMCT",
2100+
"coding": [{
2101+
"code": "C99079",
2102+
"codeSystem": "nci:ExtCodeID"
2103+
}],
21002104
"codeListItems": epoch_terms,
21012105
}
21022106

src/generators/define/codeLists.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,17 @@ def create_define_objects(
3030
for cl in template:
3131
# TODO template missing the NCI c-codes for codelists and terms
3232
cl_defn = self._create_codelist_object(cl)
33-
cl_c_code = cl.get("nciCodelistCode")
33+
coding = cl.get("coding", [])
34+
cl_c_code = coding[0].get("code") if coding else None
3435
cl_name = cl.get("name", "unknown")
3536
codelist_items = self.require_key(cl, "codeListItems", f"CodeList {cl_name}")
3637
for term in codelist_items:
37-
cl_item = self._create_codelistitem_object(term)
38-
cl_defn.CodeListItem.append(cl_item)
38+
if "decode" in term:
39+
cl_item = self._create_codelistitem_object(term)
40+
cl_defn.CodeListItem.append(cl_item)
41+
else:
42+
en_item = self._create_enumerateditem_object(term)
43+
cl_defn.EnumeratedItem.append(en_item)
3944
# TODO no indicator that a codelist is a dictionary with an external codelist reference
4045
if len(cl["codeListItems"]) == 0:
4146
self._create_external_code_list(cl_defn, cl)
@@ -71,22 +76,23 @@ def _create_codelist_object(self, obj):
7176
cl = DEFINE.CodeList(**attr)
7277
return cl
7378

74-
@staticmethod
75-
def _create_enumerateditem_object(obj):
76-
attr = {"CodedValue": obj["Term"]}
77-
if obj.get("Order"):
78-
attr["OrderNumber"] = obj["Order"]
79+
def _create_enumerateditem_object(self, obj):
80+
coded_value = self.require_key(obj, "codedValue", "CodeListItem")
81+
attr = {"CodedValue": coded_value}
82+
# if obj.get("Order"):
83+
# attr["OrderNumber"] = obj["Order"]
7984
en_item = DEFINE.EnumeratedItem(**attr)
80-
if obj.get("NCI Term Code"):
81-
alias = DEFINE.Alias(Context="nci:ExtCodeID", Name=obj["NCI Term Code"])
85+
coding = obj.get("coding", {})
86+
if coding:
87+
alias = DEFINE.Alias(Context="nci:ExtCodeID", Name=coding.get("code"))
8288
en_item.Alias.append(alias)
8389
return en_item
8490

8591
def _create_codelistitem_object(self, obj):
8692
coded_value = self.require_key(obj, "codedValue", "CodeListItem")
8793
attr = {"CodedValue": coded_value}
88-
if obj.get("order"):
89-
attr["OrderNumber"] = obj["order"]
94+
# if obj.get("order"):
95+
# attr["OrderNumber"] = obj["order"]
9096
cl_item = DEFINE.CodeListItem(**attr)
9197
decode = DEFINE.Decode()
9298
if obj.get("decode", None):
@@ -97,7 +103,8 @@ def _create_codelistitem_object(self, obj):
97103
decode.TranslatedText.append(tt)
98104
cl_item.Decode = decode
99105
# TODO NCI c-codes for terms or codelists not available in template
100-
if obj.get("nciTermCode"):
101-
alias = DEFINE.Alias(Context="nci:ExtCodeID", Name=obj["nciTermCode"])
106+
coding = obj.get("coding", {})
107+
if coding:
108+
alias = DEFINE.Alias(Context="nci:ExtCodeID", Name=coding.get("code"))
102109
cl_item.Alias.append(alias)
103110
return cl_item

src/generators/define/itemGroups.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ def _generate_dataset(self, dataset, define_objects, lang, acrf):
6363
def _create_itemgroupdef_object(self, obj):
6464
name = self.require_key(obj, "name", "ItemGroupDef")
6565
oid = self.generate_oid(["IG", name])
66-
attr = {"OID": oid, "Name": name, "Domain": name}
66+
attr = {"OID": oid, "Name": name, "Domain": name, "SASDatasetName": name}
6767
if obj.get("archiveLocationID"):
6868
attr["ArchiveLocationID"] = ".".join(["LF", obj["archiveLocationID"]])
6969
attr["Structure"] = obj.get("structure", "NA")
70-
if obj.get("sasDatasetName"):
71-
attr["SASDatasetName"] = obj["sasDatasetName"]
70+
# if obj.get("sasDatasetName"):
71+
# attr["SASDatasetName"] = obj["sasDatasetName"]
7272
if "isReferenceData" in obj:
7373
attr["IsReferenceData"] = "Yes" if obj["isReferenceData"] else "No"
7474
# else:

src/generators/define/items.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,17 @@ def _add_optional_itemdef_elements(self, item, obj, it_oid, slice):
5555
"""
5656
use the values from the Variables section in the define-template to add the optional ELEMENTS to the ItemDef
5757
"""
58+
# TODO do not find codeList in define.json example for items
59+
if obj.get("codeList"):
60+
cl_oid = self.generate_oid(["CL", obj["codeList"].split(".")[1]])
61+
cl = DEFINE.CodeListRef(CodeListOID=cl_oid)
62+
item.CodeListRef = cl
5863
for s in slice or []:
5964
if s.get("type") == "ValueList":
6065
if s.get("wasDerivedFrom") == it_oid:
6166
vl_oid = s["OID"]
6267
vl_ref = DEFINE.ValueListRef(ValueListOID=vl_oid)
6368
item.ValueListRef = vl_ref
64-
65-
# TODO do not find codeList in define.json example for items
66-
if obj.get("codeList"):
67-
cl_oid = self.generate_oid(["CL", obj["codeList"].split(".")[1]])
68-
cl = DEFINE.CodeListRef(CodeListOID=cl_oid)
69-
item.CodeListRef = cl
7069
# TODO do not find origin content in define.json example for items (nice to have that information)
7170
attr = {}
7271
if obj.get("origin"):

0 commit comments

Comments
 (0)