1135 lines
34 KiB
C#
1135 lines
34 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Sarand.Core.Base;
|
|
using Sarand.Core.Bus;
|
|
using Sarand.PatientMgr.Core.App;
|
|
|
|
namespace Sarand.PatientMgr.Core.Bus
|
|
{
|
|
//=======================================================================
|
|
public abstract class SpmAdmission : SacsHierarchyItem
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// Columns.
|
|
public enum Column
|
|
{
|
|
Pos,
|
|
Session, // Not populated - reserved for session heading.
|
|
Id,
|
|
|
|
FacilityId,
|
|
TemplateId,
|
|
Seq,
|
|
// Admission date.
|
|
AdmissionFromDate,
|
|
AdmissionFromTime,
|
|
AdmissionFromDateTime,
|
|
AdmissionToDate,
|
|
AdmissionToTime,
|
|
AdmissionToDateTime,
|
|
Type,
|
|
Type_Desc,
|
|
// Dates.
|
|
DecisionToReferOn,
|
|
ReferredOn,
|
|
BreechOn,
|
|
DecisionToAdmitOn,
|
|
// Admission details.
|
|
Patient, // No & display name.
|
|
PatientId,
|
|
PatientNo,
|
|
PatientName, // LAST, First
|
|
PatientSurname,
|
|
PatientForename,
|
|
BirthAge,
|
|
BirthOn,
|
|
Age,
|
|
AgeOn,
|
|
FacilityIdWard,
|
|
Ward,
|
|
ProcedureId,
|
|
SpecialityCode,
|
|
Procedure,
|
|
ComplexityCode,
|
|
ProcedureIndication,
|
|
DurationExp,
|
|
DurationAct,
|
|
Anaesthetic,
|
|
Position,
|
|
SpecialEquipment,
|
|
AttendanceStatusDesc,
|
|
ComfortScore,
|
|
// Admission timings.
|
|
TimeCalled,
|
|
TimeArrived,
|
|
TimeAnaesStart,
|
|
TimeProcStart,
|
|
TimeProcEnd,
|
|
TimeInRecovery,
|
|
TimeInformDest,
|
|
TimeLeave,
|
|
// Cancellations.
|
|
CancelType,
|
|
CancelTypeDesc,
|
|
CancelDate,
|
|
CancelElapsed,
|
|
CancelReBookBy,
|
|
CancelReBookDue,
|
|
CancelCount,
|
|
// Facility.
|
|
Facility_Type,
|
|
Facility_TypeDesc,
|
|
Facility_Name,
|
|
Facility_Desc,
|
|
Facility_TemplateMapType,
|
|
Facility_ApplicFrom,
|
|
Facility_ApplicTo,
|
|
Facility_Notes,
|
|
// Facility Template.
|
|
Template_WeekOfMonth,
|
|
Template_DayOfWeek,
|
|
Template_ConsultantId,
|
|
Template_ConsultantCode,
|
|
Template_SpecialityCode,
|
|
Template_StartAt,
|
|
Template_FinishAt,
|
|
Template_CategoryDesc,
|
|
Template_TypeDesc,
|
|
Template_Name,
|
|
Template_Desc,
|
|
Template_Group,
|
|
Template_ApplicFrom,
|
|
Template_ApplicTo,
|
|
Template_Notes,
|
|
// Facility Session.
|
|
Session_TemplateId,
|
|
Session_ConsultantId,
|
|
Session_ConsultantCode,
|
|
Session_SpecialityCode,
|
|
Session_StartAt,
|
|
Session_FinishAt,
|
|
Session_Name,
|
|
Session_Desc,
|
|
Session_Flags,
|
|
Session_Notes,
|
|
// Session definition (combined template and date-specific session info):
|
|
SessionDfn_Summary,
|
|
SessionDfn_Name,
|
|
// Patient.
|
|
Patient_PatientNo,
|
|
Patient_Surname,
|
|
Patient_Forename,
|
|
Patient_BirthOn,
|
|
Patient_Age,
|
|
Patient_AgeOn,
|
|
// Members of staff (Role-categories not in use are commented out).
|
|
Role_Consultant_Operating_Code,
|
|
Role_Consultant_Referring_Code,
|
|
//Role_Consultant_Attending_Code,
|
|
Role_Surgeon_Operating_Code,
|
|
//Role_Surgeon_Referring_Code,
|
|
//Role_Surgeon_Attending_Code,
|
|
Role_Anaesthetist_Operating_Code,
|
|
|
|
// Common properties.
|
|
Notes,
|
|
Flags,
|
|
Status,
|
|
Status_Ind,
|
|
Status_Desc,
|
|
CreateOn_Date,
|
|
UpdateOn_Date,
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
/// <summary>Properties other than common.</summary>
|
|
public class DataProperties
|
|
{
|
|
public SysId FacilityId { get; set; }
|
|
public SysId FacilityTemplateId { get; set; }
|
|
public DateTime AdmissionFrom { get; set; }
|
|
public DateTime AdmissionTo { get; set; }
|
|
public DateTime ToComeIn { get; set; }
|
|
public ushort Seq { get; set; }
|
|
public Spm.AdmissionType AdmissionType { get; set; }
|
|
public Spm.AdmissionOccupancy Occupancy { get; set; }
|
|
public DateTime DecisionToReferOn { get; set; }
|
|
public DateTime ReferredOn { get; set; }
|
|
public DateTime DecisionToAdmitOn { get; set; }
|
|
public DateTime BreechOn { get; set; }
|
|
public SysId PatientId { get; set; }
|
|
public String PatientNo { get; set; }
|
|
public String NhsNumber { get; set; }
|
|
public String Title { get; set; }
|
|
public String Forename { get; set; }
|
|
public String Surname { get; set; }
|
|
public Spm.Gender Gender { get; set; }
|
|
public DateTime BirthOn { get; set; }
|
|
public String Age { get; set; }
|
|
public DateTime AgeOn { get; set; }
|
|
public SysId FacilityIdWard { get; set; }
|
|
public String Ward { get; set; }
|
|
public SysId ProcedureId { get; set; }
|
|
public String SpecialityCode { get; set; }
|
|
public String ProcedureDesc { get; set; }
|
|
public String ComplexityCode { get; set; }
|
|
public String ProcedureIndication { get; set; }
|
|
public String PatientHistory { get; set; }
|
|
public String GestationPeriod { get; set; }
|
|
public String SystemRef { get; set; }
|
|
public ushort DurationExp { get; set; }
|
|
public ushort DurationAct { get; set; }
|
|
public decimal UnitsExp { get; set; }
|
|
public decimal UnitsAct { get; set; }
|
|
public String Anaesthetic { get; set; }
|
|
public String Position { get; set; }
|
|
public String SpecialEquipment { get; set; }
|
|
public Spm.AttendanceType AttendanceType { get; set; }
|
|
public String AttendanceStatus { get; set; }
|
|
public String ComfortScore { get; set; }
|
|
// Admission times.
|
|
public DateTime TimeCalled { get; set; }
|
|
public DateTime TimeArrived { get; set; }
|
|
public DateTime TimeAnaesStart { get; set; }
|
|
public DateTime TimeProcStart { get; set; }
|
|
public DateTime TimeProcEnd { get; set; }
|
|
public DateTime TimeInRecovery { get; set; }
|
|
public DateTime TimeInformDest { get; set; }
|
|
public DateTime TimeLeave { get; set; }
|
|
// Cancellation.
|
|
public static bool IsCancelled (Spm.AdmissionCancelType cancel) { return (cancel != Spm.AdmissionCancelType.None); }
|
|
public bool IsCancelled () { return IsCancelled(/*CancelType*/); }
|
|
public Spm.AdmissionCancelType CancelType { get; set; }
|
|
public DateTime CancelDate { get; set; }
|
|
public ushort CancelCount { get; set; }
|
|
public String CancelCode { get; set; }
|
|
public String CancelReason { get; set; }
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Data.
|
|
public new class Data : SacsHierarchyItem.Data
|
|
{
|
|
// Data members.
|
|
private readonly DataProperties data = new DataProperties();
|
|
// Construction.
|
|
public Data ()
|
|
{
|
|
Status = DefaultStatus;
|
|
}
|
|
// Properties.
|
|
public SysId FacilityId
|
|
{
|
|
get { return data.FacilityId; }
|
|
set { CheckChanged(data.FacilityId, value); data.FacilityId = value; }
|
|
}
|
|
public SysId FacilityTemplateId
|
|
{
|
|
get { return data.FacilityTemplateId; }
|
|
set { CheckChanged(data.FacilityTemplateId, value); data.FacilityTemplateId = value; }
|
|
}
|
|
public DateTime AdmissionFrom
|
|
{
|
|
get { return data.AdmissionFrom; }
|
|
set { CheckChanged(data.AdmissionFrom, value); data.AdmissionFrom = value; }
|
|
}
|
|
public DateTime AdmissionTo
|
|
{
|
|
get { return data.AdmissionTo; }
|
|
set { CheckChanged(data.AdmissionTo, value); data.AdmissionTo = value; }
|
|
}
|
|
public DateTime ToComeIn
|
|
{
|
|
get { return data.ToComeIn; }
|
|
set { CheckChanged(data.ToComeIn, value); data.ToComeIn = value; }
|
|
}
|
|
public ushort Seq
|
|
{
|
|
get { return data.Seq; }
|
|
set { CheckChanged(data.Seq, value); data.Seq = value; }
|
|
}
|
|
public Spm.AdmissionType AdmissionType
|
|
{
|
|
get { return data.AdmissionType; }
|
|
set { CheckChanged((int)data.AdmissionType, (int)value); data.AdmissionType = value; }
|
|
}
|
|
public Spm.AdmissionOccupancy Occupancy
|
|
{
|
|
get { return data.Occupancy; }
|
|
set { CheckChanged((int)data.Occupancy, (int)value); data.Occupancy = value; }
|
|
}
|
|
public DateTime DecisionToReferOn
|
|
{
|
|
get { return data.DecisionToReferOn; }
|
|
set { CheckChanged(data.DecisionToReferOn, value); data.DecisionToReferOn = value; }
|
|
}
|
|
public DateTime ReferredOn
|
|
{
|
|
get { return data.ReferredOn; }
|
|
set { CheckChanged(data.ReferredOn, value); data.ReferredOn = value; }
|
|
}
|
|
public DateTime DecisionToAdmitOn
|
|
{
|
|
get { return data.DecisionToAdmitOn; }
|
|
set { CheckChanged(data.DecisionToAdmitOn, value); data.DecisionToAdmitOn = value; }
|
|
}
|
|
public DateTime BreechOn
|
|
{
|
|
get { return data.BreechOn; }
|
|
set { CheckChanged(data.BreechOn, value); data.BreechOn = value; }
|
|
}
|
|
public SysId PatientId
|
|
{
|
|
get { return data.PatientId; }
|
|
set { CheckChanged(data.PatientId, value); data.PatientId = value; }
|
|
}
|
|
public String PatientNo
|
|
{
|
|
get { return data.PatientNo; }
|
|
set { CheckChanged(data.PatientNo, value); data.PatientNo = value; }
|
|
}
|
|
public String NhsNumber
|
|
{
|
|
get { return data.NhsNumber; }
|
|
set { CheckChanged(data.NhsNumber, value); data.NhsNumber = value; }
|
|
}
|
|
public String Title
|
|
{
|
|
get { return data.Title; }
|
|
set { CheckChanged(data.Title, value); data.Title = value; }
|
|
}
|
|
public String Forename
|
|
{
|
|
get { return data.Forename; }
|
|
set { CheckChanged(data.Forename, value); data.Forename = value; }
|
|
}
|
|
public String Surname
|
|
{
|
|
get { return data.Surname; }
|
|
set { CheckChanged(data.Surname, value); data.Surname = value; }
|
|
}
|
|
public Spm.Gender Gender
|
|
{
|
|
get { return data.Gender; }
|
|
set { CheckChanged((int)data.Gender, (int)value); data.Gender = value; }
|
|
}
|
|
public DateTime BirthOn
|
|
{
|
|
get { return data.BirthOn; }
|
|
set { CheckChanged(data.BirthOn, value); data.BirthOn = value; }
|
|
}
|
|
public String Age
|
|
{
|
|
get { return data.Age; }
|
|
set { CheckChanged(data.Age, value); data.Age = value; }
|
|
}
|
|
public DateTime AgeOn
|
|
{
|
|
get { return data.AgeOn; }
|
|
set { CheckChanged(data.AgeOn, value); data.AgeOn = value; }
|
|
}
|
|
public SysId FacilityIdWard
|
|
{
|
|
get { return data.FacilityIdWard; }
|
|
set { CheckChanged(data.FacilityIdWard, value); data.FacilityIdWard = value; }
|
|
}
|
|
public String Ward
|
|
{
|
|
get { return data.Ward; }
|
|
set { CheckChanged(data.Ward, value); data.Ward = value; }
|
|
}
|
|
public SysId ProcedureId
|
|
{
|
|
get { return data.ProcedureId; }
|
|
set { CheckChanged(data.ProcedureId, value); data.ProcedureId = value; }
|
|
}
|
|
public String SpecialityCode
|
|
{
|
|
get { return data.SpecialityCode; }
|
|
set { CheckChanged(data.SpecialityCode, value); data.SpecialityCode = value; }
|
|
}
|
|
public String ProcedureDesc
|
|
{
|
|
get { return data.ProcedureDesc; }
|
|
set { CheckChanged(data.ProcedureDesc, value); data.ProcedureDesc = value; }
|
|
}
|
|
public String ComplexityCode
|
|
{
|
|
get { return data.ComplexityCode; }
|
|
set { CheckChanged(data.ComplexityCode, value); data.ComplexityCode = value; }
|
|
}
|
|
public String ProcedureIndication
|
|
{
|
|
get { return data.ProcedureIndication; }
|
|
set { CheckChanged(data.ProcedureIndication, value); data.ProcedureIndication = value; }
|
|
}
|
|
public String PatientHistory
|
|
{
|
|
get { return data.PatientHistory; }
|
|
set { CheckChanged(data.PatientHistory, value); data.PatientHistory = value; }
|
|
}
|
|
public String GestationPeriod
|
|
{
|
|
get { return data.GestationPeriod; }
|
|
set { CheckChanged(data.GestationPeriod, value); data.GestationPeriod = value; }
|
|
}
|
|
public String SystemRef
|
|
{
|
|
get { return data.SystemRef; }
|
|
set { CheckChanged(data.SystemRef, value); data.SystemRef = value; }
|
|
}
|
|
public ushort DurationExp
|
|
{
|
|
get { return data.DurationExp; }
|
|
set { CheckChanged(data.DurationExp, value); data.DurationExp = value; }
|
|
}
|
|
public ushort DurationAct
|
|
{
|
|
get { return data.DurationAct; }
|
|
set { CheckChanged(data.DurationAct, value); data.DurationAct = value; }
|
|
}
|
|
public decimal UnitsExp
|
|
{
|
|
get { return data.UnitsExp; }
|
|
set { CheckChanged(data.UnitsExp, value); data.UnitsExp = value; }
|
|
}
|
|
public decimal UnitsAct
|
|
{
|
|
get { return data.UnitsAct; }
|
|
set { CheckChanged(data.UnitsAct, value); data.UnitsAct = value; }
|
|
}
|
|
public String Anaesthetic
|
|
{
|
|
get { return data.Anaesthetic; }
|
|
set { CheckChanged(data.Anaesthetic, value); data.Anaesthetic = value; }
|
|
}
|
|
public String Position
|
|
{
|
|
get { return data.Position; }
|
|
set { CheckChanged(data.Position, value); data.Position = value; }
|
|
}
|
|
public String SpecialEquipment
|
|
{
|
|
get { return data.SpecialEquipment; }
|
|
set { CheckChanged(data.SpecialEquipment, value); data.SpecialEquipment = value; }
|
|
}
|
|
public Spm.AttendanceType AttendanceType
|
|
{
|
|
get { return data.AttendanceType; }
|
|
set { CheckChanged((int)data.AttendanceType, (int)value); data.AttendanceType = value; }
|
|
}
|
|
public String AttendanceStatus
|
|
{
|
|
get { return data.AttendanceStatus; }
|
|
set { CheckChanged(data.AttendanceStatus, value); data.AttendanceStatus = value; }
|
|
}
|
|
public String ComfortScore
|
|
{
|
|
get { return data.ComfortScore; }
|
|
set { CheckChanged(data.ComfortScore, value); data.ComfortScore = value; }
|
|
}
|
|
// Admission time.
|
|
public DateTime TimeCalled
|
|
{
|
|
get { return data.TimeCalled; }
|
|
set { CheckChanged(data.TimeCalled, value); data.TimeCalled = value; }
|
|
}
|
|
public DateTime TimeArrived
|
|
{
|
|
get { return data.TimeArrived; }
|
|
set { CheckChanged(data.TimeArrived, value); data.TimeArrived = value; }
|
|
}
|
|
public DateTime TimeAnaesStart
|
|
{
|
|
get { return data.TimeAnaesStart; }
|
|
set { CheckChanged(data.TimeAnaesStart, value); data.TimeAnaesStart = value; }
|
|
}
|
|
public DateTime TimeProcStart
|
|
{
|
|
get { return data.TimeProcStart; }
|
|
set { CheckChanged(data.TimeProcStart, value); data.TimeProcStart = value; }
|
|
}
|
|
public DateTime TimeProcEnd
|
|
{
|
|
get { return data.TimeProcEnd; }
|
|
set { CheckChanged(data.TimeProcEnd, value); data.TimeProcEnd = value; }
|
|
}
|
|
public DateTime TimeInRecovery
|
|
{
|
|
get { return data.TimeInRecovery; }
|
|
set { CheckChanged(data.TimeInRecovery, value); data.TimeInRecovery = value; }
|
|
}
|
|
public DateTime TimeInformDest
|
|
{
|
|
get { return data.TimeInformDest; }
|
|
set { CheckChanged(data.TimeInformDest, value); data.TimeInformDest = value; }
|
|
}
|
|
public DateTime TimeLeave
|
|
{
|
|
get { return data.TimeLeave; }
|
|
set { CheckChanged(data.TimeLeave, value); data.TimeLeave = value; }
|
|
}
|
|
// Cancellation.
|
|
public Spm.AdmissionCancelType CancelType
|
|
{
|
|
get { return data.CancelType; }
|
|
set { CheckChanged((int)data.CancelType, (int)value); data.CancelType = value; }
|
|
}
|
|
public DateTime CancelDate
|
|
{
|
|
get { return data.CancelDate; }
|
|
set { CheckChanged(data.CancelDate, value); data.CancelDate = value; }
|
|
}
|
|
public ushort CancelCount
|
|
{
|
|
get { return data.CancelCount; }
|
|
set { CheckChanged(data.CancelCount, value); data.CancelCount = value; }
|
|
}
|
|
public String CancelCode
|
|
{
|
|
get { return data.CancelCode; }
|
|
set { CheckChanged(data.CancelCode, value); data.CancelCode = value; }
|
|
}
|
|
public String CancelReason
|
|
{
|
|
get { return data.CancelReason; }
|
|
set { CheckChanged(data.CancelReason, value); data.CancelReason = value; }
|
|
}
|
|
// Flags.
|
|
public bool HasRisk
|
|
{
|
|
get { return GetFlag(Flag_HasRisk); }
|
|
set { SetFlag(Flag_HasRisk, value); }
|
|
}
|
|
public bool HighlightNotes
|
|
{
|
|
get { return GetFlag(Flag_HighlightNotes); }
|
|
set { SetFlag(Flag_HighlightNotes, value); }
|
|
}
|
|
// Population.
|
|
internal void PopulateFrom (Data data)
|
|
{
|
|
FacilityId = data.FacilityId;
|
|
FacilityTemplateId = data.FacilityTemplateId;
|
|
AdmissionFrom = data.AdmissionFrom;
|
|
AdmissionTo = data.AdmissionTo;
|
|
ToComeIn = data.ToComeIn;
|
|
Seq = data.Seq;
|
|
AdmissionType = data.AdmissionType;
|
|
Occupancy = data.Occupancy;
|
|
DecisionToReferOn = data.DecisionToReferOn;
|
|
ReferredOn = data.ReferredOn;
|
|
DecisionToAdmitOn = data.DecisionToAdmitOn;
|
|
BreechOn = data.BreechOn;
|
|
PatientId = data.PatientId;
|
|
PatientNo = data.PatientNo;
|
|
NhsNumber = data.NhsNumber;
|
|
Title = data.Title;
|
|
Forename = data.Forename;
|
|
Surname = data.Surname;
|
|
Gender = data.Gender;
|
|
BirthOn = data.BirthOn;
|
|
Age = data.Age;
|
|
AgeOn = data.AgeOn;
|
|
FacilityIdWard = data.FacilityIdWard;
|
|
Ward = data.Ward;
|
|
ProcedureId = data.ProcedureId;
|
|
SpecialityCode = data.SpecialityCode;
|
|
ProcedureDesc = data.ProcedureDesc;
|
|
ComplexityCode = data.ComplexityCode;
|
|
ProcedureIndication = data.ProcedureIndication;
|
|
PatientHistory = data.PatientHistory;
|
|
GestationPeriod = data.GestationPeriod;
|
|
SystemRef = data.SystemRef;
|
|
DurationExp = data.DurationExp;
|
|
DurationAct = data.DurationAct;
|
|
UnitsExp = data.UnitsExp;
|
|
UnitsAct = data.UnitsAct;
|
|
Anaesthetic = data.Anaesthetic;
|
|
Position = data.Position;
|
|
SpecialEquipment = data.SpecialEquipment;
|
|
AttendanceType = data.AttendanceType;
|
|
AttendanceStatus = data.AttendanceStatus;
|
|
ComfortScore = data.ComfortScore;
|
|
TimeCalled = data.TimeCalled;
|
|
TimeArrived = data.TimeArrived;
|
|
TimeAnaesStart = data.TimeAnaesStart;
|
|
TimeProcStart = data.TimeProcStart;
|
|
TimeProcEnd = data.TimeProcEnd;
|
|
TimeInRecovery = data.TimeInRecovery;
|
|
TimeInformDest = data.TimeInformDest;
|
|
TimeLeave = data.TimeLeave;
|
|
CancelType = data.CancelType;
|
|
CancelDate = data.CancelDate;
|
|
CancelCount = data.CancelCount;
|
|
CancelCode = data.CancelCode;
|
|
CancelReason = data.CancelReason;
|
|
base.PopulateFrom(data);
|
|
}
|
|
public Data Clone ()
|
|
{
|
|
Data data = new Data();
|
|
data.PopulateFrom(this);
|
|
return data;
|
|
}
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Error field - identify properties with validation error.
|
|
public new class ErrField : SacsHierarchyItem.ErrField
|
|
{
|
|
public ValidValue FacilityId { get; set; } = ValidValue.Valid;
|
|
public ValidValue FacilityTemplateId { get; set; } = ValidValue.Valid;
|
|
public ValidValue AdmissionFrom { get; set; } = ValidValue.Valid;
|
|
public ValidValue AdmissionTo { get; set; } = ValidValue.Valid;
|
|
public ValidValue ToComeIn { get; set; } = ValidValue.Valid;
|
|
public ValidValue Seq { get; set; } = ValidValue.Valid;
|
|
public ValidValue AdmissionType { get; set; } = ValidValue.Valid;
|
|
public ValidValue Occupancy { get; set; } = ValidValue.Valid;
|
|
public ValidValue DecisionToReferOn { get; set; } = ValidValue.Valid;
|
|
public ValidValue ReferredOn { get; set; } = ValidValue.Valid;
|
|
public ValidValue DecisionToAdmitOn { get; set; } = ValidValue.Valid;
|
|
public ValidValue BreechOn { get; set; } = ValidValue.Valid;
|
|
public ValidValue PatientId { get; set; } = ValidValue.Valid;
|
|
public ValidValue PatientNo { get; set; } = ValidValue.Valid;
|
|
public ValidValue NhsNumber { get; set; } = ValidValue.Valid;
|
|
public ValidValue Title { get; set; } = ValidValue.Valid;
|
|
public ValidValue Forename { get; set; } = ValidValue.Valid;
|
|
public ValidValue Surname { get; set; } = ValidValue.Valid;
|
|
public ValidValue Gender { get; set; } = ValidValue.Valid;
|
|
public ValidValue BirthOn { get; set; } = ValidValue.Valid;
|
|
public ValidValue Age { get; set; } = ValidValue.Valid;
|
|
public ValidValue AgeOn { get; set; } = ValidValue.Valid;
|
|
public ValidValue FacilityIdWard { get; set; } = ValidValue.Valid;
|
|
public ValidValue Ward { get; set; } = ValidValue.Valid;
|
|
public ValidValue ProcedureId { get; set; } = ValidValue.Valid;
|
|
public ValidValue SpecialityCode { get; set; } = ValidValue.Valid;
|
|
public ValidValue ProcedureDesc { get; set; } = ValidValue.Valid;
|
|
public ValidValue ComplexityCode { get; set; } = ValidValue.Valid;
|
|
public ValidValue ProcedureIndication { get; set; } = ValidValue.Valid;
|
|
public ValidValue PatientHistory { get; set; } = ValidValue.Valid;
|
|
public ValidValue GestationPeriod { get; set; } = ValidValue.Valid;
|
|
public ValidValue SystemRef { get; set; } = ValidValue.Valid;
|
|
public ValidValue DurationExp { get; set; } = ValidValue.Valid;
|
|
public ValidValue DurationAct { get; set; } = ValidValue.Valid;
|
|
public ValidValue UnitsExp { get; set; } = ValidValue.Valid;
|
|
public ValidValue UnitsAct { get; set; } = ValidValue.Valid;
|
|
public ValidValue Anaesthetic { get; set; } = ValidValue.Valid;
|
|
public ValidValue Position { get; set; } = ValidValue.Valid;
|
|
public ValidValue SpecialEquipment { get; set; } = ValidValue.Valid;
|
|
public ValidValue AttendanceType { get; set; } = ValidValue.Valid;
|
|
public ValidValue AttendanceStatus { get; set; } = ValidValue.Valid;
|
|
public ValidValue ComfortScore { get; set; } = ValidValue.Valid;
|
|
public ValidValue TimeCalled { get; set; } = ValidValue.Valid;
|
|
public ValidValue TimeArrived { get; set; } = ValidValue.Valid;
|
|
public ValidValue TimeAnaesStart { get; set; } = ValidValue.Valid;
|
|
public ValidValue TimeProcStart { get; set; } = ValidValue.Valid;
|
|
public ValidValue TimeProcEnd { get; set; } = ValidValue.Valid;
|
|
public ValidValue TimeInRecovery { get; set; } = ValidValue.Valid;
|
|
public ValidValue TimeInformDest { get; set; } = ValidValue.Valid;
|
|
public ValidValue TimeLeave { get; set; } = ValidValue.Valid;
|
|
public ValidValue CancelType { get; set; } = ValidValue.Valid;
|
|
public ValidValue CancelDate { get; set; } = ValidValue.Valid;
|
|
public ValidValue CancelCount { get; set; } = ValidValue.Valid;
|
|
public ValidValue CancelCode { get; set; } = ValidValue.Valid;
|
|
public ValidValue CancelReason { get; set; } = ValidValue.Valid;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Data members.
|
|
private readonly Data data = new Data();
|
|
public static readonly Byte Flag_HasRisk = 0x01;
|
|
public static readonly Byte Flag_HighlightNotes = 0x02;
|
|
|
|
//-------------------------------------------------------------------
|
|
// Construction.
|
|
protected SpmAdmission (SysId facilityId, SysId facilityTemplateId) : base()
|
|
{
|
|
facilityId = FacilityId;
|
|
facilityTemplateId = FacilityTemplateId;
|
|
Status = DefaultStatus;
|
|
base.SetData(data);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Status.
|
|
private static readonly List<SaStatus> admissionStatuses = new List<SaStatus>()
|
|
{
|
|
SaStatus.Current,
|
|
};
|
|
public static SaStatus DefaultStatus { get { return SaStatus.Current; } }
|
|
public static List<SaStatus> AdmissionStatuses { get { return new List<SaStatus>(admissionStatuses); } }
|
|
public static DataValue.TriStateType GetStatusTriState (SaStatus status)
|
|
{
|
|
admissionStatuses.Add(SaStatus.Current);
|
|
|
|
switch (status)
|
|
{
|
|
case SaStatus.Current:
|
|
return DataValue.TriStateType.Green;
|
|
}
|
|
return DataValue.TriStateType.Unknown;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Utilities.
|
|
|
|
//-------------------------------------------------------------------
|
|
// Properties.
|
|
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");
|
|
this.data.PopulateFrom(data);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Attributes.
|
|
public SysId FacilityId
|
|
{
|
|
get { return data.FacilityId; }
|
|
set { data.FacilityId = value; }
|
|
}
|
|
public SysId FacilityTemplateId
|
|
{
|
|
get { return data.FacilityTemplateId; }
|
|
set { data.FacilityTemplateId = value; }
|
|
}
|
|
public DateTime AdmissionFrom
|
|
{
|
|
get { return data.AdmissionFrom; }
|
|
set { data.AdmissionFrom = value; }
|
|
}
|
|
public DateTime AdmissionTo
|
|
{
|
|
get { return data.AdmissionTo; }
|
|
set { data.AdmissionTo = value; }
|
|
}
|
|
public DateTime ToComeIn
|
|
{
|
|
get { return data.ToComeIn; }
|
|
set { data.ToComeIn = value; }
|
|
}
|
|
public static bool RequiresSeq (Spm.AdmissionType admissionType)
|
|
{
|
|
switch (admissionType)
|
|
{
|
|
// Ward and clinic admission do not require a sequence.
|
|
case Spm.AdmissionType.WardAdmission:
|
|
case Spm.AdmissionType.WardReservation:
|
|
case Spm.AdmissionType.ClinicBooking:
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
public ushort Seq
|
|
{
|
|
get { return data.Seq; }
|
|
set { data.Seq = value; }
|
|
}
|
|
public Spm.AdmissionType AdmissionType
|
|
{
|
|
get { return data.AdmissionType; }
|
|
set { data.AdmissionType = value; }
|
|
}
|
|
public bool IsTheatreAdmission ()
|
|
{
|
|
switch (AdmissionType)
|
|
{
|
|
case Spm.AdmissionType.TheatreDayCase:
|
|
case Spm.AdmissionType.TheatreInPatientElective:
|
|
case Spm.AdmissionType.TheatreEmergency:
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
public bool IsClinicAdmission ()
|
|
{
|
|
switch (AdmissionType)
|
|
{
|
|
case Spm.AdmissionType.ClinicBooking:
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
public bool IsWardAdmission ()
|
|
{
|
|
switch (AdmissionType)
|
|
{
|
|
case Spm.AdmissionType.WardAdmission:
|
|
case Spm.AdmissionType.WardReservation:
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
public Spm.AdmissionOccupancy Occupancy
|
|
{
|
|
get { return data.Occupancy; }
|
|
set { data.Occupancy = value; }
|
|
}
|
|
public DateTime DecisionToReferOn
|
|
{
|
|
get { return data.DecisionToReferOn; }
|
|
set { data.DecisionToReferOn = value; }
|
|
}
|
|
public DateTime ReferredOn
|
|
{
|
|
get { return data.ReferredOn; }
|
|
set { data.ReferredOn = value; }
|
|
}
|
|
public DateTime DecisionToAdmitOn
|
|
{
|
|
get { return data.DecisionToAdmitOn; }
|
|
set { data.DecisionToAdmitOn = value; }
|
|
}
|
|
public DateTime BreechOn
|
|
{
|
|
get { return data.BreechOn; }
|
|
set { data.BreechOn = value; }
|
|
}
|
|
public SysId PatientId
|
|
{
|
|
get { return data.PatientId; }
|
|
set { data.PatientId = value; }
|
|
}
|
|
public String PatientNo
|
|
{
|
|
get { return data.PatientNo; }
|
|
set { data.PatientNo = value; }
|
|
}
|
|
public String NhsNumber
|
|
{
|
|
get { return data.NhsNumber; }
|
|
set { data.NhsNumber = value; }
|
|
}
|
|
public String Title
|
|
{
|
|
get { return data.Title; }
|
|
set { data.Title = value; }
|
|
}
|
|
public String Forename
|
|
{
|
|
get { return data.Forename; }
|
|
set { data.Forename = value; }
|
|
}
|
|
public String Surname
|
|
{
|
|
get { return data.Surname; }
|
|
set { data.Surname = value; }
|
|
}
|
|
public static String GetDisplayName (String surname, String forename, bool upperSurname = true)
|
|
{
|
|
String name = surname;
|
|
if (upperSurname)
|
|
name.ToUpper();
|
|
if (!StringUtil.IsEmpty(surname) && !StringUtil.IsEmpty(forename))
|
|
name += ", ";
|
|
name += forename;
|
|
return name;
|
|
}
|
|
public String GetDisplayName (bool upperSurname = true)
|
|
{
|
|
return GetDisplayName(Surname, Forename, upperSurname);
|
|
}
|
|
public Spm.Gender Gender
|
|
{
|
|
get { return data.Gender; }
|
|
set { data.Gender = value; }
|
|
}
|
|
public DateTime BirthOn
|
|
{
|
|
get { return data.BirthOn; }
|
|
set { data.BirthOn = value; }
|
|
}
|
|
public String Age
|
|
{
|
|
get { return data.Age; }
|
|
set { data.Age = value; }
|
|
}
|
|
public DateTime AgeOn
|
|
{
|
|
get { return data.AgeOn; }
|
|
set { data.AgeOn = value; }
|
|
}
|
|
public String GetPatientAge (DateTime dob, DateTime ageOn)
|
|
{
|
|
String patientAge = "";
|
|
if (DateUtil.IsValid(dob) && DateUtil.IsValid(ageOn) && dob < ageOn)
|
|
{
|
|
ushort age = DateUtil.CalculateAge(dob, ageOn);
|
|
ushort ageMonths = DateUtil.CalculateAgeMonths(dob, ageOn);
|
|
if (age >= 2) patientAge = age.ToString();
|
|
else if (ageMonths > 0) patientAge = ageMonths.ToString() + "M";
|
|
}
|
|
return patientAge;
|
|
}
|
|
public SysId FacilityIdWard
|
|
{
|
|
get { return data.FacilityIdWard; }
|
|
set { data.FacilityIdWard = value; }
|
|
}
|
|
public String Ward
|
|
{
|
|
get { return data.Ward; }
|
|
set { data.Ward = value; }
|
|
}
|
|
public SysId ProcedureId
|
|
{
|
|
get { return data.ProcedureId; }
|
|
set { data.ProcedureId = value; }
|
|
}
|
|
public String SpecialityCode
|
|
{
|
|
get { return data.SpecialityCode; }
|
|
set { data.SpecialityCode = value; }
|
|
}
|
|
public String ProcedureDesc
|
|
{
|
|
get { return data.ProcedureDesc; }
|
|
set { data.ProcedureDesc = value; }
|
|
}
|
|
public String ComplexityCode
|
|
{
|
|
get { return data.ComplexityCode; }
|
|
set { data.ComplexityCode = value; }
|
|
}
|
|
public String ProcedureIndication
|
|
{
|
|
get { return data.ProcedureIndication; }
|
|
set { data.ProcedureIndication = value; }
|
|
}
|
|
public String PatientHistory
|
|
{
|
|
get { return data.PatientHistory; }
|
|
set { data.PatientHistory = value; }
|
|
}
|
|
public String GestationPeriod
|
|
{
|
|
get { return data.GestationPeriod; }
|
|
set { data.GestationPeriod = value; }
|
|
}
|
|
public String SystemRef
|
|
{
|
|
get { return data.SystemRef; }
|
|
set { data.SystemRef = value; }
|
|
}
|
|
public ushort DurationExp
|
|
{
|
|
get { return data.DurationExp; }
|
|
set { data.DurationExp = value; }
|
|
}
|
|
public ushort DurationAct
|
|
{
|
|
get { return data.DurationAct; }
|
|
set { data.DurationAct = value; }
|
|
}
|
|
public decimal UnitsExp
|
|
{
|
|
get { return data.UnitsExp; }
|
|
set { data.UnitsExp = value; }
|
|
}
|
|
public decimal UnitsAct
|
|
{
|
|
get { return data.UnitsAct; }
|
|
set { data.UnitsAct = value; }
|
|
}
|
|
public String Anaesthetic
|
|
{
|
|
get { return data.Anaesthetic; }
|
|
set { data.Anaesthetic = value; }
|
|
}
|
|
public String Position
|
|
{
|
|
get { return data.Position; }
|
|
set { data.Position = value; }
|
|
}
|
|
public String SpecialEquipment
|
|
{
|
|
get { return data.SpecialEquipment; }
|
|
set { data.SpecialEquipment = value; }
|
|
}
|
|
public Spm.AttendanceType AttendanceType
|
|
{
|
|
get { return data.AttendanceType; }
|
|
set { data.AttendanceType = value; }
|
|
}
|
|
public String AttendanceStatus
|
|
{
|
|
get { return data.AttendanceStatus; }
|
|
set { data.AttendanceStatus = value; }
|
|
}
|
|
public String ComfortScore
|
|
{
|
|
get { return data.ComfortScore; }
|
|
set { data.ComfortScore = value; }
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Admission time.
|
|
public DateTime TimeCalled
|
|
{
|
|
get { return data.TimeCalled; }
|
|
set { data.TimeCalled = value; }
|
|
}
|
|
public DateTime TimeArrived
|
|
{
|
|
get { return data.TimeArrived; }
|
|
set { data.TimeArrived = value; }
|
|
}
|
|
public DateTime TimeAnaesStart
|
|
{
|
|
get { return data.TimeAnaesStart; }
|
|
set { data.TimeAnaesStart = value; }
|
|
}
|
|
public DateTime TimeProcStart
|
|
{
|
|
get { return data.TimeProcStart; }
|
|
set { data.TimeProcStart = value; }
|
|
}
|
|
public DateTime TimeProcEnd
|
|
{
|
|
get { return data.TimeProcEnd; }
|
|
set { data.TimeProcEnd = value; }
|
|
}
|
|
public DateTime TimeInRecovery
|
|
{
|
|
get { return data.TimeInRecovery; }
|
|
set { data.TimeInRecovery = value; }
|
|
}
|
|
public DateTime TimeInformDest
|
|
{
|
|
get { return data.TimeInformDest; }
|
|
set { data.TimeInformDest = value; }
|
|
}
|
|
public DateTime TimeLeave
|
|
{
|
|
get { return data.TimeLeave; }
|
|
set { data.TimeLeave = value; }
|
|
}
|
|
//-------------------------------------------------------------------
|
|
// Cancellation.
|
|
public Spm.AdmissionCancelType CancelType
|
|
{
|
|
get { return data.CancelType; }
|
|
set { data.CancelType = value; }
|
|
}
|
|
public DateTime CancelDate
|
|
{
|
|
get { return data.CancelDate; }
|
|
set { data.CancelDate = value; }
|
|
}
|
|
public ushort CancelCount
|
|
{
|
|
get { return data.CancelCount; }
|
|
set { data.CancelCount = value; }
|
|
}
|
|
public String CancelCode
|
|
{
|
|
get { return data.CancelCode; }
|
|
set { data.CancelCode = value; }
|
|
}
|
|
public String CancelReason
|
|
{
|
|
get { return data.CancelReason; }
|
|
set { data.CancelReason = value; }
|
|
}
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
// Flags.
|
|
public bool HasRisk
|
|
{
|
|
get { return GetFlag(Flag_HasRisk); }
|
|
set { SetFlag(Flag_HasRisk, value); }
|
|
}
|
|
public bool HighlightNotes
|
|
{
|
|
get { return GetFlag(Flag_HighlightNotes); }
|
|
set { SetFlag(Flag_HighlightNotes, value); }
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// A s s o c i a t e d D a t a E l e m e n t s
|
|
//-------------------------------------------------------------------
|
|
// Admission Roles
|
|
public bool HasRoles () { return HasRole(Spm.EmployeeRole.Unknown, ""); }
|
|
public abstract bool HasRole (Spm.EmployeeRole admissionRole); // Any admission.
|
|
public abstract bool HasRole (Spm.EmployeeRole admissionRole, String admissionCode); // Specific emloyee.
|
|
public abstract List<SpmAdmissionRole> GetRoles ();
|
|
public abstract bool SetRoles (List<SpmAdmissionRole> admissionRoles); // Without commiting the changes.
|
|
public abstract bool CommitRoles ();
|
|
|
|
// Admission Action.
|
|
public bool HasActions () { return HasAction(Spm.AdmissionActionType.Unknown); }
|
|
public abstract bool HasAction (Spm.AdmissionActionType admissionActionType); // Any admission.
|
|
public abstract bool GetActions ();
|
|
public abstract bool SetActions (); // Without commiting the changes.
|
|
public abstract bool CommitActions ();
|
|
|
|
|
|
// Admission Data.
|
|
public bool HasDatas () { return HasData(Spm.AdmissionDataType.Unknown); }
|
|
public abstract bool HasData (Spm.AdmissionDataType admissionDataType); // Any admission.
|
|
public abstract bool GetDatas ();
|
|
public abstract bool SetDatas (); // Without commiting the changes.
|
|
public abstract bool CommitDatas ();
|
|
|
|
public abstract List<String> GetProcedureKits ();
|
|
public abstract List<String> GetAllergies ();
|
|
public abstract List<String> GetRiskFactors ();
|
|
public abstract bool SetProcedureKits (List<String> procedures);
|
|
public abstract bool SetAllergies (List<String> allergies);
|
|
public abstract bool SetRiskFactors (List<String> riskFactors);
|
|
|
|
public abstract bool ClearAssociatedData ();
|
|
|
|
//-------------------------------------------------------------------
|
|
// P a r a m s
|
|
//-------------------------------------------------------------------
|
|
/// <summary>Parameters - used to define the filters that should be applied to a List of Addresses</summary>
|
|
// List parameters.
|
|
public enum StatusCat
|
|
{
|
|
Any,
|
|
}
|
|
/// <summary> Item list parameters. </summary>
|
|
public new class Params : SacsHierarchyItem.Params
|
|
{
|
|
// List filtering.
|
|
public List<SysId> IncludedIds { get; } = new List<SysId>();
|
|
public List<SysId> ExcludedIds { get; } = new List<SysId>();
|
|
// Admission.
|
|
public DateTime Admission { get; set; }
|
|
public DateTime AdmissionFrom { get; set; }
|
|
public DateTime AdmissionTo { get; set; }
|
|
public SysId DepartmentId { get; set; }
|
|
public SysId FacilityId { get; set; }
|
|
public SysId FacilityTemplateId { get; set; }
|
|
public Spm.FacilityType FacilityType { get; set; }
|
|
public int MaxSeq { get; set; }
|
|
public int MinSeq { get; set; }
|
|
public Spm.AdmissionCancelType CancelType { get; set; }
|
|
public String PatientNoFull { get; set; }
|
|
public String PatientNoPartial { get; set; }
|
|
public String PatientSurname { get; set; }
|
|
|
|
public StatusCat StatusCat { get; set; } = StatusCat.Any;
|
|
}
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
// A d m i s s i o n D a t a L i s t
|
|
//=======================================================================
|
|
public static class SpmAdmissionList
|
|
{
|
|
}
|
|
|
|
//=======================================================================
|
|
}
|