Files
BeWoPlaner/ReportImp/PraxisPusteblume/LeistungsnachweisKrankenkasse.cs

207 lines
7.3 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BS.Shared.Core;
using DevExpress.XtraReports.UI;
using BeWo.Report.ReportObjects;
using BeWo.Report;
using BeWo.Service.DCEntityMapper;
namespace PraxisPusteblume
{
public partial class LeistungsnachweisKrankenkasse : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<ServicesOverviewRO>
{
private Dictionary<string, decimal> key2Pflegeeinheiten = new Dictionary<string, decimal>();
private Dictionary<string, decimal> key2Wegepauschale = new Dictionary<string, decimal>();
public LeistungsnachweisKrankenkasse()
{
InitializeComponent();
}
public void SetReportDataSource(ServicesOverviewRO ro)
{
//cellMonat1.Text = String.Format("{0:MMM yy}", ro.StartDate);
//lblZeitraum.Text = String.Format("Zeitraum {0:dd.MM.yyyy} - {1:dd.MM.yyyy}", ro.StartDate, ro.EndDate);
//InitRows(ro);
if (ro.Services != null)
{
foreach (ServicesOverviewRO.ServiceDetail s in ro.Services)
{
AddDetailToTable(ro, s);
}
}
if (String.IsNullOrEmpty(ro.Costbearer))
{
ro.Costbearer = HoleErstenKostentraeger(ro);
}
foreach (var cb2sc in ro.CostBearer2SupportConceptList)
{
if (cb2sc.SupportConcept != null && cb2sc.SupportConcept.Customer.TerminationDate.HasValue)
{
checkboxBetreuungDauertAn.Checked = false;
checkboxBetreuungBeendet.Checked = true;
lblBeendigungsgrund.Text = ro.SupportConceptCostBearer.SupportConcept.Customer.TerminationReason;
}
}
this.bindingSource1.DataSource = ro;
}
private string HoleErstenKostentraeger(ServicesOverviewRO ro)
{
if (ro.CostBearer2SupportConceptList == null || ro.CostBearer2SupportConceptList.Count == 0)
{
if (ro.SupportConceptCostBearer == null)
{
if (ro.CustomerOid > 0)
{
var c = DAOFactory.GenericDAO.LoadByID<Customer>(ro.CustomerOid);
foreach (var sc in c.SupportConcepts)
{
foreach (var c2s in sc.CostBearer2SupportConceptList)
{
if (c2s.StartDate.HasValue && c2s.EndDate.HasValue && c2s.StartDate <= ro.EndDate &&
c2s.EndDate >= ro.StartDate)
{
return c2s.CostBearer.Organisation.Name;
}
}
}
}
}
}
return ro.Costbearer;
}
private Customer GetCustomer(ServicesOverviewRO ro)
{
if (ro.CostBearer2SupportConceptList != null && ro.CostBearer2SupportConceptList.Count > 0)
{
return ro.CostBearer2SupportConceptList[0].SupportConcept.Customer;
}
return null;
}
private void AddDetailToTable(ServicesOverviewRO ro, ServicesOverviewRO.ServiceDetail sd)
{
var table = tableMonat1;
SetTableText(table, sd);
}
private void SetTableText(XRTable table, ServicesOverviewRO.ServiceDetail sd)
{
if (sd.Minutes == 0)
{
return;
}
XRTableCell cell = null;
int column = 0 + sd.StartDate.Day;
XRTableRow row = null;
XRTableRow wegepauschaleRow = null;
XRTableRow uhrzeitRow = null;
String text = "";
String key = String.Format("{0}_{1}", table.Name, column);
decimal decimalValue = 0;
bool firstValue = true;
if (key2Pflegeeinheiten.ContainsKey(key))
{
decimalValue = key2Pflegeeinheiten[key];
if (decimalValue > 0)
{
firstValue = false;
}
}
if (sd.ServiceCategory.StartsWith("IFS - "))
{
//int einheiten = (int)Math.Floor(sd.Minutes/60);
decimal einheiten = (decimal)sd.Minutes / 60m;
string leistung = sd.ServiceDescription.ToLower();
bool wegepauschale = false;
if (!key2Wegepauschale.ContainsKey(key))
{
wegepauschale = true;
key2Wegepauschale.Add(key, 1);
}
// Korrekte Zeile wählen
if (leistung.Contains("physio"))
{
row = tableRowPhysio;
unterschriftPhysio.Visible = true;
}
else if (leistung.Contains("ergo"))
{
row = tableRowErgo;
unterschriftErgo.Visible = true;
}
else if (leistung.Contains("logop"))
{
row = tableRowLogopaedie;
unterschriftLogopaedie.Visible = true;
}
//totalEinheiten1 += einheiten;
//if (wegepauschale)
//{
// if (IstWochentagOderFeiertag(sd.StartDate))
// {
// totalWegepWochenende1++;
// wegepauschaleRow = tableRowWegepWochenende1;
// }
// else
// {
// totalWegepWochentags1++;
// wegepauschaleRow = tableRowWegepWochentags1;
// }
//}
decimalValue += einheiten;
string leistungsform = null;
if (leistung.Contains("(") && leistung.Contains(")") && !leistung.Contains("eingangsdiagnostik"))
{
int indexKlammerAuf = leistung.IndexOf("(");
int indexKlammerZu = leistung.IndexOf(")");
leistungsform = leistung.Substring(indexKlammerAuf + 1, indexKlammerZu - indexKlammerAuf - 1).ToUpper();
// Wenn die Leistung länger als 1.5h geht, muss ein E angehangen werden (aber nur bei E, R und M)
if (sd.Minutes >= 90 && (leistungsform == "E" || leistungsform == "M" || leistungsform == "R"))
leistungsform += "E";
}
if (row != null)
row.Cells[column].Text = leistungsform;
if (wegepauschaleRow != null)
{
wegepauschaleRow.Cells[column].Text = "1";
}
if (uhrzeitRow != null && firstValue)
{
uhrzeitRow.Cells[column].Text = String.Format("{0:HH:mm}", sd.StartDate);
}
}
key2Pflegeeinheiten[key] = decimalValue;
}
}
}