automapper_validation/generated/fv2604/utilmd_gas_conditions_fv2604.rs
1// <auto-generated>
2// Generated by automapper-generator generate-conditions
3// AHB: xml-migs-and-ahbs/FV2604/UTILMD_AHB_Gas_1_1_außerordentliche_20251211.xml
4// Generated: 2026-03-12T11:40:25Z
5// </auto-generated>
6
7// LLM-produced bodies aren't idiomatic Rust — silence stylistic lints at
8// file scope so `cargo clippy -D warnings` stays green. Correctness,
9// suspicious, and perf categories stay on so real bugs still surface.
10#![allow(clippy::style, clippy::complexity)]
11
12#[allow(unused_imports)]
13use crate::eval::format_validators::*;
14use crate::eval::{ConditionEvaluator, ConditionResult, EvaluationContext};
15
16/// Generated condition evaluator for UTILMD_Gas FV2604.
17pub struct UtilmdGasConditionEvaluatorFV2604 {
18 // External condition IDs that require runtime context.
19 external_conditions: std::collections::HashSet<u32>,
20}
21
22impl Default for UtilmdGasConditionEvaluatorFV2604 {
23 fn default() -> Self {
24 let mut external_conditions = std::collections::HashSet::new();
25 external_conditions.insert(1);
26 external_conditions.insert(3);
27 external_conditions.insert(4);
28 external_conditions.insert(5);
29 external_conditions.insert(14);
30 external_conditions.insert(17);
31 external_conditions.insert(29);
32 external_conditions.insert(39);
33 external_conditions.insert(51);
34 external_conditions.insert(65);
35 external_conditions.insert(92);
36 external_conditions.insert(98);
37 external_conditions.insert(108);
38 external_conditions.insert(127);
39 external_conditions.insert(129);
40 external_conditions.insert(133);
41 external_conditions.insert(147);
42 external_conditions.insert(165);
43 external_conditions.insert(166);
44 external_conditions.insert(219);
45 external_conditions.insert(241);
46 external_conditions.insert(268);
47 external_conditions.insert(283);
48 external_conditions.insert(315);
49 external_conditions.insert(324);
50 external_conditions.insert(336);
51 external_conditions.insert(427);
52 Self {
53 external_conditions,
54 }
55 }
56}
57
58impl ConditionEvaluator for UtilmdGasConditionEvaluatorFV2604 {
59 fn message_type(&self) -> &str {
60 "UTILMD_Gas"
61 }
62
63 fn format_version(&self) -> &str {
64 "FV2604"
65 }
66
67 fn evaluate(&self, condition: u32, ctx: &EvaluationContext) -> ConditionResult {
68 match condition {
69 1 => self.evaluate_1(ctx),
70 2 => self.evaluate_2(ctx),
71 3 => self.evaluate_3(ctx),
72 4 => self.evaluate_4(ctx),
73 5 => self.evaluate_5(ctx),
74 7 => self.evaluate_7(ctx),
75 9 => self.evaluate_9(ctx),
76 10 => self.evaluate_10(ctx),
77 11 => self.evaluate_11(ctx),
78 12 => self.evaluate_12(ctx),
79 13 => self.evaluate_13(ctx),
80 14 => self.evaluate_14(ctx),
81 15 => self.evaluate_15(ctx),
82 16 => self.evaluate_16(ctx),
83 17 => self.evaluate_17(ctx),
84 18 => self.evaluate_18(ctx),
85 19 => self.evaluate_19(ctx),
86 24 => self.evaluate_24(ctx),
87 25 => self.evaluate_25(ctx),
88 26 => self.evaluate_26(ctx),
89 28 => self.evaluate_28(ctx),
90 29 => self.evaluate_29(ctx),
91 32 => self.evaluate_32(ctx),
92 33 => self.evaluate_33(ctx),
93 35 => self.evaluate_35(ctx),
94 36 => self.evaluate_36(ctx),
95 37 => self.evaluate_37(ctx),
96 39 => self.evaluate_39(ctx),
97 46 => self.evaluate_46(ctx),
98 47 => self.evaluate_47(ctx),
99 48 => self.evaluate_48(ctx),
100 51 => self.evaluate_51(ctx),
101 58 => self.evaluate_58(ctx),
102 64 => self.evaluate_64(ctx),
103 65 => self.evaluate_65(ctx),
104 66 => self.evaluate_66(ctx),
105 68 => self.evaluate_68(ctx),
106 69 => self.evaluate_69(ctx),
107 70 => self.evaluate_70(ctx),
108 77 => self.evaluate_77(ctx),
109 78 => self.evaluate_78(ctx),
110 81 => self.evaluate_81(ctx),
111 84 => self.evaluate_84(ctx),
112 92 => self.evaluate_92(ctx),
113 98 => self.evaluate_98(ctx),
114 106 => self.evaluate_106(ctx),
115 108 => self.evaluate_108(ctx),
116 123 => self.evaluate_123(ctx),
117 127 => self.evaluate_127(ctx),
118 128 => self.evaluate_128(ctx),
119 129 => self.evaluate_129(ctx),
120 130 => self.evaluate_130(ctx),
121 133 => self.evaluate_133(ctx),
122 137 => self.evaluate_137(ctx),
123 138 => self.evaluate_138(ctx),
124 147 => self.evaluate_147(ctx),
125 165 => self.evaluate_165(ctx),
126 166 => self.evaluate_166(ctx),
127 200 => self.evaluate_200(ctx),
128 202 => self.evaluate_202(ctx),
129 203 => self.evaluate_203(ctx),
130 205 => self.evaluate_205(ctx),
131 209 => self.evaluate_209(ctx),
132 212 => self.evaluate_212(ctx),
133 213 => self.evaluate_213(ctx),
134 216 => self.evaluate_216(ctx),
135 219 => self.evaluate_219(ctx),
136 230 => self.evaluate_230(ctx),
137 241 => self.evaluate_241(ctx),
138 249 => self.evaluate_249(ctx),
139 252 => self.evaluate_252(ctx),
140 257 => self.evaluate_257(ctx),
141 268 => self.evaluate_268(ctx),
142 274 => self.evaluate_274(ctx),
143 276 => self.evaluate_276(ctx),
144 277 => self.evaluate_277(ctx),
145 283 => self.evaluate_283(ctx),
146 315 => self.evaluate_315(ctx),
147 324 => self.evaluate_324(ctx),
148 328 => self.evaluate_328(ctx),
149 333 => self.evaluate_333(ctx),
150 336 => self.evaluate_336(ctx),
151 345 => self.evaluate_345(ctx),
152 361 => self.evaluate_361(ctx),
153 362 => self.evaluate_362(ctx),
154 367 => self.evaluate_367(ctx),
155 368 => self.evaluate_368(ctx),
156 427 => self.evaluate_427(ctx),
157 442 => self.evaluate_442(ctx),
158 490 => self.evaluate_490(ctx),
159 491 => self.evaluate_491(ctx),
160 494 => self.evaluate_494(ctx),
161 500 => self.evaluate_500(ctx),
162 501 => self.evaluate_501(ctx),
163 502 => self.evaluate_502(ctx),
164 504 => self.evaluate_504(ctx),
165 505 => self.evaluate_505(ctx),
166 507 => self.evaluate_507(ctx),
167 508 => self.evaluate_508(ctx),
168 510 => self.evaluate_510(ctx),
169 511 => self.evaluate_511(ctx),
170 513 => self.evaluate_513(ctx),
171 527 => self.evaluate_527(ctx),
172 528 => self.evaluate_528(ctx),
173 530 => self.evaluate_530(ctx),
174 556 => self.evaluate_556(ctx),
175 558 => self.evaluate_558(ctx),
176 559 => self.evaluate_559(ctx),
177 560 => self.evaluate_560(ctx),
178 566 => self.evaluate_566(ctx),
179 567 => self.evaluate_567(ctx),
180 570 => self.evaluate_570(ctx),
181 571 => self.evaluate_571(ctx),
182 572 => self.evaluate_572(ctx),
183 581 => self.evaluate_581(ctx),
184 583 => self.evaluate_583(ctx),
185 584 => self.evaluate_584(ctx),
186 590 => self.evaluate_590(ctx),
187 601 => self.evaluate_601(ctx),
188 621 => self.evaluate_621(ctx),
189 622 => self.evaluate_622(ctx),
190 636 => self.evaluate_636(ctx),
191 637 => self.evaluate_637(ctx),
192 638 => self.evaluate_638(ctx),
193 643 => self.evaluate_643(ctx),
194 644 => self.evaluate_644(ctx),
195 651 => self.evaluate_651(ctx),
196 654 => self.evaluate_654(ctx),
197 655 => self.evaluate_655(ctx),
198 902 => self.evaluate_902(ctx),
199 907 => self.evaluate_907(ctx),
200 912 => self.evaluate_912(ctx),
201 930 => self.evaluate_930(ctx),
202 931 => self.evaluate_931(ctx),
203 934 => self.evaluate_934(ctx),
204 935 => self.evaluate_935(ctx),
205 937 => self.evaluate_937(ctx),
206 938 => self.evaluate_938(ctx),
207 950 => self.evaluate_950(ctx),
208 951 => self.evaluate_951(ctx),
209 952 => self.evaluate_952(ctx),
210 953 => self.evaluate_953(ctx),
211 2061 => self.evaluate_2061(ctx),
212 2119 => self.evaluate_2119(ctx),
213 2284 => self.evaluate_2284(ctx),
214 2286 => self.evaluate_2286(ctx),
215 2287 => self.evaluate_2287(ctx),
216 2335 => self.evaluate_2335(ctx),
217 2353 => self.evaluate_2353(ctx),
218 _ => ConditionResult::Unknown,
219 }
220 }
221
222 fn is_external(&self, condition: u32) -> bool {
223 self.external_conditions.contains(&condition)
224 }
225 fn is_known(&self, condition: u32) -> bool {
226 matches!(
227 condition,
228 1 | 2
229 | 3
230 | 4
231 | 5
232 | 7
233 | 9
234 | 10
235 | 11
236 | 12
237 | 13
238 | 14
239 | 15
240 | 16
241 | 17
242 | 18
243 | 19
244 | 24
245 | 25
246 | 26
247 | 28
248 | 29
249 | 32
250 | 33
251 | 35
252 | 36
253 | 37
254 | 39
255 | 46
256 | 47
257 | 48
258 | 51
259 | 58
260 | 64
261 | 65
262 | 66
263 | 68
264 | 69
265 | 70
266 | 77
267 | 78
268 | 81
269 | 84
270 | 92
271 | 98
272 | 106
273 | 108
274 | 123
275 | 127
276 | 128
277 | 129
278 | 130
279 | 133
280 | 137
281 | 138
282 | 147
283 | 165
284 | 166
285 | 200
286 | 202
287 | 203
288 | 205
289 | 209
290 | 212
291 | 213
292 | 216
293 | 219
294 | 230
295 | 241
296 | 249
297 | 252
298 | 257
299 | 268
300 | 274
301 | 276
302 | 277
303 | 283
304 | 315
305 | 324
306 | 328
307 | 333
308 | 336
309 | 345
310 | 361
311 | 362
312 | 367
313 | 368
314 | 427
315 | 442
316 | 490
317 | 491
318 | 494
319 | 500
320 | 501
321 | 502
322 | 504
323 | 505
324 | 507
325 | 508
326 | 510
327 | 511
328 | 513
329 | 527
330 | 528
331 | 530
332 | 556
333 | 558
334 | 559
335 | 560
336 | 566
337 | 567
338 | 570
339 | 571
340 | 572
341 | 581
342 | 583
343 | 584
344 | 590
345 | 601
346 | 621
347 | 622
348 | 636
349 | 637
350 | 638
351 | 643
352 | 644
353 | 651
354 | 654
355 | 655
356 | 902
357 | 907
358 | 912
359 | 930
360 | 931
361 | 934
362 | 935
363 | 937
364 | 938
365 | 950
366 | 951
367 | 952
368 | 953
369 | 2061
370 | 2119
371 | 2284
372 | 2286
373 | 2287
374 | 2335
375 | 2353
376 )
377 }
378}
379
380impl UtilmdGasConditionEvaluatorFV2604 {
381 /// [2] Wenn UNH DE0070 (Übermittlungsfolgenummer) mit 1 vorhanden
382 fn evaluate_2(&self, ctx: &EvaluationContext) -> ConditionResult {
383 let unh_segs = ctx.find_segments("UNH");
384 match unh_segs.first() {
385 Some(unh) => match unh.elements.get(3).and_then(|e| e.first()) {
386 Some(val) => ConditionResult::from(val == "1"),
387 None => ConditionResult::False,
388 },
389 None => ConditionResult::False, // segment absent → condition not applicable
390 }
391 }
392
393 /// [3] Bei Aufteilung, in der Nachricht mit der höchsten Übermittlungsfolgenummer
394 /// EXTERNAL: Requires context from outside the message.
395 fn evaluate_3(&self, ctx: &EvaluationContext) -> ConditionResult {
396 ctx.external.evaluate("is_highest_sequence_number_in_split")
397 }
398
399 /// [203] Wenn STS+7++E06 / Z39 / ZC6 / ZC7 / ZT6 / ZT7
400 fn evaluate_203(&self, ctx: &EvaluationContext) -> ConditionResult {
401 ctx.has_qualified_value(
402 "STS",
403 0,
404 "7",
405 2,
406 0,
407 &["E06", "Z39", "ZC6", "ZC7", "ZT6", "ZT7"],
408 )
409 }
410
411 /// [315] Es sind alle OBISKennzahlen gem. EDI@Energy Codeliste der OBIS-Kennzahlen und Medien für den deutschen Energiemarkt Kap. 4 anzugeben welche an der Marktlokation erforderlich sind, dabei muss der M...
412 /// EXTERNAL: Requires context from outside the message.
413 fn evaluate_315(&self, ctx: &EvaluationContext) -> ConditionResult {
414 ctx.external.evaluate("obis_kennzahlen_mindestumfang_valid")
415 }
416
417 /// [324] Es sind alle OBIS-Kennzahlen gem. EDI@Energy Codeliste der OBIS Kennzahlen Kap. 4. anzugeben welche an der Zähleinrichtung genutzt werden. Der Mindestumfang der OBIS-Kennzahlen ergibt sich aus den...
418 /// EXTERNAL: Requires context from outside the message.
419 fn evaluate_324(&self, ctx: &EvaluationContext) -> ConditionResult {
420 ctx.external
421 .evaluate("zaehler_obis_kennzahlen_mindestumfang_valid")
422 }
423
424 /// [328] Wenn IMD++Z36+Z12 (Identifikationslogik: Marktlokations-ID) vorhanden
425 fn evaluate_328(&self, ctx: &EvaluationContext) -> ConditionResult {
426 ctx.has_segment_matching("IMD", &[(1, 0, "Z36"), (2, 0, "Z12")])
427 }
428
429 /// [333] Wenn IMD+Z36+Z13 (Identifikationslogik: Alle Identifikationsdaten) vorhanden
430 fn evaluate_333(&self, ctx: &EvaluationContext) -> ConditionResult {
431 ctx.has_segment_matching("IMD", &[(1, 0, "Z36"), (2, 0, "Z13")])
432 }
433
434 /// [502] Hinweis: Ersatzbelieferung gibt es nur bei - Marktlokationen in der Niederdruckebene, die kein Haushaltskunde gem. EnWG sind und die nicht mehr der gesetzlichen Ersatzversorgung (drei Monate) un...
435 fn evaluate_502(&self, _ctx: &EvaluationContext) -> ConditionResult {
436 // Hinweis: Ersatzbelieferung gibt es nur bei Marktlokationen in der Niederdruckebene, die kein Haushaltskunde gem. EnWG sind und die nicht mehr der gesetzlichen Ersatzversorgung unterliegen, und für Marktlokationen in Mitteldruck. Grundlage ist die bilaterale Vereinbarung — informational note, always applies
437 ConditionResult::True
438 }
439
440 /// [504] Hinweis: Der Code Z22 wird auch in der Sparte Strom genutzt. Der Verweis auf den Einspeisevergütungsintervall ist in der Sparte Gas nicht relevant
441 fn evaluate_504(&self, _ctx: &EvaluationContext) -> ConditionResult {
442 // Hinweis: Code Z22 wird auch in der Sparte Strom genutzt. Der Verweis auf den Einspeisevergütungsintervall ist in der Sparte Gas nicht relevant — informational note, always applies
443 ConditionResult::True
444 }
445
446 /// [505] Hinweis: Übergangsversorgung gibt es nur bei Marktlokationen, die unter § 38a EnWG fallen. Grundlage ist eine bilaterale Vereinbarung
447 fn evaluate_505(&self, _ctx: &EvaluationContext) -> ConditionResult {
448 // Hinweis: Übergangsversorgung gibt es nur bei Marktlokationen, die unter § 38a EnWG fallen. Grundlage ist eine bilaterale Vereinbarung — informational note, always applies
449 ConditionResult::True
450 }
451
452 /// [511] Hinweis: Zu verwenden bei der Abmeldung der Übergangsversorgung
453 fn evaluate_511(&self, _ctx: &EvaluationContext) -> ConditionResult {
454 // Hinweis: Zu verwenden bei der Abmeldung der Übergangsversorgung — informational note, always applies
455 ConditionResult::True
456 }
457
458 /// [1] Wenn Aufteilung vorhanden
459 /// EXTERNAL: Requires context from outside the message.
460 fn evaluate_1(&self, ctx: &EvaluationContext) -> ConditionResult {
461 ctx.external.evaluate("message_splitting")
462 }
463
464 /// [4] Wenn MP-ID in SG2 NAD+MR (Nachrichtenempfänger) in der Rolle LF
465 /// EXTERNAL: Requires context from outside the message.
466 fn evaluate_4(&self, ctx: &EvaluationContext) -> ConditionResult {
467 ctx.external.evaluate("recipient_is_lf")
468 }
469
470 /// [5] Wenn MP-ID in SG2 NAD+MS (Nachrichtenabsender) in der Rolle LF
471 /// EXTERNAL: Requires context from outside the message.
472 fn evaluate_5(&self, ctx: &EvaluationContext) -> ConditionResult {
473 ctx.external.evaluate("sender_is_lf")
474 }
475
476 /// [7] Wenn SG4 STS+7++ZG9/ZH1/ZH2 (Transaktionsgrund: Aufhebung einer zukünftigen Zuordnung wegen Auszug des Kunden / -wegen Stilllegung / -wegen aufgehobenem Vertragsverhältnis) vorhanden
477 fn evaluate_7(&self, ctx: &EvaluationContext) -> ConditionResult {
478 ctx.has_qualified_value("STS", 0, "7", 2, 0, &["ZG9", "ZH1", "ZH2"])
479 }
480
481 /// [9] Wenn SG4 STS+7++ZE4 (Transaktionsgrund: Weggefallene Markt- bzw. Messlokation) nicht vorhanden
482 fn evaluate_9(&self, ctx: &EvaluationContext) -> ConditionResult {
483 match ctx.has_qualified_value("STS", 0, "7", 2, 0, &["ZE4"]) {
484 ConditionResult::True => ConditionResult::False,
485 ConditionResult::False | ConditionResult::Unknown => ConditionResult::True,
486 }
487 }
488
489 /// [10] Wenn SG4 STS+Z17 (Transaktionsgrund für befristete Anmeldung) vorhanden
490 fn evaluate_10(&self, ctx: &EvaluationContext) -> ConditionResult {
491 ctx.has_qualifier("STS", 0, "Z17")
492 }
493
494 /// [11] Wenn SG4 STS+7++ZG9/ZH1/ZH2 (Transaktionsgrund: Aufhebung einer zukünftigen Zuordnung wegen Auszug des Kunden / -wegen Stilllegung / -wegen aufgehobenem Vertragsverhältnis) nicht vorhanden
495 fn evaluate_11(&self, ctx: &EvaluationContext) -> ConditionResult {
496 match ctx.has_qualified_value("STS", 0, "7", 2, 0, &["ZG9", "ZH1", "ZH2"]) {
497 ConditionResult::True => ConditionResult::False,
498 ConditionResult::False | ConditionResult::Unknown => ConditionResult::True,
499 }
500 }
501
502 /// [12] Wenn SG4 DTM+471 (Ende zum nächstmöglichem Termin) nicht vorhanden
503 fn evaluate_12(&self, ctx: &EvaluationContext) -> ConditionResult {
504 ctx.lacks_qualifier("DTM", 0, "471")
505 }
506
507 /// [13] Wenn SG4 STS+E01++Z01 (Status der Antwort: Zustimmung mit Terminänderung) nicht vorhanden
508 fn evaluate_13(&self, ctx: &EvaluationContext) -> ConditionResult {
509 match ctx.has_qualified_value("STS", 0, "E01", 2, 0, &["Z01"]) {
510 ConditionResult::True => ConditionResult::False,
511 ConditionResult::False | ConditionResult::Unknown => ConditionResult::True,
512 }
513 }
514
515 /// [14] Wenn Datum bekannt
516 /// EXTERNAL: Requires context from outside the message.
517 fn evaluate_14(&self, ctx: &EvaluationContext) -> ConditionResult {
518 ctx.external.evaluate("date_known")
519 }
520
521 /// [15] Wenn SG4 STS+E01++Z34 (Status der Antwort: Ablehnung Mehrfachkündigung) vorhanden
522 fn evaluate_15(&self, ctx: &EvaluationContext) -> ConditionResult {
523 ctx.has_qualified_value("STS", 0, "E01", 2, 0, &["Z34"])
524 }
525
526 /// [16] Wenn SG4 STS+E01++Z12 (Status der Antwort: Ablehnung Vertragsbindung) vorhanden
527 fn evaluate_16(&self, ctx: &EvaluationContext) -> ConditionResult {
528 ctx.has_qualified_value("STS", 0, "E01", 2, 0, &["Z12"])
529 }
530
531 /// [17] Wenn bereits eine bestätigte Kündigung durch Kunde oder MP vorhanden
532 /// EXTERNAL: Requires context from outside the message.
533 fn evaluate_17(&self, ctx: &EvaluationContext) -> ConditionResult {
534 ctx.external.evaluate("confirmed_cancellation_present")
535 }
536
537 /// [18] Wenn SG4 DTM+93 (Ende zum) nicht vorhanden
538 fn evaluate_18(&self, ctx: &EvaluationContext) -> ConditionResult {
539 ctx.lacks_qualifier("DTM", 0, "93")
540 }
541
542 /// [19] Wenn SG8 SEQ+Z01 (Daten der Marktlokation) SG10 CCI+++ZC0 (Prognose auf Basis von Werten) vorhanden
543 fn evaluate_19(&self, ctx: &EvaluationContext) -> ConditionResult {
544 ctx.filtered_parent_child_has_qualifier(
545 &["SG4", "SG8"],
546 "SEQ",
547 0,
548 "Z01",
549 "SG10",
550 "CCI",
551 2,
552 "ZC0",
553 )
554 }
555
556 /// [24] Wenn SG6 DTM+Z21 (Termin der Netznutzungsabrechnung) vorhanden
557 fn evaluate_24(&self, ctx: &EvaluationContext) -> ConditionResult {
558 ctx.has_qualifier("DTM", 0, "Z21")
559 }
560
561 /// [25] Wenn der Meldepunkt im SG5 LOC+172 (Meldepunkt) DE3225 das Format der Marktlokations-ID hat
562 // REVIEW: Marktlokations-ID in German gas market is a numeric (all-digit) identifier. LOC+172 has elements[0][0]='172', elements[1][0]=DE3225. Checks if value consists entirely of ASCII digits. Returns Unknown if no LOC+172 exists. (medium confidence)
563 fn evaluate_25(&self, ctx: &EvaluationContext) -> ConditionResult {
564 let segs = ctx.find_segments_with_qualifier("LOC", 0, "172");
565 if segs.is_empty() {
566 return ConditionResult::Unknown;
567 }
568 for seg in &segs {
569 if let Some(val) = seg.elements.get(1).and_then(|e| e.first()) {
570 if !val.is_empty() && val.chars().all(|c| c.is_ascii_digit()) {
571 return ConditionResult::True;
572 }
573 }
574 }
575 ConditionResult::False
576 }
577
578 /// [26] Wenn der Meldepunkt im SG5 LOC+172 (Meldepunkt) DE3225 das Format der Zählpunktbezeichnung hat
579 // REVIEW: Zählpunktbezeichnung format contains non-digit characters (typically alphanumeric string). Negates condition 25's all-digit check. Returns True if DE3225 of LOC+172 is non-empty and contains at least one non-digit character. (medium confidence)
580 fn evaluate_26(&self, ctx: &EvaluationContext) -> ConditionResult {
581 let segs = ctx.find_segments_with_qualifier("LOC", 0, "172");
582 if segs.is_empty() {
583 return ConditionResult::Unknown;
584 }
585 for seg in &segs {
586 if let Some(val) = seg.elements.get(1).and_then(|e| e.first()) {
587 if !val.is_empty() && !val.chars().all(|c| c.is_ascii_digit()) {
588 return ConditionResult::True;
589 }
590 }
591 }
592 ConditionResult::False
593 }
594
595 /// [28] Wenn SG4 DTM+93 (Ende zum) vorhanden
596 fn evaluate_28(&self, ctx: &EvaluationContext) -> ConditionResult {
597 ctx.has_qualifier("DTM", 0, "93")
598 }
599
600 /// [29] Wenn eine Bilanzierung stattfindet
601 /// EXTERNAL: Requires context from outside the message.
602 fn evaluate_29(&self, ctx: &EvaluationContext) -> ConditionResult {
603 ctx.external.evaluate("balancing_takes_place")
604 }
605
606 /// [32] Wenn BGM+E03 (Änderungsmeldungen) vorhanden
607 fn evaluate_32(&self, ctx: &EvaluationContext) -> ConditionResult {
608 ctx.has_qualifier("BGM", 0, "E03")
609 }
610
611 /// [33] Wenn in Abmeldung ein Bilanzierungsende vorhanden
612 // REVIEW: Wenn in Abmeldung ein Bilanzierungsende vorhanden: BGM+E02 identifies the message as Abmeldung (de-registration), DTM+159 is Bilanzierungsende. Both must coexist. (medium confidence)
613 fn evaluate_33(&self, ctx: &EvaluationContext) -> ConditionResult {
614 let has_abmeldung = !ctx.find_segments_with_qualifier("BGM", 0, "E02").is_empty();
615 let has_bilanzierungsende = !ctx.find_segments_with_qualifier("DTM", 0, "159").is_empty();
616 ConditionResult::from(has_abmeldung && has_bilanzierungsende)
617 }
618
619 /// [35] Wenn das DE2380 von SG4 DTM+Z01 (Kündigungsfrist des Vertrags) an vierter Stelle T (Termin) enthält
620 fn evaluate_35(&self, ctx: &EvaluationContext) -> ConditionResult {
621 let segs = ctx.find_segments_with_qualifier("DTM", 0, "Z01");
622 match segs.first() {
623 Some(dtm) => {
624 match dtm
625 .elements
626 .first()
627 .and_then(|e| e.get(1))
628 .map(|s| s.as_str())
629 {
630 Some(value) => match value.chars().nth(3) {
631 Some('T') => ConditionResult::True,
632 Some(_) => ConditionResult::False,
633 None => ConditionResult::False, // segment absent → condition not applicable
634 },
635 None => ConditionResult::False, // segment absent → condition not applicable
636 }
637 }
638 None => ConditionResult::False, // segment absent → condition not applicable
639 }
640 }
641
642 /// [36] Wenn SG4 STS+E01++ZC5 (Status der Antwort: Ablehnung andere Anmeldung in Bearbeitung) vorhanden
643 fn evaluate_36(&self, ctx: &EvaluationContext) -> ConditionResult {
644 ctx.has_qualified_value("STS", 0, "E01", 2, 0, &["ZC5"])
645 }
646
647 /// [37] Wenn Anmeldung/ Änderung befristet
648 fn evaluate_37(&self, ctx: &EvaluationContext) -> ConditionResult {
649 // Same check as [10]: STS+Z17 indicates befristete Anmeldung in Gas
650 ctx.has_qualifier("STS", 0, "Z17")
651 }
652
653 /// [39] Wenn LF beabsichtigt Zählerstand zu übermitteln
654 /// EXTERNAL: Requires context from outside the message.
655 fn evaluate_39(&self, ctx: &EvaluationContext) -> ConditionResult {
656 ctx.external
657 .evaluate("lf_intends_to_transmit_meter_reading")
658 }
659
660 /// [46] Wenn in SG8 SEQ+Z35 ein SG10 CCI+Z12 (Lastprofil) CAV (Lastprofil) DE3055 der Wert 293 enthalten ist
661 // REVIEW: In SG8 with SEQ+Z35 (Lastprofildaten), check SG10 children for CCI+Z12 (Lastprofil, elements[0][0]='Z12') AND a Klimazone CCI with DE3055=293 at elements[2][2] (responsible agency code = BDEW/GS1-DE). Uses collect_group_values to find Z35 SG8 instances by index, then navigator for SG10 child traversal. (medium confidence)
662 fn evaluate_46(&self, ctx: &EvaluationContext) -> ConditionResult {
663 let seq_values = ctx.collect_group_values("SEQ", 0, 0, &["SG4", "SG8"]);
664 let z35_instances: Vec<usize> = seq_values
665 .iter()
666 .filter(|(_, v)| v == "Z35")
667 .map(|(i, _)| *i)
668 .collect();
669 if z35_instances.is_empty() {
670 return ConditionResult::False;
671 }
672 let nav = match ctx.navigator() {
673 Some(n) => n,
674 None => return ConditionResult::Unknown,
675 };
676 for i in z35_instances {
677 let sg10_count = nav.child_group_instance_count(&["SG4", "SG8"], i, "SG10");
678 for j in 0..sg10_count {
679 let ccis = nav.find_segments_in_child_group("CCI", &["SG4", "SG8"], i, "SG10", j);
680 let has_z12 = ccis.iter().any(|s| {
681 s.elements
682 .first()
683 .and_then(|e| e.first())
684 .is_some_and(|v| v == "Z12")
685 });
686 if !has_z12 {
687 continue;
688 }
689 // Check Klimazone CCI (Z99/ZA0) for DE3055=293 at elements[2][2]
690 let has_293 = ccis.iter().any(|s| {
691 s.elements
692 .get(2)
693 .and_then(|e| e.get(2))
694 .is_some_and(|v| v == "293")
695 });
696 if has_293 {
697 return ConditionResult::True;
698 }
699 }
700 }
701 ConditionResult::False
702 }
703
704 /// [47] Wenn in SG8 SEQ+Z35 ein SG10 CCI+Z12 (Lastprofil) CAV (Lastprofil) DE3055 der Wert 293 nicht enthalten ist
705 // REVIEW: Logical negation of condition 46: CCI+Z12 Klimazone DE3055=293 NOT present in SG10 under SG8+Z35. Propagates Unknown to maintain three-valued semantics. (medium confidence)
706 fn evaluate_47(&self, ctx: &EvaluationContext) -> ConditionResult {
707 match self.evaluate_46(ctx) {
708 ConditionResult::True => ConditionResult::False,
709 ConditionResult::False => ConditionResult::True,
710 ConditionResult::Unknown => ConditionResult::Unknown,
711 }
712 }
713
714 /// [48] Wenn in dieser SG4 das STS+E01++E14 (Status der Antwort: Ablehnung Sonstiges) vorhanden
715 fn evaluate_48(&self, ctx: &EvaluationContext) -> ConditionResult {
716 // HAND-EDITED: "in dieser SG4" — the enclosing SG4 only, when the scope
717 // reaches one; the message as before otherwise. As
718 // `has_qualified_value`: Unknown without any STS+E01.
719 if let Some(scope) = ctx.enclosing_scope("SG4") {
720 let e01: Vec<_> = ctx
721 .find_segments_at(scope, "STS")
722 .into_iter()
723 .filter(|s| s.get_element(0) == "E01")
724 .collect();
725 if e01.is_empty() {
726 return ConditionResult::Unknown;
727 }
728 return ConditionResult::from(e01.iter().any(|s| s.get_component(2, 0) == "E14"));
729 }
730 ctx.has_qualified_value("STS", 0, "E01", 2, 0, &["E14"])
731 }
732
733 /// [51] Bei rückwirkendem Lieferende/Lieferbeginn
734 /// EXTERNAL: Requires context from outside the message.
735 fn evaluate_51(&self, ctx: &EvaluationContext) -> ConditionResult {
736 ctx.external.evaluate("retroactive_delivery_change")
737 }
738
739 /// [58] Wenn in diesem CCI das DE3055 mit dem Code 293 vorhanden
740 // REVIEW: DE3055 (Verantwortliche Stelle für die Codepflege) appears at CCI elements[2][2] in CCI — Klimazone/Temperaturmessstelle. Checks any CCI in the message has that code. 'In diesem CCI' implies context-local check; falls back to message-wide. (medium confidence)
741 fn evaluate_58(&self, ctx: &EvaluationContext) -> ConditionResult {
742 let ccis = ctx.find_segments("CCI");
743 ConditionResult::from(ccis.iter().any(|s| {
744 s.elements
745 .get(2)
746 .and_then(|e| e.get(2))
747 .is_some_and(|v| v == "293")
748 }))
749 }
750
751 /// [64] Wenn SG4 DTM+158 (Bilanzierungsbeginn) vorhanden
752 fn evaluate_64(&self, ctx: &EvaluationContext) -> ConditionResult {
753 ctx.has_qualifier("DTM", 0, "158")
754 }
755
756 /// [65] Wenn Marktgebietsüber-lappung besteht, sind alle Bilanzkreise des LF zu melden in denen freie Kapazitäten beim NB bestehen
757 /// EXTERNAL: Requires context from outside the message.
758 fn evaluate_65(&self, ctx: &EvaluationContext) -> ConditionResult {
759 ctx.external.evaluate("market_area_overlap_exists")
760 }
761
762 /// [66] Wenn SG10 CCI+Z19 (Bilanzkreis) im Vorgang mehr als einmal vorhanden
763 fn evaluate_66(&self, ctx: &EvaluationContext) -> ConditionResult {
764 let count = ctx.find_segments_with_qualifier("CCI", 0, "Z19").len();
765 ConditionResult::from(count > 1)
766 }
767
768 /// [68] Wenn SG10 CCI+Z19 (Bilanzkreis) im Vorgang mehr als zweimal vorhanden
769 fn evaluate_68(&self, ctx: &EvaluationContext) -> ConditionResult {
770 let count = ctx.find_segments_with_qualifier("CCI", 0, "Z19").len();
771 ConditionResult::from(count > 2)
772 }
773
774 /// [69] Wenn SG10 CCI+Z19 (Bilanzkreis) im Vorgang mehr als dreimal vorhanden
775 fn evaluate_69(&self, ctx: &EvaluationContext) -> ConditionResult {
776 let count = ctx.find_segments_with_qualifier("CCI", 0, "Z19").len();
777 ConditionResult::from(count > 3)
778 }
779
780 /// [70] Wenn SG10 CCI+Z19 (Bilanzkreis) im Vorgang fünfmal vorhanden
781 fn evaluate_70(&self, ctx: &EvaluationContext) -> ConditionResult {
782 let count = ctx.find_segments_with_qualifier("CCI", 0, "Z19").len();
783 ConditionResult::from(count == 5)
784 }
785
786 /// [77] Wenn SG8 SEQ+Z03 (Zähleinrichtungsdaten) CAV+Z30 (Identifikation/Nummer des Gerätes) nicht vorhanden
787 fn evaluate_77(&self, ctx: &EvaluationContext) -> ConditionResult {
788 ctx.any_group_has_qualifier_without("SEQ", 0, "Z03", "CAV", 0, "Z30", &["SG4", "SG8"])
789 }
790
791 /// [78] Wenn SG4 STS+7++E02 (Transaktionsgrund: Einzug in Neuanlage) nicht vorhanden
792 fn evaluate_78(&self, ctx: &EvaluationContext) -> ConditionResult {
793 let result = ctx.has_qualified_value("STS", 0, "7", 2, 0, &["E02"]);
794 match result {
795 ConditionResult::True => ConditionResult::False,
796 ConditionResult::False => ConditionResult::True,
797 ConditionResult::Unknown => ConditionResult::Unknown,
798 }
799 }
800
801 /// [81] Wenn SG4 FTX+ABO+Z05 (Beschreibung der Abweichung zur übermittelten Liste: Änderung vorhanden) vorhanden
802 fn evaluate_81(&self, ctx: &EvaluationContext) -> ConditionResult {
803 ctx.has_qualified_value("FTX", 0, "ABO", 2, 0, &["Z05"])
804 }
805
806 /// [84] Wenn SG4 STS+E01++Z35 (Status der Antwort: Ablehnung der Abmeldeanfrage) vorhanden
807 fn evaluate_84(&self, ctx: &EvaluationContext) -> ConditionResult {
808 ctx.has_qualified_value("STS", 0, "E01", 2, 0, &["Z35"])
809 }
810
811 /// [92] Wenn Wert innerhalb SG bzw. Segment geändert wird
812 /// EXTERNAL: Requires context from outside the message.
813 // REVIEW: 'Wenn Wert innerhalb SG bzw. Segment geändert wird' — whether a value was changed compared to a prior state cannot be determined from the EDIFACT message alone; requires external business context comparing current vs previous transmission. (medium confidence)
814 fn evaluate_92(&self, ctx: &EvaluationContext) -> ConditionResult {
815 ctx.external.evaluate("value_changed_in_segment")
816 }
817
818 /// [98] Wenn MP-ID in SG2 NAD+MS (Nachrichtenabsender) in der Rolle NB
819 /// EXTERNAL: Requires context from outside the message.
820 // REVIEW: 'Wenn MP-ID in SG2 NAD+MS in der Rolle NB' — while we can confirm NAD+MS exists in the message, determining whether that market participant ID is registered in the role of Netzbetreiber (NB) requires an external role/master-data lookup. Cannot be derived from the EDIFACT message content alone. (medium confidence)
821 fn evaluate_98(&self, ctx: &EvaluationContext) -> ConditionResult {
822 ctx.external.evaluate("sender_is_nb")
823 }
824
825 /// [106] Wenn in dieser SG8 SEQ+Z01 SG10 CCI+++ZA6 (Prognosegrundlage der Marktlokation: Prognose auf Basis von Profilen) vorhanden
826 fn evaluate_106(&self, ctx: &EvaluationContext) -> ConditionResult {
827 // HAND-EDITED: "in dieser/derselben SG8" — the enclosing SG8 only, when the
828 // scope reaches one; the message as before otherwise.
829 if let Some(scope) = ctx.enclosing_scope("SG8") {
830 return ConditionResult::from(
831 ctx.find_segments_at(scope, "SEQ")
832 .iter()
833 .any(|s| matches!(s.get_element(0), "Z01"))
834 && ctx
835 .find_segments_at(scope, "CCI")
836 .iter()
837 .any(|s| s.get_component(2, 0) == "ZA6"),
838 );
839 }
840 ctx.filtered_parent_child_has_qualifier(
841 &["SG4", "SG8"],
842 "SEQ",
843 0,
844 "Z01",
845 "SG10",
846 "CCI",
847 2,
848 "ZA6",
849 )
850 }
851
852 /// [108] Wenn Kundenwertverfahren (z. B. TU München)
853 /// EXTERNAL: Requires context from outside the message.
854 // REVIEW: Kundenwertverfahren (e.g., TU München) is a specific billing methodology determined by contract terms, not derivable from the EDIFACT message content itself. (medium confidence)
855 fn evaluate_108(&self, ctx: &EvaluationContext) -> ConditionResult {
856 ctx.external.evaluate("kundenwertverfahren")
857 }
858
859 /// [123] Wenn noch mindestens eine weitere SG8 SEQ+Z20 (OBIS-Daten der Zähleinrichtung / Mengenumwerter) mit dem SG8 RFF+MG / Z11 (Gerätenummer des Zählers / Mengenumwerters) auf die gleiche Identifikati...
860 // REVIEW: Collects device IDs (via RFF+MG or RFF+Z11) from all SG8 instances that have SEQ+Z20. Returns True if any device ID appears in at least two such instances, indicating at least one further SG8 references the same device. Requires navigator for proper group-scoped traversal. (medium confidence)
861 fn evaluate_123(&self, ctx: &EvaluationContext) -> ConditionResult {
862 let nav = match ctx.navigator() {
863 Some(n) => n,
864 None => {
865 let seqs = ctx.find_segments_with_qualifier("SEQ", 0, "Z20");
866 if seqs.len() < 2 {
867 return ConditionResult::False;
868 }
869 return ConditionResult::Unknown;
870 }
871 };
872 let sg8_count = nav.group_instance_count(&["SG4", "SG8"]);
873 let mut device_ids: Vec<String> = Vec::new();
874 for i in 0..sg8_count {
875 let seqs = nav.find_segments_in_group("SEQ", &["SG4", "SG8"], i);
876 let has_z20 = seqs.iter().any(|s| {
877 s.elements
878 .first()
879 .and_then(|e| e.first())
880 .is_some_and(|v| v == "Z20")
881 });
882 if !has_z20 {
883 continue;
884 }
885 let rffs = nav.find_segments_in_group("RFF", &["SG4", "SG8"], i);
886 for rff in &rffs {
887 let qual = rff
888 .elements
889 .first()
890 .and_then(|e| e.first())
891 .map(|s| s.as_str());
892 if matches!(qual, Some("MG") | Some("Z11")) {
893 if let Some(id) = rff.elements.first().and_then(|e| e.get(1)) {
894 if !id.is_empty() {
895 device_ids.push(id.clone());
896 }
897 }
898 }
899 }
900 }
901 for i in 0..device_ids.len() {
902 for j in (i + 1)..device_ids.len() {
903 if device_ids[i] == device_ids[j] {
904 return ConditionResult::True;
905 }
906 }
907 }
908 ConditionResult::False
909 }
910
911 /// [127] Hat der Lieferant auf Grund seines Vertrags Kenntnis, dass der Kunde keine hohe KA hat so muss er dies dem NB mitteilen
912 /// EXTERNAL: Requires context from outside the message.
913 // REVIEW: Whether the supplier knows from their contract that the customer has no high KA (Kapazitätsanteil) is contract-based knowledge external to the EDIFACT message. Cannot be determined from segment data alone. (medium confidence)
914 fn evaluate_127(&self, ctx: &EvaluationContext) -> ConditionResult {
915 ctx.external.evaluate("supplier_knows_no_high_ka")
916 }
917
918 /// [128] Wenn SG10 CAV+TAS/ TKS/ SAS/ KAS vorhanden
919 fn evaluate_128(&self, ctx: &EvaluationContext) -> ConditionResult {
920 ctx.any_group_has_any_qualifier(
921 "CAV",
922 0,
923 &["TAS", "TKS", "SAS", "KAS"],
924 &["SG4", "SG8", "SG10"],
925 )
926 }
927
928 /// [129] Hat der Lieferant auf Grund seines Vertrags Kenntnis über die Höhe der Sonder-KA, so muss er diesen dem NB mitteilen
929 /// EXTERNAL: Requires context from outside the message.
930 // REVIEW: Whether the supplier has contract knowledge about the amount of a special KA (Sonder-Kapazitätsanteil) is contract-based knowledge. Cannot be derived from the EDIFACT message. (medium confidence)
931 fn evaluate_129(&self, ctx: &EvaluationContext) -> ConditionResult {
932 ctx.external.evaluate("supplier_knows_special_ka_amount")
933 }
934
935 /// [130] Wenn an Messlokation vorhanden
936 // REVIEW: 'Wenn an Messlokation vorhanden' is interpreted as: a Messlokation section exists in the message, indicated by SEQ+Z18 (Daten der Messlokation) in SG8. Returns True when such a section is present. (medium confidence)
937 fn evaluate_130(&self, ctx: &EvaluationContext) -> ConditionResult {
938 ctx.has_qualifier("SEQ", 0, "Z18")
939 }
940
941 /// [133] Wenn an der übermittelten Marktlokation / Messlokation vorhanden
942 /// EXTERNAL: Requires context from outside the message.
943 // REVIEW: 'Wenn an der übermittelten Marktlokation / Messlokation vorhanden' — whether a specific data element exists at the transmitted market or metering location is a business/registry lookup that cannot be determined from the EDIFACT message content alone. Marked external. (medium confidence)
944 fn evaluate_133(&self, ctx: &EvaluationContext) -> ConditionResult {
945 ctx.external.evaluate("at_marktlokation_or_messlokation")
946 }
947
948 /// [137] Nicht bei Neuanlage
949 // REVIEW: 'Nicht bei Neuanlage' — the condition is True when the transaction reason is NOT E02 (Neubau / new installation). Finds STS with elements[0][0]="7" (Transaktionsgrund), checks elements[2][0] for E02, and negates the result. (medium confidence)
950 fn evaluate_137(&self, ctx: &EvaluationContext) -> ConditionResult {
951 match ctx.has_qualified_value("STS", 0, "7", 2, 0, &["E02"]) {
952 ConditionResult::True => ConditionResult::False,
953 ConditionResult::False => ConditionResult::True,
954 ConditionResult::Unknown => ConditionResult::Unknown,
955 }
956 }
957
958 /// [138] Wenn SG5 LOC+172 (Meldepunkt) nicht vorhanden
959 fn evaluate_138(&self, ctx: &EvaluationContext) -> ConditionResult {
960 ctx.lacks_qualifier("LOC", 0, "172")
961 }
962
963 /// [147] Wenn in Anfrage vorhanden
964 /// EXTERNAL: Requires context from outside the message.
965 // REVIEW: 'Wenn in Anfrage vorhanden' — whether something is present in the original inquiry/request message is a cross-message business context that cannot be determined from the current EDIFACT message alone. Marked external. (medium confidence)
966 fn evaluate_147(&self, ctx: &EvaluationContext) -> ConditionResult {
967 ctx.external.evaluate("present_in_request")
968 }
969
970 /// [165] Wenn bekannt
971 /// EXTERNAL: Requires context from outside the message.
972 fn evaluate_165(&self, ctx: &EvaluationContext) -> ConditionResult {
973 ctx.external.evaluate("date_known")
974 }
975
976 /// [166] Wenn vorhanden
977 /// EXTERNAL: Requires context from outside the message.
978 // REVIEW: 'Wenn vorhanden' — generic 'if present/available' without a specific segment reference. When used as a standalone condition this refers to business data availability that cannot be determined from the EDIFACT message structure alone. Marked external. (medium confidence)
979 fn evaluate_166(&self, ctx: &EvaluationContext) -> ConditionResult {
980 ctx.external.evaluate("data_available")
981 }
982
983 /// [200] Wenn BGM+Z26 (Vorläufige Meldung zur Marktraumumstellung) vorhanden
984 fn evaluate_200(&self, ctx: &EvaluationContext) -> ConditionResult {
985 ctx.has_qualifier("BGM", 0, "Z26")
986 }
987
988 /// [202] Wenn SG4 STS+E01+ZG2 (Status der Antwort: Gültiges Ergebnis nach der Datenprüfung) vorhanden
989 fn evaluate_202(&self, ctx: &EvaluationContext) -> ConditionResult {
990 ctx.has_qualified_value("STS", 0, "E01", 1, 0, &["ZG2"])
991 }
992
993 /// [205] Wenn SG9 QTY+Y02 (TUM Kundenwert) nicht vorhanden
994 fn evaluate_205(&self, ctx: &EvaluationContext) -> ConditionResult {
995 ctx.lacks_qualifier("QTY", 0, "Y02")
996 }
997
998 /// [209] Wenn im selben Segment im DE2379 der Code 303 vorhanden ist
999 fn evaluate_209(&self, ctx: &EvaluationContext) -> ConditionResult {
1000 ConditionResult::from(ctx.self_segment_value_equals("DTM", 0, 2, "303"))
1001 }
1002
1003 /// [212] Wenn im selben SG12 NAD DE3124 nicht vorhanden
1004 // REVIEW: Checks if any NAD in SG12 has DE3124 (C058 first component, elements[2][0]) absent or empty. Without group-scoped navigation, falls back to message-wide NAD check. (medium confidence)
1005 fn evaluate_212(&self, ctx: &EvaluationContext) -> ConditionResult {
1006 let nads = ctx.find_segments("NAD");
1007 ConditionResult::from(nads.iter().any(|s| {
1008 s.elements
1009 .get(2)
1010 .map(|e| e.first().map(|v| v.is_empty()).unwrap_or(true))
1011 .unwrap_or(true)
1012 }))
1013 }
1014
1015 /// [213] Wenn SG12 NAD+Z09 (Kunde des Lieferanten) vorhanden
1016 fn evaluate_213(&self, ctx: &EvaluationContext) -> ConditionResult {
1017 ctx.has_qualifier("NAD", 0, "Z09")
1018 }
1019
1020 /// [216] Wenn CCI+++Z88 (Netznutzung) CAV+Z74:::Z08 (Netznutzungsvertrag: Direkter Vertrag zwischen Kunden und NB) vorhanden
1021 // REVIEW: CCI+++Z88 means elements[2][0]=='Z88' (Netznutzung). CAV+Z74:::Z08 means elements[0][0]=='Z74' and elements[0][3]=='Z08' (Direkter Vertrag). Uses parent-child group navigation to check co-occurrence within the same SG10 instance. (medium confidence)
1022 fn evaluate_216(&self, ctx: &EvaluationContext) -> ConditionResult {
1023 let nav = match ctx.navigator() {
1024 Some(n) => n,
1025 None => {
1026 let cavs = ctx.find_segments("CAV");
1027 return ConditionResult::from(cavs.iter().any(|s| {
1028 let e0 = s.elements.first();
1029 e0.and_then(|e| e.first()).is_some_and(|v| v == "Z74")
1030 && e0.and_then(|e| e.get(3)).is_some_and(|v| v == "Z08")
1031 }));
1032 }
1033 };
1034 let sg8_count = nav.group_instance_count(&["SG4", "SG8"]);
1035 for i in 0..sg8_count {
1036 let sg10_count = nav.child_group_instance_count(&["SG4", "SG8"], i, "SG10");
1037 for j in 0..sg10_count {
1038 let ccis = nav.find_segments_in_child_group("CCI", &["SG4", "SG8"], i, "SG10", j);
1039 let has_cci_z88 = ccis.iter().any(|s| {
1040 s.elements
1041 .get(2)
1042 .and_then(|e| e.first())
1043 .is_some_and(|v| v == "Z88")
1044 });
1045 if has_cci_z88 {
1046 let cavs =
1047 nav.find_segments_in_child_group("CAV", &["SG4", "SG8"], i, "SG10", j);
1048 if cavs.iter().any(|s| {
1049 let e0 = s.elements.first();
1050 e0.and_then(|e| e.first()).is_some_and(|v| v == "Z74")
1051 && e0.and_then(|e| e.get(3)).is_some_and(|v| v == "Z08")
1052 }) {
1053 return ConditionResult::True;
1054 }
1055 }
1056 }
1057 }
1058 ConditionResult::False
1059 }
1060
1061 /// [219] Wenn an Marktlokation vorhanden
1062 /// EXTERNAL: Requires context from outside the message.
1063 // REVIEW: 'Wenn an Marktlokation vorhanden' — whether specific data exists at the market location is a registry/master-data lookup that cannot be derived from the EDIFACT message content. Marked external. (medium confidence)
1064 fn evaluate_219(&self, ctx: &EvaluationContext) -> ConditionResult {
1065 ctx.external.evaluate("at_marktlokation")
1066 }
1067
1068 /// [230] Sich ergebendes Datum/ bzw. Endedatum des Turnuszeitraums aus DTM+Z21 (Termin der Netznutzungsabrechnung) und DTM+Z09 (Nächste Netznutzungsabrechnung) muss >= DTM+92 (Beginn zum) sein
1069 // REVIEW: Compares the later of DTM+Z21 and DTM+Z09 (end of Turnuszeitraum) against DTM+92 (start date). Date formats differ across the three DTM qualifiers (Z21=CCYYMM/format 106, Z09=format 602, DTM+92=CCYYMMDDHHMM/format 303), so comparison is normalized to the CCYYMM prefix (first 6 chars). The exact definition of 'sich ergebendes Datum' from Z21+Z09 introduces some ambiguity — using max(Z21,Z09) as the best approximation. (medium confidence)
1070 fn evaluate_230(&self, ctx: &EvaluationContext) -> ConditionResult {
1071 {
1072 // DTM+Z21 (Termin der Netznutzungsabrechnung): elements[0][1], format 106/104
1073 let z21_val = ctx
1074 .find_segments_with_qualifier("DTM", 0, "Z21")
1075 .into_iter()
1076 .find_map(|s| s.elements.first().and_then(|e| e.get(1)).cloned())
1077 .unwrap_or_default();
1078 // DTM+Z09 (Nächste Netznutzungsabrechnung): elements[0][1], format 602
1079 let z09_val = ctx
1080 .find_segments_with_qualifier("DTM", 0, "Z09")
1081 .into_iter()
1082 .find_map(|s| s.elements.first().and_then(|e| e.get(1)).cloned())
1083 .unwrap_or_default();
1084 // DTM+92 (Beginn zum): elements[0][1], format 303 (CCYYMMDDHHMM)
1085 let dtm92_val = match ctx
1086 .find_segments_with_qualifier("DTM", 0, "92")
1087 .into_iter()
1088 .find_map(|s| s.elements.first().and_then(|e| e.get(1)).cloned())
1089 {
1090 Some(v) if !v.is_empty() => v,
1091 _ => return ConditionResult::Unknown,
1092 };
1093 // Use the later of Z21 and Z09 as the end date of the Turnuszeitraum
1094 // Note: formats differ (Z21=106/104, Z09=602, DTM+92=303) — use first 6 chars (CCYYMM) for comparison
1095 let end_date = match (z21_val.is_empty(), z09_val.is_empty()) {
1096 (false, false) => {
1097 if z21_val >= z09_val {
1098 z21_val
1099 } else {
1100 z09_val
1101 }
1102 }
1103 (false, true) => z21_val,
1104 (true, false) => z09_val,
1105 (true, true) => return ConditionResult::Unknown,
1106 };
1107 // Compare first 6 chars (CCYYMM) — both reference dates have at least CCYYMM
1108 let end_ym = &end_date[..end_date.len().min(6)];
1109 let begin_ym = &dtm92_val[..dtm92_val.len().min(6)];
1110 if end_ym.len() < 6 || begin_ym.len() < 6 {
1111 return ConditionResult::Unknown;
1112 }
1113 ConditionResult::from(end_ym >= begin_ym)
1114 }
1115 }
1116
1117 /// [241] Wenn MP-ID in SG2 NAD+MR (Nachrichtenempfänger) in der Rolle MSB
1118 /// EXTERNAL: Requires context from outside the message.
1119 fn evaluate_241(&self, ctx: &EvaluationContext) -> ConditionResult {
1120 ctx.external.evaluate("recipient_is_msb")
1121 }
1122
1123 /// [249] Innerhalb eines SG4 IDE müssen alle DE1131 der SG4 STS+E01 den identischen Wert enthalten
1124 // REVIEW: Checks that all STS+E01 segments have identical DE1131 values (elements[2][1] — Codeliste, Code within C556). Returns True when all values match the first occurrence. Message-wide fallback without per-SG4 grouping. (medium confidence)
1125 fn evaluate_249(&self, ctx: &EvaluationContext) -> ConditionResult {
1126 let sts_segs = ctx.find_segments("STS");
1127 let sts_e01: Vec<_> = sts_segs
1128 .iter()
1129 .filter(|s| {
1130 s.elements
1131 .first()
1132 .and_then(|e| e.first())
1133 .is_some_and(|v| v == "E01")
1134 })
1135 .collect();
1136 if sts_e01.is_empty() {
1137 return ConditionResult::Unknown;
1138 }
1139 let first_val = sts_e01
1140 .first()
1141 .and_then(|s| s.elements.get(2))
1142 .and_then(|e| e.get(1))
1143 .map(|v| v.as_str())
1144 .unwrap_or("");
1145 ConditionResult::from(sts_e01.iter().all(|s| {
1146 s.elements
1147 .get(2)
1148 .and_then(|e| e.get(1))
1149 .map(|v| v.as_str())
1150 .unwrap_or("")
1151 == first_val
1152 }))
1153 }
1154
1155 /// [252] Wenn DE0068 vorhanden
1156 // REVIEW: DE0068 is the Common Access Reference in UNH (elements[2][0]). Checks if it is present and non-empty in any UNH segment. (medium confidence)
1157 fn evaluate_252(&self, ctx: &EvaluationContext) -> ConditionResult {
1158 let unh_segs = ctx.find_segments("UNH");
1159 ConditionResult::from(unh_segs.iter().any(|s| {
1160 s.elements
1161 .get(2)
1162 .and_then(|e| e.first())
1163 .is_some_and(|v| !v.is_empty())
1164 }))
1165 }
1166
1167 /// [257] Wenn in derselben SG8 SEQ+Z02 (OBIS-Daten der Marktlokation) das PIA+5+7-0?:33.86.0 vorhanden
1168 fn evaluate_257(&self, ctx: &EvaluationContext) -> ConditionResult {
1169 // HAND-EDITED: "in dieser/derselben SG8" — the enclosing SG8 only, when the
1170 // scope reaches one; the message as before otherwise.
1171 if let Some(scope) = ctx.enclosing_scope("SG8") {
1172 return ConditionResult::from(
1173 ctx.find_segments_at(scope, "SEQ")
1174 .iter()
1175 .any(|s| matches!(s.get_element(0), "Z02"))
1176 && ctx
1177 .find_segments_at(scope, "PIA")
1178 .iter()
1179 .any(|s| s.get_component(1, 0) == "7-0:33.86.0"),
1180 );
1181 }
1182 ctx.any_group_has_co_occurrence(
1183 "SEQ",
1184 0,
1185 &["Z02"],
1186 "PIA",
1187 1,
1188 0,
1189 &["7-0:33.86.0"],
1190 &["SG4", "SG8"],
1191 )
1192 }
1193
1194 /// [268] Wenn der Code im DE3207 in der "EDI@Energy Codeliste der europäischen Ländercodes" in der Spalte "PLZ vorhanden" ein "X" aufgeführt ist
1195 /// EXTERNAL: Requires context from outside the message.
1196 fn evaluate_268(&self, ctx: &EvaluationContext) -> ConditionResult {
1197 ctx.external.evaluate("country_has_postal_code_requirement")
1198 }
1199
1200 /// [274] Wenn in derselben SG8 SEQ+Z20 (OBIS-Daten der Zähleinrichtung / Mengenumwerter) das PIA+5+7-b?:3.0.0 / 7-b?:6.0.0 / 7-b?:3.1.0 / 7-b?:6.1.0 / 7-b?:3.2.0 / 7-b?:6.2.0 / 7-b?:13.2.0 / 7-b?:16.2.0 / ...
1201 // REVIEW: Checks co-occurrence of SEQ+Z20 and PIA+5 in same SG8, then verifies the OBIS code (elements[1][0]) matches pattern '7-b:X.X.X' where b is variable (any subgroup) and suffix is one of the 16 listed measurement quantities. EDIFACT ?. decoded as literal colon. OBIS suffix match is message-wide as a secondary filter. (medium confidence)
1202 fn evaluate_274(&self, ctx: &EvaluationContext) -> ConditionResult {
1203 let obis_suffixes = [
1204 ":3.0.0", ":6.0.0", ":3.1.0", ":6.1.0", ":3.2.0", ":6.2.0", ":13.2.0", ":16.2.0",
1205 ":1.0.0", ":2.0.0", ":4.0.0", ":5.0.0", ":11.2.0", ":12.2.0", ":14.2.0", ":15.2.0",
1206 ];
1207 // HAND-EDITED: "in dieser/derselben SG8" — the enclosing SG8 only, when the
1208 // scope reaches one; the message as before otherwise.
1209 if let Some(scope) = ctx.enclosing_scope("SG8") {
1210 return ConditionResult::from(
1211 ctx.find_segments_at(scope, "SEQ")
1212 .iter()
1213 .any(|s| matches!(s.get_element(0), "Z20"))
1214 && ctx.find_segments_at(scope, "PIA").iter().any(|s| {
1215 let v = s.get_component(1, 0);
1216 s.get_element(0) == "5"
1217 && v.starts_with("7-")
1218 && obis_suffixes.iter().any(|suf| v.ends_with(suf))
1219 }),
1220 );
1221 }
1222 let has_seq_pia_co = ctx.any_group_has_co_occurrence(
1223 "SEQ",
1224 0,
1225 &["Z20"],
1226 "PIA",
1227 0,
1228 0,
1229 &["5"],
1230 &["SG4", "SG8"],
1231 );
1232 if !matches!(has_seq_pia_co, ConditionResult::True) {
1233 return has_seq_pia_co;
1234 }
1235 let pias = ctx.find_segments_with_qualifier("PIA", 0, "5");
1236 ConditionResult::from(pias.iter().any(|s| {
1237 s.elements.get(1).and_then(|e| e.first()).is_some_and(|v| {
1238 v.starts_with("7-") && obis_suffixes.iter().any(|suf| v.ends_with(suf))
1239 })
1240 }))
1241 }
1242
1243 /// [276] Wenn SG4 DTM+92 (Beginn zum) vorhanden
1244 fn evaluate_276(&self, ctx: &EvaluationContext) -> ConditionResult {
1245 ctx.has_qualifier("DTM", 0, "92")
1246 }
1247
1248 /// [277] Wenn Zuordnung vorhanden
1249 // REVIEW: 'Wenn Zuordnung vorhanden' most likely refers to Bilanzkreiszuordnung zur Marktlokation, indicated by STS+Z18 per the MIG segment reference. Medium confidence as 'Zuordnung' could refer to other assignments in different PID contexts. (medium confidence)
1250 fn evaluate_277(&self, ctx: &EvaluationContext) -> ConditionResult {
1251 ctx.has_qualifier("STS", 0, "Z18")
1252 }
1253
1254 /// [283] Wenn Empfänger der Nachricht der zum Nachrichtendatum aktuell zugeordnete Lieferant ist
1255 /// EXTERNAL: Requires context from outside the message.
1256 fn evaluate_283(&self, ctx: &EvaluationContext) -> ConditionResult {
1257 ctx.external.evaluate("recipient_is_current_supplier")
1258 }
1259
1260 /// [336] Wenn in Änderungsmeldung gefüllt
1261 /// EXTERNAL: Requires context from outside the message.
1262 // REVIEW: "Wenn in Änderungsmeldung gefüllt" means the condition applies when this field is populated in the context of an amendment message (Änderungsmeldung). Whether a given transmission constitutes an amendment depends on business context (the PID / Vorgang type) that cannot be reliably determined from the raw EDIFACT segments alone. Delegated to external provider. (medium confidence)
1263 fn evaluate_336(&self, ctx: &EvaluationContext) -> ConditionResult {
1264 ctx.external.evaluate("field_filled_in_amendment_message")
1265 }
1266
1267 /// [345] Wenn 33-stelliger Meldepunkt im SG5 LOC+172 (Meldepunkt) vorhanden
1268 fn evaluate_345(&self, ctx: &EvaluationContext) -> ConditionResult {
1269 let locs = ctx.find_segments_with_qualifier("LOC", 0, "172");
1270 ConditionResult::from(locs.iter().any(|s| {
1271 s.elements
1272 .get(1)
1273 .and_then(|e| e.first())
1274 .map(|id| id.len() == 33)
1275 .unwrap_or(false)
1276 }))
1277 }
1278
1279 /// [361] Wenn STS+E01++A03/ A04 nicht vorhanden
1280 fn evaluate_361(&self, ctx: &EvaluationContext) -> ConditionResult {
1281 let found = ctx
1282 .find_segments_with_qualifier("STS", 0, "E01")
1283 .iter()
1284 .any(|s| {
1285 s.elements
1286 .get(2)
1287 .and_then(|e| e.first())
1288 .map(|v| v == "A03" || v == "A04")
1289 .unwrap_or(false)
1290 });
1291 ConditionResult::from(!found)
1292 }
1293
1294 /// [362] Wenn STS+E01++A03/ A17 nicht vorhanden
1295 fn evaluate_362(&self, ctx: &EvaluationContext) -> ConditionResult {
1296 let found = ctx
1297 .find_segments_with_qualifier("STS", 0, "E01")
1298 .iter()
1299 .any(|s| {
1300 s.elements
1301 .get(2)
1302 .and_then(|e| e.first())
1303 .map(|v| v == "A03" || v == "A17")
1304 .unwrap_or(false)
1305 });
1306 ConditionResult::from(!found)
1307 }
1308
1309 /// [367] Wenn SG4 STS+E01++A04 vorhanden
1310 fn evaluate_367(&self, ctx: &EvaluationContext) -> ConditionResult {
1311 ctx.has_qualified_value("STS", 0, "E01", 2, 0, &["A04"])
1312 }
1313
1314 /// [368] Es sind alle Codes aus der Codeliste G_0009 erlaubt
1315 fn evaluate_368(&self, _ctx: &EvaluationContext) -> ConditionResult {
1316 ConditionResult::True
1317 }
1318
1319 /// [427] Messprodukt-Code aus Kapitel 3 "Codeliste der Standard-Messprodukte Gas" der Codeliste der Konfigurationen
1320 /// EXTERNAL: Requires context from outside the message.
1321 fn evaluate_427(&self, ctx: &EvaluationContext) -> ConditionResult {
1322 ctx.external.evaluate("messprodukt_code_gas_valid")
1323 }
1324
1325 /// [442] Wenn in keinem SG8+SEQ+Z09 Mengenumwerterdaten das RFF+MG (Referenz auf die Gerätenummer) der in diesem RFF DE1154 genannte Gerätenummer des Zählers vorhanden ist
1326 // REVIEW: Condition is True when NO SG8 with SEQ+Z09 (Mengenumwerterdaten) has a co-occurring RFF+MG. Implemented by negating any_group_has_co_occurrence. Medium confidence because the 'same device number as meter' cross-reference aspect cannot be fully validated without knowing which meter device number to compare against. (medium confidence)
1327 fn evaluate_442(&self, ctx: &EvaluationContext) -> ConditionResult {
1328 let result = ctx.any_group_has_co_occurrence(
1329 "SEQ",
1330 0,
1331 &["Z09"],
1332 "RFF",
1333 0,
1334 0,
1335 &["MG"],
1336 &["SG4", "SG8"],
1337 );
1338 match result {
1339 ConditionResult::True => ConditionResult::False,
1340 ConditionResult::False => ConditionResult::True,
1341 ConditionResult::Unknown => ConditionResult::Unknown,
1342 }
1343 }
1344
1345 /// [490] Wenn Wert in diesem DE, an der Stelle CCYYMMDD ein Datum aus dem angegeben Zeitraum der Tabelle Kapitel 3.5 „Prozesszeitpunkt bei MESZ mit UTC“ ist
1346 fn evaluate_490(&self, ctx: &EvaluationContext) -> ConditionResult {
1347 match ctx.resolved_value {
1348 Some(val) => is_mesz_utc(val),
1349 None => ConditionResult::False,
1350 }
1351 }
1352
1353 /// [491] Wenn Wert in diesem DE, an der Stelle CCYYMMDD ein Datum aus dem angegeben Zeitraum der Tabelle Kapitel 3.6 „Prozesszeitpunkt bei MEZ mit UTC““ ist
1354 fn evaluate_491(&self, ctx: &EvaluationContext) -> ConditionResult {
1355 match ctx.resolved_value {
1356 Some(val) => is_mez_utc(val),
1357 None => ConditionResult::False,
1358 }
1359 }
1360
1361 /// [494] Das hier genannte Datum muss der Zeitpunkt sein, zu dem das Dokument erstellt wurde, oder ein Zeitpunkt, der davor liegt
1362 fn evaluate_494(&self, _ctx: &EvaluationContext) -> ConditionResult {
1363 // Hinweis: Das genannte Datum muss dem Dokumenterstellungszeitpunkt oder einem früheren Zeitpunkt entsprechen — informational annotation
1364 ConditionResult::True
1365 }
1366
1367 /// [500] Hinweis: Code ist gemäß der Kategorie der zu stornierenden Meldung zu wählen
1368 fn evaluate_500(&self, _ctx: &EvaluationContext) -> ConditionResult {
1369 // Hinweis: Code ist gemäß der Kategorie der zu stornierenden Meldung zu wählen — informational note, always applies
1370 ConditionResult::True
1371 }
1372
1373 /// [501] Hinweis: Die Angabe wird aus dem DTM+157 (Änderung zum) der Zuordnungsliste übernommen
1374 fn evaluate_501(&self, _ctx: &EvaluationContext) -> ConditionResult {
1375 // Hinweis: Die Angabe wird aus dem DTM+157 (Änderung zum) der Zuordnungsliste übernommen — informational note, always applies
1376 ConditionResult::True
1377 }
1378
1379 /// [507] Hinweis: Ursprünglich vom NB bestätigtes Beginndatum
1380 fn evaluate_507(&self, _ctx: &EvaluationContext) -> ConditionResult {
1381 // Hinweis: Informational note — 'ursprünglich vom NB bestätigtes Beginndatum'.
1382 // Documents the semantic meaning of the date field; no boolean logic.
1383 ConditionResult::Unknown
1384 }
1385
1386 /// [508] Hinweis: Beginndatum beim neuen NB
1387 fn evaluate_508(&self, _ctx: &EvaluationContext) -> ConditionResult {
1388 // Hinweis: Informational note — 'Beginndatum beim neuen NB'.
1389 // Documents the semantic meaning of the date field; no boolean logic.
1390 ConditionResult::Unknown
1391 }
1392
1393 /// [510] Hinweis: Zu verwenden bei der Abmeldung der ESV
1394 fn evaluate_510(&self, _ctx: &EvaluationContext) -> ConditionResult {
1395 // Hinweis: Informational note — to be used for deregistration of ESV (Ersatzversorgung).
1396 // Documents usage context; no boolean logic.
1397 ConditionResult::Unknown
1398 }
1399
1400 /// [513] Hinweis: Ist SG9 QTY+Y02 (TUM Kundenwert) vorhanden, dann ist ausschließlich SG9 QTY+Y02, unabhängig von SG9 QTY+31 (Veranschlagte Jahresmenge gesamt), für die Bilanzierung und MMM-Abrechnung zu...
1401 // REVIEW: Hinweis describing precedence rule between QTY+Y02 and QTY+31. Partial implementation checks whether QTY+Y02 is present (i.e. the rule is active). Full semantic enforcement (exclusive use) cannot be expressed as a simple ConditionResult. (medium confidence)
1402 fn evaluate_513(&self, ctx: &EvaluationContext) -> ConditionResult {
1403 // Hinweis: If QTY+Y02 (TUM Kundenwert) is present, only QTY+Y02 (not QTY+31) is
1404 // to be used for billing and MMM settlement. This is a documentation note about
1405 // precedence, not a simple presence/absence condition.
1406 // Best approximation: True if QTY+Y02 is present (signalling the rule applies).
1407 ctx.has_qualifier("QTY", 0, "Y02")
1408 }
1409
1410 /// [527] Hinweis: Es ist die ID der Marktlokation und alle Identifikatoren der Messlokationen anzugeben
1411 fn evaluate_527(&self, _ctx: &EvaluationContext) -> ConditionResult {
1412 // Hinweis: Informational note — ID of Marktlokation AND all Messlokation
1413 // identifiers must be provided. No evaluatable boolean logic.
1414 ConditionResult::Unknown
1415 }
1416
1417 /// [528] Hinweis: Es ist das Datum/ Daten aus der Anfrage zu verwenden
1418 fn evaluate_528(&self, _ctx: &EvaluationContext) -> ConditionResult {
1419 // Hinweis: Informational note — the date(s) from the original request must be used.
1420 // No evaluatable boolean logic.
1421 ConditionResult::Unknown
1422 }
1423
1424 /// [530] Hinweis: Es sind alle an dem Meldepunkt vorhandenen Daten, die mit dieser Segmentgruppe übermittelt werden und zum Datum „Änderung zum“ Gültigkeit haben, anzugeben. Dies kann zur Folge haben...
1425 fn evaluate_530(&self, _ctx: &EvaluationContext) -> ConditionResult {
1426 // Hinweis: Informational note — all data valid at 'Änderung zum' date for the
1427 // reporting point must be provided, possibly requiring repeated segment groups.
1428 // No evaluatable boolean logic.
1429 ConditionResult::Unknown
1430 }
1431
1432 /// [556] Hinweis: Wenn keine Korrespondenzanschrift des Endverbrauchers/ Kunden vorliegt, ist die Anschrift der Marktlokation zu übermitteln
1433 fn evaluate_556(&self, _ctx: &EvaluationContext) -> ConditionResult {
1434 // Hinweis: Wenn keine Korrespondenzanschrift des Endverbrauchers/Kunden vorliegt, ist die Anschrift der Marktlokation zu übermitteln — informational note, always applies
1435 ConditionResult::True
1436 }
1437
1438 /// [558] Hinweis: Diese Information kann freiwillig ausgetauscht werden
1439 fn evaluate_558(&self, _ctx: &EvaluationContext) -> ConditionResult {
1440 // Hinweis: This information can be exchanged voluntarily.
1441 // No evaluatable boolean logic — purely documentary.
1442 ConditionResult::Unknown
1443 }
1444
1445 /// [559] Hinweis: Die Korrespondenzanschrift des Endverbrauchers/Kunden wird nicht zur Identifikation genutzt
1446 fn evaluate_559(&self, _ctx: &EvaluationContext) -> ConditionResult {
1447 // Hinweis: Correspondence address of end consumer/customer is not used for identification.
1448 // No evaluatable boolean logic — purely documentary.
1449 ConditionResult::Unknown
1450 }
1451
1452 /// [560] Hinweis: Die Angabe Name und Adresse für die Ablesekarte wird nicht zur Identifikation genutzt
1453 fn evaluate_560(&self, _ctx: &EvaluationContext) -> ConditionResult {
1454 // Hinweis: Name and address for Ablesekarte (meter reading card) is not used
1455 // for identification purposes. No evaluatable boolean logic — purely documentary.
1456 ConditionResult::Unknown
1457 }
1458
1459 /// [566] Hinweis: Altlieferant
1460 fn evaluate_566(&self, _ctx: &EvaluationContext) -> ConditionResult {
1461 // Hinweis: 'Altlieferant' (previous supplier). Informational label for the
1462 // market participant role context; no evaluatable boolean logic.
1463 ConditionResult::Unknown
1464 }
1465
1466 /// [567] Hinweis: Neulieferant
1467 fn evaluate_567(&self, _ctx: &EvaluationContext) -> ConditionResult {
1468 // Hinweis: 'Neulieferant' (new supplier). Informational label for the
1469 // market participant role context; no evaluatable boolean logic.
1470 ConditionResult::Unknown
1471 }
1472
1473 /// [570] Hinweis: Netzbetreiber Alt
1474 fn evaluate_570(&self, _ctx: &EvaluationContext) -> ConditionResult {
1475 // Hinweis: Netzbetreiber Alt — informational note, always applies
1476 ConditionResult::True
1477 }
1478
1479 /// [571] Hinweis: Auslösender Marktpartner (LFA bei STS+7++ZG9, LFN bei STS+7++ZH0, NB bei STS+7++ZH1)
1480 fn evaluate_571(&self, _ctx: &EvaluationContext) -> ConditionResult {
1481 // Hinweis: Auslösender Marktpartner (LFA bei STS+7++ZG9, LFN bei STS+7++ZH0, NB bei STS+7++ZH1) — informational note, always applies
1482 ConditionResult::True
1483 }
1484
1485 /// [572] Hinweis: Kundenname aus Anmeldung Lieferant neu
1486 fn evaluate_572(&self, _ctx: &EvaluationContext) -> ConditionResult {
1487 // Hinweis: Kundenname aus Anmeldung Lieferant neu — informational note, always applies
1488 ConditionResult::True
1489 }
1490
1491 /// [581] Hinweis: Es ist das nächst mögliche Kündigungsdatum anzugeben
1492 fn evaluate_581(&self, _ctx: &EvaluationContext) -> ConditionResult {
1493 // Hinweis: Es ist das nächst mögliche Kündigungsdatum anzugeben — informational note, always applies
1494 ConditionResult::True
1495 }
1496
1497 /// [583] Hinweis: Verwendung der ID der Marktlokation
1498 fn evaluate_583(&self, _ctx: &EvaluationContext) -> ConditionResult {
1499 // Hinweis: Verwendung der ID der Marktlokation — informational note, always applies
1500 ConditionResult::True
1501 }
1502
1503 /// [584] Hinweis: Verwendung der ID der Messlokation
1504 fn evaluate_584(&self, _ctx: &EvaluationContext) -> ConditionResult {
1505 // Hinweis: Verwendung der ID der Messlokation — informational note, always applies
1506 ConditionResult::True
1507 }
1508
1509 /// [590] Hinweis: Es ist die ID der Marktlokation, welche dem LF zugeordnet sind, sowie alle Identifikatoren der Messlokationen anzugeben
1510 fn evaluate_590(&self, _ctx: &EvaluationContext) -> ConditionResult {
1511 // Hinweis: Es ist die ID der Marktlokation, welche dem LF zugeordnet sind, sowie alle Identifikatoren der Messlokationen anzugeben — informational note, always applies
1512 ConditionResult::True
1513 }
1514
1515 /// [601] Hinweis: Es ist die ID der Marktlokation und alle Identifikatoren der Messlokationen anzugeben.
1516 fn evaluate_601(&self, _ctx: &EvaluationContext) -> ConditionResult {
1517 // Hinweis: Es ist die ID der Marktlokation und alle Identifikatoren der Messlokationen anzugeben — informational note, always applies
1518 ConditionResult::True
1519 }
1520
1521 /// [621] Hinweis: Es ist der MSB anzugeben, welcher ab dem Zeitpunkt der Lokation zugeordnet ist, der in DTM+76 (Datum zum geplanten Leistungsbeginn) genannt ist.
1522 fn evaluate_621(&self, _ctx: &EvaluationContext) -> ConditionResult {
1523 // Hinweis: Es ist der MSB anzugeben, welcher ab dem Zeitpunkt der Lokation zugeordnet ist, der in DTM+76 (Datum zum geplanten Leistungsbeginn) genannt ist.
1524 ConditionResult::True
1525 }
1526
1527 /// [622] Hinweis: Falls die OBIS-Kennzahl für mehrere Marktrollen relevant ist, so muss die Segmentgruppe pro Marktrolle wiederholt werden
1528 fn evaluate_622(&self, _ctx: &EvaluationContext) -> ConditionResult {
1529 // Hinweis: Falls die OBIS-Kennzahl für mehrere Marktrollen relevant ist, so muss die Segmentgruppe pro Marktrolle wiederholt werden
1530 ConditionResult::True
1531 }
1532
1533 /// [636] Hinweis: Dieses RFF klassifiziert mit einem Code im DE1153 die in derselben Segmentgruppe enthaltenen DTM zu einem Markt- bzw. Messlokation relevanten Inhalt
1534 fn evaluate_636(&self, _ctx: &EvaluationContext) -> ConditionResult {
1535 // Hinweis: Dieses RFF klassifiziert mit einem Code im DE1153 die in derselben Segmentgruppe enthaltenen DTM zu einem Markt- bzw. Messlokation relevanten Inhalt
1536 ConditionResult::True
1537 }
1538
1539 /// [637] Hinweis: Bei Verpflichtungsanfrage
1540 fn evaluate_637(&self, _ctx: &EvaluationContext) -> ConditionResult {
1541 // Hinweis: Bei Verpflichtungsanfrage — informational note, always applies
1542 ConditionResult::True
1543 }
1544
1545 /// [638] Hinweis: Bei Aufforderung zur Übernahme der einzelnen Messlokation durch den gMSB
1546 fn evaluate_638(&self, _ctx: &EvaluationContext) -> ConditionResult {
1547 // Hinweis: Bei Aufforderung zur Übernahme der einzelnen Messlokation durch den gMSB — informational note, always applies
1548 ConditionResult::True
1549 }
1550
1551 /// [643] Hinweis: Nachfolgender Netzbetreiber
1552 fn evaluate_643(&self, _ctx: &EvaluationContext) -> ConditionResult {
1553 // Hinweis: Nachfolgender Netzbetreiber — informational note, always applies
1554 ConditionResult::True
1555 }
1556
1557 /// [644] Hinweis: Wenn in der zugehörigen Anmeldung (44001) in diesem Segmente "Einzug in Neuanlage" (SG4 STS+7++E02) enthalten ist, wird in diesem Geschäftsvorfall der Code E01 verwendet
1558 fn evaluate_644(&self, _ctx: &EvaluationContext) -> ConditionResult {
1559 // Hinweis: informational note about E01/E02 usage in Bestätigung — always applies
1560 ConditionResult::True
1561 }
1562
1563 /// [651] Hinweis: Bei einer Marktraumumstellung (Gas) ist zu beachten, dass die tatsächliche Meldung zur Marktraumumstellung auf Ebene der Messlokation durch Angabe der Gasqualität erfolgt. Die betroffene...
1564 fn evaluate_651(&self, _ctx: &EvaluationContext) -> ConditionResult {
1565 // Hinweis: Marktraumumstellung Gas — informational note about Messlokation reporting — always applies
1566 ConditionResult::True
1567 }
1568
1569 /// [654] Hinweis: Es sind ausschließlich die Daten zum Meldepunkt anzugeben, die für den in NAD+MR (Nachrichtenempfänger) adressierten Marktpartner relevant ist
1570 fn evaluate_654(&self, _ctx: &EvaluationContext) -> ConditionResult {
1571 // Hinweis: Only data relevant to the addressed Marktpartner (NAD+MR) should be provided — always applies
1572 ConditionResult::True
1573 }
1574
1575 /// [655] Hinweis: Wenn ein Zähler an einen Mengenumwerter angeschlossen ist werden an dem Zähler keine OBIS-Kennzahlen angegeben Hier gibt es nur OBIS Kennzahlen vom Mengenumwerter
1576 fn evaluate_655(&self, _ctx: &EvaluationContext) -> ConditionResult {
1577 // Hinweis: When a meter is connected to a volume converter, no OBIS codes are given for the meter — always applies
1578 ConditionResult::True
1579 }
1580
1581 /// [902] Format: Möglicher Wert: ≥ 0
1582 fn evaluate_902(&self, ctx: &EvaluationContext) -> ConditionResult {
1583 ctx.format_check("QTY", 0, 1, |val| validate_numeric(val, ">=", 0.0))
1584 }
1585
1586 /// [907] Format: max. 4 Nachkommastellen
1587 fn evaluate_907(&self, ctx: &EvaluationContext) -> ConditionResult {
1588 ctx.format_check("QTY", 0, 1, |val| validate_max_decimal_places(val, 4))
1589 }
1590
1591 /// [912] Format: max. 6 Nachkommastellen
1592 fn evaluate_912(&self, ctx: &EvaluationContext) -> ConditionResult {
1593 ctx.format_check("QTY", 0, 1, |val| validate_max_decimal_places(val, 6))
1594 }
1595
1596 /// [930] Format: max. 2 Nachkommastellen
1597 fn evaluate_930(&self, ctx: &EvaluationContext) -> ConditionResult {
1598 ctx.format_check("QTY", 0, 1, |val| validate_max_decimal_places(val, 2))
1599 }
1600
1601 /// [931] Format: ZZZ = +00
1602 fn evaluate_931(&self, ctx: &EvaluationContext) -> ConditionResult {
1603 ctx.format_check("DTM", 0, 1, validate_timezone_utc)
1604 }
1605
1606 /// [934] Format: HHMM = 0400
1607 fn evaluate_934(&self, ctx: &EvaluationContext) -> ConditionResult {
1608 ctx.format_check("DTM", 0, 1, |val| validate_hhmm_equals(val, "0400"))
1609 }
1610
1611 /// [935] Format: HHMM = 0500
1612 fn evaluate_935(&self, ctx: &EvaluationContext) -> ConditionResult {
1613 ctx.format_check("DTM", 0, 1, |val| validate_hhmm_equals(val, "0500"))
1614 }
1615
1616 /// [937] Format: keine Nachkommastelle
1617 fn evaluate_937(&self, ctx: &EvaluationContext) -> ConditionResult {
1618 ctx.format_check("QTY", 0, 1, |val| validate_max_decimal_places(val, 0))
1619 }
1620
1621 /// [938] Format: Möglicher Wert: <= 10
1622 fn evaluate_938(&self, ctx: &EvaluationContext) -> ConditionResult {
1623 ctx.format_check("QTY", 0, 1, |val| validate_numeric(val, "<=", 10.0))
1624 }
1625
1626 /// [950] Format: Marktlokations-ID
1627 fn evaluate_950(&self, ctx: &EvaluationContext) -> ConditionResult {
1628 ctx.format_check_qualified("LOC", 0, "Z16", 1, 0, validate_malo_id)
1629 }
1630
1631 /// [951] Format: Zählpunktbezeichnung
1632 fn evaluate_951(&self, ctx: &EvaluationContext) -> ConditionResult {
1633 ctx.format_check_qualified("LOC", 0, "Z19", 1, 0, validate_zahlpunkt)
1634 }
1635
1636 /// [952] Format: Gerätenummer nach DIN 43863-5
1637 // REVIEW: DIN 43863-5 Gerätenummer is an alphanumeric device identifier with a max length of 20 characters. No dedicated validator exists, so validate_max_length(20) is used as the structural check. The exact segment/element depends on the AHB table position — IDE is the most common carrier for device IDs in UTILMD Gas, with PIA as a fallback. Medium confidence due to uncertainty about the exact segment without the full AHB table context. (medium confidence)
1638 fn evaluate_952(&self, ctx: &EvaluationContext) -> ConditionResult {
1639 // Format: Gerätenummer nach DIN 43863-5 — alphanumeric, max 20 characters
1640 // DIN 43863-5 device numbers appear in IDE segment (element 1, component 0)
1641 // or in SG8 PIA segments for device identification
1642 let ide_segs = ctx.find_segments("IDE");
1643 if let Some(val) = ide_segs
1644 .first()
1645 .and_then(|s| s.elements.get(1))
1646 .and_then(|e| e.first())
1647 .filter(|v| !v.is_empty())
1648 {
1649 return validate_max_length(val, 20);
1650 }
1651 // Fallback: check PIA segment for device number (qualifier 5 = substitute product)
1652 let pia_segs = ctx.find_segments_with_qualifier("PIA", 0, "5");
1653 match pia_segs
1654 .first()
1655 .and_then(|s| s.elements.get(1))
1656 .and_then(|e| e.first())
1657 {
1658 Some(val) => validate_max_length(val, 20),
1659 None => ConditionResult::False, // segment absent → condition not applicable
1660 }
1661 }
1662
1663 /// [953] Format: Marktlokations-ID oder Zählpunktbezeichnung
1664 fn evaluate_953(&self, ctx: &EvaluationContext) -> ConditionResult {
1665 ctx.format_check("LOC", 1, 0, validate_malo_or_zahlpunkt)
1666 }
1667
1668 /// [2061] Segment bzw. Segmentgruppe ist genau einmal je SG4 IDE (Vorgang) anzugeben
1669 // REVIEW: Condition states the segment/group is to be given exactly once per SG4 IDE (Vorgang). As a boolean applicability condition, this is True when the IDE segment (Vorgangsidentifikator) is present, indicating the SG4 context exists. Cardinality enforcement (exactly once) is a structural rule beyond a simple boolean evaluator. (medium confidence)
1670 fn evaluate_2061(&self, ctx: &EvaluationContext) -> ConditionResult {
1671 ConditionResult::from(ctx.has_segment("IDE"))
1672 }
1673
1674 /// [2119] Je SG8 SEQ+Z13 (Smartmeter-Gateway) ist genau einmal die Segmentgruppe anzugeben
1675 fn evaluate_2119(&self, ctx: &EvaluationContext) -> ConditionResult {
1676 ctx.any_group_has_qualifier("SEQ", 0, "Z13", &["SG4", "SG8"])
1677 }
1678
1679 /// [2284] Für jede Messlokations-ID im SG5 LOC+172 (Meldepunkt) DE3225 genau einmal anzugeben
1680 fn evaluate_2284(&self, ctx: &EvaluationContext) -> ConditionResult {
1681 ctx.any_group_has_qualifier("LOC", 0, "172", &["SG4", "SG5"])
1682 }
1683
1684 /// [2286] Für jede SEQ+Z18 (Daten der Messlokation) mindestens einmal anzugeben
1685 fn evaluate_2286(&self, ctx: &EvaluationContext) -> ConditionResult {
1686 ctx.any_group_has_qualifier("SEQ", 0, "Z18", &["SG4", "SG8"])
1687 }
1688
1689 /// [2287] Für jede SEQ+Z03 (Zähleinrichtungsdaten) mindestens einmal anzugeben
1690 fn evaluate_2287(&self, ctx: &EvaluationContext) -> ConditionResult {
1691 ctx.any_group_has_qualifier("SEQ", 0, "Z03", &["SG4", "SG8"])
1692 }
1693
1694 /// [2335] Für jede SEQ+Z02 (OBIS-Daten der Marktlokation), welche im PIA+5 die OBIS-Kennzahl 7-20:99.33.17/ 7-0:33.86.0 übermittelt, genau einmal anzugeben
1695 // REVIEW: Condition states: to be given exactly once for each SEQ+Z02 (OBIS-Daten der Marktlokation) where PIA+5 transmits OBIS code 7-20:99.33.17 or 7-0:33.86.0. Per segment structure reference, PIA elements[1][0] (DE7140) holds the OBIS code. Checks message-wide PIA+5 for the target OBIS values, then verifies SEQ+Z02 is present. Since PIA is always nested in the same SG8 as its SEQ, message-wide PIA check is a valid approximation when group navigator is unavailable. (medium confidence)
1696 fn evaluate_2335(&self, ctx: &EvaluationContext) -> ConditionResult {
1697 {
1698 // Check for PIA+5 with specific OBIS codes 7-20:99.33.17 or 7-0:33.86.0 at elements[1][0]
1699 let pias = ctx.find_segments_with_qualifier("PIA", 0, "5");
1700 let has_target_obis = pias.iter().any(|pia| {
1701 pia.elements
1702 .get(1)
1703 .and_then(|e| e.first())
1704 .map(|v| v == "7-20:99.33.17" || v == "7-0:33.86.0")
1705 .unwrap_or(false)
1706 });
1707 if !has_target_obis {
1708 return ConditionResult::False;
1709 }
1710 // Also verify SEQ+Z02 (OBIS-Daten der Marktlokation) is present — PIA is always co-located in the same SG8
1711 ctx.any_group_has_qualifier("SEQ", 0, "Z02", &["SG4", "SG8"])
1712 }
1713 }
1714
1715 /// [2353] Für jede SEQ+Z09 (Mengenumwerter-Daten) mindestens einmal anzugeben
1716 fn evaluate_2353(&self, ctx: &EvaluationContext) -> ConditionResult {
1717 ctx.any_group_has_qualifier("SEQ", 0, "Z09", &["SG4", "SG8"])
1718 }
1719}