Table of Contents

Class AbstractTimeInterval

Namespace
Core.CliniCore.Scheduling
Assembly
Core.CliniCore.dll

Base implementation for all time interval types

public abstract class AbstractTimeInterval : ITimeInterval, IIdentifiable
Inheritance
AbstractTimeInterval
Implements
Derived
Inherited Members

Constructors

AbstractTimeInterval(DateTime, DateTime, string)

protected AbstractTimeInterval(DateTime start, DateTime end, string description = "")

Parameters

start DateTime
end DateTime
description string

Properties

DayOfWeek

Gets the day of week for this interval

public DayOfWeek DayOfWeek { get; }

Property Value

DayOfWeek

Description

Description or title of this time interval

public virtual string Description { get; protected set; }

Property Value

string

Duration

Duration of the interval

public TimeSpan Duration { get; }

Property Value

TimeSpan

End

End time of the interval

public DateTime End { get; protected set; }

Property Value

DateTime

Id

Unique identifier for this time interval

public Guid Id { get; protected set; }

Property Value

Guid

Start

Start time of the interval

public DateTime Start { get; protected set; }

Property Value

DateTime

Methods

Contains(ITimeInterval)

Checks if this interval completely contains another interval

public virtual bool Contains(ITimeInterval other)

Parameters

other ITimeInterval

Returns

bool

Contains(DateTime)

Checks if this interval contains a specific point in time

public virtual bool Contains(DateTime moment)

Parameters

moment DateTime

Returns

bool

CreateMergedInterval(DateTime, DateTime, string, ITimeInterval)

Override in derived classes to create a properly typed merged interval

protected abstract ITimeInterval? CreateMergedInterval(DateTime start, DateTime end, string description, ITimeInterval other)

Parameters

start DateTime
end DateTime
description string
other ITimeInterval

Returns

ITimeInterval

Equals(object?)

Equality comparison

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetHashCode()

Hash code for dictionary storage

public override int GetHashCode()

Returns

int

GetSpecificValidationErrors()

Override in derived classes to add specific validation rules

protected virtual List<string> GetSpecificValidationErrors()

Returns

List<string>

GetValidationErrors()

Gets validation errors if the interval is not valid

public virtual List<string> GetValidationErrors()

Returns

List<string>

IsAdjacentTo(ITimeInterval)

Checks if this interval is adjacent to another (touching but not overlapping)

public virtual bool IsAdjacentTo(ITimeInterval other)

Parameters

other ITimeInterval

Returns

bool

IsBusinessHoursSlot(DateTime, DateTime)

Static helper to check if a given time slot is available

public static bool IsBusinessHoursSlot(DateTime start, DateTime end)

Parameters

start DateTime
end DateTime

Returns

bool

IsValid()

Validates that the interval is valid

public virtual bool IsValid()

Returns

bool

IsWithinBusinessHours()

Checks if this interval occurs within business hours (M-F 8am-5pm)

public virtual bool IsWithinBusinessHours()

Returns

bool

MergeWith(ITimeInterval)

Attempts to merge with another interval if they overlap or are adjacent

public virtual ITimeInterval? MergeWith(ITimeInterval other)

Parameters

other ITimeInterval

Returns

ITimeInterval

Overlaps(ITimeInterval)

Checks if this interval overlaps with another

public virtual bool Overlaps(ITimeInterval other)

Parameters

other ITimeInterval

Returns

bool

ToString()

Gets a display string for this interval

public override string ToString()

Returns

string