Skip to main content

automapper_validation/generated/fv2510/
remadv_conditions_fv2510.rs

1// <auto-generated>
2// Generated by automapper-generator generate-conditions
3// AHB: xml-migs-and-ahbs/FV2510/REMADV_AHB_1_0__20250401.xml
4// Generated: 2026-03-12T10:35:55Z
5// </auto-generated>
6
7#[allow(unused_imports)]
8use crate::eval::format_validators::*;
9use crate::eval::{ConditionEvaluator, ConditionResult, EvaluationContext};
10
11/// Generated condition evaluator for REMADV FV2510.
12pub struct RemadvConditionEvaluatorFV2510 {
13    // External condition IDs that require runtime context.
14    external_conditions: std::collections::HashSet<u32>,
15}
16
17impl Default for RemadvConditionEvaluatorFV2510 {
18    fn default() -> Self {
19        let mut external_conditions = std::collections::HashSet::new();
20        external_conditions.insert(45);
21        external_conditions.insert(492);
22        external_conditions.insert(493);
23        Self {
24            external_conditions,
25        }
26    }
27}
28
29impl ConditionEvaluator for RemadvConditionEvaluatorFV2510 {
30    fn message_type(&self) -> &str {
31        "REMADV"
32    }
33
34    fn format_version(&self) -> &str {
35        "FV2510"
36    }
37
38    fn evaluate(&self, condition: u32, ctx: &EvaluationContext) -> ConditionResult {
39        match condition {
40            2 => self.evaluate_2(ctx),
41            3 => self.evaluate_3(ctx),
42            4 => self.evaluate_4(ctx),
43            8 => self.evaluate_8(ctx),
44            9 => self.evaluate_9(ctx),
45            11 => self.evaluate_11(ctx),
46            12 => self.evaluate_12(ctx),
47            14 => self.evaluate_14(ctx),
48            15 => self.evaluate_15(ctx),
49            16 => self.evaluate_16(ctx),
50            18 => self.evaluate_18(ctx),
51            22 => self.evaluate_22(ctx),
52            26 => self.evaluate_26(ctx),
53            28 => self.evaluate_28(ctx),
54            33 => self.evaluate_33(ctx),
55            34 => self.evaluate_34(ctx),
56            35 => self.evaluate_35(ctx),
57            36 => self.evaluate_36(ctx),
58            39 => self.evaluate_39(ctx),
59            40 => self.evaluate_40(ctx),
60            41 => self.evaluate_41(ctx),
61            42 => self.evaluate_42(ctx),
62            43 => self.evaluate_43(ctx),
63            45 => self.evaluate_45(ctx),
64            47 => self.evaluate_47(ctx),
65            48 => self.evaluate_48(ctx),
66            49 => self.evaluate_49(ctx),
67            50 => self.evaluate_50(ctx),
68            51 => self.evaluate_51(ctx),
69            52 => self.evaluate_52(ctx),
70            53 => self.evaluate_53(ctx),
71            54 => self.evaluate_54(ctx),
72            55 => self.evaluate_55(ctx),
73            56 => self.evaluate_56(ctx),
74            57 => self.evaluate_57(ctx),
75            58 => self.evaluate_58(ctx),
76            59 => self.evaluate_59(ctx),
77            60 => self.evaluate_60(ctx),
78            61 => self.evaluate_61(ctx),
79            62 => self.evaluate_62(ctx),
80            63 => self.evaluate_63(ctx),
81            64 => self.evaluate_64(ctx),
82            65 => self.evaluate_65(ctx),
83            66 => self.evaluate_66(ctx),
84            67 => self.evaluate_67(ctx),
85            68 => self.evaluate_68(ctx),
86            69 => self.evaluate_69(ctx),
87            70 => self.evaluate_70(ctx),
88            71 => self.evaluate_71(ctx),
89            72 => self.evaluate_72(ctx),
90            73 => self.evaluate_73(ctx),
91            74 => self.evaluate_74(ctx),
92            75 => self.evaluate_75(ctx),
93            76 => self.evaluate_76(ctx),
94            77 => self.evaluate_77(ctx),
95            78 => self.evaluate_78(ctx),
96            79 => self.evaluate_79(ctx),
97            80 => self.evaluate_80(ctx),
98            81 => self.evaluate_81(ctx),
99            82 => self.evaluate_82(ctx),
100            83 => self.evaluate_83(ctx),
101            84 => self.evaluate_84(ctx),
102            85 => self.evaluate_85(ctx),
103            86 => self.evaluate_86(ctx),
104            87 => self.evaluate_87(ctx),
105            88 => self.evaluate_88(ctx),
106            89 => self.evaluate_89(ctx),
107            90 => self.evaluate_90(ctx),
108            91 => self.evaluate_91(ctx),
109            92 => self.evaluate_92(ctx),
110            93 => self.evaluate_93(ctx),
111            94 => self.evaluate_94(ctx),
112            95 => self.evaluate_95(ctx),
113            96 => self.evaluate_96(ctx),
114            97 => self.evaluate_97(ctx),
115            98 => self.evaluate_98(ctx),
116            99 => self.evaluate_99(ctx),
117            100 => self.evaluate_100(ctx),
118            101 => self.evaluate_101(ctx),
119            102 => self.evaluate_102(ctx),
120            103 => self.evaluate_103(ctx),
121            104 => self.evaluate_104(ctx),
122            105 => self.evaluate_105(ctx),
123            106 => self.evaluate_106(ctx),
124            107 => self.evaluate_107(ctx),
125            108 => self.evaluate_108(ctx),
126            109 => self.evaluate_109(ctx),
127            110 => self.evaluate_110(ctx),
128            111 => self.evaluate_111(ctx),
129            112 => self.evaluate_112(ctx),
130            113 => self.evaluate_113(ctx),
131            114 => self.evaluate_114(ctx),
132            115 => self.evaluate_115(ctx),
133            116 => self.evaluate_116(ctx),
134            117 => self.evaluate_117(ctx),
135            118 => self.evaluate_118(ctx),
136            119 => self.evaluate_119(ctx),
137            120 => self.evaluate_120(ctx),
138            492 => self.evaluate_492(ctx),
139            493 => self.evaluate_493(ctx),
140            501 => self.evaluate_501(ctx),
141            502 => self.evaluate_502(ctx),
142            503 => self.evaluate_503(ctx),
143            510 => self.evaluate_510(ctx),
144            511 => self.evaluate_511(ctx),
145            512 => self.evaluate_512(ctx),
146            515 => self.evaluate_515(ctx),
147            517 => self.evaluate_517(ctx),
148            518 => self.evaluate_518(ctx),
149            519 => self.evaluate_519(ctx),
150            520 => self.evaluate_520(ctx),
151            521 => self.evaluate_521(ctx),
152            523 => self.evaluate_523(ctx),
153            525 => self.evaluate_525(ctx),
154            526 => self.evaluate_526(ctx),
155            529 => self.evaluate_529(ctx),
156            533 => self.evaluate_533(ctx),
157            534 => self.evaluate_534(ctx),
158            535 => self.evaluate_535(ctx),
159            536 => self.evaluate_536(ctx),
160            537 => self.evaluate_537(ctx),
161            538 => self.evaluate_538(ctx),
162            544 => self.evaluate_544(ctx),
163            548 => self.evaluate_548(ctx),
164            549 => self.evaluate_549(ctx),
165            926 => self.evaluate_926(ctx),
166            930 => self.evaluate_930(ctx),
167            931 => self.evaluate_931(ctx),
168            939 => self.evaluate_939(ctx),
169            940 => self.evaluate_940(ctx),
170            _ => ConditionResult::Unknown,
171        }
172    }
173
174    fn is_external(&self, condition: u32) -> bool {
175        self.external_conditions.contains(&condition)
176    }
177    fn is_known(&self, condition: u32) -> bool {
178        matches!(
179            condition,
180            2 | 3
181                | 4
182                | 8
183                | 9
184                | 11
185                | 12
186                | 14
187                | 15
188                | 16
189                | 18
190                | 22
191                | 26
192                | 28
193                | 33
194                | 34
195                | 35
196                | 36
197                | 39
198                | 40
199                | 41
200                | 42
201                | 43
202                | 45
203                | 47
204                | 48
205                | 49
206                | 50
207                | 51
208                | 52
209                | 53
210                | 54
211                | 55
212                | 56
213                | 57
214                | 58
215                | 59
216                | 60
217                | 61
218                | 62
219                | 63
220                | 64
221                | 65
222                | 66
223                | 67
224                | 68
225                | 69
226                | 70
227                | 71
228                | 72
229                | 73
230                | 74
231                | 75
232                | 76
233                | 77
234                | 78
235                | 79
236                | 80
237                | 81
238                | 82
239                | 83
240                | 84
241                | 85
242                | 86
243                | 87
244                | 88
245                | 89
246                | 90
247                | 91
248                | 92
249                | 93
250                | 94
251                | 95
252                | 96
253                | 97
254                | 98
255                | 99
256                | 100
257                | 101
258                | 102
259                | 103
260                | 104
261                | 105
262                | 106
263                | 107
264                | 108
265                | 109
266                | 110
267                | 111
268                | 112
269                | 113
270                | 114
271                | 115
272                | 116
273                | 117
274                | 118
275                | 119
276                | 120
277                | 492
278                | 493
279                | 501
280                | 502
281                | 503
282                | 510
283                | 511
284                | 512
285                | 515
286                | 517
287                | 518
288                | 519
289                | 520
290                | 521
291                | 523
292                | 525
293                | 526
294                | 529
295                | 533
296                | 534
297                | 535
298                | 536
299                | 537
300                | 538
301                | 544
302                | 548
303                | 549
304                | 926
305                | 930
306                | 931
307                | 939
308                | 940
309        )
310    }
311}
312
313impl RemadvConditionEvaluatorFV2510 {
314    /// [45] Nur MP-ID aus Sparte Strom
315    /// EXTERNAL: Requires context from outside the message.
316    fn evaluate_45(&self, ctx: &EvaluationContext) -> ConditionResult {
317        ctx.external.evaluate("mp_id_is_strom")
318    }
319
320    /// [49] Wenn in dieser SG7 AJT DE4465 = A01/A05/A22/A23/A90/A96
321    fn evaluate_49(&self, ctx: &EvaluationContext) -> ConditionResult {
322        ctx.any_group_has_any_qualifier(
323            "AJT",
324            0,
325            &["A01", "A05", "A22", "A23", "A90", "A96"],
326            &["SG7"],
327        )
328    }
329
330    /// [50] Wenn in dieser SG7 AJT DE4465 = A01/A05/A18/A19/A20/A90/A96
331    fn evaluate_50(&self, ctx: &EvaluationContext) -> ConditionResult {
332        ctx.any_group_has_any_qualifier(
333            "AJT",
334            0,
335            &["A01", "A05", "A18", "A19", "A20", "A90", "A96"],
336            &["SG7"],
337        )
338    }
339
340    /// [59] Wenn SG7 AJT+A08/A99+E_0459 vorhanden
341    fn evaluate_59(&self, ctx: &EvaluationContext) -> ConditionResult {
342        {
343            let ajt_segs = ctx.find_segments("AJT");
344            let found = ajt_segs.iter().any(|s| {
345                let qual = s
346                    .elements
347                    .first()
348                    .and_then(|e| e.first())
349                    .map(|v| v.as_str());
350                let pos = s
351                    .elements
352                    .get(1)
353                    .and_then(|e| e.first())
354                    .map(|v| v.as_str());
355                matches!(qual, Some("A08") | Some("A99")) && pos == Some("E_0459")
356            });
357            ConditionResult::from(found)
358        }
359    }
360
361    /// [96] Wenn SG7 AJT+E_0503/E_1007 vorhanden
362    fn evaluate_96(&self, ctx: &EvaluationContext) -> ConditionResult {
363        ctx.any_group_has_any_qualifier("AJT", 0, &["E_0503", "E_1007"], &["SG7"])
364    }
365
366    /// [100] Wenn SG7 AJT+A01 vorhanden
367    fn evaluate_100(&self, ctx: &EvaluationContext) -> ConditionResult {
368        ctx.any_group_has_qualifier("AJT", 0, "A01", &["SG5", "SG7"])
369    }
370
371    /// [105] Wenn in diesem AJT DE1082 = E_0270
372    // REVIEW: Checks if any AJT segment has DE1082 (elements[1][0]) == 'E_0270'. 'In diesem AJT' refers to the current AJT context; without per-segment scope, we search all AJT segments. E_0270 appears in the SG12 AJT code list. Returns Unknown if no AJT segments exist. (medium confidence)
373    fn evaluate_105(&self, ctx: &EvaluationContext) -> ConditionResult {
374        let segs = ctx.find_segments("AJT");
375        if segs.is_empty() {
376            return ConditionResult::Unknown;
377        }
378        ConditionResult::from(segs.iter().any(|s| {
379            s.elements
380                .get(1)
381                .and_then(|e| e.first())
382                .is_some_and(|v| v == "E_0270")
383        }))
384    }
385
386    /// [106] Wenn in diesem AJT DE1082 = E_0273
387    // REVIEW: Checks if any AJT segment has DE1082 (elements[1][0]) == 'E_0273'. Same pattern as condition 105. (medium confidence)
388    fn evaluate_106(&self, ctx: &EvaluationContext) -> ConditionResult {
389        let segs = ctx.find_segments("AJT");
390        if segs.is_empty() {
391            return ConditionResult::Unknown;
392        }
393        ConditionResult::from(segs.iter().any(|s| {
394            s.elements
395                .get(1)
396                .and_then(|e| e.first())
397                .is_some_and(|v| v == "E_0273")
398        }))
399    }
400
401    /// [107] Wenn in diesem AJT DE1082 = E_0276
402    // REVIEW: Checks if any AJT segment has DE1082 (elements[1][0]) == 'E_0276'. Same pattern as condition 105. (medium confidence)
403    fn evaluate_107(&self, ctx: &EvaluationContext) -> ConditionResult {
404        let segs = ctx.find_segments("AJT");
405        if segs.is_empty() {
406            return ConditionResult::Unknown;
407        }
408        ConditionResult::from(segs.iter().any(|s| {
409            s.elements
410                .get(1)
411                .and_then(|e| e.first())
412                .is_some_and(|v| v == "E_0276")
413        }))
414    }
415
416    /// [108] Wenn in diesem AJT DE1082 = E_0277
417    // REVIEW: Checks if any AJT segment has DE1082 (elements[1][0]) == 'E_0277'. Same pattern as condition 105. (medium confidence)
418    fn evaluate_108(&self, ctx: &EvaluationContext) -> ConditionResult {
419        let segs = ctx.find_segments("AJT");
420        if segs.is_empty() {
421            return ConditionResult::Unknown;
422        }
423        ConditionResult::from(segs.iter().any(|s| {
424            s.elements
425                .get(1)
426                .and_then(|e| e.first())
427                .is_some_and(|v| v == "E_0277")
428        }))
429    }
430
431    /// [109] Wenn in dieser SG7 AJT DE4465 = A01/A21/A22/A23/A90/A96
432    fn evaluate_109(&self, ctx: &EvaluationContext) -> ConditionResult {
433        ctx.any_group_has_any_qualifier(
434            "AJT",
435            0,
436            &["A01", "A21", "A22", "A23", "A90", "A96"],
437            &["SG7"],
438        )
439    }
440
441    /// [110] Wenn in dieser SG7 AJT DE1082 = E_0270
442    fn evaluate_110(&self, ctx: &EvaluationContext) -> ConditionResult {
443        ctx.any_group_has_qualifier("AJT", 1, "E_0270", &["SG7"])
444    }
445
446    /// [111] Wenn in dieser SG7 AJT DE1082 = E_0273
447    fn evaluate_111(&self, ctx: &EvaluationContext) -> ConditionResult {
448        ctx.any_group_has_qualifier("AJT", 1, "E_0273", &["SG7"])
449    }
450
451    /// [112] Wenn in dieser SG7 AJT DE1082 = E_0276
452    fn evaluate_112(&self, ctx: &EvaluationContext) -> ConditionResult {
453        ctx.any_group_has_qualifier("AJT", 1, "E_0276", &["SG7"])
454    }
455
456    /// [113] Wenn in dieser SG7 AJT DE1082 = E_0277
457    fn evaluate_113(&self, ctx: &EvaluationContext) -> ConditionResult {
458        ctx.any_group_has_qualifier("AJT", 1, "E_0277", &["SG7"])
459    }
460
461    /// [114] Wenn in dieser SG12 AJT DE1082 = E_0270
462    fn evaluate_114(&self, ctx: &EvaluationContext) -> ConditionResult {
463        ctx.any_group_has_qualified_value("AJT", 1, "E_0270", 1, 0, &["E_0270"], &["SG5", "SG12"])
464    }
465
466    /// [115] Wenn in dieser SG12 AJT DE1082 = E_0273
467    fn evaluate_115(&self, ctx: &EvaluationContext) -> ConditionResult {
468        ctx.any_group_has_qualified_value("AJT", 1, "E_0273", 1, 0, &["E_0273"], &["SG5", "SG12"])
469    }
470
471    /// [116] Wenn in dieser SG12 AJT DE1082 = E_0276
472    fn evaluate_116(&self, ctx: &EvaluationContext) -> ConditionResult {
473        ctx.any_group_has_qualified_value("AJT", 1, "E_0276", 1, 0, &["E_0276"], &["SG5", "SG12"])
474    }
475
476    /// [117] Wenn in dieser SG12 AJT DE1082 = E_0277
477    fn evaluate_117(&self, ctx: &EvaluationContext) -> ConditionResult {
478        ctx.any_group_has_qualified_value("AJT", 1, "E_0277", 1, 0, &["E_0277"], &["SG5", "SG12"])
479    }
480
481    /// [118] Wenn SG7 AJT+A99+E_0272 vorhanden
482    fn evaluate_118(&self, ctx: &EvaluationContext) -> ConditionResult {
483        ctx.has_segment_matching_in_group("AJT", &[(0, 0, "A99"), (1, 0, "E_0272")], &["SG7"])
484    }
485
486    /// [119] Wenn SG7 AJT+A99+E_0275 vorhanden
487    fn evaluate_119(&self, ctx: &EvaluationContext) -> ConditionResult {
488        ctx.has_segment_matching_in_group("AJT", &[(0, 0, "A99"), (1, 0, "E_0275")], &["SG7"])
489    }
490
491    /// [120] Wenn in dieser SG7 AJT DE4465 = A01
492    fn evaluate_120(&self, ctx: &EvaluationContext) -> ConditionResult {
493        ctx.any_group_has_qualifier("AJT", 0, "A01", &["SG7"])
494    }
495
496    /// [544] Hinweis: Wenn in dieser SG7 AJT DE4465 = A21 vorhanden, dann darf in den DE4440 dieses FTX-Segments jeweils nur eine Positionsnummer genannt sein, welche aus dem bestätigten Angebot nicht in der R...
497    fn evaluate_544(&self, _ctx: &EvaluationContext) -> ConditionResult {
498        // Hinweis: Wenn AJT DE4465 = A21 vorhanden, dann darf in den DE4440 dieses FTX-Segments jeweils nur eine Positionsnummer genannt sein, welche aus dem bestätigten Angebot nicht in der Rechnung enthalten sind — informational note, always applies
499        ConditionResult::True
500    }
501
502    /// [2] Wenn SG7 AJT+28 vorhanden
503    fn evaluate_2(&self, ctx: &EvaluationContext) -> ConditionResult {
504        ctx.any_group_has_qualifier("AJT", 0, "28", &["SG7"])
505    }
506
507    /// [3] Bei SG5 DOC+389 / Z25 ist der Wert aus derselben SG5 MOA+9 mit (-1) multipliziert anzugeben.
508    fn evaluate_3(&self, _ctx: &EvaluationContext) -> ConditionResult {
509        // Hinweis: Bei SG5 DOC+389/Z25 ist der Wert aus derselben SG5 MOA+9 mit (-1) multipliziert anzugeben.
510        // Informational annotation describing the calculation rule for MOA+12 (Überweisungsbetrag).
511        ConditionResult::True
512    }
513
514    /// [4] Bei SG5 DOC+380 / 457 ist der Wert aus derselben SG5 MOA+9 unverändert anzugeben.
515    fn evaluate_4(&self, _ctx: &EvaluationContext) -> ConditionResult {
516        // Hinweis: Bei SG5 DOC+380/457 ist der Wert aus derselben SG5 MOA+9 unverändert anzugeben.
517        // Informational annotation describing that MOA+12 (Überweisungsbetrag) equals MOA+9 unchanged.
518        ConditionResult::True
519    }
520
521    /// [8] Wenn SG7 AJT+A01/A02+E_0505 vorhanden
522    fn evaluate_8(&self, ctx: &EvaluationContext) -> ConditionResult {
523        let ajts = ctx.find_segments("AJT");
524        let found = ajts.iter().any(|s| {
525            let elem0 = s
526                .elements
527                .first()
528                .and_then(|e| e.first())
529                .map(|s| s.as_str())
530                .unwrap_or("");
531            let elem1 = s
532                .elements
533                .get(1)
534                .and_then(|e| e.first())
535                .map(|s| s.as_str())
536                .unwrap_or("");
537            (elem0 == "A01" || elem0 == "A02") && elem1 == "E_0505"
538        });
539        ConditionResult::from(found)
540    }
541
542    /// [9] Wenn SG7 AJT+A32/A99+E_0503 vorhanden
543    fn evaluate_9(&self, ctx: &EvaluationContext) -> ConditionResult {
544        let ajts = ctx.find_segments("AJT");
545        let found = ajts.iter().any(|s| {
546            let elem0 = s
547                .elements
548                .first()
549                .and_then(|e| e.first())
550                .map(|s| s.as_str())
551                .unwrap_or("");
552            let elem1 = s
553                .elements
554                .get(1)
555                .and_then(|e| e.first())
556                .map(|s| s.as_str())
557                .unwrap_or("");
558            (elem0 == "A32" || elem0 == "A99") && elem1 == "E_0503"
559        });
560        ConditionResult::from(found)
561    }
562
563    /// [11] Wenn in diesem AJT DE1082 = E_0406
564    // REVIEW: Check if AJT has DE1082 (elements[1][0]) == E_0406. 'In diesem AJT' implies same-segment context; message-wide fallback via has_qualifier is the safe approximation without per-instance scoping. (medium confidence)
565    fn evaluate_11(&self, ctx: &EvaluationContext) -> ConditionResult {
566        ctx.has_qualifier("AJT", 1, "E_0406")
567    }
568
569    /// [12] Wenn in diesem AJT DE1082 = E_0407
570    // REVIEW: Check if AJT has DE1082 (elements[1][0]) == E_0407. Same pattern as condition 11. (medium confidence)
571    fn evaluate_12(&self, ctx: &EvaluationContext) -> ConditionResult {
572        ctx.has_qualifier("AJT", 1, "E_0407")
573    }
574
575    /// [14] A-Code aus Cluster Ablehnung auf Kopfebene
576    fn evaluate_14(&self, _ctx: &EvaluationContext) -> ConditionResult {
577        // Hinweis: A-Code aus Cluster Ablehnung auf Kopfebene — informational annotation
578        // describing that this field's valid values come from the 'Ablehnung' code cluster at header level.
579        ConditionResult::True
580    }
581
582    /// [15] A-Code aus Cluster Ablehnung auf Positionsebene
583    fn evaluate_15(&self, _ctx: &EvaluationContext) -> ConditionResult {
584        // Hinweis: A-Code aus Cluster Ablehnung auf Positionsebene — informational annotation
585        // describing that this field's valid values come from the 'Ablehnung' code cluster at position level.
586        ConditionResult::True
587    }
588
589    /// [16] A-Code aus Cluster Ablehnung auf Summenebene
590    fn evaluate_16(&self, _ctx: &EvaluationContext) -> ConditionResult {
591        // Hinweis: A-Code aus Cluster Ablehnung auf Summenebene — informational annotation
592        // describing that this field's valid values come from the 'Ablehnung' code cluster at summary level.
593        ConditionResult::True
594    }
595
596    /// [18] Wenn in dieser SG7 AJT DE4465 = A74/A75/A76/AC5
597    fn evaluate_18(&self, ctx: &EvaluationContext) -> ConditionResult {
598        ctx.any_group_has_any_qualifier("AJT", 0, &["A74", "A75", "A76", "AC5"], &["SG7"])
599    }
600
601    /// [22] Wenn in dieser SG7 AJT DE4465 = A02/A06/A16/A66/A67/A68/A69/A78/A90/A95/A96/AC3/AC4
602    fn evaluate_22(&self, ctx: &EvaluationContext) -> ConditionResult {
603        ctx.any_group_has_any_qualifier(
604            "AJT",
605            0,
606            &[
607                "A02", "A06", "A16", "A66", "A67", "A68", "A69", "A78", "A90", "A95", "A96", "AC3",
608                "AC4",
609            ],
610            &["SG7"],
611        )
612    }
613
614    /// [26] Wenn in dieser SG12 AJT DE4465 = A51/A62/A82/AA1/AA6/AA7/AB8/AD6
615    fn evaluate_26(&self, ctx: &EvaluationContext) -> ConditionResult {
616        ctx.any_group_has_any_qualifier(
617            "AJT",
618            0,
619            &["A51", "A62", "A82", "AA1", "AA6", "AA7", "AB8", "AD6"],
620            &["SG12"],
621        )
622    }
623
624    /// [28] Wenn in dieser SG12 AJT DE4465 = A23/A26/A35/A36/A38/A46/A47/A48/A50/A58/A59/A61/A77/A84/A99
625    fn evaluate_28(&self, ctx: &EvaluationContext) -> ConditionResult {
626        ctx.any_group_has_any_qualifier(
627            "AJT",
628            0,
629            &[
630                "A23", "A26", "A35", "A36", "A38", "A46", "A47", "A48", "A50", "A58", "A59", "A61",
631                "A77", "A84", "A99",
632            ],
633            &["SG12"],
634        )
635    }
636
637    /// [33] Wenn in diesem AJT DE1082 = S_0103
638    // REVIEW: Check if AJT has DE1082 (elements[1][0]) == S_0103. 'In diesem AJT' scoping approximated by message-wide check via has_qualifier. (medium confidence)
639    fn evaluate_33(&self, ctx: &EvaluationContext) -> ConditionResult {
640        ctx.has_qualifier("AJT", 1, "S_0103")
641    }
642
643    /// [34] Wenn in diesem AJT DE1082 = S_0104
644    fn evaluate_34(&self, ctx: &EvaluationContext) -> ConditionResult {
645        ctx.has_qualifier("AJT", 1, "S_0104")
646    }
647
648    /// [35] Wenn in dieser SG12 AJT DE4465 = A34/A39/AA2/AB2
649    fn evaluate_35(&self, ctx: &EvaluationContext) -> ConditionResult {
650        ctx.any_group_has_any_qualifier("AJT", 0, &["A34", "A39", "AA2", "AB2"], &["SG12"])
651    }
652
653    /// [36] Wenn in dieser SG7 AJT DE4465 = A12/A75/A80/AE1
654    fn evaluate_36(&self, ctx: &EvaluationContext) -> ConditionResult {
655        ctx.any_group_has_any_qualifier("AJT", 0, &["A12", "A75", "A80", "AE1"], &["SG7"])
656    }
657
658    /// [39] Wenn in dieser SG7 AJT DE4465 = AC1
659    fn evaluate_39(&self, ctx: &EvaluationContext) -> ConditionResult {
660        ctx.any_group_has_qualifier("AJT", 0, "AC1", &["SG7"])
661    }
662
663    /// [40] Wenn in dieser SG7 AJT DE1082 = E_0406
664    fn evaluate_40(&self, ctx: &EvaluationContext) -> ConditionResult {
665        ctx.any_group_has_qualifier("AJT", 1, "E_0406", &["SG7"])
666    }
667
668    /// [41] Wenn in dieser SG7 AJT DE1082 = E_0407
669    fn evaluate_41(&self, ctx: &EvaluationContext) -> ConditionResult {
670        ctx.any_group_has_qualifier("AJT", 1, "E_0407", &["SG7"])
671    }
672
673    /// [42] Wenn in SG7 AJT DE1082 = E_0407/E_0568/E_0521/E_0517/E_0266
674    fn evaluate_42(&self, ctx: &EvaluationContext) -> ConditionResult {
675        ctx.any_group_has_any_qualifier(
676            "AJT",
677            1,
678            &["E_0407", "E_0568", "E_0521", "E_0517", "E_0266"],
679            &["SG7"],
680        )
681    }
682
683    /// [43] Wenn in SG12 AJT DE4465=28
684    fn evaluate_43(&self, ctx: &EvaluationContext) -> ConditionResult {
685        ctx.any_group_has_qualifier("AJT", 0, "28", &["SG12"])
686    }
687
688    /// [47] Wenn in diesem AJT DE1082 = E_0210
689    fn evaluate_47(&self, ctx: &EvaluationContext) -> ConditionResult {
690        ctx.has_qualifier("AJT", 1, "E_0210")
691    }
692
693    /// [48] Wenn in diesem AJT DE1082 = E_0259
694    fn evaluate_48(&self, ctx: &EvaluationContext) -> ConditionResult {
695        ctx.has_qualifier("AJT", 1, "E_0259")
696    }
697
698    /// [51] Wenn in dieser SG12 AJT DE1082 = E_0406
699    fn evaluate_51(&self, ctx: &EvaluationContext) -> ConditionResult {
700        ctx.any_group_has_qualifier("AJT", 1, "E_0406", &["SG12"])
701    }
702
703    /// [52] Wenn in dieser SG12 AJT DE1082 = E_0407
704    fn evaluate_52(&self, ctx: &EvaluationContext) -> ConditionResult {
705        ctx.any_group_has_qualifier("AJT", 1, "E_0407", &["SG12"])
706    }
707
708    /// [53] Wenn in dieser SG12 AJT DE4465 = A25/A31/A99/AF1
709    fn evaluate_53(&self, ctx: &EvaluationContext) -> ConditionResult {
710        ctx.any_group_has_any_qualifier("AJT", 0, &["A25", "A31", "A99", "AF1"], &["SG5", "SG12"])
711    }
712
713    /// [54] Wenn in dieser SG12 AJT DE1082 = E_0210
714    fn evaluate_54(&self, ctx: &EvaluationContext) -> ConditionResult {
715        ctx.any_group_has_qualifier("AJT", 1, "E_0210", &["SG5", "SG12"])
716    }
717
718    /// [55] Wenn in dieser SG12 AJT DE1082 = E_0259
719    fn evaluate_55(&self, ctx: &EvaluationContext) -> ConditionResult {
720        ctx.any_group_has_qualifier("AJT", 1, "E_0259", &["SG5", "SG12"])
721    }
722
723    /// [56] Wenn in dieser SG7 AJT DE4465 = A21
724    fn evaluate_56(&self, ctx: &EvaluationContext) -> ConditionResult {
725        ctx.any_group_has_qualifier("AJT", 0, "A21", &["SG5", "SG7"])
726    }
727
728    /// [57] Wenn in dieser SG7 AJT DE1082 = E_0210
729    fn evaluate_57(&self, ctx: &EvaluationContext) -> ConditionResult {
730        ctx.any_group_has_qualifier("AJT", 1, "E_0210", &["SG5", "SG7"])
731    }
732
733    /// [58] Wenn in dieser SG7 AJT DE1082 = E_0259
734    fn evaluate_58(&self, ctx: &EvaluationContext) -> ConditionResult {
735        ctx.any_group_has_qualifier("AJT", 1, "E_0259", &["SG5", "SG7"])
736    }
737
738    /// [60] Wenn SG7 AJT+A99+E_0243 vorhanden
739    fn evaluate_60(&self, ctx: &EvaluationContext) -> ConditionResult {
740        ctx.any_group_has_qualified_value("AJT", 0, "A99", 1, 0, &["E_0243"], &["SG5", "SG7"])
741    }
742
743    /// [61] Wenn SG7 AJT+A99+E_0261 vorhanden
744    fn evaluate_61(&self, ctx: &EvaluationContext) -> ConditionResult {
745        ctx.any_group_has_qualified_value("AJT", 0, "A99", 1, 0, &["E_0261"], &["SG5", "SG7"])
746    }
747
748    /// [62] Wenn SG7 AJT+A99+E_1007 vorhanden
749    fn evaluate_62(&self, ctx: &EvaluationContext) -> ConditionResult {
750        ctx.any_group_has_qualified_value("AJT", 0, "A99", 1, 0, &["E_1007"], &["SG5", "SG7"])
751    }
752
753    /// [63] Wenn SG7 AJT+A01/A02+E_1009 vorhanden
754    fn evaluate_63(&self, ctx: &EvaluationContext) -> ConditionResult {
755        let a01 =
756            ctx.any_group_has_qualified_value("AJT", 0, "A01", 1, 0, &["E_1009"], &["SG5", "SG7"]);
757        let a02 =
758            ctx.any_group_has_qualified_value("AJT", 0, "A02", 1, 0, &["E_1009"], &["SG5", "SG7"]);
759        match (a01, a02) {
760            (ConditionResult::True, _) | (_, ConditionResult::True) => ConditionResult::True,
761            (ConditionResult::False, ConditionResult::False) => ConditionResult::False,
762            _ => ConditionResult::Unknown,
763        }
764    }
765
766    /// [64] Wenn in dieser SG12 AJT DE1082 = E_0264
767    fn evaluate_64(&self, ctx: &EvaluationContext) -> ConditionResult {
768        ctx.any_group_has_qualifier("AJT", 1, "E_0264", &["SG5", "SG12"])
769    }
770
771    /// [65] Wenn in dieser SG12 AJT DE1082 = E_0515
772    fn evaluate_65(&self, ctx: &EvaluationContext) -> ConditionResult {
773        ctx.any_group_has_qualifier("AJT", 1, "E_0515", &["SG5", "SG12"])
774    }
775
776    /// [66] Wenn in dieser SG12 AJT DE1082 = E_0519
777    fn evaluate_66(&self, ctx: &EvaluationContext) -> ConditionResult {
778        ctx.any_group_has_qualifier("AJT", 1, "E_0519", &["SG5", "SG12"])
779    }
780
781    /// [67] Wenn in dieser SG12 AJT DE1082 = E_0266
782    fn evaluate_67(&self, ctx: &EvaluationContext) -> ConditionResult {
783        ctx.any_group_has_qualifier("AJT", 1, "E_0266", &["SG5", "SG12"])
784    }
785
786    /// [68] Wenn in dieser SG12 AJT DE1082 = E_0517
787    fn evaluate_68(&self, ctx: &EvaluationContext) -> ConditionResult {
788        ctx.any_group_has_qualified_value("AJT", 1, "E_0517", 1, 0, &["E_0517"], &["SG12"])
789    }
790
791    /// [69] Wenn in dieser SG12 AJT DE1082 = E_0521
792    fn evaluate_69(&self, ctx: &EvaluationContext) -> ConditionResult {
793        ctx.any_group_has_qualified_value("AJT", 1, "E_0521", 1, 0, &["E_0521"], &["SG12"])
794    }
795
796    /// [70] Wenn in dieser SG12 AJT DE4465 = A15
797    fn evaluate_70(&self, ctx: &EvaluationContext) -> ConditionResult {
798        ctx.any_group_has_qualifier("AJT", 0, "A15", &["SG12"])
799    }
800
801    /// [71] Wenn in dieser SG12 AJT DE4465 = A99
802    fn evaluate_71(&self, ctx: &EvaluationContext) -> ConditionResult {
803        ctx.any_group_has_qualifier("AJT", 0, "A99", &["SG12"])
804    }
805
806    /// [72] Wenn SG7 AJT+A99+E_0518 vorhanden
807    fn evaluate_72(&self, ctx: &EvaluationContext) -> ConditionResult {
808        ctx.any_group_has_qualified_value("AJT", 0, "A99", 1, 0, &["E_0518"], &["SG7"])
809    }
810
811    /// [73] Wenn SG7 AJT+A99+E_0522 vorhanden
812    fn evaluate_73(&self, ctx: &EvaluationContext) -> ConditionResult {
813        ctx.any_group_has_qualified_value("AJT", 0, "A99", 1, 0, &["E_0522"], &["SG7"])
814    }
815
816    /// [74] Wenn SG7 AJT+A99+E_0267 vorhanden
817    fn evaluate_74(&self, ctx: &EvaluationContext) -> ConditionResult {
818        ctx.any_group_has_qualified_value("AJT", 0, "A99", 1, 0, &["E_0267"], &["SG7"])
819    }
820
821    /// [75] Wenn in diesem AJT DE1082 = E_0264
822    // REVIEW: 'In diesem AJT' means current segment context; approximated as message-wide AJT search. DE1082 at elements[1][0]. Redundant qual+val check correctly matches E_0264. (medium confidence)
823    fn evaluate_75(&self, ctx: &EvaluationContext) -> ConditionResult {
824        ctx.has_qualified_value("AJT", 1, "E_0264", 1, 0, &["E_0264"])
825    }
826
827    /// [76] Wenn in diesem AJT DE1082 = E_0266
828    // REVIEW: Same pattern as 75, checking DE1082=E_0266 in any AJT segment. (medium confidence)
829    fn evaluate_76(&self, ctx: &EvaluationContext) -> ConditionResult {
830        ctx.has_qualified_value("AJT", 1, "E_0266", 1, 0, &["E_0266"])
831    }
832
833    /// [77] Wenn in diesem AJT DE1082 = E_0515
834    // REVIEW: Same pattern as 75, checking DE1082=E_0515 in any AJT segment. (medium confidence)
835    fn evaluate_77(&self, ctx: &EvaluationContext) -> ConditionResult {
836        ctx.has_qualified_value("AJT", 1, "E_0515", 1, 0, &["E_0515"])
837    }
838
839    /// [78] Wenn in diesem AJT DE1082 = E_0517
840    // REVIEW: Same pattern as 75, checking DE1082=E_0517 in any AJT segment. (medium confidence)
841    fn evaluate_78(&self, ctx: &EvaluationContext) -> ConditionResult {
842        ctx.has_qualified_value("AJT", 1, "E_0517", 1, 0, &["E_0517"])
843    }
844
845    /// [79] Wenn in diesem AJT DE1082 = E_0519
846    // REVIEW: Same pattern as 75, checking DE1082=E_0519 in any AJT segment. (medium confidence)
847    fn evaluate_79(&self, ctx: &EvaluationContext) -> ConditionResult {
848        ctx.has_qualified_value("AJT", 1, "E_0519", 1, 0, &["E_0519"])
849    }
850
851    /// [80] Wenn in diesem AJT DE1082 = E_0521
852    // REVIEW: Same pattern as 75, checking DE1082=E_0521 in any AJT segment. (medium confidence)
853    fn evaluate_80(&self, ctx: &EvaluationContext) -> ConditionResult {
854        ctx.has_qualified_value("AJT", 1, "E_0521", 1, 0, &["E_0521"])
855    }
856
857    /// [81] Wenn in dieser SG7 AJT DE1082 = E_0264
858    fn evaluate_81(&self, ctx: &EvaluationContext) -> ConditionResult {
859        ctx.any_group_has_qualified_value("AJT", 1, "E_0264", 1, 0, &["E_0264"], &["SG7"])
860    }
861
862    /// [82] Wenn in dieser SG7 AJT DE1082 = E_0515
863    fn evaluate_82(&self, ctx: &EvaluationContext) -> ConditionResult {
864        ctx.any_group_has_qualified_value("AJT", 1, "E_0515", 1, 0, &["E_0515"], &["SG7"])
865    }
866
867    /// [83] Wenn in dieser SG7 AJT DE1082 = E_0519
868    fn evaluate_83(&self, ctx: &EvaluationContext) -> ConditionResult {
869        let values = ctx.collect_group_values("AJT", 1, 0, &["SG7"]);
870        ConditionResult::from(values.iter().any(|(_, v)| v == "E_0519"))
871    }
872
873    /// [84] Wenn in dieser SG7 AJT DE1082 = E_0266
874    fn evaluate_84(&self, ctx: &EvaluationContext) -> ConditionResult {
875        let values = ctx.collect_group_values("AJT", 1, 0, &["SG7"]);
876        ConditionResult::from(values.iter().any(|(_, v)| v == "E_0266"))
877    }
878
879    /// [85] Wenn in dieser SG7 AJT DE1082 = E_0517
880    fn evaluate_85(&self, ctx: &EvaluationContext) -> ConditionResult {
881        let values = ctx.collect_group_values("AJT", 1, 0, &["SG7"]);
882        ConditionResult::from(values.iter().any(|(_, v)| v == "E_0517"))
883    }
884
885    /// [86] Wenn in dieser SG7 AJT DE1082 = E_0521
886    fn evaluate_86(&self, ctx: &EvaluationContext) -> ConditionResult {
887        let values = ctx.collect_group_values("AJT", 1, 0, &["SG7"]);
888        ConditionResult::from(values.iter().any(|(_, v)| v == "E_0521"))
889    }
890
891    /// [87] Wenn in dieser SG7 AJT DE4465 = A05/A21/A22/A23/A90/A96/AE7
892    fn evaluate_87(&self, ctx: &EvaluationContext) -> ConditionResult {
893        ctx.any_group_has_any_qualifier(
894            "AJT",
895            0,
896            &["A05", "A21", "A22", "A23", "A90", "A96", "AE7"],
897            &["SG7"],
898        )
899    }
900
901    /// [88] Wenn in dieser SG7 AJT DE4465 = A25
902    fn evaluate_88(&self, ctx: &EvaluationContext) -> ConditionResult {
903        ctx.any_group_has_qualifier("AJT", 0, "A25", &["SG7"])
904    }
905
906    /// [89] wenn im DE3155 in demselben COM der Code EM vorhanden ist
907    fn evaluate_89(&self, ctx: &EvaluationContext) -> ConditionResult {
908        let segs = ctx.find_segments("COM");
909        ConditionResult::from(segs.iter().any(|s| {
910            s.elements
911                .first()
912                .and_then(|e| e.get(1))
913                .is_some_and(|v| v == "EM")
914        }))
915    }
916
917    /// [90] wenn im DE3155 in demselben COM der Code TE / FX / AJ / AL vorhanden ist
918    fn evaluate_90(&self, ctx: &EvaluationContext) -> ConditionResult {
919        let segs = ctx.find_segments("COM");
920        ConditionResult::from(segs.iter().any(|s| {
921            s.elements
922                .first()
923                .and_then(|e| e.get(1))
924                .is_some_and(|v| matches!(v.as_str(), "TE" | "FX" | "AJ" | "AL"))
925        }))
926    }
927
928    /// [91] Wenn in diesem AJT DE1082 = E_0566
929    fn evaluate_91(&self, ctx: &EvaluationContext) -> ConditionResult {
930        let segs = ctx.find_segments("AJT");
931        ConditionResult::from(segs.iter().any(|s| {
932            s.elements
933                .get(1)
934                .and_then(|e| e.first())
935                .is_some_and(|v| v == "E_0566")
936        }))
937    }
938
939    /// [92] Wenn in diesem AJT DE1082 = E_0568
940    fn evaluate_92(&self, ctx: &EvaluationContext) -> ConditionResult {
941        let segs = ctx.find_segments("AJT");
942        ConditionResult::from(segs.iter().any(|s| {
943            s.elements
944                .get(1)
945                .and_then(|e| e.first())
946                .is_some_and(|v| v == "E_0568")
947        }))
948    }
949
950    /// [93] Wenn SG7 AJT+A99+E_0804 vorhanden
951    fn evaluate_93(&self, ctx: &EvaluationContext) -> ConditionResult {
952        ctx.any_group_has_qualified_value("AJT", 0, "A99", 1, 0, &["E_0804"], &["SG7"])
953    }
954
955    /// [94] Wenn SG7 AJT+A99+E_0806 vorhanden
956    fn evaluate_94(&self, ctx: &EvaluationContext) -> ConditionResult {
957        ctx.any_group_has_qualified_value("AJT", 0, "A99", 1, 0, &["E_0806"], &["SG7"])
958    }
959
960    /// [95] Wenn SG7 AJT+A99+E_0569 vorhanden
961    fn evaluate_95(&self, ctx: &EvaluationContext) -> ConditionResult {
962        ctx.any_group_has_qualified_value("AJT", 0, "A99", 1, 0, &["E_0569"], &["SG7"])
963    }
964
965    /// [97] Wenn in dieser SG12 AJT DE4465 = A27
966    fn evaluate_97(&self, ctx: &EvaluationContext) -> ConditionResult {
967        ctx.any_group_has_qualifier("AJT", 0, "A27", &["SG12"])
968    }
969
970    /// [98] Wenn in SG12 AJT DE1082 = E_0407
971    fn evaluate_98(&self, ctx: &EvaluationContext) -> ConditionResult {
972        let values = ctx.collect_group_values("AJT", 1, 0, &["SG12"]);
973        ConditionResult::from(values.iter().any(|(_, v)| v == "E_0407"))
974    }
975
976    /// [99] Wenn in SG12 AJT DE1082 = E_0568
977    // REVIEW: Checks any AJT segment in the message where DE1082 (elements[1][0]) equals E_0568. No 'dieser' qualifier so message-wide search is appropriate. SG12 scoping not enforced due to API limitations without group path context. (medium confidence)
978    fn evaluate_99(&self, ctx: &EvaluationContext) -> ConditionResult {
979        ConditionResult::from(ctx.find_segments("AJT").iter().any(|s| {
980            s.elements
981                .get(1)
982                .and_then(|e| e.first())
983                .is_some_and(|v| v == "E_0568")
984        }))
985    }
986
987    /// [101] Wenn in dieser SG7 AJT DE1082 = E_0566
988    // REVIEW: Group-scoped check for AJT DE1082=E_0566 within SG7 (nested under SG5). Uses navigator to iterate SG7 instances; falls back to message-wide AJT scan when no navigator available. 'Dieser SG7' semantics best approximated by iterating all SG7 instances. (medium confidence)
989    fn evaluate_101(&self, ctx: &EvaluationContext) -> ConditionResult {
990        if let Some(nav) = ctx.navigator() {
991            let count = nav.group_instance_count(&["SG5", "SG7"]);
992            for i in 0..count {
993                let ajts = nav.find_segments_in_group("AJT", &["SG5", "SG7"], i);
994                if ajts.iter().any(|s| {
995                    s.elements
996                        .get(1)
997                        .and_then(|e| e.first())
998                        .is_some_and(|v| v == "E_0566")
999                }) {
1000                    return ConditionResult::True;
1001                }
1002            }
1003            ConditionResult::False
1004        } else {
1005            ConditionResult::from(ctx.find_segments("AJT").iter().any(|s| {
1006                s.elements
1007                    .get(1)
1008                    .and_then(|e| e.first())
1009                    .is_some_and(|v| v == "E_0566")
1010            }))
1011        }
1012    }
1013
1014    /// [102] Wenn in dieser SG7 AJT DE1082 = E_0568
1015    // REVIEW: Group-scoped check for AJT DE1082=E_0568 within SG7 (nested under SG5). Same pattern as condition 101 but checking E_0568 instead of E_0566. (medium confidence)
1016    fn evaluate_102(&self, ctx: &EvaluationContext) -> ConditionResult {
1017        if let Some(nav) = ctx.navigator() {
1018            let count = nav.group_instance_count(&["SG5", "SG7"]);
1019            for i in 0..count {
1020                let ajts = nav.find_segments_in_group("AJT", &["SG5", "SG7"], i);
1021                if ajts.iter().any(|s| {
1022                    s.elements
1023                        .get(1)
1024                        .and_then(|e| e.first())
1025                        .is_some_and(|v| v == "E_0568")
1026                }) {
1027                    return ConditionResult::True;
1028                }
1029            }
1030            ConditionResult::False
1031        } else {
1032            ConditionResult::from(ctx.find_segments("AJT").iter().any(|s| {
1033                s.elements
1034                    .get(1)
1035                    .and_then(|e| e.first())
1036                    .is_some_and(|v| v == "E_0568")
1037            }))
1038        }
1039    }
1040
1041    /// [103] Wenn in dieser SG12 AJT DE1082 = E_0566
1042    // REVIEW: Group-scoped check for AJT DE1082=E_0566 within SG12 (nested under SG10 for line-item rejections). Uses navigator to iterate SG12 instances; falls back to message-wide scan. (medium confidence)
1043    fn evaluate_103(&self, ctx: &EvaluationContext) -> ConditionResult {
1044        if let Some(nav) = ctx.navigator() {
1045            let count = nav.group_instance_count(&["SG10", "SG12"]);
1046            for i in 0..count {
1047                let ajts = nav.find_segments_in_group("AJT", &["SG10", "SG12"], i);
1048                if ajts.iter().any(|s| {
1049                    s.elements
1050                        .get(1)
1051                        .and_then(|e| e.first())
1052                        .is_some_and(|v| v == "E_0566")
1053                }) {
1054                    return ConditionResult::True;
1055                }
1056            }
1057            ConditionResult::False
1058        } else {
1059            ConditionResult::from(ctx.find_segments("AJT").iter().any(|s| {
1060                s.elements
1061                    .get(1)
1062                    .and_then(|e| e.first())
1063                    .is_some_and(|v| v == "E_0566")
1064            }))
1065        }
1066    }
1067
1068    /// [104] Wenn in dieser SG12 AJT DE1082 = E_0568
1069    // REVIEW: Group-scoped check for AJT DE1082=E_0568 within SG12 (nested under SG10). Same pattern as condition 103 but checking E_0568. (medium confidence)
1070    fn evaluate_104(&self, ctx: &EvaluationContext) -> ConditionResult {
1071        if let Some(nav) = ctx.navigator() {
1072            let count = nav.group_instance_count(&["SG10", "SG12"]);
1073            for i in 0..count {
1074                let ajts = nav.find_segments_in_group("AJT", &["SG10", "SG12"], i);
1075                if ajts.iter().any(|s| {
1076                    s.elements
1077                        .get(1)
1078                        .and_then(|e| e.first())
1079                        .is_some_and(|v| v == "E_0568")
1080                }) {
1081                    return ConditionResult::True;
1082                }
1083            }
1084            ConditionResult::False
1085        } else {
1086            ConditionResult::from(ctx.find_segments("AJT").iter().any(|s| {
1087                s.elements
1088                    .get(1)
1089                    .and_then(|e| e.first())
1090                    .is_some_and(|v| v == "E_0568")
1091            }))
1092        }
1093    }
1094
1095    /// [492] Wenn MP-ID in NAD+MR (Nachrichtenempfänger) aus Sparte Strom
1096    /// EXTERNAL: Requires context from outside the message.
1097    fn evaluate_492(&self, ctx: &EvaluationContext) -> ConditionResult {
1098        ctx.external.evaluate("recipient_is_strom")
1099    }
1100
1101    /// [493] Wenn MP-ID in NAD+MR (Nachrichtenempfänger) aus Sparte Gas
1102    /// EXTERNAL: Requires context from outside the message.
1103    fn evaluate_493(&self, ctx: &EvaluationContext) -> ConditionResult {
1104        ctx.external.evaluate("recipient_is_gas")
1105    }
1106
1107    /// [501] Hinweis: An dieser Stelle ist der Betrag aus SG50 MOA+9 der zugrundeliegenden INVOIC zu übernehmen.
1108    fn evaluate_501(&self, _ctx: &EvaluationContext) -> ConditionResult {
1109        // Hinweis: An dieser Stelle ist der Betrag aus SG50 MOA+9 der zugrundeliegenden INVOIC zu übernehmen.
1110        // Informational note — always applies
1111        ConditionResult::True
1112    }
1113
1114    /// [502] Hinweis: Bei positivem Betrag ergibt sich eine Forderung des Rechnungsstellers. Bei negativem Betrag ergibt sich eine Forderung für den Rechnungsempfänger.
1115    fn evaluate_502(&self, _ctx: &EvaluationContext) -> ConditionResult {
1116        // Hinweis: Bei positivem Betrag ergibt sich eine Forderung des Rechnungsstellers.
1117        // Bei negativem Betrag ergibt sich eine Forderung für den Rechnungsempfänger.
1118        // Informational note — always applies
1119        ConditionResult::True
1120    }
1121
1122    /// [503] Hinweis: Empfohlen, um bei Abweisung Ansprechpartner für Rückfragen zu erreichen.
1123    fn evaluate_503(&self, _ctx: &EvaluationContext) -> ConditionResult {
1124        // Hinweis: Empfohlen, um bei Abweisung Ansprechpartner für Rückfragen zu erreichen.
1125        // Informational note — always applies
1126        ConditionResult::True
1127    }
1128
1129    /// [510] Hinweis: Bei Ablehnung einer vorherigen COMDIS
1130    fn evaluate_510(&self, _ctx: &EvaluationContext) -> ConditionResult {
1131        // Hinweis: Bei Ablehnung einer vorherigen COMDIS
1132        // Informational note — always applies
1133        ConditionResult::True
1134    }
1135
1136    /// [511] Hinweis: BGM DE1004 aus der abgelehnten INVOIC-Nachricht
1137    fn evaluate_511(&self, _ctx: &EvaluationContext) -> ConditionResult {
1138        // Hinweis: BGM DE1004 aus der abgelehnten INVOIC-Nachricht — informational note, always applies
1139        ConditionResult::True
1140    }
1141
1142    /// [512] Hinweis: BGM DE1004 aus der abgelehnten COMDIS-Nachricht
1143    fn evaluate_512(&self, _ctx: &EvaluationContext) -> ConditionResult {
1144        // Hinweis: BGM DE1004 aus der abgelehnten COMDIS-Nachricht — informational note, always applies
1145        ConditionResult::True
1146    }
1147
1148    /// [515] Hinweis: BGM DE1004 aus der bestätigten INVOIC- Nachricht
1149    fn evaluate_515(&self, _ctx: &EvaluationContext) -> ConditionResult {
1150        // Hinweis: BGM DE1004 aus der bestätigten INVOIC-Nachricht — informational note, always applies
1151        ConditionResult::True
1152    }
1153
1154    /// [517] Hinweis: Wenn in dieser SG5 in AJT DE4465 ein Code aus Cluster Ablehnung auf Summenebene verwendet wird, ist diese SG7 so oft zu wiederholen, bis alle Fehler der Summenebene genannt sind.
1155    fn evaluate_517(&self, _ctx: &EvaluationContext) -> ConditionResult {
1156        // Hinweis: Cardinality guidance for SG7 repetition when AJT DE4465 uses a rejection code at sum level — informational note, always applies
1157        ConditionResult::True
1158    }
1159
1160    /// [518] Hinweis: Wenn in dieser SG5 in AJT DE4465 ein Code aus Cluster Ablehnung auf Kopfebene verwendet wird, der von A80 abweicht, ist diese SG7 genau einmal zu nutzen.
1161    fn evaluate_518(&self, _ctx: &EvaluationContext) -> ConditionResult {
1162        // Hinweis: Cardinality guidance for SG7 — exactly once when AJT DE4465 uses a header-level rejection code other than A80 — informational note, always applies
1163        ConditionResult::True
1164    }
1165
1166    /// [519] Hinweis: Diese SG7 ist so oft mit AJT DE4465 = A74 zu wiederholen, bis alle Rechnungsnummern im RFF-Segment dieser SG7 genannt sind, die in der INVOIC fehlen, die in diesem SG5 DOC DE1004 genannt ist
1167    fn evaluate_519(&self, _ctx: &EvaluationContext) -> ConditionResult {
1168        // Hinweis: Diese SG7 ist so oft mit AJT DE4465 = A74 zu wiederholen, bis alle Rechnungsnummern im RFF-Segment dieser SG7 genannt sind, die in der INVOIC fehlen, die in diesem SG5 DOC DE1004 genannt ist
1169        // Informational note, always applies
1170        ConditionResult::True
1171    }
1172
1173    /// [520] Hinweis: Diese SG7 ist so oft mit AJT DE4465 = A75 zu wiederholen, bis alle Rechnungsnummern der Rechnungen genannt sind, die mindestens eine Abschlagsrechnung enthalten, die in der INVOIC abgerech...
1174    fn evaluate_520(&self, _ctx: &EvaluationContext) -> ConditionResult {
1175        // Hinweis: Diese SG7 ist so oft mit AJT DE4465 = A75 zu wiederholen, bis alle Rechnungsnummern der Rechnungen genannt sind, die mindestens eine Abschlagsrechnung enthalten, die in der INVOIC abgerechnet wurden, die in diesem SG5 DOC DE1004 genannt ist.
1176        // Informational note, always applies
1177        ConditionResult::True
1178    }
1179
1180    /// [521] Hinweis: Diese SG7 ist so oft mit AJT DE4465 = A76 zu wiederholen, bis alle Rechnungsnummern der Abschlagsrechnungen genannt sind, die in der INVOIC, die in diesem SG5 DOC DE1004 genannt ist, nicht...
1181    fn evaluate_521(&self, _ctx: &EvaluationContext) -> ConditionResult {
1182        // Hinweis: Diese SG7 ist so oft mit AJT DE4465 = A76 zu wiederholen, bis alle Rechnungsnummern der Abschlagsrechnungen genannt sind, die in der INVOIC, die in diesem SG5 DOC DE1004 genannt ist, nicht hätten berücksichtigt werden dürfen.
1183        // Informational note, always applies
1184        ConditionResult::True
1185    }
1186
1187    /// [523] Hinweis: Jede Rechnungsnummer einer Abschlagsrechnung muss in einem separaten DE4440 angegeben werden. Reichen die fünf DE4440 für die Rechnungsnummern aller anzugebenden Abschlagrechnungen nicht...
1188    fn evaluate_523(&self, _ctx: &EvaluationContext) -> ConditionResult {
1189        // Hinweis: Jede Rechnungsnummer einer Abschlagsrechnung muss in einem separaten DE4440 angegeben werden. Reichen die fünf DE4440 für die Rechnungsnummern aller anzugebenden Abschlagrechnungen nicht aus, ist das FTX+Z14 zu wiederholen.
1190        // Informational note, always applies
1191        ConditionResult::True
1192    }
1193
1194    /// [525] Hinweis: Diese SG10 ist so oft zu wiederholen, bis alle Fehler der Positionsebene genannt sind.
1195    fn evaluate_525(&self, _ctx: &EvaluationContext) -> ConditionResult {
1196        // Hinweis: Diese SG10 ist so oft zu wiederholen, bis alle Fehler der Positionsebene genannt sind.
1197        // Informational note, always applies
1198        ConditionResult::True
1199    }
1200
1201    /// [526] Hinweis: Wert aus DE1082 der SG26 in der sich der nachfolgende Fehler in der INVOIC befindet, die in diesem SG5 DOC DE1004 genannt ist.
1202    fn evaluate_526(&self, _ctx: &EvaluationContext) -> ConditionResult {
1203        // Hinweis: Wert aus DE1082 der SG26 in der sich der nachfolgende Fehler in der INVOIC befindet, die in diesem SG5 DOC DE1004 genannt ist.
1204        ConditionResult::True
1205    }
1206
1207    /// [529] Hinweis: Wenn in dieser SG7 AJT DE4465 = A75 vorhanden, dann dürfen in den DE4440 dieses FTX-Segments nur Abschlagsrechnungsnummern genannt sein, welche in der Rechnung enthalten sind, deren Numme...
1208    // REVIEW: The trigger 'Wenn in dieser SG7 AJT DE4465=A75 vorhanden' is evaluable via group-scoped qualifier check on SG5.SG7. The subsequent content constraint (FTX DE4440 must contain only installment invoice numbers that appear in the invoice referenced by RFF+AFL) requires cross-message business context not available in the EDIFACT message itself, so only the trigger condition is implemented. (medium confidence)
1209    fn evaluate_529(&self, ctx: &EvaluationContext) -> ConditionResult {
1210        // Check if this SG7 contains AJT DE4465=A75.
1211        // The content constraint on FTX DE4440 (only installment invoice numbers
1212        // from the referenced invoice) requires cross-message business context
1213        // and cannot be verified from EDIFACT structure alone.
1214        ctx.any_group_has_qualifier("AJT", 0, "A75", &["SG5", "SG7"])
1215    }
1216
1217    /// [533] Hinweis: Wenn in dieser SG12 AJT DE4465 = AA1/AA6/AA7/AB8/AD6, ist diese SG12 so oft mit AJT DE4465 = Code zu wiederholen, bis alle Rechnungsnummern im RFF-Segment dieser SG12 genannt sind.
1218    // REVIEW: The trigger condition 'Wenn in dieser SG12 AJT DE4465=AA1/AA6/AA7/AB8/AD6' is evaluable via group-scoped multi-qualifier check on SG12. AJT DE4465 is at elements[0][0]. The subsequent repetition rule (how many times to repeat SG12) is informational and not a boolean condition. (medium confidence)
1219    fn evaluate_533(&self, ctx: &EvaluationContext) -> ConditionResult {
1220        // Check if this SG12 contains AJT DE4465 with one of the specified codes.
1221        // When any of these codes is present, SG12 must be repeated until all
1222        // relevant invoice numbers are listed in RFF segments.
1223        ctx.any_group_has_any_qualifier("AJT", 0, &["AA1", "AA6", "AA7", "AB8", "AD6"], &["SG12"])
1224    }
1225
1226    /// [534] Hinweis: Wenn in dieser SG12 AJT DE4465 = A34/A39/AA2/AB2, ist diese SG12 ist so oft mit AJT DE4465 = Code zu wiederholen, bis alle Nummern der Reklamationen im RFF-Segment dieser SG12 genannt sind.
1227    // REVIEW: The trigger condition 'Wenn in dieser SG12 AJT DE4465=A34/A39/AA2/AB2' is evaluable via group-scoped multi-qualifier check on SG12. AJT DE4465 is at elements[0][0]. The subsequent repetition rule is informational. (medium confidence)
1228    fn evaluate_534(&self, ctx: &EvaluationContext) -> ConditionResult {
1229        // Check if this SG12 contains AJT DE4465 with one of the specified codes.
1230        // When any of these codes is present, SG12 must be repeated until all
1231        // relevant complaint/claim numbers are listed in RFF segments.
1232        ctx.any_group_has_any_qualifier("AJT", 0, &["A34", "A39", "AA2", "AB2"], &["SG12"])
1233    }
1234
1235    /// [535] Hinweis: Diese SG7 ist so oft mit AJT DE4465 = A80 zu wiederholen, bis die Rechnungsnummern der nicht stornierten Sonderrechnungen mit derselben Sonderrechnungsart wie sie in Sonderrechnung genannt...
1236    fn evaluate_535(&self, _ctx: &EvaluationContext) -> ConditionResult {
1237        // Hinweis: Diese SG7 ist so oft mit AJT DE4465 = A80 zu wiederholen, bis die Rechnungsnummern der nicht stornierten Sonderrechnungen... — informational note about repetition cardinality, always applies
1238        ConditionResult::True
1239    }
1240
1241    /// [536] Hinweis: Dieses DE darf keine Abschlagsrechnungsnummer enthalten
1242    fn evaluate_536(&self, _ctx: &EvaluationContext) -> ConditionResult {
1243        // Hinweis: Dieses DE darf keine Abschlagsrechnungsnummer enthalten — informational note about field usage restriction, always applies
1244        ConditionResult::True
1245    }
1246
1247    /// [537] Hinweis: Diese SG7 ist so oft mit AJT DE4465 = AC5 zu wiederholen, bis alle Rechnungsnummern im RFF Segment dieser SG7 genannt sind, die in der INVOIC berücksichtigt werden sollten, die in diesem ...
1248    fn evaluate_537(&self, _ctx: &EvaluationContext) -> ConditionResult {
1249        // Hinweis: Diese SG7 ist so oft mit AJT DE4465 = AC5 zu wiederholen, bis alle Rechnungsnummern im RFF Segment dieser SG7 genannt sind... — informational note about repetition cardinality, always applies
1250        ConditionResult::True
1251    }
1252
1253    /// [538] Hinweis: Jede Positionsnummer eines Angebotes muss in einem separaten DE4440 angegeben werden. Reichen die fünf DE4440 für die Positionsnummern aller anzugebenden Angebote nicht aus, ist das SG7 ...
1254    fn evaluate_538(&self, _ctx: &EvaluationContext) -> ConditionResult {
1255        // Hinweis: Jede Positionsnummer eines Angebotes muss in einem separaten DE4440 angegeben werden. Reichen die fünf DE4440 nicht aus, ist das SG7 FTX+Z16 zu wiederholen. — informational note about field usage, always applies
1256        ConditionResult::True
1257    }
1258
1259    /// [548] Hinweis: Die Befüllung des Datenelements ergibt sich aus dem zugehörigen EBD.
1260    fn evaluate_548(&self, _ctx: &EvaluationContext) -> ConditionResult {
1261        // Hinweis: Die Befüllung des Datenelements ergibt sich aus dem zugehörigen EBD.
1262        ConditionResult::True
1263    }
1264
1265    /// [549] Hinweis: Es darf nur eine Information im DE3148 übermittelt werden
1266    fn evaluate_549(&self, _ctx: &EvaluationContext) -> ConditionResult {
1267        // Hinweis: Es darf nur eine Information im DE3148 übermittelt werden — informational note, always applies
1268        ConditionResult::True
1269    }
1270
1271    /// [926] Format: Möglicher Wert: 0
1272    // REVIEW: Format condition checking that the value equals 0. Applied to MOA segment (monetary amount) which is the primary numeric field in REMADV. The segment is the most likely target for this constraint in REMADV context. (medium confidence)
1273    fn evaluate_926(&self, ctx: &EvaluationContext) -> ConditionResult {
1274        // Format: Möglicher Wert: 0
1275        let segs = ctx.find_segments("MOA");
1276        match segs
1277            .first()
1278            .and_then(|s| s.elements.first())
1279            .and_then(|e| e.get(1))
1280        {
1281            Some(val) => validate_numeric(val, "==", 0.0),
1282            None => ConditionResult::False, // segment absent → condition not applicable
1283        }
1284    }
1285
1286    /// [930] Format: max. 2 Nachkommastellen
1287    // REVIEW: Format condition for maximum 2 decimal places. Applied to MOA segment value (element[0][1]) which is the primary numeric data element in REMADV messages. (medium confidence)
1288    fn evaluate_930(&self, ctx: &EvaluationContext) -> ConditionResult {
1289        // Format: max. 2 Nachkommastellen
1290        let segs = ctx.find_segments("MOA");
1291        match segs
1292            .first()
1293            .and_then(|s| s.elements.first())
1294            .and_then(|e| e.get(1))
1295        {
1296            Some(val) => validate_max_decimal_places(val, 2),
1297            None => ConditionResult::False, // segment absent → condition not applicable
1298        }
1299    }
1300
1301    /// [931] Format: ZZZ = +00
1302    fn evaluate_931(&self, ctx: &EvaluationContext) -> ConditionResult {
1303        // Format: ZZZ = +00 — timezone must be UTC
1304        let dtm_segs = ctx.find_segments("DTM");
1305        match dtm_segs
1306            .first()
1307            .and_then(|s| s.elements.first())
1308            .and_then(|e| e.get(1))
1309        {
1310            Some(val) => validate_timezone_utc(val),
1311            None => ConditionResult::False, // segment absent → condition not applicable
1312        }
1313    }
1314
1315    /// [939] Format: Die Zeichenkette muss die Zeichen @ und . enthalten
1316    fn evaluate_939(&self, ctx: &EvaluationContext) -> ConditionResult {
1317        let segs = ctx.find_segments("COM");
1318        match segs
1319            .first()
1320            .and_then(|s| s.elements.first())
1321            .and_then(|e| e.first())
1322        {
1323            Some(val) => validate_email(val),
1324            None => ConditionResult::False, // segment absent → condition not applicable
1325        }
1326    }
1327
1328    /// [940] Format: Die Zeichenkette muss mit dem Zeichen + beginnen und danach dürfen nur noch Ziffern folgen
1329    fn evaluate_940(&self, ctx: &EvaluationContext) -> ConditionResult {
1330        let segs = ctx.find_segments("COM");
1331        match segs
1332            .first()
1333            .and_then(|s| s.elements.first())
1334            .and_then(|e| e.first())
1335        {
1336            Some(val) => validate_phone(val),
1337            None => ConditionResult::False, // segment absent → condition not applicable
1338        }
1339    }
1340}