Files
2019-06-04 09:06:12 +01:00

198 lines
9.0 KiB
C#

using Sarand.PatientMgr.Core.Mgr;
using Sarand.Core.App;
using Sarand.Core.Base;
using System;
using System.Collections.Generic;
using System.Text;
namespace Sarand.PatientMgr.Core.App
{
//=======================================================================
public abstract partial class SpmSystem : SacsSystem
{
//-------------------------------------------------------------------
// Data members.
private static List<TypeCodeDesc> codeTypes = new List<TypeCodeDesc>();
// System Code types.
private static List<TypeCodeDesc> sites = new List<TypeCodeDesc>();
private static List<TypeCodeDesc> facilityTypes = new List<TypeCodeDesc>();
private static List<TypeCodeDesc> scheduleTypes = new List<TypeCodeDesc>();
private static List<TypeCodeDesc> employeeRoles = new List<TypeCodeDesc>();
private static List<TypeCodeDesc> genders = new List<TypeCodeDesc>();
private static List<TypeCodeDesc> patientDataSources = new List<TypeCodeDesc>();
private static List<TypeCodeDesc> templateMapTypes = new List<TypeCodeDesc>();
private static List<TypeCodeDesc> sessionModels = new List<TypeCodeDesc>();
private static List<TypeCodeDesc> resourceCategories = new List<TypeCodeDesc>();
private static List<TypeCodeDesc> theatreSessionTypes = new List<TypeCodeDesc>();
private static List<TypeCodeDesc> clinicSessionTypes = new List<TypeCodeDesc>();
private static List<TypeCodeDesc> wardResourceTypes = new List<TypeCodeDesc>();
private static List<TypeCodeDesc> resourceCapacityTypes = new List<TypeCodeDesc>();
private static List<TypeCodeDesc> resourceLoadingTypes = new List<TypeCodeDesc>();
private static List<TypeCodeDesc> scheduleFreezeTypes = new List<TypeCodeDesc>();
private static List<TypeCodeDesc> templateDataTypes = new List<TypeCodeDesc>();
private static List<TypeCodeDesc> procedureComplexities = new List<TypeCodeDesc>();
private static List<TypeCodeDesc> admissionOccupancies = new List<TypeCodeDesc>();
private static List<TypeCodeDesc> admissionActionTypes = new List<TypeCodeDesc>();
private static List<TypeCodeDesc> admissionCancelTypes = new List<TypeCodeDesc>();
private static List<TypeCodeDesc> attendanceTypes = new List<TypeCodeDesc>();
private static List<TypeCodeDesc> attendanceStatuses = new List<TypeCodeDesc>();
private static List<TypeCodeDesc> wardPeriodLengths = new List<TypeCodeDesc>();
private static List<TypeCodeDesc> wardResourceDisplays = new List<TypeCodeDesc>();
private static List<TypeCodeDesc> wardHighlightings = new List<TypeCodeDesc>();
private static List<TypeCodeDesc> reportSpacings = new List<TypeCodeDesc>();
//-------------------------------------------------------------------
// Construction - use derived objects.
protected SpmSystem (PropertySet properties)
{
// Configure extended logging.
extendedLoggingOptions = StringList.Split(properties.GetPropertyValue("Logging", "ExtendedLogging"));
}
//-------------------------------------------------------------------
// Application definitions.
public static String GetCopyrightNotice (bool html = false)
{
return (html ? "&copy; " : "(c) ") + "2002- " + DateTime.Today.Year + " Sarand Ltd";
}
public static bool IsSysAdminSession ()
{
// Dev mode.
if (IsDevHost()) return true;
// Production servers.
if (UserName.ContainsCI("Sarand"))
{
if (ComputerName.EqualsCI("Norman")) return true;
}
// Development.
if (ComputerName.ContainsCI("Sarand")) return true;
return false;
}
//-------------------------------------------------------------------
// S y s t e m C o d e s
//-------------------------------------------------------------------
public static List<TypeCodeDesc> GetCodesOfType (Spm.SystemCode systemCode)
{
// Lists are cloned to avoid modifications to the internal static lists.
switch (systemCode)
{
//-----------------------------------------------------------
case Spm.SystemCode.Site:
return new List<TypeCodeDesc>(sites);
case Spm.SystemCode.FacilityType:
return new List<TypeCodeDesc>(facilityTypes);
case Spm.SystemCode.ScheduleType:
return new List<TypeCodeDesc>(scheduleTypes);
case Spm.SystemCode.EmployeeRole:
return new List<TypeCodeDesc>(employeeRoles);
case Spm.SystemCode.Gender:
return new List<TypeCodeDesc>(genders);
case Spm.SystemCode.PatientDataSource:
return new List<TypeCodeDesc>(patientDataSources);
case Spm.SystemCode.TemplateMapType:
return new List<TypeCodeDesc>(templateMapTypes);
case Spm.SystemCode.SessionModel:
return new List<TypeCodeDesc>(sessionModels);
case Spm.SystemCode.ResourceCategory:
return new List<TypeCodeDesc>(resourceCategories);
case Spm.SystemCode.TheatreSessionType:
return new List<TypeCodeDesc>(theatreSessionTypes);
case Spm.SystemCode.ClinicSessionType:
return new List<TypeCodeDesc>(clinicSessionTypes);
case Spm.SystemCode.WardResourceType:
return new List<TypeCodeDesc>(wardResourceTypes);
case Spm.SystemCode.ResourceCapacityType:
return new List<TypeCodeDesc>(resourceCapacityTypes);
case Spm.SystemCode.ResourceLoadingType:
return new List<TypeCodeDesc>(resourceLoadingTypes);
case Spm.SystemCode.ScheduleFreezeType:
return new List<TypeCodeDesc>(scheduleFreezeTypes);
case Spm.SystemCode.TemplateDataType:
return new List<TypeCodeDesc>(templateDataTypes);
case Spm.SystemCode.ProcedureComplexity:
return new List<TypeCodeDesc>(procedureComplexities);
case Spm.SystemCode.AdmissionOccupancy:
return new List<TypeCodeDesc>(admissionOccupancies);
case Spm.SystemCode.AdmissionActionType:
return new List<TypeCodeDesc>(admissionActionTypes);
case Spm.SystemCode.AdmissionCancelType:
return new List<TypeCodeDesc>(admissionCancelTypes);
case Spm.SystemCode.AttendanceType:
return new List<TypeCodeDesc>(attendanceTypes);
case Spm.SystemCode.AttendanceStatus:
return new List<TypeCodeDesc>(attendanceStatuses);
case Spm.SystemCode.WardPeriodLength:
return new List<TypeCodeDesc>(wardPeriodLengths);
case Spm.SystemCode.WardResourceDisplay:
return new List<TypeCodeDesc>(wardResourceDisplays);
case Spm.SystemCode.WardHighlighting:
return new List<TypeCodeDesc>(wardHighlightings);
case Spm.SystemCode.ReportSpacing:
return new List<TypeCodeDesc>(reportSpacings);
default:
Logger.Warn("SpmSystem.GetCodesOfType Invalid code type: " + systemCode.ToString());
break;
}
//---------------------------------------------------------------
return null;
}
//-------------------------------------------------------------------
// System code utilities.
public static Spm.Site GetSiteForCode (String siteCode)
{
return (Spm.Site)sites.GetTypeForCode(siteCode);
}
public static String GetSiteCode (Spm.Site site)
{
return sites.GetCodeForType((int)site);
}
public static String GetSiteDesc (Spm.Site site)
{
return sites.GetDescForType((int)site, site.ToString());
}
//-------------------------------------------------------------------
// D a t a M a n a g e r s
//-------------------------------------------------------------------
public abstract SpmAdmissionMgr CreateAdmissionMgr (SpmUserContext userContext);
public abstract SpmDepartmentMgr CreateDepartmentMgr(SpmUserContext userContext);
public abstract SpmInstitutionMgr CreateInstitutionMgr(SpmUserContext userContext);
//-------------------------------------------------------------------
// E x t e n d e d L o g g i n g
//-------------------------------------------------------------------
// Extended logging options.
public enum ExtendedLogginOption
{
SecurityProfile,
DbQueryExecution,
Printing,
ServiceRequests,
}
public static readonly String ExtendedLogging_SecurityProfile = "SecurityProfile";
public static readonly String ExtendedLogging_DbQueryExecution = "DbQueryExecution";
public static readonly String ExtendedLogging_Printing = "Printing";
public static readonly String ExtendedLogging_ServiceRequests = "ServiceRequests";
private List<String> extendedLoggingOptions;
//-------------------------------------------------------------------
public bool IsExtendedLogging (ExtendedLogginOption extendedLoggingOption)
{
if (extendedLoggingOptions == null) return false;
if (extendedLoggingOption == ExtendedLogginOption.SecurityProfile)
return extendedLoggingOptions.ContainsCI(ExtendedLogging_SecurityProfile);
if (extendedLoggingOption == ExtendedLogginOption.DbQueryExecution)
return extendedLoggingOptions.ContainsCI(ExtendedLogging_DbQueryExecution);
if (extendedLoggingOption == ExtendedLogginOption.Printing)
return extendedLoggingOptions.ContainsCI(ExtendedLogging_Printing);
if (extendedLoggingOption == ExtendedLogginOption.ServiceRequests)
return extendedLoggingOptions.ContainsCI(ExtendedLogging_ServiceRequests);
return false;
}
//-------------------------------------------------------------------
}
//=======================================================================
}