Config - Departments - in progress

This commit is contained in:
2019-12-04 13:59:00 +00:00
parent 15541b77aa
commit 114aa49535
90 changed files with 3430 additions and 660 deletions
+1
View File
@@ -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);
//-------------------------------------------------------------------
+2 -1
View File
@@ -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,
+8 -9
View File
@@ -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];
}
//-------------------------------------------------------------------
}
//=======================================================================
}
+3 -6
View File
@@ -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; }
//-------------------------------------------------------------------
}
//=======================================================================
}
+84 -49
View File
@@ -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)
+140 -8
View File
@@ -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);
}
//-------------------------------------------------------------------
}
+9
View File
@@ -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 --- */
+9
View File
@@ -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

+10
View File
@@ -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\" />
@@ -19,13 +19,13 @@ namespace Sarand.PatientMgr.Win.Dbas.Bus
//-------------------------------------------------------------------
// Construction.
public SpmDepartment_Dbas(SpmUserContext userContext, SysId id, ushort flags) :
base(id)
public SpmDepartment_Dbas (SpmUserContext userContext, SysId id, SysId institutionId, ushort flags) :
base(id, institutionId)
{
this.userContext = userContext;
Flags = flags;
}
protected override void Dispose(bool disposing)
protected override void Dispose (bool disposing)
{
if (disposing)
{
@@ -39,7 +39,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Bus
//-------------------------------------------------------------------
// A s s o c i a t e d D a t a E l e m e n t s
//-------------------------------------------------------------------
public override int GetFacilityCount(Spm.FacilityType type)
public override int GetFacilityCount (Spm.FacilityType facilityType)
{
ClearErrorState();
if (!SysId.IsValid(Id)) { SetErrorState("invalid department"); return 0; }
@@ -48,26 +48,26 @@ namespace Sarand.PatientMgr.Win.Dbas.Bus
// Build query filter.
List<String> filters = new List<String>();
filters.Add(SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmFacility_DepartmentId)+"=" + Id.ToString());
if (type > 0) filters.Add(" AND " + SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmFacility_Type) + "=" + ((int)type).ToString());
filters.Add(SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmFacility_DepartmentId) + "=" + Id.ToString());
if (facilityType > 0) filters.Add(" AND " + SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmFacility_Type) + "=" + ((int)facilityType).ToString());
// Count the number of matching rows.
return (int)db.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmFacility), filters.Concat(" AND ", "(", ")"));
}
public override bool HasFacilities(Spm.FacilityType type)
public override bool HasFacilities (Spm.FacilityType facilityType)
{
ClearErrorState();
return (GetFacilityCount(type) > 0);
return (GetFacilityCount(facilityType) > 0);
}
public override bool HasProcedures()
public override bool HasProcedures ()
{
ClearErrorState();
if (!SysId.IsValid(Id)) return SetErrorState("invalid department");
ISacsDatabase db = SpmGlobals.Application.GetDatabase(userContext.SessionContext);
if (db == null) return SetErrorState("database unavailable");
List<String> filters = new List<String>();
filters.Add(SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmProcedure_DepartmentId)+"=" + Id.ToString());
filters.Add(SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmProcedure_DepartmentId) + "=" + Id.ToString());
return (int)db.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmFacility), filters.Concat(" AND ", "(", ")")) > 0;
}
@@ -1,4 +1,5 @@
using Sarand.Core.Base;
using Sarand.Core.UpdateLog;
using Sarand.PatientMgr.Core.App;
using Sarand.Win.Dbas.Base;
using Sarand.Win.Dbas.Security;
@@ -38,11 +39,25 @@ namespace Sarand.PatientMgr.Win.Dbas.Consoles
// Construction.
protected SpmSecurityConsole_Dbas (SpmSessionContext sessionContext, SacsDatabase database) : base(database)
{
SessionContext = sessionContext;
}
//-------------------------------------------------------------------
// Properties.
public List<TypeCodeDesc> GetSecurityRights () { return new List<TypeCodeDesc>(securityRights); }
protected SpmSessionContext SessionContext { get; }
public override short SecurityItemDataType { get { return (short)Spm.DataItemType.SecurityItem; } }
public override short SecurityLinkDataType { get { return (short)Spm.DataItemType.SecurityLink; } }
//-------------------------------------------------------------------
// Utilities.
//-------------------------------------------------------------------
// S e c u r i t y R i g h t s
//-------------------------------------------------------------------
public List<TypeCodeDesc> GetSecurityRights ()
{
return new List<TypeCodeDesc>(securityRights);
}
//-------------------------------------------------------------------
// Register Security Rights.
@@ -63,7 +63,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
if (DateUtil.IsValid(sessionDate) && SysId.IsValid(facilityId))
{
// Dummy query to set DBMS - for correct formatting of strings and dates etc.
DbQuery qryDummy = new DbQuery(db != null ? db.DbmsType : DbmsType.General);
DbQuery qryDummy = new DbQuery(Database != null ? Database.DbmsType : DbmsType.General);
// Filter to identify matching templates.
// Admission.AdmissionFrom <= Session date
@@ -75,7 +75,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
filters.Add(SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmAdmission_AdmissionTo) + ">=" + DbQuery.FormatDateForCondition(sessionDate));
filters.Add(SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmAdmission_FacilityId) + "=" + facilityId.ToString());
filters.Add(SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmAdmission_CancelType) + "=" + ((int)Spm.AdmissionCancelType.None).ToString());
return db.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmission), filters.Concat(" AND ", "(", ")"));
return Database.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmission), filters.Concat(" AND ", "(", ")"));
}
return 0;
}
@@ -86,7 +86,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
if (DateUtil.IsValid(sessionDate) && SysId.IsValid(templateId))
{
// Dummy query to set DBMS - for correct formatting of strings and dates etc.
DbQuery qryDummy = new DbQuery(db != null ? db.DbmsType : DbmsType.General);
DbQuery qryDummy = new DbQuery(Database != null ? Database.DbmsType : DbmsType.General);
// Filter to identify matching templates.
// Admission.AdmissionFrom <= Session date
@@ -98,7 +98,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
filters.Add(SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmAdmission_AdmissionTo) + ">=" + DbQuery.FormatDateForCondition(sessionDate));
filters.Add(SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmAdmission_FacilityTemplateId) + "=" + templateId.ToString());
filters.Add(SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmAdmission_CancelType) + "=" + ((int)Spm.AdmissionCancelType.None).ToString());
return db.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmission), filters.Concat(" AND ", "(", ")"));
return Database.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmission), filters.Concat(" AND ", "(", ")"));
}
return 0;
}
@@ -135,7 +135,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
SpmAdmission admission = null;
// Query data.
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -170,7 +170,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
ClearErrorState();
if (!IsValidAdmission(admission)) return false;
if (SysId.IsValid(admission.Id)) return SetErrorState(ErrorMessage.ValiditemId);
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -181,7 +181,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
if (SwmAdmission_Db.FieldsNonId.Contains("Id"))
{
// Generate next Id.
dbAdmission._Id = SysId.ToInt(db.GetNextId("Admission", dbUpdateInfo));
dbAdmission._Id = SysId.ToInt(Database.GetNextId("Admission", dbUpdateInfo));
}
dbAdmission.ExecuteInsertCommand(dbCommand);
admission.Id = new SysId(dbAdmission._Id);
@@ -198,7 +198,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
ClearErrorState();
if (!IsValidAdmission(admission)) return false;
if (!SysId.IsValid(admission.Id)) return SetErrorState(ErrorMessage.InvalidItemId);
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -234,7 +234,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
{
ClearErrorState();
if (!AdmissionCanBeDeleted(admission)) return false;
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -867,7 +867,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
{
// Sub-query to retrict to facilities that belong to this department.
String colFacilityId = SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmFacility_Id, aliasAdmission_Facility);
DbQuery qry = new DbQuery(db.DbmsType);
DbQuery qry = new DbQuery(Database.DbmsType);
qry.Tables.Add(new StringPair(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmFacility), aliasAdmission_Facility));
qry.Columns.Add(colFacilityId);
qry.Filters.AddRange(filterDeptIdFacType);
@@ -978,7 +978,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
private long GetAdmissionCount(String filter)
{
ClearErrorState();
return db.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmission) + " As " + aliasAdmission, filter);
return Database.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmission) + " As " + aliasAdmission, filter);
}
public override long GetAdmissionCount(SpmAdmission.Params prm)
{
@@ -991,12 +991,12 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
public override List<SpmAdmission> GetAdmissionList(SpmAdmission.Params prm)
{
List<SpmAdmission> Admissiones = new List<SpmAdmission>();
DbQuery qry = new DbQuery(db.DbmsType);
DbQuery qry = new DbQuery(Database.DbmsType);
qry.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmission), aliasAdmission);
qry.Columns.AddRange(SwmAdmission_Db.Fields);
qry.Filters.AddRange(GetAdmissionQueryFilter(prm));
// Query data.
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -1029,7 +1029,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
//---------------------------------------------------------------
// Construct query.
DbQuery query = new DbQuery(db.DbmsType);
DbQuery query = new DbQuery(Database.DbmsType);
query.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmission), aliasAdmission);
// Admission Properties - add columns as defined in query list.
@@ -1077,7 +1077,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
if (columns.HasId((int)SpmAdmission.Column.Position)) query.Columns.Add(SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmAdmission_Position));
if (columns.HasId((int)SpmAdmission.Column.SpecialEquipment)) query.Columns.Add(SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmAdmission_SpecialEquipment));
if (columns.HasId((int)SpmAdmission.Column.AttendanceStatusDesc)) query.Columns.Add(SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmAdmission_AttendanceStatus));
if (columns.HasId((int)SpmAdmission.Column.ComfortScore) && db.ColumnExists(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmission), SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmAdmission_ComfortScore)))
if (columns.HasId((int)SpmAdmission.Column.ComfortScore) && Database.ColumnExists(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmission), SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmAdmission_ComfortScore)))
query.Columns.Add(SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmAdmission_ComfortScore));
// Common Properties
@@ -1288,8 +1288,8 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
//---------------------------------------------------------------
//return new DbResultSet_DataTableReader(db, query.BuildQuery());
return new Sarand.Win.Dbas.Data.DbResultSet_DataReader(db, query.BuildQuery());
//return new DbResultSet_DataTableReader(Database, query.BuildQuery());
return new Sarand.Win.Dbas.Data.DbResultSet_DataReader(Database, query.BuildQuery());
}
//-------------------------------------------------------------------
@@ -59,7 +59,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
SpmAdmissionAction admissionAction = null;
// Query data.
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -94,7 +94,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
ClearErrorState();
if (!IsValidAdmissionAction(admissionAction)) return false;
if (SysId.IsValid(admissionAction.Id)) return SetErrorState(ErrorMessage.ValiditemId);
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -105,7 +105,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
if (SwmAdmissionAction_Db.FieldsNonId.Contains("Id"))
{
// Generate next Id.
dbAdmissionAction._Id = SysId.ToInt(db.GetNextId("AdmissionAction", dbUpdateInfo));
dbAdmissionAction._Id = SysId.ToInt(Database.GetNextId("AdmissionAction", dbUpdateInfo));
}
dbAdmissionAction.ExecuteInsertCommand(dbCommand);
admissionAction.Id = new SysId(dbAdmissionAction._Id);
@@ -122,7 +122,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
ClearErrorState();
if (!IsValidAdmissionAction(admissionAction)) return false;
if (!SysId.IsValid(admissionAction.Id)) return SetErrorState(ErrorMessage.InvalidItemId);
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -158,7 +158,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
{
ClearErrorState();
if (!AdmissionActionCanBeDeleted(admissionAction)) return false;
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -419,7 +419,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
filters.Add(SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmFacility_DepartmentId, aliasAdmission_Facility) + "=" + prm.DepartmentId.ToString());
else
{
DbQuery qry = new DbQuery(db.DbmsType);
DbQuery qry = new DbQuery(Database.DbmsType);
qry.Tables.Add(new StringPair(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmFacility), aliasAdmission_Facility));
qry.Columns.Add(SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmFacility_Id));
qry.Filters.Add(SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmFacility_DepartmentId) + "=" + prm.DepartmentId.ToString());
@@ -431,7 +431,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
filtersDepartIdFacilityId.Add(SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmAdmission_FacilityId, aliasAdmission) + "=" + prm.FacilityId.ToString());
else
{
DbQuery qry = new DbQuery(db.DbmsType);
DbQuery qry = new DbQuery(Database.DbmsType);
qry.Tables.Add(new StringPair(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmission), aliasAdmission));
qry.Columns.Add(SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmAdmission_Id, aliasAdmission));
qry.Filters.AddRange(filtersDepartIdFacilityId);
@@ -497,7 +497,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
private long GetAdmissionActionCount(String filter)
{
ClearErrorState();
return db.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmissionAction) + " As " + aliasAdmissionAction, filter);
return Database.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmissionAction) + " As " + aliasAdmissionAction, filter);
}
public override long GetAdmissionActionCount(SpmAdmissionAction.Params prm)
{
@@ -510,12 +510,12 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
public override List<SpmAdmissionAction> GetAdmissionActionList(SpmAdmissionAction.Params prm)
{
List<SpmAdmissionAction> AdmissionActiones = new List<SpmAdmissionAction>();
DbQuery qry = new DbQuery(db.DbmsType);
DbQuery qry = new DbQuery(Database.DbmsType);
qry.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmissionAction), aliasAdmissionAction);
qry.Columns.AddRange(SwmAdmissionAction_Db.Fields);
qry.Filters.AddRange(GetAdmissionActionQueryFilter(prm));
// Query data.
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -548,7 +548,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
//---------------------------------------------------------------
// Construct query.
DbQuery query = new DbQuery(db.DbmsType);
DbQuery query = new DbQuery(Database.DbmsType);
query.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmissionAction), aliasAdmissionAction);
// AdmissionAction Properties - add columns as defined in query list.
@@ -652,8 +652,8 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
//---------------------------------------------------------------
//return new DbResultSet_DataTableReader(db, query.BuildQuery());
return new Sarand.Win.Dbas.Data.DbResultSet_DataReader(db, query.BuildQuery());
//return new DbResultSet_DataTableReader(Database, query.BuildQuery());
return new Sarand.Win.Dbas.Data.DbResultSet_DataReader(Database, query.BuildQuery());
}
//-------------------------------------------------------------------
@@ -59,7 +59,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
SpmAdmissionData admissionData = null;
// Query data.
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -94,7 +94,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
ClearErrorState();
if (!IsValidAdmissionData(admissionData)) return false;
if (SysId.IsValid(admissionData.Id)) return SetErrorState(ErrorMessage.ValiditemId);
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -105,7 +105,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
if (SwmAdmissionData_Db.FieldsNonId.Contains("Id"))
{
// Generate next Id.
//dbAdmissionData._Id = SysId.ToInt(db.GetNextId("AdmissionData", dbUpdateInfo));
//dbAdmissionData._Id = SysId.ToInt(Database.GetNextId("AdmissionData", dbUpdateInfo));
}
dbAdmissionData.ExecuteInsertCommand(dbCommand);
//admissionData.Id = new SysId(dbAdmissionData._Id);
@@ -122,7 +122,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
ClearErrorState();
if (!IsValidAdmissionData(admissionData)) return false;
if (!SysId.IsValid(admissionData.Id)) return SetErrorState(ErrorMessage.InvalidItemId);
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -158,7 +158,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
{
ClearErrorState();
if (!AdmissionDataCanBeDeleted(admissionData)) return false;
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -360,7 +360,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
private long GetAdmissionDataCount(String filter)
{
ClearErrorState();
return db.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmissionData) + " As " + aliasAdmissionData, filter);
return Database.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmissionData) + " As " + aliasAdmissionData, filter);
}
public override long GetAdmissionDataCount(SpmAdmissionData.Params prm)
{
@@ -373,12 +373,12 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
public override List<SpmAdmissionData> GetAdmissionDataList(SpmAdmissionData.Params prm)
{
List<SpmAdmissionData> AdmissionDataes = new List<SpmAdmissionData>();
DbQuery qry = new DbQuery(db.DbmsType);
DbQuery qry = new DbQuery(Database.DbmsType);
qry.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmissionData), aliasAdmissionData);
qry.Columns.AddRange(SwmAdmissionData_Db.Fields);
qry.Filters.AddRange(GetAdmissionDataQueryFilter(prm));
// Query data.
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -411,7 +411,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
//---------------------------------------------------------------
// Construct query.
DbQuery query = new DbQuery(db.DbmsType);
DbQuery query = new DbQuery(Database.DbmsType);
query.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmissionData), aliasAdmissionData);
// AdmissionData Properties - add columns as defined in query list.
@@ -446,8 +446,8 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
//---------------------------------------------------------------
//return new DbResultSet_DataTableReader(db, query.BuildQuery());
return new Sarand.Win.Dbas.Data.DbResultSet_DataReader(db, query.BuildQuery());
//return new DbResultSet_DataTableReader(Database, query.BuildQuery());
return new Sarand.Win.Dbas.Data.DbResultSet_DataReader(Database, query.BuildQuery());
}
//-------------------------------------------------------------------
}
@@ -59,7 +59,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
SpmAdmissionRole admissionRole = null;
// Query data.
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -94,7 +94,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
ClearErrorState();
if (!IsValidAdmissionRole(admissionRole)) return false;
if (SysId.IsValid(admissionRole.Id)) return SetErrorState(ErrorMessage.ValiditemId);
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -105,7 +105,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
if (SwmAdmissionRole_Db.FieldsNonId.Contains("Id"))
{
// Generate next Id.
dbAdmissionRole._AdmissionId = SysId.ToInt(db.GetNextId("AdmissionRole", dbUpdateInfo));
dbAdmissionRole._AdmissionId = SysId.ToInt(Database.GetNextId("AdmissionRole", dbUpdateInfo));
}
dbAdmissionRole.ExecuteInsertCommand(dbCommand);
admissionRole.Id = new SysId(dbAdmissionRole._AdmissionId);
@@ -122,7 +122,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
ClearErrorState();
if (!IsValidAdmissionRole(admissionRole)) return false;
if (!SysId.IsValid(admissionRole.Id)) return SetErrorState(ErrorMessage.InvalidItemId);
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -158,7 +158,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
{
ClearErrorState();
if (!AdmissionRoleCanBeDeleted(admissionRole)) return false;
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -399,7 +399,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
private long GetAdmissionRoleCount(String filter)
{
ClearErrorState();
return db.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmissionRole) + " As " + aliasAdmissionRole, filter);
return Database.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmissionRole) + " As " + aliasAdmissionRole, filter);
}
public override long GetAdmissionRoleCount(SpmAdmissionRole.Params prm)
{
@@ -412,12 +412,12 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
public override List<SpmAdmissionRole> GetAdmissionRoleList(SpmAdmissionRole.Params prm)
{
List<SpmAdmissionRole> AdmissionRolees = new List<SpmAdmissionRole>();
DbQuery qry = new DbQuery(db.DbmsType);
DbQuery qry = new DbQuery(Database.DbmsType);
qry.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmissionRole), aliasAdmissionRole);
qry.Columns.AddRange(SwmAdmissionRole_Db.Fields);
qry.Filters.AddRange(GetAdmissionRoleQueryFilter(prm));
// Query data.
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -450,7 +450,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
//---------------------------------------------------------------
// Construct query.
DbQuery query = new DbQuery(db.DbmsType);
DbQuery query = new DbQuery(Database.DbmsType);
query.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmissionRole), aliasAdmissionRole);
// AdmissionRole Properties - add columns as defined in query list.
@@ -491,8 +491,8 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
//---------------------------------------------------------------
//return new DbResultSet_DataTableReader(db, query.BuildQuery());
return new Sarand.Win.Dbas.Data.DbResultSet_DataReader(db, query.BuildQuery());
//return new DbResultSet_DataTableReader(Database, query.BuildQuery());
return new Sarand.Win.Dbas.Data.DbResultSet_DataReader(Database, query.BuildQuery());
}
//-------------------------------------------------------------------
}
@@ -3,6 +3,7 @@ using Sarand.PatientMgr.Core.App;
using Sarand.PatientMgr.Core.Mgr;
using Sarand.PatientMgr.Win.Dbas.Data;
using Sarand.Win.Dbas.Base;
using Sarand.Win.Dbas.Data;
using System;
using System.Collections.Generic;
using System.Text;
@@ -14,20 +15,20 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
{
//-------------------------------------------------------------------
// Data members.
private SacsDatabase db = null;
private readonly SpmDbDataItem.DatabaseInfo dbInfo;
//-------------------------------------------------------------------
// Construction.
public SpmAdmissionMgr_Dbas (SpmUserContext userContext) :
base(userContext)
{
Database = SpmGlobals.Application.GetDatabase(userContext.SessionContext) as SacsDatabase;
DbInfo = new DbDataItem.DatabaseInfo(Database);
}
//-------------------------------------------------------------------
// Properties.
protected ISacsDatabase Database { get { return db; } }
protected SpmDbDataItem.DatabaseInfo DbInfo { get { return dbInfo; } }
protected SacsDatabase Database { get; }
protected DbDataItem.DatabaseInfo DbInfo { get; }
//-------------------------------------------------------------------
// Utilities.
@@ -29,14 +29,14 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
//-------------------------------------------------------------------
// Create Department.
public override SpmDepartment CreateDepartment()
public override SpmDepartment CreateDepartment(SysId institutionId)
{
return new SpmDepartment_Dbas(UserContext, null, 0);
return new SpmDepartment_Dbas(UserContext, null, institutionId, 0);
}
private SpmDepartment_Dbas CreateDepartment(SwmDepartment_Db dbDepartment)
{
ClearErrorState();
SpmDepartment_Dbas department = new SpmDepartment_Dbas(UserContext, new SysId(dbDepartment._Id), (ushort)dbDepartment._Flags);
SpmDepartment_Dbas department = new SpmDepartment_Dbas(UserContext, new SysId(dbDepartment._Id), new SysId(dbDepartment._InstitutionId), (ushort)dbDepartment._Flags);
PopulateFrom(dbDepartment, department);
return department;
}
@@ -59,7 +59,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
SpmDepartment department = null;
// Query data.
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -94,7 +94,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
ClearErrorState();
if (!IsValidDepartment(department)) return false;
if (SysId.IsValid(department.Id)) return SetErrorState(ErrorMessage.ValiditemId);
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -105,7 +105,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
if (SwmDepartment_Db.FieldsNonId.Contains("Id"))
{
// Generate next Id.
dbDepartment._Id = SysId.ToInt(db.GetNextId("Department", dbUpdateInfo));
dbDepartment._Id = SysId.ToInt(Database.GetNextId("Department", dbUpdateInfo));
}
dbDepartment.ExecuteInsertCommand(dbCommand);
department.Id = new SysId(dbDepartment._Id);
@@ -122,7 +122,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
ClearErrorState();
if (!IsValidDepartment(department)) return false;
if (!SysId.IsValid(department.Id)) return SetErrorState(ErrorMessage.InvalidItemId);
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -158,7 +158,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
{
ClearErrorState();
if (!DepartmentCanBeDeleted(department)) return false;
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -181,13 +181,14 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
// Copy data properties to and from database.
private void PopulateTo(SwmDepartment_Db dbDepartment, SpmDepartment department, DbUpdateInfo dbUpdateInfo)
{
dbDepartment._Id = department.Id.ToInt();
dbDepartment._Id = SysId.ToInt(department.Id);
dbDepartment._InstitutionId = SysId.ToInt(department.InstitutionId);
dbDepartment._Name = department.Name;
dbDepartment._FacilityTypes = (int)department.GetFacilityTypes();
dbDepartment._AllowAnyFacility = (int)department.GetAllowAnyFacilities();
dbDepartment._ApplicFrom = department.ApplicationFrom;
dbDepartment._ApplicTo = department.ApplicationTo;
dbDepartment._FacilityTypes = (int)department.FacilityTypes;
dbDepartment._AllowAnyFacility = (int)department.AllowAnyFacilities;
dbDepartment._ApplicFrom = department.ApplicableFrom;
dbDepartment._ApplicTo = department.ApplicableTo;
// Common properties.
dbDepartment._Notes = department.Notes;
dbDepartment._Status = SacsSystem.GetStatusCode(department.Status);
dbDepartment._Flags = (short)department.Flags;
@@ -203,11 +204,13 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
private void PopulateFrom(SwmDepartment_Db dbDepartment, SpmDepartment department)
{
department.Id = new SysId(dbDepartment._Id);
//department.InstitutionId = new SysId(dbDepartment._InstitutionId);
department.Name = dbDepartment._Name;
department.ApplicationFrom = dbDepartment._ApplicFrom;
department.ApplicationTo = dbDepartment._ApplicTo;
department.FacilityTypes = (uint)dbDepartment._FacilityTypes;
department.AllowAnyFacilities = (uint)dbDepartment._AllowAnyFacility;
department.ApplicableFrom = dbDepartment._ApplicFrom;
department.ApplicableTo = dbDepartment._ApplicTo;
// Common properties.
department.Notes = dbDepartment._Notes;
department.Status = SacsSystem.GetStatusForCode(dbDepartment._Status);
department.SetCreateStamp(dbDepartment._CreateOn, new SysId(dbDepartment._CreateBy), dbDepartment._CreateHost);
@@ -246,17 +249,21 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
SetDepartmentColDfn(columnDfn, "Id", 40, SpmDbDfn.ColumnIdx.SwmDepartment_Id, ColumnAlignment.Right, DataValue.DataType.Long);
columnDfn.ReadOnly = true;
break;
case SpmDepartment.Column.InstitutionId:
SetDepartmentColDfn(columnDfn, "Institution #", 40, SpmDbDfn.ColumnIdx.SwmDepartment_InstitutionId, ColumnAlignment.Right, DataValue.DataType.Long);
columnDfn.ReadOnly = true;
break;
// Department Properties.
case SpmDepartment.Column.Name:
SetDepartmentColDfn(columnDfn, "Name", 60, SpmDbDfn.ColumnIdx.SwmDepartment_Name, ColumnAlignment.Center, DataValue.DataType.String);
SetDepartmentColDfn(columnDfn, "Department", 160, SpmDbDfn.ColumnIdx.SwmDepartment_Name);
break;
case SpmDepartment.Column.ApplicatonFrom:
SetDepartmentColDfn(columnDfn, "ApplicationFrom", 70, SpmDbDfn.ColumnIdx.SwmDepartment_ApplicFrom, ColumnAlignment.Center, DataValue.DataType.Date);
case SpmDepartment.Column.ApplicableFrom:
SetDepartmentColDfn(columnDfn, "From", 80, SpmDbDfn.ColumnIdx.SwmDepartment_ApplicFrom, ColumnAlignment.Center, DataValue.DataType.Date);
columnDfn.DateFormat = "d-MMM-yy";
break;
case SpmDepartment.Column.ApplicationTo:
SetDepartmentColDfn(columnDfn, "ApplicationTo", 70, SpmDbDfn.ColumnIdx.SwmDepartment_ApplicTo, ColumnAlignment.Center, DataValue.DataType.Date);
case SpmDepartment.Column.ApplicableTo:
SetDepartmentColDfn(columnDfn, "To", 80, SpmDbDfn.ColumnIdx.SwmDepartment_ApplicTo, ColumnAlignment.Center, DataValue.DataType.Date);
columnDfn.DateFormat = "d-MMM-yy";
break;
@@ -320,25 +327,25 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
filters.Add("(" + colApplicFrom + " IS NULL OR " + colApplicFrom + "=" + DbQuery.FormatDateForCondition(nullDate) + " OR " + colApplicFrom + "<" + DbQuery.FormatDateForCondition(DateUtil.IncrementDate(prm.Application, 1)) + ")");
filters.Add("(" + colApplicTo + " IS NULL OR " + colApplicTo + "=" + DbQuery.FormatDateForCondition(nullDate) + " OR " + colApplicTo + ">=" + DbQuery.FormatDateForCondition(prm.Application) + ")");
}
else if (DateUtil.IsValid(prm.ApplicationFrom) || DateUtil.IsValid(prm.ApplicationTo))
else if (DateUtil.IsValid(prm.ApplicableFrom) || DateUtil.IsValid(prm.ApplicableTo))
{
// Looking for roles that overlap with the specified date range.
if (DateUtil.IsValid(prm.ApplicationFrom) && DateUtil.IsValid(prm.ApplicationTo))
if (DateUtil.IsValid(prm.ApplicableFrom) && DateUtil.IsValid(prm.ApplicableTo))
{
// Both from and to dates specified.
filters.Add("(" + colApplicFrom + " IS NULL OR " + colApplicFrom + "=" + DbQuery.FormatDateForCondition(nullDate) + " OR " + colApplicFrom + "<" + DbQuery.FormatDateForCondition(DateUtil.IncrementDate(prm.ApplicationTo, 1)) + ")");
filters.Add("(" + colApplicTo + " IS NULL OR " + colApplicTo + "=" + DbQuery.FormatDateForCondition(nullDate) + " OR " + colApplicTo + ">=" + DbQuery.FormatDateForCondition(prm.ApplicationFrom) + ")");
filters.Add("(" + colApplicFrom + " IS NULL OR " + colApplicFrom + "=" + DbQuery.FormatDateForCondition(nullDate) + " OR " + colApplicFrom + "<" + DbQuery.FormatDateForCondition(DateUtil.IncrementDate(prm.ApplicableTo, 1)) + ")");
filters.Add("(" + colApplicTo + " IS NULL OR " + colApplicTo + "=" + DbQuery.FormatDateForCondition(nullDate) + " OR " + colApplicTo + ">=" + DbQuery.FormatDateForCondition(prm.ApplicableFrom) + ")");
}
else if (DateUtil.IsValid(prm.ApplicationFrom))
else if (DateUtil.IsValid(prm.ApplicableFrom))
{
// Only 'from' date specified - Matches with ApplicTo not specified or after 'from' date.
filters.Add("(" + colApplicTo + " IS NULL OR " + colApplicTo + "=" + DbQuery.FormatDateForCondition(nullDate) + " OR " + colApplicTo + ">=" + DbQuery.FormatDateForCondition(prm.ApplicationFrom) + ")");
filters.Add("(" + colApplicTo + " IS NULL OR " + colApplicTo + "=" + DbQuery.FormatDateForCondition(nullDate) + " OR " + colApplicTo + ">=" + DbQuery.FormatDateForCondition(prm.ApplicableFrom) + ")");
String filter = filters[0];
}
else if (DateUtil.IsValid(prm.ApplicationTo))
else if (DateUtil.IsValid(prm.ApplicableTo))
{
// Only 'to' date specified - Matches with ApplicFrom not specified or before 'to' date.
filters.Add("(" + colApplicFrom + " IS NULL OR " + colApplicFrom + "=" + DbQuery.FormatDateForCondition(nullDate) + " OR " + colApplicFrom + "<" + DbQuery.FormatDateForCondition(DateUtil.IncrementDate(prm.ApplicationTo, 1)) + ")");
filters.Add("(" + colApplicFrom + " IS NULL OR " + colApplicFrom + "=" + DbQuery.FormatDateForCondition(nullDate) + " OR " + colApplicFrom + "<" + DbQuery.FormatDateForCondition(DateUtil.IncrementDate(prm.ApplicableTo, 1)) + ")");
String filter = filters[0];
}
}
@@ -390,7 +397,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
private long GetDepartmentCount(String filter)
{
ClearErrorState();
return db.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmDepartment) + " As " + aliasDepartment, filter);
return Database.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmDepartment) + " As " + aliasDepartment, filter);
}
public override long GetDepartmentCount(SpmDepartment.Params prm)
{
@@ -403,12 +410,12 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
public override List<SpmDepartment> GetDepartmentList(SpmDepartment.Params prm)
{
List<SpmDepartment> Departmentes = new List<SpmDepartment>();
DbQuery qry = new DbQuery(db.DbmsType);
DbQuery qry = new DbQuery(Database.DbmsType);
qry.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmDepartment), aliasDepartment);
qry.Columns.AddRange(SwmDepartment_Db.Fields);
qry.Filters.AddRange(GetDepartmentQueryFilter(prm));
// Query data.
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -441,7 +448,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
//---------------------------------------------------------------
// Construct query.
DbQuery query = new DbQuery(db.DbmsType);
DbQuery query = new DbQuery(Database.DbmsType);
query.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmDepartment), aliasDepartment);
// Department Properties - add columns as defined in query list.
@@ -449,9 +456,9 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
query.Columns.Add(SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmDepartment_Id, aliasDepartment));
if (columns.HasId((int)SpmDepartment.Column.Name))
query.Columns.Add(SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmDepartment_Name, aliasDepartment));
if (columns.HasId((int)SpmDepartment.Column.ApplicatonFrom))
if (columns.HasId((int)SpmDepartment.Column.ApplicableFrom))
query.Columns.Add(SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmDepartment_ApplicFrom, aliasDepartment));
if (columns.HasId((int)SpmDepartment.Column.ApplicationTo))
if (columns.HasId((int)SpmDepartment.Column.ApplicableTo))
query.Columns.Add(SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmDepartment_ApplicTo, aliasDepartment));
@@ -477,8 +484,8 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
//---------------------------------------------------------------
//return new DbResultSet_DataTableReader(db, query.BuildQuery());
return new Sarand.Win.Dbas.Data.DbResultSet_DataReader(db, query.BuildQuery());
//return new DbResultSet_DataTableReader(Database, query.BuildQuery());
return new Sarand.Win.Dbas.Data.DbResultSet_DataReader(Database, query.BuildQuery());
}
//-------------------------------------------------------------------
@@ -59,7 +59,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
SpmEmployeeRole employeeRole = null;
// Query data.
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -94,7 +94,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
ClearErrorState();
if (!IsValidEmployeeRole(employeeRole)) return false;
if (SysId.IsValid(employeeRole.Id)) return SetErrorState(ErrorMessage.ValiditemId);
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -105,7 +105,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
if (SwmEmployeeRole_Db.FieldsNonId.Contains("Id"))
{
// Generate next Id.
dbEmployeeRole._Id = SysId.ToInt(db.GetNextId("EmployeeRole", dbUpdateInfo));
dbEmployeeRole._Id = SysId.ToInt(Database.GetNextId("EmployeeRole", dbUpdateInfo));
}
dbEmployeeRole.ExecuteInsertCommand(dbCommand);
employeeRole.Id = new SysId(dbEmployeeRole._Id);
@@ -122,7 +122,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
ClearErrorState();
if (!IsValidEmployeeRole(employeeRole)) return false;
if (!SysId.IsValid(employeeRole.Id)) return SetErrorState(ErrorMessage.InvalidItemId);
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -158,7 +158,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
{
ClearErrorState();
if (!EmployeeRoleCanBeDeleted(employeeRole)) return false;
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -325,7 +325,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
String colSurname = SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmEmployee_Surname, aliasEmployee);
// Build sub query on employee.
DbQuery qry = new DbQuery(db.DbmsType);
DbQuery qry = new DbQuery(Database.DbmsType);
qry.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmEmployee), aliasEmployee);
qry.Columns.Add(colEmployeeId);
@@ -417,7 +417,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
private long GetEmployeeRoleCount(String filter)
{
ClearErrorState();
return db.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmEmployeeRole) + " As " + aliasEmployeeRole, filter);
return Database.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmEmployeeRole) + " As " + aliasEmployeeRole, filter);
}
public override long GetEmployeeRoleCount(SpmEmployeeRole.Params prm)
{
@@ -430,12 +430,12 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
public override List<SpmEmployeeRole> GetEmployeeRoleList(SpmEmployeeRole.Params prm)
{
List<SpmEmployeeRole> EmployeeRolees = new List<SpmEmployeeRole>();
DbQuery qry = new DbQuery(db.DbmsType);
DbQuery qry = new DbQuery(Database.DbmsType);
qry.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmEmployeeRole), aliasEmployeeRole);
qry.Columns.AddRange(SwmEmployeeRole_Db.Fields);
qry.Filters.AddRange(GetEmployeeRoleQueryFilter(prm));
// Query data.
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -468,7 +468,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
//---------------------------------------------------------------
// Construct query.
DbQuery query = new DbQuery(db.DbmsType);
DbQuery query = new DbQuery(Database.DbmsType);
query.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmEmployeeRole), aliasEmployeeRole);
// EmployeeRole Properties - add columns as defined in query list.
@@ -501,8 +501,8 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
//---------------------------------------------------------------
//return new DbResultSet_DataTableReader(db, query.BuildQuery());
return new Sarand.Win.Dbas.Data.DbResultSet_DataReader(db, query.BuildQuery());
//return new DbResultSet_DataTableReader(Database, query.BuildQuery());
return new Sarand.Win.Dbas.Data.DbResultSet_DataReader(Database, query.BuildQuery());
}
//-------------------------------------------------------------------
@@ -59,7 +59,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
SpmFacility facility = null;
// Query data.
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -94,7 +94,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
ClearErrorState();
if (!IsValidFacility(facility)) return false;
if (SysId.IsValid(facility.Id)) return SetErrorState(ErrorMessage.ValiditemId);
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -105,7 +105,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
if (SwmFacility_Db.FieldsNonId.Contains("Id"))
{
// Generate next Id.
dbFacility._Id = SysId.ToInt(db.GetNextId("Facility", dbUpdateInfo));
dbFacility._Id = SysId.ToInt(Database.GetNextId("Facility", dbUpdateInfo));
}
dbFacility.ExecuteInsertCommand(dbCommand);
facility.Id = new SysId(dbFacility._Id);
@@ -122,7 +122,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
ClearErrorState();
if (!IsValidFacility(facility)) return false;
if (!SysId.IsValid(facility.Id)) return SetErrorState(ErrorMessage.InvalidItemId);
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -158,7 +158,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
{
ClearErrorState();
if (!FacilityCanBeDeleted(facility)) return false;
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -421,7 +421,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
private long GetFacilityCount(String filter)
{
ClearErrorState();
return db.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmFacility) + " As " + aliasFacility, filter);
return Database.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmFacility) + " As " + aliasFacility, filter);
}
public override long GetFacilityCount(SpmFacility.Params prm)
{
@@ -434,12 +434,12 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
public override List<SpmFacility> GetFacilityList(SpmFacility.Params prm)
{
List<SpmFacility> Facilityes = new List<SpmFacility>();
DbQuery qry = new DbQuery(db.DbmsType);
DbQuery qry = new DbQuery(Database.DbmsType);
qry.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmFacility), aliasFacility);
qry.Columns.AddRange(SwmFacility_Db.Fields);
qry.Filters.AddRange(GetFacilityQueryFilter(prm));
// Query data.
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -472,7 +472,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
//---------------------------------------------------------------
// Construct query.
DbQuery query = new DbQuery(db.DbmsType);
DbQuery query = new DbQuery(Database.DbmsType);
query.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmFacility), aliasFacility);
// Facility Properties - add columns as defined in query list.
@@ -511,8 +511,8 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
//---------------------------------------------------------------
//return new DbResultSet_DataTableReader(db, query.BuildQuery());
return new Sarand.Win.Dbas.Data.DbResultSet_DataReader(db, query.BuildQuery());
//return new DbResultSet_DataTableReader(Database, query.BuildQuery());
return new Sarand.Win.Dbas.Data.DbResultSet_DataReader(Database, query.BuildQuery());
}
//-------------------------------------------------------------------
}
@@ -59,7 +59,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
SpmFacilitySession facilitySession = null;
// Query data.
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -94,7 +94,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
ClearErrorState();
if (!IsValidFacilitySession(facilitySession)) return false;
if (SysId.IsValid(facilitySession.Id)) return SetErrorState(ErrorMessage.ValiditemId);
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -105,7 +105,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
if (SwmFacilitySession_Db.FieldsNonId.Contains("Id"))
{
// Generate next Id.
//dbFacilitySession._Id = SysId.ToInt(db.GetNextId("FacilitySession", dbUpdateInfo));
//dbFacilitySession._Id = SysId.ToInt(Database.GetNextId("FacilitySession", dbUpdateInfo));
}
dbFacilitySession.ExecuteInsertCommand(dbCommand);
//facilitySession.Id = new SysId(dbFacilitySession._Id);
@@ -122,7 +122,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
ClearErrorState();
if (!IsValidFacilitySession(facilitySession)) return false;
if (!SysId.IsValid(facilitySession.Id)) return SetErrorState(ErrorMessage.InvalidItemId);
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -158,7 +158,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
{
ClearErrorState();
if (!FacilitySessionCanBeDeleted(facilitySession)) return false;
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -702,7 +702,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
private long GetFacilitySessionCount(String filter)
{
ClearErrorState();
return db.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmFacilitySession) + " As " + aliasFacilitySession_Session, filter);
return Database.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmFacilitySession) + " As " + aliasFacilitySession_Session, filter);
}
public override long GetFacilitySessionCount(SpmFacilitySession.Params prm)
{
@@ -715,12 +715,12 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
public override List<SpmFacilitySession> GetFacilitySessionList(SpmFacilitySession.Params prm)
{
List<SpmFacilitySession> FacilitySessiones = new List<SpmFacilitySession>();
DbQuery qry = new DbQuery(db.DbmsType);
DbQuery qry = new DbQuery(Database.DbmsType);
qry.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmFacilitySession), aliasFacilitySession_Session);
qry.Columns.AddRange(SwmFacilitySession_Db.Fields);
qry.Filters.AddRange(GetFacilitySessionQueryFilter(prm));
// Query data.
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -758,7 +758,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
//---------------------------------------------------------------
// Construct query.
DbQuery query = new DbQuery(db.DbmsType);
DbQuery query = new DbQuery(Database.DbmsType);
query.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmFacilitySession), aliasFacilitySession_Session);
// FacilitySession Properties - add columns as defined in query list.
@@ -886,7 +886,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
{
// Calculated total duration for admissions.
String aliasAdmDur = "aAdmDur";
DbQuery qryAdmDur = new DbQuery(db.DbmsType);
DbQuery qryAdmDur = new DbQuery(Database.DbmsType);
qryAdmDur.Tables.Add(new StringPair(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmission), aliasAdmDur));
qryAdmDur.Columns.Add("SUM(" + DbQuery.FormatFn_DateDiff(DbDateDiffInterval.Minute, SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmAdmission_AdmissionFrom, aliasAdmDur), SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmAdmission_AdmissionTo, aliasAdmDur)) + ")");
qryAdmDur.Filters.Add(SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmAdmission_FacilityTemplateId, aliasAdmDur) + "=" + SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmFacilityTemplate_Id, aliasFacilitySession_Template));
@@ -900,7 +900,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
{
// Calculated total duration for admissions with blank patient numbers.
String aliasAdmDur = "aAdmDur_PatNo";
DbQuery qryAdmDur = new DbQuery(db.DbmsType);
DbQuery qryAdmDur = new DbQuery(Database.DbmsType);
qryAdmDur.Tables.Add(new StringPair(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmission), aliasAdmDur));
qryAdmDur.Columns.Add("SUM(" + DbQuery.FormatFn_DateDiff(DbDateDiffInterval.Minute, SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmAdmission_AdmissionFrom, aliasAdmDur), SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmAdmission_AdmissionTo, aliasAdmDur)) + ")");
qryAdmDur.Filters.Add(SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmAdmission_FacilityTemplateId, aliasAdmDur) + "=" + SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmFacilityTemplate_Id, aliasFacilitySession_Template));
@@ -915,7 +915,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
{
// Total estimated slot duration for this session.
String aliasAdmDur = "aAdmDur_EstSess";
DbQuery qryAdmDur = new DbQuery(db.DbmsType);
DbQuery qryAdmDur = new DbQuery(Database.DbmsType);
qryAdmDur.Tables.Add(new StringPair(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmission), aliasAdmDur));
qryAdmDur.Columns.Add("SUM(" + SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmAdmission_DurationExp, aliasAdmDur) + ")");
qryAdmDur.Filters.Add(SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmAdmission_FacilityTemplateId, aliasAdmDur) + "=" + SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmFacilityTemplate_Id, aliasFacilitySession_Template));
@@ -929,7 +929,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
{
// Total estimated slot duration for this session.
String aliasAdmDur = "aAdmDur";
DbQuery qryAdmDur = new DbQuery(db.DbmsType);
DbQuery qryAdmDur = new DbQuery(Database.DbmsType);
qryAdmDur.Tables.Add(new StringPair(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmission), aliasAdmDur));
qryAdmDur.Columns.Add("SUM(" + SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmAdmission_DurationAct, aliasAdmDur) + ")");
qryAdmDur.Filters.Add(SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmAdmission_FacilityTemplateId, aliasAdmDur) + "=" + SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmFacilityTemplate_Id, aliasFacilitySession_Template));
@@ -944,7 +944,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
{
// Total estimated slot duration for this session:
String aliasAdmDur = "aAdmDur";
DbQuery qryAdmDur = new DbQuery(db.DbmsType);
DbQuery qryAdmDur = new DbQuery(Database.DbmsType);
qryAdmDur.Tables.Add(new StringPair(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmission), aliasAdmDur));
qryAdmDur.Columns.Add("SUM(" + SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmAdmission_DurationExp, aliasAdmDur) + ")");
qryAdmDur.Filters.Add(SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmAdmission_FacilityTemplateId, aliasAdmDur) + "=" + SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmFacilityTemplate_Id, aliasFacilitySession_Template));
@@ -964,7 +964,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
{
// Calculated total UnitsExp for admissions:
String aliasAdmUnt = "aAdmUnt";
DbQuery qryAdmUnt = new DbQuery(db.DbmsType);
DbQuery qryAdmUnt = new DbQuery(Database.DbmsType);
qryAdmUnt.Tables.Add(new StringPair(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmission), aliasAdmUnt));
qryAdmUnt.Columns.Add("SUM(" + SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmAdmission_UnitsExp, aliasAdmUnt) + ")");
qryAdmUnt.Filters.Add(SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmAdmission_FacilityTemplateId, aliasAdmUnt) + "=" + SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmFacilityTemplate_Id, aliasFacilitySession_Template));
@@ -983,7 +983,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
{
// Count admissions cancelled (or moved/deleted) since day before admission for this session:
String aliasAdmCount = "aAdmCount";
DbQuery qryAdmCount = new DbQuery(db.DbmsType);
DbQuery qryAdmCount = new DbQuery(Database.DbmsType);
qryAdmCount.Tables.Add(new StringPair(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmission), aliasAdmCount));
qryAdmCount.Columns.Add("COUNT(" + SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmAdmission_Id, aliasAdmCount) + ")");
qryAdmCount.Filters.Add(SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmAdmission_FacilityTemplateId, aliasAdmCount) + "=" + SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmFacilityTemplate_Id, aliasFacilitySession_Template));
@@ -1013,7 +1013,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
{
// Count admissions for this session.
String aliasAdmCount = "aAdmCount";
DbQuery qryAdmCount = new DbQuery(db.DbmsType);
DbQuery qryAdmCount = new DbQuery(Database.DbmsType);
qryAdmCount.Tables.Add(new StringPair(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmission), aliasAdmCount));
qryAdmCount.Columns.Add("COUNT(" + SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmAdmission_Id, aliasAdmCount) + ")");
qryAdmCount.Filters.Add(SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmAdmission_FacilityTemplateId, aliasAdmCount) + "=" + SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmFacilityTemplate_Id, aliasFacilitySession_Template));
@@ -1068,8 +1068,8 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
//---------------------------------------------------------------
//return new DbResultSet_DataTableReader(db, query.BuildQuery());
return new Sarand.Win.Dbas.Data.DbResultSet_DataReader(db, query.BuildQuery());
//return new DbResultSet_DataTableReader(Database, query.BuildQuery());
return new Sarand.Win.Dbas.Data.DbResultSet_DataReader(Database, query.BuildQuery());
}
//-------------------------------------------------------------------
}
@@ -59,7 +59,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
SpmFacilityTemplate facilityTemplate = null;
// Query data.
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -94,7 +94,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
ClearErrorState();
if (!IsValidFacilityTemplate(facilityTemplate)) return false;
if (SysId.IsValid(facilityTemplate.Id)) return SetErrorState(ErrorMessage.ValiditemId);
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -105,7 +105,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
if (SwmFacilityTemplate_Db.FieldsNonId.Contains("Id"))
{
// Generate next Id.
dbFacilityTemplate._Id = SysId.ToInt(db.GetNextId("FacilityTemplate", dbUpdateInfo));
dbFacilityTemplate._Id = SysId.ToInt(Database.GetNextId("FacilityTemplate", dbUpdateInfo));
}
dbFacilityTemplate.ExecuteInsertCommand(dbCommand);
facilityTemplate.Id = new SysId(dbFacilityTemplate._Id);
@@ -122,7 +122,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
ClearErrorState();
if (!IsValidFacilityTemplate(facilityTemplate)) return false;
if (!SysId.IsValid(facilityTemplate.Id)) return SetErrorState(ErrorMessage.InvalidItemId);
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -158,7 +158,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
{
ClearErrorState();
if (!FacilityTemplateCanBeDeleted(facilityTemplate)) return false;
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -383,7 +383,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
private long GetFacilityTemplateCount(String filter)
{
ClearErrorState();
return db.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmFacilityTemplate) + " As " + aliasFacilityTemplate, filter);
return Database.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmFacilityTemplate) + " As " + aliasFacilityTemplate, filter);
}
public override long GetFacilityTemplateCount(SpmFacilityTemplate.Params prm)
{
@@ -396,12 +396,12 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
public override List<SpmFacilityTemplate> GetFacilityTemplateList(SpmFacilityTemplate.Params prm)
{
List<SpmFacilityTemplate> FacilityTemplatees = new List<SpmFacilityTemplate>();
DbQuery qry = new DbQuery(db.DbmsType);
DbQuery qry = new DbQuery(Database.DbmsType);
qry.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmFacilityTemplate), aliasFacilityTemplate);
qry.Columns.AddRange(SwmFacilityTemplate_Db.Fields);
qry.Filters.AddRange(GetFacilityTemplateQueryFilter(prm));
// Query data.
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -434,7 +434,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
//---------------------------------------------------------------
// Construct query.
DbQuery query = new DbQuery(db.DbmsType);
DbQuery query = new DbQuery(Database.DbmsType);
query.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmFacilityTemplate), aliasFacilityTemplate);
// FacilityTemplate Properties - add columns as defined in query list.
@@ -463,8 +463,8 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
//---------------------------------------------------------------
//return new DbResultSet_DataTableReader(db, query.BuildQuery());
return new Sarand.Win.Dbas.Data.DbResultSet_DataReader(db, query.BuildQuery());
//return new DbResultSet_DataTableReader(Database, query.BuildQuery());
return new Sarand.Win.Dbas.Data.DbResultSet_DataReader(Database, query.BuildQuery());
}
//-------------------------------------------------------------------
}
@@ -59,7 +59,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
SpmProcedure procedure = null;
// Query data.
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -94,7 +94,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
ClearErrorState();
if (!IsValidProcedure(procedure)) return false;
if (SysId.IsValid(procedure.Id)) return SetErrorState(ErrorMessage.ValiditemId);
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -105,7 +105,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
if (SwmProcedure_Db.FieldsNonId.Contains("Id"))
{
// Generate next Id.
dbProcedure._Id = SysId.ToInt(db.GetNextId("Procedure", dbUpdateInfo));
dbProcedure._Id = SysId.ToInt(Database.GetNextId("Procedure", dbUpdateInfo));
}
dbProcedure.ExecuteInsertCommand(dbCommand);
procedure.Id = new SysId(dbProcedure._Id);
@@ -122,7 +122,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
ClearErrorState();
if (!IsValidProcedure(procedure)) return false;
if (!SysId.IsValid(procedure.Id)) return SetErrorState(ErrorMessage.InvalidItemId);
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -158,7 +158,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
{
ClearErrorState();
if (!ProcedureCanBeDeleted(procedure)) return false;
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -414,7 +414,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
private long GetProcedureCount(String filter)
{
ClearErrorState();
return db.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmProcedure) + " As " + aliasProcedure, filter);
return Database.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmProcedure) + " As " + aliasProcedure, filter);
}
public override long GetProcedureCount(SpmProcedure.Params prm)
{
@@ -427,12 +427,12 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
public override List<SpmProcedure> GetProcedureList(SpmProcedure.Params prm)
{
List<SpmProcedure> Procedurees = new List<SpmProcedure>();
DbQuery qry = new DbQuery(db.DbmsType);
DbQuery qry = new DbQuery(Database.DbmsType);
qry.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmProcedure), aliasProcedure);
qry.Columns.AddRange(SwmProcedure_Db.Fields);
qry.Filters.AddRange(GetProcedureQueryFilter(prm));
// Query data.
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -465,7 +465,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
//---------------------------------------------------------------
// Construct query.
DbQuery query = new DbQuery(db.DbmsType);
DbQuery query = new DbQuery(Database.DbmsType);
query.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmProcedure), aliasProcedure);
// Procedure Properties - add columns as defined in query list.
@@ -512,8 +512,8 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
//---------------------------------------------------------------
//return new DbResultSet_DataTableReader(db, query.BuildQuery());
return new Sarand.Win.Dbas.Data.DbResultSet_DataReader(db, query.BuildQuery());
//return new DbResultSet_DataTableReader(Database, query.BuildQuery());
return new Sarand.Win.Dbas.Data.DbResultSet_DataReader(Database, query.BuildQuery());
}
//-------------------------------------------------------------------
}
@@ -59,7 +59,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
SpmTemplateData templateData = null;
// Query data.
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -94,7 +94,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
ClearErrorState();
if (!IsValidTemplateData(templateData)) return false;
if (SysId.IsValid(templateData.Id)) return SetErrorState(ErrorMessage.ValiditemId);
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -105,7 +105,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
if (SwmTemplateData_Db.FieldsNonId.Contains("Id"))
{
// Generate next Id.
//dbTemplateData._Id = SysId.ToInt(db.GetNextId("TemplateData", dbUpdateInfo));
//dbTemplateData._Id = SysId.ToInt(Database.GetNextId("TemplateData", dbUpdateInfo));
}
dbTemplateData.ExecuteInsertCommand(dbCommand);
//templateData.Id = new SysId(dbTemplateData._Id);
@@ -122,7 +122,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
ClearErrorState();
if (!IsValidTemplateData(templateData)) return false;
if (!SysId.IsValid(templateData.Id)) return SetErrorState(ErrorMessage.InvalidItemId);
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -158,7 +158,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
{
ClearErrorState();
if (!TemplateDataCanBeDeleted(templateData)) return false;
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -333,7 +333,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
private long GetTemplateDataCount(String filter)
{
ClearErrorState();
return db.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmTemplateData) + " As " + aliasTemplateData, filter);
return Database.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmTemplateData) + " As " + aliasTemplateData, filter);
}
public override long GetTemplateDataCount(SpmTemplateData.Params prm)
{
@@ -346,12 +346,12 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
public override List<SpmTemplateData> GetTemplateDataList(SpmTemplateData.Params prm)
{
List<SpmTemplateData> TemplateDataes = new List<SpmTemplateData>();
DbQuery qry = new DbQuery(db.DbmsType);
DbQuery qry = new DbQuery(Database.DbmsType);
qry.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmTemplateData), aliasTemplateData);
qry.Columns.AddRange(SwmTemplateData_Db.Fields);
qry.Filters.AddRange(GetTemplateDataQueryFilter(prm));
// Query data.
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -384,7 +384,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
//---------------------------------------------------------------
// Construct query.
DbQuery query = new DbQuery(db.DbmsType);
DbQuery query = new DbQuery(Database.DbmsType);
query.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmTemplateData), aliasTemplateData);
// TemplateData Properties - add columns as defined in query list.
@@ -413,8 +413,8 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
//---------------------------------------------------------------
//return new DbResultSet_DataTableReader(db, query.BuildQuery());
return new Sarand.Win.Dbas.Data.DbResultSet_DataReader(db, query.BuildQuery());
//return new DbResultSet_DataTableReader(Database, query.BuildQuery());
return new Sarand.Win.Dbas.Data.DbResultSet_DataReader(Database, query.BuildQuery());
}
//-------------------------------------------------------------------
}
@@ -4,6 +4,7 @@ using Sarand.PatientMgr.Core.App;
using Sarand.PatientMgr.Core.Mgr;
using Sarand.PatientMgr.Win.Dbas.Data;
using Sarand.Win.Dbas.Base;
using Sarand.Win.Dbas.Data;
using System;
using System.Collections.Generic;
using System.Text;
@@ -15,8 +16,6 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
{
//-------------------------------------------------------------------
// Data members.
private SacsDatabase db = null;
private readonly SpmDbDataItem.DatabaseInfo dbInfo;
private List<TypeCodeDesc> attendStatuses = SpmSystem.GetCodesOfType(Spm.SystemCode.AttendanceStatus);
//-------------------------------------------------------------------
@@ -24,12 +23,14 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
public SpmDepartmentMgr_Dbas (SpmUserContext userContext) :
base(userContext)
{
Database = SpmGlobals.Application.GetDatabase(userContext.SessionContext) as SacsDatabase;
DbInfo = new DbDataItem.DatabaseInfo(Database);
}
//-------------------------------------------------------------------
// Properties.
protected ISacsDatabase Database { get { return db; } }
protected SpmDbDataItem.DatabaseInfo DbInfo { get { return dbInfo; } }
protected SacsDatabase Database { get; }
protected DbDataItem.DatabaseInfo DbInfo { get; }
//-------------------------------------------------------------------
// Utilities.
@@ -59,7 +59,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
SpmEmployee employee = null;
// Query data.
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -94,7 +94,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
ClearErrorState();
if (!IsValidEmployee(employee)) return false;
if (SysId.IsValid(employee.Id)) return SetErrorState(ErrorMessage.ValiditemId);
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -105,7 +105,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
if (SwmEmployee_Db.FieldsNonId.Contains("Id"))
{
// Generate next Id.
dbEmployee._Id = SysId.ToInt(db.GetNextId("Employee", dbUpdateInfo));
dbEmployee._Id = SysId.ToInt(Database.GetNextId("Employee", dbUpdateInfo));
}
dbEmployee.ExecuteInsertCommand(dbCommand);
employee.Id = new SysId(dbEmployee._Id);
@@ -122,7 +122,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
ClearErrorState();
if (!IsValidEmployee(employee)) return false;
if (!SysId.IsValid(employee.Id)) return SetErrorState(ErrorMessage.InvalidItemId);
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -158,7 +158,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
{
ClearErrorState();
if (!EmployeeCanBeDeleted(employee)) return false;
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -386,7 +386,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
private long GetEmployeeCount(String filter)
{
ClearErrorState();
return db.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmEmployee) + " As " + aliasEmployee, filter);
return Database.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmEmployee) + " As " + aliasEmployee, filter);
}
public override long GetEmployeeCount(SpmEmployee.Params prm)
{
@@ -399,12 +399,12 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
public override List<SpmEmployee> GetEmployeeList(SpmEmployee.Params prm)
{
List<SpmEmployee> Employeees = new List<SpmEmployee>();
DbQuery qry = new DbQuery(db.DbmsType);
DbQuery qry = new DbQuery(Database.DbmsType);
qry.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmEmployee), aliasEmployee);
qry.Columns.AddRange(SwmEmployee_Db.Fields);
qry.Filters.AddRange(GetEmployeeQueryFilter(prm));
// Query data.
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -437,7 +437,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
//---------------------------------------------------------------
// Construct query.
DbQuery query = new DbQuery(db.DbmsType);
DbQuery query = new DbQuery(Database.DbmsType);
query.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmEmployee), aliasEmployee);
// Employee Properties - add columns as defined in query list.
@@ -478,8 +478,8 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
//---------------------------------------------------------------
//return new DbResultSet_DataTableReader(db, query.BuildQuery());
return new Sarand.Win.Dbas.Data.DbResultSet_DataReader(db, query.BuildQuery());
//return new DbResultSet_DataTableReader(Database, query.BuildQuery());
return new Sarand.Win.Dbas.Data.DbResultSet_DataReader(Database, query.BuildQuery());
}
//-------------------------------------------------------------------
@@ -29,11 +29,11 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
//-------------------------------------------------------------------
// Create Institution.
public override SpmInstitution CreateInstitution(SysId institutionId)
public override SpmInstitution CreateInstitution ()
{
return new SpmInstitution_Dbas(UserContext, null, 0);
}
private SpmInstitution_Dbas CreateInstitution(SwmInstitution_Db dbInstitution)
private SpmInstitution_Dbas CreateInstitution (SwmInstitution_Db dbInstitution)
{
ClearErrorState();
SpmInstitution_Dbas institution = new SpmInstitution_Dbas(UserContext, new SysId(dbInstitution._Id), (ushort)dbInstitution._Flags);
@@ -43,11 +43,30 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
//-------------------------------------------------------------------
// Get Institution.
public override SpmInstitution GetInstitution(SpmInstitution.Params prm)
public override SpmInstitution GetInstitution ()
{
ClearErrorState();
SpmInstitution.Params prmInstitution = new SpmInstitution.Params();
prmInstitution.StatusCat = SpmInstitution.StatusCat.Any;
if (GetInstitutionCount(prmInstitution) == 0)
{
SetErrorState("No institution available.");
Logger.Warn("GetInstitution " + ErrorStateMessage);
return null;
}
if (GetInstitutionCount(prmInstitution) > 1)
{
SetErrorState("Multiple institutions available.");
Logger.Warn("GetInstitution " + ErrorStateMessage);
return null;
}
return GetInstitution(prmInstitution);
}
public override SpmInstitution GetInstitution (SpmInstitution.Params prm)
{
return GetInstitution(GetInstitutionQueryFilter(prm).Concat(" AND ", "(", ")"));
}
private SpmInstitution GetInstitution(String filter)
private SpmInstitution GetInstitution (String filter)
{
ClearErrorState();
long count = GetInstitutionCount(filter);
@@ -59,7 +78,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
SpmInstitution institution = null;
// Query data.
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -80,7 +99,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
//-------------------------------------------------------------------
// Validate Institution.
public override bool IsValidInstitutionData(SpmInstitution.Data data, SpmInstitution.ErrField errField)
public override bool IsValidInstitutionData (SpmInstitution.Data data, SpmInstitution.ErrField errField)
{
ClearErrorState();
if (!base.IsValidInstitutionData(data, errField)) return false;
@@ -89,12 +108,12 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
//-------------------------------------------------------------------
// Insert Institution.
public override bool InsertInstitution(SpmInstitution institution, DbUpdateInfo dbUpdateInfo)
public override bool InsertInstitution (SpmInstitution institution, DbUpdateInfo dbUpdateInfo)
{
ClearErrorState();
if (!IsValidInstitution(institution)) return false;
if (SysId.IsValid(institution.Id)) return SetErrorState(ErrorMessage.ValiditemId);
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -105,7 +124,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
if (SwmInstitution_Db.FieldsNonId.Contains("Id"))
{
// Generate next Id.
dbInstitution._Id = SysId.ToInt(db.GetNextId("Institution", dbUpdateInfo));
dbInstitution._Id = SysId.ToInt(Database.GetNextId("Institution", dbUpdateInfo));
}
dbInstitution.ExecuteInsertCommand(dbCommand);
institution.Id = new SysId(dbInstitution._Id);
@@ -117,12 +136,12 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
//-------------------------------------------------------------------
// Update Institution.
public override bool UpdateInstitution(SpmInstitution institution, DbUpdateInfo dbUpdateInfo)
public override bool UpdateInstitution (SpmInstitution institution, DbUpdateInfo dbUpdateInfo)
{
ClearErrorState();
if (!IsValidInstitution(institution)) return false;
if (!SysId.IsValid(institution.Id)) return SetErrorState(ErrorMessage.InvalidItemId);
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -148,17 +167,17 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
//-------------------------------------------------------------------
// Delete Institution.
public override bool InstitutionCanBeDeleted(SpmInstitution institution)
public override bool InstitutionCanBeDeleted (SpmInstitution institution)
{
ClearErrorState();
if (!base.InstitutionCanBeDeleted(institution)) return false;
return true;
}
public override bool DeleteInstitution(SpmInstitution institution, DbUpdateInfo dbUpdateInfo)
public override bool DeleteInstitution (SpmInstitution institution, DbUpdateInfo dbUpdateInfo)
{
ClearErrorState();
if (!InstitutionCanBeDeleted(institution)) return false;
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -179,7 +198,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
//-------------------------------------------------------------------
// Copy data properties to and from database.
private void PopulateTo(SwmInstitution_Db dbInstitution, SpmInstitution institution, DbUpdateInfo dbUpdateInfo)
private void PopulateTo (SwmInstitution_Db dbInstitution, SpmInstitution institution, DbUpdateInfo dbUpdateInfo)
{
dbInstitution._Id = institution.Id.ToInt();
dbInstitution._Name = institution.Name;
@@ -197,7 +216,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
dbInstitution._UpdateBy = dbUpdateInfo.UserId.ToInt();
dbInstitution._UpdateHost = dbUpdateInfo.Host;
}
private void PopulateFrom(SwmInstitution_Db dbInstitution, SpmInstitution institution)
private void PopulateFrom (SwmInstitution_Db dbInstitution, SpmInstitution institution)
{
institution.Id = new SysId(dbInstitution._Id);
institution.Name = dbInstitution._Name;
@@ -225,7 +244,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
//-------------------------------------------------------------------
// Getting prmInstitution column definition.
public override ColumnDfn GetInstitutionColumnDfn(SpmInstitution.Column columnId, string caption = "", int width = 0)
public override ColumnDfn GetInstitutionColumnDfn (SpmInstitution.Column columnId, string caption = "", int width = 0)
{
ColumnDfn columnDfn = new ColumnDfn((int)columnId, caption, width);
switch (columnId)
@@ -244,7 +263,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
// Institution Properties.
case SpmInstitution.Column.Name:
SetInstitutionColDfn(columnDfn, "Name", 60, SpmDbDfn.ColumnIdx.SwmInstitution_Name, ColumnAlignment.Default, DataValue.DataType.String, aliasInstitution);
break;
break;
// Common properties.
case SpmInstitution.Column.Notes:
@@ -278,7 +297,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
//-------------------------------------------------------------------
// Institution query filter.
public override List<string> GetInstitutionQueryFilter(SpmInstitution.Params prm)
public override List<string> GetInstitutionQueryFilter (SpmInstitution.Params prm)
{
List<String> filter = new List<String>();
@@ -303,8 +322,10 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
filter.Add(colInstitution_Notes + " LIKE '%" + DbQuery.FormatForLike(prm.NotesPartial) + "%'");
// Status.
if (prm.StatusCat == SpmInstitution.StatusCat.Any)
filter.Add(SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmInstitution_Status, aliasInstitution) + " = '" + SacsSystem.GetStatusCode(SaStatus.Any) + "'");
if (prm.StatusCat != SpmInstitution.StatusCat.Any)
{
//filter.Add(SpmDbDfn.GetColumnNameQual(SpmDbDfn.ColumnIdx.SwmInstitution_Status, aliasInstitution) + " = '" + SacsSystem.GetStatusCode(SaStatus.Active) + "'");
}
if (filter.Count < 1) filter.Add("1=1");
@@ -313,7 +334,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
//-------------------------------------------------------------------
// Institution sort columns.
public List<String> GetInstitutionSortColumns(SpmInstitution.Params prm)
public List<String> GetInstitutionSortColumns (SpmInstitution.Params prm)
{
// Sort sequence:
List<String> sortColumnNames = new List<String>();
@@ -348,12 +369,12 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
//-------------------------------------------------------------------
// Institution count.
private long GetInstitutionCount(String filter)
private long GetInstitutionCount (String filter)
{
ClearErrorState();
return db.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmInstitution) + " As " + aliasInstitution, filter);
return Database.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmInstitution) + " As " + aliasInstitution, filter);
}
public override long GetInstitutionCount(SpmInstitution.Params prm)
public override long GetInstitutionCount (SpmInstitution.Params prm)
{
ClearErrorState();
return GetInstitutionCount(GetInstitutionQueryFilter(prm).Concat(" AND ", "(", ")"));
@@ -361,15 +382,15 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
//-------------------------------------------------------------------
// Institution list.
public override List<SpmInstitution> GetInstitutionList(SpmInstitution.Params prm)
public override List<SpmInstitution> GetInstitutionList (SpmInstitution.Params prm)
{
List<SpmInstitution> Institutiones = new List<SpmInstitution>();
DbQuery qry = new DbQuery(db.DbmsType);
DbQuery qry = new DbQuery(Database.DbmsType);
qry.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmInstitution), aliasInstitution);
qry.Columns.AddRange(SwmInstitution_Db.Fields);
qry.Filters.AddRange(GetInstitutionQueryFilter(prm));
// Query data.
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -396,13 +417,13 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
//-------------------------------------------------------------------
// Institution query execution.
public override DbResultSet ExecuteInstitutionQuery(List<ColumnDfn> columns, SpmInstitution.Params prm)
public override DbResultSet ExecuteInstitutionQuery (List<ColumnDfn> columns, SpmInstitution.Params prm)
{
ClearErrorState();
//---------------------------------------------------------------
// Construct query.
DbQuery query = new DbQuery(db.DbmsType);
DbQuery query = new DbQuery(Database.DbmsType);
query.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmInstitution), aliasInstitution);
// Institution Properties - add columns as defined in query list.
@@ -433,8 +454,8 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
//---------------------------------------------------------------
//return new DbResultSet_DataTableReader(db, query.BuildQuery());
return new Sarand.Win.Dbas.Data.DbResultSet_DataReader(db, query.BuildQuery());
//return new DbResultSet_DataTableReader(Database, query.BuildQuery());
return new Sarand.Win.Dbas.Data.DbResultSet_DataReader(Database, query.BuildQuery());
}
//-------------------------------------------------------------------
@@ -59,7 +59,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
SpmOperation operation = null;
// Query data.
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -94,7 +94,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
ClearErrorState();
if (!IsValidOperation(operation)) return false;
if (SysId.IsValid(operation.Id)) return SetErrorState(ErrorMessage.ValiditemId);
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -105,7 +105,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
if (SwmOperation_Db.FieldsNonId.Contains("Id"))
{
// Generate next Id.
dbOperation._Id = SysId.ToInt(db.GetNextId("Operation", dbUpdateInfo));
dbOperation._Id = SysId.ToInt(Database.GetNextId("Operation", dbUpdateInfo));
}
dbOperation.ExecuteInsertCommand(dbCommand);
operation.Id = new SysId(dbOperation._Id);
@@ -122,7 +122,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
ClearErrorState();
if (!IsValidOperation(operation)) return false;
if (!SysId.IsValid(operation.Id)) return SetErrorState(ErrorMessage.InvalidItemId);
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -158,7 +158,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
{
ClearErrorState();
if (!OperationCanBeDeleted(operation)) return false;
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -362,7 +362,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
private long GetOperationCount(String filter)
{
ClearErrorState();
return db.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmOperation) + " As " + aliasOperation, filter);
return Database.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmOperation) + " As " + aliasOperation, filter);
}
public override long GetOperationCount(SpmOperation.Params prm)
{
@@ -375,12 +375,12 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
public override List<SpmOperation> GetOperationList(SpmOperation.Params prm)
{
List<SpmOperation> Operationes = new List<SpmOperation>();
DbQuery qry = new DbQuery(db.DbmsType);
DbQuery qry = new DbQuery(Database.DbmsType);
qry.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmOperation), aliasOperation);
qry.Columns.AddRange(SwmOperation_Db.Fields);
qry.Filters.AddRange(GetOperationQueryFilter(prm));
// Query data.
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -413,7 +413,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
//---------------------------------------------------------------
// Construct query.
DbQuery query = new DbQuery(db.DbmsType);
DbQuery query = new DbQuery(Database.DbmsType);
query.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmOperation), aliasOperation);
// Operation Properties - add columns as defined in query list.
@@ -446,8 +446,8 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
//---------------------------------------------------------------
//return new DbResultSet_DataTableReader(db, query.BuildQuery());
return new Sarand.Win.Dbas.Data.DbResultSet_DataReader(db, query.BuildQuery());
//return new DbResultSet_DataTableReader(Database, query.BuildQuery());
return new Sarand.Win.Dbas.Data.DbResultSet_DataReader(Database, query.BuildQuery());
}
//-------------------------------------------------------------------
@@ -59,7 +59,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
SpmPatient admissionAction = null;
// Query data.
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -94,7 +94,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
ClearErrorState();
if (!IsValidPatient(admissionAction)) return false;
if (SysId.IsValid(admissionAction.Id)) return SetErrorState(ErrorMessage.ValiditemId);
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -105,7 +105,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
if (SwmPatient_Db.FieldsNonId.Contains("Id"))
{
// Generate next Id.
dbPatient._Id = SysId.ToInt(db.GetNextId("Patient", dbUpdateInfo));
dbPatient._Id = SysId.ToInt(Database.GetNextId("Patient", dbUpdateInfo));
}
dbPatient.ExecuteInsertCommand(dbCommand);
admissionAction.Id = new SysId(dbPatient._Id);
@@ -122,7 +122,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
ClearErrorState();
if (!IsValidPatient(admissionAction)) return false;
if (!SysId.IsValid(admissionAction.Id)) return SetErrorState(ErrorMessage.InvalidItemId);
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -158,7 +158,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
{
ClearErrorState();
if (!PatientCanBeDeleted(admissionAction)) return false;
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -388,7 +388,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
private long GetPatientCount(String filter)
{
ClearErrorState();
return db.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmPatient) + " As " + aliasPatient, filter);
return Database.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmPatient) + " As " + aliasPatient, filter);
}
public override long GetPatientCount(SpmPatient.Params prm)
{
@@ -401,12 +401,12 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
public override List<SpmPatient> GetPatientList(SpmPatient.Params prm)
{
List<SpmPatient> Patientes = new List<SpmPatient>();
DbQuery qry = new DbQuery(db.DbmsType);
DbQuery qry = new DbQuery(Database.DbmsType);
qry.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmPatient), aliasPatient);
qry.Columns.AddRange(SwmPatient_Db.Fields);
qry.Filters.AddRange(GetPatientQueryFilter(prm));
// Query data.
using (var dbConnection = db.CreateConnection())
using (var dbConnection = Database.CreateConnection())
using (var dbCommand = dbConnection.CreateCommand())
{
try
@@ -439,7 +439,7 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
//---------------------------------------------------------------
// Construct query.
DbQuery query = new DbQuery(db.DbmsType);
DbQuery query = new DbQuery(Database.DbmsType);
query.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmPatient), aliasPatient);
// Patient Properties - add columns as defined in query list.
@@ -486,8 +486,8 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
}
//---------------------------------------------------------------
//return new DbResultSet_DataTableReader(db, query.BuildQuery());
return new Sarand.Win.Dbas.Data.DbResultSet_DataReader(db, query.BuildQuery());
//return new DbResultSet_DataTableReader(Database, query.BuildQuery());
return new Sarand.Win.Dbas.Data.DbResultSet_DataReader(Database, query.BuildQuery());
}
//-------------------------------------------------------------------
@@ -3,6 +3,7 @@ using Sarand.PatientMgr.Core.App;
using Sarand.PatientMgr.Core.Mgr;
using Sarand.PatientMgr.Win.Dbas.Data;
using Sarand.Win.Dbas.Base;
using Sarand.Win.Dbas.Data;
using System;
using System.Collections.Generic;
using System.Text;
@@ -14,20 +15,20 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
{
//-------------------------------------------------------------------
// Data members.
private SacsDatabase db = null;
private readonly SpmDbDataItem.DatabaseInfo dbInfo;
//-------------------------------------------------------------------
// Construction.
public SpmInstitutionMgr_Dbas (SpmUserContext userContext) :
base(userContext)
{
Database = SpmGlobals.Application.GetDatabase(userContext.SessionContext) as SacsDatabase;
DbInfo = new DbDataItem.DatabaseInfo(Database);
}
//-------------------------------------------------------------------
// Properties.
protected ISacsDatabase Database { get { return db; } }
protected SpmDbDataItem.DatabaseInfo DbInfo { get { return dbInfo; } }
protected SacsDatabase Database { get; }
protected DbDataItem.DatabaseInfo DbInfo { get; }
//-------------------------------------------------------------------
// Utilities.
+44
View File
@@ -43,6 +43,12 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Win\Forms\Config\SpmForm_Config.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Win\Forms\Config\SpmForm_Config.Designer.cs">
<DependentUpon>SpmForm_Config.cs</DependentUpon>
</Compile>
<Compile Include="Win\Forms\App\SpmGlobals_Win.cs" />
<Compile Include="Win\Forms\App\SpmSessionProfile_Win.cs" />
<Compile Include="Win\Forms\Base\SpmForm.cs">
@@ -69,6 +75,12 @@
<Compile Include="Win\Forms\Base\SpmTabPage.Designer.cs">
<DependentUpon>SpmTabPage.cs</DependentUpon>
</Compile>
<Compile Include="Win\Forms\Config\SpmPanel_Config_Menu.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Win\Forms\Config\SpmPanel_Config_Menu.Designer.cs">
<DependentUpon>SpmPanel_Config_Menu.cs</DependentUpon>
</Compile>
<Compile Include="Win\Forms\Controls\SpmContextMenuStrip.cs">
<SubType>Component</SubType>
</Compile>
@@ -417,12 +429,24 @@
<Compile Include="Win\Forms\Panels\SpmPanel_Procedures.Designer.cs">
<DependentUpon>SpmPanel_Procedures.cs</DependentUpon>
</Compile>
<Compile Include="Win\Forms\Panels\SpmPanel_UpdateStamp.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Win\Forms\Panels\SpmPanel_UpdateStamp.Designer.cs">
<DependentUpon>SpmPanel_UpdateStamp.cs</DependentUpon>
</Compile>
<Compile Include="Win\Forms\TabPages\SpmTabPage_Admission.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Win\Forms\TabPages\SpmTabPage_Admission.Designer.cs">
<DependentUpon>SpmTabPage_Admission.cs</DependentUpon>
</Compile>
<Compile Include="Win\Forms\TabPages\SpmTabPage_Department.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Win\Forms\TabPages\SpmTabPage_Department.Designer.cs">
<DependentUpon>SpmTabPage_Department.cs</DependentUpon>
</Compile>
<Compile Include="Win\Forms\TabPages\SpmTabPage_Facility.cs">
<SubType>Component</SubType>
</Compile>
@@ -448,6 +472,10 @@
<Name>SacsCoreBase</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\Common-C#\Workspace\SacsWinDbas\SacsWinDbas.csproj">
<Project>{86e11448-66df-4eb6-922f-c84e220608ad}</Project>
<Name>SacsWinDbas</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Common-C#\Workspace\SacsWinForms\SacsWinForms.csproj">
<Project>{18353651-1f1a-4b23-91fb-bdb9aa56bc57}</Project>
<Name>SacsWinForms</Name>
@@ -458,13 +486,26 @@
<Name>SaPatMgrCore</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\SaPatMgrWinDbas\SaPatMgrWinDbas.csproj">
<Project>{9f5d8526-b4b9-457f-8dba-e6b79b938aa9}</Project>
<Name>SaPatMgrWinDbas</Name>
</ProjectReference>
<ProjectReference Include="..\SaPatMgrWinProcs\SaPatMgrWinProcs.csproj">
<Project>{ed6a8e47-67fb-42ca-9b6e-9095c427b64c}</Project>
<Name>SaPatMgrWinProcs</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Win\Forms\Procs\" />
<Folder Include="Win\Forms\Schedule\" />
<Folder Include="Win\Forms\Testing\" />
<Folder Include="Win\Forms\Utils\" />
<Folder Include="Win\Forms\Views\" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Win\Forms\Config\SpmForm_Config.resx">
<DependentUpon>SpmForm_Config.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Win\Forms\Filters\SpmItemListFilter_Patient.resx">
<DependentUpon>SpmItemListFilter_Patient.cs</DependentUpon>
</EmbeddedResource>
@@ -573,6 +614,9 @@
<EmbeddedResource Include="Win\Forms\Panels\SpmPanel_Procedures.resx">
<DependentUpon>SpmPanel_Procedures.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Win\Forms\Panels\SpmPanel_UpdateStamp.resx">
<DependentUpon>SpmPanel_UpdateStamp.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
@@ -1,4 +1,5 @@
using Sarand.PatientMgr.Core.App;
using Sarand.Core.Bus;
using Sarand.PatientMgr.Core.App;
using System;
using System.Collections.Generic;
using System.Text;
@@ -21,6 +22,17 @@ namespace Sarand.PatientMgr.Win.Forms.App
{
}
//-------------------------------------------------------------------
// S e s s i o n P r o p e r t i e s
//-------------------------------------------------------------------
// Schedule filter.
public class FilterData
{
public SysId DepartmentId { get; private set; }
public String Name { get; private set; }
}
public static FilterData Filter { get; } = new FilterData();
//-------------------------------------------------------------------
}
//=======================================================================
@@ -1,4 +1,8 @@
using Sarand.PatientMgr.Core.App;
using Sarand.Core.Base;
using Sarand.Core.Bus;
using Sarand.PatientMgr.Core.App;
using Sarand.PatientMgr.Core.Base;
using Sarand.Win.App;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -8,9 +12,7 @@ using System.Threading.Tasks;
namespace Sarand.PatientMgr.Win.Forms.App
{
//=======================================================================
/// <summary>
/// PatientMgr global properties for desktop/console applications.
/// </summary>
/// <summary>PatientMgr global properties for desktop applications.</summary>
public class SpmSessionProfile_Win : SpmSessionProfile
{
//-------------------------------------------------------------------
@@ -26,19 +28,102 @@ namespace Sarand.PatientMgr.Win.Forms.App
//-------------------------------------------------------------------
// Data members.
private readonly SpmUserContext_Win userContext;
private SpmSessionProperties sessionProperties = new SpmSessionProperties();
private readonly SacsRegistry registryConfig, registryProcess;
// Registry keys.
private static String kpcProfileSectionConfig = "Config";
private static String kpcProfileSectionProcess = "Process";
//private static String kpcProfileSectionWindowPos = "WindowPos";
private static String kpcProfileKeyDeptId = "DepartmentId";
private static String kpcProfileKeyFacilityType = "FacilityType";
private static String kpcProfileKeyFacilityId = "FacilityId";
private static String kpcProfileDisplayFilter = "DisplayFilter";
private static String kpcProfileAdmExportDir = "AdmExportDir";
private static String kpcProfileStatsGenerateDir = "StatsGenerateDir";
//private static String kpcProfileWndPos_Help = "Help";
//private static String kpcProfileWndPos_Config = "Config";
//private static String kpcProfileWndPos_Lists = "Lists";
//-------------------------------------------------------------------
// Construction.
protected SpmSessionProfile_Win (SpmSessionContext sessionContext)
{
userContext = new SpmUserContext_Win(sessionContext);
// Registries.
registryConfig = new SacsRegistry("Sarand", "Sarand Patient Manager", kpcProfileSectionConfig);
registryProcess = new SacsRegistry("Sarand", "Sarand Patient Manager", kpcProfileSectionProcess);
// Filter properties.
Filter.DepartmentId = new SysId(registryConfig.GetIntValue("", kpcProfileKeyDeptId));
Filter.FacilityType = EnumUtil.ParseEnum(registryConfig.GetIntValue("", kpcProfileKeyFacilityType).ToString(), Spm.FacilityType.Unknown);
Filter.FacilityId = new SysId(registryConfig.GetIntValue("", kpcProfileKeyFacilityId));
sessionProperties.DisplayFilter = registryConfig.GetIntValue("", kpcProfileDisplayFilter) > 0 ? true : false;
sessionProperties.AdmissionExportFolder = registryProcess.GetStringValue("", kpcProfileAdmExportDir, "");
sessionProperties.StatisticsExportFolder = registryProcess.GetStringValue("", kpcProfileStatsGenerateDir, "");
}
//-------------------------------------------------------------------
// S t o r e P r o p e r t i e s
//-------------------------------------------------------------------
public void StoreProperties()
{
registryConfig.WriteInt("", kpcProfileKeyDeptId, SysId.ToInt(Filter.DepartmentId));
registryConfig.WriteInt("", kpcProfileKeyFacilityType, (int)Filter.FacilityType);
registryConfig.WriteInt("", kpcProfileKeyFacilityId, SysId.ToInt(Filter.FacilityId));
registryConfig.WriteInt("", kpcProfileDisplayFilter, sessionProperties.DisplayFilter ? 1 : 0);
registryProcess.WriteString("", kpcProfileAdmExportDir, sessionProperties.AdmissionExportFolder);
registryProcess.WriteString("", kpcProfileStatsGenerateDir, sessionProperties.StatisticsExportFolder);
}
//-------------------------------------------------------------------
// S e s s i o n P r o p e r t i e s
//-------------------------------------------------------------------
// User context.
public SpmSessionContext SessionContext { get { return userContext.SessionContext; } }
public SpmUserContext UserContext { get { return userContext; } }
//-------------------------------------------------------------------
// Schdedule display characteristics.
/// <summary>Earliest date to list - 2 year in past.</summary>
public DateTime ScheduleStart { get { return sessionProperties.ScheduleStart; } }
/// <summary>Latest date to list - 2 year in future.</summary>
public DateTime ScheduleEnd { get { return sessionProperties.ScheduleEnd; } }
/// <summary>Show filter.</summary>
public bool DisplayFilter { get { return sessionProperties.DisplayFilter; } set { sessionProperties.DisplayFilter = value; } }
//-------------------------------------------------------------------
/// <summary>Admission display text height (standard, medium, large)</summary>
public int GetTextHeight (Spm.DisplayFont displayFont)
{
return sessionProperties.GetTextHeight(displayFont);
}
public void SetTextHeight (Spm.DisplayFont displayFont, int textHeight)
{
sessionProperties.SetTextHeight(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 sessionProperties.GetDisplayBoundary(displayBoundary);
}
public void SetDisplayBoundary (Spm.DisplayBoundary displayBoundary, int boundary)
{
sessionProperties.SetDisplayBoundary(displayBoundary, boundary);
}
//-------------------------------------------------------------------
// Schedule filter.
public SpmSessionProperties.FilterData Filter { get { return sessionProperties.Filter; } }
//-------------------------------------------------------------------
// Data folders.
public String AdmissionExportFolder { get { return sessionProperties.AdmissionExportFolder; } set { sessionProperties.AdmissionExportFolder = value; } }
public String StatisticsExportFolder { get { return sessionProperties.StatisticsExportFolder; } set { sessionProperties.StatisticsExportFolder = value; } }
//-------------------------------------------------------------------
}
//=======================================================================
+28 -20
View File
@@ -26,26 +26,29 @@ namespace Sarand.PatientMgr.Win.Forms.Base
[Browsable(false)]
public new class Config : SacsForm.Config
{
/// <summary>Pass Internals via Config to share cached data.</summary>
public SpmInternals Internals { get; set; } = null;
}
//-------------------------------------------------------------------
// Data members.
private readonly Config config;
private readonly SpmInternals internals;
private SpmInternals internals = null;
//-------------------------------------------------------------------
// Construction.
private SpmForm() : this(new Config()) { }
protected SpmForm(Config config) : base(config)
private SpmForm () : this(new Config()) { }
protected SpmForm (Config config) : base(config)
{
this.config = config;
InitializeComponent();
}
protected override void Dispose(bool disposing)
protected override void Dispose (bool disposing)
{
if (disposing && (components != null))
if (disposing)
{
components.Dispose();
if (components != null) components.Dispose();
if (internals != null) internals.Dispose();
}
base.Dispose(disposing);
}
@@ -55,23 +58,28 @@ namespace Sarand.PatientMgr.Win.Forms.Base
// Session.
protected SpmSessionProfile_Win SessionProfile { get; } = SpmGlobals_Win.SessionProfile;
protected SpmUserContext UserContext { get { return (SessionProfile != null ? SessionProfile.UserContext : null); } }
protected SpmSessionContext SessionContext { get { return (UserContext != null ? UserContext.SessionContext : null); } }
public SpmUserContext UserContext { get { return (SessionProfile != null ? SessionProfile.UserContext : null); } }
public SpmSessionContext SessionContext { get { return (UserContext != null ? UserContext.SessionContext : null); } }
protected SpmInternals Internals
{
get
{
if (config.Internals != null) return config.Internals;
if (internals == null) internals = new SpmInternals(UserContext);
return internals;
}
}
// Security.
protected SpmSecurityProfile SecurityProfile { get { return internals.SecurityProfile; } }
public SpmSecurityProfile SecurityProfile { get { return Internals.SecurityProfile; } }
// Managers.
protected SpmAdmissionMgr AdmissionMgr { get { return internals.AdmissionMgr; } }
protected SpmDepartmentMgr DepartmentMgr { get { return internals.DepartmentMgr; } }
protected SpmInstitutionMgr InstitutionMgr { get { return internals.InstitutionMgr; } }
public SpmInstitutionMgr InstitutionMgr { get { return Internals.InstitutionMgr; } }
public SpmDepartmentMgr DepartmentMgr { get { return Internals.DepartmentMgr; } }
public SpmAdmissionMgr AdmissionMgr { get { return Internals.AdmissionMgr; } }
// Consoles.
protected SaSecurityConsole SecurityConsole { get { return internals.SecurityConsole; } }
protected SaCodeTypeConsole CodeTypeConsole { get { return internals.CodeTypeConsole; } }
protected SaUpdateLogConsole UpdateLogConsole { get { return internals.UpdateLogConsole; } }
protected SaItemOptionConsole ItemOptionConsole { get { return internals.ItemOptionConsole; } }
public SaSecurityConsole SecurityConsole { get { return Internals.SecurityConsole; } }
public SaCodeTypeConsole CodeTypeConsole { get { return Internals.CodeTypeConsole; } }
public SaUpdateLogConsole UpdateLogConsole { get { return Internals.UpdateLogConsole; } }
public SaItemOptionConsole ItemOptionConsole { get { return Internals.ItemOptionConsole; } }
//-------------------------------------------------------------------
}
+20 -14
View File
@@ -26,12 +26,14 @@ namespace Sarand.PatientMgr.Win.Forms.Base
// Configuration.
public new class Config : SacsPanel.Config
{
/// <summary>Pass Internals via Config to share cached data.</summary>
public SpmInternals Internals { get; set; } = null;
}
//-------------------------------------------------------------------
// Data members.
private Config config = new Config();
private readonly SpmInternals internals;
private SpmInternals internals = null;
//-------------------------------------------------------------------
// Construction.
@@ -40,7 +42,6 @@ namespace Sarand.PatientMgr.Win.Forms.Base
{
SetConfig(config);
InitializeComponent();
internals = new SpmInternals(SessionProfile != null ? SessionProfile.UserContext : null);
}
protected override void Dispose(bool disposing)
{
@@ -60,21 +61,26 @@ namespace Sarand.PatientMgr.Win.Forms.Base
protected SpmUserContext UserContext { get { return (SessionProfile != null ? SessionProfile.UserContext : null); } }
protected SpmSessionContext SessionContext { get { return (UserContext != null ? UserContext.SessionContext : null); } }
protected DbUpdateInfo DbUpdateInfo { get { return internals.DbUpdateInfo; } }
protected SpmInternals Internals
{
get
{
if (config.Internals != null) return config.Internals;
if (internals == null) internals = new SpmInternals(UserContext);
return internals;
}
}
// Security.
protected SpmSecurityProfile SecurityProfile { get { return internals.SecurityProfile; } }
public SpmSecurityProfile SecurityProfile { get { return Internals.SecurityProfile; } }
// Managers.
protected SpmAdmissionMgr AdmissionMgr { get { return internals.AdmissionMgr; } }
protected SpmDepartmentMgr DepartmentMgr { get { return internals.DepartmentMgr; } }
protected SpmInstitutionMgr InstitutionMgr { get { return internals.InstitutionMgr; } }
public SpmInstitutionMgr InstitutionMgr { get { return Internals.InstitutionMgr; } }
public SpmDepartmentMgr DepartmentMgr { get { return Internals.DepartmentMgr; } }
public SpmAdmissionMgr AdmissionMgr { get { return Internals.AdmissionMgr; } }
// Consoles.
protected SaSecurityConsole SecurityConsole { get { return internals.SecurityConsole; } }
protected SaCodeTypeConsole CodeTypeConsole { get { return internals.CodeTypeConsole; } }
protected SaUpdateLogConsole UpdateLogConsole { get { return internals.UpdateLogConsole; } }
protected SaItemOptionConsole ItemOptionConsole { get { return internals.ItemOptionConsole; } }
public SaSecurityConsole SecurityConsole { get { return Internals.SecurityConsole; } }
public SaCodeTypeConsole CodeTypeConsole { get { return Internals.CodeTypeConsole; } }
public SaUpdateLogConsole UpdateLogConsole { get { return Internals.UpdateLogConsole; } }
public SaItemOptionConsole ItemOptionConsole { get { return Internals.ItemOptionConsole; } }
//-------------------------------------------------------------------
// Configure.
+20 -13
View File
@@ -32,12 +32,14 @@ namespace Sarand.PatientMgr.Win.Forms.Base
public virtual bool WrapSinglePanelInGroupBox { get; protected set; } = false;
/// <summary>Wrap multiple panels on tab page in group boxes. Default - multiple panels are wrapped in group boxes.</summary>
public virtual bool WrapMultiplePanelsInGroupBoxes { get; protected set; } = true;
/// <summary>Pass Internals via Config to share cached data.</summary>
public SpmInternals Internals { get; set; } = null;
}
//-------------------------------------------------------------------
// Data members.
private Config config = new Config();
private readonly SpmInternals internals;
private SpmInternals internals = null;
//-------------------------------------------------------------------
// Construction.
@@ -46,7 +48,6 @@ namespace Sarand.PatientMgr.Win.Forms.Base
{
this.config = config;
InitializeComponent();
internals = new SpmInternals(SessionProfile != null ? SessionProfile.UserContext : null);
}
protected override void Dispose(bool disposing)
{
@@ -67,20 +68,26 @@ namespace Sarand.PatientMgr.Win.Forms.Base
protected SpmSessionProfile_Win SessionProfile { get; } = SpmGlobals_Win.SessionProfile;
protected SpmUserContext UserContext { get { return SessionProfile.UserContext; } }
protected SpmSessionContext SessionContext { get { return SessionProfile.SessionContext; } }
protected SpmInternals Internals
{
get
{
if (config.Internals != null) return config.Internals;
if (internals == null) internals = new SpmInternals(UserContext);
return internals;
}
}
// Security.
protected SpmSecurityProfile SecurityProfile { get { return internals.SecurityProfile; } }
public SpmSecurityProfile SecurityProfile { get { return Internals.SecurityProfile; } }
// Managers.
protected SpmAdmissionMgr AdmissionMgr { get { return internals.AdmissionMgr; } }
protected SpmDepartmentMgr DepartmentMgr { get { return internals.DepartmentMgr; } }
protected SpmInstitutionMgr InstitutionMgr { get { return internals.InstitutionMgr; } }
public SpmInstitutionMgr InstitutionMgr { get { return Internals.InstitutionMgr; } }
public SpmDepartmentMgr DepartmentMgr { get { return Internals.DepartmentMgr; } }
public SpmAdmissionMgr AdmissionMgr { get { return Internals.AdmissionMgr; } }
// Consoles.
protected SaSecurityConsole SecurityConsole { get { return internals.SecurityConsole; } }
protected SaCodeTypeConsole CodeTypeConsole { get { return internals.CodeTypeConsole; } }
protected SaUpdateLogConsole UpdateLogConsole { get { return internals.UpdateLogConsole; } }
protected SaItemOptionConsole ItemOptionConsole { get { return internals.ItemOptionConsole; } }
public SaSecurityConsole SecurityConsole { get { return Internals.SecurityConsole; } }
public SaCodeTypeConsole CodeTypeConsole { get { return Internals.CodeTypeConsole; } }
public SaUpdateLogConsole UpdateLogConsole { get { return Internals.UpdateLogConsole; } }
public SaItemOptionConsole ItemOptionConsole { get { return Internals.ItemOptionConsole; } }
//-------------------------------------------------------------------
// I n i t i a l i s a t i o n
@@ -0,0 +1,53 @@
namespace Sarand.PatientMgr.Win.Forms.Config
{
partial class SpmForm_Config
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent ()
{
this.splitContainer = new System.Windows.Forms.SplitContainer();
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
this.splitContainer.SuspendLayout();
this.SuspendLayout();
//
// splitContainer
//
this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer.Location = new System.Drawing.Point(0, 0);
this.splitContainer.Name = "splitContainer";
this.splitContainer.Size = new System.Drawing.Size(747, 493);
this.splitContainer.SplitterDistance = 179;
this.splitContainer.TabIndex = 0;
//
// SpmForm_Config
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(747, 493);
this.Controls.Add(this.splitContainer);
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(720, 480);
this.Name = "SpmForm_Config";
this.ShowIcon = false;
this.Text = "Sarand Patient Manager - Configuration";
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
this.splitContainer.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.SplitContainer splitContainer;
}
}
@@ -0,0 +1,204 @@
using Sarand.PatientMgr.Win.Forms.Base;
using Sarand.PatientMgr.Win.Forms.Panels;
using Sarand.Win.Forms.Utils;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Sarand.PatientMgr.Win.Forms.Config
{
//=======================================================================
public partial class SpmForm_Config : SpmForm
{
//-------------------------------------------------------------------
// Configuration.
public new class Config : SpmForm.Config
{
}
//-------------------------------------------------------------------
// Definitions.
public enum ConfigPanelType
{
Unknown = 0,
Departments,
Operations,
Employees,
Patients,
Procedures,
EmployeeRoles,
FacilityTemplates
}
//-------------------------------------------------------------------
// Data members.
private Config config = null;
private SpmPanel_Config_Menu panelMenu = null;
private ConfigPanelType panelType = ConfigPanelType.Unknown;
//-------------------------------------------------------------------
// Construction.
private SpmForm_Config () : this(new Config()) { }
public SpmForm_Config (Config config) : base(config)
{
InitializeComponent();
}
protected override void Dispose (bool disposing)
{
if (disposing)
{
if (components != null) components.Dispose();
if (panelMenu != null) panelMenu.Dispose();
}
base.Dispose(disposing);
}
//-------------------------------------------------------------------
// Properties.
[Browsable(false), ReadOnly(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public ConfigPanelType PanelType
{
get { return panelType; }
set
{
SwitchPanel(value);
}
}
private void SwitchPanel (ConfigPanelType panelType)
{
if (this.panelType == panelType) return;
SpmPanel panel = null;
switch (panelType)
{
case ConfigPanelType.Departments:
{
SpmPanel_Departments.Config panelConfig = new SpmPanel_Departments.Config(SpmPanel_Departments.PanelMode.Maintain);
panel = new SpmPanel_Departments(panelConfig);
break;
}
case ConfigPanelType.FacilityTemplates:
{
SpmPanel_FacilityTemplates.Config panelConfig = new SpmPanel_FacilityTemplates.Config();
panelConfig.Mode = SpmPanel_FacilityTemplates.PanelMode.Maintain;
panel = new SpmPanel_FacilityTemplates(panelConfig);
break;
}
case ConfigPanelType.Operations:
{
/* ToDo Operations panel
SpmPanel_Operations.Config panelConfig = new SpmPanel_Operations.Config();
panelConfig.Mode = SpmPanel_Operations.PanelMode.Maintain;
panel = new SpmPanel_Operations(panelConfig);
*/
break;
}
case ConfigPanelType.Procedures:
{
SpmPanel_Procedures.Config panelConfig = new SpmPanel_Procedures.Config();
panelConfig.Mode = SpmPanel_Procedures.PanelMode.Maintain;
panel = new SpmPanel_Procedures(panelConfig);
break;
}
case ConfigPanelType.Patients:
{
/* ToDo Patients panel
SpmPanel_Patients.Config panelConfig = new SpmPanel_Patients.Config();
panelConfig.Mode = SpmPanel_Patients.PanelMode.Maintain;
panel = new SpmPanel_Patients(panelConfig);
*/
break;
}
case ConfigPanelType.Employees:
{
/* ToDo Employees panel
SpmPanel_Employees.Config panelConfig = new SpmPanel_Employees.Config();
panelConfig.Mode = SpmPanel_Employees.PanelMode.Maintain;
panel = new SpmPanel_Employees(panelConfig);
*/
break;
}
case ConfigPanelType.EmployeeRoles:
{
SpmPanel_EmployeeRoles.Config panelConfig = new SpmPanel_EmployeeRoles.Config();
panelConfig.Mode = SpmPanel_EmployeeRoles.PanelMode.Maintain;
panel = new SpmPanel_EmployeeRoles(panelConfig);
break;
}
}
if (panel == null) return;
// Clear existing view.
while (splitContainer.Panel2.Controls.Count > 0)
{
Control control = splitContainer.Panel2.Controls[0];
splitContainer.Panel2.Controls.RemoveAt(0);
control.Dispose();
}
// Add new view.
splitContainer.Panel2.Controls.Add(panel);
panel.Dock = DockStyle.Fill;
this.panelType = panelType;
}
//-------------------------------------------------------------------
// I n i t i a l i s a t i o n
//-------------------------------------------------------------------
protected override void OnCreateControl ()
{
base.OnCreateControl();
if (this.IsDesignerHosted()) return;
// Spliter.
splitContainer.SplitterDistance = 200;
splitContainer.FixedPanel = FixedPanel.Panel1;
splitContainer.IsSplitterFixed = true;
// Menu panel.
SpmPanel_Config_Menu.Config menuConfig = new SpmPanel_Config_Menu.Config();
menuConfig.ConfigForm = this;
panelMenu = new SpmPanel_Config_Menu(menuConfig);
splitContainer.Panel1.Controls.Add(panelMenu);
panelMenu.Dock = DockStyle.Fill;
panelMenu.RefreshPanel();
SetControlActivity();
}
protected override void OnShown (EventArgs e)
{
base.OnShown(e);
}
//-------------------------------------------------------------------
// C o n t r o l A c t i v i t y
//-------------------------------------------------------------------
protected override void SetControlActivity ()
{
SetControlsReadOnly();
}
protected override void SetControlsReadOnly ()
{
}
//-------------------------------------------------------------------
// F o r m A c t i o n s
//-------------------------------------------------------------------
public void RefreshView()
{
}
//-------------------------------------------------------------------
// F o r m E v e n t s
//-------------------------------------------------------------------
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,23 @@
namespace Sarand.PatientMgr.Win.Forms.Config
{
partial class SpmPanel_Config_Menu
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent ()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}
@@ -0,0 +1,311 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Sarand.Win.Forms.Controls;
using Sarand.Win.Forms.Utils;
using Sarand.Core.Base;
using Sarand.Core.App;
using Sarand.PatientMgr.Core.Bus;
using Sarand.PatientMgr.Core.App;
using Sarand.PatientMgr.Win.Forms.Base;
using Sarand.Core.Dbas.Base;
using Sarand.Core.Security;
using Sarand.PatientMgr.Win.Forms.App;
namespace Sarand.PatientMgr.Win.Forms.Config
{
//=======================================================================
public partial class SpmPanel_Config_Menu : SacsHtmlPanel
{
//-------------------------------------------------------------------
// Configuration.
public new class Config : SacsHtmlPanel.Config
{
public SpmForm_Config ConfigForm { get; set; }
public SpmForm AdmissionListForm { get; set; }
}
//-------------------------------------------------------------------
// Data members.
private Config config = null;
private bool appCmdInProgress = false;
private static String AppCmd_AdmClose = "AdmClose";
private static String AppCmd_AdmRefresh = "AdmRefresh";
private static String AppCmd_AdmSecurity = "AdmSecurity";
private static String AppCmd_AdmCodeTypes = "AdmCodeTypes";
private static String AppCmd_AdmExport = "AdmExport";
private static String AppCmd_AdmStatistics = "AdmStatistics";
private static String AppCmd_AdmDatabase = "AdmDatabase";
private static String AppCmd_Departments = "Departments";
private static String AppCmd_Operations = "Operations";
private static String AppCmd_Employees = "Employees";
private static String AppCmd_Patients = "Patients";
private static String AppCmd_Procedures = "Procedures";
private static String AppCmd_EmployeeRoles = "EmployeeRoles";
private static String AppCmd_FacilityTemplates = "FacilityTemplates";
private static String AppCmd_PatientSearch = "PatientSearch";
private static String AppCmd_WaitingList = "WaitingList";
private static String AppCmd_RequiredActions = "RequiredActions";
private static String AppCmd_CancelTimeLimit = "CancelTimeLimit";
private static String AppCmd_CancelOther = "CancelOther";
private static String AppCmd_Deletions = "Deletions";
//-------------------------------------------------------------------
// Construction.
private SpmPanel_Config_Menu () : this(new Config()) { }
public SpmPanel_Config_Menu (Config config) : base(config)
{
this.config = config;
InitializeComponent();
}
protected override void Dispose (bool disposing)
{
if (disposing)
{
if (components != null) components.Dispose();
}
base.Dispose(disposing);
}
//-------------------------------------------------------------------
// Properties.
public bool HasActiveProcess { get { return appCmdInProgress; } }
//-------------------------------------------------------------------
// I n i t i a l i s a t i o n
//-------------------------------------------------------------------
protected override void OnCreateControl ()
{
base.OnCreateControl();
if (this.IsDesignerHosted()) return;
}
//-------------------------------------------------------------------
// R e f r e s h P a n e l
//-------------------------------------------------------------------
public void RefreshPanel ()
{
List<String> body = new List<string>();
body.Add("<div class='Title'>Sarand<br/>Patient&nbsp;Manager</div>");
// Institution.
SpmInstitution institution = config.ConfigForm.InstitutionMgr.GetInstitution();
if (institution != null)
{
body.Add("<div class='Caption'>Institution</div>");
body.Add("<div class='Institution'>" + institution.Name + "</div>");
institution.Dispose(); institution = null;
}
if (config.ConfigForm != null)
{
// Configuration options:
body.Add("<div class='Caption'>Configuration</div>");
body.Add(BuildMenuOpt(AppCmd_Departments, "Departments"));
body.Add(BuildMenuOpt(AppCmd_FacilityTemplates, "Session templates"));
body.Add(BuildMenuOpt(AppCmd_Operations, "Operations"));
body.Add(BuildMenuOpt(AppCmd_Procedures, "Procedures"));
body.Add(BuildMenuOpt(AppCmd_Patients, "Patients"));
body.Add(BuildMenuOpt(AppCmd_Employees, "Employees"));
body.Add(BuildMenuOpt(AppCmd_EmployeeRoles, "Employee roles"));
// Application options.
body.Add("<div class='Caption'>Application</div>");
body.Add(BuildMenuOpt(AppCmd_AdmRefresh, "Refresh", false));
if (config.ConfigForm.SecurityProfile.Admin.CanManageSecurity())
body.Add(BuildMenuOpt(AppCmd_AdmSecurity, "Security", false));
body.Add(BuildMenuOpt(AppCmd_AdmExport, "Export", false));
body.Add(BuildMenuOpt(AppCmd_AdmStatistics, "Statistics", false));
if (config.ConfigForm.SecurityProfile.Admin.CanManageDatabase())
{
ISacsDatabase database = SpmGlobals.Application.GetDatabase(config.ConfigForm.SessionContext);
if (database != null && database.DbmsType == DbmsType.Access)
body.Add(BuildMenuOpt(AppCmd_AdmDatabase, "Db housekeeping", false));
}
if (config.ConfigForm.SecurityProfile.Admin.CanManageConfig() && config.ConfigForm.CodeTypeConsole != null)
body.Add(BuildMenuOpt(AppCmd_AdmCodeTypes, "Codes", false));
}
else if (config.AdmissionListForm != null)
{
// Admission Lists options.
body.Add("<div class='Caption'>Admission Lists</div>");
body.Add(BuildMenuOpt(AppCmd_PatientSearch, "Patient Search"));
body.Add(BuildMenuOpt(AppCmd_WaitingList, "Waiting List"));
body.Add(BuildMenuOpt(AppCmd_RequiredActions, "Required Actions"));
body.Add(BuildMenuOpt(AppCmd_CancelTimeLimit, "Cancellations - 28 day"));
body.Add(BuildMenuOpt(AppCmd_CancelOther, "Cancellations - other"));
body.Add(BuildMenuOpt(AppCmd_Deletions, "Deletions"));
// Action options:
body.Add("<div class='Caption'>Actions</div>");
foreach (SacsCommand item in new List<SacsCommand>()) //config.AdmissionListForm.GetMenuItems())
body.Add(BuildMenuOpt(item.CommandId, item.Caption, false));
}
body.Add(BuildMenuOpt(AppCmd_AdmClose, "Close", false));
if (DocumentPopulated)
{
SetDocumentBody(body.Concat("\n"));
}
else
{
List<String> html = new List<string>();
html.Add("<html><head>" + GetMenuStyle() + GetMenuScript() + "</head><body>");
html.AddRange(body);
html.Add("</body></html>");
SetDocumentHtml(html.Concat("\n"));
DocumentPopulated = true;
}
}
private String BuildMenuOpt (String command, String display, bool panelOption = true)
{
// Is this the currently selected option:
bool currentOption = false;
if (panelOption)
{
if (config.ConfigForm != null) currentOption = GetConfigPanelType(command) == config.ConfigForm.PanelType;
else if (config.AdmissionListForm != null) currentOption = false; // GetAdmissionsPanelType(command) == config.AdmissionListForm.PanelType;
}
// Build the menu option:
String option = "";
option += currentOption ? "<b>" : "<a class='Mnu' href='" + AppHrefPrefix + command + "'>";
option += display;
option += currentOption ? "</b>" : "</a>";
option += "<br>";
return option;
}
private String GetMenuStyle ()
{
List<String> style = new List<string>();
style.Add("<style>" + SacsResourceConsole.GetTextResource(SacsResourceConsole.TextResource.SaBaseCss) + "</style>");
style.Add("<style>");
style.Add("*{font-size:14px;font-family:'sans-serif';color:#303080;background-color:#A0D0A0;scrollbar-base-color:#A0D0A0;}");
style.Add("body{padding:4;margin:0;background-color:#A0D0A0;overflow-y:auto;}");
style.Add("p{font-size:14px;margin-top:15px;margin-bottom:5px;}");
style.Add("td{font-size:14px;vertical-align:top;}");
style.Add(".Title{margin:4px 0;padding-left:32px;font-weight:bold;font-size:20px;background-image:url('" + GetImageUri(SpmResourceConsole.GetImageResource(SpmResourceConsole.ImageResource.PatientMgr_Icon_gif), "png") + "');background-position:left top;background-repeat:no-repeat;}");
style.Add(".Caption{margin-top:5px;margin-bottom:5px;padding:3px;font-size:16px;font-weight:bold;text-align:center;color:#E0E0FF;background-color:#6060E0;}");
style.Add(".Institution{margin-top:2px;margin-bottom:2px;font-weight:bold;font-size:14px;text-align:center;}");
style.Add(".SuperScript{font-size:66%;position:relative;top:-5px;}");
style.Add(".Body{text-align:left;padding-left:5%;}");
style.Add("A:link,A:visited,A:active{line-height:150%;font-weight:normal;text-decoration:none;padding:3px;}");
style.Add("A.Mnu:link,A.Mnu:visited,A.Mnu:active{font-size:13px;text-align:center;}");
style.Add("A:hover,A.Mnu:hover{font-weight:bold;padding-left:0px;padding-right:0px;}");
style.Add("</style>");
return style.Concat("\n");
}
private String GetMenuScript ()
{
List<String> script = new List<string>();
return script.Concat("\n");
}
//-------------------------------------------------------------------
// P a n e l E v e n t s
//-------------------------------------------------------------------
protected override void OnAppAction (string action)
{
Logger.Debug("OnAppAction Action: " + action);
bool optionProcessed = false;
if (action.EqualsCI(AppCmd_AdmClose))
{
if (config.ConfigForm != null) config.ConfigForm.Close();
else if (config.AdmissionListForm != null) config.AdmissionListForm.Close();
optionProcessed = true;
}
else if (action.EqualsCI(AppCmd_AdmRefresh))
{
if (config.ConfigForm != null) config.ConfigForm.RefreshView();
//else if (config.AdmissionListForm != null) config.AdmissionListForm.RefreshView();
optionProcessed = true;
}
else if (action.EqualsCI(AppCmd_AdmSecurity))
{
SaSecurityConsole securityConsole = config.ConfigForm?.SecurityConsole ?? config.AdmissionListForm?.SecurityConsole ?? null;
SpmSecurityProfile securityProfile = config.ConfigForm?.SecurityProfile ?? config.AdmissionListForm?.SecurityProfile ?? null;
if (securityConsole == null || securityProfile == null) return;
securityConsole.ManageSecurity(securityProfile.Admin.CanManageSecurity(), SpmGlobals_Win.UserContext.DbUpdateInfo);
optionProcessed = true;
}
else if (action.EqualsCI(AppCmd_AdmCodeTypes))
{
// ToDo Code Types options.
optionProcessed = true;
}
else if (action.EqualsCI(AppCmd_AdmExport))
{
// ToDo Export options.
optionProcessed = true;
}
else if (action.EqualsCI(AppCmd_AdmStatistics))
{
// ToDo Export options.
optionProcessed = true;
}
else if (action.EqualsCI(AppCmd_AdmDatabase))
{
// No longer required - database now SQL rather than Access.
// Unless SQL database housekeeping could be invoked.
optionProcessed = true;
}
else if (config.ConfigForm != null)
{
// Flag to avoid other commands during length processing:
appCmdInProgress = true;
SpmForm_Config.ConfigPanelType panelType = GetConfigPanelType (action);
if (panelType != SpmForm_Config.ConfigPanelType.Unknown)
{
config.ConfigForm.PanelType = panelType;
RefreshPanel();
}
optionProcessed = true;
}
else if (config.AdmissionListForm != null)
{
// Flag to avoid other commands during length processing (eg. multiple deletions):
appCmdInProgress = true;
// ToDo Admission List actions.
/*
SwmDlgAdmissionLists::eSwmAdmissionsPanel ePanel = SwmPanelMenu::PanelForAdmissionsCmd (sCmd);
if (ePanel != SwmDlgAdmissionLists::ePanelUnknown)
{
pDlgAdmLists->SetAdmissionsPanel(ePanel);
Refresh();
optionProcessed = true;
}
else
{
bOptionProcessed = pDlgAdmLists->DoMenuOption(String(sCmd).AsLong());
SetFocus();
}
*/
optionProcessed = true;
}
appCmdInProgress = false;
//base.OnAppAction(action);
}
private SpmForm_Config.ConfigPanelType GetConfigPanelType (String command)
{
if (config.ConfigForm == null) return SpmForm_Config.ConfigPanelType.Unknown;
if (command.EqualsCI(AppCmd_Departments)) return SpmForm_Config.ConfigPanelType.Departments;
if (command.EqualsCI(AppCmd_Operations)) return SpmForm_Config.ConfigPanelType.Operations;
if (command.EqualsCI(AppCmd_Employees)) return SpmForm_Config.ConfigPanelType.Employees;
if (command.EqualsCI(AppCmd_Patients)) return SpmForm_Config.ConfigPanelType.Patients;
if (command.EqualsCI(AppCmd_Procedures)) return SpmForm_Config.ConfigPanelType.Procedures;
if (command.EqualsCI(AppCmd_EmployeeRoles)) return SpmForm_Config.ConfigPanelType.EmployeeRoles;
if (command.EqualsCI(AppCmd_FacilityTemplates)) return SpmForm_Config.ConfigPanelType.FacilityTemplates;
return SpmForm_Config.ConfigPanelType.Unknown;
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -14,6 +14,8 @@ using Sarand.Core.Security;
using Sarand.Core.CodeTypes;
using Sarand.Core.UpdateLog;
using Sarand.Core.ItemOptions;
using System.Windows.Forms;
using Sarand.Core.Dbas.Base;
namespace Sarand.PatientMgr.Win.Forms.Controls
{
@@ -24,12 +26,14 @@ namespace Sarand.PatientMgr.Win.Forms.Controls
// Configuration.
public class Config
{
/// <summary>Pass Internals via Config to share cached data.</summary>
public SpmInternals Internals { get; set; } = null;
}
//-------------------------------------------------------------------
// Data members.
private Config config = new Config();
private readonly SpmInternals internals;
private SpmInternals internals = null;
//-------------------------------------------------------------------
// Construction.
@@ -38,7 +42,6 @@ namespace Sarand.PatientMgr.Win.Forms.Controls
{
this.config = config;
InitializeComponent();
internals = new SpmInternals(SessionProfile != null ? SessionProfile.UserContext : null);
}
protected override void Dispose(bool disposing)
{
@@ -60,26 +63,30 @@ namespace Sarand.PatientMgr.Win.Forms.Controls
/// <summary>Total number of items to be displayed (not items already in the list).</summary>
[Browsable(false), ReadOnly(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public virtual int ItemTotal { get; protected set; } = 0;
// Session.
protected SpmSessionProfile_Win SessionProfile { get; } = SpmGlobals_Win.SessionProfile;
protected SpmUserContext UserContext { get { return (SessionProfile != null ? SessionProfile.UserContext : null); } }
protected SpmSessionContext SessionContext { get { return (UserContext != null ? UserContext.SessionContext : null); } }
protected SpmInternals Internals
{
get
{
if (config.Internals != null) return config.Internals;
if (internals == null) internals = new SpmInternals(UserContext);
return internals;
}
}
// Security.
protected SpmSecurityProfile SecurityProfile { get { return internals.SecurityProfile; } }
public SpmSecurityProfile SecurityProfile { get { return Internals.SecurityProfile; } }
// Managers.
protected SpmAdmissionMgr AdmissionMgr { get { return internals.AdmissionMgr; } }
protected SpmDepartmentMgr DepartmentMgr { get { return internals.DepartmentMgr; } }
protected SpmInstitutionMgr InstitutionMgr { get { return internals.InstitutionMgr; } }
public SpmInstitutionMgr InstitutionMgr { get { return Internals.InstitutionMgr; } }
public SpmDepartmentMgr DepartmentMgr { get { return Internals.DepartmentMgr; } }
public SpmAdmissionMgr AdmissionMgr { get { return Internals.AdmissionMgr; } }
// Consoles.
protected SaSecurityConsole SecurityConsole { get { return internals.SecurityConsole; } }
protected SaCodeTypeConsole CodeTypeConsole { get { return internals.CodeTypeConsole; } }
protected SaUpdateLogConsole UpdateLogConsole { get { return internals.UpdateLogConsole; } }
protected SaItemOptionConsole ItemOptionConsole { get { return internals.ItemOptionConsole; } }
public SaSecurityConsole SecurityConsole { get { return Internals.SecurityConsole; } }
public SaCodeTypeConsole CodeTypeConsole { get { return Internals.CodeTypeConsole; } }
public SaUpdateLogConsole UpdateLogConsole { get { return Internals.UpdateLogConsole; } }
public SaItemOptionConsole ItemOptionConsole { get { return Internals.ItemOptionConsole; } }
//-------------------------------------------------------------------
// Configure.
@@ -94,6 +101,34 @@ namespace Sarand.PatientMgr.Win.Forms.Controls
{
base.OnCreateControl();
if (this.IsDesignerHosted()) return;
// List View configuration.
View = View.Details;
FullRowSelect = true;
HideSelection = false;
MultiSelect = false;
}
//-------------------------------------------------------------------
protected override void OnHandleDestroyed (EventArgs e)
{
//CancelListRefresh();
Clear();
base.OnHandleDestroyed(e);
}
//-------------------------------------------------------------------
// R e f r e s h L i s t
//-------------------------------------------------------------------
/// <summary>Close and dispose the result set, if not null.</summary>
protected void ClearResultSet (ref DbResultSet dbResultSet)
{
if (dbResultSet == null) return;
// Copy the ResultSet reference so that the original can be nulled before closing/disposing.
DbResultSet dbResultSet_Local = dbResultSet;
dbResultSet = null;
dbResultSet_Local.Close();
dbResultSet_Local.Dispose();
}
//-------------------------------------------------------------------
@@ -60,8 +60,8 @@ namespace Sarand.PatientMgr.Win.Forms.Controls
if (disposing)
{
if (components != null) components.Dispose();
timerQueryData.Dispose();
timerDisplayItem.Dispose();
if (timerQueryData != null) timerQueryData.Dispose();
if (timerDisplayItem != null) timerDisplayItem.Dispose();
ClearResultSet();
}
base.Dispose(disposing);
@@ -56,8 +56,8 @@ namespace Sarand.PatientMgr.Win.Forms.Controls
if (disposing)
{
if (components != null) components.Dispose();
timerQueryData.Dispose();
timerDisplayItem.Dispose();
if (timerQueryData != null) timerQueryData.Dispose();
if (timerDisplayItem != null) timerDisplayItem.Dispose();
ClearResultSet();
}
base.Dispose(disposing);
@@ -56,8 +56,8 @@ namespace Sarand.PatientMgr.Win.Forms.Controls
if (disposing)
{
if (components != null) components.Dispose();
timerQueryData.Dispose();
timerDisplayItem.Dispose();
if (timerQueryData != null) timerQueryData.Dispose();
if (timerDisplayItem != null) timerDisplayItem.Dispose();
ClearResultSet();
}
base.Dispose(disposing);
@@ -56,8 +56,8 @@ namespace Sarand.PatientMgr.Win.Forms.Controls
if (disposing)
{
if (components != null) components.Dispose();
timerQueryData.Dispose();
timerDisplayItem.Dispose();
if (timerQueryData != null) timerQueryData.Dispose();
if (timerDisplayItem != null) timerDisplayItem.Dispose();
ClearResultSet();
}
base.Dispose(disposing);
@@ -1,6 +1,7 @@
using Sarand.Core.Base;
using Sarand.Core.Bus;
using Sarand.Core.Dbas.Base;
using Sarand.PatientMgr.Core.App;
using Sarand.PatientMgr.Core.Bus;
using Sarand.Win.Forms.Controls;
using Sarand.Win.Forms.Utils;
@@ -47,21 +48,24 @@ namespace Sarand.PatientMgr.Win.Forms.Controls
public SpmItemListView_Department(Config config) : base(config)
{
this.config = config;
if (SpmGlobals.System != null)
{
columnDfnId = DepartmentMgr.GetDepartmentColumnDfn(SpmDepartment.Column.Id);
}
InitializeComponent();
/* ToDo Timers function need modifying.
timerQueryData = new Timer() { Interval = 250 };
timerQueryData.Tick += OnTimerQueryData;
timerDisplayItem = new Timer() { Interval = 5 };
timerDisplayItem.Tick += OnTimerDisplayItem;*/
timerDisplayItem.Tick += OnTimerDisplayItem;
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null) components.Dispose();
timerQueryData.Dispose();
timerDisplayItem.Dispose();
if (timerQueryData != null) timerQueryData.Dispose();
if (timerDisplayItem != null) timerDisplayItem.Dispose();
ClearResultSet();
}
base.Dispose(disposing);
@@ -114,7 +118,6 @@ namespace Sarand.PatientMgr.Win.Forms.Controls
InitDepartmentList(true);
}
//-------------------------------------------------------------------
private void InitDepartmentList(bool forceInit = false)
{
@@ -126,9 +129,9 @@ namespace Sarand.PatientMgr.Win.Forms.Controls
// Populate list of columns to be displayed.
columnsDisplay.Add(DepartmentMgr.GetDepartmentColumnDfn(SpmDepartment.Column.Name));
columnsDisplay.Add(DepartmentMgr.GetDepartmentColumnDfn(SpmDepartment.Column.ApplicatonFrom));
columnsDisplay.Add(DepartmentMgr.GetDepartmentColumnDfn(SpmDepartment.Column.ApplicationTo));
columnsDisplay.Add(DepartmentMgr.GetDepartmentColumnDfn(SpmDepartment.Column.ApplicableFrom));
columnsDisplay.Add(DepartmentMgr.GetDepartmentColumnDfn(SpmDepartment.Column.ApplicableTo));
columnsDisplay.Add(DepartmentMgr.GetDepartmentColumnDfn(SpmDepartment.Column.Notes));
#if DEBUG
columnsDisplay.Add(DepartmentMgr.GetDepartmentColumnDfn(SpmDepartment.Column.Id));
#endif
@@ -157,8 +160,8 @@ namespace Sarand.PatientMgr.Win.Forms.Controls
public void RefreshDepartments(SpmDepartment.Params prmDepartment)
{
// Clear timers.
/*timerQueryData.Enabled = false;
timerDisplayItem.Enabled = false;*/
timerQueryData.Enabled = false;
timerDisplayItem.Enabled = false;
// Item Ids in the 'Initial selection' list are automatically selected on population.
// Subsequent refreshes automatically select the current selection by repopulation of the 'Initial selection' list.
if (!InitialPopulation)
@@ -174,10 +177,12 @@ namespace Sarand.PatientMgr.Win.Forms.Controls
ClearResultSet();
this.prmDepartment = prmDepartment;
// Enable timer.
timerQueryData.Start();
}
void OnTimerQueryData(Object myObject, EventArgs myEventArgs)
{
//timerQueryData.Enabled = false;
timerQueryData.Stop();
timerDisplayItem.Stop();
QueryData();
}
private void QueryData()
@@ -188,7 +193,7 @@ namespace Sarand.PatientMgr.Win.Forms.Controls
ItemTotal = (int)DepartmentMgr.GetDepartmentCount(prmDepartment);
if (ItemTotal > 0) Logger.Trace(GetType().Name + ".QueryData Department count: " + ItemTotal);
dbResultSet = DepartmentMgr.ExecuteDepartmentQuery(columnsQuery, prmDepartment);
//timerDisplayItem.Enabled = true;
timerDisplayItem.Start();
InitialPopulation = false;
}
public void RefreshDepartment(SysId affiliateId)
@@ -56,8 +56,8 @@ namespace Sarand.PatientMgr.Win.Forms.Controls
if (disposing)
{
if (components != null) components.Dispose();
timerQueryData.Dispose();
timerDisplayItem.Dispose();
if (timerQueryData != null) timerQueryData.Dispose();
if (timerDisplayItem != null) timerDisplayItem.Dispose();
ClearResultSet();
}
base.Dispose(disposing);
@@ -56,8 +56,8 @@ namespace Sarand.PatientMgr.Win.Forms.Controls
if (disposing)
{
if (components != null) components.Dispose();
timerQueryData.Dispose();
timerDisplayItem.Dispose();
if (timerQueryData != null) timerQueryData.Dispose();
if (timerDisplayItem != null) timerDisplayItem.Dispose();
ClearResultSet();
}
base.Dispose(disposing);
@@ -56,8 +56,8 @@ namespace Sarand.PatientMgr.Win.Forms.Controls
if (disposing)
{
if (components != null) components.Dispose();
timerQueryData.Dispose();
timerDisplayItem.Dispose();
if (timerQueryData != null) timerQueryData.Dispose();
if (timerDisplayItem != null) timerDisplayItem.Dispose();
ClearResultSet();
}
base.Dispose(disposing);
@@ -56,8 +56,8 @@ namespace Sarand.PatientMgr.Win.Forms.Controls
if (disposing)
{
if (components != null) components.Dispose();
timerQueryData.Dispose();
timerDisplayItem.Dispose();
if (timerQueryData != null) timerQueryData.Dispose();
if (timerDisplayItem != null) timerDisplayItem.Dispose();
ClearResultSet();
}
base.Dispose(disposing);
@@ -56,8 +56,8 @@ namespace Sarand.PatientMgr.Win.Forms.Controls
if (disposing)
{
if (components != null) components.Dispose();
timerQueryData.Dispose();
timerDisplayItem.Dispose();
if (timerQueryData != null) timerQueryData.Dispose();
if (timerDisplayItem != null) timerDisplayItem.Dispose();
ClearResultSet();
}
base.Dispose(disposing);
@@ -60,8 +60,8 @@ namespace Sarand.PatientMgr.Win.Forms.Controls
if (disposing)
{
if (components != null) components.Dispose();
timerQueryData.Dispose();
timerDisplayItem.Dispose();
if (timerQueryData != null) timerQueryData.Dispose();
if (timerDisplayItem != null) timerDisplayItem.Dispose();
ClearResultSet();
}
base.Dispose(disposing);
@@ -56,8 +56,8 @@ namespace Sarand.PatientMgr.Win.Forms.Controls
if (disposing)
{
if (components != null) components.Dispose();
timerQueryData.Dispose();
timerDisplayItem.Dispose();
if (timerQueryData != null) timerQueryData.Dispose();
if (timerDisplayItem != null) timerDisplayItem.Dispose();
ClearResultSet();
}
base.Dispose(disposing);
@@ -56,8 +56,8 @@ namespace Sarand.PatientMgr.Win.Forms.Controls
if (disposing)
{
if (components != null) components.Dispose();
timerQueryData.Dispose();
timerDisplayItem.Dispose();
if (timerQueryData != null) timerQueryData.Dispose();
if (timerDisplayItem != null) timerDisplayItem.Dispose();
ClearResultSet();
}
base.Dispose(disposing);
@@ -56,8 +56,8 @@ namespace Sarand.PatientMgr.Win.Forms.Controls
if (disposing)
{
if (components != null) components.Dispose();
timerQueryData.Dispose();
timerDisplayItem.Dispose();
if (timerQueryData != null) timerQueryData.Dispose();
if (timerDisplayItem != null) timerDisplayItem.Dispose();
ClearResultSet();
}
base.Dispose(disposing);
@@ -56,8 +56,8 @@ namespace Sarand.PatientMgr.Win.Forms.Controls
if (disposing)
{
if (components != null) components.Dispose();
timerQueryData.Dispose();
timerDisplayItem.Dispose();
if (timerQueryData != null) timerQueryData.Dispose();
if (timerDisplayItem != null) timerDisplayItem.Dispose();
ClearResultSet();
}
base.Dispose(disposing);
@@ -15,7 +15,7 @@ using System.Windows.Forms;
namespace Sarand.PatientMgr.Win.Forms.Maint
{
//=======================================================================
public partial class SpmForm_Admission : SpmForm
public partial class SpmForm_Admission : SpmForm_Item
{
//-------------------------------------------------------------------
// Configuration.
@@ -15,17 +15,17 @@
/// </summary>
private void InitializeComponent()
{
this.groupBoxProperties = new Sarand.Win.Forms.Controls.SacsGroupBox();
this.labelApplication = new System.Windows.Forms.Label();
this.groupBoxProperties = new System.Windows.Forms.GroupBox();
this.labelApplicable = new System.Windows.Forms.Label();
this.labelthrough = new System.Windows.Forms.Label();
this.dateTimePickerApplicTo = new Sarand.Win.Forms.Controls.SacsDateTimePicker();
this.dateTimePickerApplicableTo = new Sarand.Win.Forms.Controls.SacsDateTimePicker();
this.checkBoxAllowAnyWards = new System.Windows.Forms.CheckBox();
this.checkBoxAllowAnyClinics = new System.Windows.Forms.CheckBox();
this.checkBoxWards = new System.Windows.Forms.CheckBox();
this.checkBoxClinics = new System.Windows.Forms.CheckBox();
this.checkBoxAllowAnyTheatres = new System.Windows.Forms.CheckBox();
this.checkBoxTheatres = new System.Windows.Forms.CheckBox();
this.dateTimePickerApplicFrom = new Sarand.Win.Forms.Controls.SacsDateTimePicker();
this.dateTimePickerApplicableFrom = new Sarand.Win.Forms.Controls.SacsDateTimePicker();
this.labelName = new System.Windows.Forms.Label();
this.labelInstitution = new System.Windows.Forms.Label();
this.textBoxName = new Sarand.Win.Forms.Controls.SacsTextBox();
@@ -35,6 +35,7 @@
this.tabPage2 = new System.Windows.Forms.TabPage();
this.buttonCancel = new Sarand.Win.Forms.Controls.SacsButton();
this.buttonOk = new Sarand.Win.Forms.Controls.SacsButton();
this.panelUpdateStamp = new Sarand.PatientMgr.Win.Forms.Panels.SpmPanel_UpdateStamp();
this.groupBoxProperties.SuspendLayout();
this.tabControl.SuspendLayout();
this.SuspendLayout();
@@ -43,62 +44,63 @@
//
this.groupBoxProperties.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBoxProperties.BorderColour = System.Drawing.Color.Gray;
this.groupBoxProperties.Controls.Add(this.labelApplication);
this.groupBoxProperties.Controls.Add(this.labelApplicable);
this.groupBoxProperties.Controls.Add(this.labelthrough);
this.groupBoxProperties.Controls.Add(this.dateTimePickerApplicTo);
this.groupBoxProperties.Controls.Add(this.dateTimePickerApplicableTo);
this.groupBoxProperties.Controls.Add(this.checkBoxAllowAnyWards);
this.groupBoxProperties.Controls.Add(this.checkBoxAllowAnyClinics);
this.groupBoxProperties.Controls.Add(this.checkBoxWards);
this.groupBoxProperties.Controls.Add(this.checkBoxClinics);
this.groupBoxProperties.Controls.Add(this.checkBoxAllowAnyTheatres);
this.groupBoxProperties.Controls.Add(this.checkBoxTheatres);
this.groupBoxProperties.Controls.Add(this.dateTimePickerApplicFrom);
this.groupBoxProperties.Controls.Add(this.dateTimePickerApplicableFrom);
this.groupBoxProperties.Controls.Add(this.labelName);
this.groupBoxProperties.Controls.Add(this.labelInstitution);
this.groupBoxProperties.Controls.Add(this.textBoxName);
this.groupBoxProperties.Controls.Add(this.textBoxInstitution);
this.groupBoxProperties.Location = new System.Drawing.Point(12, 12);
this.groupBoxProperties.Location = new System.Drawing.Point(11, 10);
this.groupBoxProperties.Margin = new System.Windows.Forms.Padding(2);
this.groupBoxProperties.Name = "groupBoxProperties";
this.groupBoxProperties.Size = new System.Drawing.Size(608, 190);
this.groupBoxProperties.Padding = new System.Windows.Forms.Padding(2);
this.groupBoxProperties.Size = new System.Drawing.Size(482, 157);
this.groupBoxProperties.TabIndex = 0;
this.groupBoxProperties.TabStop = false;
this.groupBoxProperties.Text = "Properties";
//
// labelApplication
// labelApplicable
//
this.labelApplication.AutoSize = true;
this.labelApplication.Location = new System.Drawing.Point(72, 158);
this.labelApplication.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelApplication.Name = "labelApplication";
this.labelApplication.Size = new System.Drawing.Size(109, 17);
this.labelApplication.TabIndex = 10;
this.labelApplication.Text = "Application from";
this.labelApplicable.AutoSize = true;
this.labelApplicable.Location = new System.Drawing.Point(26, 131);
this.labelApplicable.Name = "labelApplicable";
this.labelApplicable.Size = new System.Drawing.Size(79, 13);
this.labelApplicable.TabIndex = 10;
this.labelApplicable.Text = "Applicable from";
//
// labelthrough
//
this.labelthrough.AutoSize = true;
this.labelthrough.Location = new System.Drawing.Point(364, 160);
this.labelthrough.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelthrough.Location = new System.Drawing.Point(242, 131);
this.labelthrough.Name = "labelthrough";
this.labelthrough.Size = new System.Drawing.Size(57, 17);
this.labelthrough.Size = new System.Drawing.Size(43, 13);
this.labelthrough.TabIndex = 12;
this.labelthrough.Text = "through";
//
// dateTimePickerApplicTo
// dateTimePickerApplicableTo
//
this.dateTimePickerApplicTo.Location = new System.Drawing.Point(426, 157);
this.dateTimePickerApplicTo.Name = "dateTimePickerApplicTo";
this.dateTimePickerApplicTo.Size = new System.Drawing.Size(170, 22);
this.dateTimePickerApplicTo.TabIndex = 13;
this.dateTimePickerApplicTo.Value = new System.DateTime(2019, 6, 13, 0, 0, 0, 0);
this.dateTimePickerApplicableTo.Location = new System.Drawing.Point(290, 128);
this.dateTimePickerApplicableTo.Margin = new System.Windows.Forms.Padding(2);
this.dateTimePickerApplicableTo.Name = "dateTimePickerApplicableTo";
this.dateTimePickerApplicableTo.Size = new System.Drawing.Size(110, 20);
this.dateTimePickerApplicableTo.TabIndex = 13;
this.dateTimePickerApplicableTo.Value = new System.DateTime(2019, 6, 13, 0, 0, 0, 0);
//
// checkBoxAllowAnyWards
//
this.checkBoxAllowAnyWards.AutoSize = true;
this.checkBoxAllowAnyWards.Location = new System.Drawing.Point(387, 130);
this.checkBoxAllowAnyWards.Location = new System.Drawing.Point(259, 107);
this.checkBoxAllowAnyWards.Margin = new System.Windows.Forms.Padding(2);
this.checkBoxAllowAnyWards.Name = "checkBoxAllowAnyWards";
this.checkBoxAllowAnyWards.Size = new System.Drawing.Size(141, 21);
this.checkBoxAllowAnyWards.Size = new System.Drawing.Size(110, 17);
this.checkBoxAllowAnyWards.TabIndex = 9;
this.checkBoxAllowAnyWards.Text = "Allow \'Any\' Wards";
this.checkBoxAllowAnyWards.UseVisualStyleBackColor = true;
@@ -106,9 +108,10 @@
// checkBoxAllowAnyClinics
//
this.checkBoxAllowAnyClinics.AutoSize = true;
this.checkBoxAllowAnyClinics.Location = new System.Drawing.Point(387, 103);
this.checkBoxAllowAnyClinics.Location = new System.Drawing.Point(259, 86);
this.checkBoxAllowAnyClinics.Margin = new System.Windows.Forms.Padding(2);
this.checkBoxAllowAnyClinics.Name = "checkBoxAllowAnyClinics";
this.checkBoxAllowAnyClinics.Size = new System.Drawing.Size(140, 21);
this.checkBoxAllowAnyClinics.Size = new System.Drawing.Size(109, 17);
this.checkBoxAllowAnyClinics.TabIndex = 7;
this.checkBoxAllowAnyClinics.Text = "Allow \'Any\' Clinics";
this.checkBoxAllowAnyClinics.UseVisualStyleBackColor = true;
@@ -116,9 +119,10 @@
// checkBoxWards
//
this.checkBoxWards.AutoSize = true;
this.checkBoxWards.Location = new System.Drawing.Point(188, 130);
this.checkBoxWards.Location = new System.Drawing.Point(110, 107);
this.checkBoxWards.Margin = new System.Windows.Forms.Padding(2);
this.checkBoxWards.Name = "checkBoxWards";
this.checkBoxWards.Size = new System.Drawing.Size(71, 21);
this.checkBoxWards.Size = new System.Drawing.Size(57, 17);
this.checkBoxWards.TabIndex = 8;
this.checkBoxWards.Text = "Wards";
this.checkBoxWards.UseVisualStyleBackColor = true;
@@ -126,9 +130,10 @@
// checkBoxClinics
//
this.checkBoxClinics.AutoSize = true;
this.checkBoxClinics.Location = new System.Drawing.Point(188, 103);
this.checkBoxClinics.Location = new System.Drawing.Point(110, 86);
this.checkBoxClinics.Margin = new System.Windows.Forms.Padding(2);
this.checkBoxClinics.Name = "checkBoxClinics";
this.checkBoxClinics.Size = new System.Drawing.Size(70, 21);
this.checkBoxClinics.Size = new System.Drawing.Size(56, 17);
this.checkBoxClinics.TabIndex = 6;
this.checkBoxClinics.Text = "Clinics";
this.checkBoxClinics.UseVisualStyleBackColor = true;
@@ -136,9 +141,10 @@
// checkBoxAllowAnyTheatres
//
this.checkBoxAllowAnyTheatres.AutoSize = true;
this.checkBoxAllowAnyTheatres.Location = new System.Drawing.Point(387, 76);
this.checkBoxAllowAnyTheatres.Location = new System.Drawing.Point(259, 65);
this.checkBoxAllowAnyTheatres.Margin = new System.Windows.Forms.Padding(2);
this.checkBoxAllowAnyTheatres.Name = "checkBoxAllowAnyTheatres";
this.checkBoxAllowAnyTheatres.Size = new System.Drawing.Size(157, 21);
this.checkBoxAllowAnyTheatres.Size = new System.Drawing.Size(121, 17);
this.checkBoxAllowAnyTheatres.TabIndex = 5;
this.checkBoxAllowAnyTheatres.Text = "Allow \'Any\' Theatres";
this.checkBoxAllowAnyTheatres.UseVisualStyleBackColor = true;
@@ -146,54 +152,57 @@
// checkBoxTheatres
//
this.checkBoxTheatres.AutoSize = true;
this.checkBoxTheatres.Location = new System.Drawing.Point(188, 76);
this.checkBoxTheatres.Location = new System.Drawing.Point(110, 65);
this.checkBoxTheatres.Margin = new System.Windows.Forms.Padding(2);
this.checkBoxTheatres.Name = "checkBoxTheatres";
this.checkBoxTheatres.Size = new System.Drawing.Size(87, 21);
this.checkBoxTheatres.Size = new System.Drawing.Size(68, 17);
this.checkBoxTheatres.TabIndex = 4;
this.checkBoxTheatres.Text = "Theatres";
this.checkBoxTheatres.UseVisualStyleBackColor = true;
//
// dateTimePickerApplicFrom
// dateTimePickerApplicableFrom
//
this.dateTimePickerApplicFrom.Location = new System.Drawing.Point(188, 157);
this.dateTimePickerApplicFrom.Name = "dateTimePickerApplicFrom";
this.dateTimePickerApplicFrom.Size = new System.Drawing.Size(170, 22);
this.dateTimePickerApplicFrom.TabIndex = 11;
this.dateTimePickerApplicFrom.Value = new System.DateTime(2019, 6, 13, 0, 0, 0, 0);
this.dateTimePickerApplicableFrom.Location = new System.Drawing.Point(110, 128);
this.dateTimePickerApplicableFrom.Margin = new System.Windows.Forms.Padding(2);
this.dateTimePickerApplicableFrom.Name = "dateTimePickerApplicableFrom";
this.dateTimePickerApplicableFrom.Size = new System.Drawing.Size(110, 20);
this.dateTimePickerApplicableFrom.TabIndex = 11;
this.dateTimePickerApplicableFrom.Value = new System.DateTime(2019, 6, 13, 0, 0, 0, 0);
//
// labelName
//
this.labelName.AutoSize = true;
this.labelName.Location = new System.Drawing.Point(136, 51);
this.labelName.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelName.Location = new System.Drawing.Point(70, 44);
this.labelName.Name = "labelName";
this.labelName.Size = new System.Drawing.Size(45, 17);
this.labelName.Size = new System.Drawing.Size(35, 13);
this.labelName.TabIndex = 2;
this.labelName.Text = "Name";
//
// labelInstitution
//
this.labelInstitution.AutoSize = true;
this.labelInstitution.Location = new System.Drawing.Point(113, 23);
this.labelInstitution.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelInstitution.Location = new System.Drawing.Point(53, 20);
this.labelInstitution.Name = "labelInstitution";
this.labelInstitution.Size = new System.Drawing.Size(68, 17);
this.labelInstitution.Size = new System.Drawing.Size(52, 13);
this.labelInstitution.TabIndex = 0;
this.labelInstitution.Text = "Institution";
//
// textBoxName
//
this.textBoxName.Location = new System.Drawing.Point(188, 48);
this.textBoxName.Location = new System.Drawing.Point(110, 41);
this.textBoxName.Margin = new System.Windows.Forms.Padding(2);
this.textBoxName.Name = "textBoxName";
this.textBoxName.Size = new System.Drawing.Size(408, 22);
this.textBoxName.Size = new System.Drawing.Size(307, 20);
this.textBoxName.TabIndex = 3;
this.textBoxName.TextChanged += new System.EventHandler(this.textBoxName_TextChanged);
//
// textBoxInstitution
//
this.textBoxInstitution.Location = new System.Drawing.Point(188, 20);
this.textBoxInstitution.Location = new System.Drawing.Point(110, 17);
this.textBoxInstitution.Margin = new System.Windows.Forms.Padding(2);
this.textBoxInstitution.Name = "textBoxInstitution";
this.textBoxInstitution.ReadOnly = true;
this.textBoxInstitution.Size = new System.Drawing.Size(408, 22);
this.textBoxInstitution.Size = new System.Drawing.Size(307, 20);
this.textBoxInstitution.TabIndex = 1;
//
// tabControl
@@ -203,28 +212,31 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.tabControl.Controls.Add(this.tabPage1);
this.tabControl.Controls.Add(this.tabPage2);
this.tabControl.Location = new System.Drawing.Point(12, 208);
this.tabControl.Location = new System.Drawing.Point(11, 171);
this.tabControl.Margin = new System.Windows.Forms.Padding(2);
this.tabControl.Name = "tabControl";
this.tabControl.SelectedIndex = 0;
this.tabControl.Size = new System.Drawing.Size(608, 197);
this.tabControl.Size = new System.Drawing.Size(482, 170);
this.tabControl.TabIndex = 1;
//
// tabPage1
//
this.tabPage1.Location = new System.Drawing.Point(4, 25);
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Margin = new System.Windows.Forms.Padding(2);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.Size = new System.Drawing.Size(600, 168);
this.tabPage1.Padding = new System.Windows.Forms.Padding(2);
this.tabPage1.Size = new System.Drawing.Size(474, 144);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "tabPage1";
this.tabPage1.UseVisualStyleBackColor = true;
//
// tabPage2
//
this.tabPage2.Location = new System.Drawing.Point(4, 25);
this.tabPage2.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Margin = new System.Windows.Forms.Padding(2);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(600, 168);
this.tabPage2.Padding = new System.Windows.Forms.Padding(2);
this.tabPage2.Size = new System.Drawing.Size(474, 144);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "tabPage2";
this.tabPage2.UseVisualStyleBackColor = true;
@@ -232,10 +244,9 @@
// buttonCancel
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.Location = new System.Drawing.Point(519, 412);
this.buttonCancel.Margin = new System.Windows.Forms.Padding(4);
this.buttonCancel.Location = new System.Drawing.Point(417, 346);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(100, 28);
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 3;
this.buttonCancel.Text = "Cancel";
this.buttonCancel.UseVisualStyleBackColor = true;
@@ -244,28 +255,38 @@
// buttonOk
//
this.buttonOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOk.Location = new System.Drawing.Point(411, 412);
this.buttonOk.Margin = new System.Windows.Forms.Padding(4);
this.buttonOk.Location = new System.Drawing.Point(336, 346);
this.buttonOk.Name = "buttonOk";
this.buttonOk.Size = new System.Drawing.Size(100, 28);
this.buttonOk.Size = new System.Drawing.Size(75, 23);
this.buttonOk.TabIndex = 2;
this.buttonOk.Text = "OK";
this.buttonOk.UseVisualStyleBackColor = true;
this.buttonOk.Click += new System.EventHandler(this.buttonOk_Click);
//
// panelUpdateStamp
//
this.panelUpdateStamp.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.panelUpdateStamp.Location = new System.Drawing.Point(11, 342);
this.panelUpdateStamp.Name = "panelUpdateStamp";
this.panelUpdateStamp.Size = new System.Drawing.Size(319, 38);
this.panelUpdateStamp.TabIndex = 4;
//
// SpmForm_Department
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(632, 453);
this.ClientSize = new System.Drawing.Size(504, 381);
this.ControlBox = false;
this.Controls.Add(this.panelUpdateStamp);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonOk);
this.Controls.Add(this.tabControl);
this.Controls.Add(this.groupBoxProperties);
this.Margin = new System.Windows.Forms.Padding(2);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(650, 500);
this.MinimumSize = new System.Drawing.Size(520, 420);
this.Name = "SpmForm_Department";
this.ShowIcon = false;
this.Text = "Update Department";
@@ -278,25 +299,26 @@
#endregion
private Sarand.Win.Forms.Controls.SacsGroupBox groupBoxProperties;
private System.Windows.Forms.GroupBox groupBoxProperties;
private System.Windows.Forms.TabControl tabControl;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.Label labelthrough;
private Sarand.Win.Forms.Controls.SacsDateTimePicker dateTimePickerApplicTo;
private Sarand.Win.Forms.Controls.SacsDateTimePicker dateTimePickerApplicableTo;
private System.Windows.Forms.CheckBox checkBoxAllowAnyWards;
private System.Windows.Forms.CheckBox checkBoxAllowAnyClinics;
private System.Windows.Forms.CheckBox checkBoxWards;
private System.Windows.Forms.CheckBox checkBoxClinics;
private System.Windows.Forms.CheckBox checkBoxAllowAnyTheatres;
private System.Windows.Forms.CheckBox checkBoxTheatres;
private Sarand.Win.Forms.Controls.SacsDateTimePicker dateTimePickerApplicFrom;
private Sarand.Win.Forms.Controls.SacsDateTimePicker dateTimePickerApplicableFrom;
private System.Windows.Forms.Label labelName;
private System.Windows.Forms.Label labelInstitution;
private Sarand.Win.Forms.Controls.SacsTextBox textBoxName;
private Sarand.Win.Forms.Controls.SacsTextBox textBoxInstitution;
private Sarand.Win.Forms.Controls.SacsButton buttonCancel;
private Sarand.Win.Forms.Controls.SacsButton buttonOk;
private System.Windows.Forms.Label labelApplication;
private System.Windows.Forms.Label labelApplicable;
private Panels.SpmPanel_UpdateStamp panelUpdateStamp;
}
}
@@ -1,6 +1,8 @@
using Sarand.PatientMgr.Core.App;
using Sarand.Core.Bus;
using Sarand.PatientMgr.Core.App;
using Sarand.PatientMgr.Core.Bus;
using Sarand.PatientMgr.Win.Forms.Base;
using Sarand.Win.Forms.Controls;
using Sarand.Win.Forms.Utils;
using System;
using System.Collections.Generic;
@@ -15,12 +17,15 @@ using System.Windows.Forms;
namespace Sarand.PatientMgr.Win.Forms.Maint
{
//=======================================================================
public partial class SpmForm_Department : SpmForm
public partial class SpmForm_Department : SpmForm_Item
{
//-------------------------------------------------------------------
// Configuration.
public new class Config : SpmForm_Item.Config
{
/// <summary>Institution - mandatory for department creation.</summary>
public SysId InstitutionId { get; set; }
/// <summary>Department to update.</summary>
public SpmDepartment DepartmentToUpdate { internal get; set; } = null;
}
@@ -30,8 +35,8 @@ namespace Sarand.PatientMgr.Win.Forms.Maint
//-------------------------------------------------------------------
// Construction.
public SpmForm_Department() : this(new Config()) { }
public SpmForm_Department(Config config) : base(config)
public SpmForm_Department () : this(new Config()) { }
public SpmForm_Department (Config config) : base(config)
{
this.config = config;
if (SpmGlobals.System != null)
@@ -39,7 +44,7 @@ namespace Sarand.PatientMgr.Win.Forms.Maint
}
InitializeComponent();
}
protected override void Dispose(bool disposing)
protected override void Dispose (bool disposing)
{
if (disposing && (components != null))
{
@@ -56,23 +61,90 @@ namespace Sarand.PatientMgr.Win.Forms.Maint
//-------------------------------------------------------------------
// S h o w D i a l o g
//-------------------------------------------------------------------
public new DialogResult ShowDialog()
public new DialogResult ShowDialog ()
{
if (!ValidateConfiguration()) return DialogResult;
if (config.DepartmentToUpdate == null)
{
// Creating new affiliate.
AddMode = true;
}
else
{
// Updating existing affiliate.
config.InstitutionId = config.DepartmentToUpdate.InstitutionId;
}
return base.ShowDialog();
}
// Validate configuration to ensure that form can be opened correctly.
private bool ValidateConfiguration()
private bool ValidateConfiguration ()
{
DialogResult = DialogResult.None;
if (config.DepartmentToUpdate == null)
{
// Creating new department.
if (!SysId.IsValid(config.InstitutionId))
return MessageConsole.ShowMessageWarning("Institution must be specified.");
if (!InstitutionMgr.InstitutionExistsById(config.InstitutionId))
return MessageConsole.ShowMessageWarning("Invalid Institution specified.");
}
else
{
if (SysId.IsValid(config.InstitutionId) && !config.InstitutionId.Equals(config.DepartmentToUpdate.InstitutionId))
return MessageConsole.ShowMessageWarning("Inconsistent Institution specified.");
}
return true;
}
//-------------------------------------------------------------------
// I n i t i a l i s a t i o n
//-------------------------------------------------------------------
protected override void OnCreateControl()
protected override void OnCreateControl ()
{
base.OnCreateControl();
if (this.IsDesignerHosted()) return;
AcceptButton = buttonOk;
CancelButton = buttonCancel;
if (ReadOnly)
{
buttonOk.Visible = false;
buttonCancel.Text = "Close";
}
else
{
buttonOk.Visible = true;
buttonCancel.Text = "Cancel";
}
// Institution.
SpmInstitution institution = InstitutionMgr.GetInstitutionById(config.InstitutionId);
textBoxInstitution.Text = institution?.Name ?? "Unknown";
// Applicable dates.
dateTimePickerApplicableFrom.Type = DateTimePickerType.Date;
dateTimePickerApplicableFrom.ShowCheckBox = true;
dateTimePickerApplicableFrom.Checked = false;
dateTimePickerApplicableTo.Type = DateTimePickerType.Date;
dateTimePickerApplicableTo.ShowCheckBox = true;
dateTimePickerApplicableTo.Checked = false;
// Configure controls.
//InitTabs();
// Initial display.
if (AddMode)
{
Text = "Create Department";
panelUpdateStamp.Visible = false;
}
else
{
Text = "Update Department";
PopulateToControls(config.DepartmentToUpdate.GetData());
panelUpdateStamp.ItemData = config.DepartmentToUpdate.GetData();
}
// Complete dialog initialisation.
PositionControls();
@@ -81,7 +153,7 @@ namespace Sarand.PatientMgr.Win.Forms.Maint
}
//-------------------------------------------------------------------
protected override void OnShown(EventArgs e)
protected override void OnShown (EventArgs e)
{
base.OnShown(e);
// Initial focus.
@@ -91,29 +163,46 @@ namespace Sarand.PatientMgr.Win.Forms.Maint
// P o p u l a t i o n
//-------------------------------------------------------------------
// PopulateToControls.
private void PopulateToControls(SpmDepartment.Data data)
private void PopulateToControls (SpmDepartment.Data data)
{
// Populate item properties to controls.
textBoxName.Text = data.Name;
dateTimePickerApplicableFrom.Value = data.ApplicableFrom;
dateTimePickerApplicableTo.Value = data.ApplicableTo;
checkBoxTheatres.Checked = data.HasFacilityType(Spm.FacilityType.Theatre);
checkBoxAllowAnyTheatres.Checked = data.AllowAnyFacility(Spm.FacilityType.Theatre);
checkBoxClinics.Checked = data.HasFacilityType(Spm.FacilityType.Clinic);
checkBoxAllowAnyClinics.Checked = data.AllowAnyFacility(Spm.FacilityType.Clinic);
checkBoxWards.Checked = data.HasFacilityType(Spm.FacilityType.Ward);
checkBoxAllowAnyWards.Checked = data.AllowAnyFacility(Spm.FacilityType.Ward);
AcceptChanges();
}
//-------------------------------------------------------------------
// Validate properties.
public bool IsDataValid(SpmDepartment.Data data)
public bool IsDataValid (SpmDepartment.Data data)
{
return true;
}
//-------------------------------------------------------------------
// PopulateFromControls.
private void PopulateFromControls(SpmDepartment.Data data)
private void PopulateFromControls (SpmDepartment.Data data)
{
if (!SysId.IsValid(data.InstitutionId))
data.InstitutionId = config.InstitutionId;
if (textBoxName.Visible && !textBoxName.ReadOnly)
data.Name = textBoxName.Text;
if (dateTimePickerApplicableFrom.Visible && !dateTimePickerApplicableFrom.ReadOnly)
data.ApplicableFrom = dateTimePickerApplicableFrom.Value;
if (dateTimePickerApplicableTo.Visible && !dateTimePickerApplicableTo.ReadOnly)
data.ApplicableTo = dateTimePickerApplicableTo.Value;
}
//-------------------------------------------------------------------
// UpdatedAssociated Data.
public bool UpdateAssociatedData()
public bool UpdateAssociatedData ()
{
return true;
}
@@ -121,40 +210,48 @@ namespace Sarand.PatientMgr.Win.Forms.Maint
//-------------------------------------------------------------------
// C l o s e F o r m
//-------------------------------------------------------------------
private void buttonOk_Click(object sender, EventArgs e)
private void buttonOk_Click (object sender, EventArgs e)
{
}
private void buttonCancel_Click(object sender, EventArgs e)
private void buttonCancel_Click (object sender, EventArgs e)
{
}
//-------------------------------------------------------------------
// C o n t r o l A c t i v i t y
//-------------------------------------------------------------------
protected override void SetControlActivity()
protected override void SetControlActivity ()
{
SetControlsReadOnly();
textBoxName.Enabled = Enabled;
}
public bool IsFieldReadOnly(SpmDbDfn.ColumnIdx col)
public bool IsFieldReadOnly (SpmDbDfn.ColumnIdx col)
{
if (ReadOnly) return true;
return false;
}
protected override void SetControlsReadOnly()
protected override void SetControlsReadOnly ()
{
textBoxName.ReadOnly = IsFieldReadOnly(SpmDbDfn.ColumnIdx.SwmDepartment_Name);
}
//-------------------------------------------------------------------
// P o s i t i o n C o n t r o l s
//-------------------------------------------------------------------
protected override void PositionControls()
protected override void PositionControls ()
{
}
//-------------------------------------------------------------------
// F o r m E v e n t s
//-------------------------------------------------------------------
private void textBoxName_TextChanged (object sender, EventArgs e)
{
Changed = true;
SetControlActivity();
}
//-------------------------------------------------------------------
}
@@ -15,7 +15,7 @@ using System.Windows.Forms;
namespace Sarand.PatientMgr.Win.Forms.Maint
{
//=======================================================================
public partial class SpmForm_Employee : SpmForm
public partial class SpmForm_Employee : SpmForm_Item
{
//-------------------------------------------------------------------
// Configuration.
@@ -15,7 +15,7 @@ using System.Windows.Forms;
namespace Sarand.PatientMgr.Win.Forms.Maint
{
//=======================================================================
public partial class SpmForm_EmployeeRole : SpmForm
public partial class SpmForm_EmployeeRole : SpmForm_Item
{
//-------------------------------------------------------------------
// Configuration.
@@ -15,7 +15,7 @@ using System.Windows.Forms;
namespace Sarand.PatientMgr.Win.Forms.Maint
{
//=======================================================================
public partial class SpmForm_Facility : SpmForm
public partial class SpmForm_Facility : SpmForm_Item
{
//-------------------------------------------------------------------
// Configuration.
@@ -15,7 +15,7 @@ using System.Windows.Forms;
namespace Sarand.PatientMgr.Win.Forms.Maint
{
//=======================================================================
public partial class SpmForm_FacilityTemplate_Slot : SpmForm
public partial class SpmForm_FacilityTemplate_Slot : SpmForm_Item
{
//-------------------------------------------------------------------
// Configuration.
@@ -15,7 +15,7 @@ using System.Windows.Forms;
namespace Sarand.PatientMgr.Win.Forms.Maint
{
//=======================================================================
public partial class SpmForm_Operation : SpmForm
public partial class SpmForm_Operation : SpmForm_Item
{
//-------------------------------------------------------------------
// Configuration.
@@ -15,7 +15,7 @@ using System.Windows.Forms;
namespace Sarand.PatientMgr.Win.Forms.Maint
{
//=======================================================================
public partial class SpmForm_Patient : SpmForm
public partial class SpmForm_Patient : SpmForm_Item
{
//-------------------------------------------------------------------
// Configuration.
@@ -15,7 +15,7 @@ using System.Windows.Forms;
namespace Sarand.PatientMgr.Win.Forms.Maint
{
//=======================================================================
public partial class SpmForm_Procedure : SpmForm
public partial class SpmForm_Procedure : SpmForm_Item
{
//-------------------------------------------------------------------
// Configuration.
@@ -23,26 +23,40 @@
this.buttonRemove = new System.Windows.Forms.Button();
this.buttonUpdate = new System.Windows.Forms.Button();
this.buttonCreate = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonOk = new System.Windows.Forms.Button();
this.tabControl.SuspendLayout();
this.SuspendLayout();
//
// listFilterDepartment
//
this.listFilterDepartment.Location = new System.Drawing.Point(3, 3);
this.listFilterDepartment.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listFilterDepartment.Location = new System.Drawing.Point(0, 2);
this.listFilterDepartment.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.listFilterDepartment.Name = "listFilterDepartment";
this.listFilterDepartment.Size = new System.Drawing.Size(694, 37);
this.listFilterDepartment.Size = new System.Drawing.Size(400, 30);
this.listFilterDepartment.TabIndex = 0;
this.listFilterDepartment.FilterChanged += new System.EventHandler(this.listFilterDepartment_FilterChanged);
//
// listViewDepartment
//
this.listViewDepartment.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listViewDepartment.FullRowSelect = true;
this.listViewDepartment.HideSelection = false;
this.listViewDepartment.Location = new System.Drawing.Point(8, 46);
this.listViewDepartment.Location = new System.Drawing.Point(0, 37);
this.listViewDepartment.Margin = new System.Windows.Forms.Padding(2);
this.listViewDepartment.Name = "listViewDepartment";
this.listViewDepartment.OwnerDraw = true;
this.listViewDepartment.Size = new System.Drawing.Size(575, 165);
this.listViewDepartment.Size = new System.Drawing.Size(317, 155);
this.listViewDepartment.TabIndex = 1;
this.listViewDepartment.UseCompatibleStateImageBehavior = false;
this.listViewDepartment.ItemCountChanged += new System.EventHandler<Sarand.Win.Forms.Controls.SacsListView.ItemCountChangedEventArgs>(this.listViewDepartment_ItemCountChanged);
this.listViewDepartment.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.listViewDepartment_ColumnClick);
this.listViewDepartment.SelectedIndexChanged += new System.EventHandler(this.listViewDepartment_SelectedIndexChanged);
this.listViewDepartment.DoubleClick += new System.EventHandler(this.listViewDepartment_DoubleClick);
this.listViewDepartment.MouseUp += new System.Windows.Forms.MouseEventHandler(this.listViewDepartment_MouseUp);
//
// tabControl
//
@@ -51,28 +65,31 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.tabControl.Controls.Add(this.tabPage1);
this.tabControl.Controls.Add(this.tabPage2);
this.tabControl.Location = new System.Drawing.Point(8, 217);
this.tabControl.Location = new System.Drawing.Point(2, 196);
this.tabControl.Margin = new System.Windows.Forms.Padding(2);
this.tabControl.Name = "tabControl";
this.tabControl.SelectedIndex = 0;
this.tabControl.Size = new System.Drawing.Size(574, 236);
this.tabControl.Size = new System.Drawing.Size(398, 154);
this.tabControl.TabIndex = 6;
//
// tabPage1
//
this.tabPage1.Location = new System.Drawing.Point(4, 25);
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Margin = new System.Windows.Forms.Padding(2);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.Size = new System.Drawing.Size(566, 207);
this.tabPage1.Padding = new System.Windows.Forms.Padding(2);
this.tabPage1.Size = new System.Drawing.Size(390, 128);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "tabPage1";
this.tabPage1.UseVisualStyleBackColor = true;
//
// tabPage2
//
this.tabPage2.Location = new System.Drawing.Point(4, 25);
this.tabPage2.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Margin = new System.Windows.Forms.Padding(2);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(566, 207);
this.tabPage2.Padding = new System.Windows.Forms.Padding(2);
this.tabPage2.Size = new System.Drawing.Size(390, 128);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "tabPage2";
this.tabPage2.UseVisualStyleBackColor = true;
@@ -80,49 +97,74 @@
// buttonRemove
//
this.buttonRemove.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonRemove.Location = new System.Drawing.Point(594, 182);
this.buttonRemove.Margin = new System.Windows.Forms.Padding(4);
this.buttonRemove.Location = new System.Drawing.Point(322, 95);
this.buttonRemove.Name = "buttonRemove";
this.buttonRemove.Size = new System.Drawing.Size(100, 28);
this.buttonRemove.Size = new System.Drawing.Size(75, 23);
this.buttonRemove.TabIndex = 15;
this.buttonRemove.Text = "Remove";
this.buttonRemove.UseVisualStyleBackColor = true;
this.buttonRemove.Click += new System.EventHandler(this.buttonRemove_Click);
//
// buttonUpdate
//
this.buttonUpdate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonUpdate.Location = new System.Drawing.Point(594, 114);
this.buttonUpdate.Margin = new System.Windows.Forms.Padding(4);
this.buttonUpdate.Location = new System.Drawing.Point(322, 66);
this.buttonUpdate.Name = "buttonUpdate";
this.buttonUpdate.Size = new System.Drawing.Size(100, 28);
this.buttonUpdate.Size = new System.Drawing.Size(75, 23);
this.buttonUpdate.TabIndex = 14;
this.buttonUpdate.Text = "Update";
this.buttonUpdate.UseVisualStyleBackColor = true;
this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
//
// buttonCreate
//
this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCreate.Location = new System.Drawing.Point(594, 46);
this.buttonCreate.Margin = new System.Windows.Forms.Padding(4);
this.buttonCreate.Location = new System.Drawing.Point(322, 37);
this.buttonCreate.Name = "buttonCreate";
this.buttonCreate.Size = new System.Drawing.Size(100, 28);
this.buttonCreate.Size = new System.Drawing.Size(75, 23);
this.buttonCreate.TabIndex = 13;
this.buttonCreate.Text = "Create";
this.buttonCreate.UseVisualStyleBackColor = true;
this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click);
//
// buttonCancel
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.Location = new System.Drawing.Point(322, 168);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 15;
this.buttonCancel.Text = "Cancel";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// buttonOk
//
this.buttonOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOk.Location = new System.Drawing.Point(322, 139);
this.buttonOk.Name = "buttonOk";
this.buttonOk.Size = new System.Drawing.Size(75, 23);
this.buttonOk.TabIndex = 15;
this.buttonOk.Text = "OK";
this.buttonOk.UseVisualStyleBackColor = true;
this.buttonOk.Click += new System.EventHandler(this.buttonOk_Click);
//
// SpmPanel_Departments
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.buttonOk);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonRemove);
this.Controls.Add(this.buttonUpdate);
this.Controls.Add(this.buttonCreate);
this.Controls.Add(this.tabControl);
this.Controls.Add(this.listViewDepartment);
this.Controls.Add(this.listFilterDepartment);
this.MinimumSize = new System.Drawing.Size(700, 460);
this.Margin = new System.Windows.Forms.Padding(2);
this.MinimumSize = new System.Drawing.Size(400, 350);
this.Name = "SpmPanel_Departments";
this.Size = new System.Drawing.Size(700, 460);
this.Size = new System.Drawing.Size(400, 350);
this.tabControl.ResumeLayout(false);
this.ResumeLayout(false);
@@ -138,5 +180,7 @@
private System.Windows.Forms.Button buttonRemove;
private System.Windows.Forms.Button buttonUpdate;
private System.Windows.Forms.Button buttonCreate;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.Button buttonOk;
}
}
@@ -14,6 +14,9 @@ using Sarand.Core.Base;
using Sarand.PatientMgr.Core.App;
using Sarand.PatientMgr.Win.Forms.Maint;
using Sarand.PatientMgr.Win.Forms.Controls;
using Sarand.PatientMgr.Win.Forms.TabPages;
using Sarand.PatientMgr.Win.Forms.Filters;
using Sarand.PatientMgr.Win.Forms.Base;
namespace Sarand.PatientMgr.Win.Forms.Panels
{
@@ -29,22 +32,39 @@ namespace Sarand.PatientMgr.Win.Forms.Panels
}
public new class Config : SpmPanel_Items.Config
{
public PanelMode Mode { get; set; } = PanelMode.Maintain;
public Config (PanelMode mode)
{
Mode = mode;
// Defaults based on mode.
DisplayFilter = false; // Mode == PanelMode.Maintain || Mode == PanelMode.Search;
DisplayTabs = Mode == PanelMode.Maintain;
DisplayActionButtons = Mode == PanelMode.Maintain;
DisplayNavigationButtons = Mode == PanelMode.Search;
}
public PanelMode Mode { get; } = PanelMode.Maintain;
public SpmForm SearchForm { get; set; }
// Display options.
public bool DisplayFilter { get; set; } = false;
public bool DisplayContextMenu { get; set; } = true;
public bool DisplayActionButtons { get; set; } = false;
public bool DisplayNavigationButtons { get; set; } = false;
public bool DisplayTabs { get; set; } = false;
}
//-------------------------------------------------------------------
// Data members.
private Config config = new Config();
private Config config = new Config(PanelMode.Search);
private readonly List<SpmTabPage_Department> tabPages = new List<SpmTabPage_Department>();
//-------------------------------------------------------------------
// Construction.
public SpmPanel_Departments() : this(new Config()) { }
public SpmPanel_Departments(Config config) : base(config)
private SpmPanel_Departments () : this(new Config(PanelMode.Search)) { }
public SpmPanel_Departments (Config config) : base(config)
{
this.config = config;
InitializeComponent();
}
protected override void Dispose(bool disposing)
protected override void Dispose (bool disposing)
{
if (disposing)
{
@@ -65,7 +85,7 @@ namespace Sarand.PatientMgr.Win.Forms.Panels
//-------------------------------------------------------------------
// Configure.
public void SetConfig(Config config)
public void SetConfig (Config config)
{
base.SetConfig(config);
this.config = config;
@@ -73,8 +93,9 @@ namespace Sarand.PatientMgr.Win.Forms.Panels
}
//-------------------------------------------------------------------
// Initialisation.
protected override void OnCreateControl()
// I n i t i a l i s a t i o n
//-------------------------------------------------------------------
protected override void OnCreateControl ()
{
base.OnCreateControl();
if (this.IsDesignerHosted()) return;
@@ -82,38 +103,173 @@ namespace Sarand.PatientMgr.Win.Forms.Panels
ConfigurePanel();
}
private void ConfigurePanel()
private void ConfigurePanel ()
{
if (!Created) return;
if (this.IsDesignerHosted()) return;
if (!Created || this.IsDesignerHosted()) return;
// Configure filter.
if (config.DisplayFilter)
{
SpmItemListFilter_Department.Config configFilter = new SpmItemListFilter_Department.Config();
configFilter.Internals = Internals;
listFilterDepartment.SetConfig(configFilter);
}
listFilterDepartment.Visible = config.DisplayFilter;
// Configure list.
SpmItemListView_Department.Config configList = new SpmItemListView_Department.Config();
configList.Internals = Internals;
configList.Mode = SpmItemListView_Department.ListMode.General;
listViewDepartment.SetConfig(configList);
// Tabs.
tabControl.TabPages.Clear();
tabControl.Visible = config.DisplayTabs;
RefreshTabs();
// Configure buttons.
buttonCreate.Visible = config.DisplayActionButtons && SecurityProfile.Admin.CanManageConfig();
buttonUpdate.Visible = config.DisplayActionButtons;
buttonRemove.Visible = config.DisplayActionButtons && buttonCreate.Visible;
buttonOk.Visible = config.DisplayNavigationButtons && config.Mode == PanelMode.Search;
buttonCancel.Visible = config.DisplayNavigationButtons;
// Complete form initialisation.
RefreshDataItems();
SetControlActivity();
PositionControls();
}
//-------------------------------------------------------------------
// Initialise tabs.
private void InitTabs()
private void InitTabs ()
{
/*tabControl.TabPages.Clear();
String fn = GetType().Name + ".InitTabs";
tabControl.TabPages.Clear();
tabPages.Clear();
if (!config.DisplayTabs) return;
if (!config.DisplayTabs)
{
tabPages.Clear();
tabControl.TabPages.Clear();
tabControl.Visible = false;
return;
}
// Selected Department.
SpmDepartment department = SelectedDepartment;
// Theatres.
List<SpmTabPage_Department.PanelType> panelTypes_Theatres = new List<SpmTabPage_Department.PanelType>();
if (department?.HasFacilityType(Spm.FacilityType.Theatre) ?? false)
panelTypes_Theatres.Add(SpmTabPage_Department.PanelType.Theatres);
if (panelTypes_Theatres.Count > 0)
{
SpmTabPage_Department.Config configTabPage = new SpmTabPage_Department.Config();
configTabPage.Internals = Internals;
configTabPage.ReadOnly = ReadOnly;
configTabPage.PanelTypes.AddRange(panelTypes_Theatres);
SpmTabPage_Department tabPage = new SpmTabPage_Department(configTabPage) { Text = "Theatres" };
tabPages.Add(tabPage);
}
// Clinics.
List<SpmTabPage_Department.PanelType> panelTypes_Clinics = new List<SpmTabPage_Department.PanelType>();
if (department?.HasFacilityType(Spm.FacilityType.Clinic) ?? false)
panelTypes_Clinics.Add(SpmTabPage_Department.PanelType.Clinics);
if (panelTypes_Clinics.Count > 0)
{
SpmTabPage_Department.Config configTabPage = new SpmTabPage_Department.Config();
configTabPage.Internals = Internals;
configTabPage.ReadOnly = ReadOnly;
configTabPage.PanelTypes.AddRange(panelTypes_Clinics);
SpmTabPage_Department tabPage = new SpmTabPage_Department(configTabPage) { Text = "Clinics" };
tabPages.Add(tabPage);
}
// Wards.
List<SpmTabPage_Department.PanelType> panelTypes_Wards = new List<SpmTabPage_Department.PanelType>();
if (department?.HasFacilityType(Spm.FacilityType.Ward) ?? false)
panelTypes_Wards.Add(SpmTabPage_Department.PanelType.Wards);
if (panelTypes_Wards.Count > 0)
{
SpmTabPage_Department.Config configTabPage = new SpmTabPage_Department.Config();
configTabPage.Internals = Internals;
configTabPage.ReadOnly = ReadOnly;
configTabPage.PanelTypes.AddRange(panelTypes_Wards);
SpmTabPage_Department tabPage = new SpmTabPage_Department(configTabPage) { Text = "Wards" };
tabPages.Add(tabPage);
}
// Updates.
List<SpmTabPage_Department.PanelType> panelTypes_Updates = new List<SpmTabPage_Department.PanelType>();
panelTypes_Updates.Add(SpmTabPage_Department.PanelType.Updates);
if (panelTypes_Updates.Count > 0)
{
SpmTabPage_Department.Config configTabPage = new SpmTabPage_Department.Config();
configTabPage.Internals = Internals;
configTabPage.ReadOnly = ReadOnly;
configTabPage.PanelTypes.AddRange(panelTypes_Updates);
SpmTabPage_Department tabPage = new SpmTabPage_Department(configTabPage) { Text = "Updates" };
tabPages.Add(tabPage);
}
// Populate tab pages.
tabControl.Visible = tabPages.Count > 0;
foreach (var tabPage in tabPages)
tabControl.TabPages.Add(tabPage);
tabControl.Visible = (tabControl.TabPages.Count > 0);*/
}
//-------------------------------------------------------------------
// P a n e l I n t e r f a c e
//-------------------------------------------------------------------
private String previouslySelectedTabPageText = "";
private void RefreshTabs ()
{
if (tabControl.SelectedTab != null)
previouslySelectedTabPageText = tabControl.SelectedTab.Text;
// Reinitialise tabs whenever the selection changes in case the set of tab pages displayed needs to be changed.
InitTabs();
// Select previous tab page if still present.
if (!StringUtil.IsEmpty(previouslySelectedTabPageText))
{
foreach (TabPage tabPage in tabControl.TabPages)
{
if (tabPage.Text.Equals(previouslySelectedTabPageText))
{
tabControl.SelectTab(tabPage);
break;
}
}
}
RefreshTabPages();
SetControlActivity();
PositionControls();
}
private void RefreshTabPages ()
{
// Selected Department - populated when needed.
SpmDepartment department = null;
// Refresh tabs.
if (tabControl.Visible)
{
if (department == null) department = SelectedDepartment;
SpmDepartment.Data departmentData = department != null ? department.GetData() : new SpmDepartment.Data();
tabPages.PopulateToControls(departmentData);
}
}
//-------------------------------------------------------------------
// F i l t e r
//-------------------------------------------------------------------
public SpmDepartment.Params GetParams()
public bool ParamsAreValid (SpmDepartment.Params prmDepartment)
{
return true;
}
public SpmDepartment.Params GetParams ()
{
SpmDepartment.Params prmDepartment = new SpmDepartment.Params();
@@ -125,27 +281,31 @@ namespace Sarand.PatientMgr.Win.Forms.Panels
//-------------------------------------------------------------------
// A c t i o n s
//-------------------------------------------------------------------
public override void RefreshDataItems()
// Refresh.
public override void RefreshDataItems ()
{
listViewDepartment.RefreshDepartments(GetParams());
SpmDepartment.Params prmDepartment = GetParams();
if (!ParamsAreValid(prmDepartment)) prmDepartment = null;
listViewDepartment.RefreshDepartments(prmDepartment);
}
public override void RefreshDataItem(SysId id)
public override void RefreshDataItem (SysId id)
{
listViewDepartment.RefreshDepartment(id);
}
public override void RemoveDataItem(SysId id)
public override void RemoveDataItem (SysId id)
{
listViewDepartment.RemoveItemById(id);
}
//-------------------------------------------------------------------
// Create item.
public override bool CanCreateItem()
public override bool CanCreateItem ()
{
if (ReadOnly) return false;
//if (!SecurityProfile.UserCanCreateItemType(Spm.DataItemType.Department)) return false;
if (!SecurityProfile.Admin.CanManageConfig()) return false;
return true;
}
public override void CreateItem()
public override void CreateItem ()
{
if (!CanCreateItem()) return;
if (config.Mode == PanelMode.Search) return;
@@ -155,26 +315,25 @@ namespace Sarand.PatientMgr.Win.Forms.Panels
{
if (form.ShowDialog() == DialogResult.OK)
{
/*RefreshDataItem(form.NewItemId);
InvokeItemCreatedEvent(Spm.ItemType.Department, form.NewItemId);*/
RefreshDataItem(form.NewItemId);
InvokeItemCreatedEvent(Spm.DataItemType.Department, form.NewItemId);
}
}
}
//-------------------------------------------------------------------
// View/Update item.
public override bool CanViewItem()
public override bool CanViewItem ()
{
return true;
}
public override bool CanUpdateItem()
public override bool CanUpdateItem ()
{
if (ReadOnly) return false;
/*bool canMaintainDepartments = SecurityProfile.UserCanCreateItemType(Spm.ItemType.Department) || SecurityProfile.UserCanUpdateItemType(Spm.ItemType.Department);
if (!canMaintainDepartments) return false;*/
if (!SecurityProfile.Admin.CanManageConfig()) return false;
return true;
}
public override void UpdateItem(bool updateItem = true)
public override void UpdateItem (bool updateItem = true)
{
if (config.Mode == PanelMode.Search) return;
SpmDepartment department = SelectedDepartment;
@@ -204,13 +363,13 @@ namespace Sarand.PatientMgr.Win.Forms.Panels
//-------------------------------------------------------------------
// Delete item.
public override bool CanDeleteItem()
public override bool CanDeleteItem ()
{
if (ReadOnly) return false;
//if (!SecurityProfile.UserCanRemoveItemType(Spm.ItemType.Department)) return false;
if (!SecurityProfile.Admin.CanManageConfig()) return false;
return true;
}
public override void DeleteItem()
public override void DeleteItem ()
{
if (!CanDeleteItem()) return;
if (config.Mode == PanelMode.Search) return;
@@ -240,41 +399,24 @@ namespace Sarand.PatientMgr.Win.Forms.Panels
}
}
//-------------------------------------------------------------------
// Status change - Deactivate.
protected void DeactivateItem(object sender, EventArgs e) { DeactivateItem(); }
public void DeactivateItem()
{
SpmDepartment department = SelectedDepartment;
if (department != null && department.Status == SaStatus.Active)
{
department.Status = SaStatus.Inactive;
if (DepartmentMgr.UpdateDepartment(department, DbUpdateInfo))
{
RefreshDataItem(department.Id);
//InvokeItemUpdatedEvent(Spm.ItemType.Department, department.Id);
}
}
}
//-------------------------------------------------------------------
// Import data.
public override bool CanImportData()
public override bool CanImportData ()
{
return false;
}
public override void ImportData()
public override void ImportData ()
{
if (!CanImportData()) return;
}
//-------------------------------------------------------------------
// Export data.
public override bool CanExportData()
public override bool CanExportData ()
{
return false;
}
public override void ExportData()
public override void ExportData ()
{
}
@@ -282,7 +424,7 @@ namespace Sarand.PatientMgr.Win.Forms.Panels
// C o n t e x t M e n u
//-------------------------------------------------------------------
private SpmContextMenuStrip contextMenuStrip = new SpmContextMenuStrip();
private void RefreshContextMenu()
private void RefreshContextMenu ()
{
contextMenuStrip.Name = "Department";
contextMenuStrip.Items.Clear();
@@ -293,11 +435,13 @@ namespace Sarand.PatientMgr.Win.Forms.Panels
SpmDepartment department = SelectedDepartment;
if (department != null)
{
if (CanUpdateItem())
if (CanUpdateItem() || CanDeleteItem())
{
if (contextMenuStrip.Items.Count > 0)
contextMenuStrip.Items.Add(new ToolStripSeparator());
contextMenuStrip.Items.Add("Update", null, UpdateItem);
contextMenuStrip.Items.Add(CanUpdateItem() ? "Update" : "View", null, UpdateItem);
if (CanDeleteItem())
contextMenuStrip.Items.Add("Remove", null, DeleteItem);
}
}
}
@@ -315,31 +459,186 @@ namespace Sarand.PatientMgr.Win.Forms.Panels
//-------------------------------------------------------------------
// C o n t r o l A c t i v i t y
//-------------------------------------------------------------------
protected override void SetControlActivity()
protected override void SetControlActivity ()
{
// Department list:
listViewDepartment.Enabled = Enabled;
SetControlsReadOnly();
bool itemSelected = SysId.IsValid(SelectedItemId);
//ToDo SpmPanel_Department > UpdateStats
listViewDepartment.Enabled = Enabled;
buttonCreate.Enabled = Enabled;
buttonUpdate.Enabled = Enabled && itemSelected;
buttonRemove.Enabled = Enabled && itemSelected;
buttonOk.Enabled = Enabled;
buttonCancel.Enabled = Enabled;
}
protected override void SetControlsReadOnly()
protected override void SetControlsReadOnly ()
{
}
//-------------------------------------------------------------------
// P o s i t i o n C o n t r o l s
//-------------------------------------------------------------------
protected override void PositionControls()
protected override void PositionControls ()
{
if (this.IsDesignerHosted()) return;
base.PositionControls();
if (this.IsDesignerHosted() || !Created) return;
Rectangle clientRect = ClientRectangle;
//---------------------------------------------------------------
// Filter panel.
if (listFilterDepartment.Visible)
{
listFilterDepartment.PositionAtTopLeftOf(this);
listFilterDepartment.SetFullWidthOf(this);
listFilterDepartment.ResizeToBottomControl();
listViewDepartment.PositionBelow(listFilterDepartment);
}
else
{
listViewDepartment.PositionAtTopLeftOf(this);
}
//---------------------------------------------------------------
// List view.
int buttonLeft = clientRect.Width - buttonCreate.Width - buttonCreate.Margin.Right - Padding.Right;
listViewDepartment.Left = listViewDepartment.Margin.Left;
listViewDepartment.Width = buttonLeft - buttonCreate.Margin.Left - listViewDepartment.Left - listViewDepartment.Margin.Right;
if (!(buttonCreate.Visible || buttonUpdate.Visible || buttonRemove.Visible || buttonOk.Visible || buttonCancel.Visible))
listViewDepartment.Width = clientRect.Width - Padding.Right - listViewDepartment.Left - listViewDepartment.Margin.Right;
//---------------------------------------------------------------
// Tab control.
if (tabControl.Visible)
{
tabControl.Left = listViewDepartment.Left;
tabControl.Width = clientRect.Width - (tabControl.Left * 2);
listViewDepartment.Height = (int)((clientRect.Height - listViewDepartment.Top) * 0.40);
tabControl.Top = listViewDepartment.Bottom + listViewDepartment.Margin.Bottom + tabControl.Margin.Top;
tabControl.Height = clientRect.Height - tabControl.Top - tabControl.Margin.Bottom - Padding.Bottom;
}
else
{
listViewDepartment.Height = clientRect.Height - listViewDepartment.Top - listViewDepartment.Margin.Bottom - Padding.Bottom;
}
//---------------------------------------------------------------
// Create button.
int buttonTop = listViewDepartment.Top + listViewDepartment.HeaderHeight;
buttonCreate.Top = buttonTop;
buttonCreate.Left = buttonLeft;
if (buttonCreate.Visible)
buttonTop += buttonCreate.Height + buttonCreate.Margin.Bottom;
// Update button.
buttonUpdate.Top = buttonTop;
buttonUpdate.Left = buttonLeft;
if (buttonUpdate.Visible)
buttonTop += buttonUpdate.Height + buttonUpdate.Margin.Bottom;
// Remove button.
buttonRemove.Top = buttonTop;
buttonRemove.Left = buttonLeft;
if (buttonRemove.Visible)
buttonTop += buttonRemove.Height + buttonRemove.Margin.Bottom;
//---------------------------------------------------------------
// Navigation buttons.
// Cancel button.
buttonCancel.Top = clientRect.Bottom - Padding.Bottom - buttonCancel.Margin.Bottom - buttonCancel.Height;
buttonCancel.Left = buttonLeft;
// OK button.
buttonOk.Top = buttonCancel.Top - buttonOk.Height - buttonCancel.Padding.Top - buttonCancel.Margin.Bottom;
buttonOk.Left = buttonLeft;
if (buttonOk.Visible)
buttonTop += buttonOk.Height + buttonOk.Margin.Bottom;
//---------------------------------------------------------------
}
//-------------------------------------------------------------------
// F o r m E v e n t s
// P a n e l E v e n t s
//-------------------------------------------------------------------
// Filter.
private void listFilterDepartment_FilterChanged (object sender, EventArgs e)
{
RefreshDataItems();
SetControlActivity();
}
//-------------------------------------------------------------------
// Item list.
private void listViewDepartment_ColumnClick (object sender, ColumnClickEventArgs e)
{
RefreshDataItems();
}
private void listViewDepartment_ItemCountChanged (object sender, Sarand.Win.Forms.Controls.SacsListView.ItemCountChangedEventArgs e)
{
InvokeItemCountChangedEvent(e);
}
private void listViewDepartment_SelectedIndexChanged (object sender, EventArgs e)
{
RefreshTabs();
InvokeItemSelectionChangedEvent(e);
SetControlActivity();
}
private void listViewDepartment_DoubleClick (object sender, EventArgs e)
{
if (config.Mode == PanelMode.Search)
{
//if (config.SearchForm != null) config.SearchForm.OnOK();
}
else
UpdateItem();
SetControlActivity();
}
private void listViewDepartment_MouseUp (object sender, MouseEventArgs e)
{
switch (e.Button)
{
case MouseButtons.Right:
// Refresh the context menu and display at pointer position.
RefreshContextMenu();
contextMenuStrip.Show(listViewDepartment, new Point(e.X, e.Y), ToolStripDropDownDirection.Default);
break;
}
SetControlActivity();
}
//-------------------------------------------------------------------
// Actions.
private void buttonCreate_Click (object sender, EventArgs e)
{
CreateItem();
SetControlActivity();
}
private void buttonUpdate_Click (object sender, EventArgs e)
{
UpdateItem();
SetControlActivity();
}
private void buttonRemove_Click (object sender, EventArgs e)
{
DeleteItem();
SetControlActivity();
}
private void buttonOk_Click (object sender, EventArgs e)
{
if (config.SearchForm != null)
{
//config.SearchForm.OnOK();
return;
}
SetControlActivity();
}
private void buttonCancel_Click (object sender, EventArgs e)
{
if (config.SearchForm != null)
{
//config.SearchForm.OnCancel();
return;
}
SetControlActivity();
}
//-------------------------------------------------------------------
}
@@ -30,11 +30,13 @@ namespace Sarand.PatientMgr.Win.Forms.Panels
public new class Config : SpmPanel_Items.Config
{
public PanelMode Mode { get; set; } = PanelMode.Maintain;
public Spm.FacilityType FacilityType { get; set; } = Spm.FacilityType.Unknown;
}
//-------------------------------------------------------------------
// Data members.
private Config config = new Config();
private SysId departmentId = null;
//-------------------------------------------------------------------
// Construction.
@@ -56,6 +58,17 @@ namespace Sarand.PatientMgr.Win.Forms.Panels
//-------------------------------------------------------------------
// Properties.
protected override String DefaultMessageTitle { get { return "Facility"; } }
[Browsable(false), ReadOnly(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public SysId DepartmentId
{
get { return departmentId; }
set
{
if (SysId.ToInt(departmentId) == SysId.ToInt(value)) return;
departmentId = value;
RefreshDataItems();
}
}
public override int ItemTotal { get { return listViewFacility.ItemTotal; } }
public override int ItemCount { get { return listViewFacility.ItemCount; } }
public override int SelectedItemCount { get { return listViewFacility.SelectedItemCount; } }
@@ -0,0 +1,57 @@
namespace Sarand.PatientMgr.Win.Forms.Panels
{
partial class SpmPanel_UpdateStamp
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent ()
{
this.htmlPanel = new Sarand.Win.Forms.Controls.SacsHtmlPanel();
this.sacsHtmlPanel1 = new Sarand.Win.Forms.Controls.SacsHtmlPanel();
this.SuspendLayout();
//
// htmlPanel
//
this.htmlPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.htmlPanel.Location = new System.Drawing.Point(0, 0);
this.htmlPanel.MinimumSize = new System.Drawing.Size(20, 20);
this.htmlPanel.Name = "htmlPanel";
this.htmlPanel.Size = new System.Drawing.Size(405, 104);
this.htmlPanel.TabIndex = 0;
//
// sacsHtmlPanel1
//
this.sacsHtmlPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.sacsHtmlPanel1.Location = new System.Drawing.Point(0, 0);
this.sacsHtmlPanel1.MinimumSize = new System.Drawing.Size(20, 20);
this.sacsHtmlPanel1.Name = "sacsHtmlPanel1";
this.sacsHtmlPanel1.Size = new System.Drawing.Size(405, 104);
this.sacsHtmlPanel1.TabIndex = 1;
//
// SpmPanel_UPdateStamp
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.sacsHtmlPanel1);
this.Controls.Add(this.htmlPanel);
this.Name = "SpmPanel_UPdateStamp";
this.Size = new System.Drawing.Size(405, 104);
this.ResumeLayout(false);
}
#endregion
private Sarand.Win.Forms.Controls.SacsHtmlPanel htmlPanel;
private Sarand.Win.Forms.Controls.SacsHtmlPanel sacsHtmlPanel1;
}
}
@@ -0,0 +1,130 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Sarand.Win.Forms.Controls;
using Sarand.PatientMgr.Win.Forms.App;
using Sarand.Core.Bus;
using Sarand.Core.Security;
using Sarand.Win.Forms.Utils;
using Sarand.Core.Base;
using Sarand.PatientMgr.Core.App;
namespace Sarand.PatientMgr.Win.Forms.Panels
{
//=======================================================================
public partial class SpmPanel_UpdateStamp : SacsUserControl
{
//-------------------------------------------------------------------
// Data members.
private SpmSessionProfile_Win sessionProfile = null;
private SacsHierarchyItem.Data itemData = null;
private SaSecurityConsole securityConsole;
//-------------------------------------------------------------------
// Construction.
public SpmPanel_UpdateStamp ()
{
if (SpmGlobals.System != null)
{
sessionProfile = SpmGlobals_Win.SessionProfile;
securityConsole = SpmGlobals.Application.GetSecurityConsole(sessionProfile.SessionContext);
}
InitializeComponent();
}
protected override void Dispose (bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
//-------------------------------------------------------------------
// I n i t i a l i s a t i o n
//-------------------------------------------------------------------
protected override void OnCreateControl ()
{
base.OnCreateControl();
if (this.IsDesignerHosted()) return;
BorderStyle = BorderStyle.None;
RefreshDisplay();
}
//-------------------------------------------------------------------
// Properties.
public SacsHierarchyItem.Data ItemData
{
set
{
if (itemData == value) return;
itemData = value;
RefreshDisplay();
}
}
//-------------------------------------------------------------------
// Refresh display.
private void RefreshDisplay ()
{
List<String> body = new List<String>();
if (itemData != null)
{
// Users.
string createUser = (securityConsole != null ? securityConsole.GetNameForItemId(itemData.CreateStamp.By) : "");
string updateUser = (securityConsole != null ? securityConsole.GetNameForItemId(itemData.UpdateStamp.By) : "");
// Display update stamp.
body.Add("<div><span class='label'>Created:</span> <span class='value'>" + DateUtil.Format(itemData.CreateStamp.On, "d-MMM-yyyy HH:mm") + (!StringUtil.IsEmpty(createUser) ? " by " + createUser : "") + "</div>");
body.Add("<div><span class='label'>Updated:</span> <span class='value'>" + DateUtil.Format(itemData.UpdateStamp.On, "d-MMM-yyyy HH:mm") + (!StringUtil.IsEmpty(updateUser) ? " by " + updateUser : "") + "</div>");
}
else
{
body.Add("<div><span class='label'>Created:</span> <span class='value'>" + DateUtil.Format(DateTime.Now, "d-MMM-yyyy HH:mm") + "</span></div>");
}
if (htmlPanel.DocumentPopulated && htmlPanel.Document != null && htmlPanel.Document.Body != null && false)
{
htmlPanel.SetDocumentBody(body.Concat("\n"));
}
else
{
List<String> html = new List<String>();
html.Add("<html><head>" + GetStyle() + "</html><body>");
html.AddRange(body);
html.Add("</body></html>");
htmlPanel.SetDocumentHtml(html.Concat("\n"));
htmlPanel.DocumentPopulated = true;
}
}
private String GetStyle ()
{
List<String> style = new List<String>();
style.Add("<style>");
style.Add("body{margin:0;padding:4px;font-family:arial;font-size:10px;background-color:#F0F0F0;border:1px solid #D0D0D0;overflow:hidden;}");
style.Add(".label{color:#606060;font-weight:bold;}");
style.Add("</style>");
return style.Concat("\n");
}
//-------------------------------------------------------------------
// C o n t r o l A c t i v i t y
//-------------------------------------------------------------------
protected override void SetControlActivity ()
{
SetControlsReadOnly();
}
protected override void SetControlsReadOnly ()
{
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,23 @@
namespace Sarand.PatientMgr.Win.Forms.TabPages
{
partial class SpmTabPage_Department
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}
@@ -0,0 +1,240 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Sarand.PatientMgr.Win.Forms.Base;
using Sarand.PatientMgr.Core.Bus;
using Sarand.Core.Base;
using Sarand.PatientMgr.Win.Forms.Panels;
using Sarand.Win.Forms.UpdateLog;
using Sarand.Win.Forms.Controls;
using Sarand.PatientMgr.Win.Forms.Maint;
using Sarand.PatientMgr.Core.App;
using Sarand.Core.Bus;
using Sarand.Win.Forms.Utils;
namespace Sarand.PatientMgr.Win.Forms.TabPages
{
//=======================================================================
public partial class SpmTabPage_Department : SpmTabPage
{
//-------------------------------------------------------------------
// Configuration.
public enum PanelType
{
Unknown = 0,
// Department properties.
Notes,
// Department list.
Theatres,
Clinics,
Wards,
// Common.
Config,
Updates,
}
public new class Config : SpmTabPage.Config
{
/// <summary>Department form hosting the tab control.</summary>
public SpmForm_Department DepartmentForm { get; set; } = null;
/// <summary>Panels to display on this tab page.</summary>
public List<PanelType> PanelTypes { get; } = new List<PanelType>();
/// <summary>Number of panels on this tab page.</summary>
public override int PanelCount { get { return PanelTypes.Count; } }
}
//-------------------------------------------------------------------
// Data members.
private Config config = new Config();
private SpmPanel_Facilities panelTheatres = null;
private SpmPanel_Facilities panelWards = null;
private SpmPanel_Facilities panelClinics = null;
private SaPanel_UpdateLog panelUpdates = null;
//-------------------------------------------------------------------
// Construction.
public SpmTabPage_Department (Config config) : base(config)
{
this.config = config;
InitializeComponent();
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null) components.Dispose();
}
base.Dispose(disposing);
}
//-------------------------------------------------------------------
// Properties.
/// <summary>Panels to display on this tab page.</summary>
public List<PanelType> PanelTypes { get { return config.PanelTypes; } }
//-------------------------------------------------------------------
// Initialisation.
protected override void OnCreateControl()
{
base.OnCreateControl();
if (this.IsDesignerHosted()) return;
// Configure page.
// Initial panels.
List<SacsPanel> panels = new List<SacsPanel>();
foreach (var panelType in config.PanelTypes)
{
SacsPanel panel = null;
switch (panelType)
{
case PanelType.Theatres:
{
SpmPanel_Facilities.Config configPanel = new SpmPanel_Facilities.Config();
configPanel.Mode = SpmPanel_Facilities.PanelMode.Maintain;
configPanel.FacilityType = Spm.FacilityType.Theatre;
panelTheatres = new SpmPanel_Facilities(configPanel);
panel = panelTheatres;
panel.SizeChanged += Panel_Resize;
break;
}
case PanelType.Clinics:
{
SpmPanel_Facilities.Config configPanel = new SpmPanel_Facilities.Config();
configPanel.Mode = SpmPanel_Facilities.PanelMode.Maintain;
configPanel.FacilityType = Spm.FacilityType.Clinic;
panelClinics = new SpmPanel_Facilities(configPanel);
panel = panelClinics;
panel.SizeChanged += Panel_Resize;
break;
}
case PanelType.Wards:
{
SpmPanel_Facilities.Config configPanel = new SpmPanel_Facilities.Config();
configPanel.Mode = SpmPanel_Facilities.PanelMode.Maintain;
configPanel.FacilityType = Spm.FacilityType.Ward;
panelWards = new SpmPanel_Facilities(configPanel);
panel = panelWards;
panel.SizeChanged += Panel_Resize;
break;
}
case PanelType.Updates:
{
SaPanel_UpdateLog.Config configPanel = new SaPanel_UpdateLog.Config();
configPanel.UpdateLogConsole = UpdateLogConsole;
panelUpdates = new SaPanel_UpdateLog();
panelUpdates.SetConfig(configPanel);
panel = panelUpdates;
panel.SizeChanged += Panel_Resize;
break;
}
}
if (panel != null)
panels.Add(panel);
else Logger.Warn(GetType().Name + ".OnCreateControl Panel type not supported: " + panelType.ToString());
}
AddPanelsToPage(panels);
// Complete panel initialisation.
SetControlsReadOnly();
SetControlActivity();
}
//-------------------------------------------------------------------
// P a g e I n t e r f a c e
//-------------------------------------------------------------------
//-------------------------------------------------------------------
// P o p u l a t i o n
//-------------------------------------------------------------------
public void PopulateToControls(SpmDepartment.Data data)
{
if (panelTheatres != null)
panelTheatres.DepartmentId = data.Id;
if (panelClinics != null)
panelClinics.DepartmentId = data.Id;
if (panelWards != null)
panelWards.DepartmentId = data.Id;
if (panelUpdates != null)
panelUpdates.ItemId = new ItemId((short)Spm.DataItemType.Department, data.Id);
}
public bool IsDataValid(SpmDepartment.Data data)
{
return true;
}
public void PopulateFromControls(SpmDepartment.Data data)
{
}
public bool UpdateAssociatedData(SpmDepartment.Data data)
{
return true;
}
//-------------------------------------------------------------------
// C o n t r o l A c t i v i t y
//-------------------------------------------------------------------
protected void SetControlActivity()
{
if (panelUpdates != null)
panelUpdates.Enabled = Enabled;
}
public bool IsFieldReadOnly(SpmDbDfn.ColumnIdx col)
{
return false;
}
protected void SetControlsReadOnly()
{
return;
}
//-------------------------------------------------------------------
// P a n e l E v e n t s
//-------------------------------------------------------------------
private void panel_ItemCreated(object sender, SpmPanel_Items.ItemModifiedEventArgs e)
{
InvokeItemCreatedEvent((short)e.ItemType, e.ItemId);
}
private void panel_ItemUpdated(object sender, SpmPanel_Items.ItemModifiedEventArgs e)
{
InvokeItemUpdatedEvent((short)e.ItemType, e.ItemId);
}
private void panel_ItemDeleted(object sender, SpmPanel_Items.ItemModifiedEventArgs e)
{
InvokeItemDeletedEvent((short)e.ItemType, e.ItemId);
}
//-------------------------------------------------------------------
// P a n e l S i z e a n d P o s i t i o n
//-------------------------------------------------------------------
protected override void PositionControls()
{
base.PositionControls();
Rectangle clientRect = ClientRectangle;
}
//-------------------------------------------------------------------
}
//=======================================================================
public static class SpmTabPage_DepartmentList
{
public static void PopulateToControls (this List<SpmTabPage_Department> tabPages, SpmDepartment.Data data)
{
foreach (SpmTabPage_Department tabPage in tabPages)
tabPage.PopulateToControls(data);
}
public static void PopulateFromControls (this List<SpmTabPage_Department> tabPages, SpmDepartment.Data data)
{
foreach (SpmTabPage_Department tabPage in tabPages)
tabPage.PopulateFromControls(data);
}
}
//=======================================================================
}
@@ -1,4 +1,5 @@
using Sarand.Core.Bus;
using Sarand.Core.UpdateLog;
using Sarand.PatientMgr.Core.App;
using Sarand.PatientMgr.Win.Dbas.Consoles;
using Sarand.PatientMgr.Win.Forms.App;
@@ -25,6 +26,10 @@ namespace Sarand.PatientMgr.App.Consoles
{
}
//-------------------------------------------------------------------
// Properties.
public override SaUpdateLogConsole UpdateLogConsole { get { return SpmGlobals.Application.GetUpdateLogConsole(SessionContext); } }
//-------------------------------------------------------------------
// Security events.
protected override bool OnLogin (SysId userId)
+18 -3
View File
@@ -16,11 +16,12 @@
private void InitializeComponent ()
{
this.buttonGenerateDbDfn = new System.Windows.Forms.Button();
this.panelScheduleControl = new Sarand.PatientMgr.App.Panels.SpmPanel_ScheduleControl();
this.SuspendLayout();
//
// buttonGenerateDbDfn
//
this.buttonGenerateDbDfn.Location = new System.Drawing.Point(58, 63);
this.buttonGenerateDbDfn.Location = new System.Drawing.Point(271, 104);
this.buttonGenerateDbDfn.Name = "buttonGenerateDbDfn";
this.buttonGenerateDbDfn.Size = new System.Drawing.Size(100, 23);
this.buttonGenerateDbDfn.TabIndex = 0;
@@ -28,14 +29,27 @@
this.buttonGenerateDbDfn.UseVisualStyleBackColor = true;
this.buttonGenerateDbDfn.Click += new System.EventHandler(this.buttonGenerateDbDfn_Click);
//
// panelScheduleControl
//
this.panelScheduleControl.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.panelScheduleControl.Location = new System.Drawing.Point(9, 9);
this.panelScheduleControl.MainForm = null;
this.panelScheduleControl.Margin = new System.Windows.Forms.Padding(0);
this.panelScheduleControl.Name = "panelScheduleControl";
this.panelScheduleControl.Size = new System.Drawing.Size(147, 543);
this.panelScheduleControl.TabIndex = 1;
//
// SaPatientMgrForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.ClientSize = new System.Drawing.Size(784, 561);
this.Controls.Add(this.panelScheduleControl);
this.Controls.Add(this.buttonGenerateDbDfn);
this.MinimumSize = new System.Drawing.Size(800, 600);
this.Name = "SaPatientMgrForm";
this.Text = "Form1";
this.Text = "Sarand Patient Manager";
this.ResumeLayout(false);
}
@@ -43,6 +57,7 @@
#endregion
private System.Windows.Forms.Button buttonGenerateDbDfn;
private Panels.SpmPanel_ScheduleControl panelScheduleControl;
}
}
@@ -64,6 +64,10 @@ namespace Sarand.PatientMgr.App.Forms
base.OnCreateControl();
if (this.IsDesignerHosted()) return;
// Configure schedule control panel.
panelScheduleControl.MainForm = this;
SetControlActivity();
}
protected override void OnShown (EventArgs e)
{
@@ -92,6 +96,11 @@ namespace Sarand.PatientMgr.App.Forms
else MessageBox.Show("Database definition not generated.\n\n"+result.ErrorMessage, "Database Definition", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
private void spmPanel_ScheduleControl1_Load (object sender, EventArgs e)
{
}
//-------------------------------------------------------------------
}
//=======================================================================
@@ -0,0 +1,84 @@
namespace Sarand.PatientMgr.App.Panels
{
partial class SpmPanel_ScheduleControl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent ()
{
this.buttonConfig = new Sarand.Win.Forms.Controls.SacsButton();
this.buttonMinimise = new Sarand.Win.Forms.Controls.SacsButton();
this.buttonExit = new Sarand.Win.Forms.Controls.SacsButton();
this.buttonSetup = new Sarand.Win.Forms.Controls.SacsButton();
this.SuspendLayout();
//
// buttonConfig
//
this.buttonConfig.Location = new System.Drawing.Point(42, 195);
this.buttonConfig.Name = "buttonConfig";
this.buttonConfig.Size = new System.Drawing.Size(75, 23);
this.buttonConfig.TabIndex = 0;
this.buttonConfig.Text = "Config";
this.buttonConfig.UseVisualStyleBackColor = true;
this.buttonConfig.Click += new System.EventHandler(this.buttonConfig_Click);
//
// buttonMinimise
//
this.buttonMinimise.Location = new System.Drawing.Point(42, 253);
this.buttonMinimise.Name = "buttonMinimise";
this.buttonMinimise.Size = new System.Drawing.Size(75, 23);
this.buttonMinimise.TabIndex = 1;
this.buttonMinimise.Text = "Minimise";
this.buttonMinimise.UseVisualStyleBackColor = true;
//
// buttonExit
//
this.buttonExit.Location = new System.Drawing.Point(42, 282);
this.buttonExit.Name = "buttonExit";
this.buttonExit.Size = new System.Drawing.Size(75, 23);
this.buttonExit.TabIndex = 2;
this.buttonExit.Text = "Exit";
this.buttonExit.UseVisualStyleBackColor = true;
this.buttonExit.Click += new System.EventHandler(this.buttonExit_Click);
//
// buttonSetup
//
this.buttonSetup.Location = new System.Drawing.Point(42, 3);
this.buttonSetup.Name = "buttonSetup";
this.buttonSetup.Size = new System.Drawing.Size(75, 23);
this.buttonSetup.TabIndex = 3;
this.buttonSetup.Text = "Setup";
this.buttonSetup.UseVisualStyleBackColor = true;
//
// SpmPanel_ScheduleControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.buttonSetup);
this.Controls.Add(this.buttonExit);
this.Controls.Add(this.buttonMinimise);
this.Controls.Add(this.buttonConfig);
this.Margin = new System.Windows.Forms.Padding(0);
this.Name = "SpmPanel_ScheduleControl";
this.Size = new System.Drawing.Size(151, 358);
this.ResumeLayout(false);
}
#endregion
private Sarand.Win.Forms.Controls.SacsButton buttonConfig;
private Sarand.Win.Forms.Controls.SacsButton buttonMinimise;
private Sarand.Win.Forms.Controls.SacsButton buttonExit;
private Sarand.Win.Forms.Controls.SacsButton buttonSetup;
}
}
@@ -0,0 +1,94 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Sarand.Win.Forms.Utils;
using Sarand.PatientMgr.Win.Forms.Base;
using Sarand.PatientMgr.App.Forms;
using Sarand.PatientMgr.Win.Forms.App;
using Sarand.PatientMgr.Win.Forms.Config;
namespace Sarand.PatientMgr.App.Panels
{
//=======================================================================
public partial class SpmPanel_ScheduleControl : SpmPanel
{
//-------------------------------------------------------------------
// Configuration.
public new class Config : SpmPanel.Config
{
}
//-------------------------------------------------------------------
// Data members.
private Config config = null;
//-------------------------------------------------------------------
// Construction.
public SpmPanel_ScheduleControl ()
{
InitializeComponent();
}
protected override void Dispose (bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
//-------------------------------------------------------------------
// Properties.
public SaPatientMgrForm MainForm { get; set; }
//-------------------------------------------------------------------
// I n i t i a l i s a t i o n
//-------------------------------------------------------------------
protected override void OnCreateControl ()
{
base.OnCreateControl();
if (this.IsDesignerHosted()) return;
SetControlActivity();
}
//-------------------------------------------------------------------
// C o n t r o l A c t i v i t y
//-------------------------------------------------------------------
protected override void SetControlActivity ()
{
SetControlsReadOnly();
}
protected override void SetControlsReadOnly ()
{
}
//-------------------------------------------------------------------
// P a n e l E v e n t s
//-------------------------------------------------------------------
private void buttonConfig_Click (object sender, EventArgs e)
{
SpmForm_Config.Config formConfig = new SpmForm_Config.Config();
using (SpmForm_Config form = new SpmForm_Config(formConfig))
{
if (form.ShowDialog() == DialogResult.OK)
{
// ToDo Refresh schedule view.
}
}
}
private void buttonExit_Click (object sender, EventArgs e)
{
MainForm.Close();
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+5
View File
@@ -57,6 +57,9 @@ namespace Sarand.PatientMgr.App
SessionContext = new SpmSessionContext_Desktop(0, Site);
InitGlobals();
//SpmGlobals.DbConsole.VerifyDatabaseSchema();
// Login the current windows user.
SpmGlobals.Application.GetSecurityConsole(SessionContext).LoginAuthenticatedUser();
}
public void Dispose ()
{
@@ -120,6 +123,8 @@ namespace Sarand.PatientMgr.App
//-------------------------------------------------------------------
private void DeinitGlobals ()
{
if (SpmGlobals_Win.SessionProfile != null)
SpmGlobals_Win.SessionProfile.StoreProperties();
SpmGlobals.clear();
}
+13 -1
View File
@@ -40,11 +40,23 @@ namespace Sarand.PatientMgr.App
{
return Database;
}
public override bool TableExists (SpmSessionContext sessionContext, SpmDbDfn.TableIdx tableIdx)
{
SacsDatabase database = GetDatabase(sessionContext) as SacsDatabase;
if (database != null)
{
String tablename = SpmDbDfn.GetTableName(tableIdx, false);
DbDfnTable table = database.GetTableDfn(tablename);
if (table != null)
return true;
}
return false;
}
public override bool ColumnExists (SpmSessionContext sessionContext, SpmDbDfn.ColumnIdx columnIdx)
{
ISacsDatabase database = GetDatabase(sessionContext);
if (database != null)
return database.ColumnExists(SpmDbDfn.GetTableName(SpmDbDfn.GetTableForColumn(columnIdx)), SpmDbDfn.GetColumnName(columnIdx));
return database.ColumnExists(SpmDbDfn.GetTableName(SpmDbDfn.GetTableForColumn(columnIdx),false), SpmDbDfn.GetColumnName(columnIdx,false));
return false;
}
+10 -3
View File
@@ -58,6 +58,12 @@
<Compile Include="App\Forms\SaPatientMgrForm.Designer.cs">
<DependentUpon>SaPatientMgrForm.cs</DependentUpon>
</Compile>
<Compile Include="App\Panels\SpmPanel_ScheduleControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="App\Panels\SpmPanel_ScheduleControl.Designer.cs">
<DependentUpon>SpmPanel_ScheduleControl.cs</DependentUpon>
</Compile>
<Compile Include="App\Program.cs" />
<Compile Include="App\SaPatientMgrApp.cs" />
<Compile Include="App\SpmApplication_Desktop.cs" />
@@ -67,6 +73,9 @@
<EmbeddedResource Include="App\Forms\SaPatientMgrForm.resx">
<DependentUpon>SaPatientMgrForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="App\Panels\SpmPanel_ScheduleControl.resx">
<DependentUpon>SpmPanel_ScheduleControl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
@@ -90,9 +99,7 @@
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Folder Include="App\Panels\" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<ProjectReference Include="..\..\..\Common-C#\Workspace\SacsCoreBase\SacsCoreBase.csproj">
<Project>{7528f88e-a24d-4d6b-be6c-9d5fb14f0cb5}</Project>