113 lines
4.7 KiB
C#
113 lines
4.7 KiB
C#
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using Sarand.Core.App;
|
|
using Sarand.Core.Base;
|
|
using Sarand.Core.Bus;
|
|
using Sarand.Core.Dbas.Base;
|
|
using Sarand.PatientMgr.Core.App;
|
|
using Sarand.PatientMgr.Core.Bus;
|
|
|
|
namespace Sarand.PatientMgr.Core.Mgr
|
|
{
|
|
//=======================================================================
|
|
partial class SpmDepartmentMgr
|
|
{
|
|
//*******************************************************************
|
|
// D e p a r t m e n t
|
|
//*******************************************************************
|
|
//-------------------------------------------------------------------
|
|
// Utilities.
|
|
|
|
//-------------------------------------------------------------------
|
|
// Retrieve individual department.
|
|
//-------------------------------------------------------------------
|
|
// Exist department.
|
|
public abstract bool DepartmentExistsById(SysId id);
|
|
//-------------------------------------------------------------------
|
|
// Get department.
|
|
public abstract SpmDepartment GetDepartment(SpmDepartment.Params prm);
|
|
public abstract SpmDepartment GetDepartmentById(SysId id);
|
|
public abstract SpmDepartment GetDepartmentByName(String name);
|
|
public abstract SpmDepartment GetDepartmentByFacilityId(SysId facilityId);
|
|
public abstract SpmDepartment GetDepartmentByFacilityTemplateId(SysId facilityId);
|
|
|
|
//-------------------------------------------------------------------
|
|
// Create department.
|
|
public abstract SpmDepartment CreateDepartment();
|
|
|
|
//-------------------------------------------------------------------
|
|
// Validate department data.
|
|
public bool IsValidDepartment(SpmDepartment department)
|
|
{
|
|
ClearErrorState();
|
|
if (department == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
|
return IsValidDepartmentData(department.GetData(), new SpmDepartment.ErrField());
|
|
}
|
|
public virtual bool IsValidDepartmentData(SpmDepartment.Data data, SpmDepartment.ErrField errField)
|
|
{
|
|
ClearErrorState();
|
|
// Department properties.
|
|
if (errField.Name != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Name, "name", (long)SpmDbDfn.GetColTextLen(SpmDbDfn.ColumnIdx.SwmDepartment_Name), true))
|
|
{
|
|
errField.Name = SacsHierarchyItem.ValidValue.Invalid;
|
|
return false;
|
|
}
|
|
if (errField.ApplicationFrom != SacsHierarchyItem.ValidValue.Ignore && errField.ApplicationTo != SacsHierarchyItem.ValidValue.Ignore && DateUtil.IsValid(data.ApplicationFrom) && DateUtil.IsValid(data.ApplicationTo))
|
|
{
|
|
if (data.ApplicationFrom.CompareTo(data.ApplicationTo) > 0)
|
|
{
|
|
errField.ApplicationFrom = SacsHierarchyItem.ValidValue.Invalid;
|
|
return SetErrorState("Invalid application date range");
|
|
}
|
|
}
|
|
|
|
// Common properties.
|
|
if (!IsValidValue(data.Notes, "notes", (long)SpmDbDfn.GetColTextLen(SpmDbDfn.ColumnIdx.SwmDepartment_Notes)))
|
|
{
|
|
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
|
return false;
|
|
}
|
|
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
|
{
|
|
if (!IsValidValue(SacsSystem.GetStatusCode(data.Status), "status", (long)SpmDbDfn.GetColTextLen(SpmDbDfn.ColumnIdx.SwmDepartment_Status), true, true))
|
|
{
|
|
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
|
return false;
|
|
}
|
|
if (!SpmDepartment.DepartmentStatuses.Contains(data.Status))
|
|
{
|
|
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
|
return SetErrorState(ErrorMessage.InvalidStatus);
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Department database interface.
|
|
public abstract bool InsertDepartment(SpmDepartment department, DbUpdateInfo dbUpdateInfo);
|
|
public abstract bool UpdateDepartment(SpmDepartment department, DbUpdateInfo dbUpdateInfo);
|
|
public virtual bool DepartmentCanBeDeleted(SpmDepartment department)
|
|
{
|
|
ClearErrorState();
|
|
return true;
|
|
}
|
|
public abstract bool DeleteDepartment(SpmDepartment department, DbUpdateInfo dbUpdateInfo);
|
|
|
|
//-------------------------------------------------------------------
|
|
// Department list.
|
|
public abstract ColumnDfn GetDepartmentColumnDfn(SpmDepartment.Column columnId, String caption = "", int width = 0);
|
|
public abstract List<String> GetDepartmentQueryFilter(SpmDepartment.Params prm);
|
|
public abstract long GetDepartmentCount(SpmDepartment.Params prm);
|
|
public abstract List<SpmDepartment> GetDepartmentList(SpmDepartment.Params prm);
|
|
public abstract DbResultSet ExecuteDepartmentQuery(List<ColumnDfn> columns, SpmDepartment.Params prm);
|
|
public abstract DataValue GetDepartmentDataValue(ColumnDfn column, NamedValue.Map values);
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|