using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Sarand.Core.Base; using Sarand.Core.Bus; using Sarand.PatientMgr.Core.App; namespace Sarand.PatientMgr.Core.Bus { //======================================================================= public abstract class SpmEmployeeRole : SacsHierarchyItem { //------------------------------------------------------------------- // Columns. public enum Column { Pos, Id, DepartmentId, EmployeeId, Role, ApplicationFrom, ApplicationTo, // Common properties. Notes, Flag, Status, Status_Ind, Status_Desc, CreateOn_Date, UpdateOn_Date, } //------------------------------------------------------------------- /// Properties other than common. public class DataProperties { public SysId DepartmentId { get; set; } public SysId EmployeeId { get; set; } public Spm.EmployeeRole EmployeeRole { get; set; } public DateTime ApplicationFrom { get; set; } public DateTime ApplicationTo { get; set; } } //------------------------------------------------------------------- // Data. public new class Data : SacsHierarchyItem.Data { // Data members. private readonly DataProperties data = new DataProperties(); // Construction. public Data () { Status = DefaultStatus; } // Properties. public SysId DepartmentId { get { return data.DepartmentId; } set { CheckChanged(data.DepartmentId, value); data.DepartmentId = value; } } public SysId EmployeeId { get { return data.EmployeeId; } set { CheckChanged(data.EmployeeId, value); data.EmployeeId = value; } } public Spm.EmployeeRole EmployeeRole { get { return data.EmployeeRole; } set { CheckChanged((int)data.EmployeeRole, (int)value); data.EmployeeRole = value; } } public DateTime ApplicationFrom { get { return data.ApplicationFrom; } set { CheckChanged(data.ApplicationFrom, value); data.ApplicationFrom = value; } } public DateTime ApplicationTo { get { return data.ApplicationTo; } set { CheckChanged(data.ApplicationTo, value); data.ApplicationTo = value; } } // Population. internal void PopulateFrom (Data data) { DepartmentId = data.DepartmentId; EmployeeId = data.EmployeeId; EmployeeRole = data.EmployeeRole; ApplicationFrom = data.ApplicationFrom; ApplicationTo = data.ApplicationTo; base.PopulateFrom(data); } public Data Clone () { Data data = new Data(); data.PopulateFrom(this); return data; } } //------------------------------------------------------------------- // Error field - identify properties with validation error. public new class ErrField : SacsHierarchyItem.ErrField { public ValidValue DepartmentId { get; set; } = ValidValue.Valid; public ValidValue EmployeeId { get; set; } = ValidValue.Valid; public ValidValue EmployeeRole { get; set; } = ValidValue.Valid; public ValidValue ApplicationFrom { get; set; } = ValidValue.Valid; public ValidValue ApplicationTo { get; set; } = ValidValue.Valid; } //------------------------------------------------------------------- // Data members. private readonly Data data = new Data(); //------------------------------------------------------------------- // Construction. protected SpmEmployeeRole (SysId departmentId, SysId employeeId, Spm.EmployeeRole employeeRole) : base() { departmentId = DepartmentId; employeeId = EmployeeId; employeeRole = EmployeeRole; Status = DefaultStatus; base.SetData(data); } //------------------------------------------------------------------- // Status. private static readonly List employeeRoleStatuses = new List() { SaStatus.Current, }; public static SaStatus DefaultStatus { get { return SaStatus.Current; } } public static List EmployeeRoleStatuses { get { return new List(employeeRoleStatuses); } } public static DataValue.TriStateType GetStatusTriState (SaStatus status) { employeeRoleStatuses.Add(SaStatus.Current); switch (status) { case SaStatus.Current: return DataValue.TriStateType.Green; } return DataValue.TriStateType.Unknown; } //------------------------------------------------------------------- // Utilities. //------------------------------------------------------------------- // Properties. public Data GetData () { return data.Clone(); } public void SetData (Data data) { String fn = GetType().Name + ".SetData"; // Properties that cannot be changed if previously specified. if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id)) throw new NotSupportedException(fn + " Id cannot be changed"); this.data.PopulateFrom(data); } //------------------------------------------------------------------- // Attributes. public SysId DepartmentId { get { return data.DepartmentId; } set { data.DepartmentId = value; } } public SysId EmployeeId { get { return data.EmployeeId; } set { data.EmployeeId = value; } } public Spm.EmployeeRole EmployeeRole { get { return data.EmployeeRole; } set { data.EmployeeRole = value; } } public DateTime ApplicationFrom { get { return data.ApplicationFrom; } set { data.ApplicationFrom = value; } } public DateTime ApplicationTo { get { return data.ApplicationTo; } set { data.ApplicationTo = value; } } //------------------------------------------------------------------- // Flags. //------------------------------------------------------------------- // A s s o c i a t e d D a t a E l e m e n t s //------------------------------------------------------------------- public abstract bool HasAdmissionRoles (); //------------------------------------------------------------------- // P a r a m s //------------------------------------------------------------------- /// Parameters - used to define the filters that should be applied to a List of Addresses // List parameters. public enum StatusCat { Any, } /// Item list parameters. public new class Params : SacsHierarchyItem.Params { // List filtering. public List IncludedIds { get; } = new List(); public List ExcludedIds { get; } = new List(); // EmployeeRole. public SysId DepartmentId { get; set; } public SysId EmployeeId { get; set; } public Spm.EmployeeRole EmployeeRole { get; set; } public String Surname { get; set; } public String Initials { get; set; } public DateTime ApplicationFrom { get; set; } public DateTime ApplicationTo { get; set; } public DateTime Application { get; set; } public StatusCat StatusCat { get; set; } = StatusCat.Any; } //------------------------------------------------------------------- } //======================================================================= // EmployeeRole D a t a L i s t //======================================================================= public static class SpmEmployeeRoleList { } //======================================================================= }