using adas_core.Domain.Models.MongoModels;
using adas_core.Domain.Utils;
namespace adas_core.Domain.Models.Observations;
///
/// Represents a medication-related observation, extending the base type.
///
///
/// Serves as a specialized observation for capturing and modeling medication-specific data within the inheritance hierarchy.
///
public class Medication : Observation
{
public Medication()
{
}
public Medication(string id, Dictionary obj)
{
if (obj.TryGetValue("MDC_184504", out var mode)) PumpMode = new PumpMode(mode);
if (obj.TryGetValue("MDC_184519", out var status)) PumpStatus = new PumpStatus(status);
if (obj.TryGetValue("MDC_157784", out var flow)) FlowFluid = new FlowFluid(flow);
if (obj.TryGetValue("MDC_157993", out var fluid)) VolFluidTotal = new VolumeFluidDeliveryTotal(fluid);
if (obj.TryGetValue("MDCX_PUMP_DELIVERY_PRESSURE", out var pressure))
PumpDeliveryPressure = new PumpDeliveryPressure(pressure);
if (obj.TryGetValue("MDC_DEV_PUMP_ACTIVE_SOURCES", out var source))
PumpActiveSources = new PumpActiveSources(source);
if (obj.TryGetValue("MDC_184514", out var drug)) Drug = new Drug(drug);
if (obj.TryGetValue("MDC_157872", out var volume)) VolumeFluidTbiRemain = new VolumeFluidTbiRemain(volume);
if (obj.TryGetValue("MDC_157916", out var remain)) VolumeFluidTimeRemain = new VolumeFluidTimePdRemain(remain);
Id = id;
}
public string? Id { get; set; }
public PumpMode? PumpMode { get; set; }
public PumpStatus? PumpStatus { get; set; }
public FlowFluid? FlowFluid { get; set; }
public VolumeFluidDeliveryTotal? VolFluidTotal { get; set; }
public VolumeFluidTbiRemain? VolumeFluidTbiRemain { get; set; }
public VolumeFluidTimePdRemain? VolumeFluidTimeRemain { get; set; }
public PumpDeliveryPressure? PumpDeliveryPressure { get; set; }
public PumpActiveSources? PumpActiveSources { get; set; }
public Drug? Drug { get; set; }
}
///
/// Represents a value or data entry associated with a drug, such as dosage, concentration, or other pharmaceutical-related information.
///
public class DrugValue
{
public DrugValue()
{
}
public DrugValue(PumpElement pumpElement)
{
Id = pumpElement.Id;
Text = pumpElement.Text;
Time = pumpElement.Time;
Units = pumpElement.Units;
CodingSystem = pumpElement.CodingSystem;
Result = pumpElement.Result;
}
public string? Id { get; set; }
public string? Text { get; set; }
public string? Units { get; set; }
public DateTime? Time { get; set; }
public string? CodingSystem { get; set; }
public char? Result { get; set; } = 'R';
///
/// Copies the values from the specified instance into the current instance, replacing the existing Id, Text, Units, Time, CodingSystem, and Result properties.
///
/// The instance whose property values will be copied to the current instance.
public void Copy(DrugValue common)
{
Id = common.Id;
Text = common.Text;
Units = common.Units;
Time = common.Time;
CodingSystem = common.CodingSystem;
Result = common.Result;
}
}
///
/// Represents an abstract base class for drug values that are expressed as double-precision floating-point numbers, providing a common foundation for numerical drug-related data.
///
///
/// As an abstract class, it must be inherited by a derived class that supplies the concrete implementation for the double-based drug value behavior.
///
public abstract class DrugDoubleValue : DrugValue
{
protected DrugDoubleValue(PumpElement pumpElement) : base(pumpElement)
{
if (double.TryParse(pumpElement.Value?.ToString(), out var valueParsed))
Value = valueParsed;
}
public double? Value { get; set; }
}
///
/// Serves as an abstract base class for drug values represented as strings, extending .
///
///
/// Inherits from and is intended to be derived by concrete classes that encapsulate string-typed drug data associated with a .
///
public abstract class DrugStringValue(PumpElement pumpElement) : DrugValue(pumpElement)
{
public string? Value { get; set; } = pumpElement.Value?.ToString();
}
///
/// Represents a double-precision drug value that describes the flow of a fluid for the specified .
///
public class FlowFluid(PumpElement pumpElement) : DrugDoubleValue(pumpElement);
///
/// Represents the total volume of fluid delivered as a drug-related double value associated with a specific pump element.
///
///
/// Inherits from , sharing the pump element context with its base type.
///
public class VolumeFluidDeliveryTotal(PumpElement pumpElement) : DrugDoubleValue(pumpElement);
///
/// Represents the delivery pressure of a pump as a drug-related double precision value.
///
///
/// Inherits from and is constructed with a instance that is forwarded to the base constructor.
///
public class PumpDeliveryPressure(PumpElement pumpElement) : DrugDoubleValue(pumpElement);
///
/// Represents the remaining volume of fluid to be infused (TBI) associated with a pump element, implemented as a drug-related double value.
///
public class VolumeFluidTbiRemain(PumpElement pumpElement) : DrugDoubleValue(pumpElement);
///
/// Represents the remaining time for volume fluid delivery, derived from a drug double value associated with a pump element.
///
///
/// Inherits from and is constructed with a to capture time-related fluid volume metrics.
///
public class VolumeFluidTimePdRemain(PumpElement pumpElement) : DrugDoubleValue(pumpElement);
///
/// Represents the active sources of a pump element as a drug string value.
/// Inherits from , encapsulating source information for pump operations.
///
public class PumpActiveSources(PumpElement pumpElement) : DrugStringValue(pumpElement)
{
public string? ValueId { get; set; } = pumpElement.ValueId;
public string? ValueCodingSystem { get; set; } = pumpElement.ValueCodingSystem;
}
///
/// Represents a drug value associated with a pump element, inheriting from the DrugStringValue base class.
///
public class Drug(PumpElement pumpElement) : DrugStringValue(pumpElement);
///
/// Represents a pump mode as a drug-related string value, inheriting string-based value semantics from .
///
public class PumpMode : DrugStringValue
{
public PumpMode(PumpElement pumpElement) : base(pumpElement)
{
Value = pumpElement.Value?.ToString()?.SubstringAfter("pump-mode-").Replace("-", "_");
}
}
///
/// Represents the operational status of a pump as a drug-related string value.
///
public class PumpStatus : DrugStringValue
{
public PumpStatus(PumpElement pumpElement) : base(pumpElement)
{
Value = pumpElement.Value?.ToString()?.SubstringAfter("pump-status-").Replace("-", "_");
}
}