Files
BeWoPlaner/ReportImp/MitMenschenWuppertal/Reporting/CustomAnnualReportFactory.cs
2019-02-12 19:32:04 +01:00

245 lines
8.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BeWo.Service.Reporting;
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;
namespace MitMenschenWuppertal.Reporting
{
public class CustomAnnualReportFactory : AnnualReportFactory
{
int gruppe_UnbekanntAlle = 0;
int gruppe_UnbekanntM = 0;
int gruppe_UnbekanntF = 0;
int gruppe0_Bis20Alle = 0;
int gruppe0_Bis20M = 0;
int gruppe0_Bis20F = 0;
int gruppe_20_29_Alle = 0;
int gruppe_20_29_M = 0;
int gruppe_20_29_F = 0;
int gruppe_30_39_Alle = 0;
int gruppe_30_39_M = 0;
int gruppe_30_39_F = 0;
int gruppe_40_49_Alle = 0;
int gruppe_40_49_M = 0;
int gruppe_40_49_F = 0;
int gruppe_50_59_Alle = 0;
int gruppe_50_59_M = 0;
int gruppe_50_59_F = 0;
int gruppe_60_69_Alle = 0;
int gruppe_60_69_M = 0;
int gruppe_60_69_F = 0;
int gruppeAb70Alle = 0;
int gruppeAb70M = 0;
int gruppeAb70F = 0;
public override List<AnnualReportDC> CreateAnnualReport(CostBearer cb, long? teamOid, long? customerCareTypeValueListEntryOid, DateTime reportStartDate, DateTime reportEndDate)
{
var basereports = base.CreateAnnualReport(cb, teamOid, customerCareTypeValueListEntryOid, reportStartDate, reportEndDate);
// Nach Behinderung
var report = new AnnualReportDC();
report.Name = "Anzahl Personen nach Alter";
basereports.Add(report);
report.Data = new List<AnnualReportDataDC>();
int index = 1;
var d = new AnnualReportDataDC();
report.Data.Add(d);
d.Index = index++;
d.Name = "Jünger als 20";
d.Value = gruppe0_Bis20Alle;
d.Male = gruppe0_Bis20M;
d.Female = gruppe0_Bis20F;
d = new AnnualReportDataDC();
report.Data.Add(d);
d.Index = index++;
d.Name = "20 bis 29";
d.Value = gruppe_20_29_Alle;
d.Male = gruppe_20_29_M;
d.Female = gruppe_20_29_F;
d = new AnnualReportDataDC();
report.Data.Add(d);
d.Index = index++;
d.Name = "30 bis 39";
d.Value = gruppe_30_39_Alle;
d.Male = gruppe_30_39_M;
d.Female = gruppe_30_39_F;
d = new AnnualReportDataDC();
report.Data.Add(d);
d.Index = index++;
d.Name = "40 bis 49";
d.Value = gruppe_40_49_Alle;
d.Male = gruppe_40_49_M;
d.Female = gruppe_40_49_F;
d = new AnnualReportDataDC();
report.Data.Add(d);
d.Index = index++;
d.Name = "50 bis 59";
d.Value = gruppe_50_59_Alle;
d.Male = gruppe_50_59_M;
d.Female = gruppe_50_59_F;
d = new AnnualReportDataDC();
report.Data.Add(d);
d.Index = index++;
d.Name = "60 bis 69";
d.Value = gruppe_60_69_Alle;
d.Male = gruppe_60_69_M;
d.Female = gruppe_60_69_F;
d = new AnnualReportDataDC();
report.Data.Add(d);
d.Index = index++;
d.Name = " 70 und älter";
d.Value = gruppeAb70Alle;
d.Male = gruppeAb70M;
d.Female = gruppeAb70F;
if (gruppe_UnbekanntAlle > 0)
{
d = new AnnualReportDataDC();
report.Data.Add(d);
d.Index = index++;
d.Name = "Unbekannt";
d.Value = gruppe_UnbekanntAlle;
d.Male = gruppe_UnbekanntM;
d.Female = gruppe_UnbekanntF;
}
return basereports;
}
public override void ProcessCustomer(Customer customer, List<CostBearer2SupportConcept> allCostBearer2SupportConcepts)
{
if (LiegtImStichtagByCustomerOid.ContainsKey(customer.Oid.Value))
{
int alter = -1;
if (customer.Person.DateOfBirth.HasValue)
{
alter = Stichtag.Year - customer.Person.DateOfBirth.Value.Year;
}
if (alter < 0)
{
gruppe_UnbekanntAlle++;
if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Male)
{
gruppe_UnbekanntM++;
}
else if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Female)
{
gruppe_UnbekanntF++;
}
}
if (alter < 20)
{
gruppe0_Bis20Alle++;
if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Male)
{
gruppe0_Bis20M++;
}
else if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Female)
{
gruppe0_Bis20F++;
}
}
if (alter >= 20 && alter <= 29)
{
gruppe_20_29_Alle++;
if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Male)
{
gruppe_20_29_M++;
}
else if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Female)
{
gruppe_20_29_F++;
}
}
if (alter >= 30 && alter <= 39)
{
gruppe_30_39_Alle++;
if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Male)
{
gruppe_30_39_M++;
}
else if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Female)
{
gruppe_30_39_F++;
}
}
if (alter >= 40 && alter <= 49)
{
gruppe_40_49_Alle++;
if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Male)
{
gruppe_40_49_M++;
}
else if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Female)
{
gruppe_40_49_F++;
}
}
if (alter >= 50 && alter <= 59)
{
gruppe_50_59_Alle++;
if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Male)
{
gruppe_50_59_M++;
}
else if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Female)
{
gruppe_50_59_F++;
}
}
if (alter >= 60 && alter <= 69)
{
gruppe_60_69_Alle++;
if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Male)
{
gruppe_60_69_M++;
}
else if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Female)
{
gruppe_60_69_F++;
}
}
if (alter >= 70)
{
gruppeAb70Alle++;
if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Male)
{
gruppeAb70M++;
}
else if (customer.Person.Sex.HasValue && customer.Person.Sex.Value == Sex.Female)
{
gruppeAb70F++;
}
}
}
}
}
}