Files
BeWoPlaner/ReportImp/KirschbaumManz/Validation/ServiceRecordValidator.cs

58 lines
3.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using BeWo.Service.Plugins;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BS.Shared;
using BS.Shared.Core;
using BS.Shared.DataContracts;
using BS.Shared.DataContracts.Compact;
using BS.Shared.Extensions;
using BS.Shared.Services;
namespace KirschbaumManz.Validation
{
public class CustomServiceRecordValidator : ServiceRecordValidator
{
public override string[] GetIgnoreCategoriesForOverlappingCheck()
{
// return new[] { "Soziotherapie", "Arbeitszeit" };
return new[] { "Arbeitszeit" };
}
public override List<ServiceRecordValidationResultDC> ValidateServiceRecord(ServiceRecordDC newServiceRecord, SupportConceptStatisticsDC statistics, int maxDaysEditServiceRecordsAllowed, IList<long> employeeOids, IList<long> cb2scOids)
{
var validation = base.ValidateServiceRecord(newServiceRecord, statistics, maxDaysEditServiceRecordsAllowed, employeeOids, cb2scOids);
// Prüfen, ob beim Speichern der Doku bei Kategorie "Soziotherapie" und die Leistungen "aufsuchend Einzel" oder "Probestunde" sind. Wenn ja, an Eintragen der Hausbesuchspauschale erinnern
if (newServiceRecord.ServiceDescription.Category.Name.ToLower().Contains("soziotherapie") && (newServiceRecord.ServiceDescription.Name.ToLower().Contains("aufsuchend einzel") || newServiceRecord.ServiceDescription.Name.ToLower().Contains("probestunde")))
{
validation.Add(new ServiceRecordValidationResultDC()
{
Allow = true,
EmployeeName = newServiceRecord.Employee.LastName + ", " + newServiceRecord.Employee.FirstName,
StartDate = newServiceRecord.Start.Value,
EndDate = newServiceRecord.End.Value,
ResultType = ServiceRecordValidationResult.Custom,
Message = "Bitte denken Sie an das Eintragen der Hausbesuchspauschale."
});
}
// Prüfen, ob beim Speichern der Doku das Dokufeld "Ort" eingetragen ist, wenn Leistungskategorie "Soziotherapie" ist. Wenn nicht, daran erinnern
if (newServiceRecord.ServiceDescription.Category.Name.ToLower().Contains("soziotherapie") && newServiceRecord.Notice3.IsNullOrEmpty())
{
validation.Add(new ServiceRecordValidationResultDC()
{
Allow = false,
EmployeeName = newServiceRecord.Employee.LastName + ", " + newServiceRecord.Employee.FirstName,
StartDate = newServiceRecord.Start.Value,
EndDate = newServiceRecord.End.Value,
ResultType = ServiceRecordValidationResult.Custom,
Message = "Bei der Leistungskategorie \"Soziotherapie\" ist der Ort ein Pflichtfeld, bitte füllen Sie dieses aus."
});
}
return validation;
}
}
}