//
//  lkfc2021SP1Tests.swift
//  lkfcTests
//
//  Created by Alexander Holzer on 29.01.21.
//  Copyright © 2021 Alexander Holzer. All rights reserved.
//


import XCTest
@testable import lkfc

class lkfc2021SP1Tests: XCTestCase {

    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.
    }

    static var fall_geschlI = [
        "X01|K714|1234||20190621|1200|S|19360601|80|I|AT|AT|1010|90101|A|P||||E|20190621|1200|11|J|0",
        "X02|K714|1234||20190621|01|11111100|20190621||J||||||N|80|",
                "X03|K714|1234||20190621|I51.9|H|D||",
        "X03|K714|1234||20190621|R53|Z|D||",
        "X04|K714|1234||20190621|BG020||J|0001|20190621|2024|18111600|"]

    static var fall_geschlO = [
        "X01|K714|1234||20190621|1200|S|19360601|80|O|AT|AT|1010|90101|A|P||||E|20190621|1200|11|J|0",
        "X02|K714|1234||20190621|01|11111100|20190621||J||||||N|80|",
                "X03|K714|1234||20190621|I51.9|H|D||",
        "X03|K714|1234||20190621|R53|Z|D||",
        "X04|K714|1234||20190621|BG020||J|0001|20190621|2024|18111600|"]

    static var fall_geschlK = [
        "X01|K714|1234||20190621|1200|S|19360601|80|K|AT|AT|1010|90101|A|P||||E|20190621|1200|11|J|0",
        "X02|K714|1234||20190621|01|11111100|20190621||J||||||N|80|",
                "X03|K714|1234||20190621|I51.9|H|D||",
        "X03|K714|1234||20190621|R53|Z|D||",
        "X04|K714|1234||20190621|BG020||J|0001|20190621|2024|18111600|"]

    static var fall_geschlA34X = [
        "X01|K714|1234||20190621|1200|S|19960601|80|X|AT|AT|1010|90101|A|P||||E|20190621|1200|11|J|0",
        "X02|K714|1234||20190621|01|11111100|20190621||J||||||N|80|",
                "X03|K714|1234||20190621|I51.9|H|D||",
        "X03|K714|1234||20190621|A34|Z|D||",
        "X04|K714|1234||20190621|BG020||J|0001|20190621|2024|18111600|"]

    
    static var fall_geschlA34 = [
        "X01|K714|1234||20190621|1200|S|19960601|80|O|AT|AT|1010|90101|A|P||||E|20190621|1200|11|J|0",
        "X02|K714|1234||20190621|01|11111100|20190621||J||||||N|80|",
                "X03|K714|1234||20190621|I51.9|H|D||",
        "X03|K714|1234||20190621|A34|Z|D||",
        "X04|K714|1234||20190621|BG020||J|0001|20190621|2024|18111600|"]


    func createContextWith (model: UInt32, lines : [String]) throws -> LKFContext {
        return try lkfcTests.createContextWith(model:model, lines:lines)
    }
    
    func resultForContext (context: LKFContext) -> String {
        return lkfcTests.resultForContext (context: context)
    }
    
    func combine (_ first:[String], _ second:[String]) -> [String] {
        return lkfcTests.combine(first, second)
    }
    
    func testGESCHL() throws {

        var context = try createContextWith(model:2020, lines: lkfc2021SP1Tests.fall_geschlI)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        _ = resultForContext(context: context)
        var errors = context.errorsWith (code:"EX06") // Geschlecht falsch
        XCTAssert (errors != nil, "error EX06 expected")

        context = try createContextWith(model:2021, lines: lkfc2021SP1Tests.fall_geschlI)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        _ = resultForContext(context: context)
        errors = context.errorsWith (code:"EX06") // Geschlecht falsch
        XCTAssert (errors == nil, "error EX06 not expected")

        context = try createContextWith(model:2020, lines: lkfc2021SP1Tests.fall_geschlO)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        _ = resultForContext(context: context)
        errors = context.errorsWith (code:"EX06") // Geschlecht falsch
        XCTAssert (errors != nil, "error EX06 expected")

        context = try createContextWith(model:2021, lines: lkfc2021SP1Tests.fall_geschlO)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        _ = resultForContext(context: context)
        errors = context.errorsWith (code:"EX06") // Geschlecht falsch
        XCTAssert (errors == nil, "error EX06 not expected")

        context = try createContextWith(model:2023, lines: lkfc2021SP1Tests.fall_geschlK)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        _ = resultForContext(context: context)
        errors = context.errorsWith (code:"EX06") // Geschlecht falsch
        XCTAssert (errors != nil, "error EX06 expected")

        context = try createContextWith(model:2024, lines: lkfc2021SP1Tests.fall_geschlK)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        _ = resultForContext(context: context)
        errors = context.errorsWith (code:"EX06") // Geschlecht falsch
        XCTAssert (errors == nil, "error EX06 not expected")

        
        context = try createContextWith(model:2019, lines: lkfc2021SP1Tests.fall_geschlA34X)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        _ = resultForContext(context: context)
        errors = context.errorsWith (code:"EX1U") // Diagnose - Geschlecht
        XCTAssert (errors != nil, "error EX1U expected")

        context = try createContextWith(model:2020, lines: lkfc2021SP1Tests.fall_geschlA34X)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        _ = resultForContext(context: context)
        errors = context.errorsWith (code:"EX1U") // Diagnose - Geschlecht
        XCTAssert (errors == nil, "error EX1U not expected")

        context = try createContextWith(model:2021, lines: lkfc2021SP1Tests.fall_geschlA34X)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        _ = resultForContext(context: context)
        errors = context.errorsWith (code:"EX1U") // Diagnose - Geschlecht
        XCTAssert (errors == nil, "error EX1U not expected")

        context = try createContextWith(model:2020, lines: lkfc2021SP1Tests.fall_geschlA34)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        _ = resultForContext(context: context)
        errors = context.errorsWith (code:"EX1U") // Diagnose - Geschlecht
        XCTAssert (errors != nil, "error EX1U expected")

        context = try createContextWith(model:2021, lines: lkfc2021SP1Tests.fall_geschlA34)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        _ = resultForContext(context: context)
        errors = context.errorsWith (code:"EX1U") // Diagnose - Geschlecht
        XCTAssert (errors == nil, "error EX1U not expected")

    }

    static var fall_geschlBlank = [
        "X01|K714|1234||20190621|1200|S|19360601|80||AT|AT|1010|90101|A|P||||E|20190627|1200|11|J|0",
        "X02|K714|1234||20190621|01|11111100|20190621||J||||||N|80|",
        "X03|K714|1234||20190621|C60.9|H|D||",
        "X03|K714|1234||20190621|D17.6|Z|D||",
        "X04|K714|1234||20190621|JH130||J|0001|20190621|2024|18111600|",
        "X06|K714|1234||20190621||EX05|GESCHL leer"]
    
    func testGESCHLBlank() throws {
        var context = try createContextWith(model:2020, lines: lkfc2021SP1Tests.fall_geschlBlank)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        _ = resultForContext(context: context)
        var errors = context.errorsWith (code:"EX05") // Geschlecht fehlt
        XCTAssert (errors != nil, "error EX05 expected")
        
        context = try createContextWith(model:2021, lines: lkfc2021SP1Tests.fall_geschlBlank)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        let result = resultForContext(context: context)
        XCTAssert(result == "X05|K714|1234||20190621|MEL12.04|A|1794|2978|||||||4772", "result differs")
        errors = context.errorsWith (code:"EX05") // Geschlecht fehlt
        XCTAssert (errors == nil, "error EX05 accepted => not expected")
    }

    static var fall_unterbr = [
        "X01|K714|1234||20190121|1200|S|19960601|80|M|AT|AT|1010|90101|A|P||||E|20190624|1200|11|J|0",
        "X02|K714|1234||20190121|01|11111100|20190121||J||||||N|80|",
        "X02|K714|1234||20190121|02|10000000|20190126||J||||||N|80|",
        "X02|K714|1234||20190121|03|11111100|20190603||J||||||N|80|",
        "X03|K714|1234||20190121|B21.3|H|D||",
        "X04|K714|1234||20190121|XA160||J|0001|20190121|2024|18111600|"]

    static var fall_unterbrEX33 = [
        "X01|K714|1234||20190121|1200|S|19960601|80|M|AT|AT|1010|90101|A|P||||E|20190624|1200|11|J|0",
        "X02|K714|1234||20190121|01|11111100|20190121||J||||||N|80|",
        "X02|K714|1234||20190121|02|10000000|20190121||J||||||N|80|",
        "X02|K714|1234||20190121|03|11111100|20190123||J||||||N|80|",
        "X03|K714|1234||20190121|B21.3|H|D||",
        "X04|K714|1234||20190121|XA160||J|0001|20190121|2024|18111600|"]

    static var fall_unterbrEX30 = [
        "X01|K714|1234||20190121|1200|S|19960601|80|M|AT|AT|1010|90101|A|P||||E|20190624|1200|11|J|0",
        "X02|K714|1234||20190121|01|11111100|20190121||J||||||N|80|",
        "X02|K714|1234||20190121|02|10000000|20190126||J||||||N|80|",
        "X02|K714|1234||20190121|03|11111100|20190126||J||||||N|80|",
        "X03|K714|1234||20190121|B21.3|H|D||",
        "X04|K714|1234||20190121|XA160||J|0001|20190121|2024|18111600|"]

    static var fall_unterbrEX34 = [
        "X01|K714|1234||20190121|1200|S|19960601|80|M|AT|AT|1010|90101|A|P||||E|20190130|1200|11|J|0",
        "X02|K714|1234||20190121|01|11111100|20190121||J||||||N|80|",
        "X02|K714|1234||20190121|02|10000000|20190126||J||||||N|80|",
        "X02|K714|1234||20190121|03|11111100|20190130||J||||||N|80|",
        "X03|K714|1234||20190121|B21.3|H|D||",
        "X04|K714|1234||20190121|XA160||J|0001|20190121|2024|18111600|"]

    
    func replace(source:[String], from: String, to: String) -> [String] {
        return lkfcFeatureTests.replace(source:source, from: from, to:to)
    }

    func testUnterbrechung() throws  {
        var context = try createContextWith(model:2020, lines: lkfc2021SP1Tests.fall_unterbr)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        _ = resultForContext(context: context)
        var errors = context.errorsWith (code:"EX32") // Unterbrechung > 5 Tage
        XCTAssert (errors != nil, "error EX32 expected")
        
        var replaced = replace (source: lkfc2021SP1Tests.fall_unterbr, from: "K714", to: "K931")

        context = try createContextWith(model:2019, lines: replaced)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        _ = resultForContext(context: context)
        errors = context.errorsWith (code:"EX32") // Unterbrechung > 5 Tage
        XCTAssert (errors != nil, "error EX32 expected")

        context = try createContextWith(model:2020, lines: replaced)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        _ = resultForContext(context: context)
        errors = context.errorsWith (code:"EX32") // Unterbrechung > 5 Tage
        XCTAssert (errors == nil, "error EX32 not expected")

        context = try createContextWith(model:2021, lines: replaced)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        _ = resultForContext(context: context)
        errors = context.errorsWith (code:"EX32") // Unterbrechung > 5 Tage
        XCTAssert (errors == nil, "error EX32 not expected")

        context = try createContextWith(model:2020, lines: lkfc2021SP1Tests.fall_unterbrEX33)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        _ = resultForContext(context: context)
        errors = context.errorsWith (code:"EX33") // Unterbrechung nach 0-Tage-Aufenthalt
        XCTAssert (errors != nil, "error EX33 expected")
        
        replaced = replace (source: lkfc2021SP1Tests.fall_unterbrEX33, from: "K714", to: "K931")

        context = try createContextWith(model:2019, lines: replaced)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        _ = resultForContext(context: context)
        errors = context.errorsWith (code:"EX33")
        XCTAssert (errors != nil, "error EX33 expected")

        context = try createContextWith(model:2020, lines: replaced)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        _ = resultForContext(context: context)
        errors = context.errorsWith (code:"EX33")
        XCTAssert (errors == nil, "error EX33 not expected")

        context = try createContextWith(model:2021, lines: replaced)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        _ = resultForContext(context: context)
        errors = context.errorsWith (code:"EX33")
        XCTAssert (errors == nil, "error EX33 not expected")

        context = try createContextWith(model:2020, lines: lkfc2021SP1Tests.fall_unterbrEX30)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        _ = resultForContext(context: context)
        errors = context.errorsWith (code:"EX30") // Unterbrechung unter 1 Nacht
        XCTAssert (errors != nil, "error EX30 expected")
        
        replaced = replace (source: lkfc2021SP1Tests.fall_unterbrEX30, from: "K714", to: "K931")

        context = try createContextWith(model:2020, lines: replaced)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        _ = resultForContext(context: context)
        errors = context.errorsWith (code:"EX30") // Unterbrechung unter 1 Nacht auch für Nicht-Fonds
        XCTAssert (errors != nil, "error EX30 expected")

        
        context = try createContextWith(model:2020, lines: lkfc2021SP1Tests.fall_unterbrEX34)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        _ = resultForContext(context: context)
        errors = context.errorsWith (code:"EX34") // Unterbrechung nach 0-Tage-Aufenthalt
        XCTAssert (errors != nil, "error EX34 expected")
        
        replaced = replace (source: lkfc2021SP1Tests.fall_unterbrEX34, from: "K714", to: "K931")

        context = try createContextWith(model:2019, lines: replaced)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        _ = resultForContext(context: context)
        errors = context.errorsWith (code:"EX34")
        XCTAssert (errors != nil, "error EX34 expected")

        context = try createContextWith(model:2020, lines: replaced)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        _ = resultForContext(context: context)
        errors = context.errorsWith (code:"EX34")
        XCTAssert (errors == nil, "error EX34 not expected")

        context = try createContextWith(model:2021, lines: replaced)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        _ = resultForContext(context: context)
        errors = context.errorsWith (code:"EX34")
        XCTAssert (errors == nil, "error EX34 not expected")

        
    }

    static var fall_onkoXA1 = [
        "X01|K714|1234||20190621|1200|S|19960601|80|M|AT|AT|1010|90101|A|P||||E|20190624|1200|11|J|0",
        "X02|K714|1234||20190621|01|11111100|20190621||J||||||N|80|",
        "X03|K714|1234||20190621|B21.3|H|D||",
        "X04|K714|1234||20190621|XA160||J|0001|20190621|2024|18111600|"]

    static var fall_onkoXA2 = [
        "X01|K714|1234||20190621|1200|S|19960601|80|M|AT|AT|1010|90101|A|P||||E|20190624|1200|11|J|0",
        "X02|K714|1234||20190621|01|11111100|20190621||J||||||N|80|",
        "X03|K714|1234||20190621|M70.7|H|D||",
        "X04|K714|1234||20190621|XA330||J|0001|20190621|2024|18111600|"]

    static var fall_onkoXB = [
        "X01|K714|1234||20190621|1200|S|19960601|80|M|AT|AT|1010|90101|A|P||||E|20190624|1200|11|J|0",
        "X02|K714|1234||20190621|01|11111100|20190621||J||||||N|80|",
        "X03|K714|1234||20190621|B21.3|H|D||",
        "X04|K714|1234||20190621|XB220||J|0001|20190621|2024|18111600|"]

    static var fall_onkoXC = [
        "X01|K714|1234||20190621|1200|S|19960601|80|M|AT|AT|1010|90101|A|P||||E|20190624|1200|11|J|0",
        "X02|K714|1234||20190621|01|11111100|20190621||J||||||N|80|",
        "X03|K714|1234||20190621|B21.3|H|D||",
        "X04|K714|1234||20190621|XC048||J|0001|20190621|2024|18111600|"]

    func testOnko() throws  {
        var context = try createContextWith(model:2021, lines: lkfc2021SP1Tests.fall_onkoXA1)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        var result = resultForContext(context: context)
        XCTAssert(result == "X05|K714|1234||20190621|HDG16.12|A|||473|1166|||||1639", "result differs")
        var errors = context.errorsWith (code:"HX05") // keine Onko-Diagnose XA
        XCTAssert (errors != nil, "info HX05 expected")

        context = try createContextWith(model:2021, lines: lkfc2021SP1Tests.fall_onkoXA2)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        result = resultForContext(context: context)
        errors = context.errorsWith (code:"HX05") // SP1: gr.XA250 => kein HX05
        XCTAssert (errors == nil, "info HX05 not expected")
        
        context = try createContextWith(model:2021, lines: lkfc2021SP1Tests.fall_onkoXB)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        result = resultForContext(context: context)
        errors = context.errorsWith (code:"HX05") // keine Onko-Diagnose XB
        XCTAssert (errors != nil, "info HX05 expected")

        context = try createContextWith(model:2021, lines: lkfc2021SP1Tests.fall_onkoXC)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        result = resultForContext(context: context)
        errors = context.errorsWith (code:"HX05") // keine Onko-Diagnose XC
        XCTAssert (errors != nil, "info HX05 expected")
    }
    
    static var fall_onkoSP2 = [
        "X01|K714|1234||20190621|1200|S|19960601|80|M|AT|AT|1010|90101|A|P||||E|20190624|1200|11|J|0",
        "X02|K714|1234||20190621|01|11111100|20190621||J||||||N|80|",
        "X03|K714|1234||20190621|B21.3|H|D||",
        "X03|K714|1234||20190621|B21.7|Z|D||",
        "X04|K714|1234||20190621|XA130||J|0001|20190621|2024|18111600|"]


    func replace(testCase:[String], source:String, dest:String) -> [String] {
        var arr = [String]()
        for s in testCase {
            arr.append(s.replacingOccurrences(of: source, with: dest))
        }
        return arr
    }
    
    
    func testOnkoSP2() throws {
        var context = try createContextWith(model:2021, lines: lkfc2021SP1Tests.fall_onkoSP2)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        var result = resultForContext(context: context)
        XCTAssert(result == "X05|K714|1234||20190621|HDG16.12|A|||473|1166|||||1639", "result differs")
        var errors = context.errorsWith (code:"HX05") // keine Onko-Diagnose XA
        XCTAssert (errors != nil, "info HX05 expected")

        let okDiag = replace(testCase: lkfc2021SP1Tests.fall_onkoSP2, source: "B21.3", dest: "C00.3")
        context = try createContextWith(model:2021, lines: okDiag)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        result = resultForContext(context: context)
        XCTAssert(result == "X05|K714|1234||20190621|MEL22.07|A|||869|1204|||||2073", "result differs")
        errors = context.errorsWith (code:"HX05") // keine Onko-Diagnose XA
        XCTAssert (errors == nil, "info HX05 not expected")

        let replXA200 = replace(testCase: okDiag, source: "XA130", dest: "XA200")
        context = try createContextWith(model:2021, lines: replXA200)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        result = resultForContext(context: context)
        XCTAssert(result == "X05|K714|1234||20190621|MEL22.13|D|||310|1488|||||1798", "result differs")
        errors = context.errorsWith (code:"HX05") // keine Onko-Diagnose XA
        XCTAssert (errors == nil, "info HX05 not expected")
        
        var specHDiag = replace(testCase: replXA200, source: "C00.3", dest: "D69.3")
        context = try createContextWith(model:2021, lines: specHDiag)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        result = resultForContext(context: context)
        XCTAssert(result == "X05|K714|1234||20190621|MEL22.13|D|||310|1488|||||1798", "result differs")
        errors = context.errorsWith (code:"HX05") // keine Onko-Diagnose XA
        XCTAssert (errors == nil, "info HX05 not expected")

        specHDiag = replace(testCase: replXA200, source: "C00.3", dest: "D64.8")
        context = try createContextWith(model:2021, lines: specHDiag)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        result = resultForContext(context: context)
        XCTAssert(result == "X05|K714|1234||20190621|MEL22.13|D|||310|1488|||||1798",  "result differs")
        errors = context.errorsWith (code:"HX05") // keine Onko-Diagnose XA
        XCTAssert (errors == nil, "info HX05 not expected")
        
        let onkoZDiag = replace(testCase: lkfc2021SP1Tests.fall_onkoSP2, source: "B21.7", dest: "D69.3")
        context = try createContextWith(model:2021, lines: onkoZDiag)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        result = resultForContext(context: context)
        XCTAssert(result == "X05|K714|1234||20190621|HDG16.12|A|||473|1166|||||1639", "result differs")
        errors = context.errorsWith (code:"HX05") // keine Onko-Diagnose XA
        XCTAssert (errors != nil, "info HX05 expected")

        var specZDiag = replace(testCase: onkoZDiag, source: "D69.3", dest: "C00.3")
        context = try createContextWith(model:2021, lines: specZDiag)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        result = resultForContext(context: context)
        XCTAssert(result == "X05|K714|1234||20190621|MEL22.07|A|||869|1204|||||2073", "result differs")
        errors = context.errorsWith (code:"HX05") // keine Onko-Diagnose XA
        XCTAssert (errors == nil, "info HX05 not expected")
        
        specZDiag = replace(testCase: onkoZDiag, source: "XA130", dest: "XA200")
        context = try createContextWith(model:2021, lines: specZDiag)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        result = resultForContext(context: context)
        XCTAssert(result == "X05|K714|1234||20190621|MEL22.13|D|||310|1488|||||1798", "result differs")
        errors = context.errorsWith (code:"HX05") // keine Onko-Diagnose XA
        XCTAssert (errors == nil, "info HX05 not expected")

    }
    
    static var fall_zn800 = [
        "X01|K714|1234||20190621|1200|S|19960601|80|M|AT|AT|1010|90101|A|P||||S|20190624|1200|11|J|0",
        "X02|K714|1234||20190621|01|11111100|20190621||J||||||N|80|",
        "X03|K714|1234||20190621|A32.0|H|D||",
        "X03|K714|1234||20190621|R99|Z|D||",
        "X04|K714|1234||20190621|ZN800||J|0001|20190621|2024|18111600|"]

    static var fall_zn800_noR99 = [
        "X01|K714|1234||20190621|1200|S|19960601|80|M|AT|AT|1010|90101|A|P||||S|20190624|1200|11|J|0",
        "X02|K714|1234||20190621|01|11111100|20190621||J||||||N|80|",
        "X03|K714|1234||20190621|A32.0|H|D||",
        "X04|K714|1234||20190621|ZN800||J|0001|20190621|2024|18111600|"]

    static var fall_zn800entartE = [
        "X01|K714|1234||20190621|1200|S|19960601|80|M|AT|AT|1010|90101|A|P||||E|20190624|1200|11|J|0",
        "X02|K714|1234||20190621|01|11111100|20190621||J||||||N|80|",
        "X03|K714|1234||20190621|A32.0|H|D||",
        "X03|K714|1234||20190621|R99|Z|D||",
        "X04|K714|1234||20190621|ZN800||J|0001|20190621|2024|18111600|"]

    
    static var fall_zn800A = [
        "X01|K714|1234||20190621|1200|I|19960601|80|M|AT|AT|1010|90101|1|P||||8|20190621|1200|11|J|0",
        "X02|K714|1234||20190621|01|16111100|20190621||J||||||N|80|",
        "X03|K714|1234||20190621|A32.0|H|D||",
        "X03|K714|1234||20190621|R99|Z|D||",
        "X04|K714|1234||20190621|ZN800||J|0001|20190621|2024|18111600|"]

    static var fall_zn800A_R99 = [
        "X01|K714|1234||20190621|1200|I|19960601|80|M|AT|AT|1010|90101|1|P||||7|20190621|1200|11|J|0",
        "X02|K714|1234||20190621|01|16111100|20190621||J||||||N|80|",
        "X03|K714|1234||20190621|R99|H|D||"]

    
    
    func testZN800() throws {

        var context = try createContextWith(model:2021, lines: lkfc2021SP1Tests.fall_zn800)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        var result = resultForContext(context: context)
        XCTAssert(result == "X05|K714|1234||20190621|HDG16.03|A|70|3092|||||||3162", "result differs")
        
        context = try createContextWith(model:2021, lines: lkfc2021SP1Tests.fall_zn800entartE)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        result = resultForContext(context: context)
        var errors = context.errorsWith (code:"EX25") // MEL-Entart
        XCTAssert (errors != nil, "error EX25 expected")
        errors = context.errorsWith (code:"EX3U") // DIAG-EntArt
        XCTAssert (errors != nil, "error EX3U expected")

        context = try createContextWith(model:2020, lines: lkfc2021SP1Tests.fall_zn800A)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        _ = resultForContext(context: context)
        errors = context.errorsWith (code:"EX3U") // DIAG-EntArt
        XCTAssert (errors != nil, "error EX3U expected")


        context = try createContextWith(model:2021, lines: lkfc2021SP1Tests.fall_zn800A)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        result = resultForContext(context: context)
        XCTAssert(result == "X05|K714|1234||20190621|APG00.10|C||30|||||||30", "result differs")

        context = try createContextWith(model:2020, lines: lkfc2021SP1Tests.fall_zn800A_R99)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        result = resultForContext(context: context)
        errors = context.errorsWith (code:"EX3U") // DIAG-EntArt
        XCTAssert (errors != nil, "error EX3U expected")

        context = try createContextWith(model:2021, lines: lkfc2021SP1Tests.fall_zn800A_R99)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        result = resultForContext(context: context)
        XCTAssert(result == "X05|K714|1234||20190621|APG00.00|C||25|||||||25", "result differs")
    }
    
    static var fall_FATG = [
        "X01|K955|234||20200314|0930|S|19490101|70|M|AT|AT|1230|92301|A|A||||E|20200319|1000|07|J|||",
        "X02|K955|234||20200314|001|12718101|20200314|0930||20200315|0930|1|||N|70|",
        "X02|K955|234||20200314|002|11111103|20200315|0930|||||||N|70|",
        "X03|K955|234||20200314|R55|Z|||",
        "X03|K955|234||20200314|I71.9|H|||",
        "X03|K955|234||20200314|I47.1|Z|||",
        "X03|K955|234||20200314|I10|Z|||",
        "X04|K955|234||20200314|DZ510||J|1|20200315|1155|16111103||",
        "X04|K955|234||20200314|ZB020||J|1|20200318|1132|17725100||",
        "X04|K955|234||20200314|ZB520||J|1|20200315|1249|17725100||",
        "X04|K955|234||20200314|ZC020||J|1|20200318|1132|17725100||",
        "I11|K955|234||20200314|000|20200314|00|1|2|0|0|12|0|0|1|0|0|0|2|6,25||0323|00|3|6|5|4|085|000000000000000000011|36,6|0|||1,1|1,18|110|000|7",
        "I11|K955|234||20200314|001|20200314|00|1|2|0|0|12|0|0|0|0|0|0|2|6,25||0323|00|3|6|5|4|065|000000000000000000001|36,5|0|||1,1|1,18|130|000|7",
        "I12|K955|234||20200314|000|20200314|1|1|2|1|0|0|1|0|1|0|0|0|0|0|0|0|1|0|0|0|0|0|0|0|4|0|0|0|0|0",
        "I12|K955|234||20200314|000|20200315|1|1|2|1|0|0|1|0|1|0|0|0|0|0|0|0|1|0|0|0|0|0|0|0|4|0|0|0|0|0",
        "I12|K955|234||20200314|001|20200314|1|1|2|1|0|0|1|0|1|0|0|0|0|0|0|0|1|0|0|0|0|0|0|0|4|0|0|0|0|0",
        "I12|K955|234||20200314|001|20200315|1|1|2|1|0|0|1|0|1|0|0|0|0|0|0|0|1|0|0|0|0|0|0|0|4|0|0|0|0|0"]
    

    func testFATG() throws {
        let context = try createContextWith(model:2021, lines: lkfc2021SP1Tests.fall_FATG)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        _ = resultForContext(context: context)
        let errors = context.errorsWith (code:"FATG") // X02 fehlt
        XCTAssert (errors != nil, "error FATG expected")
    }

    static var fall_quickscore_afg = [
        "X01|K524|123||20210102|0818|I|20180502|1|W|RU|AT|5020|50101|||||||||17|J|||",
        "X04|K524|123||20210102|BL550||J|1|20210102|0818|16411100||1076772921",
        "X04|K524|123||20210102|BL590||J|1|20210102|0818|16411100||1076772921",
        "X04|K524|123||20210102|BZ989||J|1|20210102|0818|16411100||1076772921",
        "X04|K524|123||20210102|ZZ533||J|2|20210102|0818|16411100||1076772921",
        "X05|K524|123||20210102|APG00.10|B|0|50|0|0|0|0|0|0|50"]

    func testQuickscoreAFG() throws {
        let context = try createContextWith(model:2021, lines: lkfc2021SP1Tests.fall_quickscore_afg)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        context.flags = (1<<6)
        /*
        context.tracingStart (options:LKFContextTraceOptions()) { line in
            print (line)
        }
        */
        let result = resultForContext(context: context)
        XCTAssert (result == "X05|K524|123||20210102|APG00.10|B||50|||||||50", "result differs (\(result)")
        context.tracingEnd()
    }

    
    static var fall_tracing = [
        "X01|K524|123||20210102|0818|I|20180502|1|W|RU|AT|5020|50101|||||||||17|J|||",
        "X02|K524|123||20210102|001|16411100|20210102|0818|J|||||||1|1076772921",
        "X04|K524|123||20210102|BL550||J|1|20210102|0818|16411100||1076772921",
        "X04|K524|123||20210102|BL590||J|1|20210102|0818|16411100||1076772921",
        "X04|K524|123||20210102|BZ989||J|1|20210102|0818|16411100||1076772921",
        "X04|K524|123||20210102|ZZ533||J|2|20210102|0818|16411100||1076772921",
        "X05|K524|123||20210102|APG00.10|B|0|50|0|0|0|0|0|0|50"]
    
    func testTracing() throws {
        let context = try createContextWith(model:2021, lines: lkfc2021SP1Tests.fall_tracing)
        XCTAssert (context.lastError == nil, "couldn't not execute case" + context.lastError!.message)
        context.tracingStart (options:LKFContextTraceOptions()) { line in
            // print (line)
        }
        let result = resultForContext(context: context)
        XCTAssert (result == "X05|K524|123||20210102|APG00.10|B||50|||||||50", "result differs (\(result)")
        context.tracingEnd()
    }
    
    static var fall_sharpDiagAmb = [
        "X01|K380|123||20210105|1237|I|19530101|70|W|AT|AT|2325|30732|||||||||12|J|0||",
        "X02|K380|123||20210105|001|16211111|20210105|1237|J||||||N|80",
        "X02|K380|123||20210105|002|17721111|20210105|1306|J||||||N|80",
        "X02|K380|123||20210105|003|17721411|20210105|1313|J||||||N|80",
        "X03|K380|123||20210105|Z00.8|H|||2155034486",
        "X04|K380|123||20210105|EC010|R|J|0001|20210105|1313|17721411"
    ]
    
    static var fall_sharpAddLeist = [
        "X04|K380|123||20210105|ZB520||J|0001|20210105|1306|17721111"
    ]
  
    func testSharpDiagAmb () throws {
        var context = try createContextWith (model: 2021, lines: lkfc2021SP1Tests.fall_sharpDiagAmb)
        try context.execute()
        var errors = context.errorsWith (code:"EX1N")
        XCTAssert (errors != nil, "ZD: EX1N not returned with SP2")

        context = try createContextWith (model: 2020, lines: combine (lkfc2021SP1Tests.fall_sharpDiagAmb, lkfc2021SP1Tests.fall_sharpAddLeist))
        try context.execute()
        XCTAssert(resultForContext(context: context) == "X05|K380|123||20210105|||||||||||", "invalid result for model 2020")

        context = try createContextWith (model: 2021, lines: combine (lkfc2021SP1Tests.fall_sharpDiagAmb, lkfc2021SP1Tests.fall_sharpAddLeist))
        try context.execute()
        errors = context.errorsWith (code:"EX1N")
        XCTAssert (errors != nil, "ZD: EX1N not returned with SP2")
    }

    static var fall_EX1L = [
        "X01|K901|2||20210101|0010|S|19340101|85|M|AT|AT|8010|60101|A|P||||E|20210104|1000|15|J|0||",
        "X02|K901|2||20210101|001|11111100|20210101||||||||N|85|",
        "X03|K901|2||20210101|E10.0|H|||",
        "X03|K901|2||20210101|I10|H|||"
    ]

    static var fall_EX1LacceptStat = [
        "X01|K901|2||20210101|0010|S|19340101|85|M|AT|AT|8010|60101|A|P||||E|20210104|1000|15|J|0||",
        "X02|K901|2||20210101|001|11111100|20210101||||||||N|85|",
        "X03|K901|2||20210101|I10|H|||",
        "X03|K901|2||20210101|E10.0|H|||",
        "X06|K901|2||20210101|I10|EX1L|"
    ]

    
    static var fall_EX1LacceptAmb = [
        "X01|K214|01||20190101|0120|I|19900101|25|M|AT|AT|9102|20817|||||||||16|J|0",
        "X02|K214|01||20190101|001|16115001|20190101|0120|J||||||N|25|",
        "X02|K214|01||20190101|002|17821100|20190101|0120|J||||||N|25|",
        "X03|K214|01||20190101|R51|H|D||",
        "X03|K214|01||20190101|R51|H|D||",
        "X03|K214|01||20190101|I10|H|D||",
        "X04|K214|01||20190101|ZX540||J|1|20190101|0120|17821100||",
        "X06|K214|01||20190101|R51|EX1L|"
    ]

    
    func testEX1L () throws {
        var context = try createContextWith (model: 2021, lines: lkfc2021SP1Tests.fall_EX1L)
        try context.execute()
        var errors = context.errorsWith (code:"EX1L")
        XCTAssert (errors != nil, "EX1L missing")
        context = try createContextWith (model: 2020, lines: lkfc2021SP1Tests.fall_EX1L)
        try context.execute()
        errors = context.errorsWith (code:"EX1L")
        XCTAssert (errors == nil, "EX1L not expected with model 2020")

        context = try createContextWith (model: 2021, lines: lkfc2021SP1Tests.fall_EX1LacceptStat)
        try context.execute()
        errors = context.errorsWith (code:"EX1L")
        XCTAssert (errors != nil, "EX1L cannot be accepted")

        context = try createContextWith (model: 2020, lines: lkfc2021SP1Tests.fall_EX1LacceptAmb)
        try context.execute()
        errors = context.errorsWith (code:"EX1L")
        XCTAssert (errors != nil, "EX1L cannot be accepted 2020")

        context = try createContextWith (model: 2021, lines: lkfc2021SP1Tests.fall_EX1LacceptAmb)
        try context.execute()
        errors = context.errorsWith (code:"EX1L")
        XCTAssert (errors == nil, "EX1L accepted 2021")

    }
    
    static var fall_zz710_2021 = [
        "X01|K214|01||20190101|0120|I|19900101|25|M|AT|AT|9102|20817|||||||||16|J|0",
        "X02|K214|01||20190101|001|16115001|20190101|0120|J||||||N|25|",
        "X02|K214|01||20190101|002|17821100|20190101|0120|J||||||N|25|",
        "X03|K214|01||20190101|R51|H|D||",
        "X03|K214|01||20190101|I10|Z|D||",
        "X04|K214|01||20190101|ZX540||J|1|20190101|0120|17821100||"
    ]
    
    static var korrabt = ["X04|K214|01||20190101|ZZ710||J|1|20190101|0125|16115001||"]
    static var otherabt = ["X04|K214|01||20190101|ZZ710||J|1|20190101|0125|17821100||"]
    
    func testZZ710 () throws {
        
        let fallKorr = combine(lkfc2021SP1Tests.fall_zz710_2021, lkfc2021SP1Tests.korrabt)
        let fallNKorr = combine(lkfc2021SP1Tests.fall_zz710_2021, lkfc2021SP1Tests.otherabt)
        
        var context = try createContextWith (model: 2020, lines: fallKorr)
        try context.execute()
        var errors = context.errorsWith (code:"WX3Q")
        XCTAssert (errors != nil, "WX3Q expected")

        var result = resultForContext(context: context)
        XCTAssert(result == "X05|K214|01||20190101|APG18.03|A|100|35|||||||135", "result differs")
        
        context = try createContextWith (model: 2021, lines: fallKorr)
        try context.execute()
        errors = context.errorsWith (code:"WX3Q")
        XCTAssert (errors != nil, "WX3Q expected")
        result = resultForContext(context: context)
        XCTAssert(result == "X05|K214|01||20190101|APG00.00|C||25|||||||25", "result differs")

        context = try createContextWith (model: 2021, lines: fallNKorr)
        try context.execute()
        errors = context.errorsWith (code:"WX3Q")
        XCTAssert (errors != nil, "WX3Q expected")
        errors = context.errorsWith (code:"EX4R")
        XCTAssert (errors != nil, "EX4R not expected")


        /*
        var errors = context.errorsWith (code:"EX1L")
        XCTAssert (errors != nil, "EX1L missing")
        context = try createContextWith (model: 2020, lines: lkfc2021SP1Tests.fall_EX1L)
        try context.execute()
        errors = context.errorsWith (code:"EX1L")
        XCTAssert (errors == nil, "EX1L not expected with model 2020")
        */
    }
    
    static var fall_diffSP2 = [
    "X01|K612|123||20210103|0735|I|19560101|60|W|AT|AT|8020|60101|||||||||15|J|0",
    "X02|K612|123||20210103|001|16116400|20210103|0700|J||||||N|60|",
    "X02|K612|123||20210103|002|17821101|20210103|2300|N||||||N|60|",
    "X04|K612|123||20210103|XA149||J|1|20210103|0735|16116400||",
    "X04|K612|123||20210103|ZV510||J|1|20210103|0735|16116400||",
    "X04|K612|123||20210103|ZZ533||J|1|20210103|0735|16116400||",
    "X04|K612|123||20210103|ZZ533||J|1|20210103|0735|16116400||",
    ]
    
    func testDiffSP2 () throws {
        let context = try createContextWith (model: 2021, lines: lkfc2021SP1Tests.fall_diffSP2)
        try context.execute()
        let result = context.getResultLine(forIndex: 0)
        //var errors = context.errorsWith (code:"WX3Q")
        XCTAssert (result == "X05|K612|123||20210103|APG00.25|B||30|||||||30", "result differs")
    }
    
    static var fall_meldata = ["X01|K901|001||20220101|1200|S|19360501|85|M|AT|AT|1010|90101|A|P||||E|20220104|1200|06|N|1||",
         "X02|K901|001||20220101|001|11111100|20220101||||||||N|85|",
         "X03|K901|001||20220101|C00.0|H|||",
         "X04|K901|001||20220101|DE080||J|1|20220101||11111100||",
         "X04|K901|001||20220101|DE150||J|1|20220101||11111100||"]

    static var fall_meldata2 = [ "X01|K920|123||20170101|0000|S|19410101|50|M|AT|AT|1220|92201|A|A||||E|20170102|0000|05|K|3",
    "X02|K920|123||20170101|001|11221100|20170330||||||||N|50|",
    "X03|K920|123||20170101|M75.3|H|||",
    "X04|K920|123||20170101|JC010||J|0001|20170101|0000|11221100||",
    "X04|K920|123||20170101|PZ580||J|0001|20170101|0000|11221100||"]

    static var fall_meldata3 = [
    "X01|K612|111||20190402|1754|S|19310411|85|M|AT|AT|8715|62045|A|A||||E|20190415|1010|15|J|2",
    "X02|K612|111||20190402|001|13211100|20190402|1754|||||||N|85|",
    "X02|K612|111||20190402|002|12718100|20190403|0239||20190404|1145|1|||N|85|",
    "X02|K612|111||20190402|003|12918103|20190404|1145||20190405|1513|1|||N|85|",
    "X02|K612|111||20190402|004|13268900|20190405|1513|||||||N|85|",
    "X03|K612|111||20190402|S48.1|H|||",
    "X03|K612|111||20190402|901.9|Z|||",
    "X03|K612|111||20190402|I10|Z|||",
    "X03|K612|111||20190402|N40|Z|||",
    "X03|K612|111||20190402|S42.31|Z|||",
    "X03|K612|111||20190402|S51.0|Z|||",
    "X03|K612|111||20190402|T05.2|Z|||",
    "X03|K612|111||20190402|T79.6|Z|||",
    "X04|K612|111||20190402|AJ090|R|J|1|20190402|1919|18309500||",
    "X04|K612|111||20190402|EC050|R|J|1|20190402|1919|18309500||",
    "X04|K612|111||20190402|EC070|R|J|1|20190402|1919|18309500||",
    "X04|K612|111||20190402|EK079|L|J|1|20190402|1919|18309500||",
    "X04|K612|111||20190402|EP069||J|1|20190402|1919|18309500||",
    "X04|K612|111||20190402|MB020|R|J|1|20190402|1919|18309500||",
    "X04|K612|111||20190402|MJ090|R|J|1|20190402|1919|18309500||",
    "X04|K612|111||20190402|MJ140|R|J|1|20190402|1919|18309500||",
    "X04|K612|111||20190402|PE010||J|1|20190403|1045|18216700||",
    "X04|K612|111||20190402|QZ050||J|1|20190402|1919|18309500||",
    "X04|K612|111||20190402|QZ070||J|1|20190402|1919|18309500||",
    "X04|K612|111||20190402|QZ109||J|1|20190410|1318|18269500||",
    "X04|K612|111||20190402|ZA010||J|1|20190402|1835|17721300||",
    "X04|K612|111||20190402|ZB010||J|1|20190402|1836|17721300||",
    "X04|K612|111||20190402|ZD020||J|1|20190402|1836|17721300||",
    "X04|K612|111||20190402|ZN250||J|1|20190402|1835|17721300||",
    "X05|K612|111||20190402|MEL09.01|D|3034|6946||||2495|3221||15696",
    "I11|K612|111||20190402|002|20190403|00|0|3|0|0|00|0|0|0|0|0|1|2||7,35||32|2|1|1|1||000000000000000000001||1||||1,2||011|5",
    "I11|K612|111||20190402|003|20190404|00|0|3|0|0|00|0|0|0|0|0|0|1||||32|2|6|5|4||000000000000000000000||0||||||000|3",
    "I12|K612|111||20190402|002|20190403|1|1|2|3|1|4|4|1|1|1|0|1|0|0|0|0|1|1|0|0|0|0|0|0|3|0|0|0|0|0",
    "I12|K612|111||20190402|002|20190404|1|1|2|3|1|0|1|0|1|0|0|1|0|0|0|0|1|1|0|0|0|0|0|0|4|0|0|0|0|0",
    "I12|K612|111||20190402|003|20190404|1|1|2|3|1|0|1|0|1|0|0|1|0|0|0|0|1|1|0|0|0|0|0|0|4|0|0|0|0|0",
    "I12|K612|111||20190402|003|20190405|1|1|2|3|1|0|1|0|0|0|0|1|0|0|0|0|1|0|0|0|0|0|0|0|0|0|0|0|0|0"
    ]

    
    
    func testMELData () throws {
        var context = try createContextWith (model: 2022, lines: lkfc2021SP1Tests.fall_meldata)
        // context.setContextParameters(year: 2022)
        try context.execute()
        
        if context.getAufenthaltCount() != 1 {
            XCTAssert (false, "fehlerhafte Anzahl Aufenthalte (expected=1, actual=\(context.getAufenthaltCount())")
            return
        }
        
        var result = context.getResultLine(forIndex: 0)
        //var errors = context.errorsWith (code:"WX3Q")
        
        var aufenthalt = context[0]
        
        for i in 0..<aufenthalt.melCount {
            let mel = aufenthalt.melAt(index: i)
            let melResult = mel.scoringData()
            
            if mel.MEL == "DE150" {
                XCTAssert(melResult.melmelInfo == "WX3T", "WX3T expected")
            }
            else if mel.MEL == "DE080" {
                XCTAssert(melResult.melmelInfo == "", "empty melmelinfo expected")

            }
            else {
                XCTAssert(false, "unknown MEL")
            }
            
          //  print ("\(mel.MEL) (\(mel.MELANZString)/\(melResult.date)): \(melResult.gruppe)/\(melResult.knoten) \(melResult.relevant) \(melResult.leist) \(melResult.melmelInfo)")
        }
        
        XCTAssert (result == "X05|K901|001||20220101|MEL10.01|B|3081|3391|||||||6472", "result differs")
        
        
        context = try createContextWith (model: 2019, lines: lkfc2021SP1Tests.fall_meldata3)
        try context.execute()
        result = context.getResultLine(forIndex: 0)
        aufenthalt = context[0]
        /*
        print ("---")
        for i in 0..<aufenthalt.melCount {
            let mel = aufenthalt.melAt(index: i)
            let melResult = mel.scoringData()

            print ("\(mel.MEL) (\(mel.MELANZString)/\(melResult.date)): \(melResult.gruppe)/\(melResult.knoten) \(melResult.relevant) \(melResult.leist) - \(melResult.melmelPool):\(melResult.melmelInfo)")

        }
         */

        context = try createContextWith (model: 2018, lines: lkfc2021SP1Tests.fall_meldata2)
        context.setContextParameters(year: 2017)
        try context.execute()   
        result = context.getResultLine(forIndex: 0)
        aufenthalt = context[0]
        /*
        print ("---")
        for i in 0..<aufenthalt.melCount {
            let mel = aufenthalt.melAt(index: i)
            let melResult = mel.scoringData()

            print ("\(mel.MEL) (\(mel.MELANZString)/\(melResult.date)): \(melResult.gruppe)/\(melResult.knoten) \(melResult.relevant) \(melResult.leist) - \(melResult.melmelPool):\(melResult.melmelInfo)")

        }
         */
    }
}
