SB 04-Jun-2019
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Sarand.Core.Base;
|
||||
using Sarand.Core.Bus;
|
||||
using Sarand.PatientMgr.Core.App;
|
||||
using Sarand.PatientMgr.Core.Bus;
|
||||
@@ -36,7 +37,39 @@ namespace Sarand.PatientMgr.Win.Dbas.Bus
|
||||
// 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;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user