@@ -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 )
@@ -64,29 +69,30 @@ def _create_codelist_object(self, obj):
6469 attr = {"OID" : oid , "Name" : name , "DataType" : data_type }
6570 if obj .get ("comment" ):
6671 attr ["CommentOID" ] = obj ["comment" ]
67- if obj . get ( "isNonStandard" ) :
68- attr ["IsNonStandard" ] = obj [ "isNonStandard" ]
69- if obj .get ("standardOID " ):
70- attr ["StandardOID" ] = obj ["standardOID " ]
72+ if "isNonStandard" in obj :
73+ attr ["IsNonStandard" ] = "Yes"
74+ if obj .get ("standard " ):
75+ attr ["StandardOID" ] = obj ["standard " ]
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
0 commit comments