Config - Departments - in progress
This commit is contained in:
@@ -18,10 +18,10 @@ namespace Sarand.PatientMgr.Core.Bus
|
||||
{
|
||||
Pos,
|
||||
Id,
|
||||
InstitutionId,
|
||||
Name,
|
||||
ApplicatonFrom,
|
||||
ApplicationTo,
|
||||
|
||||
ApplicableFrom,
|
||||
ApplicableTo,
|
||||
// Common properties.
|
||||
Notes,
|
||||
Flag,
|
||||
@@ -32,25 +32,41 @@ namespace Sarand.PatientMgr.Core.Bus
|
||||
UpdateOn_Date,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data.
|
||||
public new class Data : SacsHierarchyItem.Data
|
||||
{
|
||||
public Data()
|
||||
public Data ()
|
||||
{
|
||||
//Status = DepartmentStatus;
|
||||
Status = SpmDepartment.DefaultStatus;
|
||||
}
|
||||
public SysId InstitutionId { get; set; }
|
||||
public String Name { get; set; }
|
||||
public DateTime ApplicationFrom { get; set; }
|
||||
public DateTime ApplicationTo { get; set; }
|
||||
|
||||
internal void PopulateFrom(Data data)
|
||||
public uint FacilityTypes { get; set; } = 0;
|
||||
public bool HasFacilityType (Spm.FacilityType facilityType)
|
||||
{
|
||||
return SpmDepartment.HasFacilityType(FacilityTypes, facilityType);
|
||||
}
|
||||
public uint AllowAnyFacilities { get; set; } = 0;
|
||||
public bool AllowAnyFacility (Spm.FacilityType facilityType)
|
||||
{
|
||||
return SpmDepartment.AllowAnyFacility(AllowAnyFacilities, facilityType);
|
||||
}
|
||||
public ushort GetCancelReBookLimit (Spm.FacilityType facilityType)
|
||||
{
|
||||
return SpmDepartment.GetCancelReBookLimit("", facilityType);
|
||||
}
|
||||
public DateTime ApplicableFrom { get; set; }
|
||||
public DateTime ApplicableTo { get; set; }
|
||||
internal void PopulateFrom (Data data)
|
||||
{
|
||||
InstitutionId = data.InstitutionId;
|
||||
Name = data.Name;
|
||||
ApplicationFrom = data.ApplicationFrom;
|
||||
ApplicationTo = data.ApplicationTo;
|
||||
ApplicableFrom = data.ApplicableFrom;
|
||||
ApplicableTo = data.ApplicableTo;
|
||||
base.PopulateFrom(data);
|
||||
}
|
||||
public Data Clone()
|
||||
public Data Clone ()
|
||||
{
|
||||
Data data = new Data();
|
||||
data.PopulateFrom(this);
|
||||
@@ -58,24 +74,25 @@ namespace Sarand.PatientMgr.Core.Bus
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// ErrField.
|
||||
public new class ErrField : SacsHierarchyItem.ErrField
|
||||
{
|
||||
public ValidValue InstitutionId { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Name { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ApplicationFrom { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ApplicationTo { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ApplicableFrom { get; set; } = ValidValue.Valid;
|
||||
public ValidValue ApplicableTo { get; set; } = ValidValue.Valid;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly Data data = new Data();
|
||||
private long facilityTypes;
|
||||
private long allowAnyFacility;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
protected SpmDepartment(SysId id) : base(id)
|
||||
protected SpmDepartment (SysId id, SysId institutionId) : base(id)
|
||||
{
|
||||
InstitutionId = institutionId;
|
||||
Status = DefaultStatus;
|
||||
base.SetData(data);
|
||||
}
|
||||
@@ -87,11 +104,9 @@ namespace Sarand.PatientMgr.Core.Bus
|
||||
SaStatus.Current,
|
||||
};
|
||||
public static SaStatus DefaultStatus { get { return SaStatus.Current; } }
|
||||
public static List<SaStatus> DepartmentStatuses { get { return new List<SaStatus>(departmentStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
||||
public static List<SaStatus> ValidStatuses { get { return new List<SaStatus>(departmentStatuses); } }
|
||||
public static DataValue.TriStateType GetStatusTriState (SaStatus status)
|
||||
{
|
||||
departmentStatuses.Add(SaStatus.Current);
|
||||
|
||||
switch (status)
|
||||
{
|
||||
case SaStatus.Current:
|
||||
@@ -105,24 +120,33 @@ namespace Sarand.PatientMgr.Core.Bus
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public Data GetData() { return data.Clone(); }
|
||||
public void SetData(Data data)
|
||||
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");
|
||||
if (SysId.IsValid(InstitutionId) && SysId.ToInt(InstitutionId) != SysId.ToInt(data.InstitutionId))
|
||||
throw new NotSupportedException(fn + " Institution Id cannot be changed");
|
||||
this.data.PopulateFrom(data);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Attributes.
|
||||
// Properties.
|
||||
public SysId InstitutionId
|
||||
{
|
||||
get { return data.InstitutionId; }
|
||||
protected set { CheckChanged(data.InstitutionId, value); data.InstitutionId = value; }
|
||||
}
|
||||
public String Name
|
||||
{
|
||||
get { return data.Name; }
|
||||
set { CheckChanged(data.Name, value); data.Name = value; }
|
||||
}
|
||||
public int GetFacilityTypeBit(Spm.FacilityType facilityType)
|
||||
// Facility types.
|
||||
public uint FacilityTypes { get { return data.FacilityTypes; } set { data.FacilityTypes = value; } }
|
||||
public static int GetFacilityTypeBit (Spm.FacilityType facilityType)
|
||||
{
|
||||
// Map facility types to their position in the bit mapped value:
|
||||
if (facilityType == Spm.FacilityType.Theatre) return 0;
|
||||
@@ -131,38 +155,49 @@ namespace Sarand.PatientMgr.Core.Bus
|
||||
if (facilityType == Spm.FacilityType.Apparatus) return 3;
|
||||
return -1;
|
||||
}
|
||||
public bool HasFacilityType(Spm.FacilityType facilityType)
|
||||
public static bool HasFacilityType (uint facilityTypes, Spm.FacilityType facilityType)
|
||||
{
|
||||
int facilityTypeBit = GetFacilityTypeBit (facilityType);
|
||||
if (facilityTypeBit >= 0 && facilityTypeBit < 32)
|
||||
return (facilityTypes & (((uint)1) << facilityTypeBit)) > 0;
|
||||
return false;
|
||||
}
|
||||
public bool HasFacilityType (Spm.FacilityType facilityType)
|
||||
{
|
||||
return HasFacilityType(data.FacilityTypes, facilityType);
|
||||
}
|
||||
// Allow any facility.
|
||||
public uint AllowAnyFacilities { get { return data.AllowAnyFacilities; } set { data.AllowAnyFacilities = value; } }
|
||||
public static bool AllowAnyFacility (uint allowAnyFacilities, Spm.FacilityType facilityType)
|
||||
{
|
||||
int facilityTypeBit = GetFacilityTypeBit(facilityType);
|
||||
if (facilityTypeBit >= 0 && facilityTypeBit < 32)
|
||||
return ((facilityTypes & (((long)1) << facilityTypeBit)) > 0);
|
||||
return (allowAnyFacilities & (((uint)1) << facilityTypeBit)) > 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool AllowAnyFacility(Spm.FacilityType facilityType)
|
||||
public bool AllowAnyFacility (Spm.FacilityType facilityType)
|
||||
{
|
||||
int iFacilityTypeBit = GetFacilityTypeBit(facilityType);
|
||||
if (iFacilityTypeBit >= 0 && iFacilityTypeBit < 32)
|
||||
return ((allowAnyFacility & (((long)1) << iFacilityTypeBit)) > 0);
|
||||
return false;
|
||||
return AllowAnyFacility(data.AllowAnyFacilities, facilityType);
|
||||
}
|
||||
public long GetFacilityTypes() { return facilityTypes; }
|
||||
public long GetAllowAnyFacilities() { return allowAnyFacility; }
|
||||
|
||||
public ushort GetCancelReBookLimit(Spm.FacilityType facility)
|
||||
// Cancel re-book limit.
|
||||
public static ushort GetCancelReBookLimit (String cancelReBookLimit, Spm.FacilityType facilityType)
|
||||
{
|
||||
if (facility == Spm.FacilityType.Theatre) return 28;
|
||||
if (facilityType == Spm.FacilityType.Theatre) return 28;
|
||||
return 0;
|
||||
}
|
||||
public DateTime ApplicationFrom
|
||||
public ushort GetCancelReBookLimit (Spm.FacilityType facilityType)
|
||||
{
|
||||
get { return data.ApplicationFrom; }
|
||||
set { CheckChanged(data.ApplicationFrom, value); data.ApplicationFrom = value; }
|
||||
return GetCancelReBookLimit("", facilityType);
|
||||
}
|
||||
public DateTime ApplicationTo
|
||||
public DateTime ApplicableFrom
|
||||
{
|
||||
get { return data.ApplicationTo; }
|
||||
set { CheckChanged(data.ApplicationTo, value); data.ApplicationTo = value; }
|
||||
get { return data.ApplicableFrom; }
|
||||
set { CheckChanged(data.ApplicableFrom, value); data.ApplicableFrom = value; }
|
||||
}
|
||||
public DateTime ApplicableTo
|
||||
{
|
||||
get { return data.ApplicableTo; }
|
||||
set { CheckChanged(data.ApplicableTo, value); data.ApplicableTo = value; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -171,9 +206,9 @@ namespace Sarand.PatientMgr.Core.Bus
|
||||
//-------------------------------------------------------------------
|
||||
// A s s o c i a t e d D a t a E l e m e n t s
|
||||
//-------------------------------------------------------------------
|
||||
public abstract int GetFacilityCount(Spm.FacilityType type);
|
||||
public abstract bool HasFacilities(Spm.FacilityType type);
|
||||
public abstract bool HasProcedures();
|
||||
public abstract int GetFacilityCount (Spm.FacilityType type);
|
||||
public abstract bool HasFacilities (Spm.FacilityType type);
|
||||
public abstract bool HasProcedures ();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a r a m s
|
||||
@@ -194,8 +229,8 @@ namespace Sarand.PatientMgr.Core.Bus
|
||||
// Department.
|
||||
public String Name { get; set; }
|
||||
public String NamePartial { get; set; }
|
||||
public DateTime ApplicationFrom { get; set; }
|
||||
public DateTime ApplicationTo { get; set; }
|
||||
public DateTime ApplicableFrom { get; set; }
|
||||
public DateTime ApplicableTo { get; set; }
|
||||
public DateTime Application { get; set; }
|
||||
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.Any;
|
||||
|
||||
Reference in New Issue
Block a user