//
//  lkf2024Tests.swift
//  LKF
//
//  Created by Alexander Holzer on 21.07.23.
//  Copyright © 2023 Alexander Holzer. All rights reserved.
//

import XCTest
@testable import lkfc

final class lkf2024Tests: XCTestCase {

    func createContextWith (model: UInt32, year: Int32? = nil, lines : [String]) throws -> LKFContext {
        let c = try lkfcTests.createContextWith(model:model, lines:lines)
        if let year {
            c.setContextParameters(year: year)
        }
        return c
    }
    
    func combine (_ first:[String], _ second:[String]) -> [String] {
        return lkfcTests.combine(first, second)
    }
    
    override func setUpWithError() throws {
        // Put setup code here. This method is called before the invocation of each test method in the class.
    }

    override func tearDownWithError() throws {
        // Put teardown code here. This method is called after the invocation of each test method in the class.
    }

    func testExample() throws {
        // This is an example of a functional test case.
        // Use XCTAssert and related functions to verify your tests produce the correct results.
        // Any test you write for XCTest can be annotated as throws and async.
        // Mark your test throws to produce an unexpected failure when your test encounters an uncaught error.
        // Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards.
    }

    func testPerformanceExample() throws {
        // This is an example of a performance test case.
        self.measure {
            // Put the code you want to measure the time of here.
        }
    }

    static var fall_testAA180 = [
        "X01|K534|234||20190401|0859|S|20041105|10|M|AT|AT|5452|50416|A|P||||E|20190402|0955|17|J|4",
        "X02|K534|234||20190401|001|14628500|20190401|0859|||||||N|10|",
        "X03|K534|234||20190401|G40.0|H|||",
        "X04|K534|234||20190401|AA180||J|1|20190401|1030|187867||",
        
    ]
    
    static var fall_testAA180_add = [
        "L01|2024|K534||M|XY|"
    ]
    
    static var fall_testFZ124 = [
        "X01|K534|234||20190401|0859|S|20041105|10|M|AT|AT|5452|50416|A|P||||E|20190402|0955|17|J|4",
        "X02|K534|234||20190401|001|14628500|20190401|0859|||||||N|10|",
        "X03|K534|234||20190401|C90.0|H|||",
        "X04|K534|234||20190401|FZ124||J|1|20190401|1030|187867||"
        ]
    
    static var fall_testFZ124_add = [
        "L01|2023|K534||M|XS|"
        ]
    
    func testAA180 () throws {
        var context = try createContextWith(model: 2024, lines: lkf2024Tests.fall_testAA180)
        try context.execute()
        //let res = context.getResultLine(forIndex: 0)
        var errors = context.errorsWith (code:"WX3Q") // Verlegungen nicht aufeinanderfolgend
        XCTAssert(errors != nil, "expected WX3Q")
        
        let okaa180 = combine(lkf2024Tests.fall_testFZ124, lkf2024Tests.fall_testFZ124_add)
        
        context = try createContextWith(model: 2024, lines: okaa180)
        try context.execute()
        //let res = context.getResultLine(forIndex: 0)
        errors = context.errorsWith (code:"WX3Q") // Verlegungen nicht aufeinanderfolgend
        XCTAssert(errors == nil, "WX3Q not expected")
        
        context = try createContextWith(model: 2023, lines: lkf2024Tests.fall_testFZ124)
        try context.execute()
        //let res = context.getResultLine(forIndex: 0)
        errors = context.errorsWith (code:"WX3Q") // Verlegungen nicht aufeinanderfolgend
        XCTAssert(errors != nil, "expected WX3Q")
        
        let okFZ124 = combine(lkf2024Tests.fall_testFZ124, lkf2024Tests.fall_testFZ124_add)
        
        context = try createContextWith(model: 2023, lines: okFZ124)
        try context.execute()
        //let res = context.getResultLine(forIndex: 0)
        errors = context.errorsWith (code:"WX3Q") // Verlegungen nicht aufeinanderfolgend
        XCTAssert(errors == nil, "WX3Q not expected")
    }
    
    func testNeonat () throws {
        
        let diags : [(String,UInt32,UInt32)] =
            [("P07.2", 147, 0), ("P07.0", 147, 0), ("P07.11",  98, 0), ("P07.32",  77, 0),
             ("301.17", 0, 0), ("301.20", 0, 0), ("301.21", 0, 161), ("301.23", 0, 147), ("301.30", 0, 98),
             ("301.31", 0, 91), ("301.36", 0, 56), ("301.39", 0, 35), ("301.40", 0, 0), ("301.47", 0, 0)]
        
        let ctx2020 = try LKFContext(model: 2020, path: LKFTest.rootPath)
        let ctx2024 = try LKFContext(model: 2024, path: LKFTest.rootPath)
        
        for d in diags {
            let limit2020 = ctx2020.neonatologieLimit(for: d.0)
            let limit2024 = ctx2024.neonatologieLimit(for: d.0)
            XCTAssert(limit2020 == d.1, "Diag \(d.0) in model 2020: expected neonat. limit \(d.1), got \(limit2020)")
            XCTAssert(limit2024 == d.2, "Diag \(d.0) in model 2024: expected neonat. limit \(d.2), got \(limit2024)")
        }
    }
    
    
    static var fall_testWX3P0 = [
        "X01|K534|234||20190401|0859|S|20041105|10|M|AT|AT|5452|50416|A|P||||E|20190401|0955|17|J|4",
        "X02|K534|234||20190401|001|14628500|20190401|0859|||||||N|10|",
        "X03|K534|234||20190401|I50.01|H|||",
        "X03|K534|234||20190401|I50.11|Z|||",
        "X04|K534|234||20190401|DE111||J|1|20190401|1030|187867||"
    ]

    static var fall_testEX24 = [
        "X01|K534|234||20190401|0859|S|20041105|10|M|AT|AT|5452|50416|A|P||||E|20190404|0955|17|J|4",
        "X02|K534|234||20190401|001|14628500|20190401|0859|||||||N|10|",
        "X03|K534|234||20190401|L98.7|H|||",
        "X04|K534|234||20190401|QB010||J|1|20190404|1030|187867||"
    ]

    static var fall_testWX3P0UntBr = [
        "X01|K534|234||20190401|0859|S|20041105|10|M|AT|AT|5452|50416|A|P||||E|20190406|0955|17|J|4",
        "X02|K534|234||20190401|001|14628500|20190401|0859|||||||N|10|",
        "X02|K534|234||20190401|002|10000000|20190404|0859|||||||N|10|",
        "X02|K534|234||20190401|003|14628500|20190405|0859|||||||N|10|",
        "X03|K534|234||20190401|I50.01|H|||",
        "X03|K534|234||20190401|I50.11|Z|||",
        "X04|K534|234||20190401|DE111||J|1|20190404|1030|187867||"
    ]

    static var fall_testEX24UntBr = [
        "X01|K534|234||20190401|0859|S|20041105|10|M|AT|AT|5452|50416|A|P||||E|20190406|0955|17|J|4",
        "X02|K534|234||20190401|001|14628500|20190401|0859|||||||N|10|",
        "X02|K534|234||20190401|002|10000000|20190404|0859|||||||N|10|",
        "X02|K534|234||20190401|003|14628500|20190405|0859|||||||N|10|",
        "X03|K534|234||20190401|L98.7|H|||",
        "X04|K534|234||20190401|QB010||J|1|20190404|1030|187867||"
    ]

    /* V2024.1 */
    static var fall_testnoWX3PUntBr = [
        "X01|K534|234||20190401|0859|S|20041105|10|M|AT|AT|5452|50416|A|P||||E|20190406|0955|17|J|4",
        "X02|K534|234||20190401|001|14628500|20190401|0859|||||||N|10|",
        "X02|K534|234||20190401|002|10000000|20190404|0859|||||||N|10|",
        "X02|K534|234||20190401|003|14628500|20190405|0859|||||||N|10|",
        "X03|K534|234||20190401|C97|H|||",
        "X03|K534|234||20190401|K76.5|Z|||",
        "X04|K534|234||20190401|XA185||J|1|20190404|1030|187867||"
    ]

    
    func testMELEntDat() throws {
        
        var context = try createContextWith(model: 2023, lines: lkf2024Tests.fall_testWX3P0)
        try context.execute()
        var errors = context.errorsWith (code:"WX3P") // Med.Leistung für 0-Tage unplausibel (Warning)
        XCTAssert(errors != nil, "WX3P expected in model 2023")
        
        context = try createContextWith(model: 2024, lines: lkf2024Tests.fall_testWX3P0)
        try context.execute()
        errors = context.errorsWith (code:"WX3P") // Med.Leistung für 0-Tage unplausibel (Warning)
        XCTAssert(errors != nil, "WX3P expected in model 2024")

        context = try createContextWith(model: 2023, lines: lkf2024Tests.fall_testEX24)
        try context.execute()
        errors = context.errorsWith (code:"EX24") // Med.Leistung für 0-Tage unplausibel (Warning)
        XCTAssert(errors == nil, "EX24 not expected in model 2023")

        context = try createContextWith(model: 2024, lines: lkf2024Tests.fall_testEX24)
        try context.execute()
        errors = context.errorsWith (code:"EX24") // Med.Leistung für 0-Tage unplausibel (Warning)
        XCTAssert(errors != nil, "EX24 expected in model 2024")
        errors = context.errorsWith (code: "WX41") // Med.Leistung für 0-Tage unplausibel (Warning)
        XCTAssert(errors == nil, "WX41 not expected because of EX24 in model 2024")

        context = try createContextWith(model: 2023, lines: lkf2024Tests.fall_testWX3P0UntBr)
        try context.execute()
        errors = context.errorsWith (code:"WX3P") // Med.Leistung für 0-Tage unplausibel (Warning)
        XCTAssert(errors == nil, "WX3P not expected in model 2023")
        errors = context.errorsWith (code:"WX41") // Med.Leistung für 0-Tage unplausibel (Warning)
        XCTAssert(errors != nil, "WX41 expected in model 2023")

        context = try createContextWith(model: 2024, lines: lkf2024Tests.fall_testWX3P0UntBr)
        try context.execute()
        errors = context.errorsWith (code:"WX3P") // Med.Leistung für 0-Tage unplausibel (Warning)
        XCTAssert(errors != nil, "WX3P expected in model 2024")
        errors = context.errorsWith (code: "WX41") // Med.Leistung für 0-Tage unplausibel (Warning)
        XCTAssert(errors == nil, "WX41 not expected because of WX3P in model 2024")

        context = try createContextWith(model: 2023, lines: lkf2024Tests.fall_testEX24UntBr)
        try context.execute()
        errors = context.errorsWith (code:"EX24") // Med.Leistung für 0-Tage unplausibel (Warning)
        XCTAssert(errors == nil, "EX24 not expected in model 2023")
        errors = context.errorsWith (code:"WX41") // Med.Leistung für 0-Tage unplausibel (Warning)
        XCTAssert(errors != nil, "WX41 expected in model 2023")

        context = try createContextWith(model: 2024, lines: lkf2024Tests.fall_testEX24UntBr)
        try context.execute()
        errors = context.errorsWith (code:"EX24") // Med.Leistung für 0-Tage unplausibel (Warning)
        XCTAssert(errors != nil, "EX24 expected in model 2024")
        errors = context.errorsWith (code: "WX41") // Med.Leistung für 0-Tage unplausibel (Warning)

        XCTAssert(errors == nil, "WX41 not expected because of EX24 in model 2024")

        /* V2024.1 */
        context = try createContextWith(model: 2024, lines: lkf2024Tests.fall_testnoWX3PUntBr)
        try context.execute()
        errors = context.errorsWith (code:"WX3P") // Med.Leistung für 0-Tage unplausibel (Warning)
        XCTAssert(errors == nil, "WX3P not expected in model 2024 (MEL with LE=E/SP1)")
        errors = context.errorsWith (code: "WX41") // Med.Leistung für 0-Tage unplausibel (Warning)
        XCTAssert(errors == nil, "WX41 not expected because of WX3P in model 2024")

        
    }
    
    static var fall_i519 = [
        "X01|K534|234||20190401|0859|S|20041105|10|M|AT|AT|5452|50416|A|P||||E|20190404|0955|17|J|4",
        "X02|K534|234||20190401|001|14628500|20190401|0859|||||||N|10|",
        "X03|K534|234||20190401|I51.9|H|||",
        //"X04|K534|234||20190401|QB010||J|1|20190404|1030|187867||",
    ]
    
    func testI519() throws {
        
        var context = try createContextWith(model: 2023, lines: lkf2024Tests.fall_i519)
        try context.execute()
        var res = context.getResultLine(forIndex: 0)
        XCTAssert(res == "X05|K534|234||20190401|HDG06.04|B|172|2516|||||||2688", "result differs")
        var errors = context.errorsWith (code:"WX4M") // Med.Leistung für 0-Tage unplausibel (Warning)
        XCTAssert(errors == nil, "WX4M not expected in model 2024")
        
        context = try createContextWith(model: 2024, lines: lkf2024Tests.fall_i519)
        try context.execute()
        errors = context.errorsWith (code:"WX4M") // Med.Leistung für 0-Tage unplausibel (Warning)
        XCTAssert(errors != nil, "WX4M expected in model 2024")
        res = context.getResultLine(forIndex: 0)
        XCTAssert(res == "X05|K534|234||20190401|HDG06.04|B|172|2516|||||||2688", "result differs")
        
    }
    
    static var fall_xc = [
        "X01|K901|123||20220102|1247|S|19450416|75|M|AT|AT|8742|62042|T|A||K672||E|20220210|1118|05|J|2",
        "X02|K901|123||20220102|001|13091100|20220102|1247|||||||N|75|",
        "X02|K901|123||20220102|002|11115800|20220109|1041|||||||N|75|",
        "X02|K901|123||20220102|003|13913700|20220122|1105|||||||N|75|",
        "X03|K901|123||20220102|C84.4|H|||",
        "X03|K901|123||20220102|C78.2|Z|||",
        "X03|K901|123||20220102|C85.7|Z|||",
        "X04|K901|123||20220102|PE010||J|1|20220103|1329|13091100||",
        "X04|K901|123||20220102|XC153||J|1|20220201|0840|16115800||",
        "X04|K901|123||20220102|XC153||J|1|20220202|0824|16115800||",
        "X04|K901|123||20220102|ZA030||J|1|20220202|1411|17725100||",
        "X04|K901|123||20220102|ZB010||J|1|20220105|0921|17725100||",
        "X04|K901|123||20220102|ZC010||J|1|20220106|0921|17725100||",
        "X05|K901|123||20220102|MEL22.03|A|1308|2952|||3896|||13720|21876"
    ]

    func testXC () throws {
        
        var context = try createContextWith(model: 2023, lines: lkf2024Tests.fall_xc)
        try context.execute()
        var res = context.getResultLine(forIndex: 0)
        var errors = context.errorsWith (code:"WX4L") // XC
        XCTAssert(errors == nil, "WX4L not expected in model 2023")
        XCTAssert(res == "X05|K901|123||20220102|MEL22.03|A|1308|2952|||8570||1308||14138", "result differs: \(res)")
        context = try createContextWith(model: 2024, lines: lkf2024Tests.fall_xc)
        try context.execute()
        errors = context.errorsWith (code:"WX4L") // Med.Leistung für 0-Tage unplausibel (Warning)
        XCTAssert(errors != nil, "WX4L expected in model 2024")
        res = context.getResultLine(forIndex: 0)
        XCTAssert(res == "X05|K901|123||20220102|MEL22.03|A|1308|2952|||8570||||12830", "result differs: \(res)")
    }
    
    static var fall_ambLimit = [
        "X01|K901|123||20230101|0919|I|19670829|50|W|AT|AT|8410|61059|||||||||15|J|0",
        "X02|K901|123||20230101|001|17721500|20230101|0919|J||||||N|50|",
        "X02|K901|123||20230101|002|17725300|20230101|1100|J||||||N|50|",
        "X04|K901|123||20230101|ZC030||J|1|20230101|0940|17721500||",
        "X04|K901|123||20230101|ZC030||J|1|20230101|1040|17213100||",
        "X04|K901|123||20230101|ZN340||J|1|20230101|1736|17725300||",
        "X05|K901|123||20230101|APG14.04|A|796|44|||||154||994"
    ]

    static var fall_ambLimitKA = [
        "X01|K901|123||20230101|0919|I|19670829|50|W|AT|AT|8410|61059|||||||||15|J|0",
        "X02|K901|123||20230101|001|17721500|20230101|0919|J||||||N|50|",
        "X02|K901|123||20230101|002|17725300|20230101|1100|J||||||N|50|",
        "X04|K901|123||20230101|ZC030||J|1|20230101|0940||K910|",
        "X04|K901|123||20230101|ZC030||J|1|20230101|1040|17721500||",
        "X04|K901|123||20230101|ZN340||J|1|20230101|1736|17725300||",
        "X05|K901|123||20230101|APG14.04|A|796|44|||||154||994"
    ]

    static var fall_ambLimitSameFC34 = [
        "X01|K901|123||20230101|0919|I|19670829|50|W|AT|AT|8410|61059|||||||||15|J|0",
        "X02|K901|123||20230101|001|17721500|20230101|0919|J||||||N|50|",
        "X02|K901|123||20230101|002|17725300|20230101|1100|J||||||N|50|",
        "X04|K901|123||20230101|ZC030||J|1|20230101|0940|17725300||",
        "X04|K901|123||20230101|ZC030||J|1|20230101|1040|17721500||",
        "X04|K901|123||20230101|ZN340||J|1|20230101|1736|17725300||",
        "X05|K901|123||20230101|APG14.04|A|796|44|||||154||994"
    ]
    
    static var fall_ambLimitWX4Z =
    [
        "X01|K901|F01||20240101|1200|I|19340101|90|M|AT|AT|1010|90101|1|P||||1|||11|J|4||",
        "X02|K901|F01||20240101|001|16111111|20240101||J||||||N|90|",
        "X04|K901|F01||20240101|DE510||J|1|20240101||16211100||",
        "X04|K901|F01||20240101|DE510||J|2|20240101||16111111||"
    ]

    static var fall_ambLimitnoWX4Z =
    [
        "X01|K901|F06||20240101|1200|I|19340101|90|M|AT|AT|1010|90101|1|P||||1|||11|J|2||",
        "X02|K901|F06||20240101|001|16111111|20240101||J||||||N|90|",
        "X04|K901|F06||20240101|DE510||J|1|20240101||16111111||",
        "X04|K901|F06||20240101|DE510||J|1|20240101||16211100||"
    ]

    func testAmbLimit() throws {
        
        var context = try createContextWith(model: 2023, lines: lkf2024Tests.fall_ambLimit)
        try context.execute()
        var res = context.getResultLine(forIndex: 0)
        var errors = context.errorsWith (code:"WX4Z") // Warnlimit
        XCTAssert(errors != nil, "WX4Z expected in model 2023")
        XCTAssert(res == "X05|K901|123||20230101|APG14.04|A|796|44|||||154||994", "result differs: \(res)")
        context = try createContextWith(model: 2024, lines: lkf2024Tests.fall_ambLimit)
        try context.execute()
        errors = context.errorsWith (code:"WX4Z") // Warnlimit (wird Errlimit in 2024)
        XCTAssert(errors == nil, "WX4Z not expected in model 2024")
        res = context.getResultLine(forIndex: 0)
        XCTAssert(res == "X05|K901|123||20230101|APG14.04|A|796|44|||||154||994", "result differs: \(res)")
        
        context = try createContextWith(model: 2023, lines: lkf2024Tests.fall_ambLimitSameFC34)
        try context.execute()
        res = context.getResultLine(forIndex: 0)
        errors = context.errorsWith (code:"WX4Z") // Warnlimit
        XCTAssert(errors != nil, "WX4Z expected in model 2023")
        XCTAssert(res == "X05|K901|123||20230101|APG14.04|A|796|44|||||154||994", "result differs: \(res)")
        context = try createContextWith(model: 2024, lines: lkf2024Tests.fall_ambLimitSameFC34)
        try context.execute()
        errors = context.errorsWith (code:"EX4D") // Errorlimit in 2024
        XCTAssert(errors != nil, "EX4D expected in model 2024")
 
        context = try createContextWith(model: 2023, lines: lkf2024Tests.fall_ambLimitKA)
        try context.execute()
        res = context.getResultLine(forIndex: 0)
        errors = context.errorsWith (code:"WX4Z") // Warnlimit
        XCTAssert(errors != nil, "WX4Z expected in model 2023")
        XCTAssert(res == "X05|K901|123||20230101|APG14.04|A|796|44|||||154||994", "result differs: \(res)")
        context = try createContextWith(model: 2024, lines: lkf2024Tests.fall_ambLimitKA)
        try context.execute()
        errors = context.errorsWith (code:"WX4Z") // Warnlimit (wird Errlimit in 2024)
        XCTAssert(errors == nil, "WX4Z not expected in model 2024")
        res = context.getResultLine(forIndex: 0)
        XCTAssert(res == "X05|K901|123||20230101|APG14.04|A|796|44|||||154||994", "result differs: \(res)")

        context = try createContextWith(model: 2024, lines: lkf2024Tests.fall_ambLimitWX4Z)
        try context.execute()
        errors = context.errorsWith (code:"WX4Z") // Warnlimit (wird Errlimit in 2024)
        XCTAssert(errors != nil, "WX4Z expected in model 2024")
        res = context.getResultLine(forIndex: 0)
        XCTAssert(res == "X05|K901|F01||20240101|APG05.00|A||44|||||||44", "result differs: \(res)")

        context = try createContextWith(model: 2024, lines: lkf2024Tests.fall_ambLimitnoWX4Z)
        try context.execute()
        errors = context.errorsWith (code:"WX4Z") // Warnlimit (wird Errlimit in 2024)
        XCTAssert(errors == nil, "WX4Z not expected in model 2024")
        res = context.getResultLine(forIndex: 0)
        XCTAssert(res == "X05|K901|F06||20240101|APG05.00|A||44|||||||44", "result differs: \(res)")
    }
    
    static var fall_doubleEX4V = [
        "X01|K534|234||20240401|0859|S|20041105|10|W|AT|AT|5452|50416|A|P||||E|20240424|0955|17|J|4",
        "X02|K534|234||20240401|001|14628500|20240401|0859|||||||N|10|",
        "X03|K534|234||20240401|O84.0|H|||",
        "X03|K534|234||20240401|301.31|Z|||",
        "X03|K534|234||20240401|301.33|Z|||",
        "X04|K534|234||20240401|JN020||J|1|20240401|1040|17721500||",

        //"X04|K534|234||20190401|QB010||J|1|20190404|1030|187867||",
    ]
    
    static var fall_doubleEX4V_accept = ["X06|K534|234||20240401|001:JN020|EX4V"]
    
    func testEX4VAccept() throws {
        var context = try createContextWith(model: 2024, lines: lkf2024Tests.fall_doubleEX4V)
        try context.execute()
        var res = context.getResultLine(forIndex: 0)
        var errors = context.errorsWith (code:"EX4V") // Gestationsalter mehrfach
        XCTAssert(errors != nil, "EX4V not accepted -> expected in model 2024")
        
        let accepted = lkfcTests.combine(lkf2024Tests.fall_doubleEX4V, lkf2024Tests.fall_doubleEX4V_accept)
        
        context = try createContextWith(model: 2023, lines: accepted)
        try context.execute()
        res = context.getResultLine(forIndex: 0)
        errors = context.errorsWith (code:"EX4V") // Warnlimit
        XCTAssert(errors != nil, "EX4V accepted, but expected in model 2023")

        context = try createContextWith(model: 2024, lines: accepted)
        try context.execute()
        res = context.getResultLine(forIndex: 0)
        errors = context.errorsWith (code:"EX4V") // Warnlimit
        XCTAssert(errors == nil, "EX4V accepted and not expected")
    }

    static var case_wi3gacc = [
        "X01|K901|123||20240101|0931|S|19560101|65|W|AT|AT|1020|90201|A|P||||S|20240101|0800|40|J|2|",
        "X02|K901|123||20240101|001|12718111|20240101|0931||20240101|0900|3|12718111|12718111|N|65||",
        "X03|K901|123||20240101|T78.2|H||||",
        "X03|K901|123||20240101|999.9|Z||||",
        "X03|K901|123||20240101|D25.0|Z||||",
        "X03|K901|123||20240101|N95.0|Z||||",
        "X04|K901|123||20240101|JK010||J|1|20240101||16319511|||",
        "X05|K901|123||20240101||||||||||||",
        "I11|K901|123||20240101|001|20240101|00|0|0|0|0|6|0|0|0|0|0|0|2||||14|1|1|1|1||000000000000000000000||0||||||000|5|",
        "I12|K901|123||20240101|001|20240101|1|1|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|"
      ]
    
      func testAcceptWI3G () throws {
          let context = try createContextWith(model: 2024, lines: lkf2024Tests.case_wi3gacc)
          try context.execute()
          let _ = context.getResultLine(forIndex: 0)
          let errors = context.errorsWith (code:"WI3G")
          try? context.addLine(line: "X06|K901|123||20240101|001:01.01.2024|WI3G|test")
          XCTAssert(errors != nil, "WI3G expected")
          let aufenthalt = context[0];
          
          if aufenthalt.akwarnCount < 1 {
              XCTAssert(aufenthalt.akwarnCount==1, "wrong count of akwarns");
          }
          else {
              let akwarn = aufenthalt.akwarnAt(index: 0)
              XCTAssert(akwarn.rawLine == "X06|K901|123||20240101|001:01.01.2024|WI3G|test", "falsch")
              try context.execute()
          }
     }
    
     func testPrivateStamm () throws {
         
         let context = try createContextWith(model: 2024, lines: lkf2024Tests.case_wi3gacc)
         try context.execute()
         
     }
}

