186 lines
6.6 KiB
C#
186 lines
6.6 KiB
C#
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BS.Shared.DataContracts;
|
|
using Dakota;
|
|
using Dakota.Models;
|
|
using Dakota.Models.Infos;
|
|
using Dakota.Models.Schlüssels;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace BeWo.Service.ServiceUtils.Generell
|
|
{
|
|
public static class DakotaFileCreator
|
|
{
|
|
internal struct DakotaKeyDictionary
|
|
{
|
|
public DateTime DateTime { get; set; }
|
|
public Kassenart Kassenart { get; set; }
|
|
public string Kostenträger { get; set; }
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
if (obj == null || GetType() != obj.GetType())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
var objectToCompareWith = (DakotaKeyDictionary)obj;
|
|
|
|
return objectToCompareWith.DateTime == DateTime && objectToCompareWith.Kassenart == Kassenart &&
|
|
objectToCompareWith.Kostenträger == Kostenträger;
|
|
|
|
}
|
|
}
|
|
|
|
public static List<string> GenerateDakotaFilesByMonth(int year, int month)
|
|
{
|
|
var dict = GenerateDakotaFiles(year, month);
|
|
|
|
return dict.Values.Select(x => x.GetRows()).ToList();
|
|
}
|
|
|
|
internal static Dictionary<DakotaKeyDictionary, DakotaFile> GenerateDakotaFiles(int year, int month)
|
|
{
|
|
// Datum, Kassenart, Kostenträger
|
|
var res = new Dictionary<DakotaKeyDictionary, DakotaFile>();
|
|
|
|
var invoiceitems = DAOFactory.GenericDAO.GetAllActive<InvoiceItem>();
|
|
|
|
var first = new DateTime(year, month, 1);
|
|
var last = new DateTime(year, month, 1).AddMonths(1).AddDays(-1);
|
|
|
|
var filtered = invoiceitems.Where(x => x.ItemPeriodStart == first && x.ItemPeriodEnd == last);
|
|
|
|
foreach (var invoice in filtered)
|
|
{
|
|
// Aufteilen
|
|
// 1. Monat/Jahr - erstmal gleich
|
|
// 2. Kassenart - aok, bkk, lkk
|
|
// Kostenträger - kt1, kt2, kt3
|
|
// Leistungsbereich - immer soziotherapie
|
|
|
|
|
|
DakotaKeyDictionary currentkey = new DakotaKeyDictionary
|
|
{
|
|
DateTime = first,
|
|
Kassenart = Kassenart.BKK,
|
|
Kostenträger = ""
|
|
};
|
|
|
|
var dakota = GetDakotaFile(res, currentkey, invoice);
|
|
|
|
var invoiceinfo = GetDakotaFileInvoiceItem(dakota.FileInfo, invoice);
|
|
|
|
dakota.AddInvoiceItem(invoiceinfo);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get Dakota File. Creates if doesn't exist
|
|
/// </summary>
|
|
/// <param name="dict">current Dict</param>
|
|
/// <param name="key"></param>
|
|
/// <param name="invoice"></param>
|
|
/// <returns></returns>
|
|
internal static DakotaFile GetDakotaFile(Dictionary<DakotaKeyDictionary, DakotaFile> dict, DakotaKeyDictionary key, InvoiceItem invoice)
|
|
{
|
|
var dakota = dict.FirstOrDefault(keypair => keypair.Key.Equals(key)).Value;
|
|
|
|
if (dakota is null)
|
|
{
|
|
var info = LoadInfo(invoice);
|
|
|
|
dakota = new DakotaFile(info);
|
|
|
|
dict.Add(key, dakota);
|
|
}
|
|
|
|
return dakota;
|
|
}
|
|
|
|
internal static DakotaInvoiceItemInfo GetDakotaFileInvoiceItem(DakotaFileInfo fileinfo, InvoiceItem invoice)
|
|
{
|
|
var invoiceinfo = new DakotaInvoiceItemInfo();
|
|
|
|
invoiceinfo.IKLeistungserbringer = fileinfo.IKLeistungserbringers;
|
|
invoiceinfo.IKAbsender = fileinfo.Absenderbezeichnung;
|
|
invoiceinfo.IKEmpfänger = fileinfo.Empfangerbezeichnung;
|
|
invoiceinfo.IKKostentrager = fileinfo.Empfangerbezeichnung;
|
|
invoiceinfo.IKKrankenkasse = "112233445";
|
|
invoiceinfo.IKKVKarte = "566778899";
|
|
|
|
invoiceinfo.Verarbeitungskennzeichen = SchlüsselVerarbeitungskennzeichen.AbrechnungOhneBesonderheit;
|
|
// invoiceinfo.
|
|
|
|
return invoiceinfo;
|
|
}
|
|
|
|
public static DakotaFileInfo LoadInfo(InvoiceItem invoice)
|
|
{
|
|
var info = new DakotaFileInfo();
|
|
|
|
info.IKLeistungserbringers = "999888777";
|
|
info.Absenderbezeichnung = "123456789";
|
|
info.Empfangerbezeichnung = "987654321";
|
|
info.Datenaustauschreferenz = 1;
|
|
info.Leistungsbereich = SchlüsselLeistungserbringerSammelgruppenschlussel.SoziotherapeutischerLeistungserbringer;
|
|
info.Anwendungsreferenz = "abovollkra.txt";
|
|
info.Testindikator = SchlüsselTestindikator.Testdatei;
|
|
|
|
info.Created = DateTime.Now;
|
|
|
|
info.Rechnungsdatum = invoice.ItemPeriodEnd.Value;
|
|
info.Rechnungsart = SchlüsselRechnungsart.AbrechnungVonLeistungserbringer;
|
|
|
|
info.Summenstatus = SchlüsselSummenstatus.Mitglieder;
|
|
info.Gesamtrechnungsbetrag = 1;
|
|
info.GesamtbetragZuzahlung = 1;
|
|
info.Gesamtbruttobetrag = 1;
|
|
|
|
info.Name1 = "Hallo Dies";
|
|
info.Name2 = "Dies nicht gut";
|
|
info.Name3 = "Nein";
|
|
info.Name4 = "omg";
|
|
|
|
return info;
|
|
}
|
|
|
|
//public static DakotaFileInfo LoadInfos(List<InvoiceItemDC> invoiceItems)
|
|
//{
|
|
// var res = new DakotaFileInfo();
|
|
|
|
// res.Absenderbezeichnung = "123456789";
|
|
// res.Empfangerbezeichnung = "987654321";
|
|
// res.Datenaustauschreferenz = 1;
|
|
// res.Leistungsbereich = SchlüsselLeistungserbringerSammelgruppenschlussel.SoziotherapeutischerLeistungserbringer;
|
|
// res.Anwendungsreferenz = "abovollkra.txt";
|
|
// res.Testindikator = SchlüsselTestindikator.Testdatei;
|
|
|
|
// res.IKLeistungserbringers = "abovollkrass.txt";
|
|
// // res.Rechnungsnummer = dc.InvoiceBase.InvoiceNumber;
|
|
// // Einheitlich monatlich
|
|
// // res.Rechnungsdatum = dc.InvoiceBase.InvoiceDate.Value;
|
|
|
|
// res.Summenstatus = SchlüsselSummenstatus.Mitglieder;
|
|
// res.Gesamtrechnungsbetrag = 3.5m;
|
|
// res.Gesamtbruttobetrag = 3.5m;
|
|
// res.GesamtbetragZuzahlung = 3.5m;
|
|
// res.Rechnungsart = SchlüsselRechnungsart.AbrechnungVonLeistungserbringer;
|
|
// res.Name1 = "nam7";
|
|
// res.Name2 = "nam4";
|
|
// res.Name3 = "nam3";
|
|
// res.Name4 = "nam1";
|
|
|
|
// res.Verarbeitungskennzeichen = SchlüsselVerarbeitungskennzeichen.AbrechnungOhneBesonderheit;
|
|
|
|
// return res;
|
|
//}
|
|
}
|
|
}
|