@@ -72,7 +72,11 @@ def make_from_details_dict(
7272 raise ConceptFactoryError (f"Concept '{ code } ' in domain '{ domain_code } ' has no definition" )
7373 details_dict ["definition" ] = concept_definition
7474 details_dict ["domain" ] = domain_code
75- details_dict ["refines" ] = ConceptFactory .make_refines (domain = domain_code , refines = details_dict .pop ("refines" , []))
75+ refines = ConceptFactory .make_refines (domain = domain_code , refines = details_dict .pop ("refines" , []))
76+ if not refines and not details_dict .get ("structure" ):
77+ # No structure? this refines Text
78+ refines = [NativeConcept .TEXT .code ]
79+ details_dict ["refines" ] = refines
7680 concept_blueprint = ConceptBlueprint .model_validate (details_dict )
7781 the_concept = ConceptFactory .make_concept_from_blueprint (domain = domain_code , code = code , concept_blueprint = concept_blueprint )
7882 return the_concept
@@ -90,19 +94,18 @@ def make_concept_from_definition(
9094 structure_class_name = code
9195 else :
9296 structure_class_name = TextContent .__name__
93- # TODO: why use a dict to create a concept? it makes no sense
94- # TODO: don't wall make_concept_code from the factory, the code received here must already be a valid concept code
95- concept_dict = {
96- "domain" : domain_code ,
97- "code" : ConceptCodeFactory .make_concept_code (domain_code , code ),
98- "definition" : definition ,
99- "structure_class_name" : structure_class_name ,
100- }
97+
10198 try :
102- the_concept = Concept .model_validate (concept_dict )
99+ the_concept = Concept (
100+ code = ConceptCodeFactory .make_concept_code (domain_code , code ),
101+ domain = domain_code ,
102+ definition = definition ,
103+ structure_class_name = structure_class_name ,
104+ refines = [NativeConcept .TEXT .code ],
105+ )
106+ return Concept .model_validate (the_concept )
103107 except ValidationError as e :
104108 raise ConceptFactoryError (f"Error validating concept: { e } " ) from e
105- return the_concept
106109
107110 @classmethod
108111 def make_concept_from_blueprint (
0 commit comments