Config - Departments - in progress
This commit is contained in:
@@ -24,6 +24,7 @@ namespace Sarand.PatientMgr.Core.App
|
||||
//-------------------------------------------------------------------
|
||||
// Database.
|
||||
public abstract ISacsDatabase GetDatabase (SpmSessionContext sessionContext);
|
||||
public abstract bool TableExists (SpmSessionContext sessionContext, SpmDbDfn.TableIdx tableIdx);
|
||||
public abstract bool ColumnExists (SpmSessionContext sessionContext, SpmDbDfn.ColumnIdx columnIdx);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -134,7 +134,8 @@ namespace Sarand.PatientMgr.Core.App
|
||||
/* Codes of type 'Speciality'. */
|
||||
CodeSpeciality = 101,
|
||||
// System data types.
|
||||
SecItem = SaDataItemType.SecItem,
|
||||
SecurityItem = SaDataItemType.SecurityItem,
|
||||
SecurityLink = SaDataItemType.SecurityLink,
|
||||
CodeType = SaDataItemType.CodeType,
|
||||
Code = SaDataItemType.Code,
|
||||
Interface = SaDataItemType.Interface,
|
||||
|
||||
@@ -19,12 +19,10 @@ namespace Sarand.PatientMgr.Core.App
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private readonly SpmSystem system = SpmGlobals.System;
|
||||
|
||||
// Managers.
|
||||
private SpmAdmissionMgr admissionMgr = null;
|
||||
private SpmDepartmentMgr departmentMgr = null;
|
||||
private SpmInstitutionMgr institutionMgr = null;
|
||||
|
||||
private SpmDepartmentMgr departmentMgr = null;
|
||||
private SpmAdmissionMgr admissionMgr = null;
|
||||
// Consoles.
|
||||
private SaSecurityConsole securityConsole;
|
||||
private SaCodeTypeConsole codeTypeConsole;
|
||||
@@ -33,22 +31,22 @@ namespace Sarand.PatientMgr.Core.App
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SpmInternals(SpmUserContext userContext)
|
||||
public SpmInternals (SpmUserContext userContext)
|
||||
{
|
||||
UserContext = userContext;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
protected override void Dispose (bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (admissionMgr != null) admissionMgr.Dispose();
|
||||
if (institutionMgr != null) institutionMgr.Dispose();
|
||||
if (departmentMgr != null) departmentMgr.Dispose();
|
||||
if (admissionMgr != null) admissionMgr.Dispose();
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Session.
|
||||
public SpmUserContext UserContext { get; }
|
||||
@@ -58,7 +56,8 @@ namespace Sarand.PatientMgr.Core.App
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Managers.
|
||||
public SpmAdmissionMgr AdmissionMgr {
|
||||
public SpmAdmissionMgr AdmissionMgr
|
||||
{
|
||||
get
|
||||
{
|
||||
if (admissionMgr == null)
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
using Sarand.Core.App;
|
||||
using Sarand.Core.Base;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace Sarand.PatientMgr.Core.App
|
||||
{
|
||||
//=======================================================================
|
||||
public static class SpmResourceConsole
|
||||
{
|
||||
//----------------------------------------------------------------------
|
||||
// Definitions.
|
||||
public enum TextResource
|
||||
{
|
||||
SaBaseCss,
|
||||
SaBaseJs,
|
||||
SpmBaseCss,
|
||||
SpmBaseJs,
|
||||
JQueryJs,
|
||||
JQueryUiCss,
|
||||
JQueryUiJs,
|
||||
}
|
||||
public enum ImageResource
|
||||
{
|
||||
PatientMgr_Icon_gif,
|
||||
NHS_bmp,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public static String GetTextResource (TextResource textResource)
|
||||
{
|
||||
switch (textResource)
|
||||
{
|
||||
case TextResource.SaBaseCss:
|
||||
return SacsResourceConsole.GetTextResource(SacsResourceConsole.TextResource.SaBaseCss);
|
||||
case TextResource.SaBaseJs:
|
||||
return SacsResourceConsole.GetTextResource(SacsResourceConsole.TextResource.SaBaseJs);
|
||||
case TextResource.SpmBaseCss:
|
||||
return GetTextResource("spm-base.css");
|
||||
case TextResource.SpmBaseJs:
|
||||
return GetTextResource("spm-base.js");
|
||||
case TextResource.JQueryJs:
|
||||
return SacsResourceConsole.GetTextResource(SacsResourceConsole.TextResource.JQueryJs);
|
||||
case TextResource.JQueryUiCss:
|
||||
return SacsResourceConsole.GetTextResource(SacsResourceConsole.TextResource.JQueryUiCss);
|
||||
case TextResource.JQueryUiJs:
|
||||
return SacsResourceConsole.GetTextResource(SacsResourceConsole.TextResource.JQueryUiJs);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
public static String GetTextResource (String resourceFilename, String partialPath = "")
|
||||
{
|
||||
if (!StringUtil.IsEmpty(resourceFilename))
|
||||
{
|
||||
var assembly = typeof(SacsResourceConsole).GetTypeInfo().Assembly;
|
||||
String resourceText = SacsResourceConsole.GetManifestResourceAsText(assembly, partialPath, resourceFilename);
|
||||
if (!StringUtil.IsEmpty(resourceText))
|
||||
return resourceText;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public static byte[] GetImageResource (ImageResource imageResource)
|
||||
{
|
||||
String partialPath = "";
|
||||
String resourceFilename = "";
|
||||
switch (imageResource)
|
||||
{
|
||||
case ImageResource.PatientMgr_Icon_gif:
|
||||
resourceFilename = "PatientMgr-icon.gif";
|
||||
break;
|
||||
case ImageResource.NHS_bmp:
|
||||
resourceFilename = "nhs.bmp";
|
||||
break;
|
||||
}
|
||||
if (!StringUtil.IsEmpty(resourceFilename))
|
||||
{
|
||||
var assembly = typeof(SpmResourceConsole).GetTypeInfo().Assembly;
|
||||
byte[] resourceData = SacsResourceConsole.GetManifestResourceAsBinary(assembly, partialPath, resourceFilename);
|
||||
if (resourceData != null)
|
||||
return resourceData;
|
||||
}
|
||||
return new byte[0];
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -130,14 +130,11 @@ namespace Sarand.PatientMgr.Core.App
|
||||
{
|
||||
internal AdminProfile (ProfileParams paramsData) { Params = paramsData; }
|
||||
private ProfileParams Params { get; set; }
|
||||
public bool CanManageSecurity { get; internal set; } = false;
|
||||
public bool CanManageDatabase { get; internal set; } = false;
|
||||
public bool CanManageConfig { get; internal set; } = false;
|
||||
public bool CanManageSecurity () { return Params.IsSecurityRightGranted(Spm.SecurityRight.ManageSecurity); }
|
||||
public bool CanManageDatabase () { return Params.IsSecurityRightGranted(Spm.SecurityRight.ManageDb); }
|
||||
public bool CanManageConfig () { return Params.IsSecurityRightGranted(Spm.SecurityRight.ManageConfig); }
|
||||
internal void Clear ()
|
||||
{
|
||||
CanManageSecurity = false;
|
||||
CanManageDatabase = false;
|
||||
CanManageConfig = false;
|
||||
}
|
||||
}
|
||||
public AdminProfile Admin { get; }
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
using Sarand.Core.Base;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Sarand.PatientMgr.Core.Base
|
||||
{
|
||||
//=======================================================================
|
||||
public class SpmResourceGroupParam : CodeParam
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SpmResourceGroupParam (String code, String displayCaption = "", bool including = true) :
|
||||
base (code, including)
|
||||
{
|
||||
DisplayCaption = displayCaption;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
public String DisplayCaption { get; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
using Sarand.Core.App;
|
||||
using Sarand.Core.Base;
|
||||
using Sarand.Core.Bus;
|
||||
using Sarand.PatientMgr.Core.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Sarand.PatientMgr.Core.Base
|
||||
{
|
||||
//=======================================================================
|
||||
public class SpmSessionProperties
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Schdedule display characteristics.
|
||||
/// <summary>Earliest date to list - 2 year in past.</summary>
|
||||
public DateTime ScheduleStart { get; } = DateUtil.IncrementDate(DateTime.Today, -2 * 365);
|
||||
/// <summary>Latest date to list - 2 year in future.</summary>
|
||||
public DateTime ScheduleEnd { get; } = DateUtil.IncrementDate(DateTime.Today, 2 * 365);
|
||||
/// <summary>Show filter.</summary>
|
||||
public bool DisplayFilter { get; set; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
private readonly Dictionary<Spm.DisplayFont,int> textHeights = new Dictionary<Spm.DisplayFont,int>();
|
||||
/// <summary>Admission display text height (standard, medium, large)</summary>
|
||||
public int GetTextHeight (Spm.DisplayFont displayFont)
|
||||
{
|
||||
return textHeights.GetValue(displayFont, 0);
|
||||
}
|
||||
public void SetTextHeight (Spm.DisplayFont displayFont, int textHeight)
|
||||
{
|
||||
textHeights[displayFont] = textHeight;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
private readonly Dictionary<Spm.DisplayBoundary,int> displayBoundaries = new Dictionary<Spm.DisplayBoundary,int>();
|
||||
/// <summary>Width for selected boundary definition</summary>
|
||||
public int GetDisplayBoundary (Spm.DisplayBoundary displayBoundary)
|
||||
{
|
||||
return displayBoundaries.GetValue(displayBoundary, 0);
|
||||
}
|
||||
public void SetDisplayBoundary (Spm.DisplayBoundary displayBoundary, int boundary)
|
||||
{
|
||||
displayBoundaries[displayBoundary] = boundary;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Schedule filter.
|
||||
public class FilterData
|
||||
{
|
||||
// Data members.
|
||||
private SysId departmentId;
|
||||
private Spm.FacilityType facilityType;
|
||||
private SpmResourceGroupParam resourceGroup { get; set; } = new SpmResourceGroupParam("");
|
||||
// Properties.
|
||||
public SysId DepartmentId
|
||||
{
|
||||
get { return departmentId; }
|
||||
set
|
||||
{
|
||||
if (SysId.ToInt(departmentId) == SysId.ToInt(value)) return;
|
||||
departmentId = value;
|
||||
facilityType = Spm.FacilityType.Unknown;
|
||||
}
|
||||
}
|
||||
public Spm.FacilityType FacilityType
|
||||
{
|
||||
get { return facilityType; }
|
||||
set
|
||||
{
|
||||
if (facilityType == value) return;
|
||||
facilityType = value;
|
||||
FacilityId = null;
|
||||
}
|
||||
}
|
||||
public SysId FacilityId { get; set; }
|
||||
public SpmResourceGroupParam ResourceGroup
|
||||
{
|
||||
get { return resourceGroup; }
|
||||
set
|
||||
{
|
||||
if (SacsSystem.DebugMode) Logger.Debug(GetType().Name + ".ResourceGroup.set Code: " + value.Code + " [" + resourceGroup.Code + "], Including: " + value.Including + " [" + resourceGroup.Including + "].");
|
||||
resourceGroup = value;
|
||||
}
|
||||
}
|
||||
public int WorkingDayOfWeek { get; set; } = -1;
|
||||
public String Consultant { get; set; }
|
||||
public String Speciality { get; set; }
|
||||
public String SessionName { get; set; }
|
||||
public String ResourceName { get; set; }
|
||||
public Spm.WardPeriodLength WardPeriodLength { get; set; } = Spm.WardPeriodLength.Unknown;
|
||||
public Spm.WardResourceDisplay WardResourceDisplay { get; set; } = Spm.WardResourceDisplay.Unknown;
|
||||
public Spm.WardHighlighting WardHighlighting { get; set; } = Spm.WardHighlighting.Unknown;
|
||||
}
|
||||
public FilterData Filter { get; } = new FilterData();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data folders.
|
||||
public String AdmissionExportFolder { get; set; }
|
||||
public String StatisticsExportFolder { get; set; }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Sarand.PatientMgr.Core.Mgr
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create department.
|
||||
public abstract SpmDepartment CreateDepartment();
|
||||
public abstract SpmDepartment CreateDepartment(SysId institutionId);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Department exists.
|
||||
@@ -38,7 +38,6 @@ namespace Sarand.PatientMgr.Core.Mgr
|
||||
//-------------------------------------------------------------------
|
||||
// Get department.
|
||||
public abstract SpmDepartment GetDepartment(SpmDepartment.Params prm);
|
||||
|
||||
public SpmDepartment GetDepartmentById(SysId departmentId)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -93,12 +92,12 @@ namespace Sarand.PatientMgr.Core.Mgr
|
||||
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 (errField.ApplicableFrom != SacsHierarchyItem.ValidValue.Ignore && errField.ApplicableTo != SacsHierarchyItem.ValidValue.Ignore && DateUtil.IsValid(data.ApplicableFrom) && DateUtil.IsValid(data.ApplicableTo))
|
||||
{
|
||||
if (data.ApplicationFrom.CompareTo(data.ApplicationTo) > 0)
|
||||
if (data.ApplicableFrom.CompareTo(data.ApplicableTo) > 0)
|
||||
{
|
||||
errField.ApplicationFrom = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid application date range");
|
||||
errField.ApplicableFrom = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState("Invalid applicable date range");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +114,7 @@ namespace Sarand.PatientMgr.Core.Mgr
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!SpmDepartment.DepartmentStatuses.Contains(data.Status))
|
||||
if (!SpmDepartment.ValidStatuses.Contains(data.Status))
|
||||
{
|
||||
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return SetErrorState(ErrorMessage.InvalidStatus);
|
||||
|
||||
@@ -21,11 +21,11 @@ namespace Sarand.PatientMgr.Core.Mgr
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create institution.
|
||||
public abstract SpmInstitution CreateInstitution(SysId institutionId);
|
||||
public abstract SpmInstitution CreateInstitution ();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Institution exists.
|
||||
public bool InstitutionExistsById(SysId institutionId)
|
||||
public bool InstitutionExistsById (SysId institutionId)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(institutionId)) return false;
|
||||
@@ -36,10 +36,10 @@ namespace Sarand.PatientMgr.Core.Mgr
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Get institution.
|
||||
public abstract SpmInstitution GetInstitution(SpmInstitution.Params prm);
|
||||
|
||||
public SpmInstitution GetInstitutionById(SysId institutionId)
|
||||
// Get institution - should only be one.
|
||||
public abstract SpmInstitution GetInstitution ();
|
||||
public abstract SpmInstitution GetInstitution (SpmInstitution.Params prm);
|
||||
public SpmInstitution GetInstitutionById (SysId institutionId)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(institutionId)) return null;
|
||||
@@ -51,13 +51,13 @@ namespace Sarand.PatientMgr.Core.Mgr
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validate institution data.
|
||||
public bool IsValidInstitution(SpmInstitution institution)
|
||||
public bool IsValidInstitution (SpmInstitution institution)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (institution == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
||||
return IsValidInstitutionData(institution.GetData(), new SpmInstitution.ErrField());
|
||||
}
|
||||
public virtual bool IsValidInstitutionData(SpmInstitution.Data data, SpmInstitution.ErrField errField)
|
||||
public virtual bool IsValidInstitutionData (SpmInstitution.Data data, SpmInstitution.ErrField errField)
|
||||
{
|
||||
ClearErrorState();
|
||||
// Institution properties.
|
||||
@@ -92,27 +92,27 @@ namespace Sarand.PatientMgr.Core.Mgr
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Institution database interface.
|
||||
public abstract bool InsertInstitution(SpmInstitution institution, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateInstitution(SpmInstitution institution, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool InstitutionCanBeDeleted(SpmInstitution institution)
|
||||
public abstract bool InsertInstitution (SpmInstitution institution, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateInstitution (SpmInstitution institution, DbUpdateInfo dbUpdateInfo);
|
||||
public virtual bool InstitutionCanBeDeleted (SpmInstitution institution)
|
||||
{
|
||||
ClearErrorState();
|
||||
return true;
|
||||
}
|
||||
public abstract bool DeleteInstitution(SpmInstitution institution, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool DeleteInstitution (SpmInstitution institution, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Institution list.
|
||||
public abstract ColumnDfn GetInstitutionColumnDfn(SpmInstitution.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetInstitutionQueryFilter(SpmInstitution.Params prm);
|
||||
public abstract long GetInstitutionCount(SpmInstitution.Params prm);
|
||||
public abstract List<SpmInstitution> GetInstitutionList(SpmInstitution.Params prm);
|
||||
public abstract DbResultSet ExecuteInstitutionQuery(List<ColumnDfn> columns, SpmInstitution.Params prm);
|
||||
public abstract ColumnDfn GetInstitutionColumnDfn (SpmInstitution.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<String> GetInstitutionQueryFilter (SpmInstitution.Params prm);
|
||||
public abstract long GetInstitutionCount (SpmInstitution.Params prm);
|
||||
public abstract List<SpmInstitution> GetInstitutionList (SpmInstitution.Params prm);
|
||||
public abstract DbResultSet ExecuteInstitutionQuery (List<ColumnDfn> columns, SpmInstitution.Params prm);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// D a t a V a l u e s
|
||||
//-------------------------------------------------------------------
|
||||
public DataValue GetInstitutionDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
public DataValue GetInstitutionDataValue (ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
switch ((SpmInstitution.Column)column.Id)
|
||||
|
||||
@@ -4,17 +4,83 @@ using Sarand.Core.CodeTypes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Sarand.Core.Base;
|
||||
using System.Linq;
|
||||
using Sarand.Core.App;
|
||||
|
||||
namespace Sarand.PatientMgr.Core.Mgr
|
||||
{
|
||||
//=======================================================================
|
||||
public abstract class SpmItemMgr : SacsItemMgr
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// System code cache.
|
||||
/// <summary>Central repository for system codes used by manager.</summary>
|
||||
private class SystemCodeCache
|
||||
{
|
||||
public SystemCodeCache (SpmUserContext userContext)
|
||||
{
|
||||
this.userContext = userContext;
|
||||
}
|
||||
private readonly SpmUserContext userContext;
|
||||
private Dictionary<Spm.SystemCode, List<TypeCodeDesc>> systemCodes = new Dictionary<Spm.SystemCode, List<TypeCodeDesc>>();
|
||||
public List<TypeCodeDesc> GetCodesOfType (Spm.SystemCode systemCode)
|
||||
{
|
||||
if (!systemCodes.ContainsKey(systemCode))
|
||||
systemCodes[systemCode] = SpmSystem.GetCodesOfType(systemCode);
|
||||
return new List<TypeCodeDesc>(systemCodes.GetValue(systemCode, new List<TypeCodeDesc>()));
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Code type cache.
|
||||
public class CodeTypeCache
|
||||
{
|
||||
/// <summary>
|
||||
/// Cached codes by code type.
|
||||
/// <para>NB Likely to only contain a subset of code types depending on context.</para>
|
||||
/// </summary>
|
||||
private Dictionary<String, List<SaCode>> codesByCodeType { get; }
|
||||
// Construction.
|
||||
public CodeTypeCache (Dictionary<String, List<SaCode>> codes)
|
||||
{
|
||||
codesByCodeType = codes;
|
||||
}
|
||||
/// <summary>Are there any codes of the specified type.</summary>
|
||||
public bool CodeTypeHasCodes (Spm.CodeType codeType)
|
||||
{
|
||||
String codeTypeCode = SpmSystem.GetCodeTypeCode(codeType);
|
||||
return codesByCodeType.ContainsKey(codeTypeCode)
|
||||
? codesByCodeType[codeTypeCode].Count > 0
|
||||
: false;
|
||||
}
|
||||
/// <summary>Get the description for the code belonging to the specified code type.</summary>
|
||||
public String GetDescForCodeTypeCode (Spm.CodeType codeType, String code, bool defaultToCode = true)
|
||||
{
|
||||
List<SaCode> codes = GetCodesForCodeType(codeType, false);
|
||||
return codes?.GetDescForCode(code, defaultToCode ? code : "") ?? "";
|
||||
}
|
||||
/// <summary>Retrieve codes for specified code type.</summary>
|
||||
public List<SaCode> GetCodesForCodeType (Spm.CodeType codeType, bool activeOnly = true)
|
||||
{
|
||||
String codeTypeCode = SpmSystem.GetCodeTypeCode(codeType);
|
||||
return codesByCodeType.ContainsKey(codeTypeCode)
|
||||
? new List<SaCode>(codesByCodeType[codeTypeCode].FindAll(code => !activeOnly || code.Status == SaCode.ActiveStatus))
|
||||
: null;
|
||||
}
|
||||
/// <summary>Retrieve code descs for specified code type.</summary>
|
||||
public List<CodeDesc> GetCodeDescsForCodeType (Spm.CodeType codeType, bool activeOnly = true)
|
||||
{
|
||||
String codeTypeCode = SpmSystem.GetCodeTypeCode(codeType);
|
||||
return codesByCodeType.ContainsKey(codeTypeCode)
|
||||
? new List<CodeDesc>(codesByCodeType[codeTypeCode].FindAll(code => !activeOnly || code.Status == SaCode.ActiveStatus).Select(code => new CodeDesc(code.Code, code.Description)))
|
||||
: null;
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private SaCodeTypeConsole codeTypeConsole;
|
||||
// Managers.
|
||||
private SpmAdmissionMgr admissionMgr;
|
||||
private SpmInternals internals;
|
||||
private readonly SystemCodeCache systemCodeCache;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Static initialisation.
|
||||
@@ -29,27 +95,42 @@ namespace Sarand.PatientMgr.Core.Mgr
|
||||
if (userContext == null)
|
||||
throw new NotSupportedException("SpmItemMgr User context must be supplied");
|
||||
UserContext = userContext;
|
||||
systemCodeCache = new SystemCodeCache(userContext);
|
||||
}
|
||||
protected override void Dispose (bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (admissionMgr != null) admissionMgr.Dispose();
|
||||
if (internals != null) internals.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
protected bool DebugMode { get; } = SacsSystem.DebugMode;
|
||||
public SpmUserContext UserContext { get; }
|
||||
public SpmInternals Internals { get { if (internals == null) internals = new SpmInternals(UserContext); return internals; } }
|
||||
public SpmSessionContext SessionContext { get { return UserContext.SessionContext; } }
|
||||
public SaCodeTypeConsole CodeTypeConsole { get { if (codeTypeConsole == null) codeTypeConsole = SpmGlobals.GetCodeTypeConsole(UserContext); { return codeTypeConsole; } } }
|
||||
// Consoles.
|
||||
public SaCodeTypeConsole CodeTypeConsole { get { return internals.CodeTypeConsole; } }
|
||||
// Managers.
|
||||
public SpmAdmissionMgr AdmissionMgr { get { if (admissionMgr == null) admissionMgr = SpmGlobals.System.CreateAdmissionMgr(UserContext); return admissionMgr; } }
|
||||
public SpmAdmissionMgr AdmissionMgr { get { return internals.AdmissionMgr; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
/*
|
||||
public List<TypeCodeDesc> GetCodesOfType (Spm.SystemCode systemCode)
|
||||
{
|
||||
return systemCodeCache.GetCodesOfType(systemCode);
|
||||
}
|
||||
// Database utilities.
|
||||
public bool TableExists (SpmDbDfn.TableIdx tableIdx)
|
||||
{
|
||||
SpmApplication application = SpmGlobals.Application;
|
||||
if (application != null)
|
||||
return application.TableExists(SessionContext, tableIdx);
|
||||
return false;
|
||||
}
|
||||
public bool ColumnExists (SpmDbDfn.ColumnIdx columnIdx)
|
||||
{
|
||||
SpmApplication application = SpmGlobals.Application;
|
||||
@@ -57,7 +138,58 @@ namespace Sarand.PatientMgr.Core.Mgr
|
||||
return application.ColumnExists(SessionContext, columnIdx);
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// C o d e T y p e s
|
||||
//-------------------------------------------------------------------
|
||||
public virtual List<Spm.CodeType> SupportedCodeTypes { get; } = new List<Spm.CodeType>();
|
||||
private CodeTypeCache codeTypeCache;
|
||||
public bool CodeTypeHasCodes (Spm.CodeType codeType)
|
||||
{
|
||||
if (DebugMode && !SupportedCodeTypes.Contains(codeType)) throw new NotSupportedException(GetType().Name + ".CodeTypeHasCodes Unsupported code type: " + codeType);
|
||||
PopulateCodeTypes();
|
||||
return codeTypeCache.CodeTypeHasCodes(codeType);
|
||||
}
|
||||
public String GetCodeTypeCodeDesc (Spm.CodeType codeType, String code, bool defaultToCode = true)
|
||||
{
|
||||
if (DebugMode && !SupportedCodeTypes.Contains(codeType)) throw new NotSupportedException(GetType().Name + ".GetCodeTypeCodeDesc Unsupported code type: " + codeType);
|
||||
PopulateCodeTypes();
|
||||
List<SaCode> codes = codeTypeCache.GetCodesForCodeType(codeType, false);
|
||||
if (codes != null)
|
||||
return codes.GetDescForCode(code, defaultToCode ? code : "");
|
||||
return "";
|
||||
}
|
||||
public List<SaCode> GetCodesForCodeType (Spm.CodeType codeType, bool activeOnly = true)
|
||||
{
|
||||
if (DebugMode && !SupportedCodeTypes.Contains(codeType)) throw new NotSupportedException(GetType().Name + ".GetCodesForCodeType Unsupported code type: " + codeType);
|
||||
PopulateCodeTypes();
|
||||
return codeTypeCache.GetCodesForCodeType(codeType, activeOnly);
|
||||
}
|
||||
public List<CodeDesc> GetCodeDescsForCodeType (Spm.CodeType codeType, bool activeOnly = true)
|
||||
{
|
||||
if (DebugMode && !SupportedCodeTypes.Contains(codeType)) throw new NotSupportedException(GetType().Name + ".GetCodeDescsForCodeType Unsupported code type: " + codeType);
|
||||
PopulateCodeTypes();
|
||||
return codeTypeCache.GetCodeDescsForCodeType(codeType, activeOnly);
|
||||
}
|
||||
private void PopulateCodeTypes ()
|
||||
{
|
||||
if (codeTypeCache != null) return;
|
||||
// Populate cache with codes for all supported code types.
|
||||
// Intended to minimise db I/O to retrieve all required codes.
|
||||
SaCode.Params prmCode = new SaCode.Params();
|
||||
foreach (Spm.CodeType codeType in SupportedCodeTypes)
|
||||
prmCode.CodeTypeCodes.Add(SpmSystem.GetCodeTypeCode(codeType));
|
||||
prmCode.StatusCat = SaCode.StatusCat.Any;
|
||||
Dictionary<String, List<SaCode>> codesByCodeType = CodeTypeConsole.GetCodesByCodeType(prmCode);
|
||||
// Populate any supported code types without codes.
|
||||
foreach (Spm.CodeType codeType in SupportedCodeTypes)
|
||||
{
|
||||
String codeTypeCode = SpmSystem.GetCodeTypeCode(codeType);
|
||||
if (!codesByCodeType.ContainsKey(codeTypeCode))
|
||||
codesByCodeType[codeTypeCode] = new List<SaCode>();
|
||||
}
|
||||
codeTypeCache = new CodeTypeCache(codesByCodeType);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
Sarand PatientMgr
|
||||
Base css styling
|
||||
Includes sa-base.css.
|
||||
From a www.sarand.com original.
|
||||
*/
|
||||
body{margin:0;padding:0;font-family:Verdana,Arial;font-size:12px;background-color:#F8F8F8;overflow:auto;}
|
||||
|
||||
/* --- The End --- */
|
||||
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
Sarand PatientMgr
|
||||
Base Javascript
|
||||
Includes sa-base.js.
|
||||
From a www.sarand.com original.
|
||||
*/
|
||||
if (typeof spm == 'undefined') spm = {};
|
||||
|
||||
//-------------------------------------------------------------
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1017 B |
Binary file not shown.
|
After Width: | Height: | Size: 886 B |
@@ -11,6 +11,16 @@
|
||||
<None Remove="Core - Copy\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="Resources\img\nhs.bmp" />
|
||||
<None Remove="Resources\img\PatientMgr-icon.gif" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\img\nhs.bmp" />
|
||||
<EmbeddedResource Include="Resources\img\PatientMgr-icon.gif" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Core\Consoles\" />
|
||||
<Folder Include="Core\Data\" />
|
||||
|
||||
Reference in New Issue
Block a user