2026-02-26 11:43:39 +01:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using BeWo.Data.Access;
|
|
|
|
|
|
using BeWo.Data.Entities;
|
|
|
|
|
|
using BeWo.Service.DCEntityMapper;
|
|
|
|
|
|
|
|
|
|
|
|
using BS.Shared;
|
|
|
|
|
|
using BS.Shared.Core;
|
|
|
|
|
|
using BS.Shared.DataContracts;
|
|
|
|
|
|
using BS.Shared.DataContracts.Compact;
|
|
|
|
|
|
using BS.Shared.Extensions;
|
|
|
|
|
|
using BS.Shared.Services;
|
|
|
|
|
|
using BeWo.Service.Configuration;
|
|
|
|
|
|
using BeWo.Data.Security;
|
|
|
|
|
|
|
|
|
|
|
|
using SecurityUtils = BeWo.Service.Security.SecurityUtils;
|
|
|
|
|
|
using BeWo.Service.ServiceImplementations;
|
|
|
|
|
|
|
|
|
|
|
|
namespace BeWo.Service.Plugins
|
|
|
|
|
|
{
|
|
|
|
|
|
public class SupportConceptValidator
|
|
|
|
|
|
{
|
|
|
|
|
|
public virtual List<ValidationResultDC> ValidateSupportConcept(SupportConceptDC supportConcept)
|
|
|
|
|
|
{
|
|
|
|
|
|
var result = new List<ValidationResultDC>();
|
|
|
|
|
|
|
|
|
|
|
|
bool isNew = !supportConcept.SupportConceptOid.HasValue;
|
|
|
|
|
|
|
2026-03-10 00:24:45 +01:00
|
|
|
|
// 1. Prüfe Datumsbereiche. Startdatum darf nicht größer als Enddatum sein
|
|
|
|
|
|
bool containsDatumCheck = false;
|
|
|
|
|
|
if (supportConcept.CostBearerRelations != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var c2s in supportConcept.CostBearerRelations)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!containsDatumCheck)
|
|
|
|
|
|
{
|
2026-03-13 15:13:24 +01:00
|
|
|
|
var val = CheckDate(c2s.StartDate, c2s.EndDate, c2s, null);
|
2026-03-10 00:24:45 +01:00
|
|
|
|
if (val != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
result.Add(val);
|
|
|
|
|
|
containsDatumCheck = true;
|
|
|
|
|
|
}
|
2026-02-26 11:43:39 +01:00
|
|
|
|
|
2026-03-10 00:24:45 +01:00
|
|
|
|
if (c2s.ApprovalPeriodList != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var ap in c2s.ApprovalPeriodList)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!containsDatumCheck)
|
|
|
|
|
|
{
|
2026-03-13 15:13:24 +01:00
|
|
|
|
val = CheckDate(ap.StartDate, ap.EndDate, c2s, ap);
|
2026-03-10 00:24:45 +01:00
|
|
|
|
if (val != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
result.Add(val);
|
|
|
|
|
|
containsDatumCheck = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-02-26 11:43:39 +01:00
|
|
|
|
|
2026-03-10 00:24:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-26 11:43:39 +01:00
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-13 15:13:24 +01:00
|
|
|
|
private ValidationResultDC CheckDate(DateTime? start, DateTime? end, SupportConceptCostBearerRelDC c2s, SupportConceptApprovalPeriodDC scap)
|
2026-03-10 00:24:45 +01:00
|
|
|
|
{
|
|
|
|
|
|
if (start.HasValue && end.HasValue && start > end)
|
|
|
|
|
|
{
|
|
|
|
|
|
ValidationResultDC resultDc = new ValidationResultDC();
|
|
|
|
|
|
resultDc.Message = "Das Startdatum darf nicht größer als das Enddatum sein.";
|
2026-03-13 15:13:24 +01:00
|
|
|
|
|
|
|
|
|
|
if (scap == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2026-03-10 00:24:45 +01:00
|
|
|
|
resultDc.AllowSave = false;
|
|
|
|
|
|
return resultDc;
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-26 11:43:39 +01:00
|
|
|
|
public virtual List<ValidationResultDC> ValidateSupportConceptDeletion(long supportConceptOid)
|
|
|
|
|
|
{
|
|
|
|
|
|
var result = new List<ValidationResultDC>();
|
|
|
|
|
|
|
|
|
|
|
|
var os = new OperationsServiceImp();
|
|
|
|
|
|
|
|
|
|
|
|
var list = os.GetSupportConceptInfosForSupportConceptOid(supportConceptOid);
|
|
|
|
|
|
|
|
|
|
|
|
if (list != null && list.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
var containsServiceRecords = false;
|
|
|
|
|
|
foreach (var info in list.Where(info => info.RecordedHours > 0))
|
|
|
|
|
|
{
|
|
|
|
|
|
containsServiceRecords = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (containsServiceRecords)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
ValidationResultDC resultDc = new ValidationResultDC();
|
|
|
|
|
|
resultDc.Message = "Für den gewählten Hilfeplan wurden bereits Leistungen hinterlegt.";
|
|
|
|
|
|
resultDc.AllowSave = true;
|
|
|
|
|
|
result.Add(resultDc);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|