126 lines
5.3 KiB
C#
126 lines
5.3 KiB
C#
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using Sarand.Core.App;
|
|
using Sarand.Core.Base;
|
|
using Sarand.Core.Bus;
|
|
using Sarand.Core.Dbas.Base;
|
|
using Sarand.PatientMgr.Core.App;
|
|
using Sarand.PatientMgr.Core.Bus;
|
|
|
|
namespace Sarand.PatientMgr.Core.Mgr
|
|
{
|
|
//=======================================================================
|
|
partial class SpmInstitutionMgr
|
|
{
|
|
//*******************************************************************
|
|
// P a t i e n t
|
|
//*******************************************************************
|
|
//-------------------------------------------------------------------
|
|
// Utilities.
|
|
|
|
//-------------------------------------------------------------------
|
|
// Retrieve individual patient.
|
|
//-------------------------------------------------------------------
|
|
// Exist patient.
|
|
public abstract bool PatientExistsById(SysId id);
|
|
//-------------------------------------------------------------------
|
|
// Get patient.
|
|
public abstract SpmPatient GetPatient(SpmPatient.Params prm);
|
|
public abstract SpmPatient GetPatientById(SysId id);
|
|
//-------------------------------------------------------------------
|
|
// Create patient.
|
|
public abstract SpmPatient CreatePatient(SysId id, SysId institutionId);
|
|
|
|
//-------------------------------------------------------------------
|
|
// Validate patient data.
|
|
public bool IsValidPatient(SpmPatient patient)
|
|
{
|
|
ClearErrorState();
|
|
if (patient == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
|
return IsValidPatientData(patient.GetData(), new SpmPatient.ErrField());
|
|
}
|
|
public virtual bool IsValidPatientData(SpmPatient.Data data, SpmPatient.ErrField errField)
|
|
{
|
|
ClearErrorState();
|
|
// Patient properties.
|
|
if (errField.PatientNo != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.PatientNo, "PatientNo", (long)SpmDbDfn.GetColTextLen(SpmDbDfn.ColumnIdx.SwmPatient_PatientNo), true))
|
|
{
|
|
errField.PatientNo = SacsHierarchyItem.ValidValue.Invalid;
|
|
return false;
|
|
}
|
|
if (errField.NhsNumber != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.NhsNumber, "NhsNumber", (long)SpmDbDfn.GetColTextLen(SpmDbDfn.ColumnIdx.SwmPatient_NhsNumber), true))
|
|
{
|
|
errField.NhsNumber = SacsHierarchyItem.ValidValue.Invalid;
|
|
return false;
|
|
}
|
|
if (errField.Title != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Title, "Title", (long)SpmDbDfn.GetColTextLen(SpmDbDfn.ColumnIdx.SwmPatient_Title), true))
|
|
{
|
|
errField.Title = SacsHierarchyItem.ValidValue.Invalid;
|
|
return false;
|
|
}
|
|
if (errField.Forename != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Forename, "Forename", (long)SpmDbDfn.GetColTextLen(SpmDbDfn.ColumnIdx.SwmPatient_Forename), true))
|
|
{
|
|
errField.Forename = SacsHierarchyItem.ValidValue.Invalid;
|
|
return false;
|
|
}
|
|
if (errField.Surname != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Surname, "Surname", (long)SpmDbDfn.GetColTextLen(SpmDbDfn.ColumnIdx.SwmPatient_Surname), true))
|
|
{
|
|
errField.Surname = SacsHierarchyItem.ValidValue.Invalid;
|
|
return false;
|
|
}
|
|
if (errField.Age != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Age, "Age", (long)SpmDbDfn.GetColTextLen(SpmDbDfn.ColumnIdx.SwmPatient_Age), true))
|
|
{
|
|
errField.Age = SacsHierarchyItem.ValidValue.Invalid;
|
|
return false;
|
|
}
|
|
|
|
// Common properties.
|
|
if (!IsValidValue(data.Notes, "notes", (long)SpmDbDfn.GetColTextLen(SpmDbDfn.ColumnIdx.SwmPatient_Notes)))
|
|
{
|
|
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
|
return false;
|
|
}
|
|
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
|
{
|
|
if (!IsValidValue(SacsSystem.GetStatusCode(data.Status), "status", (long)SpmDbDfn.GetColTextLen(SpmDbDfn.ColumnIdx.SwmPatient_Status), true, true))
|
|
{
|
|
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
|
return false;
|
|
}
|
|
if (!SpmPatient.PatientStatuses.Contains(data.Status))
|
|
{
|
|
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
|
return SetErrorState(ErrorMessage.InvalidStatus);
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Patient database interface.
|
|
public abstract bool InsertPatient(SpmPatient patient, DbUpdateInfo dbUpdateInfo);
|
|
public abstract bool UpdatePatient(SpmPatient patient, DbUpdateInfo dbUpdateInfo);
|
|
public virtual bool PatientCanBeDeleted(SpmPatient patient)
|
|
{
|
|
ClearErrorState();
|
|
return true;
|
|
}
|
|
public abstract bool DeletePatient(SpmPatient patient, DbUpdateInfo dbUpdateInfo);
|
|
|
|
//-------------------------------------------------------------------
|
|
// Patient list.
|
|
public abstract ColumnDfn GetPatientColumnDfn(SpmPatient.Column columnId, String caption = "", int width = 0);
|
|
public abstract List<String> GetPatientQueryFilter(SpmPatient.Params prm);
|
|
public abstract long GetPatientCount(SpmPatient.Params prm);
|
|
public abstract List<SpmPatient> GetPatientList(SpmPatient.Params prm);
|
|
public abstract DbResultSet ExecutePatientQuery(List<ColumnDfn> columns, SpmPatient.Params prm);
|
|
public abstract DataValue GetPatientDataValue(ColumnDfn column, NamedValue.Map values);
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|