automapper-validation 0.3.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
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
// <auto-generated>
// Generated by automapper-generator generate-conditions
// AHB: xml-migs-and-ahbs/FV2604/UTILMD_AHB_Gas_1_1_außerordentliche_20251211.xml
// Generated: 2026-03-12T11:40:25Z
// </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::{ConditionEvaluator, ConditionResult, EvaluationContext};

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

impl Default for UtilmdGasConditionEvaluatorFV2604 {
    fn default() -> Self {
        let mut external_conditions = std::collections::HashSet::new();
        external_conditions.insert(1);
        external_conditions.insert(3);
        external_conditions.insert(4);
        external_conditions.insert(5);
        external_conditions.insert(14);
        external_conditions.insert(17);
        external_conditions.insert(29);
        external_conditions.insert(39);
        external_conditions.insert(51);
        external_conditions.insert(65);
        external_conditions.insert(92);
        external_conditions.insert(98);
        external_conditions.insert(108);
        external_conditions.insert(127);
        external_conditions.insert(129);
        external_conditions.insert(133);
        external_conditions.insert(147);
        external_conditions.insert(165);
        external_conditions.insert(166);
        external_conditions.insert(219);
        external_conditions.insert(241);
        external_conditions.insert(268);
        external_conditions.insert(283);
        external_conditions.insert(315);
        external_conditions.insert(324);
        external_conditions.insert(336);
        external_conditions.insert(427);
        Self {
            external_conditions,
        }
    }
}

impl ConditionEvaluator for UtilmdGasConditionEvaluatorFV2604 {
    fn message_type(&self) -> &str {
        "UTILMD_Gas"
    }

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

    fn evaluate(&self, condition: u32, ctx: &EvaluationContext) -> ConditionResult {
        match condition {
            1 => self.evaluate_1(ctx),
            2 => self.evaluate_2(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),
            19 => self.evaluate_19(ctx),
            24 => self.evaluate_24(ctx),
            25 => self.evaluate_25(ctx),
            26 => self.evaluate_26(ctx),
            28 => self.evaluate_28(ctx),
            29 => self.evaluate_29(ctx),
            32 => self.evaluate_32(ctx),
            33 => self.evaluate_33(ctx),
            35 => self.evaluate_35(ctx),
            36 => self.evaluate_36(ctx),
            37 => self.evaluate_37(ctx),
            39 => self.evaluate_39(ctx),
            46 => self.evaluate_46(ctx),
            47 => self.evaluate_47(ctx),
            48 => self.evaluate_48(ctx),
            51 => self.evaluate_51(ctx),
            58 => self.evaluate_58(ctx),
            64 => self.evaluate_64(ctx),
            65 => self.evaluate_65(ctx),
            66 => self.evaluate_66(ctx),
            68 => self.evaluate_68(ctx),
            69 => self.evaluate_69(ctx),
            70 => self.evaluate_70(ctx),
            77 => self.evaluate_77(ctx),
            78 => self.evaluate_78(ctx),
            81 => self.evaluate_81(ctx),
            84 => self.evaluate_84(ctx),
            92 => self.evaluate_92(ctx),
            98 => self.evaluate_98(ctx),
            106 => self.evaluate_106(ctx),
            108 => self.evaluate_108(ctx),
            123 => self.evaluate_123(ctx),
            127 => self.evaluate_127(ctx),
            128 => self.evaluate_128(ctx),
            129 => self.evaluate_129(ctx),
            130 => self.evaluate_130(ctx),
            133 => self.evaluate_133(ctx),
            137 => self.evaluate_137(ctx),
            138 => self.evaluate_138(ctx),
            147 => self.evaluate_147(ctx),
            165 => self.evaluate_165(ctx),
            166 => self.evaluate_166(ctx),
            200 => self.evaluate_200(ctx),
            202 => self.evaluate_202(ctx),
            203 => self.evaluate_203(ctx),
            205 => self.evaluate_205(ctx),
            209 => self.evaluate_209(ctx),
            212 => self.evaluate_212(ctx),
            213 => self.evaluate_213(ctx),
            216 => self.evaluate_216(ctx),
            219 => self.evaluate_219(ctx),
            230 => self.evaluate_230(ctx),
            241 => self.evaluate_241(ctx),
            249 => self.evaluate_249(ctx),
            252 => self.evaluate_252(ctx),
            257 => self.evaluate_257(ctx),
            268 => self.evaluate_268(ctx),
            274 => self.evaluate_274(ctx),
            276 => self.evaluate_276(ctx),
            277 => self.evaluate_277(ctx),
            283 => self.evaluate_283(ctx),
            315 => self.evaluate_315(ctx),
            324 => self.evaluate_324(ctx),
            328 => self.evaluate_328(ctx),
            333 => self.evaluate_333(ctx),
            336 => self.evaluate_336(ctx),
            345 => self.evaluate_345(ctx),
            361 => self.evaluate_361(ctx),
            362 => self.evaluate_362(ctx),
            367 => self.evaluate_367(ctx),
            368 => self.evaluate_368(ctx),
            427 => self.evaluate_427(ctx),
            442 => self.evaluate_442(ctx),
            490 => self.evaluate_490(ctx),
            491 => self.evaluate_491(ctx),
            494 => self.evaluate_494(ctx),
            500 => self.evaluate_500(ctx),
            501 => self.evaluate_501(ctx),
            502 => self.evaluate_502(ctx),
            504 => self.evaluate_504(ctx),
            505 => self.evaluate_505(ctx),
            507 => self.evaluate_507(ctx),
            508 => self.evaluate_508(ctx),
            510 => self.evaluate_510(ctx),
            511 => self.evaluate_511(ctx),
            513 => self.evaluate_513(ctx),
            527 => self.evaluate_527(ctx),
            528 => self.evaluate_528(ctx),
            530 => self.evaluate_530(ctx),
            556 => self.evaluate_556(ctx),
            558 => self.evaluate_558(ctx),
            559 => self.evaluate_559(ctx),
            560 => self.evaluate_560(ctx),
            566 => self.evaluate_566(ctx),
            567 => self.evaluate_567(ctx),
            570 => self.evaluate_570(ctx),
            571 => self.evaluate_571(ctx),
            572 => self.evaluate_572(ctx),
            581 => self.evaluate_581(ctx),
            583 => self.evaluate_583(ctx),
            584 => self.evaluate_584(ctx),
            590 => self.evaluate_590(ctx),
            601 => self.evaluate_601(ctx),
            621 => self.evaluate_621(ctx),
            622 => self.evaluate_622(ctx),
            636 => self.evaluate_636(ctx),
            637 => self.evaluate_637(ctx),
            638 => self.evaluate_638(ctx),
            643 => self.evaluate_643(ctx),
            644 => self.evaluate_644(ctx),
            651 => self.evaluate_651(ctx),
            654 => self.evaluate_654(ctx),
            655 => self.evaluate_655(ctx),
            902 => self.evaluate_902(ctx),
            907 => self.evaluate_907(ctx),
            912 => self.evaluate_912(ctx),
            930 => self.evaluate_930(ctx),
            931 => self.evaluate_931(ctx),
            934 => self.evaluate_934(ctx),
            935 => self.evaluate_935(ctx),
            937 => self.evaluate_937(ctx),
            938 => self.evaluate_938(ctx),
            950 => self.evaluate_950(ctx),
            951 => self.evaluate_951(ctx),
            952 => self.evaluate_952(ctx),
            953 => self.evaluate_953(ctx),
            2061 => self.evaluate_2061(ctx),
            2119 => self.evaluate_2119(ctx),
            2284 => self.evaluate_2284(ctx),
            2286 => self.evaluate_2286(ctx),
            2287 => self.evaluate_2287(ctx),
            2335 => self.evaluate_2335(ctx),
            2353 => self.evaluate_2353(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 | 2
                | 3
                | 4
                | 5
                | 7
                | 9
                | 10
                | 11
                | 12
                | 13
                | 14
                | 15
                | 16
                | 17
                | 18
                | 19
                | 24
                | 25
                | 26
                | 28
                | 29
                | 32
                | 33
                | 35
                | 36
                | 37
                | 39
                | 46
                | 47
                | 48
                | 51
                | 58
                | 64
                | 65
                | 66
                | 68
                | 69
                | 70
                | 77
                | 78
                | 81
                | 84
                | 92
                | 98
                | 106
                | 108
                | 123
                | 127
                | 128
                | 129
                | 130
                | 133
                | 137
                | 138
                | 147
                | 165
                | 166
                | 200
                | 202
                | 203
                | 205
                | 209
                | 212
                | 213
                | 216
                | 219
                | 230
                | 241
                | 249
                | 252
                | 257
                | 268
                | 274
                | 276
                | 277
                | 283
                | 315
                | 324
                | 328
                | 333
                | 336
                | 345
                | 361
                | 362
                | 367
                | 368
                | 427
                | 442
                | 490
                | 491
                | 494
                | 500
                | 501
                | 502
                | 504
                | 505
                | 507
                | 508
                | 510
                | 511
                | 513
                | 527
                | 528
                | 530
                | 556
                | 558
                | 559
                | 560
                | 566
                | 567
                | 570
                | 571
                | 572
                | 581
                | 583
                | 584
                | 590
                | 601
                | 621
                | 622
                | 636
                | 637
                | 638
                | 643
                | 644
                | 651
                | 654
                | 655
                | 902
                | 907
                | 912
                | 930
                | 931
                | 934
                | 935
                | 937
                | 938
                | 950
                | 951
                | 952
                | 953
                | 2061
                | 2119
                | 2284
                | 2286
                | 2287
                | 2335
                | 2353
        )
    }
}

impl UtilmdGasConditionEvaluatorFV2604 {
    /// [2] Wenn UNH DE0070 (Übermittlungsfolgenummer) mit 1 vorhanden
    fn evaluate_2(&self, ctx: &EvaluationContext) -> ConditionResult {
        let unh_segs = ctx.find_segments("UNH");
        match unh_segs.first() {
            Some(unh) => match unh.elements.get(3).and_then(|e| e.first()) {
                Some(val) => ConditionResult::from(val == "1"),
                None => ConditionResult::False,
            },
            None => ConditionResult::False, // segment absent → condition not applicable
        }
    }

    /// [3] Bei Aufteilung, in der Nachricht mit der höchsten Übermittlungsfolgenummer
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_3(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("is_highest_sequence_number_in_split")
    }

    /// [203] Wenn STS+7++E06 / Z39 / ZC6 / ZC7 / ZT6 / ZT7
    fn evaluate_203(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualified_value(
            "STS",
            0,
            "7",
            2,
            0,
            &["E06", "Z39", "ZC6", "ZC7", "ZT6", "ZT7"],
        )
    }

    /// [315] Es sind alle OBISKennzahlen gem. EDI@Energy Codeliste der OBIS-Kennzahlen und Medien für den deutschen Energiemarkt Kap. 4 anzugeben welche an der Marktlokation erforderlich sind, dabei muss der M...
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_315(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("obis_kennzahlen_mindestumfang_valid")
    }

    /// [324] Es sind alle OBIS-Kennzahlen gem. EDI@Energy Codeliste der OBIS Kennzahlen Kap. 4. anzugeben welche an der Zähleinrichtung genutzt werden. Der Mindestumfang der OBIS-Kennzahlen ergibt sich aus den...
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_324(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external
            .evaluate("zaehler_obis_kennzahlen_mindestumfang_valid")
    }

    /// [328] Wenn IMD++Z36+Z12 (Identifikationslogik: Marktlokations-ID) vorhanden
    fn evaluate_328(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_segment_matching("IMD", &[(1, 0, "Z36"), (2, 0, "Z12")])
    }

    /// [333] Wenn IMD+Z36+Z13 (Identifikationslogik: Alle Identifikationsdaten) vorhanden
    fn evaluate_333(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_segment_matching("IMD", &[(1, 0, "Z36"), (2, 0, "Z13")])
    }

    /// [502] Hinweis:  Ersatzbelieferung gibt es nur bei  - Marktlokationen in der  Niederdruckebene, die kein Haushaltskunde gem. EnWG sind und die nicht mehr der gesetzlichen Ersatzversorgung (drei Monate) un...
    fn evaluate_502(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Ersatzbelieferung gibt es nur bei Marktlokationen in der Niederdruckebene, die kein Haushaltskunde gem. EnWG sind und die nicht mehr der gesetzlichen Ersatzversorgung unterliegen, und für Marktlokationen in Mitteldruck. Grundlage ist die bilaterale Vereinbarung — informational note, always applies
        ConditionResult::True
    }

    /// [504] Hinweis: Der Code Z22 wird auch in der Sparte Strom genutzt. Der Verweis auf den Einspeisevergütungsintervall ist in der Sparte Gas nicht relevant
    fn evaluate_504(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Code Z22 wird auch in der Sparte Strom genutzt. Der Verweis auf den Einspeisevergütungsintervall ist in der Sparte Gas nicht relevant — informational note, always applies
        ConditionResult::True
    }

    /// [505] Hinweis: Übergangsversorgung gibt es nur bei Marktlokationen, die unter § 38a EnWG fallen. Grundlage ist eine bilaterale Vereinbarung
    fn evaluate_505(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Übergangsversorgung gibt es nur bei Marktlokationen, die unter § 38a EnWG fallen. Grundlage ist eine bilaterale Vereinbarung — informational note, always applies
        ConditionResult::True
    }

    /// [511] Hinweis: Zu verwenden bei der Abmeldung der Übergangsversorgung
    fn evaluate_511(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Zu verwenden bei der Abmeldung der Übergangsversorgung — informational note, always applies
        ConditionResult::True
    }

    /// [1] Wenn Aufteilung vorhanden
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_1(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("message_splitting")
    }

    /// [4] Wenn MP-ID in SG2 NAD+MR (Nachrichtenempfänger) in der Rolle LF
    /// 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 SG2 NAD+MS (Nachrichtenabsender) in der Rolle LF
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_5(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("sender_is_lf")
    }

    /// [7] Wenn SG4 STS+7++ZG9/ZH1/ZH2 (Transaktionsgrund: Aufhebung einer zukünftigen Zuordnung wegen Auszug des Kunden / -wegen Stilllegung / -wegen aufgehobenem Vertragsverhältnis) vorhanden
    fn evaluate_7(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualified_value("STS", 0, "7", 2, 0, &["ZG9", "ZH1", "ZH2"])
    }

    /// [9] Wenn SG4 STS+7++ZE4 (Transaktionsgrund: Weggefallene Markt- bzw. Messlokation) nicht vorhanden
    fn evaluate_9(&self, ctx: &EvaluationContext) -> ConditionResult {
        match ctx.has_qualified_value("STS", 0, "7", 2, 0, &["ZE4"]) {
            ConditionResult::True => ConditionResult::False,
            ConditionResult::False | ConditionResult::Unknown => ConditionResult::True,
        }
    }

    /// [10] Wenn SG4 STS+Z17 (Transaktionsgrund für befristete Anmeldung) vorhanden
    fn evaluate_10(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualifier("STS", 0, "Z17")
    }

    /// [11] Wenn SG4 STS+7++ZG9/ZH1/ZH2 (Transaktionsgrund: Aufhebung einer zukünftigen Zuordnung wegen Auszug des Kunden / -wegen Stilllegung / -wegen aufgehobenem Vertragsverhältnis) nicht vorhanden
    fn evaluate_11(&self, ctx: &EvaluationContext) -> ConditionResult {
        match ctx.has_qualified_value("STS", 0, "7", 2, 0, &["ZG9", "ZH1", "ZH2"]) {
            ConditionResult::True => ConditionResult::False,
            ConditionResult::False | ConditionResult::Unknown => ConditionResult::True,
        }
    }

    /// [12] Wenn SG4 DTM+471 (Ende zum nächstmöglichem Termin) nicht vorhanden
    fn evaluate_12(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.lacks_qualifier("DTM", 0, "471")
    }

    /// [13] Wenn SG4 STS+E01++Z01 (Status der Antwort: Zustimmung mit Terminänderung) nicht vorhanden
    fn evaluate_13(&self, ctx: &EvaluationContext) -> ConditionResult {
        match ctx.has_qualified_value("STS", 0, "E01", 2, 0, &["Z01"]) {
            ConditionResult::True => ConditionResult::False,
            ConditionResult::False | ConditionResult::Unknown => ConditionResult::True,
        }
    }

    /// [14] Wenn Datum bekannt
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_14(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("date_known")
    }

    /// [15] Wenn SG4 STS+E01++Z34 (Status der Antwort: Ablehnung Mehrfachkündigung) vorhanden
    fn evaluate_15(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualified_value("STS", 0, "E01", 2, 0, &["Z34"])
    }

    /// [16] Wenn SG4 STS+E01++Z12 (Status der Antwort: Ablehnung Vertragsbindung) vorhanden
    fn evaluate_16(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualified_value("STS", 0, "E01", 2, 0, &["Z12"])
    }

    /// [17] Wenn bereits eine bestätigte Kündigung durch Kunde oder MP vorhanden
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_17(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("confirmed_cancellation_present")
    }

    /// [18] Wenn SG4 DTM+93 (Ende zum) nicht vorhanden
    fn evaluate_18(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.lacks_qualifier("DTM", 0, "93")
    }

    /// [19] Wenn SG8 SEQ+Z01 (Daten der Marktlokation) SG10 CCI+++ZC0 (Prognose auf Basis von Werten) vorhanden
    fn evaluate_19(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.filtered_parent_child_has_qualifier(
            &["SG4", "SG8"],
            "SEQ",
            0,
            "Z01",
            "SG10",
            "CCI",
            2,
            "ZC0",
        )
    }

    /// [24] Wenn SG6 DTM+Z21 (Termin der Netznutzungsabrechnung) vorhanden
    fn evaluate_24(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualifier("DTM", 0, "Z21")
    }

    /// [25] Wenn der Meldepunkt im SG5 LOC+172 (Meldepunkt) DE3225 das Format der Marktlokations-ID hat
    // REVIEW: Marktlokations-ID in German gas market is a numeric (all-digit) identifier. LOC+172 has elements[0][0]='172', elements[1][0]=DE3225. Checks if value consists entirely of ASCII digits. Returns Unknown if no LOC+172 exists. (medium confidence)
    fn evaluate_25(&self, ctx: &EvaluationContext) -> ConditionResult {
        let segs = ctx.find_segments_with_qualifier("LOC", 0, "172");
        if segs.is_empty() {
            return ConditionResult::Unknown;
        }
        for seg in &segs {
            if let Some(val) = seg.elements.get(1).and_then(|e| e.first()) {
                if !val.is_empty() && val.chars().all(|c| c.is_ascii_digit()) {
                    return ConditionResult::True;
                }
            }
        }
        ConditionResult::False
    }

    /// [26] Wenn der Meldepunkt im SG5 LOC+172 (Meldepunkt) DE3225 das Format der Zählpunktbezeichnung hat
    // REVIEW: Zählpunktbezeichnung format contains non-digit characters (typically alphanumeric string). Negates condition 25's all-digit check. Returns True if DE3225 of LOC+172 is non-empty and contains at least one non-digit character. (medium confidence)
    fn evaluate_26(&self, ctx: &EvaluationContext) -> ConditionResult {
        let segs = ctx.find_segments_with_qualifier("LOC", 0, "172");
        if segs.is_empty() {
            return ConditionResult::Unknown;
        }
        for seg in &segs {
            if let Some(val) = seg.elements.get(1).and_then(|e| e.first()) {
                if !val.is_empty() && !val.chars().all(|c| c.is_ascii_digit()) {
                    return ConditionResult::True;
                }
            }
        }
        ConditionResult::False
    }

    /// [28] Wenn SG4 DTM+93 (Ende zum) vorhanden
    fn evaluate_28(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualifier("DTM", 0, "93")
    }

    /// [29] Wenn eine Bilanzierung stattfindet
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_29(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("balancing_takes_place")
    }

    /// [32] Wenn BGM+E03 (Änderungsmeldungen) vorhanden
    fn evaluate_32(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualifier("BGM", 0, "E03")
    }

    /// [33] Wenn in Abmeldung ein Bilanzierungsende vorhanden
    // REVIEW: Wenn in Abmeldung ein Bilanzierungsende vorhanden: BGM+E02 identifies the message as Abmeldung (de-registration), DTM+159 is Bilanzierungsende. Both must coexist. (medium confidence)
    fn evaluate_33(&self, ctx: &EvaluationContext) -> ConditionResult {
        let has_abmeldung = !ctx.find_segments_with_qualifier("BGM", 0, "E02").is_empty();
        let has_bilanzierungsende = !ctx.find_segments_with_qualifier("DTM", 0, "159").is_empty();
        ConditionResult::from(has_abmeldung && has_bilanzierungsende)
    }

    /// [35] Wenn das DE2380 von SG4 DTM+Z01 (Kündigungsfrist des Vertrags) an vierter Stelle T (Termin) enthält
    fn evaluate_35(&self, ctx: &EvaluationContext) -> ConditionResult {
        let segs = ctx.find_segments_with_qualifier("DTM", 0, "Z01");
        match segs.first() {
            Some(dtm) => {
                match dtm
                    .elements
                    .first()
                    .and_then(|e| e.get(1))
                    .map(|s| s.as_str())
                {
                    Some(value) => match value.chars().nth(3) {
                        Some('T') => ConditionResult::True,
                        Some(_) => ConditionResult::False,
                        None => ConditionResult::False, // segment absent → condition not applicable
                    },
                    None => ConditionResult::False, // segment absent → condition not applicable
                }
            }
            None => ConditionResult::False, // segment absent → condition not applicable
        }
    }

    /// [36] Wenn SG4 STS+E01++ZC5 (Status der Antwort: Ablehnung andere Anmeldung in Bearbeitung) vorhanden
    fn evaluate_36(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualified_value("STS", 0, "E01", 2, 0, &["ZC5"])
    }

    /// [37] Wenn Anmeldung/ Änderung befristet
    fn evaluate_37(&self, ctx: &EvaluationContext) -> ConditionResult {
        // Same check as [10]: STS+Z17 indicates befristete Anmeldung in Gas
        ctx.has_qualifier("STS", 0, "Z17")
    }

    /// [39] Wenn LF beabsichtigt Zählerstand zu übermitteln
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_39(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external
            .evaluate("lf_intends_to_transmit_meter_reading")
    }

    /// [46] Wenn in SG8 SEQ+Z35 ein SG10 CCI+Z12 (Lastprofil) CAV (Lastprofil) DE3055 der Wert 293 enthalten ist
    // REVIEW: In SG8 with SEQ+Z35 (Lastprofildaten), check SG10 children for CCI+Z12 (Lastprofil, elements[0][0]='Z12') AND a Klimazone CCI with DE3055=293 at elements[2][2] (responsible agency code = BDEW/GS1-DE). Uses collect_group_values to find Z35 SG8 instances by index, then navigator for SG10 child traversal. (medium confidence)
    fn evaluate_46(&self, ctx: &EvaluationContext) -> ConditionResult {
        let seq_values = ctx.collect_group_values("SEQ", 0, 0, &["SG4", "SG8"]);
        let z35_instances: Vec<usize> = seq_values
            .iter()
            .filter(|(_, v)| v == "Z35")
            .map(|(i, _)| *i)
            .collect();
        if z35_instances.is_empty() {
            return ConditionResult::False;
        }
        let nav = match ctx.navigator() {
            Some(n) => n,
            None => return ConditionResult::Unknown,
        };
        for i in z35_instances {
            let sg10_count = nav.child_group_instance_count(&["SG4", "SG8"], i, "SG10");
            for j in 0..sg10_count {
                let ccis = nav.find_segments_in_child_group("CCI", &["SG4", "SG8"], i, "SG10", j);
                let has_z12 = ccis.iter().any(|s| {
                    s.elements
                        .first()
                        .and_then(|e| e.first())
                        .is_some_and(|v| v == "Z12")
                });
                if !has_z12 {
                    continue;
                }
                // Check Klimazone CCI (Z99/ZA0) for DE3055=293 at elements[2][2]
                let has_293 = ccis.iter().any(|s| {
                    s.elements
                        .get(2)
                        .and_then(|e| e.get(2))
                        .is_some_and(|v| v == "293")
                });
                if has_293 {
                    return ConditionResult::True;
                }
            }
        }
        ConditionResult::False
    }

    /// [47] Wenn in SG8 SEQ+Z35 ein SG10 CCI+Z12 (Lastprofil) CAV (Lastprofil) DE3055 der Wert 293 nicht enthalten ist
    // REVIEW: Logical negation of condition 46: CCI+Z12 Klimazone DE3055=293 NOT present in SG10 under SG8+Z35. Propagates Unknown to maintain three-valued semantics. (medium confidence)
    fn evaluate_47(&self, ctx: &EvaluationContext) -> ConditionResult {
        match self.evaluate_46(ctx) {
            ConditionResult::True => ConditionResult::False,
            ConditionResult::False => ConditionResult::True,
            ConditionResult::Unknown => ConditionResult::Unknown,
        }
    }

    /// [48] Wenn in dieser SG4 das STS+E01++E14 (Status der Antwort: Ablehnung Sonstiges) vorhanden
    fn evaluate_48(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualified_value("STS", 0, "E01", 2, 0, &["E14"])
    }

    /// [51] Bei rückwirkendem Lieferende/Lieferbeginn
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_51(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("retroactive_delivery_change")
    }

    /// [58] Wenn in diesem CCI das DE3055 mit dem Code 293 vorhanden
    // REVIEW: DE3055 (Verantwortliche Stelle für die Codepflege) appears at CCI elements[2][2] in CCI — Klimazone/Temperaturmessstelle. Checks any CCI in the message has that code. 'In diesem CCI' implies context-local check; falls back to message-wide. (medium confidence)
    fn evaluate_58(&self, ctx: &EvaluationContext) -> ConditionResult {
        let ccis = ctx.find_segments("CCI");
        ConditionResult::from(ccis.iter().any(|s| {
            s.elements
                .get(2)
                .and_then(|e| e.get(2))
                .is_some_and(|v| v == "293")
        }))
    }

    /// [64] Wenn SG4 DTM+158 (Bilanzierungsbeginn) vorhanden
    fn evaluate_64(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualifier("DTM", 0, "158")
    }

    /// [65] Wenn Marktgebietsüber-lappung besteht, sind alle Bilanzkreise des LF zu melden in denen freie Kapazitäten beim NB bestehen
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_65(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("market_area_overlap_exists")
    }

    /// [66] Wenn SG10 CCI+Z19 (Bilanzkreis) im Vorgang mehr als einmal vorhanden
    fn evaluate_66(&self, ctx: &EvaluationContext) -> ConditionResult {
        let count = ctx.find_segments_with_qualifier("CCI", 0, "Z19").len();
        ConditionResult::from(count > 1)
    }

    /// [68] Wenn SG10 CCI+Z19 (Bilanzkreis) im Vorgang mehr als zweimal vorhanden
    fn evaluate_68(&self, ctx: &EvaluationContext) -> ConditionResult {
        let count = ctx.find_segments_with_qualifier("CCI", 0, "Z19").len();
        ConditionResult::from(count > 2)
    }

    /// [69] Wenn SG10 CCI+Z19 (Bilanzkreis) im Vorgang mehr als dreimal vorhanden
    fn evaluate_69(&self, ctx: &EvaluationContext) -> ConditionResult {
        let count = ctx.find_segments_with_qualifier("CCI", 0, "Z19").len();
        ConditionResult::from(count > 3)
    }

    /// [70] Wenn SG10 CCI+Z19 (Bilanzkreis) im Vorgang fünfmal vorhanden
    fn evaluate_70(&self, ctx: &EvaluationContext) -> ConditionResult {
        let count = ctx.find_segments_with_qualifier("CCI", 0, "Z19").len();
        ConditionResult::from(count == 5)
    }

    /// [77] Wenn SG8 SEQ+Z03 (Zähleinrichtungsdaten) CAV+Z30 (Identifikation/Nummer des Gerätes) nicht vorhanden
    fn evaluate_77(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.any_group_has_qualifier_without("SEQ", 0, "Z03", "CAV", 0, "Z30", &["SG4", "SG8"])
    }

    /// [78] Wenn SG4 STS+7++E02 (Transaktionsgrund: Einzug in Neuanlage) nicht vorhanden
    fn evaluate_78(&self, ctx: &EvaluationContext) -> ConditionResult {
        let result = ctx.has_qualified_value("STS", 0, "7", 2, 0, &["E02"]);
        match result {
            ConditionResult::True => ConditionResult::False,
            ConditionResult::False => ConditionResult::True,
            ConditionResult::Unknown => ConditionResult::Unknown,
        }
    }

    /// [81] Wenn SG4 FTX+ABO+Z05 (Beschreibung der Abweichung zur übermittelten Liste: Änderung vorhanden) vorhanden
    fn evaluate_81(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualified_value("FTX", 0, "ABO", 2, 0, &["Z05"])
    }

    /// [84] Wenn SG4 STS+E01++Z35 (Status der Antwort: Ablehnung der Abmeldeanfrage) vorhanden
    fn evaluate_84(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualified_value("STS", 0, "E01", 2, 0, &["Z35"])
    }

    /// [92] Wenn Wert innerhalb SG bzw. Segment geändert wird
    /// EXTERNAL: Requires context from outside the message.
    // REVIEW: 'Wenn Wert innerhalb SG bzw. Segment geändert wird' — whether a value was changed compared to a prior state cannot be determined from the EDIFACT message alone; requires external business context comparing current vs previous transmission. (medium confidence)
    fn evaluate_92(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("value_changed_in_segment")
    }

    /// [98] Wenn MP-ID in SG2 NAD+MS (Nachrichtenabsender) in der Rolle NB
    /// EXTERNAL: Requires context from outside the message.
    // REVIEW: 'Wenn MP-ID in SG2 NAD+MS in der Rolle NB' — while we can confirm NAD+MS exists in the message, determining whether that market participant ID is registered in the role of Netzbetreiber (NB) requires an external role/master-data lookup. Cannot be derived from the EDIFACT message content alone. (medium confidence)
    fn evaluate_98(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("sender_is_nb")
    }

    /// [106] Wenn in dieser SG8 SEQ+Z01 SG10 CCI+++ZA6 (Prognosegrundlage der Marktlokation: Prognose auf Basis von Profilen) vorhanden
    fn evaluate_106(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.filtered_parent_child_has_qualifier(
            &["SG4", "SG8"],
            "SEQ",
            0,
            "Z01",
            "SG10",
            "CCI",
            2,
            "ZA6",
        )
    }

    /// [108] Wenn Kundenwertverfahren (z. B. TU München)
    /// EXTERNAL: Requires context from outside the message.
    // REVIEW: Kundenwertverfahren (e.g., TU München) is a specific billing methodology determined by contract terms, not derivable from the EDIFACT message content itself. (medium confidence)
    fn evaluate_108(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("kundenwertverfahren")
    }

    /// [123] Wenn noch mindestens eine weitere SG8 SEQ+Z20 (OBIS-Daten der Zähleinrichtung / Mengenumwerter) mit dem SG8 RFF+MG / Z11 (Gerätenummer des Zählers / Mengenumwerters) auf die gleiche Identifikati...
    // REVIEW: Collects device IDs (via RFF+MG or RFF+Z11) from all SG8 instances that have SEQ+Z20. Returns True if any device ID appears in at least two such instances, indicating at least one further SG8 references the same device. Requires navigator for proper group-scoped traversal. (medium confidence)
    fn evaluate_123(&self, ctx: &EvaluationContext) -> ConditionResult {
        let nav = match ctx.navigator() {
            Some(n) => n,
            None => {
                let seqs = ctx.find_segments_with_qualifier("SEQ", 0, "Z20");
                if seqs.len() < 2 {
                    return ConditionResult::False;
                }
                return ConditionResult::Unknown;
            }
        };
        let sg8_count = nav.group_instance_count(&["SG4", "SG8"]);
        let mut device_ids: Vec<String> = Vec::new();
        for i in 0..sg8_count {
            let seqs = nav.find_segments_in_group("SEQ", &["SG4", "SG8"], i);
            let has_z20 = seqs.iter().any(|s| {
                s.elements
                    .first()
                    .and_then(|e| e.first())
                    .is_some_and(|v| v == "Z20")
            });
            if !has_z20 {
                continue;
            }
            let rffs = nav.find_segments_in_group("RFF", &["SG4", "SG8"], i);
            for rff in &rffs {
                let qual = rff
                    .elements
                    .first()
                    .and_then(|e| e.first())
                    .map(|s| s.as_str());
                if matches!(qual, Some("MG") | Some("Z11")) {
                    if let Some(id) = rff.elements.first().and_then(|e| e.get(1)) {
                        if !id.is_empty() {
                            device_ids.push(id.clone());
                        }
                    }
                }
            }
        }
        for i in 0..device_ids.len() {
            for j in (i + 1)..device_ids.len() {
                if device_ids[i] == device_ids[j] {
                    return ConditionResult::True;
                }
            }
        }
        ConditionResult::False
    }

    /// [127] Hat der Lieferant auf Grund seines Vertrags Kenntnis, dass der Kunde keine hohe KA hat so muss er dies dem NB mitteilen
    /// EXTERNAL: Requires context from outside the message.
    // REVIEW: Whether the supplier knows from their contract that the customer has no high KA (Kapazitätsanteil) is contract-based knowledge external to the EDIFACT message. Cannot be determined from segment data alone. (medium confidence)
    fn evaluate_127(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("supplier_knows_no_high_ka")
    }

    /// [128] Wenn SG10 CAV+TAS/ TKS/ SAS/ KAS vorhanden
    fn evaluate_128(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.any_group_has_any_qualifier(
            "CAV",
            0,
            &["TAS", "TKS", "SAS", "KAS"],
            &["SG4", "SG8", "SG10"],
        )
    }

    /// [129] Hat der Lieferant auf Grund seines Vertrags Kenntnis über die Höhe der Sonder-KA, so muss er diesen dem NB mitteilen
    /// EXTERNAL: Requires context from outside the message.
    // REVIEW: Whether the supplier has contract knowledge about the amount of a special KA (Sonder-Kapazitätsanteil) is contract-based knowledge. Cannot be derived from the EDIFACT message. (medium confidence)
    fn evaluate_129(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("supplier_knows_special_ka_amount")
    }

    /// [130] Wenn an Messlokation vorhanden
    // REVIEW: 'Wenn an Messlokation vorhanden' is interpreted as: a Messlokation section exists in the message, indicated by SEQ+Z18 (Daten der Messlokation) in SG8. Returns True when such a section is present. (medium confidence)
    fn evaluate_130(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualifier("SEQ", 0, "Z18")
    }

    /// [133] Wenn an der übermittelten Marktlokation / Messlokation vorhanden
    /// EXTERNAL: Requires context from outside the message.
    // REVIEW: 'Wenn an der übermittelten Marktlokation / Messlokation vorhanden' — whether a specific data element exists at the transmitted market or metering location is a business/registry lookup that cannot be determined from the EDIFACT message content alone. Marked external. (medium confidence)
    fn evaluate_133(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("at_marktlokation_or_messlokation")
    }

    /// [137] Nicht bei Neuanlage
    // REVIEW: 'Nicht bei Neuanlage' — the condition is True when the transaction reason is NOT E02 (Neubau / new installation). Finds STS with elements[0][0]="7" (Transaktionsgrund), checks elements[2][0] for E02, and negates the result. (medium confidence)
    fn evaluate_137(&self, ctx: &EvaluationContext) -> ConditionResult {
        match ctx.has_qualified_value("STS", 0, "7", 2, 0, &["E02"]) {
            ConditionResult::True => ConditionResult::False,
            ConditionResult::False => ConditionResult::True,
            ConditionResult::Unknown => ConditionResult::Unknown,
        }
    }

    /// [138] Wenn SG5 LOC+172 (Meldepunkt) nicht vorhanden
    fn evaluate_138(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.lacks_qualifier("LOC", 0, "172")
    }

    /// [147] Wenn in Anfrage vorhanden
    /// EXTERNAL: Requires context from outside the message.
    // REVIEW: 'Wenn in Anfrage vorhanden' — whether something is present in the original inquiry/request message is a cross-message business context that cannot be determined from the current EDIFACT message alone. Marked external. (medium confidence)
    fn evaluate_147(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("present_in_request")
    }

    /// [165] Wenn bekannt
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_165(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("date_known")
    }

    /// [166] Wenn vorhanden
    /// EXTERNAL: Requires context from outside the message.
    // REVIEW: 'Wenn vorhanden' — generic 'if present/available' without a specific segment reference. When used as a standalone condition this refers to business data availability that cannot be determined from the EDIFACT message structure alone. Marked external. (medium confidence)
    fn evaluate_166(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("data_available")
    }

    /// [200] Wenn BGM+Z26 (Vorläufige Meldung zur Marktraumumstellung) vorhanden
    fn evaluate_200(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualifier("BGM", 0, "Z26")
    }

    /// [202] Wenn SG4 STS+E01+ZG2 (Status der Antwort: Gültiges Ergebnis nach der Datenprüfung) vorhanden
    fn evaluate_202(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualified_value("STS", 0, "E01", 1, 0, &["ZG2"])
    }

    /// [205] Wenn SG9 QTY+Y02 (TUM Kundenwert) nicht vorhanden
    fn evaluate_205(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.lacks_qualifier("QTY", 0, "Y02")
    }

    /// [209] Wenn im selben Segment im DE2379 der Code 303 vorhanden ist
    fn evaluate_209(&self, ctx: &EvaluationContext) -> ConditionResult {
        ConditionResult::from(ctx.self_segment_value_equals("DTM", 0, 2, "303"))
    }

    /// [212] Wenn im selben SG12 NAD DE3124 nicht vorhanden
    // REVIEW: Checks if any NAD in SG12 has DE3124 (C058 first component, elements[2][0]) absent or empty. Without group-scoped navigation, falls back to message-wide NAD check. (medium confidence)
    fn evaluate_212(&self, ctx: &EvaluationContext) -> ConditionResult {
        let nads = ctx.find_segments("NAD");
        ConditionResult::from(nads.iter().any(|s| {
            s.elements
                .get(2)
                .map(|e| e.first().map(|v| v.is_empty()).unwrap_or(true))
                .unwrap_or(true)
        }))
    }

    /// [213] Wenn SG12 NAD+Z09 (Kunde des Lieferanten) vorhanden
    fn evaluate_213(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualifier("NAD", 0, "Z09")
    }

    /// [216] Wenn CCI+++Z88 (Netznutzung) CAV+Z74:::Z08 (Netznutzungsvertrag: Direkter Vertrag zwischen Kunden und NB) vorhanden
    // REVIEW: CCI+++Z88 means elements[2][0]=='Z88' (Netznutzung). CAV+Z74:::Z08 means elements[0][0]=='Z74' and elements[0][3]=='Z08' (Direkter Vertrag). Uses parent-child group navigation to check co-occurrence within the same SG10 instance. (medium confidence)
    fn evaluate_216(&self, ctx: &EvaluationContext) -> ConditionResult {
        let nav = match ctx.navigator() {
            Some(n) => n,
            None => {
                let cavs = ctx.find_segments("CAV");
                return ConditionResult::from(cavs.iter().any(|s| {
                    let e0 = s.elements.first();
                    e0.and_then(|e| e.first()).is_some_and(|v| v == "Z74")
                        && e0.and_then(|e| e.get(3)).is_some_and(|v| v == "Z08")
                }));
            }
        };
        let sg8_count = nav.group_instance_count(&["SG4", "SG8"]);
        for i in 0..sg8_count {
            let sg10_count = nav.child_group_instance_count(&["SG4", "SG8"], i, "SG10");
            for j in 0..sg10_count {
                let ccis = nav.find_segments_in_child_group("CCI", &["SG4", "SG8"], i, "SG10", j);
                let has_cci_z88 = ccis.iter().any(|s| {
                    s.elements
                        .get(2)
                        .and_then(|e| e.first())
                        .is_some_and(|v| v == "Z88")
                });
                if has_cci_z88 {
                    let cavs =
                        nav.find_segments_in_child_group("CAV", &["SG4", "SG8"], i, "SG10", j);
                    if cavs.iter().any(|s| {
                        let e0 = s.elements.first();
                        e0.and_then(|e| e.first()).is_some_and(|v| v == "Z74")
                            && e0.and_then(|e| e.get(3)).is_some_and(|v| v == "Z08")
                    }) {
                        return ConditionResult::True;
                    }
                }
            }
        }
        ConditionResult::False
    }

    /// [219] Wenn an Marktlokation vorhanden
    /// EXTERNAL: Requires context from outside the message.
    // REVIEW: 'Wenn an Marktlokation vorhanden' — whether specific data exists at the market location is a registry/master-data lookup that cannot be derived from the EDIFACT message content. Marked external. (medium confidence)
    fn evaluate_219(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("at_marktlokation")
    }

    /// [230] Sich ergebendes Datum/ bzw. Endedatum des Turnuszeitraums aus DTM+Z21 (Termin der Netznutzungsabrechnung) und DTM+Z09 (Nächste Netznutzungsabrechnung) muss &gt;= DTM+92 (Beginn zum) sein
    // REVIEW: Compares the later of DTM+Z21 and DTM+Z09 (end of Turnuszeitraum) against DTM+92 (start date). Date formats differ across the three DTM qualifiers (Z21=CCYYMM/format 106, Z09=format 602, DTM+92=CCYYMMDDHHMM/format 303), so comparison is normalized to the CCYYMM prefix (first 6 chars). The exact definition of 'sich ergebendes Datum' from Z21+Z09 introduces some ambiguity — using max(Z21,Z09) as the best approximation. (medium confidence)
    fn evaluate_230(&self, ctx: &EvaluationContext) -> ConditionResult {
        {
            // DTM+Z21 (Termin der Netznutzungsabrechnung): elements[0][1], format 106/104
            let z21_val = ctx
                .find_segments_with_qualifier("DTM", 0, "Z21")
                .into_iter()
                .find_map(|s| s.elements.first().and_then(|e| e.get(1)).cloned())
                .unwrap_or_default();
            // DTM+Z09 (Nächste Netznutzungsabrechnung): elements[0][1], format 602
            let z09_val = ctx
                .find_segments_with_qualifier("DTM", 0, "Z09")
                .into_iter()
                .find_map(|s| s.elements.first().and_then(|e| e.get(1)).cloned())
                .unwrap_or_default();
            // DTM+92 (Beginn zum): elements[0][1], format 303 (CCYYMMDDHHMM)
            let dtm92_val = match ctx
                .find_segments_with_qualifier("DTM", 0, "92")
                .into_iter()
                .find_map(|s| s.elements.first().and_then(|e| e.get(1)).cloned())
            {
                Some(v) if !v.is_empty() => v,
                _ => return ConditionResult::Unknown,
            };
            // Use the later of Z21 and Z09 as the end date of the Turnuszeitraum
            // Note: formats differ (Z21=106/104, Z09=602, DTM+92=303) — use first 6 chars (CCYYMM) for comparison
            let end_date = match (z21_val.is_empty(), z09_val.is_empty()) {
                (false, false) => {
                    if z21_val >= z09_val {
                        z21_val
                    } else {
                        z09_val
                    }
                }
                (false, true) => z21_val,
                (true, false) => z09_val,
                (true, true) => return ConditionResult::Unknown,
            };
            // Compare first 6 chars (CCYYMM) — both reference dates have at least CCYYMM
            let end_ym = &end_date[..end_date.len().min(6)];
            let begin_ym = &dtm92_val[..dtm92_val.len().min(6)];
            if end_ym.len() < 6 || begin_ym.len() < 6 {
                return ConditionResult::Unknown;
            }
            ConditionResult::from(end_ym >= begin_ym)
        }
    }

    /// [241] Wenn MP-ID in SG2 NAD+MR (Nachrichtenempfänger) in der Rolle MSB
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_241(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("recipient_is_msb")
    }

    /// [249] Innerhalb eines SG4 IDE müssen alle DE1131 der SG4 STS+E01 den identischen Wert enthalten
    // REVIEW: Checks that all STS+E01 segments have identical DE1131 values (elements[2][1] — Codeliste, Code within C556). Returns True when all values match the first occurrence. Message-wide fallback without per-SG4 grouping. (medium confidence)
    fn evaluate_249(&self, ctx: &EvaluationContext) -> ConditionResult {
        let sts_segs = ctx.find_segments("STS");
        let sts_e01: Vec<_> = sts_segs
            .iter()
            .filter(|s| {
                s.elements
                    .first()
                    .and_then(|e| e.first())
                    .is_some_and(|v| v == "E01")
            })
            .collect();
        if sts_e01.is_empty() {
            return ConditionResult::Unknown;
        }
        let first_val = sts_e01
            .first()
            .and_then(|s| s.elements.get(2))
            .and_then(|e| e.get(1))
            .map(|v| v.as_str())
            .unwrap_or("");
        ConditionResult::from(sts_e01.iter().all(|s| {
            s.elements
                .get(2)
                .and_then(|e| e.get(1))
                .map(|v| v.as_str())
                .unwrap_or("")
                == first_val
        }))
    }

    /// [252] Wenn DE0068 vorhanden
    // REVIEW: DE0068 is the Common Access Reference in UNH (elements[2][0]). Checks if it is present and non-empty in any UNH segment. (medium confidence)
    fn evaluate_252(&self, ctx: &EvaluationContext) -> ConditionResult {
        let unh_segs = ctx.find_segments("UNH");
        ConditionResult::from(unh_segs.iter().any(|s| {
            s.elements
                .get(2)
                .and_then(|e| e.first())
                .is_some_and(|v| !v.is_empty())
        }))
    }

    /// [257] Wenn in derselben SG8 SEQ+Z02 (OBIS-Daten der Marktlokation) das PIA+5+7-0?:33.86.0 vorhanden
    fn evaluate_257(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.any_group_has_co_occurrence(
            "SEQ",
            0,
            &["Z02"],
            "PIA",
            1,
            0,
            &["7-0:33.86.0"],
            &["SG4", "SG8"],
        )
    }

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

    /// [274] Wenn in derselben SG8 SEQ+Z20 (OBIS-Daten der Zähleinrichtung / Mengenumwerter) das PIA+5+7-b?:3.0.0 / 7-b?:6.0.0 / 7-b?:3.1.0 / 7-b?:6.1.0 / 7-b?:3.2.0 / 7-b?:6.2.0 / 7-b?:13.2.0 / 7-b?:16.2.0 / ...
    // REVIEW: Checks co-occurrence of SEQ+Z20 and PIA+5 in same SG8, then verifies the OBIS code (elements[1][0]) matches pattern '7-b:X.X.X' where b is variable (any subgroup) and suffix is one of the 16 listed measurement quantities. EDIFACT ?. decoded as literal colon. OBIS suffix match is message-wide as a secondary filter. (medium confidence)
    fn evaluate_274(&self, ctx: &EvaluationContext) -> ConditionResult {
        let obis_suffixes = [
            ":3.0.0", ":6.0.0", ":3.1.0", ":6.1.0", ":3.2.0", ":6.2.0", ":13.2.0", ":16.2.0",
            ":1.0.0", ":2.0.0", ":4.0.0", ":5.0.0", ":11.2.0", ":12.2.0", ":14.2.0", ":15.2.0",
        ];
        let has_seq_pia_co = ctx.any_group_has_co_occurrence(
            "SEQ",
            0,
            &["Z20"],
            "PIA",
            0,
            0,
            &["5"],
            &["SG4", "SG8"],
        );
        if !matches!(has_seq_pia_co, ConditionResult::True) {
            return has_seq_pia_co;
        }
        let pias = ctx.find_segments_with_qualifier("PIA", 0, "5");
        ConditionResult::from(pias.iter().any(|s| {
            s.elements.get(1).and_then(|e| e.first()).is_some_and(|v| {
                v.starts_with("7-") && obis_suffixes.iter().any(|suf| v.ends_with(suf))
            })
        }))
    }

    /// [276] Wenn SG4 DTM+92 (Beginn zum) vorhanden
    fn evaluate_276(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualifier("DTM", 0, "92")
    }

    /// [277] Wenn Zuordnung vorhanden
    // REVIEW: 'Wenn Zuordnung vorhanden' most likely refers to Bilanzkreiszuordnung zur Marktlokation, indicated by STS+Z18 per the MIG segment reference. Medium confidence as 'Zuordnung' could refer to other assignments in different PID contexts. (medium confidence)
    fn evaluate_277(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualifier("STS", 0, "Z18")
    }

    /// [283] Wenn Empfänger der Nachricht der zum Nachrichtendatum aktuell zugeordnete Lieferant ist
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_283(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("recipient_is_current_supplier")
    }

    /// [336] Wenn in Änderungsmeldung gefüllt
    /// EXTERNAL: Requires context from outside the message.
    // REVIEW: "Wenn in Änderungsmeldung gefüllt" means the condition applies when this field is populated in the context of an amendment message (Änderungsmeldung). Whether a given transmission constitutes an amendment depends on business context (the PID / Vorgang type) that cannot be reliably determined from the raw EDIFACT segments alone. Delegated to external provider. (medium confidence)
    fn evaluate_336(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("field_filled_in_amendment_message")
    }

    /// [345] Wenn 33-stelliger Meldepunkt im SG5 LOC+172 (Meldepunkt) vorhanden
    fn evaluate_345(&self, ctx: &EvaluationContext) -> ConditionResult {
        let locs = ctx.find_segments_with_qualifier("LOC", 0, "172");
        ConditionResult::from(locs.iter().any(|s| {
            s.elements
                .get(1)
                .and_then(|e| e.first())
                .map(|id| id.len() == 33)
                .unwrap_or(false)
        }))
    }

    /// [361] Wenn STS+E01++A03/ A04 nicht vorhanden
    fn evaluate_361(&self, ctx: &EvaluationContext) -> ConditionResult {
        let found = ctx
            .find_segments_with_qualifier("STS", 0, "E01")
            .iter()
            .any(|s| {
                s.elements
                    .get(2)
                    .and_then(|e| e.first())
                    .map(|v| v == "A03" || v == "A04")
                    .unwrap_or(false)
            });
        ConditionResult::from(!found)
    }

    /// [362] Wenn STS+E01++A03/ A17 nicht vorhanden
    fn evaluate_362(&self, ctx: &EvaluationContext) -> ConditionResult {
        let found = ctx
            .find_segments_with_qualifier("STS", 0, "E01")
            .iter()
            .any(|s| {
                s.elements
                    .get(2)
                    .and_then(|e| e.first())
                    .map(|v| v == "A03" || v == "A17")
                    .unwrap_or(false)
            });
        ConditionResult::from(!found)
    }

    /// [367] Wenn SG4 STS+E01++A04 vorhanden
    fn evaluate_367(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.has_qualified_value("STS", 0, "E01", 2, 0, &["A04"])
    }

    /// [368] Es sind alle Codes aus der Codeliste G_0009 erlaubt
    fn evaluate_368(&self, _ctx: &EvaluationContext) -> ConditionResult {
        ConditionResult::True
    }

    /// [427] Messprodukt-Code aus Kapitel 3 "Codeliste der Standard-Messprodukte Gas" der Codeliste der Konfigurationen
    /// EXTERNAL: Requires context from outside the message.
    fn evaluate_427(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.external.evaluate("messprodukt_code_gas_valid")
    }

    /// [442] Wenn in keinem SG8+SEQ+Z09 Mengenumwerterdaten das RFF+MG (Referenz auf die Gerätenummer) der in diesem RFF DE1154 genannte Gerätenummer des Zählers vorhanden ist
    // REVIEW: Condition is True when NO SG8 with SEQ+Z09 (Mengenumwerterdaten) has a co-occurring RFF+MG. Implemented by negating any_group_has_co_occurrence. Medium confidence because the 'same device number as meter' cross-reference aspect cannot be fully validated without knowing which meter device number to compare against. (medium confidence)
    fn evaluate_442(&self, ctx: &EvaluationContext) -> ConditionResult {
        let result = ctx.any_group_has_co_occurrence(
            "SEQ",
            0,
            &["Z09"],
            "RFF",
            0,
            0,
            &["MG"],
            &["SG4", "SG8"],
        );
        match result {
            ConditionResult::True => ConditionResult::False,
            ConditionResult::False => ConditionResult::True,
            ConditionResult::Unknown => ConditionResult::Unknown,
        }
    }

    /// [490] Wenn Wert in diesem DE, an der Stelle CCYYMMDD ein Datum aus dem angegeben Zeitraum der Tabelle Kapitel 3.5 „Prozesszeitpunkt bei MESZ mit UTC“ ist
    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 CCYYMMDD ein Datum aus dem angegeben Zeitraum der Tabelle Kapitel 3.6 „Prozesszeitpunkt bei MEZ mit UTC““ ist
    fn evaluate_491(&self, ctx: &EvaluationContext) -> ConditionResult {
        match ctx.resolved_value {
            Some(val) => is_mez_utc(val),
            None => ConditionResult::False,
        }
    }

    /// [494] Das hier genannte Datum muss der Zeitpunkt sein, zu dem das Dokument erstellt wurde, oder ein Zeitpunkt, der davor liegt
    fn evaluate_494(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Das genannte Datum muss dem Dokumenterstellungszeitpunkt oder einem früheren Zeitpunkt entsprechen — informational annotation
        ConditionResult::True
    }

    /// [500] Hinweis: Code ist gemäß der Kategorie der zu stornierenden Meldung zu wählen
    fn evaluate_500(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Code ist gemäß der Kategorie der zu stornierenden Meldung zu wählen — informational note, always applies
        ConditionResult::True
    }

    /// [501] Hinweis: Die Angabe wird aus dem DTM+157 (Änderung zum) der Zuordnungsliste übernommen
    fn evaluate_501(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Die Angabe wird aus dem DTM+157 (Änderung zum) der Zuordnungsliste übernommen — informational note, always applies
        ConditionResult::True
    }

    /// [507] Hinweis: Ursprünglich vom NB bestätigtes Beginndatum
    fn evaluate_507(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Informational note — 'ursprünglich vom NB bestätigtes Beginndatum'.
        // Documents the semantic meaning of the date field; no boolean logic.
        ConditionResult::Unknown
    }

    /// [508] Hinweis: Beginndatum beim neuen NB
    fn evaluate_508(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Informational note — 'Beginndatum beim neuen NB'.
        // Documents the semantic meaning of the date field; no boolean logic.
        ConditionResult::Unknown
    }

    /// [510] Hinweis: Zu verwenden bei der Abmeldung der ESV
    fn evaluate_510(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Informational note — to be used for deregistration of ESV (Ersatzversorgung).
        // Documents usage context; no boolean logic.
        ConditionResult::Unknown
    }

    /// [513] Hinweis: Ist SG9 QTY+Y02 (TUM Kundenwert) vorhanden, dann ist ausschließlich SG9 QTY+Y02, unabhängig von SG9 QTY+31 (Veranschlagte Jahresmenge gesamt), für die Bilanzierung und MMM-Abrechnung zu...
    // REVIEW: Hinweis describing precedence rule between QTY+Y02 and QTY+31. Partial implementation checks whether QTY+Y02 is present (i.e. the rule is active). Full semantic enforcement (exclusive use) cannot be expressed as a simple ConditionResult. (medium confidence)
    fn evaluate_513(&self, ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: If QTY+Y02 (TUM Kundenwert) is present, only QTY+Y02 (not QTY+31) is
        // to be used for billing and MMM settlement. This is a documentation note about
        // precedence, not a simple presence/absence condition.
        // Best approximation: True if QTY+Y02 is present (signalling the rule applies).
        ctx.has_qualifier("QTY", 0, "Y02")
    }

    /// [527] Hinweis: Es ist die ID der Marktlokation und alle Identifikatoren der Messlokationen anzugeben
    fn evaluate_527(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Informational note — ID of Marktlokation AND all Messlokation
        // identifiers must be provided. No evaluatable boolean logic.
        ConditionResult::Unknown
    }

    /// [528] Hinweis: Es ist das Datum/ Daten aus der Anfrage zu verwenden
    fn evaluate_528(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Informational note — the date(s) from the original request must be used.
        // No evaluatable boolean logic.
        ConditionResult::Unknown
    }

    /// [530] Hinweis: Es sind alle an dem Meldepunkt vorhandenen Daten, die mit dieser Segmentgruppe übermittelt werden und zum Datum „Änderung zum“ Gültigkeit haben, anzugeben. Dies kann zur Folge haben...
    fn evaluate_530(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Informational note — all data valid at 'Änderung zum' date for the
        // reporting point must be provided, possibly requiring repeated segment groups.
        // No evaluatable boolean logic.
        ConditionResult::Unknown
    }

    /// [556] Hinweis: Wenn keine Korrespondenzanschrift des Endverbrauchers/ Kunden vorliegt, ist die Anschrift der Marktlokation zu übermitteln
    fn evaluate_556(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Wenn keine Korrespondenzanschrift des Endverbrauchers/Kunden vorliegt, ist die Anschrift der Marktlokation zu übermitteln — informational note, always applies
        ConditionResult::True
    }

    /// [558] Hinweis: Diese Information kann freiwillig ausgetauscht werden
    fn evaluate_558(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: This information can be exchanged voluntarily.
        // No evaluatable boolean logic — purely documentary.
        ConditionResult::Unknown
    }

    /// [559] Hinweis: Die Korrespondenzanschrift des Endverbrauchers/Kunden wird nicht zur Identifikation genutzt
    fn evaluate_559(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Correspondence address of end consumer/customer is not used for identification.
        // No evaluatable boolean logic — purely documentary.
        ConditionResult::Unknown
    }

    /// [560] Hinweis: Die Angabe Name und Adresse für die Ablesekarte wird nicht zur Identifikation genutzt
    fn evaluate_560(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Name and address for Ablesekarte (meter reading card) is not used
        // for identification purposes. No evaluatable boolean logic — purely documentary.
        ConditionResult::Unknown
    }

    /// [566] Hinweis: Altlieferant
    fn evaluate_566(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: 'Altlieferant' (previous supplier). Informational label for the
        // market participant role context; no evaluatable boolean logic.
        ConditionResult::Unknown
    }

    /// [567] Hinweis: Neulieferant
    fn evaluate_567(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: 'Neulieferant' (new supplier). Informational label for the
        // market participant role context; no evaluatable boolean logic.
        ConditionResult::Unknown
    }

    /// [570] Hinweis: Netzbetreiber Alt
    fn evaluate_570(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Netzbetreiber Alt — informational note, always applies
        ConditionResult::True
    }

    /// [571] Hinweis: Auslösender Marktpartner (LFA bei STS+7++ZG9, LFN bei STS+7++ZH0, NB bei STS+7++ZH1)
    fn evaluate_571(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Auslösender Marktpartner (LFA bei STS+7++ZG9, LFN bei STS+7++ZH0, NB bei STS+7++ZH1) — informational note, always applies
        ConditionResult::True
    }

    /// [572] Hinweis: Kundenname aus Anmeldung Lieferant neu
    fn evaluate_572(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Kundenname aus Anmeldung Lieferant neu — informational note, always applies
        ConditionResult::True
    }

    /// [581] Hinweis: Es ist das nächst mögliche Kündigungsdatum anzugeben
    fn evaluate_581(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Es ist das nächst mögliche Kündigungsdatum anzugeben — informational note, always applies
        ConditionResult::True
    }

    /// [583] Hinweis: Verwendung der ID der Marktlokation
    fn evaluate_583(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Verwendung der ID der Marktlokation — informational note, always applies
        ConditionResult::True
    }

    /// [584] Hinweis: Verwendung der ID der Messlokation
    fn evaluate_584(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Verwendung der ID der Messlokation — informational note, always applies
        ConditionResult::True
    }

    /// [590] Hinweis: Es ist die ID der Marktlokation, welche dem LF zugeordnet sind, sowie alle Identifikatoren der Messlokationen anzugeben
    fn evaluate_590(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Es ist die ID der Marktlokation, welche dem LF zugeordnet sind, sowie alle Identifikatoren der Messlokationen anzugeben — informational note, always applies
        ConditionResult::True
    }

    /// [601] Hinweis: Es ist die ID der Marktlokation und alle Identifikatoren der Messlokationen anzugeben.
    fn evaluate_601(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Es ist die ID der Marktlokation und alle Identifikatoren der Messlokationen anzugeben — informational note, always applies
        ConditionResult::True
    }

    /// [621] Hinweis: Es ist der MSB anzugeben, welcher ab dem Zeitpunkt der Lokation zugeordnet ist, der in DTM+76 (Datum zum geplanten Leistungsbeginn) genannt ist.
    fn evaluate_621(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Es ist der MSB anzugeben, welcher ab dem Zeitpunkt der Lokation zugeordnet ist, der in DTM+76 (Datum zum geplanten Leistungsbeginn) genannt ist.
        ConditionResult::True
    }

    /// [622] Hinweis: Falls die OBIS-Kennzahl für mehrere Marktrollen relevant ist, so muss die Segmentgruppe pro Marktrolle wiederholt werden
    fn evaluate_622(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Falls die OBIS-Kennzahl für mehrere Marktrollen relevant ist, so muss die Segmentgruppe pro Marktrolle wiederholt werden
        ConditionResult::True
    }

    /// [636] Hinweis: Dieses RFF klassifiziert mit einem Code im DE1153 die in derselben Segmentgruppe enthaltenen DTM zu einem Markt- bzw. Messlokation relevanten Inhalt
    fn evaluate_636(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Dieses RFF klassifiziert mit einem Code im DE1153 die in derselben Segmentgruppe enthaltenen DTM zu einem Markt- bzw. Messlokation relevanten Inhalt
        ConditionResult::True
    }

    /// [637] Hinweis: Bei Verpflichtungsanfrage
    fn evaluate_637(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Bei Verpflichtungsanfrage — informational note, always applies
        ConditionResult::True
    }

    /// [638] Hinweis: Bei Aufforderung zur Übernahme der einzelnen Messlokation durch den gMSB
    fn evaluate_638(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Bei Aufforderung zur Übernahme der einzelnen Messlokation durch den gMSB — informational note, always applies
        ConditionResult::True
    }

    /// [643] Hinweis: Nachfolgender Netzbetreiber
    fn evaluate_643(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Nachfolgender Netzbetreiber — informational note, always applies
        ConditionResult::True
    }

    /// [644] Hinweis: Wenn in der zugehörigen Anmeldung (44001) in diesem Segmente "Einzug in Neuanlage" (SG4 STS+7++E02) enthalten ist, wird in diesem Geschäftsvorfall  der Code E01 verwendet
    fn evaluate_644(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: informational note about E01/E02 usage in Bestätigung — always applies
        ConditionResult::True
    }

    /// [651] Hinweis: Bei einer Marktraumumstellung (Gas) ist zu beachten, dass die tatsächliche Meldung zur Marktraumumstellung auf Ebene der Messlokation durch Angabe der Gasqualität erfolgt. Die betroffene...
    fn evaluate_651(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Marktraumumstellung Gas — informational note about Messlokation reporting — always applies
        ConditionResult::True
    }

    /// [654] Hinweis: Es sind ausschließlich die Daten zum Meldepunkt anzugeben, die für den in NAD+MR (Nachrichtenempfänger) adressierten Marktpartner relevant ist
    fn evaluate_654(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: Only data relevant to the addressed Marktpartner (NAD+MR) should be provided — always applies
        ConditionResult::True
    }

    /// [655] Hinweis: Wenn ein Zähler an einen Mengenumwerter angeschlossen ist werden an dem Zähler keine OBIS-Kennzahlen angegeben Hier gibt es nur OBIS Kennzahlen vom Mengenumwerter
    fn evaluate_655(&self, _ctx: &EvaluationContext) -> ConditionResult {
        // Hinweis: When a meter is connected to a volume converter, no OBIS codes are given for the meter — always applies
        ConditionResult::True
    }

    /// [902] Format: Möglicher Wert: ≥ 0
    fn evaluate_902(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.format_check("QTY", 0, 1, |val| validate_numeric(val, ">=", 0.0))
    }

    /// [907] Format: max. 4 Nachkommastellen
    fn evaluate_907(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.format_check("QTY", 0, 1, |val| validate_max_decimal_places(val, 4))
    }

    /// [912] Format: max. 6 Nachkommastellen
    fn evaluate_912(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.format_check("QTY", 0, 1, |val| validate_max_decimal_places(val, 6))
    }

    /// [930] Format: max. 2 Nachkommastellen
    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)
    }

    /// [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"))
    }

    /// [937] Format: keine Nachkommastelle
    fn evaluate_937(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.format_check("QTY", 0, 1, |val| validate_max_decimal_places(val, 0))
    }

    /// [938] Format: Möglicher Wert: &lt;= 10
    fn evaluate_938(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.format_check("QTY", 0, 1, |val| validate_numeric(val, "<=", 10.0))
    }

    /// [950] Format: Marktlokations-ID
    fn evaluate_950(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.format_check_qualified("LOC", 0, "Z16", 1, 0, validate_malo_id)
    }

    /// [951] Format: Zählpunktbezeichnung
    fn evaluate_951(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.format_check_qualified("LOC", 0, "Z19", 1, 0, validate_zahlpunkt)
    }

    /// [952] Format: Gerätenummer nach DIN 43863-5
    // REVIEW: DIN 43863-5 Gerätenummer is an alphanumeric device identifier with a max length of 20 characters. No dedicated validator exists, so validate_max_length(20) is used as the structural check. The exact segment/element depends on the AHB table position — IDE is the most common carrier for device IDs in UTILMD Gas, with PIA as a fallback. Medium confidence due to uncertainty about the exact segment without the full AHB table context. (medium confidence)
    fn evaluate_952(&self, ctx: &EvaluationContext) -> ConditionResult {
        // Format: Gerätenummer nach DIN 43863-5 — alphanumeric, max 20 characters
        // DIN 43863-5 device numbers appear in IDE segment (element 1, component 0)
        // or in SG8 PIA segments for device identification
        let ide_segs = ctx.find_segments("IDE");
        if let Some(val) = ide_segs
            .first()
            .and_then(|s| s.elements.get(1))
            .and_then(|e| e.first())
            .filter(|v| !v.is_empty())
        {
            return validate_max_length(val, 20);
        }
        // Fallback: check PIA segment for device number (qualifier 5 = substitute product)
        let pia_segs = ctx.find_segments_with_qualifier("PIA", 0, "5");
        match pia_segs
            .first()
            .and_then(|s| s.elements.get(1))
            .and_then(|e| e.first())
        {
            Some(val) => validate_max_length(val, 20),
            None => ConditionResult::False, // segment absent → condition not applicable
        }
    }

    /// [953] Format: Marktlokations-ID oder Zählpunktbezeichnung
    fn evaluate_953(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.format_check("LOC", 1, 0, validate_malo_or_zahlpunkt)
    }

    /// [2061] Segment bzw. Segmentgruppe ist genau einmal je SG4 IDE (Vorgang) anzugeben
    // REVIEW: Condition states the segment/group is to be given exactly once per SG4 IDE (Vorgang). As a boolean applicability condition, this is True when the IDE segment (Vorgangsidentifikator) is present, indicating the SG4 context exists. Cardinality enforcement (exactly once) is a structural rule beyond a simple boolean evaluator. (medium confidence)
    fn evaluate_2061(&self, ctx: &EvaluationContext) -> ConditionResult {
        ConditionResult::from(ctx.has_segment("IDE"))
    }

    /// [2119] Je SG8 SEQ+Z13 (Smartmeter-Gateway) ist genau einmal die Segmentgruppe anzugeben
    fn evaluate_2119(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.any_group_has_qualifier("SEQ", 0, "Z13", &["SG4", "SG8"])
    }

    /// [2284] Für jede Messlokations-ID im SG5 LOC+172 (Meldepunkt) DE3225 genau einmal anzugeben
    fn evaluate_2284(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.any_group_has_qualifier("LOC", 0, "172", &["SG4", "SG5"])
    }

    /// [2286] Für jede SEQ+Z18 (Daten der Messlokation) mindestens einmal anzugeben
    fn evaluate_2286(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.any_group_has_qualifier("SEQ", 0, "Z18", &["SG4", "SG8"])
    }

    /// [2287] Für jede SEQ+Z03 (Zähleinrichtungsdaten) mindestens einmal anzugeben
    fn evaluate_2287(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.any_group_has_qualifier("SEQ", 0, "Z03", &["SG4", "SG8"])
    }

    /// [2335] Für jede SEQ+Z02 (OBIS-Daten der Marktlokation), welche im PIA+5 die OBIS-Kennzahl 7-20:99.33.17/ 7-0:33.86.0 übermittelt, genau einmal anzugeben
    // REVIEW: Condition states: to be given exactly once for each SEQ+Z02 (OBIS-Daten der Marktlokation) where PIA+5 transmits OBIS code 7-20:99.33.17 or 7-0:33.86.0. Per segment structure reference, PIA elements[1][0] (DE7140) holds the OBIS code. Checks message-wide PIA+5 for the target OBIS values, then verifies SEQ+Z02 is present. Since PIA is always nested in the same SG8 as its SEQ, message-wide PIA check is a valid approximation when group navigator is unavailable. (medium confidence)
    fn evaluate_2335(&self, ctx: &EvaluationContext) -> ConditionResult {
        {
            // Check for PIA+5 with specific OBIS codes 7-20:99.33.17 or 7-0:33.86.0 at elements[1][0]
            let pias = ctx.find_segments_with_qualifier("PIA", 0, "5");
            let has_target_obis = pias.iter().any(|pia| {
                pia.elements
                    .get(1)
                    .and_then(|e| e.first())
                    .map(|v| v == "7-20:99.33.17" || v == "7-0:33.86.0")
                    .unwrap_or(false)
            });
            if !has_target_obis {
                return ConditionResult::False;
            }
            // Also verify SEQ+Z02 (OBIS-Daten der Marktlokation) is present — PIA is always co-located in the same SG8
            ctx.any_group_has_qualifier("SEQ", 0, "Z02", &["SG4", "SG8"])
        }
    }

    /// [2353] Für jede SEQ+Z09 (Mengenumwerter-Daten) mindestens einmal anzugeben
    fn evaluate_2353(&self, ctx: &EvaluationContext) -> ConditionResult {
        ctx.any_group_has_qualifier("SEQ", 0, "Z09", &["SG4", "SG8"])
    }
}