@@ -79,15 +79,21 @@ class Metastasis(TnmEnum):
79
79
80
80
81
81
class TNM (pydantic .BaseModel ):
82
- prefix : Optional [Prefix ] = None
83
- tumour : Optional [Tumour ] = None
84
- tumour_specification : Optional [Specification ] = None
82
+ tumour_prefix : Optional [str ] = None
83
+ tumour : Optional [str ] = None
84
+ tumour_specification : Optional [str ] = None
85
85
tumour_suffix : Optional [str ] = None
86
- node : Optional [Node ] = None
87
- node_specification : Optional [Specification ] = None
86
+ node_prefix : Optional [str ] = None
87
+ node : Optional [str ] = None
88
+ node_specification : Optional [str ] = None
88
89
node_suffix : Optional [str ] = None
89
- metastasis : Optional [Metastasis ] = None
90
- resection_completeness : Optional [int ] = None
90
+ metastasis_prefix : Optional [str ] = None
91
+ metastasis : Optional [str ] = None
92
+ metastasis_specification : Optional [str ] = None
93
+ pleura : Optional [str ] = None
94
+ resection : Optional [str ] = None
95
+ resection_specification : Optional [str ] = None
96
+ resection_loc : Optional [str ] = None
91
97
version : Optional [str ] = None
92
98
version_year : Optional [int ] = None
93
99
@@ -112,32 +118,43 @@ def validate_year(cls, v):
112
118
def norm (self ) -> str :
113
119
norm = []
114
120
115
- if self .prefix is not None :
116
- norm .append (str ( self .prefix ) )
121
+ if self .tumour_prefix :
122
+ norm .append (f" { self .tumour_prefix or '' } " )
117
123
118
- if (
119
- (self .tumour is not None )
120
- | (self .tumour_specification is not None )
121
- | (self .tumour_suffix is not None )
122
- ):
123
- norm .append (f"T{ str (self .tumour or '' )} " )
124
- norm .append (f"{ str (self .tumour_specification or '' )} " )
125
- norm .append (f"{ str (self .tumour_suffix or '' )} " )
126
-
127
- if (
128
- (self .node is not None )
129
- | (self .node_specification is not None )
130
- | (self .node_suffix is not None )
131
- ):
132
- norm .append (f"N{ str (self .node or '' )} " )
133
- norm .append (f"{ str (self .node_specification or '' )} " )
134
- norm .append (f"{ str (self .node_suffix or '' )} " )
124
+ if self .tumour :
125
+ norm .append (f"T{ self .tumour } " )
126
+ if self .tumour_specification :
127
+ norm .append (f"{ self .tumour_specification or '' } " )
128
+ if self .tumour_suffix :
129
+ norm .append (f"{ self .tumour_suffix or '' } " )
130
+
131
+ if self .node_prefix :
132
+ norm .append (f"{ self .node_prefix or '' } " )
135
133
136
- if self .metastasis is not None :
134
+ if self .node :
135
+ norm .append (f"N{ self .node } " )
136
+ if self .node_specification :
137
+ norm .append (f"{ self .node_specification or '' } " )
138
+ if self .node_suffix :
139
+ norm .append (f"{ self .node_suffix or '' } " )
140
+
141
+ if self .metastasis_prefix :
142
+ norm .append (f"{ self .metastasis_prefix or '' } " )
143
+
144
+ if self .metastasis :
137
145
norm .append (f"M{ self .metastasis } " )
146
+ if self .metastasis_specification :
147
+ norm .append (f"{ self .metastasis_specification or '' } " )
148
+
149
+ if self .pleura :
150
+ norm .append (f"PL{ self .pleura } " )
138
151
139
- if self .resection_completeness is not None :
140
- norm .append (f"R{ self .resection_completeness } " )
152
+ if self .resection :
153
+ norm .append (f"R{ self .resection } " )
154
+ if self .resection_specification :
155
+ norm .append (f"{ self .resection_specification or '' } " )
156
+ if self .resection_loc :
157
+ norm .append (f"{ self .resection_loc or '' } " )
141
158
142
159
if self .version is not None and self .version_year is not None :
143
160
norm .append (f" ({ self .version .upper ()} { self .version_year } )" )
@@ -182,14 +199,21 @@ def dict(
182
199
set_keys = set (d .keys ())
183
200
for k in set_keys .intersection (
184
201
{
185
- "prefix " ,
202
+ "tumour_prefix " ,
186
203
"tumour" ,
187
- "node" ,
188
- "metastasis" ,
189
204
"tumour_specification" ,
190
- "node_specification" ,
191
205
"tumour_suffix" ,
206
+ "node_prefix" ,
207
+ "node" ,
208
+ "node_specification" ,
192
209
"node_suffix" ,
210
+ "metastasis_prefix" ,
211
+ "metastasis" ,
212
+ "metastasis_specification" ,
213
+ "pleura" ,
214
+ "resection" ,
215
+ "resection_specification" ,
216
+ "resection_loc" ,
193
217
}
194
218
):
195
219
v = d [k ]
0 commit comments