SB 04-Jun-2019
This commit is contained in:
@@ -157,6 +157,8 @@ namespace Sarand.PatientMgr.Core.App
|
|||||||
// D a t a M a n a g e r s
|
// D a t a M a n a g e r s
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
public abstract SpmAdmissionMgr CreateAdmissionMgr (SpmUserContext userContext);
|
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
|
// E x t e n d e d L o g g i n g
|
||||||
|
|||||||
@@ -147,6 +147,29 @@ namespace Sarand.PatientMgr.Core.Bus
|
|||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Utilities.
|
// Utilities.
|
||||||
|
|
||||||
|
// Determine which action types can occur more than once against an admission.
|
||||||
|
public bool IsRestrictedToSingleOccurrence(Spm.AdmissionActionType type)
|
||||||
|
{
|
||||||
|
// 'Repeat admission' can only occur once.
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case Spm.AdmissionActionType.RepeatAdmission:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsRestrictedToSingleRequired(Spm.AdmissionActionType type)
|
||||||
|
{
|
||||||
|
// Everything apart from 'General'.
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case Spm.AdmissionActionType.General:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Properties.
|
// Properties.
|
||||||
public Data GetData() { return data.Clone(); }
|
public Data GetData() { return data.Clone(); }
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ namespace Sarand.PatientMgr.Core.Bus
|
|||||||
public DateTime ApplicationFrom
|
public DateTime ApplicationFrom
|
||||||
{
|
{
|
||||||
get { return data.ApplicationFrom; }
|
get { return data.ApplicationFrom; }
|
||||||
set { CheckChanged(data.ApplicationFrom, value); data.ApplicationFrom = value; }
|
set { CheckChanged(data.ApplicationFrom, value); data.ApplicationFrom = value; }dd
|
||||||
}
|
}
|
||||||
public DateTime ApplicationTo
|
public DateTime ApplicationTo
|
||||||
{
|
{
|
||||||
@@ -171,6 +171,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
|
// 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();
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// P a r a m s
|
// P a r a m s
|
||||||
|
|||||||
@@ -186,6 +186,7 @@ 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
|
// A s s o c i a t e d D a t a E l e m e n t s
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
|
public abstract bool HasRoles();
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// P a r a m s
|
// P a r a m s
|
||||||
|
|||||||
@@ -159,6 +159,7 @@ 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
|
// A s s o c i a t e d D a t a E l e m e n t s
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
|
public abstract bool HasAdmissionRoles();
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// P a r a m s
|
// P a r a m s
|
||||||
|
|||||||
@@ -135,10 +135,24 @@ namespace Sarand.PatientMgr.Core.Bus
|
|||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Utilities.
|
// Utilities.
|
||||||
|
public Spm.WardAdmissionMode GetBookingMode()
|
||||||
|
{
|
||||||
|
// Based on 'Booking to Facility' flag etc.
|
||||||
|
if (FacilityType == Spm.FacilityType.Ward && IsBookingToFacility)
|
||||||
|
return Spm.WardAdmissionMode.ByWard;
|
||||||
|
return Spm.WardAdmissionMode.ByResource;
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
public bool IsTemplateRequiredForBooking()
|
||||||
// Properties.
|
{
|
||||||
public Data GetData() { return data.Clone(); }
|
if (GetBookingMode() == Spm.WardAdmissionMode.ByWard)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
// Properties.
|
||||||
|
public Data GetData() { return data.Clone(); }
|
||||||
public void SetData(Data data)
|
public void SetData(Data data)
|
||||||
{
|
{
|
||||||
String fn = GetType().Name + ".SetData";
|
String fn = GetType().Name + ".SetData";
|
||||||
@@ -208,7 +222,7 @@ namespace Sarand.PatientMgr.Core.Bus
|
|||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Flags.
|
// Flags.
|
||||||
public bool BookingToFacility
|
public bool IsBookingToFacility
|
||||||
{
|
{
|
||||||
get { return GetFlag(Flag_BookingToFacility); }
|
get { return GetFlag(Flag_BookingToFacility); }
|
||||||
set { SetFlag(Flag_BookingToFacility, value); }
|
set { SetFlag(Flag_BookingToFacility, value); }
|
||||||
@@ -217,6 +231,15 @@ 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
|
// A s s o c i a t e d D a t a E l e m e n t s
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
|
public abstract bool HasTemplates(); // eg. Slots.
|
||||||
|
public abstract bool HasSessions();
|
||||||
|
public abstract bool HasSessionsBefore(DateTime target, ref DateTime? earliest, ref DateTime? latest);
|
||||||
|
public abstract bool HasSessionsAfter(DateTime target, ref DateTime? earliest, ref DateTime? latest);
|
||||||
|
public abstract bool HasSessions(DateTime before, DateTime after, ref DateTime? earliest, ref DateTime? latest);
|
||||||
|
public abstract bool HasAdmissions(Spm.AdmissionCancelType admissionCancelType);
|
||||||
|
public abstract bool HasAdmissionsBefore(DateTime target, Spm.AdmissionCancelType admissionCancelType, ref DateTime? earliest, ref DateTime? latest);
|
||||||
|
public abstract bool HasAdmissionsAfter(DateTime target, Spm.AdmissionCancelType admissionCancelType, ref DateTime? earliest, ref DateTime? latest);
|
||||||
|
public abstract bool HasAdmissions(DateTime before, DateTime after, Spm.AdmissionCancelType admissionCancelType, ref DateTime? earliest, ref DateTime? latest);
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// P a r a m s
|
// P a r a m s
|
||||||
|
|||||||
@@ -341,14 +341,22 @@ namespace Sarand.PatientMgr.Core.Bus
|
|||||||
set { CheckChanged(data.ApplicationTo, value); data.ApplicationTo = value; }
|
set { CheckChanged(data.ApplicationTo, value); data.ApplicationTo = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Flags.
|
// Flags.
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// A s s o c i a t e d D a t a E l e m e n t s
|
// A s s o c i a t e d D a t a E l e m e n t s
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
|
public abstract bool HasDataItems(); // eg. Slots.
|
||||||
|
public abstract bool HasSessions();
|
||||||
|
public abstract bool HasSessionsBefore(DateTime target, ref DateTime? earliest, ref DateTime? latest);
|
||||||
|
public abstract bool HasSessionsAfter(DateTime target, ref DateTime? earliest, ref DateTime? latest);
|
||||||
|
public abstract bool HasSessions(DateTime before, DateTime after, ref DateTime? earliest, ref DateTime? latest);
|
||||||
|
public abstract bool HasAdmissions(Spm.AdmissionCancelType admissionCancelType);
|
||||||
|
public abstract bool HasAdmissionsBefore(DateTime target, Spm.AdmissionCancelType admissionCancelType, ref DateTime? earliest, ref DateTime? latest);
|
||||||
|
public abstract bool HasAdmissionsAfter(DateTime target, Spm.AdmissionCancelType admissionCancelType, ref DateTime? earliest, ref DateTime? latest);
|
||||||
|
public abstract bool HasAdmissions(DateTime before, DateTime after, Spm.AdmissionCancelType admissionCancelType, ref DateTime? earliest, ref DateTime? latest);
|
||||||
|
public abstract long GetSessionComplexityCount(DateTime admission, String complexity,SysId admissionExcludeId);
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// P a r a m s
|
// P a r a m s
|
||||||
|
|||||||
@@ -138,6 +138,8 @@ 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
|
// A s s o c i a t e d D a t a E l e m e n t s
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
|
public abstract bool HasProcedures();
|
||||||
|
public abstract long GetProcedureCount(String filter = null);
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// P a r a m s
|
// P a r a m s
|
||||||
|
|||||||
@@ -215,6 +215,7 @@ 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
|
// A s s o c i a t e d D a t a E l e m e n t s
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
|
public abstract bool HasAdmission();
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// P a r a m s
|
// P a r a m s
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ 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
|
// A s s o c i a t e d D a t a E l e m e n t s
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
|
public abstract bool HasAdmission();
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// P a r a m s
|
// P a r a m s
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Sarand.Core.Base;
|
using Sarand.Core.Base;
|
||||||
using Sarand.Core.Bus;
|
using Sarand.Core.Bus;
|
||||||
|
using Sarand.PatientMgr.Core.App;
|
||||||
|
|
||||||
namespace Sarand.PatientMgr.Core.Bus
|
namespace Sarand.PatientMgr.Core.Bus
|
||||||
{
|
{
|
||||||
@@ -32,8 +33,18 @@ namespace Sarand.PatientMgr.Core.Bus
|
|||||||
{
|
{
|
||||||
//Status = TemplateDataStatus;
|
//Status = TemplateDataStatus;
|
||||||
}
|
}
|
||||||
|
public SysId FacilityTemplateId { get; set; }
|
||||||
|
public Spm.TemplateDataType TemplateDataType { get; set; }
|
||||||
|
public short Seq { get; set; }
|
||||||
|
public String Identifier { get; set; }
|
||||||
|
public String Value { get; set; }
|
||||||
internal void PopulateFrom(Data data)
|
internal void PopulateFrom(Data data)
|
||||||
{
|
{
|
||||||
|
FacilityTemplateId = FacilityTemplateId;
|
||||||
|
TemplateDataType = TemplateDataType;
|
||||||
|
Seq = Seq;
|
||||||
|
Identifier = Identifier;
|
||||||
|
Value = Value;
|
||||||
base.PopulateFrom(data);
|
base.PopulateFrom(data);
|
||||||
}
|
}
|
||||||
public Data Clone()
|
public Data Clone()
|
||||||
@@ -47,7 +58,11 @@ namespace Sarand.PatientMgr.Core.Bus
|
|||||||
// ErrField.
|
// ErrField.
|
||||||
public new class ErrField : SacsHierarchyItem.ErrField
|
public new class ErrField : SacsHierarchyItem.ErrField
|
||||||
{
|
{
|
||||||
|
public ValidValue FacilityTemplateId { get; set; } = ValidValue.Valid;
|
||||||
|
public ValidValue TemplateDataType { get; set; } = ValidValue.Valid;
|
||||||
|
public ValidValue Seq { get; set; } = ValidValue.Valid;
|
||||||
|
public ValidValue Identifier { get; set; } = ValidValue.Valid;
|
||||||
|
public ValidValue Value { get; set; } = ValidValue.Valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
@@ -99,6 +114,31 @@ namespace Sarand.PatientMgr.Core.Bus
|
|||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Attributes.
|
// Attributes.
|
||||||
|
public SysId FacilityTemplateId
|
||||||
|
{
|
||||||
|
get { return data.FacilityTemplateId; }
|
||||||
|
set { CheckChanged(data.FacilityTemplateId, value); data.FacilityTemplateId = value; }
|
||||||
|
}
|
||||||
|
public Spm.TemplateDataType TemplateDataType
|
||||||
|
{
|
||||||
|
get { return data.TemplateDataType; }
|
||||||
|
set { CheckChanged((int)data.TemplateDataType, (int)value); data.TemplateDataType = value; }
|
||||||
|
}
|
||||||
|
public short Seq
|
||||||
|
{
|
||||||
|
get { return data.Seq; }
|
||||||
|
set { CheckChanged(data.Seq, value); data.Seq = value; }
|
||||||
|
}
|
||||||
|
public String Identifier
|
||||||
|
{
|
||||||
|
get { return data.Identifier; }
|
||||||
|
set { CheckChanged(data.Identifier, value); data.Identifier = value; }
|
||||||
|
}
|
||||||
|
public String Value
|
||||||
|
{
|
||||||
|
get { return data.Value; }
|
||||||
|
set { CheckChanged(data.Value, value); data.Value = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
@@ -123,7 +163,12 @@ namespace Sarand.PatientMgr.Core.Bus
|
|||||||
// List filtering.
|
// List filtering.
|
||||||
public List<SysId> IncludedIds { get; } = new List<SysId>();
|
public List<SysId> IncludedIds { get; } = new List<SysId>();
|
||||||
public List<SysId> ExcludedIds { get; } = new List<SysId>();
|
public List<SysId> ExcludedIds { get; } = new List<SysId>();
|
||||||
// ###.
|
// Template Data.
|
||||||
|
public SysId FacilityTemplateId { get; set; }
|
||||||
|
public Spm.TemplateDataType TemplateDataType { get; set; }
|
||||||
|
public short Seq { get; set; }
|
||||||
|
public String Identifier { get; set; }
|
||||||
|
public String Value { get; set; }
|
||||||
|
|
||||||
public StatusCat StatusCat { get; set; } = StatusCat.Any;
|
public StatusCat StatusCat { get; set; } = StatusCat.Any;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,7 @@
|
|||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Tests\Core\Base\DateTimeRef.cs" />
|
||||||
<Compile Include="UnitTest1.cs" />
|
<Compile Include="UnitTest1.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -57,9 +58,43 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Resources\" />
|
<Folder Include="Resources\" />
|
||||||
<Folder Include="Tests\Core\" />
|
<Folder Include="Tests\Core\App\" />
|
||||||
<Folder Include="Tests\Win\" />
|
<Folder Include="Tests\Win\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\..\Common-C#\Workspace\SacsCoreBase\SacsCoreBase.csproj">
|
||||||
|
<Project>{7528f88e-a24d-4d6b-be6c-9d5fb14f0cb5}</Project>
|
||||||
|
<Name>SacsCoreBase</Name>
|
||||||
|
</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>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\..\..\Common-C#\Workspace\SacsWinOffice\SacsWinOffice.csproj">
|
||||||
|
<Project>{e9106099-66b4-42db-af28-c34cf1aff2aa}</Project>
|
||||||
|
<Name>SacsWinOffice</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\SaPatMgrCore\SaPatMgrCore.csproj">
|
||||||
|
<Project>{57674a5e-b0f1-49ca-a56f-f8b8ca12fbf6}</Project>
|
||||||
|
<Name>SaPatMgrCore</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\SaPatMgrWinDbas\SaPatMgrWinDbas.csproj">
|
||||||
|
<Project>{9f5d8526-b4b9-457f-8dba-e6b79b938aa9}</Project>
|
||||||
|
<Name>SaPatMgrWinDbas</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\SaPatMgrWinForms\SaPatMgrWinForms.csproj">
|
||||||
|
<Project>{7601486b-9563-40bb-81f0-7b45d9f62d70}</Project>
|
||||||
|
<Name>SaPatMgrWinForms</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\SaPatMgrWinProcs\SaPatMgrWinProcs.csproj">
|
||||||
|
<Project>{ed6a8e47-67fb-42ca-9b6e-9095c427b64c}</Project>
|
||||||
|
<Name>SaPatMgrWinProcs</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
|
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
using Sarand.Core.Base;
|
||||||
|
|
||||||
|
namespace Sarand.PatientMgr.Tests.Core.Base
|
||||||
|
{
|
||||||
|
//=======================================================================
|
||||||
|
[TestClass]
|
||||||
|
public class DateTimeRef
|
||||||
|
{
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
[TestMethod]
|
||||||
|
public void DateTime_RefParam()
|
||||||
|
{
|
||||||
|
DateTime? value = new DateTime(2019, 6, 1);
|
||||||
|
Assert.AreEqual("1-Jun-2019", DateUtil.Format((DateTime)value,"d-MMM-yyyy"));
|
||||||
|
|
||||||
|
IncrementDate((DateTime)value, 1);
|
||||||
|
Assert.AreEqual("1-Jun-2019", DateUtil.Format((DateTime)value, "d-MMM-yyyy"));
|
||||||
|
|
||||||
|
IncrementDateRef(ref value, 1);
|
||||||
|
Assert.AreEqual("2-Jun-2019", DateUtil.Format((DateTime)value, "d-MMM-yyyy"));
|
||||||
|
|
||||||
|
DateTime? nullDate = null;
|
||||||
|
IncrementDateRef(ref nullDate, 1);
|
||||||
|
}
|
||||||
|
private void IncrementDate(DateTime value, int days)
|
||||||
|
{
|
||||||
|
value = DateUtil.IncrementDate(value, days);
|
||||||
|
}
|
||||||
|
private void IncrementDateRef(ref DateTime? value, int days)
|
||||||
|
{
|
||||||
|
if (value != null)
|
||||||
|
value = DateUtil.IncrementDate((DateTime)value, days);
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
}
|
||||||
@@ -44,6 +44,14 @@ namespace Sarand.PatientMgr.Win.Dbas.App
|
|||||||
{
|
{
|
||||||
return new SpmAdmissionMgr_Dbas(userContext);
|
return new SpmAdmissionMgr_Dbas(userContext);
|
||||||
}
|
}
|
||||||
|
public override SpmDepartmentMgr CreateDepartmentMgr(SpmUserContext userContext)
|
||||||
|
{
|
||||||
|
return new SpmDepartmentMgr_Dbas(userContext);
|
||||||
|
}
|
||||||
|
public override SpmInstitutionMgr CreateInstitutionMgr(SpmUserContext userContext)
|
||||||
|
{
|
||||||
|
return new SpmInstitutionMgr_Dbas(userContext);
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ using Sarand.PatientMgr.Core.Bus;
|
|||||||
using Sarand.Core.Interfaces;
|
using Sarand.Core.Interfaces;
|
||||||
using Sarand.Core.Dbas.Base;
|
using Sarand.Core.Dbas.Base;
|
||||||
using Sarand.PatientMgr.Core.Mgr;
|
using Sarand.PatientMgr.Core.Mgr;
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace Sarand.PatientMgr.Win.Dbas.Bus
|
namespace Sarand.PatientMgr.Win.Dbas.Bus
|
||||||
{
|
{
|
||||||
@@ -45,7 +44,8 @@ namespace Sarand.PatientMgr.Win.Dbas.Bus
|
|||||||
// Utilities.
|
// Utilities.
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Associated data.
|
// A s s o c i a t e d D a t a E l e m e n t s
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
|
||||||
// Admission Roles
|
// Admission Roles
|
||||||
public override bool HasRole(Spm.EmployeeRole employeeRole)
|
public override bool HasRole(Spm.EmployeeRole employeeRole)
|
||||||
@@ -120,7 +120,6 @@ namespace Sarand.PatientMgr.Win.Dbas.Bus
|
|||||||
// Do not attempt any updates unless the list has been populated.
|
// Do not attempt any updates unless the list has been populated.
|
||||||
if (SysId.IsValid(Id))
|
if (SysId.IsValid(Id))
|
||||||
{
|
{
|
||||||
|
|
||||||
admissionRolesCopy.SetSequence();
|
admissionRolesCopy.SetSequence();
|
||||||
admissionRolesCopy.SetIdentity(this);
|
admissionRolesCopy.SetIdentity(this);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Sarand.Core.Base;
|
||||||
using Sarand.Core.Bus;
|
using Sarand.Core.Bus;
|
||||||
using Sarand.PatientMgr.Core.App;
|
using Sarand.PatientMgr.Core.App;
|
||||||
using Sarand.PatientMgr.Core.Bus;
|
using Sarand.PatientMgr.Core.Bus;
|
||||||
@@ -36,7 +37,39 @@ namespace Sarand.PatientMgr.Win.Dbas.Bus
|
|||||||
// Properties.
|
// Properties.
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Associated data.
|
// 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)
|
||||||
|
{
|
||||||
|
ClearErrorState();
|
||||||
|
if (!SysId.IsValid(Id)) { SetErrorState("invalid department"); return 0; }
|
||||||
|
ISacsDatabase db = SpmGlobals.Application.GetDatabase(userContext.SessionContext);
|
||||||
|
if (db == null) { SetErrorState("database unavailable"); return 0; }
|
||||||
|
|
||||||
|
// 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());
|
||||||
|
// 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)
|
||||||
|
{
|
||||||
|
ClearErrorState();
|
||||||
|
return (GetFacilityCount(type) > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
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());
|
||||||
|
return (int)db.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmFacility), filters.Concat(" AND ", "(", ")")) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Sarand.Core.Base;
|
||||||
using Sarand.Core.Bus;
|
using Sarand.Core.Bus;
|
||||||
using Sarand.PatientMgr.Core.App;
|
using Sarand.PatientMgr.Core.App;
|
||||||
using Sarand.PatientMgr.Core.Bus;
|
using Sarand.PatientMgr.Core.Bus;
|
||||||
@@ -36,7 +37,20 @@ namespace Sarand.PatientMgr.Win.Dbas.Bus
|
|||||||
// Properties.
|
// Properties.
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Associated data.
|
// A s s o c i a t e d D a t a E l e m e n t s
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
public override bool HasAdmissionRoles()
|
||||||
|
{
|
||||||
|
ClearErrorState();
|
||||||
|
if (!SysId.IsValid(Id)) return false;
|
||||||
|
ISacsDatabase db = SpmGlobals.Application.GetDatabase(userContext.SessionContext);
|
||||||
|
if (db == null) return SetErrorState("date unavailable");
|
||||||
|
// Filter to identify matching AdmissionRoles:
|
||||||
|
// AdmissionRole.EmployeeRoleId = This item's Id.
|
||||||
|
List<String> filters = new List<String>();
|
||||||
|
filters.Add(SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmAdmissionRole_EmployeeRoleId) + "=" + Id.ToString());
|
||||||
|
return db.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmissionRole), filters.Concat(" AND ", "(", ")")) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Sarand.Core.Base;
|
||||||
using Sarand.Core.Bus;
|
using Sarand.Core.Bus;
|
||||||
using Sarand.PatientMgr.Core.App;
|
using Sarand.PatientMgr.Core.App;
|
||||||
using Sarand.PatientMgr.Core.Bus;
|
using Sarand.PatientMgr.Core.Bus;
|
||||||
@@ -36,8 +37,20 @@ namespace Sarand.PatientMgr.Win.Dbas.Bus
|
|||||||
// Properties.
|
// Properties.
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Associated data.
|
// A s s o c i a t e d D a t a E l e m e n t s
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
public override bool HasRoles()
|
||||||
|
{
|
||||||
|
ClearErrorState();
|
||||||
|
if (!SysId.IsValid(Id)) return false;
|
||||||
|
ISacsDatabase db = SpmGlobals.Application.GetDatabase(userContext.SessionContext);
|
||||||
|
if (db == null) return SetErrorState("date unavailable");
|
||||||
|
// Filter to identify matching admissions:
|
||||||
|
// Patient Id = This item's Id.
|
||||||
|
List<String> filters = new List<String>();
|
||||||
|
filters.Add(SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmEmployeeRole_EmployeeId) + "=" + Id.ToString());
|
||||||
|
return db.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmEmployeeRole), filters.Concat(" AND ", "(", ")")) > 0;
|
||||||
|
}
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ using Sarand.PatientMgr.Core.Bus;
|
|||||||
using Sarand.Core.Interfaces;
|
using Sarand.Core.Interfaces;
|
||||||
using Sarand.Core.Dbas.Base;
|
using Sarand.Core.Dbas.Base;
|
||||||
using Sarand.PatientMgr.Core.Mgr;
|
using Sarand.PatientMgr.Core.Mgr;
|
||||||
|
using Sarand.Core.Base;
|
||||||
|
using Sarand.Win.Dbas.Data;
|
||||||
|
using Sarand.Win.Dbas.Base;
|
||||||
|
|
||||||
namespace Sarand.PatientMgr.Win.Dbas.Bus
|
namespace Sarand.PatientMgr.Win.Dbas.Bus
|
||||||
{
|
{
|
||||||
@@ -36,7 +39,145 @@ namespace Sarand.PatientMgr.Win.Dbas.Bus
|
|||||||
// Properties.
|
// Properties.
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Associated data.
|
// A s s o c i a t e d D a t a E l e m e n t s
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
public override bool HasDataItems()
|
||||||
|
{
|
||||||
|
ClearErrorState();
|
||||||
|
if (SysId.IsValid(Id)) return false;
|
||||||
|
ISacsDatabase db = SpmGlobals.Application.GetDatabase(userContext.SessionContext);
|
||||||
|
if (db == null) SetErrorState("database unavailable");
|
||||||
|
List<String> filters = new List<String>();
|
||||||
|
filters.Add(SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmTemplateData_FacilityTemplateId) + "=" + Id.ToString());
|
||||||
|
return db.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmTemplateData), filters.Concat(" AND ", "(", ")")) > 0; ;
|
||||||
|
}
|
||||||
|
public override bool HasSessions()
|
||||||
|
{
|
||||||
|
DateTime? earliest = null, latest = null;
|
||||||
|
return HasSessions(DateTime.MinValue, DateTime.MinValue, ref earliest, ref latest);
|
||||||
|
}
|
||||||
|
public override bool HasSessionsBefore(DateTime target, ref DateTime? earliest, ref DateTime? latest)
|
||||||
|
{
|
||||||
|
return HasSessions(DateTime.MinValue, DateTime.MinValue, ref earliest, ref latest);
|
||||||
|
}
|
||||||
|
public override bool HasSessionsAfter(DateTime target, ref DateTime? earliest, ref DateTime? latest)
|
||||||
|
{
|
||||||
|
return HasSessions(DateTime.MinValue, DateTime.MinValue, ref earliest, ref latest);
|
||||||
|
}
|
||||||
|
public override bool HasSessions(DateTime before, DateTime after, ref DateTime? earliest, ref DateTime? latest)
|
||||||
|
{
|
||||||
|
ClearErrorState();
|
||||||
|
if (SysId.IsValid(Id)) return false;
|
||||||
|
SacsDatabase db = SpmGlobals.Application.GetDatabase(userContext.SessionContext) as SacsDatabase;
|
||||||
|
if (db == null) SetErrorState("database unavailable");
|
||||||
|
long countSession = 0;
|
||||||
|
|
||||||
|
DbQuery query = new DbQuery(db != null ? db.DbmsType : DbmsType.General);
|
||||||
|
query.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmFacilitySession));
|
||||||
|
query.Columns.Add("Count(" + SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmFacilitySession_FacilityTemplateId) + ")", "CountAdm");
|
||||||
|
query.Columns.Add("Max(" + SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmFacilitySession_Session) + ")", "MaxSession");
|
||||||
|
query.Columns.Add("Min(" + SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmFacilitySession_Session) + ")", "MinSession");
|
||||||
|
|
||||||
|
// Filter to identify matching Sessions: FacilitySession.FacilityTemplateId = This item's Id.
|
||||||
|
query.Filters.Add(SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmFacilitySession_FacilityTemplateId) + "=" + Id.ToString());
|
||||||
|
if (DateUtil.IsValid(before)) query.Filters.Add(SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmFacilitySession_Session) + "<" + DbQuery.FormatDateForCondition(before));
|
||||||
|
if (DateUtil.IsValid(after)) query.Filters.Add(SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmFacilitySession_Session) + ">=" + DbQuery.FormatDateForCondition(after.AddDays(1)));
|
||||||
|
|
||||||
|
// Retrieve session statistics.
|
||||||
|
using (DbResultSet dbResultSet = new DbResultSet_DataReader(db, query.ToString()))
|
||||||
|
{
|
||||||
|
if (dbResultSet != null && dbResultSet.NextRecord())
|
||||||
|
{
|
||||||
|
NamedValue.Map values = dbResultSet.GetRecordValues();
|
||||||
|
countSession = values.GetValue("CountSession").AsLong();
|
||||||
|
if (countSession > 0)
|
||||||
|
{
|
||||||
|
if (earliest != null) earliest = values.GetValue("MinSession").AsDate().Date;
|
||||||
|
if (latest != null) latest = values.GetValue("MaxSession").AsDate().Date;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public override bool HasAdmissions(Spm.AdmissionCancelType cancelType)
|
||||||
|
{
|
||||||
|
DateTime? earliest = null, latest = null;
|
||||||
|
return HasAdmissions(DateTime.MinValue, DateTime.MinValue, cancelType, ref earliest, ref latest);
|
||||||
|
}
|
||||||
|
public override bool HasAdmissionsBefore(DateTime target, Spm.AdmissionCancelType cancelType, ref DateTime? earliest, ref DateTime? latest)
|
||||||
|
{
|
||||||
|
return HasAdmissions(DateTime.MinValue, DateTime.MinValue, cancelType, ref earliest, ref latest);
|
||||||
|
}
|
||||||
|
public override bool HasAdmissionsAfter(DateTime target, Spm.AdmissionCancelType cancelType, ref DateTime? earliest, ref DateTime? latest)
|
||||||
|
{
|
||||||
|
return HasAdmissions(DateTime.MinValue, DateTime.MinValue, cancelType, ref earliest, ref latest);
|
||||||
|
}
|
||||||
|
public override bool HasAdmissions(DateTime before, DateTime after, Spm.AdmissionCancelType cancelType, ref DateTime? earliest, ref DateTime? latest)
|
||||||
|
{
|
||||||
|
ClearErrorState();
|
||||||
|
if (SysId.IsValid(Id)) return false;
|
||||||
|
SacsDatabase db = SpmGlobals.Application.GetDatabase(userContext.SessionContext) as SacsDatabase;
|
||||||
|
if (db == null) SetErrorState("database unavailable");
|
||||||
|
long countAdmission = 0;
|
||||||
|
|
||||||
|
DbQuery query = new DbQuery(db.DbmsType);
|
||||||
|
query.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmission));
|
||||||
|
query.Columns.Add("Count(" + SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmAdmission_Id) + ")", "CountAdm");
|
||||||
|
if (earliest != null) query.Columns.Add("Min(" + SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmAdmission_AdmissionFrom) + ")", "MinAdm");
|
||||||
|
if (latest != null) query.Columns.Add("Max(" + SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmAdmission_AdmissionTo) + ")", "MaxAdm");
|
||||||
|
|
||||||
|
// Filter to identify matching Admissions.
|
||||||
|
SpmAdmission.Params prmAdm = new SpmAdmission.Params();
|
||||||
|
prmAdm.FacilityTemplateId = Id;
|
||||||
|
prmAdm.AdmissionFrom = after.AddDays(1);
|
||||||
|
prmAdm.AdmissionTo = before.AddDays(-1);
|
||||||
|
SpmAdmissionMgr admissionMgr = SpmGlobals.System.CreateAdmissionMgr(userContext);
|
||||||
|
query.Filters.AddRange(admissionMgr.GetAdmissionQueryFilter(prmAdm));
|
||||||
|
|
||||||
|
// Retrieve admission statistics.
|
||||||
|
using (DbResultSet dbResultSet = new DbResultSet_DataReader(db, query.ToString()))
|
||||||
|
{
|
||||||
|
if (dbResultSet != null && dbResultSet.NextRecord())
|
||||||
|
{
|
||||||
|
NamedValue.Map values = dbResultSet.GetRecordValues();
|
||||||
|
countAdmission = values.GetValue("CountAdm").AsLong();
|
||||||
|
if (countAdmission > 0)
|
||||||
|
{
|
||||||
|
if (earliest != null) earliest = values.GetValue("MinAdm").AsDate().Date;
|
||||||
|
if (latest != null) latest = values.GetValue("MaxAdm").AsDate().Date;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override long GetSessionComplexityCount(DateTime admission, String complexity, SysId admissionExcludeId)
|
||||||
|
{
|
||||||
|
ClearErrorState();
|
||||||
|
if (SysId.IsValid(Id)) return 0;
|
||||||
|
ISacsDatabase db = SpmGlobals.Application.GetDatabase(userContext.SessionContext);
|
||||||
|
if (db == null) SetErrorState("database unavailable");
|
||||||
|
|
||||||
|
// Dummy query to set the DBMS correctly (for formatting strings and dates etc)/
|
||||||
|
DbQuery qryDummy = new DbQuery(db != null ? db.DbmsType :DbmsType.General);
|
||||||
|
|
||||||
|
// Filter to identify matching Admissions.
|
||||||
|
// Admission.FacilityTemplateId = This item's Id.
|
||||||
|
// Admission.AdmissionFrom = admission date
|
||||||
|
// Admission.AdmissionTo = admission date
|
||||||
|
// Admissin.ComplexityCode = complexity code
|
||||||
|
// Admission.Id <> exclude item
|
||||||
|
List<String> filters = new List<String>();
|
||||||
|
filters.Add(SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmAdmission_FacilityTemplateId) + "=" + Id.ToString());
|
||||||
|
filters.Add(SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmAdmission_AdmissionFrom) + "=" + DbQuery.FormatDateForCondition(admission));
|
||||||
|
filters.Add(SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmAdmission_AdmissionTo) + "=" + DbQuery.FormatDateForCondition(admission));
|
||||||
|
filters.Add(SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmAdmission_ComplexityCode) + "='" + complexity + "'");
|
||||||
|
filters.Add(SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmAdmission_CancelType) + "=" + ((int)Spm.AdmissionCancelType.None));
|
||||||
|
if (SysId.IsValid(admissionExcludeId))
|
||||||
|
filters.Add(SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmAdmission_Id) + "<>" + admissionExcludeId.ToString());
|
||||||
|
|
||||||
|
return db.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmission), filters.Concat(" AND ", "(", ")"));
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ using Sarand.PatientMgr.Core.Bus;
|
|||||||
using Sarand.Core.Interfaces;
|
using Sarand.Core.Interfaces;
|
||||||
using Sarand.Core.Dbas.Base;
|
using Sarand.Core.Dbas.Base;
|
||||||
using Sarand.PatientMgr.Core.Mgr;
|
using Sarand.PatientMgr.Core.Mgr;
|
||||||
|
using Sarand.Core.Base;
|
||||||
|
using Sarand.Win.Dbas.Data;
|
||||||
|
using Sarand.Win.Dbas.Base;
|
||||||
|
|
||||||
namespace Sarand.PatientMgr.Win.Dbas.Bus
|
namespace Sarand.PatientMgr.Win.Dbas.Bus
|
||||||
{
|
{
|
||||||
@@ -36,7 +39,85 @@ namespace Sarand.PatientMgr.Win.Dbas.Bus
|
|||||||
// Properties.
|
// Properties.
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Associated data.
|
// A s s o c i a t e d D a t a E l e m e n t s
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
public override bool HasTemplates()
|
||||||
|
{
|
||||||
|
ClearErrorState();
|
||||||
|
if (SysId.IsValid(Id)) return false;
|
||||||
|
ISacsDatabase db = SpmGlobals.Application.GetDatabase(userContext.SessionContext);
|
||||||
|
if (db == null) SetErrorState("database unavailable");
|
||||||
|
List<String> filters = new List<String>();
|
||||||
|
filters.Add(SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmFacilityTemplate_FacilityId) + "=" + Id.ToString());
|
||||||
|
return db.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmFacilityTemplate), filters.Concat(" AND ", "(", ")")) > 0;
|
||||||
|
}
|
||||||
|
public override bool HasSessions()
|
||||||
|
{
|
||||||
|
DateTime? earliest = null, latest = null;
|
||||||
|
return HasSessions(DateTime.MinValue, DateTime.MinValue, ref earliest, ref latest);
|
||||||
|
}
|
||||||
|
public override bool HasSessionsBefore(DateTime target, ref DateTime? earliest, ref DateTime? latest)
|
||||||
|
{
|
||||||
|
return HasSessions(DateTime.MinValue, DateTime.MinValue, ref earliest, ref latest);
|
||||||
|
}
|
||||||
|
public override bool HasSessionsAfter(DateTime target, ref DateTime? earliest, ref DateTime? latest)
|
||||||
|
{
|
||||||
|
return HasSessions(DateTime.MinValue, DateTime.MinValue, ref earliest, ref latest);
|
||||||
|
}
|
||||||
|
public override bool HasSessions(DateTime before, DateTime after, ref DateTime? earliest, ref DateTime? latest)
|
||||||
|
{
|
||||||
|
ClearErrorState();
|
||||||
|
if (SysId.IsValid(Id)) return false;
|
||||||
|
SacsDatabase db = SpmGlobals.Application.GetDatabase(userContext.SessionContext) as SacsDatabase;
|
||||||
|
if (db == null) SetErrorState("database unavailable");
|
||||||
|
long countSession = 0;
|
||||||
|
|
||||||
|
// Filter to identify matching Sessions:
|
||||||
|
// FacilitySession.FacilityTemplateId = Template belonging to this facility (via sub query).
|
||||||
|
// FacilitySession.Session > Before date if specified.
|
||||||
|
// FacilitySession.Session > After date if specified.
|
||||||
|
List<String> filters = new List<String>();
|
||||||
|
DbQuery query = new DbQuery(db != null ? db.DbmsType : DbmsType.General);
|
||||||
|
query.Tables.Add(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmFacilityTemplate));
|
||||||
|
query.Columns.Add(SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmFacilityTemplate_Id));
|
||||||
|
query.Filters.Add(SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmFacilityTemplate_FacilityId) + "=" + Id.ToString());
|
||||||
|
filters.Add(SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmFacilitySession_FacilityTemplateId) + " IN (" + query.BuildQuery() + ")");
|
||||||
|
if (DateUtil.IsValid(before))
|
||||||
|
filters.Add(SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmFacilitySession_Session) + "<" + DbQuery.FormatDateForCondition(before));
|
||||||
|
if (DateUtil.IsValid(after))
|
||||||
|
filters.Add(SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmFacilitySession_Session) + ">" + DbQuery.FormatDateForCondition(after));
|
||||||
|
return db.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmFacilitySession), filters.Concat(" AND ", "(", ")")) > 0;
|
||||||
|
}
|
||||||
|
public override bool HasAdmissions(Spm.AdmissionCancelType cancelType)
|
||||||
|
{
|
||||||
|
DateTime? earliest = null, latest = null;
|
||||||
|
return HasAdmissions(DateTime.MinValue, DateTime.MinValue, cancelType, ref earliest, ref latest);
|
||||||
|
}
|
||||||
|
public override bool HasAdmissionsBefore(DateTime target, Spm.AdmissionCancelType cancelType, ref DateTime? earliest, ref DateTime? latest)
|
||||||
|
{
|
||||||
|
return HasAdmissions(DateTime.MinValue, DateTime.MinValue, cancelType, ref earliest, ref latest);
|
||||||
|
}
|
||||||
|
public override bool HasAdmissionsAfter(DateTime target, Spm.AdmissionCancelType cancelType, ref DateTime? earliest, ref DateTime? latest)
|
||||||
|
{
|
||||||
|
return HasAdmissions(DateTime.MinValue, DateTime.MinValue, cancelType, ref earliest, ref latest);
|
||||||
|
}
|
||||||
|
public override bool HasAdmissions(DateTime before, DateTime after, Spm.AdmissionCancelType cancelType, ref DateTime? earliest, ref DateTime? latest)
|
||||||
|
{
|
||||||
|
ClearErrorState();
|
||||||
|
if (SysId.IsValid(Id)) return false;
|
||||||
|
SacsDatabase db = SpmGlobals.Application.GetDatabase(userContext.SessionContext) as SacsDatabase;
|
||||||
|
if (db == null) SetErrorState("database unavailable");
|
||||||
|
DbQuery query = new DbQuery(db.DbmsType);
|
||||||
|
|
||||||
|
// Filter to identify matching Admissions.
|
||||||
|
SpmAdmission.Params prmAdm = new SpmAdmission.Params();
|
||||||
|
prmAdm.FacilityTemplateId = Id;
|
||||||
|
prmAdm.AdmissionFrom = after.AddDays(1);
|
||||||
|
prmAdm.AdmissionTo = before.AddDays(-1);
|
||||||
|
SpmAdmissionMgr admissionMgr = SpmGlobals.System.CreateAdmissionMgr(userContext);
|
||||||
|
List<String> filters = new List<String>(admissionMgr.GetAdmissionQueryFilter(prmAdm));
|
||||||
|
return db.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmission), filters.Concat(" AND ", "(", ")")) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ using Sarand.PatientMgr.Core.Bus;
|
|||||||
using Sarand.Core.Interfaces;
|
using Sarand.Core.Interfaces;
|
||||||
using Sarand.Core.Dbas.Base;
|
using Sarand.Core.Dbas.Base;
|
||||||
using Sarand.PatientMgr.Core.Mgr;
|
using Sarand.PatientMgr.Core.Mgr;
|
||||||
|
using Sarand.Core.Base;
|
||||||
|
using Sarand.Win.Dbas.Data;
|
||||||
|
using Sarand.Win.Dbas.Base;
|
||||||
|
|
||||||
namespace Sarand.PatientMgr.Win.Dbas.Bus
|
namespace Sarand.PatientMgr.Win.Dbas.Bus
|
||||||
{
|
{
|
||||||
@@ -36,7 +39,23 @@ namespace Sarand.PatientMgr.Win.Dbas.Bus
|
|||||||
// Properties.
|
// Properties.
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Associated data.
|
// A s s o c i a t e d D a t a E l e m e n t s
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
public override bool HasProcedures()
|
||||||
|
{
|
||||||
|
return (GetProcedureCount(null) > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override long GetProcedureCount(String filter)
|
||||||
|
{
|
||||||
|
ClearErrorState();
|
||||||
|
if (SysId.IsValid(Id)) return 0;
|
||||||
|
ISacsDatabase db = SpmGlobals.Application.GetDatabase(userContext.SessionContext);
|
||||||
|
List<String> filters = new List<String>();
|
||||||
|
filters.Add(SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmProcedure_OperationId) + "=" + Id.ToString());
|
||||||
|
//if (filter && strlen(filter)) filters.Add("(" + filter + ")");
|
||||||
|
return db.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmProcedure), filters.Concat(" AND ", "(", ")"));
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using Sarand.PatientMgr.Core.Bus;
|
|||||||
using Sarand.Core.Interfaces;
|
using Sarand.Core.Interfaces;
|
||||||
using Sarand.Core.Dbas.Base;
|
using Sarand.Core.Dbas.Base;
|
||||||
using Sarand.PatientMgr.Core.Mgr;
|
using Sarand.PatientMgr.Core.Mgr;
|
||||||
|
using Sarand.Core.Base;
|
||||||
|
|
||||||
namespace Sarand.PatientMgr.Win.Dbas.Bus
|
namespace Sarand.PatientMgr.Win.Dbas.Bus
|
||||||
{
|
{
|
||||||
@@ -36,7 +37,18 @@ namespace Sarand.PatientMgr.Win.Dbas.Bus
|
|||||||
// Properties.
|
// Properties.
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Associated data.
|
// A s s o c i a t e d D a t a E l e m e n t s
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
public override bool HasAdmission()
|
||||||
|
{
|
||||||
|
ClearErrorState();
|
||||||
|
if (SysId.IsValid(Id)) return false;
|
||||||
|
ISacsDatabase db = SpmGlobals.Application.GetDatabase(userContext.SessionContext);
|
||||||
|
// Filter to identify matching Admissions: Facility Id = This item's Id.
|
||||||
|
List<String> filters = new List<String>();
|
||||||
|
filters.Add(SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmAdmission_ProcedureId) + "=" + Id.ToString());
|
||||||
|
return db.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmission), filters.Concat(" AND ", "(", ")")) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using Sarand.PatientMgr.Core.Bus;
|
|||||||
using Sarand.Core.Interfaces;
|
using Sarand.Core.Interfaces;
|
||||||
using Sarand.Core.Dbas.Base;
|
using Sarand.Core.Dbas.Base;
|
||||||
using Sarand.PatientMgr.Core.Mgr;
|
using Sarand.PatientMgr.Core.Mgr;
|
||||||
|
using Sarand.Core.Base;
|
||||||
|
|
||||||
namespace Sarand.PatientMgr.Win.Dbas.Bus
|
namespace Sarand.PatientMgr.Win.Dbas.Bus
|
||||||
{
|
{
|
||||||
@@ -36,7 +37,18 @@ namespace Sarand.PatientMgr.Win.Dbas.Bus
|
|||||||
// Properties.
|
// Properties.
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Associated data.
|
// A s s o c i a t e d D a t a E l e m e n t s
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
public override bool HasAdmission()
|
||||||
|
{
|
||||||
|
ClearErrorState();
|
||||||
|
if (SysId.IsValid(Id)) return false;
|
||||||
|
ISacsDatabase db = SpmGlobals.Application.GetDatabase(userContext.SessionContext);
|
||||||
|
// Filter to identify matching Admissions: Facility Id = This item's Id.
|
||||||
|
List<String> filters = new List<String>();
|
||||||
|
filters.Add(SpmDbDfn.GetColumnName(SpmDbDfn.ColumnIdx.SwmAdmission_ProcedureId) + "=" + Id.ToString());
|
||||||
|
return db.GetRowCount(SpmDbDfn.GetTableName(SpmDbDfn.TableIdx.SwmAdmission), filters.Concat(" AND ", "(", ")")) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -210,9 +210,24 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
|
|||||||
//dbFacilitySession._Id = facilitySession.Id.ToInt();
|
//dbFacilitySession._Id = facilitySession.Id.ToInt();
|
||||||
dbFacilitySession._FacilityId = facilitySession.FacilityId.ToInt();
|
dbFacilitySession._FacilityId = facilitySession.FacilityId.ToInt();
|
||||||
dbFacilitySession._FacilityTemplateId = facilitySession.FacilityTemplateId.ToInt();
|
dbFacilitySession._FacilityTemplateId = facilitySession.FacilityTemplateId.ToInt();
|
||||||
|
dbFacilitySession._Session = facilitySession.SessionDate;
|
||||||
|
dbFacilitySession._Type = (short)facilitySession.TemplateType;
|
||||||
dbFacilitySession._Name = facilitySession.Name;
|
dbFacilitySession._Name = facilitySession.Name;
|
||||||
dbFacilitySession._Description = facilitySession.Description;
|
dbFacilitySession._Description = facilitySession.Description;
|
||||||
dbFacilitySession._SpecialityCode = facilitySession.SpecialityCode;
|
dbFacilitySession._SpecialityCode = facilitySession.SpecialityCode;
|
||||||
|
dbFacilitySession._SessionCode = facilitySession.SessionCode;
|
||||||
|
dbFacilitySession._StartAt = facilitySession.StartTime;
|
||||||
|
dbFacilitySession._FinishAt = facilitySession.FinishTime;
|
||||||
|
dbFacilitySession._CapacityType = (short)facilitySession.ResourceCapacityType;
|
||||||
|
dbFacilitySession._CapacityMin = facilitySession.CapacityMin;
|
||||||
|
dbFacilitySession._CapacityMax = facilitySession.CapacityMax;
|
||||||
|
dbFacilitySession._UnitsExp = (float)facilitySession.UnitsExp;
|
||||||
|
dbFacilitySession._DurationInterval = facilitySession.DurationInterval;
|
||||||
|
dbFacilitySession._DurationMin = facilitySession.DurationMin;
|
||||||
|
dbFacilitySession._DurationMax = facilitySession.DurationMax;
|
||||||
|
dbFacilitySession._ConsultantId = facilitySession.ConsultantId.ToInt();
|
||||||
|
dbFacilitySession._ConsultantCode = facilitySession.ConsultantCode;
|
||||||
|
dbFacilitySession._SpecialityCode = facilitySession.SpecialityCode;
|
||||||
|
|
||||||
dbFacilitySession._Notes = facilitySession.Notes;
|
dbFacilitySession._Notes = facilitySession.Notes;
|
||||||
dbFacilitySession._Status = SacsSystem.GetStatusCode(facilitySession.Status);
|
dbFacilitySession._Status = SacsSystem.GetStatusCode(facilitySession.Status);
|
||||||
@@ -233,8 +248,23 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
|
|||||||
facilitySession.FacilityId = new SysId(dbFacilitySession._FacilityId);
|
facilitySession.FacilityId = new SysId(dbFacilitySession._FacilityId);
|
||||||
facilitySession.FacilityTemplateId = new SysId(dbFacilitySession._FacilityTemplateId);
|
facilitySession.FacilityTemplateId = new SysId(dbFacilitySession._FacilityTemplateId);
|
||||||
facilitySession.Name = dbFacilitySession._Name;
|
facilitySession.Name = dbFacilitySession._Name;
|
||||||
|
facilitySession.SessionDate = dbFacilitySession._Session;
|
||||||
|
facilitySession.TemplateType = (Spm.TemplateType)dbFacilitySession._Type;
|
||||||
facilitySession.Description = dbFacilitySession._Description;
|
facilitySession.Description = dbFacilitySession._Description;
|
||||||
facilitySession.SpecialityCode = dbFacilitySession._SpecialityCode;
|
facilitySession.SpecialityCode = dbFacilitySession._SpecialityCode;
|
||||||
|
facilitySession.SessionCode = dbFacilitySession._SessionCode;
|
||||||
|
facilitySession.StartTime = dbFacilitySession._StartAt;
|
||||||
|
facilitySession.FinishTime = dbFacilitySession._FinishAt;
|
||||||
|
facilitySession.ResourceCapacityType = (Spm.ResourceCapacityType)dbFacilitySession._CapacityType;
|
||||||
|
facilitySession.CapacityMin = dbFacilitySession._CapacityMin;
|
||||||
|
facilitySession.CapacityMax = dbFacilitySession._CapacityMax;
|
||||||
|
facilitySession.UnitsExp = (decimal)dbFacilitySession._UnitsExp;
|
||||||
|
facilitySession.DurationInterval = dbFacilitySession._DurationInterval;
|
||||||
|
facilitySession.DurationMin = dbFacilitySession._DurationMin;
|
||||||
|
facilitySession.DurationMax = dbFacilitySession._DurationMax;
|
||||||
|
facilitySession.ConsultantId = new SysId(dbFacilitySession._ConsultantId);
|
||||||
|
facilitySession.ConsultantCode = dbFacilitySession._ConsultantCode;
|
||||||
|
facilitySession.SpecialityCode = dbFacilitySession._SpecialityCode;
|
||||||
|
|
||||||
facilitySession.Notes = dbFacilitySession._Notes;
|
facilitySession.Notes = dbFacilitySession._Notes;
|
||||||
facilitySession.Status = SacsSystem.GetStatusForCode(dbFacilitySession._Status);
|
facilitySession.Status = SacsSystem.GetStatusForCode(dbFacilitySession._Status);
|
||||||
|
|||||||
@@ -207,6 +207,14 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
|
|||||||
private void PopulateTo(SwmFacilityTemplate_Db dbFacilityTemplate, SpmFacilityTemplate facilityTemplate, DbUpdateInfo dbUpdateInfo)
|
private void PopulateTo(SwmFacilityTemplate_Db dbFacilityTemplate, SpmFacilityTemplate facilityTemplate, DbUpdateInfo dbUpdateInfo)
|
||||||
{
|
{
|
||||||
dbFacilityTemplate._Id = facilityTemplate.Id.ToInt();
|
dbFacilityTemplate._Id = facilityTemplate.Id.ToInt();
|
||||||
|
dbFacilityTemplate._FacilityId = facilityTemplate.FacilityId.ToInt();
|
||||||
|
dbFacilityTemplate._Category = (short)facilityTemplate.ResourceCategory;
|
||||||
|
dbFacilityTemplate._Type = (short)facilityTemplate.TemplateType;
|
||||||
|
dbFacilityTemplate._Name = facilityTemplate.Name;
|
||||||
|
dbFacilityTemplate._SortCode = facilityTemplate.SortCode;
|
||||||
|
dbFacilityTemplate._Description = facilityTemplate.Desc;
|
||||||
|
dbFacilityTemplate._SessionCode = facilityTemplate.SessionCode;
|
||||||
|
dbFacilityTemplate._Group = facilityTemplate.Group;
|
||||||
|
|
||||||
dbFacilityTemplate._Notes = facilityTemplate.Notes;
|
dbFacilityTemplate._Notes = facilityTemplate.Notes;
|
||||||
dbFacilityTemplate._Status = SacsSystem.GetStatusCode(facilityTemplate.Status);
|
dbFacilityTemplate._Status = SacsSystem.GetStatusCode(facilityTemplate.Status);
|
||||||
@@ -223,7 +231,16 @@ namespace Sarand.PatientMgr.Win.Dbas.Mgr
|
|||||||
}
|
}
|
||||||
private void PopulateFrom(SwmFacilityTemplate_Db dbFacilityTemplate, SpmFacilityTemplate facilityTemplate)
|
private void PopulateFrom(SwmFacilityTemplate_Db dbFacilityTemplate, SpmFacilityTemplate facilityTemplate)
|
||||||
{
|
{
|
||||||
//facilityTemplate.Id = new SysId(dbFacilityTemplate._Id);
|
facilityTemplate.Id = new SysId(dbFacilityTemplate._Id);
|
||||||
|
facilityTemplate.FacilityId = new SysId(dbFacilityTemplate._FacilityId);
|
||||||
|
facilityTemplate.ResourceCategory = (Spm.ResourceCategory)dbFacilityTemplate._Category;
|
||||||
|
facilityTemplate.TemplateType = (Spm.TemplateType)dbFacilityTemplate._Type;
|
||||||
|
facilityTemplate.Name = dbFacilityTemplate._Name;
|
||||||
|
facilityTemplate.SortCode = dbFacilityTemplate._SortCode;
|
||||||
|
facilityTemplate.Desc = dbFacilityTemplate._Description;
|
||||||
|
facilityTemplate.SessionCode = dbFacilityTemplate._SessionCode;
|
||||||
|
facilityTemplate.Group = dbFacilityTemplate._Group;
|
||||||
|
|
||||||
facilityTemplate.Notes = dbFacilityTemplate._Notes;
|
facilityTemplate.Notes = dbFacilityTemplate._Notes;
|
||||||
facilityTemplate.Status = SacsSystem.GetStatusForCode(dbFacilityTemplate._Status);
|
facilityTemplate.Status = SacsSystem.GetStatusForCode(dbFacilityTemplate._Status);
|
||||||
facilityTemplate.SetCreateStamp(dbFacilityTemplate._CreateOn, new SysId(dbFacilityTemplate._CreateBy), dbFacilityTemplate._CreateHost);
|
facilityTemplate.SetCreateStamp(dbFacilityTemplate._CreateOn, new SysId(dbFacilityTemplate._CreateBy), dbFacilityTemplate._CreateHost);
|
||||||
|
|||||||
Reference in New Issue
Block a user