109 lines
3.1 KiB
C#
109 lines
3.1 KiB
C#
using BS.Shared.Exceptions;
|
|
using Dakota.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Dakota
|
|
{
|
|
public static class DakotaUtils
|
|
{
|
|
public static string FillFromLeft(string input, int length, char filler)
|
|
{
|
|
if (input.Length > length)
|
|
return input;
|
|
|
|
if (input.Length == length)
|
|
return input;
|
|
|
|
var sb = new StringBuilder();
|
|
for (int i = 0; i < length - input.Length; i++)
|
|
{
|
|
sb.Append(filler);
|
|
}
|
|
sb.Append(input);
|
|
|
|
return sb.ToString();
|
|
}
|
|
|
|
public static string FillFromRight(string input, int length, char filler)
|
|
{
|
|
if (input.Length > length)
|
|
return input;
|
|
|
|
if (input.Length == length)
|
|
return input;
|
|
|
|
var sb = new StringBuilder();
|
|
sb.Append(input);
|
|
for (int i = 0; i < length - input.Length; i++)
|
|
{
|
|
sb.Append(filler);
|
|
}
|
|
|
|
return sb.ToString();
|
|
}
|
|
|
|
public static string GetAbrechnungscode(string leistungserbringergruppe)
|
|
{
|
|
var len = leistungserbringergruppe.Length;
|
|
|
|
if (len == 5)
|
|
{
|
|
return "69";
|
|
}
|
|
else if (len == 7)
|
|
{
|
|
return leistungserbringergruppe.Substring(0, 2);
|
|
}
|
|
else
|
|
{
|
|
throw new ArgumentException($"Leistungserbringergruppe \"{leistungserbringergruppe}\" hat ungültige Anzahl Stellen");
|
|
}
|
|
}
|
|
|
|
public static string GetTarifkennzeichen(string leistungserbringergruppe)
|
|
{
|
|
var len = leistungserbringergruppe.Length;
|
|
|
|
if (len == 5)
|
|
{
|
|
return leistungserbringergruppe;
|
|
}
|
|
else if (len == 7)
|
|
{
|
|
return leistungserbringergruppe.Substring(2);
|
|
// return leistungserbringergruppe.Substring(2, 5);
|
|
}
|
|
else
|
|
{
|
|
throw new ArgumentException($"Leistungserbringergruppe \"{leistungserbringergruppe}\" hat ungültige Anzahl Stellen");
|
|
}
|
|
}
|
|
|
|
public static string ClearTextString(string input)
|
|
{
|
|
foreach (var specialChar in DakotaConfig.SpecialCollection)
|
|
{
|
|
input = input.Replace(specialChar, DakotaConfig.Aufhebungszeichen + specialChar);
|
|
}
|
|
|
|
return input.Trim();
|
|
}
|
|
|
|
public static string GetVersichertenstatus(string versichertenStatus)
|
|
{
|
|
if (versichertenStatus.Length < 5)
|
|
return FillFromRight(versichertenStatus, 5, '0');
|
|
else if (versichertenStatus.Length == 5)
|
|
return versichertenStatus;
|
|
else if (versichertenStatus.Length == 7)
|
|
return versichertenStatus.Substring(0, 5);
|
|
else
|
|
throw new ArgumentException($"VersichertenStatus \"{versichertenStatus}\" ist ungültig.");
|
|
}
|
|
}
|
|
}
|