146 lines
4.8 KiB
C#
146 lines
4.8 KiB
C#
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BS.Shared.DataContracts;
|
|
using Dakota;
|
|
using Dakota.Models.Schlüssel;
|
|
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;
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ein Datei erzeungnis
|
|
/// </summary>
|
|
/// <param name="invoiceItems"></param>
|
|
/// <returns></returns>
|
|
//public static string generateasciicode(list<invoiceitemdc> invoiceitems)
|
|
//{
|
|
// var info = loadinfo(invoiceitems);
|
|
|
|
// var file = new dakotafile(info);
|
|
|
|
// file.generate();
|
|
|
|
// return file.getrows();
|
|
//}
|
|
|
|
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();
|
|
currentkey.DateTime = first;
|
|
currentkey.Kassenart = Kassenart.BKK;
|
|
currentkey.Kostenträger = "";
|
|
|
|
var dakota = res.FirstOrDefault(keypair => keypair.Key.Equals(currentkey)).Value;
|
|
|
|
if (dakota is null)
|
|
{
|
|
var info = LoadInfo(invoice);
|
|
|
|
dakota = new DakotaFile(info);
|
|
|
|
res.Add(currentkey, dakota);
|
|
}
|
|
|
|
dakota.AddInvoiceItem(invoice);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static DakotaFileInfo LoadInfo(InvoiceItem invoice)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
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.IKKostenträger = "abovollkrass.txt";
|
|
res.IKKrankenkasse = "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;
|
|
|
|
res.IKKrankenkasse = "abovollkrass.txt";
|
|
|
|
res.InvoiceItems = invoiceItems;
|
|
|
|
return res;
|
|
}
|
|
}
|
|
}
|