1351 lines
46 KiB
C#
1351 lines
46 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.Services;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Service.DCEntityMapper;
|
|
using BeWo.Service.Plugins;
|
|
using Castle.Components.DictionaryAdapter;
|
|
using NHibernate.Linq;
|
|
|
|
namespace BeWo.Service.Reporting
|
|
{
|
|
public class AnnualReportFactory : AbstractIDSpecificDefaultClass<AnnualReportFactory>
|
|
{
|
|
protected DateTime ReportStartDate { get; set; }
|
|
protected DateTime ReportEndDate { get; set; }
|
|
protected CostBearer CostBearer { get; set; }
|
|
protected long? TeamOid { get; set; }
|
|
protected long? CustomerCareTypeValueListEntryOid { get; set; }
|
|
protected Dictionary<long, List<CostBearer2SupportConcept>> Cb2ScListPerCustomerOid { get; set; }
|
|
protected Dictionary<long, Customer> CustomerByOid { get; set; }
|
|
protected Dictionary<long, bool> LiegtImStichtagByCustomerOid { get; set; }
|
|
protected Dictionary<long, bool> LiegtImStichtagByC2SOid { get; set; }
|
|
|
|
protected DateTime Stichtag
|
|
{
|
|
get
|
|
{
|
|
return new DateTime(ReportStartDate.Year, 12, 31);
|
|
}
|
|
}
|
|
|
|
|
|
protected virtual bool StichtagsbezogenAuswerten
|
|
{
|
|
get { return true; }
|
|
}
|
|
|
|
|
|
public virtual List<AnnualReportDC> CreateAnnualReport(CostBearer cb, long? teamOid, long? customerCareTypeValueListEntryOid, DateTime reportStartDate,
|
|
DateTime reportEndDate)
|
|
{
|
|
ReportStartDate = reportStartDate;
|
|
ReportEndDate = reportEndDate;
|
|
CostBearer = cb;
|
|
TeamOid = teamOid;
|
|
CustomerCareTypeValueListEntryOid = customerCareTypeValueListEntryOid;
|
|
Cb2ScListPerCustomerOid = new Dictionary<long, List<CostBearer2SupportConcept>>();
|
|
CustomerByOid = new Dictionary<long, Customer>();
|
|
LiegtImStichtagByC2SOid = new Dictionary<long, bool>();
|
|
LiegtImStichtagByCustomerOid = new Dictionary<long, bool>();
|
|
|
|
var reports = new List<AnnualReportDC>();
|
|
|
|
|
|
//Dictionary<long, bool> customer2TerminationProcessed = new Dictionary<long, bool>();
|
|
Dictionary<ValueListEntry, int> countPerTerminationReasonAll = new Dictionary<ValueListEntry, int>();
|
|
Dictionary<ValueListEntry, List<String>> countPerTerminationReasonNames = new Dictionary<ValueListEntry, List<String>>();
|
|
Dictionary<ValueListEntry, int> countPerTerminationReasonMale = new Dictionary<ValueListEntry, int>();
|
|
Dictionary<ValueListEntry, int> countPerTerminationReasonFemale = new Dictionary<ValueListEntry, int>();
|
|
|
|
Dictionary<long, VarFieldDef> oid2VarfieldDef = new Dictionary<long, VarFieldDef>();
|
|
|
|
//Dictionary<long, bool> customer2VarfieldProcessed = new Dictionary<long, bool>();
|
|
Dictionary<String, int> countPerWohnformAll = new Dictionary<String, int>();
|
|
Dictionary<String, List<String>> countPerWohnformNames = new Dictionary<String, List<String>>();
|
|
Dictionary<String, int> countPerWohnformMale = new Dictionary<String, int>();
|
|
Dictionary<String, int> countPerWohnformFemale = new Dictionary<String, int>();
|
|
|
|
Dictionary<String, int> countPerCityAll = new Dictionary<String, int>();
|
|
Dictionary<String, List<String>> countPerCityNames = new Dictionary<String, List<String>>();
|
|
Dictionary<String, int> countPerCityMale = new Dictionary<String, int>();
|
|
Dictionary<String, int> countPerCityFemale = new Dictionary<String, int>();
|
|
|
|
Dictionary<VarFieldDef, int> countPerVarfielddef2All = new Dictionary<VarFieldDef, int>();
|
|
Dictionary<VarFieldDef, List<String>> countPerVarfielddefNames = new Dictionary<VarFieldDef, List<String>>();
|
|
Dictionary<VarFieldDef, int> countPerVarfielddef2Male = new Dictionary<VarFieldDef, int>();
|
|
Dictionary<VarFieldDef, int> countPerVarfielddef2Female = new Dictionary<VarFieldDef, int>();
|
|
|
|
Dictionary<int, int> year2NewSCCountAll = new Dictionary<int, int>();
|
|
Dictionary<int, List<String>> year2NewSCNames = new Dictionary<int, List<String>>();
|
|
Dictionary<int, int> year2NewSCCountMale = new Dictionary<int, int>();
|
|
Dictionary<int, int> year2NewSCCountFemale = new Dictionary<int, int>();
|
|
|
|
|
|
Dictionary<long, decimal> customerOid2Hours = new Dictionary<long, decimal>();
|
|
Dictionary<long, IList<DateTimeSpan>> customerOid2ApprovalDateTimeSpan = new Dictionary<long, IList<DateTimeSpan>>();
|
|
|
|
bool hatWohnform = false;
|
|
bool hatWohnraumAngemietet = false;
|
|
|
|
var varFieldDefs = DAOFactory.GenericDAO.GetAllActive<VarFieldDef>();
|
|
foreach (var varFieldDef in varFieldDefs)
|
|
{
|
|
oid2VarfieldDef.Add(varFieldDef.Oid.Value, varFieldDef);
|
|
}
|
|
|
|
InitData();
|
|
|
|
|
|
|
|
Dictionary<long, int> customerOid2Days = new Dictionary<long, int>();
|
|
StringBuilder sb = new StringBuilder();
|
|
foreach (var customerOid in Cb2ScListPerCustomerOid.Keys)
|
|
{
|
|
List<CostBearer2SupportConcept> csList = Cb2ScListPerCustomerOid[customerOid];
|
|
|
|
Customer customer = CustomerByOid[customerOid];
|
|
if (customerOid == 7)
|
|
{
|
|
int t = 0;
|
|
}
|
|
|
|
CostBearer2SupportConcept last = null;
|
|
int days = 0;
|
|
bool hatLaufendenHPAmStichtag = false;
|
|
foreach (var c2s in csList)
|
|
{
|
|
var startdate = c2s.StartDate;
|
|
if (last == null && customer.AssistanceBegin.HasValue && customer.AssistanceBegin.Value < startdate)
|
|
{
|
|
startdate = customer.AssistanceBegin;
|
|
}
|
|
|
|
DateTime enddate = DateTime.MaxValue;
|
|
if (last != null && last.EndDate.Value.Date < DateTime.MaxValue.Date)
|
|
enddate = last.EndDate.Value.Date.AddDays(1);
|
|
bool isNewSc = !(last != null && (enddate == c2s.StartDate.Value.Date));
|
|
|
|
|
|
if (last == null)
|
|
{
|
|
if (startdate.Value.Year == 2015)
|
|
{
|
|
sb.AppendLine(String.Format("{0}, {1}: {2:dd.MM.yyyy} - {3:dd.MM.yyyy} ({4:dd.MM.yyyy} - {5:dd.MM.yyyy})", customer.Person.LastName, customer.Person.FirstName, startdate, enddate, c2s.StartDate, c2s.EndDate));
|
|
|
|
}
|
|
days = 0;
|
|
|
|
if (!year2NewSCCountAll.ContainsKey(startdate.Value.Year))
|
|
year2NewSCCountAll[startdate.Value.Year] = 0;
|
|
|
|
year2NewSCCountAll[startdate.Value.Year] += 1;
|
|
|
|
if (!year2NewSCNames.ContainsKey(startdate.Value.Year))
|
|
{
|
|
year2NewSCNames[startdate.Value.Year] = new List<string>();
|
|
}
|
|
year2NewSCNames[startdate.Value.Year].Add(String.Format("{0}, {1}", c2s.SupportConcept.Customer.Person.LastName, c2s.SupportConcept.Customer.Person.FirstName));
|
|
|
|
if (!year2NewSCCountMale.ContainsKey(startdate.Value.Year))
|
|
year2NewSCCountMale[startdate.Value.Year] = 0;
|
|
if (!year2NewSCCountFemale.ContainsKey(startdate.Value.Year))
|
|
year2NewSCCountFemale[startdate.Value.Year] = 0;
|
|
|
|
if (c2s.SupportConcept.Customer.Person.Sex.HasValue && c2s.SupportConcept.Customer.Person.Sex.Value == Sex.Male)
|
|
{
|
|
year2NewSCCountMale[startdate.Value.Year] += 1;
|
|
}
|
|
if (c2s.SupportConcept.Customer.Person.Sex.HasValue && c2s.SupportConcept.Customer.Person.Sex.Value == Sex.Female)
|
|
{
|
|
year2NewSCCountFemale[startdate.Value.Year] += 1;
|
|
}
|
|
}
|
|
|
|
if (LiegtImStichtagByC2SOid.ContainsKey(c2s.Oid.Value))
|
|
{
|
|
days += (int)Stichtag.Subtract(startdate.Value).TotalDays + 1;
|
|
hatLaufendenHPAmStichtag = true;
|
|
|
|
if (customerOid == 49)
|
|
{
|
|
int test = 0;
|
|
}
|
|
if (!customerOid2Hours.ContainsKey(customerOid))
|
|
customerOid2Hours.Add(customerOid, 0);
|
|
|
|
var calc = PluginLoader.FindClass<Calculations>(c2s.CostBearer.ID) ?? Calculations.GetInstance(c2s.CostBearer.ID);
|
|
|
|
SupportConceptCostBearerRelDC relDC =
|
|
MapperFactory.SupportConceptCostBearerRelDC_CostBearer2SupportConcept.MapToNewDC(c2s);
|
|
|
|
DateTimeSpan span = new DateTimeSpan();
|
|
span.StartDateTime = relDC.StartDate ?? DateTime.MinValue;
|
|
span.EndDate = relDC.EndDate ?? DateTime.MaxValue;
|
|
|
|
DateTime dt = Stichtag;
|
|
if (!StichtagsbezogenAuswerten)
|
|
{
|
|
|
|
if (relDC.EndDate.HasValue && relDC.EndDate < dt && relDC.EndDate >= reportStartDate)
|
|
{
|
|
dt = relDC.EndDate.Value;
|
|
}
|
|
|
|
}
|
|
decimal hours = calc.GetApprovedHoursPerWeek(relDC, dt) ?? 0;
|
|
bool addHours = true;
|
|
if (!StichtagsbezogenAuswerten)
|
|
{
|
|
if (!customerOid2ApprovalDateTimeSpan.ContainsKey(customerOid))
|
|
{
|
|
customerOid2ApprovalDateTimeSpan.Add(customerOid, new List<DateTimeSpan>());
|
|
}
|
|
else
|
|
{
|
|
var spans = customerOid2ApprovalDateTimeSpan[customerOid];
|
|
bool overlaps = false;
|
|
foreach (var span2 in spans)
|
|
{
|
|
if (span.Overlaps(span2))
|
|
{
|
|
overlaps = true;
|
|
|
|
}
|
|
}
|
|
|
|
if (!overlaps)
|
|
{
|
|
addHours = false;
|
|
if (hours > customerOid2Hours[customerOid])
|
|
{
|
|
customerOid2Hours[customerOid] = hours;
|
|
}
|
|
}
|
|
}
|
|
|
|
customerOid2ApprovalDateTimeSpan[customerOid].Add(span);
|
|
}
|
|
|
|
if (addHours)
|
|
{
|
|
customerOid2Hours[customerOid] += hours;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (c2s.EndDate.Value < Stichtag)
|
|
days += (int)c2s.EndDate.Value.Subtract(startdate.Value).TotalDays + 1;
|
|
}
|
|
|
|
|
|
last = c2s;
|
|
}
|
|
//if (!customerOid2Days.ContainsKey(customerOid))
|
|
// customerOid[customerOid]
|
|
if (hatLaufendenHPAmStichtag)
|
|
{
|
|
customerOid2Days[customerOid] = days;
|
|
}
|
|
|
|
|
|
if (customer.TerminationReason != null && customer.TerminationDate.HasValue &&
|
|
customer.TerminationDate >= reportStartDate && customer.TerminationDate < reportEndDate)
|
|
{
|
|
if (!countPerTerminationReasonAll.ContainsKey(customer.TerminationReason))
|
|
countPerTerminationReasonAll[customer.TerminationReason] = 0;
|
|
countPerTerminationReasonAll[customer.TerminationReason] += 1;
|
|
|
|
if (!countPerTerminationReasonMale.ContainsKey(customer.TerminationReason))
|
|
countPerTerminationReasonMale[customer.TerminationReason] = 0;
|
|
|
|
if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Male)
|
|
{
|
|
countPerTerminationReasonMale[customer.TerminationReason] += 1;
|
|
}
|
|
|
|
if (!countPerTerminationReasonFemale.ContainsKey(customer.TerminationReason))
|
|
countPerTerminationReasonFemale[customer.TerminationReason] = 0;
|
|
|
|
if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Female)
|
|
{
|
|
countPerTerminationReasonFemale[customer.TerminationReason] += 1;
|
|
}
|
|
|
|
if (!countPerTerminationReasonNames.ContainsKey(customer.TerminationReason))
|
|
{
|
|
countPerTerminationReasonNames[customer.TerminationReason] = new List<string>();
|
|
}
|
|
countPerTerminationReasonNames[customer.TerminationReason].Add(String.Format("{0}, {1}", customer.Person.LastName, customer.Person.FirstName));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
if (customer.VarFieldValueList != null && customer.VarFieldValueList.Count > 0)
|
|
{
|
|
if (hatLaufendenHPAmStichtag)
|
|
{
|
|
foreach (var varfield in customer.VarFieldValueList)
|
|
{
|
|
if (oid2VarfieldDef.ContainsKey(varfield.VarFieldDefOid.Value))
|
|
{
|
|
VarFieldDef def = oid2VarfieldDef[varfield.VarFieldDefOid.Value];
|
|
if (!String.IsNullOrEmpty(def.Label))
|
|
{
|
|
if (def.Label.Equals("Wohnform"))
|
|
{
|
|
hatWohnform = true;
|
|
Type type = Type.GetType(varfield.TypeName);
|
|
var varFieldValue = Utils.XMLDeserializeFromString(varfield.SerializedValue, type);
|
|
if (varFieldValue != null)
|
|
{
|
|
String str = varFieldValue.ToString();
|
|
if (!countPerWohnformAll.ContainsKey(str))
|
|
countPerWohnformAll[str] = 0;
|
|
countPerWohnformAll[str] += 1;
|
|
|
|
if (!countPerWohnformNames.ContainsKey(str))
|
|
{
|
|
countPerWohnformNames[str] = new List<string>();
|
|
}
|
|
countPerWohnformNames[str].Add(String.Format("{0}, {1}", customer.Person.LastName, customer.Person.FirstName));
|
|
|
|
if (!countPerWohnformMale.ContainsKey(str))
|
|
countPerWohnformMale[str] = 0;
|
|
|
|
if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Male)
|
|
{
|
|
countPerWohnformMale[str] += 1;
|
|
}
|
|
|
|
if (!countPerWohnformFemale.ContainsKey(str))
|
|
countPerWohnformFemale[str] = 0;
|
|
|
|
if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Female)
|
|
{
|
|
countPerWohnformFemale[str] += 1;
|
|
}
|
|
}
|
|
|
|
}
|
|
else if (def.Label.IndexOf("Wohnraum") >= 0 &&
|
|
def.Label.IndexOf("angemietet") >= 0)
|
|
{
|
|
hatWohnraumAngemietet = true;
|
|
if (!countPerVarfielddef2All.ContainsKey(def))
|
|
countPerVarfielddef2All[def] = 0;
|
|
countPerVarfielddef2All[def] += 1;
|
|
|
|
if (!countPerVarfielddefNames.ContainsKey(def))
|
|
{
|
|
countPerVarfielddefNames[def] = new List<string>();
|
|
}
|
|
countPerVarfielddefNames[def].Add(String.Format("{0}, {1}", customer.Person.LastName, customer.Person.FirstName));
|
|
|
|
|
|
if (!countPerVarfielddef2Male.ContainsKey(def))
|
|
countPerVarfielddef2Male[def] = 0;
|
|
|
|
if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Male)
|
|
{
|
|
countPerVarfielddef2Male[def] += 1;
|
|
}
|
|
|
|
if (!countPerVarfielddef2Female.ContainsKey(def))
|
|
countPerVarfielddef2Female[def] = 0;
|
|
|
|
if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Female)
|
|
{
|
|
countPerVarfielddef2Female[def] += 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//if (varfield.)
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
if (hatLaufendenHPAmStichtag)
|
|
{
|
|
//Auswertung nach City
|
|
String city = "Ohne Angabe";
|
|
if (customer.Person.Address != null && !String.IsNullOrEmpty(customer.Person.Address.Town))
|
|
{
|
|
city = customer.Person.Address.Town;
|
|
}
|
|
if (!countPerCityAll.ContainsKey(city))
|
|
{
|
|
countPerCityAll[city] = 0;
|
|
}
|
|
countPerCityAll[city] += 1;
|
|
|
|
if (!countPerCityNames.ContainsKey(city))
|
|
{
|
|
countPerCityNames[city] = new List<string>();
|
|
}
|
|
countPerCityNames[city].Add(String.Format("{0}, {1}", customer.Person.LastName, customer.Person.FirstName));
|
|
|
|
if (!countPerCityMale.ContainsKey(city))
|
|
countPerCityMale[city] = 0;
|
|
|
|
if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Male)
|
|
{
|
|
countPerCityMale[city] += 1;
|
|
}
|
|
|
|
if (!countPerCityFemale.ContainsKey(city))
|
|
countPerCityFemale[city] = 0;
|
|
|
|
if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Female)
|
|
{
|
|
countPerCityFemale[city] += 1;
|
|
}
|
|
}
|
|
ProcessCustomer(customer, csList);
|
|
|
|
}
|
|
|
|
|
|
|
|
// anz Betreuungen
|
|
AnnualReportDC report;
|
|
|
|
if (StichtagsbezogenAuswerten)
|
|
{
|
|
report = CreateCountPerYearReport();
|
|
reports.Add(report);
|
|
}
|
|
else
|
|
{
|
|
report = CreateCountPerYearReportGesamtJahr();
|
|
reports.Add(report);
|
|
}
|
|
|
|
// anz Zugänge
|
|
report = new AnnualReportDC();
|
|
report.Name = "Anzahl der Zugänge";
|
|
reports.Add(report);
|
|
report.Data = new List<AnnualReportDataDC>();
|
|
var startYear = new DateTime(reportStartDate.Year - 5, 1, 1); //reportStartDate.AddYears(-1); //Vorjahr
|
|
var index = 1;
|
|
|
|
while (startYear < reportEndDate)
|
|
{
|
|
AnnualReportDataDC data = new AnnualReportDataDC();
|
|
report.Data.Add(data);
|
|
data.Index = index++;
|
|
data.Name = String.Format("{0:yyyy}", new DateTime(startYear.Year, 1, 1));
|
|
data.Value = 0;
|
|
if (year2NewSCCountAll.ContainsKey(startYear.Year))
|
|
data.Value = year2NewSCCountAll[startYear.Year];
|
|
|
|
if (year2NewSCCountMale.ContainsKey(startYear.Year))
|
|
data.Male = year2NewSCCountMale[startYear.Year];
|
|
if (year2NewSCCountFemale.ContainsKey(startYear.Year))
|
|
data.Female = year2NewSCCountFemale[startYear.Year];
|
|
|
|
if (year2NewSCNames.ContainsKey(startYear.Year))
|
|
data.CustomerNames = year2NewSCNames[startYear.Year];
|
|
|
|
startYear = startYear.AddYears(1);
|
|
}
|
|
|
|
|
|
|
|
// anz Beendigungen
|
|
report = new AnnualReportDC();
|
|
report.Name = "Anzahl der Beendigungen der Betreuungen";
|
|
reports.Add(report);
|
|
report.Data = new List<AnnualReportDataDC>();
|
|
index = 1;
|
|
|
|
foreach (var reason in countPerTerminationReasonAll.Keys)
|
|
{
|
|
AnnualReportDataDC data = new AnnualReportDataDC();
|
|
report.Data.Add(data);
|
|
data.Index = index++;
|
|
data.Name = reason.Value;
|
|
data.Value = countPerTerminationReasonAll[reason];
|
|
|
|
if (countPerTerminationReasonMale.ContainsKey(reason))
|
|
data.Male = countPerTerminationReasonMale[reason];
|
|
if (countPerTerminationReasonFemale.ContainsKey(reason))
|
|
data.Female = countPerTerminationReasonFemale[reason];
|
|
|
|
if (countPerTerminationReasonNames.ContainsKey(reason))
|
|
data.CustomerNames = countPerTerminationReasonNames[reason];
|
|
}
|
|
|
|
|
|
// Betreuungsdauer
|
|
report = new AnnualReportDC();
|
|
report.Name = "Aktuelle Betreuungsdauer der betreuten Personen";
|
|
reports.Add(report);
|
|
report.Data = new List<AnnualReportDataDC>();
|
|
index = 1;
|
|
|
|
|
|
int below3All = 0;
|
|
int three2FiveAll = 0;
|
|
int above5All = 0;
|
|
List<string> below3AllNames = new List<string>();
|
|
List<string> three2FiveAllNames = new List<string>();
|
|
List<string> above5AllNames = new List<string>();
|
|
|
|
|
|
int below3Male = 0;
|
|
int three2FiveMale = 0;
|
|
int above5Male = 0;
|
|
|
|
int below3Female = 0;
|
|
int three2FiveFemale = 0;
|
|
int above5Female = 0;
|
|
|
|
foreach (var customerOid in customerOid2Days.Keys)
|
|
{
|
|
int days = customerOid2Days[customerOid];
|
|
if (days > 0)
|
|
{
|
|
if (days < (365*3))
|
|
below3All++;
|
|
else if (days < (365*5))
|
|
three2FiveAll++;
|
|
else
|
|
{
|
|
above5All++;
|
|
}
|
|
|
|
if (CustomerByOid.ContainsKey(customerOid))
|
|
{
|
|
Customer customer = CustomerByOid[customerOid];
|
|
String customerName = String.Format("{0}, {1}", customer.Person.LastName, customer.Person.FirstName);
|
|
|
|
if (days < (365 * 3))
|
|
below3AllNames.Add(customerName);
|
|
else if (days < (365 * 5))
|
|
three2FiveAllNames.Add(customerName);
|
|
else
|
|
{
|
|
above5AllNames.Add(customerName);
|
|
}
|
|
|
|
if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Male)
|
|
{
|
|
if (days < (365*3))
|
|
below3Male++;
|
|
else if (days < (365*5))
|
|
three2FiveMale++;
|
|
else
|
|
{
|
|
above5Male++;
|
|
}
|
|
}
|
|
if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Female)
|
|
{
|
|
if (days < (365*3))
|
|
below3Female++;
|
|
else if (days < (365*5))
|
|
three2FiveFemale++;
|
|
else
|
|
{
|
|
above5Female++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
AnnualReportDataDC d = new AnnualReportDataDC();
|
|
report.Data.Add(d);
|
|
d.Index = index++;
|
|
d.Name = "unter 3 Jahre";
|
|
d.Value = below3All;
|
|
d.Male = below3Male;
|
|
d.Female = below3Female;
|
|
d.CustomerNames = below3AllNames;
|
|
|
|
d = new AnnualReportDataDC();
|
|
report.Data.Add(d);
|
|
d.Index = index++;
|
|
d.Name = "3-5 Jahre";
|
|
d.Value = three2FiveAll;
|
|
d.Male = three2FiveMale;
|
|
d.Female = three2FiveFemale;
|
|
d.CustomerNames = three2FiveAllNames;
|
|
|
|
d = new AnnualReportDataDC();
|
|
report.Data.Add(d);
|
|
d.Index = index++;
|
|
d.Name = "über 5 Jahre";
|
|
d.Value = above5All;
|
|
d.Male = above5Male;
|
|
d.Female = above5Female;
|
|
d.CustomerNames = above5AllNames;
|
|
|
|
// Betreuungsumfang
|
|
report = new AnnualReportDC();
|
|
report.Name = "Betreuungsumfang der betreuten Personen in FLS pro Woche";
|
|
reports.Add(report);
|
|
report.Data = new List<AnnualReportDataDC>();
|
|
index = 1;
|
|
|
|
|
|
|
|
int less1All = 0;
|
|
int less1Male = 0;
|
|
int less1Female = 0;
|
|
List<string> less1AllNames = new List<string>();
|
|
int less2All = 0;
|
|
int less2Male = 0;
|
|
int less2Female = 0;
|
|
List<string> less2AllNames = new List<string>();
|
|
int less3All = 0;
|
|
int less3Male = 0;
|
|
int less3Female = 0;
|
|
List<string> less3AllNames = new List<string>();
|
|
int less4All = 0;
|
|
int less4Male = 0;
|
|
int less4Female = 0;
|
|
List<string> less4AllNames = new List<string>();
|
|
int less6All = 0;
|
|
int less6Male = 0;
|
|
int less6Female = 0;
|
|
List<string> less6AllNames = new List<string>();
|
|
int less8All = 0;
|
|
int less8Male = 0;
|
|
int less8Female = 0;
|
|
List<string> less8AllNames = new List<string>();
|
|
int greater8All = 0;
|
|
int greater8Male = 0;
|
|
int greater8Female = 0;
|
|
List<string> greater8AllNames = new List<string>();
|
|
|
|
foreach (var customerOid in customerOid2Hours.Keys)
|
|
{
|
|
decimal hours = customerOid2Hours[customerOid];
|
|
if (hours <= 1)
|
|
less1All++;
|
|
else if (hours <= 2)
|
|
less2All++;
|
|
else if (hours <= 3)
|
|
less3All++;
|
|
else if (hours <= 4)
|
|
less4All++;
|
|
else if (hours <= 6)
|
|
less6All++;
|
|
else if (hours <= 8)
|
|
less8All++;
|
|
else
|
|
greater8All++;
|
|
|
|
if (CustomerByOid.ContainsKey(customerOid))
|
|
{
|
|
Customer customer = CustomerByOid[customerOid];
|
|
String customerName = String.Format("{0}, {1}", customer.Person.LastName, customer.Person.FirstName);
|
|
if (hours <= 1)
|
|
less1AllNames.Add(customerName);
|
|
else if (hours <= 2)
|
|
less2AllNames.Add(customerName);
|
|
else if (hours <= 3)
|
|
less3AllNames.Add(customerName);
|
|
else if (hours <= 4)
|
|
less4AllNames.Add(customerName);
|
|
else if (hours <= 6)
|
|
less6AllNames.Add(customerName);
|
|
else if (hours <= 8)
|
|
less8AllNames.Add(customerName);
|
|
else
|
|
greater8AllNames.Add(customerName);
|
|
|
|
|
|
if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Male)
|
|
{
|
|
if (hours <= 1)
|
|
less1Male++;
|
|
else if (hours <= 2)
|
|
less2Male++;
|
|
else if (hours <= 3)
|
|
less3Male++;
|
|
else if (hours <= 4)
|
|
less4Male++;
|
|
else if (hours <= 6)
|
|
less6Male++;
|
|
else if (hours <= 8)
|
|
less8Male++;
|
|
else
|
|
greater8Male++;
|
|
}
|
|
if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Female)
|
|
{
|
|
if (hours <= 1)
|
|
less1Female++;
|
|
else if (hours <= 2)
|
|
less2Female++;
|
|
else if (hours <= 3)
|
|
less3Female++;
|
|
else if (hours <= 4)
|
|
less4Female++;
|
|
else if (hours <= 6)
|
|
less6Female++;
|
|
else if (hours <= 8)
|
|
less8Female++;
|
|
else
|
|
greater8Female++;
|
|
}
|
|
}
|
|
}
|
|
d = new AnnualReportDataDC();
|
|
report.Data.Add(d);
|
|
d.Index = index++;
|
|
d.Name = "<= 1 FLS";
|
|
d.Value = less1All;
|
|
d.Male = less1Male;
|
|
d.Female = less1Female;
|
|
d.CustomerNames = less1AllNames;
|
|
|
|
d = new AnnualReportDataDC();
|
|
report.Data.Add(d);
|
|
d.Index = index++;
|
|
d.Name = "> 1 <= 2 FLS";
|
|
d.Value = less2All;
|
|
d.Male = less2Male;
|
|
d.Female = less2Female;
|
|
d.CustomerNames = less2AllNames;
|
|
|
|
d = new AnnualReportDataDC();
|
|
report.Data.Add(d);
|
|
d.Index = index++;
|
|
d.Name = "> 2 <= 3 FLS";
|
|
d.Value = less3All;
|
|
d.Male = less3Male;
|
|
d.Female = less3Female;
|
|
d.CustomerNames = less3AllNames;
|
|
|
|
d = new AnnualReportDataDC();
|
|
report.Data.Add(d);
|
|
d.Index = index++;
|
|
d.Name = "> 3 <= 4 FLS";
|
|
d.Value = less4All;
|
|
d.Male = less4Male;
|
|
d.Female = less4Female;
|
|
d.CustomerNames = less4AllNames;
|
|
|
|
d = new AnnualReportDataDC();
|
|
report.Data.Add(d);
|
|
d.Index = index++;
|
|
d.Name = "> 4 <= 6 FLS";
|
|
d.Value = less6All;
|
|
d.Male = less6Male;
|
|
d.Female = less6Female;
|
|
d.CustomerNames = less6AllNames;
|
|
|
|
d = new AnnualReportDataDC();
|
|
report.Data.Add(d);
|
|
d.Index = index++;
|
|
d.Name = "> 6 <= 8 FLS";
|
|
d.Value = less8All;
|
|
d.Male = less8Male;
|
|
d.Female = less8Female;
|
|
d.CustomerNames = less8AllNames;
|
|
|
|
d = new AnnualReportDataDC();
|
|
report.Data.Add(d);
|
|
d.Index = index++;
|
|
d.Name = "> 8 FLS";
|
|
d.Value = greater8All;
|
|
d.Male = greater8Male;
|
|
d.Female = greater8Female;
|
|
d.CustomerNames = greater8AllNames;
|
|
|
|
// Nach Ort
|
|
report = new AnnualReportDC();
|
|
report.Name = "Anzahl der betreuten Personen nach Ort";
|
|
reports.Add(report);
|
|
report.Data = new List<AnnualReportDataDC>();
|
|
index = 1;
|
|
|
|
foreach (var vd in countPerCityAll.Keys)
|
|
{
|
|
AnnualReportDataDC data = new AnnualReportDataDC();
|
|
report.Data.Add(data);
|
|
data.Index = index++;
|
|
data.Name = vd;
|
|
data.Value = countPerCityAll[vd];
|
|
data.Male = countPerCityMale[vd];
|
|
data.Female = countPerCityFemale[vd];
|
|
data.CustomerNames = countPerCityNames[vd];
|
|
}
|
|
report.Data.Sort((a, b) => a.Name.CompareTo(b.Name));
|
|
|
|
if (hatWohnform)
|
|
{
|
|
// anz der betreuten Personen
|
|
report = new AnnualReportDC();
|
|
report.Name = "Anzahl der betreuten Personen nach Wohnform";
|
|
reports.Add(report);
|
|
report.Data = new List<AnnualReportDataDC>();
|
|
index = 1;
|
|
|
|
|
|
foreach (var wohnform in countPerWohnformAll.Keys)
|
|
{
|
|
AnnualReportDataDC data = new AnnualReportDataDC();
|
|
report.Data.Add(data);
|
|
data.Index = index++;
|
|
data.Name = wohnform;
|
|
data.Value = countPerWohnformAll[wohnform];
|
|
data.Male = countPerWohnformMale[wohnform];
|
|
data.Female = countPerWohnformFemale[wohnform];
|
|
data.CustomerNames = countPerWohnformNames[wohnform];
|
|
}
|
|
}
|
|
|
|
if (hatWohnraumAngemietet)
|
|
{
|
|
// Wohnraum vom Leistungserbringer/Kooperationspartner des Leistungserbringers angemietet
|
|
report = new AnnualReportDC();
|
|
report.Name = "Wohnraum vom Leistungserbringer/Kooperationspartner angemietet";
|
|
reports.Add(report);
|
|
report.Data = new List<AnnualReportDataDC>();
|
|
index = 1;
|
|
|
|
foreach (var vd in countPerVarfielddef2All.Keys)
|
|
{
|
|
AnnualReportDataDC data = new AnnualReportDataDC();
|
|
report.Data.Add(data);
|
|
data.Index = index++;
|
|
data.Name = "anz";
|
|
data.Value = countPerVarfielddef2All[vd];
|
|
data.Male = countPerVarfielddef2Male[vd];
|
|
data.Female = countPerVarfielddef2Female[vd];
|
|
data.CustomerNames = countPerVarfielddefNames[vd];
|
|
}
|
|
}
|
|
|
|
return reports;
|
|
}
|
|
|
|
public virtual void InitData()
|
|
{
|
|
foreach (var iCb2Sc in DAOFactory.GenericDAO.GetAllActiveAndArchived<CostBearer2SupportConcept>())
|
|
{
|
|
if (CostBearer == null || iCb2Sc.CostBearer.Oid == CostBearer.Oid)
|
|
{
|
|
var sc = iCb2Sc.SupportConcept;
|
|
var customer = sc.Customer;
|
|
|
|
if (ShouldProcessSupportConcept(iCb2Sc, sc, customer))
|
|
{
|
|
ProcessSupportConcept(iCb2Sc, sc, customer);
|
|
if (!CustomerByOid.ContainsKey(customer.Oid.Value))
|
|
{
|
|
CustomerByOid.Add(customer.Oid.Value, customer);
|
|
}
|
|
|
|
List<CostBearer2SupportConcept> list;
|
|
if (Cb2ScListPerCustomerOid.ContainsKey(customer.Oid.Value))
|
|
{
|
|
list = Cb2ScListPerCustomerOid[customer.Oid.Value];
|
|
}
|
|
else
|
|
{
|
|
list = new List<CostBearer2SupportConcept>();
|
|
Cb2ScListPerCustomerOid.Add(customer.Oid.Value, list);
|
|
}
|
|
//if (iCb2Sc.StartDate < ReportEndDate)
|
|
//{
|
|
list.Add(iCb2Sc);
|
|
list.Sort((a, b) => a.StartDate.Value.CompareTo(b.StartDate.Value));
|
|
//}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach (var customerOid in Cb2ScListPerCustomerOid.Keys)
|
|
{
|
|
var customer = CustomerByOid[customerOid];
|
|
var c2sList = Cb2ScListPerCustomerOid[customerOid];
|
|
|
|
bool isFirst = true;
|
|
foreach (var c2s in c2sList)
|
|
{
|
|
|
|
var startDate = c2s.StartDate;
|
|
if (isFirst && customer.AssistanceBegin.HasValue && customer.AssistanceBegin < startDate)
|
|
{
|
|
startDate = customer.AssistanceBegin;
|
|
}
|
|
isFirst = false;
|
|
|
|
var endDate = c2s.EndDate;
|
|
if (customer.TerminationDate.HasValue && customer.TerminationDate < endDate)
|
|
{
|
|
endDate = customer.TerminationDate;
|
|
}
|
|
|
|
|
|
if ((StichtagsbezogenAuswerten && startDate <= Stichtag && endDate >= Stichtag)
|
|
|| (!StichtagsbezogenAuswerten && startDate <= Stichtag && endDate >= new DateTime(Stichtag.Year, 1, 1)))
|
|
{
|
|
if (!LiegtImStichtagByCustomerOid.ContainsKey(customer.Oid.Value))
|
|
{
|
|
LiegtImStichtagByCustomerOid.Add(customer.Oid.Value, true);
|
|
}
|
|
if (!LiegtImStichtagByC2SOid.ContainsKey(c2s.Oid.Value))
|
|
{
|
|
LiegtImStichtagByC2SOid.Add(c2s.Oid.Value, true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//Stichtagsbezogene Auswertung nach Jahr
|
|
public virtual AnnualReportDC CreateCountPerYearReport()
|
|
{
|
|
var countPerYearEndAll = new Dictionary<int, int>();
|
|
var countPerYearEndMale = new Dictionary<int, int>();
|
|
var countPerYearEndFemale = new Dictionary<int, int>();
|
|
var countPerYearEndNames = new Dictionary<int, List<string>>();
|
|
|
|
var countPerYearMidAll = new Dictionary<int, int>();
|
|
var countPerYearMidMale = new Dictionary<int, int>();
|
|
var countPerYearMidFemale = new Dictionary<int, int>();
|
|
var countPerYearMidNames = new Dictionary<int, List<string>>();
|
|
|
|
countPerYearMidAll.Add(ReportStartDate.Year, 0);
|
|
countPerYearMidAll.Add(ReportStartDate.Year - 1, 0);
|
|
countPerYearMidAll.Add(ReportStartDate.Year - 2, 0);
|
|
|
|
countPerYearMidMale.Add(ReportStartDate.Year, 0);
|
|
countPerYearMidMale.Add(ReportStartDate.Year - 1, 0);
|
|
countPerYearMidMale.Add(ReportStartDate.Year - 2, 0);
|
|
|
|
countPerYearMidFemale.Add(ReportStartDate.Year, 0);
|
|
countPerYearMidFemale.Add(ReportStartDate.Year - 1, 0);
|
|
countPerYearMidFemale.Add(ReportStartDate.Year - 2, 0);
|
|
|
|
countPerYearMidNames.Add(ReportStartDate.Year, new List<string>());
|
|
countPerYearMidNames.Add(ReportStartDate.Year - 1, new List<string>());
|
|
countPerYearMidNames.Add(ReportStartDate.Year - 2, new List<string>());
|
|
|
|
countPerYearEndAll.Add(ReportStartDate.Year, 0);
|
|
countPerYearEndAll.Add(ReportStartDate.Year - 1, 0);
|
|
countPerYearEndAll.Add(ReportStartDate.Year - 2, 0);
|
|
|
|
countPerYearEndMale.Add(ReportStartDate.Year, 0);
|
|
countPerYearEndMale.Add(ReportStartDate.Year - 1, 0);
|
|
countPerYearEndMale.Add(ReportStartDate.Year - 2, 0);
|
|
|
|
countPerYearEndFemale.Add(ReportStartDate.Year, 0);
|
|
countPerYearEndFemale.Add(ReportStartDate.Year - 1, 0);
|
|
countPerYearEndFemale.Add(ReportStartDate.Year - 2, 0);
|
|
|
|
countPerYearEndNames.Add(ReportStartDate.Year, new List<string>());
|
|
countPerYearEndNames.Add(ReportStartDate.Year - 1, new List<string>());
|
|
countPerYearEndNames.Add(ReportStartDate.Year - 2, new List<string>());
|
|
|
|
var customerProcessed = new Dictionary<String, bool>();
|
|
|
|
foreach (var customerOid in Cb2ScListPerCustomerOid.Keys)
|
|
{
|
|
|
|
var customer = CustomerByOid[customerOid];
|
|
var c2sList = Cb2ScListPerCustomerOid[customerOid];
|
|
|
|
for (int i = ReportStartDate.Year - 2; i <= ReportStartDate.Year; i++)
|
|
{
|
|
DateTime midYear = new DateTime(i, 6, 30);
|
|
DateTime endYear = new DateTime(i, 12, 31);
|
|
|
|
|
|
bool countedMid = false;
|
|
bool countedEnd = false;
|
|
|
|
bool isFirst = true;
|
|
foreach (var c2s in c2sList)
|
|
{
|
|
|
|
var startDate = c2s.StartDate;
|
|
if (isFirst && customer.AssistanceBegin.HasValue && customer.AssistanceBegin < startDate)
|
|
{
|
|
startDate = customer.AssistanceBegin;
|
|
}
|
|
isFirst = false;
|
|
|
|
var endDate = c2s.EndDate;
|
|
if (customer.TerminationDate.HasValue && customer.TerminationDate < endDate)
|
|
{
|
|
endDate = customer.TerminationDate;
|
|
}
|
|
if (!countedEnd && startDate <= endYear && endDate >= endYear)
|
|
{
|
|
countPerYearEndAll[i] += 1;
|
|
|
|
countPerYearEndNames[i].Add(String.Format("{0}, {1}", customer.Person.LastName, customer.Person.FirstName));
|
|
|
|
if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Male)
|
|
{
|
|
countPerYearEndMale[i] += 1;
|
|
}
|
|
else if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Female)
|
|
{
|
|
countPerYearEndFemale[i] += 1;
|
|
}
|
|
countedEnd = true;
|
|
}
|
|
if (!countedMid && startDate <= midYear && endDate >= midYear)
|
|
{
|
|
countPerYearMidAll[i] += 1;
|
|
|
|
countPerYearMidNames[i].Add(String.Format("{0}, {1}", customer.Person.LastName, customer.Person.FirstName));
|
|
|
|
if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Male)
|
|
{
|
|
countPerYearMidMale[i] += 1;
|
|
}
|
|
else if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Female)
|
|
{
|
|
countPerYearMidFemale[i] += 1;
|
|
}
|
|
countedMid = true;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var report = new AnnualReportDC();
|
|
report.Name = "Anzahl der Betreuungen";
|
|
|
|
report.Data = new List<AnnualReportDataDC>();
|
|
DateTime startYear = new DateTime(2000, 1, 1); //reportStartDate.AddYears(-1); //Vorjahr
|
|
int index = 1;
|
|
while (startYear < ReportEndDate)
|
|
{
|
|
if (countPerYearMidAll.ContainsKey(startYear.Year))
|
|
{
|
|
AnnualReportDataDC data = new AnnualReportDataDC();
|
|
report.Data.Add(data);
|
|
data.CustomerNames = new List<string>();
|
|
data.Index = index++;
|
|
data.Name = String.Format("{0:dd/MM/yyyy}", new DateTime(startYear.Year, 6, 30));
|
|
data.Value = countPerYearMidAll[startYear.Year];
|
|
data.CustomerNames = countPerYearMidNames[startYear.Year];
|
|
|
|
if (countPerYearMidMale.ContainsKey(startYear.Year))
|
|
{
|
|
data.Male = countPerYearMidMale[startYear.Year];
|
|
}
|
|
if (countPerYearMidFemale.ContainsKey(startYear.Year))
|
|
{
|
|
data.Female = countPerYearMidFemale[startYear.Year];
|
|
}
|
|
|
|
}
|
|
if (countPerYearEndAll.ContainsKey(startYear.Year))
|
|
{
|
|
AnnualReportDataDC data = new AnnualReportDataDC();
|
|
report.Data.Add(data);
|
|
data.Index = index++;
|
|
data.Name = String.Format("{0:dd/MM/yyyy}", new DateTime(startYear.Year, 12, 31));
|
|
data.Value = countPerYearEndAll[startYear.Year];
|
|
data.CustomerNames = countPerYearEndNames[startYear.Year];
|
|
|
|
if (countPerYearEndMale.ContainsKey(startYear.Year))
|
|
{
|
|
data.Male = countPerYearEndMale[startYear.Year];
|
|
}
|
|
if (countPerYearEndFemale.ContainsKey(startYear.Year))
|
|
{
|
|
data.Female = countPerYearEndFemale[startYear.Year];
|
|
}
|
|
}
|
|
|
|
startYear = startYear.AddYears(1);
|
|
}
|
|
|
|
return report;
|
|
}
|
|
|
|
public virtual AnnualReportDC CreateCountPerYearReportGesamtJahr()
|
|
{
|
|
var countPerYearAll = new Dictionary<int, int>();
|
|
var countPerYearMale = new Dictionary<int, int>();
|
|
var countPerYearFemale = new Dictionary<int, int>();
|
|
|
|
countPerYearAll.Add(ReportStartDate.Year, 0);
|
|
countPerYearAll.Add(ReportStartDate.Year - 1, 0);
|
|
countPerYearAll.Add(ReportStartDate.Year - 2, 0);
|
|
|
|
countPerYearMale.Add(ReportStartDate.Year, 0);
|
|
countPerYearMale.Add(ReportStartDate.Year - 1, 0);
|
|
countPerYearMale.Add(ReportStartDate.Year - 2, 0);
|
|
|
|
countPerYearFemale.Add(ReportStartDate.Year, 0);
|
|
countPerYearFemale.Add(ReportStartDate.Year - 1, 0);
|
|
countPerYearFemale.Add(ReportStartDate.Year - 2, 0);
|
|
|
|
|
|
foreach (var customerOid in Cb2ScListPerCustomerOid.Keys)
|
|
{
|
|
var customer = CustomerByOid[customerOid];
|
|
var c2sList = Cb2ScListPerCustomerOid[customerOid];
|
|
|
|
for (int i = ReportStartDate.Year - 2; i <= ReportStartDate.Year; i++)
|
|
{
|
|
DateTime start = new DateTime(i, 1, 1);
|
|
DateTime end = new DateTime(i, 12, 31);
|
|
|
|
|
|
bool counted = false;
|
|
|
|
bool isFirst = true;
|
|
foreach (var c2s in c2sList)
|
|
{
|
|
|
|
var startDate = c2s.StartDate;
|
|
if (isFirst && customer.AssistanceBegin.HasValue && customer.AssistanceBegin < startDate)
|
|
{
|
|
startDate = customer.AssistanceBegin;
|
|
}
|
|
|
|
isFirst = false;
|
|
|
|
var endDate = c2s.EndDate;
|
|
if (customer.TerminationDate.HasValue && customer.TerminationDate < endDate)
|
|
{
|
|
endDate = customer.TerminationDate;
|
|
}
|
|
|
|
if (!counted && startDate <= end && endDate >= start)
|
|
{
|
|
countPerYearAll[i] += 1;
|
|
|
|
if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Male)
|
|
{
|
|
countPerYearMale[i] += 1;
|
|
}
|
|
else if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Female)
|
|
{
|
|
countPerYearFemale[i] += 1;
|
|
}
|
|
|
|
counted = true;
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
var report = new AnnualReportDC();
|
|
report.Name = "Anzahl der Betreuungen";
|
|
|
|
report.Data = new List<AnnualReportDataDC>();
|
|
DateTime startYear = new DateTime(2000, 1, 1); //reportStartDate.AddYears(-1); //Vorjahr
|
|
int index = 1;
|
|
while (startYear < ReportEndDate)
|
|
{
|
|
if (countPerYearAll.ContainsKey(startYear.Year))
|
|
{
|
|
AnnualReportDataDC data = new AnnualReportDataDC();
|
|
report.Data.Add(data);
|
|
data.Index = index++;
|
|
data.Name = String.Format("{0:yyyy}", new DateTime(startYear.Year, 1, 1));
|
|
data.Value = countPerYearAll[startYear.Year];
|
|
|
|
if (countPerYearMale.ContainsKey(startYear.Year))
|
|
{
|
|
data.Male = countPerYearMale[startYear.Year];
|
|
}
|
|
if (countPerYearFemale.ContainsKey(startYear.Year))
|
|
{
|
|
data.Female = countPerYearFemale[startYear.Year];
|
|
}
|
|
}
|
|
|
|
startYear = startYear.AddYears(1);
|
|
}
|
|
|
|
return report;
|
|
}
|
|
|
|
//Auswertung nach Jahr, mindestens ein Tag irgendwann im Jahr reicht um gezählt zu werden
|
|
public virtual AnnualReportDC CreateCountPerWholeYearReport()
|
|
{
|
|
var countPerYearAll = new Dictionary<int, int>();
|
|
var countPerYearMale = new Dictionary<int, int>();
|
|
var countPerYearFemale = new Dictionary<int, int>();
|
|
var countPerYearNames = new Dictionary<int, List<string>>();
|
|
|
|
countPerYearAll.Add(ReportStartDate.Year, 0);
|
|
countPerYearAll.Add(ReportStartDate.Year - 1, 0);
|
|
countPerYearAll.Add(ReportStartDate.Year - 2, 0);
|
|
|
|
countPerYearMale.Add(ReportStartDate.Year, 0);
|
|
countPerYearMale.Add(ReportStartDate.Year - 1, 0);
|
|
countPerYearMale.Add(ReportStartDate.Year - 2, 0);
|
|
|
|
countPerYearFemale.Add(ReportStartDate.Year, 0);
|
|
countPerYearFemale.Add(ReportStartDate.Year - 1, 0);
|
|
countPerYearFemale.Add(ReportStartDate.Year - 2, 0);
|
|
|
|
countPerYearNames.Add(ReportStartDate.Year, new List<string>());
|
|
countPerYearNames.Add(ReportStartDate.Year - 1, new List<string>());
|
|
countPerYearNames.Add(ReportStartDate.Year - 2, new List<string>());
|
|
|
|
foreach (var customerOid in Cb2ScListPerCustomerOid.Keys)
|
|
{
|
|
|
|
var customer = CustomerByOid[customerOid];
|
|
var c2sList = Cb2ScListPerCustomerOid[customerOid];
|
|
|
|
for (int i = ReportStartDate.Year - 2; i <= ReportStartDate.Year; i++)
|
|
{
|
|
DateTime start = new DateTime(i, 1, 1);
|
|
DateTime end = new DateTime(i, 12, 31);
|
|
|
|
bool counted = false;
|
|
|
|
bool isFirst = true;
|
|
foreach (var c2s in c2sList)
|
|
{
|
|
|
|
var startDate = c2s.StartDate;
|
|
if (isFirst && customer.AssistanceBegin.HasValue && customer.AssistanceBegin < startDate)
|
|
{
|
|
startDate = customer.AssistanceBegin;
|
|
}
|
|
isFirst = false;
|
|
|
|
var endDate = c2s.EndDate;
|
|
if (customer.TerminationDate.HasValue && customer.TerminationDate < endDate)
|
|
{
|
|
endDate = customer.TerminationDate;
|
|
}
|
|
if (!counted && startDate <= end && endDate >= start)
|
|
{
|
|
countPerYearAll[i] += 1;
|
|
|
|
countPerYearNames[i].Add(String.Format("{0}, {1}", customer.Person.LastName, customer.Person.FirstName));
|
|
|
|
if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Male)
|
|
{
|
|
countPerYearMale[i] += 1;
|
|
}
|
|
else if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Female)
|
|
{
|
|
countPerYearFemale[i] += 1;
|
|
}
|
|
counted = true;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var report = new AnnualReportDC();
|
|
report.Name = "Anzahl der Betreuungen im Jahr";
|
|
|
|
report.Data = new List<AnnualReportDataDC>();
|
|
DateTime startYear = new DateTime(2000, 1, 1); //reportStartDate.AddYears(-1); //Vorjahr
|
|
int index = 1;
|
|
while (startYear < ReportEndDate)
|
|
{
|
|
|
|
if (countPerYearAll.ContainsKey(startYear.Year))
|
|
{
|
|
AnnualReportDataDC data = new AnnualReportDataDC();
|
|
report.Data.Add(data);
|
|
data.Index = index++;
|
|
data.Name = String.Format("{0:yyyy}", new DateTime(startYear.Year, 1, 1));
|
|
data.Value = countPerYearAll[startYear.Year];
|
|
data.CustomerNames = countPerYearNames[startYear.Year];
|
|
|
|
if (countPerYearMale.ContainsKey(startYear.Year))
|
|
{
|
|
data.Male = countPerYearMale[startYear.Year];
|
|
}
|
|
if (countPerYearFemale.ContainsKey(startYear.Year))
|
|
{
|
|
data.Female = countPerYearFemale[startYear.Year];
|
|
}
|
|
}
|
|
|
|
startYear = startYear.AddYears(1);
|
|
}
|
|
|
|
return report;
|
|
}
|
|
|
|
public virtual void ProcessCustomer(Customer customer, List<CostBearer2SupportConcept> allCostBearer2SupportConcepts)
|
|
{
|
|
//Nur für abgeleitete Klassen
|
|
}
|
|
|
|
public virtual void ProcessSupportConcept(CostBearer2SupportConcept iCb2Sc, SupportConcept sc, Customer customer)
|
|
{
|
|
//Nur für abgeleitete Klassen
|
|
}
|
|
|
|
public virtual bool ShouldProcessSupportConcept(CostBearer2SupportConcept iCb2Sc, SupportConcept sc, Customer customer)
|
|
{
|
|
|
|
if (sc.IsActive != ActivationTypeId.Deleted && customer.IsActive != ActivationTypeId.Deleted)
|
|
{
|
|
if ((iCb2Sc.ApprovedStartDate.HasValue && iCb2Sc.ApprovedEndDate.HasValue))
|
|
{
|
|
if (CustomerBelongsToTeam(customer, TeamOid) &&
|
|
IsCustomerOfCustomerCareType(customer, CustomerCareTypeValueListEntryOid))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public virtual bool IsCustomerOfCustomerCareType(Customer customer, long? customerCareTypeValueListEntryOid)
|
|
{
|
|
bool val = true;
|
|
if (customerCareTypeValueListEntryOid.HasValue)
|
|
{
|
|
val = false;
|
|
foreach (var v in customer.ValueList)
|
|
{
|
|
if (v.Entry.Type == ValueListEntryType.CustomerCareType && v.Entry.Oid == customerCareTypeValueListEntryOid)
|
|
return true;
|
|
}
|
|
}
|
|
return val;
|
|
}
|
|
|
|
public virtual bool CustomerBelongsToTeam(Customer customer, long? teamOid)
|
|
{
|
|
bool val = true;
|
|
if (teamOid.HasValue)
|
|
{
|
|
val = false;
|
|
foreach (var t2c in customer.Team2CustomerList)
|
|
{
|
|
if (t2c.TeamOid == teamOid)
|
|
return true;
|
|
}
|
|
}
|
|
return val;
|
|
}
|
|
}
|
|
} |