automapper-validation 0.7.0

AHB condition expression parsing, evaluation, and EDIFACT validation
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
// <auto-generated>
// Generated by automapper-generator generate-conditions
// AHB: xml-migs-and-ahbs/FV2510/ORDRSP_AHB_1_1_Fehlerkorrektur_20250417.xml
// Generated: 2026-03-12T10:41:52Z
// </auto-generated>

// LLM-produced bodies aren't idiomatic Rust — silence stylistic lints at
// file scope so `cargo clippy -D warnings` stays green. Correctness,
// suspicious, and perf categories stay on so real bugs still surface.
#![allow(clippy::style, clippy::complexity)]

#[allow(unused_imports)]
use crate::eval::format_validators::*;
use crate::eval::{Cluster, ConditionEvaluator, ConditionResult, EvaluationContext};
// HAND-EDITED: shared cluster helpers for conditions [17]/[18].
// Preserve across regeneration — see CLAUDE.md "Codelist Providers".
use crate::eval::ebd_cluster::resolved_sts_code_in_cluster;

/// Generated condition evaluator for ORDRSP FV2510.
pub struct OrdrspConditionEvaluatorFV2510 {
    // External condition IDs that require runtime context.
    external_conditions: std::collections::HashSet<u32>,
}

impl Default for OrdrspConditionEvaluatorFV2510 {
    fn default() -> Self {
        let mut external_conditions = std::collections::HashSet::new();
        external_conditions.insert(3);
        external_conditions.insert(4);
        external_conditions.insert(5);
        external_conditions.insert(7);
        external_conditions.insert(9);
        external_conditions.insert(10);
        external_conditions.insert(12);
        external_conditions.insert(13);
        external_conditions.insert(14);
        external_conditions.insert(15);
        external_conditions.insert(16);
        // HAND-EDITED: [17]/[18] are no longer external — they now read
        // the EBD cluster lookup directly. See FV2504 counterpart.
        // external_conditions.insert(17);
        // external_conditions.insert(18);
        external_conditions.insert(29);
        external_conditions.insert(30);
        external_conditions.insert(31);
        external_conditions.insert(32);
        external_conditions.insert(40);
        external_conditions.insert(49);
        external_conditions.insert(52);
        external_conditions.insert(60);
        external_conditions.insert(70);
        external_conditions.insert(71);
        external_conditions.insert(75);
        external_conditions.insert(492);
        external_conditions.insert(493);
        Self {
            external_conditions,
        }
    }
}

impl ConditionEvaluator for OrdrspConditionEvaluatorFV2510 {
    fn message_type(&self) -> &str {
        "ORDRSP"
    }

    fn format_version(&self) -> &str {
        "FV2510"
    }

    fn evaluate(&self, condition: u32, ctx: &EvaluationContext) -> ConditionResult {
        match condition {
            1 => self.evaluate_1(ctx),
            3 => self.evaluate_3(ctx),
            4 => self.evaluate_4(ctx),
            5 => self.evaluate_5(ctx),
            7 => self.evaluate_7(ctx),
            9 => self.evaluate_9(ctx),
            10 => self.evaluate_10(ctx),
            11 => self.evaluate_11(ctx),
            12 => self.evaluate_12(ctx),
            13 => self.evaluate_13(ctx),
            14 => self.evaluate_14(ctx),
            15 => self.evaluate_15(ctx),
            16 => self.evaluate_16(ctx),
            17 => self.evaluate_17(ctx),
            18 => self.evaluate_18(ctx),
            21 => self.evaluate_21(ctx),
            22 => self.evaluate_22(ctx),
            23 => self.evaluate_23(ctx),
            24 => self.evaluate_24(ctx),
            25 => self.evaluate_25(ctx),
            27 => self.evaluate_27(ctx),
            28 => self.evaluate_28(ctx),
            29 => self.evaluate_29(ctx),
            30 => self.evaluate_30(ctx),
            31 => self.evaluate_31(ctx),
            32 => self.evaluate_32(ctx),
            33 => self.evaluate_33(ctx),
            34 => self.evaluate_34(ctx),
            37 => self.evaluate_37(ctx),
            38 => self.evaluate_38(ctx),
            39 => self.evaluate_39(ctx),
            40 => self.evaluate_40(ctx),
            41 => self.evaluate_41(ctx),
            42 => self.evaluate_42(ctx),
            43 => self.evaluate_43(ctx),
            44 => self.evaluate_44(ctx),
            45 => self.evaluate_45(ctx),
            46 => self.evaluate_46(ctx),
            47 => self.evaluate_47(ctx),
            48 => self.evaluate_48(ctx),
            49 => self.evaluate_49(ctx),
            50 => self.evaluate_50(ctx),
            51 => self.evaluate_51(ctx),
            52 => self.evaluate_52(ctx),
            53 => self.evaluate_53(ctx),
            54 => self.evaluate_54(ctx),
            55 => self.evaluate_55(ctx),
            56 => self.evaluate_56(ctx),
            57 => self.evaluate_57(ctx),
            58 => self.evaluate_58(ctx),
            59 => self.evaluate_59(ctx),
            60 => self.evaluate_60(ctx),
            61 => self.evaluate_61(ctx),
            62 => self.evaluate_62(ctx),
            63 => self.evaluate_63(ctx),
            64 => self.evaluate_64(ctx),
            65 => self.evaluate_65(ctx),
            66 => self.evaluate_66(ctx),
            67 => self.evaluate_67(ctx),
            68 => self.evaluate_68(ctx),
            69 => self.evaluate_69(ctx),
            70 => self.evaluate_70(ctx),
            71 => self.evaluate_71(ctx),
            72 => self.evaluate_72(ctx),
            73 => self.evaluate_73(ctx),
            74 => self.evaluate_74(ctx),
            75 => self.evaluate_75(ctx),
            76 => self.evaluate_76(ctx),
            77 => self.evaluate_77(ctx),
            78 => self.evaluate_78(ctx),
            79 => self.evaluate_79(ctx),
            80 => self.evaluate_80(ctx),
            81 => self.evaluate_81(ctx),
            82 => self.evaluate_82(ctx),
            83 => self.evaluate_83(ctx),
            490 => self.evaluate_490(ctx),
            491 => self.evaluate_491(ctx),
            492 => self.evaluate_492(ctx),
            493 => self.evaluate_493(ctx),
            494 => self.evaluate_494(ctx),
            500 => self.evaluate_500(ctx),
            503 => self.evaluate_503(ctx),
            504 => self.evaluate_504(ctx),
            513 => self.evaluate_513(ctx),
            518 => self.evaluate_518(ctx),
            519 => self.evaluate_519(ctx),
            520 => self.evaluate_520(ctx),
            521 => self.evaluate_521(ctx),
            522 => self.evaluate_522(ctx),
            523 => self.evaluate_523(ctx),
            524 => self.evaluate_524(ctx),
            525 => self.evaluate_525(ctx),
            526 => self.evaluate_526(ctx),
            527 => self.evaluate_527(ctx),
            529 => self.evaluate_529(ctx),
            530 => self.evaluate_530(ctx),
            533 => self.evaluate_533(ctx),
            534 => self.evaluate_534(ctx),
            535 => self.evaluate_535(ctx),
            536 => self.evaluate_536(ctx),
            537 => self.evaluate_537(ctx),
            538 => self.evaluate_538(ctx),
            539 => self.evaluate_539(ctx),
            540 => self.evaluate_540(ctx),
            542 => self.evaluate_542(ctx),
            543 => self.evaluate_543(ctx),
            544 => self.evaluate_544(ctx),
            545 => self.evaluate_545(ctx),
            546 => self.evaluate_546(ctx),
            547 => self.evaluate_547(ctx),
            548 => self.evaluate_548(ctx),
            902 => self.evaluate_902(ctx),
            903 => self.evaluate_903(ctx),
            930 => self.evaluate_930(ctx),
            931 => self.evaluate_931(ctx),
            932 => self.evaluate_932(ctx),
            933 => self.evaluate_933(ctx),
            934 => self.evaluate_934(ctx),
            935 => self.evaluate_935(ctx),
            939 => self.evaluate_939(ctx),
            940 => self.evaluate_940(ctx),
            2036 => self.evaluate_2036(ctx),
            _ => ConditionResult::Unknown,
        }
    }

    fn is_external(&self, condition: u32) -> bool {
        self.external_conditions.contains(&condition)
    }
    fn is_known(&self, condition: u32) -> bool {
        matches!(
            condition,
            1 | 3
                | 4
                | 5
                | 7
                | 9
                | 10
                | 11
                | 12
                | 13
                | 14
                | 15
                | 16
                | 17
                | 18
                | 21
                | 22
                | 23
                | 24
                | 25
                | 27
                | 28
                | 29
                | 30
                | 31
                | 32
                | 33
                | 34
                | 37
                | 38
                | 39
                | 40
                | 41
                | 42
                | 43
                | 44
                | 45
                | 46
                | 47
                | 48
                | 49
                | 50
                | 51
                | 52
                | 53
                | 54
                | 55
                | 56
                | 57
                | 58
                | 59
                | 60
                | 61
                | 62
                | 63
                | 64
                | 65
                | 66
                | 67
                | 68
                | 69
                | 70
                | 71
                | 72
                | 73
                | 74
                | 75
                | 76
                | 77
                | 78
                | 79
                | 80
                | 81
                | 82
                | 83
                | 490
                | 491
                | 492
                | 493
                | 494
                | 500
                | 503
                | 504
                | 513
                | 518
                | 519
                | 520
                | 521
                | 522
                | 523
                | 524
                | 525
                | 526
                | 527
                | 529
                | 530
                | 533
                | 534
                | 535
                | 536
                | 537
                | 538
                | 539
                | 540
                | 542
                | 543
                | 544
                | 545
                | 546
                | 547
                | 548
                | 902
                | 903
                | 930
                | 931
                | 932
                | 933
                | 934
                | 935
                | 939
                | 940
                | 2036
        )
    }
}

impl OrdrspConditionEvaluatorFV2510 {
    /// [7] Wenn MP-ID in SG3 NAD+MR aus Sparte Strom
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_7(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("recipient_is_strom")
    }

    /// [13] Wenn MP-ID in SG3 NAD+MR aus Sparte Gas
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_13(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("recipient_is_gas")
    }

    /// [52] wenn es sich bei der Reklamation um die Reklamation der ausgerollten Leistungskurvendefinitionen handelte
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_52(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external
            .evaluate("reklamation_ausgerollte_leistungskurvendefinitionen")
    }

    /// [60] wenn es sich bei der Reklamation um die Reklamation der Übersicht der Zählzeitdefinitionen handelte
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_60(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external
            .evaluate("reklamation_uebersicht_zaehlzeitdefinitionen")
    }

    /// [70] wenn es sich bei der Reklamation um die Reklamation der ausgerollten Zählzeitdefinitionen handelte
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_70(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external
            .evaluate("reklamation_ausgerollte_zaehlzeitdefinitionen")
    }

    /// [71] wenn es sich bei der Reklamation um die Reklamation der ausgerollten Schaltzeitdefinitionen handelte
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_71(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external
            .evaluate("complaint_is_about_rolled_out_switch_time_definitions")
    }

    /// [75] Wenn es sich um die Antwort auf eine Bestellung handelt in der ein Messprodukt der Codeliste der Konfigurationen aus dem Kapitel 4.6.2 „Werte nach Typ 2 aus SMGW“ bestellt wurde.
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_75(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external
            .evaluate("order_contains_smgw_type2_messprodukt")
    }

    /// [78] Wenn AJT+A04+E_0279 vorhanden
    fn evaluate_78(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_segment_matching("AJT", &[(0, 0, "A04"), (1, 0, "E_0279")])
    }

    /// [79] Wenn AJT+A04+E_0283 vorhanden
    fn evaluate_79(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_segment_matching("AJT", &[(0, 0, "A04"), (1, 0, "E_0283")])
    }

    /// [80] Wenn AJT+A05+E_0279 vorhanden
    fn evaluate_80(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_segment_matching("AJT", &[(0, 0, "A05"), (1, 0, "E_0279")])
    }

    /// [81] Wenn AJT+A05+E_0283 vorhanden
    fn evaluate_81(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_segment_matching("AJT", &[(0, 0, "A05"), (1, 0, "E_0283")])
    }

    /// [82] Wenn BGM+Z93 (Bestellung eines Angebots Änderung der Technik der Lokation) vorhanden
    fn evaluate_82(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualifier("BGM", 0, "Z93")
    }

    /// [83] Wenn BGM+Z12 (Änderung der Technik der Lokation) vorhanden
    fn evaluate_83(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualifier("BGM", 0, "Z12")
    }

    /// [513] Hinweis: Wert aus BGM+Z12 (Änderung der Technik der Lokation) DE1004 der ORDERS, mit der die Bestellung erfolgt ist.
    fn evaluate_513(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Wert aus BGM+Z12 (Änderung der Technik der Lokation) DE1004 der ORDERS — informational note, always applies
        ConditionResult::True
    }

    /// [543] Hinweis: Wert aus BGM+Z93 (Bestellung eines Angebots Änderung der Technik der Lokation) DE1004 der ORDERS, mit der die Bestellung erfolgt ist.
    fn evaluate_543(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Wert aus BGM+Z93 (Bestellung eines Angebots Änderung der Technik der Lokation) DE1004 der ORDERS — informational note, always applies
        ConditionResult::True
    }

    /// [544] Hinweis: Wert aus BGM DE1004 der PRICAT mit der das Preisblatt B des MSB, auf die aus Sicht des MSB das Angebot basiert, übermittelt wurde.
    fn evaluate_544(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Wert aus BGM DE1004 der PRICAT mit der das Preisblatt B des MSB — informational note, always applies
        ConditionResult::True
    }

    /// [545] Hinweis: Angabe des Beginnzeitpunkts des realistisch möglichen Umsetzungstermins der zum Zeitpunkt der Ablehnung ermittelt werden kann.
    fn evaluate_545(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Angabe des Beginnzeitpunkts des realistisch möglichen Umsetzungstermins — informational note, always applies
        ConditionResult::True
    }

    /// [546] Hinweis: Angabe des Endezeitpunkts des realistisch möglichen Umsetzungstermins der zum Zeitpunkt der Ablehnung ermittelt werden kann.
    fn evaluate_546(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Angabe des Endezeitpunkts des realistisch möglichen Umsetzungstermins — informational note, always applies
        ConditionResult::True
    }

    /// [547] Hinweis: Wenn es sich um die Bestellung eines vorherigen Angebots im Rahmen der BDEW Anwendungshilfe "Prozesse zur Änderung der Technik an Lokationen" handelt.
    fn evaluate_547(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Bestellung eines vorherigen Angebots im Rahmen der BDEW Anwendungshilfe 'Prozesse zur Änderung der Technik an Lokationen' — informational note, always applies
        ConditionResult::True
    }

    /// [548] Hinweis: Hinweis: wenn es sich um die Beauftragung einer Änderung gemäß WiM Teil1 UC "Messlokationsänderung" handelt.
    fn evaluate_548(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Beauftragung einer Änderung gemäß WiM Teil1 UC 'Messlokationsänderung' — informational note, always applies
        ConditionResult::True
    }

    /// [1] Wenn BGM+7 vorhanden
    fn evaluate_1(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualifier("BGM", 0, "7")
    }

    /// [3] Wenn MP-ID in SG3 NAD+MS mit Rolle NB vorhanden
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_3(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("sender_is_nb")
    }

    /// [4] Wenn MP-ID in SG3 NAD+MR mit Rolle LF vorhanden
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_4(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("recipient_is_lf")
    }

    /// [5] Wenn MP-ID in SG3 NAD+MS mit Rolle LF vorhanden
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_5(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("sender_is_lf")
    }

    /// [9] Wenn MP-ID in SG3 NAD+MS mit Rolle LF vorhanden
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_9(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("sender_is_lf")
    }

    /// [10] Wenn MP-ID in SG3 NAD+MS mit Rolle MSB vorhanden
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_10(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("sender_is_msb")
    }

    /// [11] Wenn AJT+A09+E_0470 vorhanden
    fn evaluate_11(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualified_value("AJT", 0, "A09", 1, 0, &["E_0470"])
    }

    /// [12] Wenn der NB eine unverbindliche Preisinformation angeben kann
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_12(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("nb_can_provide_price_info")
    }

    /// [14] Wenn MP-ID in SG3 NAD+MR mit Rolle MSB vorhanden
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_14(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("recipient_is_msb")
    }

    /// [15] Wenn MP-ID in SG3 NAD+MR mit Rolle NB vorhanden
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_15(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("recipient_is_nb")
    }

    /// [16] Wenn MP-ID in SG3 NAD+MR mit Rolle ÜNB vorhanden
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_16(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("recipient_is_uenb")
    }

    /// [17] Der hier angegebene Code des Prüfschritts muss im EBD dem Cluster Zustimmung zugeordnet sein
    // HAND-EDITED: driven by per-EBD cluster data (mako_prozesse).
    fn evaluate_17(&self, ctx: &EvaluationContext) -> ConditionResult {
        resolved_sts_code_in_cluster(ctx, Cluster::is_zustimmung)
    }

    /// [18] Der hier angegebene Code des Prüfschritts muss im EBD dem Cluster Ablehnung zugeordnet sein
    // HAND-EDITED: driven by per-EBD cluster data (mako_prozesse).
    fn evaluate_18(&self, ctx: &EvaluationContext) -> ConditionResult {
        resolved_sts_code_in_cluster(ctx, Cluster::is_ablehnung)
    }

    /// [21] Wenn IMD++Z01 vorhanden
    fn evaluate_21(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualifier("IMD", 1, "Z01")
    }

    /// [22] Wenn IMD++Z02 vorhanden
    fn evaluate_22(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualifier("IMD", 1, "Z02")
    }

    /// [23] Wenn IMD++Z03 vorhanden
    fn evaluate_23(&self, ctx: &EvaluationContext) -> ConditionResult {
        let segments = ctx.find_segments("IMD");
        ConditionResult::from(segments.iter().any(|s| {
            s.elements
                .get(1)
                .and_then(|e| e.first())
                .is_some_and(|v| v == "Z03")
        }))
    }

    /// [24] Wenn BGM+Z51 vorhanden
    fn evaluate_24(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualifier("BGM", 0, "Z51")
    }

    /// [25] Wenn BGM+Z52 vorhanden
    fn evaluate_25(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualifier("BGM", 0, "Z52")
    }

    /// [27] Wenn AJT+A05+E_0470 vorhanden
    fn evaluate_27(&self, ctx: &EvaluationContext) -> ConditionResult {
        let segments = ctx.find_segments_with_qualifier("AJT", 0, "A05");
        ConditionResult::from(segments.iter().any(|s| {
            s.elements
                .get(1)
                .and_then(|e| e.first())
                .is_some_and(|v| v == "E_0470")
        }))
    }

    /// [28] Wenn AJT+A99 vorhanden
    fn evaluate_28(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualifier("AJT", 0, "A99")
    }

    /// [29] MP-ID nur aus Sparte Gas
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_29(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("mp_id_is_gas")
    }

    /// [30] MP-ID nur aus Sparte Strom
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_30(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("mp_id_is_strom")
    }

    /// [31] MP-ID mit Rolle MSB
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_31(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("mp_id_role_is_msb")
    }

    /// [32] MP-ID mit Rolle NB
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_32(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("mp_id_role_is_nb")
    }

    /// [33] Wenn AJT+A02/A03+E_0488 vorhanden
    fn evaluate_33(&self, ctx: &EvaluationContext) -> ConditionResult {
        let segments = ctx.find_segments("AJT");
        ConditionResult::from(segments.iter().any(|s| {
            let qual = s
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|v| v.as_str());
            let val = s
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|v| v.as_str());
            matches!(qual, Some("A02") | Some("A03")) && matches!(val, Some("E_0488"))
        }))
    }

    /// [34] wenn vorhanden
    // REVIEW: 'wenn vorhanden' is a generic conditional-use annotation meaning the element should be included whenever the relevant data is available. As a standalone condition without a specific segment target, it functions as a Hinweis-like unconditional True. (medium confidence)
    fn evaluate_34(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // 'wenn vorhanden' — generic availability condition: element is conditional on presence of the data
        // Without a specific segment reference this acts as an unconditional note
        ConditionResult::True
    }

    /// [37] Wenn in dieser Nachricht das SG8 CUX+2 vorhanden
    fn evaluate_37(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualifier("CUX", 0, "2")
    }

    /// [38] Möglicher Wert: ZB4 oder ZB5
    fn evaluate_38(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Möglicher Wert: ZB4 oder ZB5 — informational note documenting permitted values
        ConditionResult::True
    }

    /// [39] Möglicher Wert: E17 oder Z07
    fn evaluate_39(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Möglicher Wert: E17 oder Z07 — informational note documenting permitted values
        ConditionResult::True
    }

    /// [40] Wenn der Code im DE3207 in der "EDI@Energy Codeliste der europäischen Ländercodes" in der Spalte "PLZ vorhanden" ein "X" enthält
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_40(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("country_has_postal_code")
    }

    /// [41] wenn SG2 AJT (Einzelheiten zu einer Anpassung/Änderung) DE4465 mit Wert ZB5 vorhanden
    fn evaluate_41(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualifier("AJT", 0, "ZB5")
    }

    /// [42] Wenn SG2 AJT+Z07 (Antwortkategorie: Ablehnung (Keine Berechtigung)) vorhanden
    fn evaluate_42(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualifier("AJT", 0, "Z07")
    }

    /// [43] Wenn AJT+A02/A03+E_1001 vorhanden
    fn evaluate_43(&self, ctx: &EvaluationContext) -> ConditionResult {
        let ajts = ctx.find_segments("AJT");
        let found = ajts.iter().any(|s| {
            let code = s
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|v| v.as_str());
            let pos = s
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|v| v.as_str());
            matches!(code, Some("A02") | Some("A03")) && matches!(pos, Some("E_1001"))
        });
        ConditionResult::from(found)
    }

    /// [44] Wenn AJT+A05+E_1000 vorhanden
    fn evaluate_44(&self, ctx: &EvaluationContext) -> ConditionResult {
        let ajts = ctx.find_segments("AJT");
        let found = ajts.iter().any(|s| {
            let code = s
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|v| v.as_str());
            let pos = s
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|v| v.as_str());
            matches!(code, Some("A05")) && matches!(pos, Some("E_1000"))
        });
        ConditionResult::from(found)
    }

    /// [45] Wenn AJT+A09+E_1000 vorhanden
    fn evaluate_45(&self, ctx: &EvaluationContext) -> ConditionResult {
        let ajts = ctx.find_segments("AJT");
        let found = ajts.iter().any(|s| {
            let code = s
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|v| v.as_str());
            let pos = s
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|v| v.as_str());
            matches!(code, Some("A09")) && matches!(pos, Some("E_1000"))
        });
        ConditionResult::from(found)
    }

    /// [46] Wenn AJT+A06+E_0552 vorhanden
    fn evaluate_46(&self, ctx: &EvaluationContext) -> ConditionResult {
        let ajts = ctx.find_segments("AJT");
        let found = ajts.iter().any(|s| {
            let code = s
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|v| v.as_str());
            let pos = s
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|v| v.as_str());
            matches!(code, Some("A06")) && matches!(pos, Some("E_0552"))
        });
        ConditionResult::from(found)
    }

    /// [47] Wenn AJT+A06+E_0553 vorhanden
    fn evaluate_47(&self, ctx: &EvaluationContext) -> ConditionResult {
        let ajts = ctx.find_segments("AJT");
        let found = ajts.iter().any(|s| {
            let code = s
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|v| v.as_str());
            let pos = s
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|v| v.as_str());
            matches!(code, Some("A06")) && matches!(pos, Some("E_0553"))
        });
        ConditionResult::from(found)
    }

    /// [48] Wenn AJT+A06+E_0554 vorhanden
    fn evaluate_48(&self, ctx: &EvaluationContext) -> ConditionResult {
        let ajts = ctx.find_segments("AJT");
        let found = ajts.iter().any(|s| {
            let code = s
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|v| v.as_str());
            let pos = s
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|v| v.as_str());
            matches!(code, Some("A06")) && matches!(pos, Some("E_0554"))
        });
        ConditionResult::from(found)
    }

    /// [49] nur, wenn in ursprünglicher Nachricht IMD++Z60 (Abbestellung Messprodukt mit Zählzeitdefinition des LF) vorhanden war
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_49(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("original_order_had_imd_z60")
    }

    /// [50] wenn im DE3155 in demselben COM der Code EM vorhanden ist
    fn evaluate_50(&self, ctx: &EvaluationContext) -> ConditionResult {
        let coms = ctx.find_segments("COM");
        ConditionResult::from(coms.iter().any(|s| {
            s.elements
                .first()
                .and_then(|e| e.get(1))
                .map(|v| v == "EM")
                .unwrap_or(false)
        }))
    }

    /// [51] wenn im DE3155 in demselben COM der Code TE / FX / AJ / AL vorhanden ist
    fn evaluate_51(&self, ctx: &EvaluationContext) -> ConditionResult {
        let coms = ctx.find_segments("COM");
        ConditionResult::from(coms.iter().any(|s| {
            matches!(
                s.elements
                    .first()
                    .and_then(|e| e.get(1))
                    .map(|v| v.as_str()),
                Some("TE") | Some("FX") | Some("AJ") | Some("AL")
            )
        }))
    }

    /// [53] Vorgangsnummer aus IDE DE7402 der UTILTS mit BGM+Z59
    fn evaluate_53(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Vorgangsnummer aus IDE DE7402 der UTILTS mit BGM+Z59 — informational note about value origin, always applies
        ConditionResult::True
    }

    /// [54] Vorgangsnummer aus IDE DE7402 der UTILTS mit BGM+Z80
    fn evaluate_54(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Vorgangsnummer aus IDE DE7402 der UTILTS mit BGM+Z80 — informational note about value origin, always applies
        ConditionResult::True
    }

    /// [55] Vorgangsnummer aus IDE DE7402 der UTILTS mit BGM+Z81
    fn evaluate_55(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Vorgangsnummer aus IDE DE7402 der UTILTS mit BGM+Z81 — informational note about value origin, always applies
        ConditionResult::True
    }

    /// [56] wenn SG2 AJT+A02/A03/A06/A07/A10/A11+E_0548 vorhanden
    fn evaluate_56(&self, ctx: &EvaluationContext) -> ConditionResult {
        let ajts = ctx.find_segments("AJT");
        ConditionResult::from(ajts.iter().any(|s| {
            let de4465 = s
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            let de1082 = s
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            matches!(
                de4465,
                Some("A02") | Some("A03") | Some("A06") | Some("A07") | Some("A10") | Some("A11")
            ) && de1082 == Some("E_0548")
        }))
    }

    /// [57] wenn SG2 AJT+A02/A03/A06/A07/A10/A11+E_0549 vorhanden
    fn evaluate_57(&self, ctx: &EvaluationContext) -> ConditionResult {
        let ajts = ctx.find_segments("AJT");
        ConditionResult::from(ajts.iter().any(|s| {
            let de4465 = s
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            let de1082 = s
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            matches!(
                de4465,
                Some("A02") | Some("A03") | Some("A06") | Some("A07") | Some("A10") | Some("A11")
            ) && de1082 == Some("E_0549")
        }))
    }

    /// [58] wenn SG2 AJT+A02/A03/A06/A07+E_0550 vorhanden
    fn evaluate_58(&self, ctx: &EvaluationContext) -> ConditionResult {
        let ajts = ctx.find_segments("AJT");
        ConditionResult::from(ajts.iter().any(|s| {
            let de4465 = s
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            let de1082 = s
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            matches!(
                de4465,
                Some("A02") | Some("A03") | Some("A06") | Some("A07")
            ) && de1082 == Some("E_0550")
        }))
    }

    /// [59] wenn SG2 AJT+A02/A03/A06/A07/A10/A11+E_0551 vorhanden
    fn evaluate_59(&self, ctx: &EvaluationContext) -> ConditionResult {
        let ajts = ctx.find_segments("AJT");
        ConditionResult::from(ajts.iter().any(|s| {
            let de4465 = s
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            let de1082 = s
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            matches!(
                de4465,
                Some("A02") | Some("A03") | Some("A06") | Some("A07") | Some("A10") | Some("A11")
            ) && de1082 == Some("E_0551")
        }))
    }

    /// [61] wenn es sich bei der Reklamation um die Reklamation der Übersicht der Schaltzeitdefinitionen handelte
    // REVIEW: The condition checks whether the complaint concerned the overview of switching time definitions (Schaltzeitdefinitionen). Condition 63 establishes that BGM+Z60 is the code for Schaltzeitdefinitionen in UTILTS, and the ORDRSP BGM code mirrors this type. Checking BGM elements[0][0] == 'Z60' identifies this complaint type. (medium confidence)
    fn evaluate_61(&self, ctx: &EvaluationContext) -> ConditionResult {
        // Reklamation der Übersicht der Schaltzeitdefinitionen → ORDRSP with BGM+Z60
        ctx.has_qualifier("BGM", 0, "Z60")
    }

    /// [62] wenn es sich bei der Reklamation um die Reklamation der Übersicht der Leistungskurvendefinitionen handelte
    // REVIEW: The condition checks whether the complaint concerned the overview of load curve definitions (Leistungskurvendefinitionen). Conditions 64 and 65 establish BGM+Z78 and BGM+Z79 as the two related UTILTS codes for Leistungskurven types, so both are checked. (medium confidence)
    fn evaluate_62(&self, ctx: &EvaluationContext) -> ConditionResult {
        // Reklamation der Übersicht der Leistungskurvendefinitionen → BGM+Z78 or BGM+Z79
        let bgm_segs = ctx.find_segments("BGM");
        match bgm_segs.first() {
            Some(s) => {
                let code = s
                    .elements
                    .first()
                    .and_then(|e| e.first())
                    .map(|v| v.as_str());
                ConditionResult::from(matches!(code, Some("Z78") | Some("Z79")))
            }
            None => ConditionResult::False, // segment absent → condition not applicable
        }
    }

    /// [63] Dokumentennummer aus BGM+Z60 DE1004 der UTILTS
    fn evaluate_63(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Dokumentennummer aus BGM+Z60 DE1004 der UTILTS — informational note, always applies
        ConditionResult::True
    }

    /// [64] Dokumentennummer aus BGM+Z78 DE1004 der UTILTS
    fn evaluate_64(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Dokumentennummer aus BGM+Z78 DE1004 der UTILTS — informational note, always applies
        ConditionResult::True
    }

    /// [65] Dokumentennummer aus BGM+Z79 DE1004 der UTILTS
    fn evaluate_65(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Dokumentennummer aus BGM+Z79 DE1004 der UTILTS — informational note, always applies
        ConditionResult::True
    }

    /// [66] wenn SG2 AJT+A01/A02/A03+E_0544 vorhanden
    fn evaluate_66(&self, ctx: &EvaluationContext) -> ConditionResult {
        let ajts = ctx.find_segments("AJT");
        ConditionResult::from(ajts.iter().any(|s| {
            let de4465 = s
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            let de1082 = s
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            matches!(de4465, Some("A01") | Some("A02") | Some("A03")) && de1082 == Some("E_0544")
        }))
    }

    /// [67] wenn SG2 AJT+A01/A02/A03+E_0545 vorhanden
    fn evaluate_67(&self, ctx: &EvaluationContext) -> ConditionResult {
        let ajts = ctx.find_segments("AJT");
        ConditionResult::from(ajts.iter().any(|s| {
            let de4465 = s
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            let de1082 = s
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            matches!(de4465, Some("A01") | Some("A02") | Some("A03")) && de1082 == Some("E_0545")
        }))
    }

    /// [68] wenn SG2 AJT+A02/A03+E_0546 vorhanden
    fn evaluate_68(&self, ctx: &EvaluationContext) -> ConditionResult {
        let ajts = ctx.find_segments("AJT");
        ConditionResult::from(ajts.iter().any(|s| {
            let de4465 = s
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            let de1082 = s
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            matches!(de4465, Some("A02") | Some("A03")) && de1082 == Some("E_0546")
        }))
    }

    /// [69] wenn SG2 AJT+A01/A02/A03+E_0547 vorhanden
    fn evaluate_69(&self, ctx: &EvaluationContext) -> ConditionResult {
        let ajts = ctx.find_segments("AJT");
        ConditionResult::from(ajts.iter().any(|s| {
            let de4465 = s
                .elements
                .first()
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            let de1082 = s
                .elements
                .get(1)
                .and_then(|e| e.first())
                .map(|s| s.as_str());
            matches!(de4465, Some("A01") | Some("A02") | Some("A03")) && de1082 == Some("E_0547")
        }))
    }

    /// [72] wenn AJT+A04+E_0552 vorhanden
    fn evaluate_72(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualified_value("AJT", 0, "A04", 1, 0, &["E_0552"])
    }

    /// [73] wenn AJT+A04+E_0553 vorhanden
    fn evaluate_73(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualified_value("AJT", 0, "A04", 1, 0, &["E_0553"])
    }

    /// [74] wenn AJT+A04+E_0554 vorhanden
    fn evaluate_74(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualified_value("AJT", 0, "A04", 1, 0, &["E_0554"])
    }

    /// [76] Wenn FTX+Z27 (IP-Adresse des Absenders) nicht vorhanden
    fn evaluate_76(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.lacks_qualifier("FTX", 0, "Z27")
    }

    /// [77] Wenn FTX+Z28 (IP-Range des Absenders) nicht vorhanden
    fn evaluate_77(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.lacks_qualifier("FTX", 0, "Z28")
    }

    /// [490] wenn Wert in diesem DE, an der Stelle CCYYMMDDHHMM ein Zeitpunkt aus dem angegeben Zeitraum der Tabelle Kapitel 3.5 „Übersicht gesetzliche deutsche Sommerzeit (MESZ)“ der Spalten: „Sommerzei...
    fn evaluate_490(&self, ctx: &EvaluationContext) -> ConditionResult {
        match ctx.resolved_value {
            Some(val) => is_mesz_utc(val),
            None => ConditionResult::False,
        }
    }

    /// [491] wenn Wert in diesem DE, an der Stelle CCYYMMDDHHMM ein Zeitpunkt aus dem angegeben Zeitraum der Tabelle Kapitel 3.6 „Übersicht gesetzliche deutsche Zeit (MEZ)“ der Spalten: „Winterzeit (MEZ)...
    fn evaluate_491(&self, ctx: &EvaluationContext) -> ConditionResult {
        match ctx.resolved_value {
            Some(val) => is_mez_utc(val),
            None => ConditionResult::False,
        }
    }

    /// [492] wenn MP-ID in NAD+MR aus Sparte Strom
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_492(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("recipient_is_strom")
    }

    /// [493] wenn MP-ID in NAD+MR aus Sparte Gas
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_493(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("recipient_is_gas")
    }

    /// [494] Das hier genannte Datum muss der Zeitpunkt sein, zu dem das Dokument erstellt wurde, oder ein Zeitpunkt, der davor liegt.
    // REVIEW: 'Das hier genannte Datum muss der Zeitpunkt sein, zu dem das Dokument erstellt wurde, oder ein Zeitpunkt, der davor liegt.' This is a constraint description stating the date must be the document creation time or earlier. It functions as an unconditional validation rule (always applies) rather than a conditional trigger. Without knowing which specific DTM qualifier 'here' refers to in the calling context, and since the constraint itself is always applicable, returning True is appropriate. (medium confidence)
    fn evaluate_494(&self, _ctx: &EvaluationContext) -> ConditionResult {
        ConditionResult::True
    }

    /// [500] Hinweis: Angabe eines technischen Ansprechpartners für die Geräteübernahme
    fn evaluate_500(&self, _ctx: &EvaluationContext) -> ConditionResult {
        ConditionResult::True
    }

    /// [503] Hinweis: Datum, bis zu dem der MSBA zur Fortführung verpflichtet wurde
    fn evaluate_503(&self, _ctx: &EvaluationContext) -> ConditionResult {
        ConditionResult::True
    }

    /// [504] Hinweis: Ggf. korrigiert bei einer Zeitangabe in der ORDERS, die außerhalb des max. möglichen Weiterverpflichtungszeitraums ist. Als Antwort wird dann in SG2 AJT Zustimmung mit Terminänderung an...
    fn evaluate_504(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Ggf. korrigiert bei einer Zeitangabe in der ORDERS, die außerhalb des max. möglichen Weiterverpflichtungszeitraums ist. Als Antwort wird dann in SG2 AJT Zustimmung mit Terminänderung angegeben.
        ConditionResult::True
    }

    /// [518] Hinweis: Wert aus BGM+Z10 DE1004 der ORDERS, mit der die Bestellung erfolgt ist
    fn evaluate_518(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Wert aus BGM+Z10 DE1004 der ORDERS, mit der die Bestellung erfolgt ist.
        ConditionResult::True
    }

    /// [519] Hinweis: Wert aus BGM+7 DE1004 der ORDERS, mit der die Bestellung erfolgt ist.
    fn evaluate_519(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Wert aus BGM+7 DE1004 der ORDERS, mit der die Bestellung erfolgt ist.
        ConditionResult::True
    }

    /// [520] Hinweis: Wert aus BGM+Z29 DE1004 der ORDERS, mit der die Anfrage zur Beendigung der Rechnungsabwicklung erfolgt ist.
    fn evaluate_520(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Wert aus BGM+Z29 DE1004 der ORDERS, mit der die Anfrage zur Beendigung der Rechnungsabwicklung erfolgt ist.
        ConditionResult::True
    }

    /// [521] Hinweis: Wert aus BGM+Z14/Z61/Z62 DE1004 der ORDERS, mit der die Anforderung von Stammdaten erfolgt ist
    fn evaluate_521(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Wert aus BGM+Z14/Z61/Z62 DE1004 der ORDERS, mit der die Anforderung von Stammdaten erfolgt ist
        // Informational note — documents that the BGM DE1004 value originates from the original ORDERS request.
        ConditionResult::True
    }

    /// [522] Hinweis: Wert aus BGM+7/Z28/Z48 DE1004 der ORDERS, mit der die Anforderung von Werten erfolgt ist.
    fn evaluate_522(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Wert aus BGM+7/Z28/Z48 DE1004 der ORDERS — informational note, always applies
        ConditionResult::True
    }

    /// [523] Hinweis: Wert aus BGM+7 DE1004 der ORDERS, mit der die Anforderung Anforderung von Brennwert und Zustandszahl erfolgt ist.
    fn evaluate_523(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Wert aus BGM+7 DE1004 der ORDERS — informational note, always applies
        ConditionResult::True
    }

    /// [524] Hinweis: Wert aus BGM+Z14 DE1004 der ORDERS, mit der die Anfrage vom MSB Gas erfolgt ist.
    fn evaluate_524(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Wert aus BGM+Z14 DE1004 der ORDERS — informational note, always applies
        ConditionResult::True
    }

    /// [525] Hinweis: Wert aus BGM+Z24 DE1004 der ORDERS, mit der die Anforderung Allokationsliste erfolgt ist
    fn evaluate_525(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Wert aus BGM+Z24 DE1004 der ORDERS — informational note, always applies
        ConditionResult::True
    }

    /// [526] Hinweis: Wert aus BGM+Z23 DE1004 der ORDERS, mit der die Anforderung bilanzierte Menge erfolgt ist
    fn evaluate_526(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Wert aus BGM+Z23 DE1004 der ORDERS — informational note, always applies
        ConditionResult::True
    }

    /// [527] Hinweis: Wert aus BGM+Z34 DE1004 der ORDERS, mit der die Reklamation von Werten erfolgt ist.
    fn evaluate_527(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Wert aus BGM+Z34 DE1004 der ORDERS, mit der die Reklamation von Werten erfolgt ist. — informational note, always applies
        ConditionResult::True
    }

    /// [529] Hinweis: Dokumentennummer aus BGM DE1004 der ORDERS
    fn evaluate_529(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Dokumentennummer aus BGM DE1004 der ORDERS — informational note, always applies
        ConditionResult::True
    }

    /// [530] Hinweis: Dokumentennummer aus BGM DE1004 der ORDCHG
    fn evaluate_530(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Dokumentennummer aus BGM DE1004 der ORDCHG — informational note, always applies
        ConditionResult::True
    }

    /// [533] Hinweis: Wert aus BGM+Z51 DE1004 der ORDCHG
    fn evaluate_533(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Wert aus BGM+Z51 DE1004 der ORDCHG — informational note, always applies
        ConditionResult::True
    }

    /// [534] Hinweis: Wert aus BGM+Z52 DE1004 der ORDCHG
    fn evaluate_534(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Wert aus BGM+Z52 DE1004 der ORDCHG — informational note, always applies
        ConditionResult::True
    }

    /// [535] Hinweis: Wert aus BGM+Z13 DE1004 der ORDERS, mit der die Ankündigung Gerätewechselabsicht erfolgt ist.
    fn evaluate_535(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Wert aus BGM+Z13 DE1004 der ORDERS — informational note, always applies
        ConditionResult::True
    }

    /// [536] Hinweis: Es ist die MP-ID des Eigentümers (MSB) zur bilateralen Klärung anzugeben, wenn der angefragte MSB nicht selber der Eigentümer ist.
    fn evaluate_536(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: MP-ID des Eigentümers (MSB) angeben — informational note, always applies
        ConditionResult::True
    }

    /// [537] Hinweis: Wert aus BGM+Z72 DE1004 der ORDERS, mit der die Bestellung Beendigung der Konfiguration erfolgt ist.
    fn evaluate_537(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Wert aus BGM+Z72 DE1004 der ORDERS — informational note, always applies
        ConditionResult::True
    }

    /// [538] Hinweis: Wert aus BGM+Z76 DE1004 der ORDERS, mit der die Reklamation der Konfiguration erfolgt ist.
    fn evaluate_538(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Wert aus BGM+Z76 DE1004 der ORDERS — informational note, always applies
        ConditionResult::True
    }

    /// [539] Hinweis: Wert aus BGM+Z73/Z74 DE1004 der ORDERS, mit der die Bestellung der Konfiguration erfolgt ist.
    fn evaluate_539(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Wert aus BGM+Z73/Z74 DE1004 der ORDERS — informational note, always applies
        ConditionResult::True
    }

    /// [540] Hinweis: Es darf nur eine Information im DE3148 übermittelt werden
    fn evaluate_540(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Es darf nur eine Information im DE3148 übermittelt werden — informational note, always applies
        ConditionResult::True
    }

    /// [542] Hinweis: Wert aus BGM+Z91 DE1004 der ORDERS, mit der die Bestellung Änderung der Abrechnungsdaten erfolgt ist.
    fn evaluate_542(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Wert aus BGM+Z91 DE1004 der ORDERS — informational note about value origin, always applies
        ConditionResult::True
    }

    /// [902] Format: Format: Möglicher Wert: ≥ 0
    // REVIEW: Format condition requiring numeric value >= 0. Applied to QTY segment value (elements[0][1]) by convention matching the example pattern. Medium confidence because the exact segment this applies to is not specified in the condition text, but QTY is the standard target for quantity format conditions. (medium confidence)
    fn evaluate_902(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.format_check("QTY", 0, 1, |val| validate_numeric(val, ">=", 0.0))
    }

    /// [903] Format: Möglicher Wert: 1
    // REVIEW: Format condition requiring the value to equal exactly 1. Applied to QTY segment value (elements[0][1]) by convention. Medium confidence as the exact target segment is not stated, but QTY quantity value is the standard target for this kind of format constraint. (medium confidence)
    fn evaluate_903(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.format_check("QTY", 0, 1, |val| validate_numeric(val, "==", 1.0))
    }

    /// [930] Format: max. 2 Nachkommastellen
    // REVIEW: Format condition requiring at most 2 decimal places. Applied to QTY segment value (elements[0][1]) following the standard pattern from example 19. Medium confidence as the exact target segment is not specified in the condition text, but QTY quantity value is the canonical target for decimal place constraints. (medium confidence)
    fn evaluate_930(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.format_check("QTY", 0, 1, |val| validate_max_decimal_places(val, 2))
    }

    /// [931] Format: ZZZ = +00
    fn evaluate_931(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.format_check("DTM", 0, 1, validate_timezone_utc)
    }

    /// [932] Format: HHMM = 2200
    fn evaluate_932(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.format_check("DTM", 0, 1, |val| validate_hhmm_equals(val, "2200"))
    }

    /// [933] Format: HHMM = 2300
    fn evaluate_933(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.format_check("DTM", 0, 1, |val| validate_hhmm_equals(val, "2300"))
    }

    /// [934] Format: HHMM = 0400
    fn evaluate_934(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.format_check("DTM", 0, 1, |val| validate_hhmm_equals(val, "0400"))
    }

    /// [935] Format: HHMM = 0500
    fn evaluate_935(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.format_check("DTM", 0, 1, |val| validate_hhmm_equals(val, "0500"))
    }

    /// [939] Format: Die Zeichenkette muss die Zeichen @ und . enthalten
    // REVIEW: Format condition checking that the string contains '@' and '.' — characteristic of an email address format requirement. Applied to COM segment with EM (Electronic Mail) qualifier where elements[0][0] is the address and elements[0][1] is the communication means type code. Returns Unknown when no COM+EM segment is found (condition not applicable). (medium confidence)
    fn evaluate_939(&self, ctx: &EvaluationContext) -> ConditionResult {
        // Format: string must contain '@' and '.' — email address format check
        // Applied to COM segment with EM (Electronic Mail) qualifier
        // COM+address:qualifier → elements[0] = ["address", "qualifier"]
        let com_segs = ctx.find_segments("COM");
        for seg in &com_segs {
            if let Some(elem0) = seg.elements.first() {
                if elem0.get(1).map(|q| q == "EM").unwrap_or(false) {
                    let value = elem0.first().map(|s| s.as_str()).unwrap_or("");
                    if value.is_empty() {
                        return ConditionResult::Unknown;
                    }
                    return ConditionResult::from(value.contains('@') && value.contains('.'));
                }
            }
        }
        ConditionResult::Unknown
    }

    /// [940] Format: Die Zeichenkette muss mit dem Zeichen + beginnen und danach dürfen nur noch Ziffern folgen
    // REVIEW: Format condition checking that the string starts with '+' and contains only digits afterwards — the international phone number format (e.g. +4912345678). Applied to COM segments with phone-type qualifiers (TE=Telephone, FX=Telefax, AH=After Hours). Returns Unknown when no COM segment with a phone qualifier is found. Requires at least one digit after '+' (len > 1) since a bare '+' is not a valid phone number. (medium confidence)
    fn evaluate_940(&self, ctx: &EvaluationContext) -> ConditionResult {
        // Format: string must start with '+' and be followed only by digits — international phone number format
        // Applied to COM segments with phone-type qualifiers: TE (Telephone), FX (Telefax), AH (After Hours)
        // COM+number:qualifier → elements[0] = ["number", "qualifier"]
        let com_segs = ctx.find_segments("COM");
        for seg in &com_segs {
            if let Some(elem0) = seg.elements.first() {
                let qualifier = elem0.get(1).map(|s| s.as_str()).unwrap_or("");
                if matches!(qualifier, "TE" | "FX" | "AH") {
                    let value = elem0.first().map(|s| s.as_str()).unwrap_or("");
                    if value.is_empty() {
                        return ConditionResult::Unknown;
                    }
                    return ConditionResult::from(
                        value.starts_with('+')
                            && value.len() > 1
                            && value[1..].chars().all(|c| c.is_ascii_digit()),
                    );
                }
            }
        }
        ConditionResult::Unknown
    }

    /// [2036] Pro Nachricht ist die SG27 genau einmal anzugeben
    // REVIEW: Cardinality condition requiring SG27 to appear exactly once per message. SG27 is the transaction group (tx_group) in ORDRSP FV2510. Uses the group navigator to count SG27 instances at the top level. Falls back to Unknown when no navigator is available (e.g., when context is used without a pre-assembled tree). This is a structural cardinality rule rather than a content condition. (medium confidence)
    fn evaluate_2036(&self, ctx: &EvaluationContext) -> ConditionResult {
        // SG27 must appear exactly once per message
        // SG27 is the transaction group (tx_group) in ORDRSP
        if let Some(nav) = ctx.navigator() {
            let count = nav.group_instance_count(&["SG27"]);
            ConditionResult::from(count == 1)
        } else {
            ConditionResult::Unknown
        }
    }
}