using adas_core.Domain.Enums;
using adas_core.Domain.Models;
using adas_core.Domain.Models.GroupedObservations;
using adas_core.Domain.Models.Masters;
using adas_core.Domain.Models.MongoModels;
using MongoDB.Bson;
namespace adas_core.Test.Utilities;
///
/// Provides a collection of utility members to support testing operations and helper functionality.
///
public class TestUtilities
{
///
/// Creates and returns a fully populated, valid instance with predefined test values, typically used as a helper for unit testing or seeding sample data.
///
/// A new object initialized with valid identifiers, room and bed information, an available status, a default configuration, and a referenced unit.
public static PointOfCare CreateValidPointOfCare()
{
return new PointOfCare
{
Id = ObjectId.GenerateNewId(),
Room = "Test Room",
Bed = "Test Bed",
UnitId = ObjectId.GenerateNewId(),
Configuration = new PointOfCareConfiguration(),
Status = StatusEnum.PointOfCare.Available,
AdmissionId = ObjectId.GenerateNewId(),
Unit = CreateValidUnit(),
UnitName = "Test Unit"
};
}
///
/// Creates a valid instance populated with generated identifiers, current UTC timestamps, and default test values for use in test scenarios.
///
/// A fully populated object with all required fields set to valid values.
public static Discharge CreateValidDischarge()
{
return new Discharge
{
Id = ObjectId.GenerateNewId(),
PointOfCareId = ObjectId.GenerateNewId(),
UnitId = ObjectId.GenerateNewId(),
DischargeDate = DateTime.UtcNow,
PatientId = ObjectId.GenerateNewId(),
Destination = "Test Destination",
DestinationOption = CreateValidOptionList(),
ServiceOption = CreateValidOptionList(),
Service = "Test Service",
MedicalDischarge = DateTime.UtcNow,
AdminDischarge = DateTime.UtcNow,
NurseDischarge = DateTime.UtcNow
};
}
///
/// Creates and returns a new instance populated with valid test/default values, including a generated identifier, sample patient numbers, admission timestamp, and related option list entries for discharge status, altable, and origin.
///
/// A fully initialized object suitable for use in testing or seeding scenarios.
public static Patient CreateValidPatient()
{
return new Patient
{
Id = ObjectId.GenerateNewId(),
PatientNumber = "TestPatientNumber",
PatientId = "TestPatientId",
AdmTime = DateTime.UtcNow,
DischargeStatus = new OptionList
{
OptionType = "TestDischargeStatus",
Name = "TestDischargeStatusName",
IconDefault = "TestIcon",
Color = "TestColor",
Description = "TestDescription",
InitDate = DateTime.UtcNow,
EndDate = DateTime.UtcNow.AddDays(7) // Example end date
},
Altable = new OptionList
{
OptionType = "TestAltable",
Name = "TestAltableName",
IconDefault = "TestAltableIcon",
Color = "TestAltableColor",
Description = "TestAltableDescription",
InitDate = DateTime.UtcNow,
EndDate = DateTime.UtcNow.AddDays(7) // Example end date
},
Origin = new OptionList
{
OptionType = "TestOrigin",
Name = "TestOriginName",
IconDefault = "TestOriginIcon",
Color = "TestOriginColor",
Description = "TestOriginDescription",
InitDate = DateTime.UtcNow,
EndDate = DateTime.UtcNow.AddDays(7) // Example end date
}
// Initialize other properties as needed
};
}
///
/// Creates a new instance populated with predefined valid test values, typically used as a helper for unit tests or test data seeding.
///
/// An with sample values, where InitDate is set to the current UTC time and EndDate is set to one day after the current UTC time.
public static OptionList CreateValidOptionList()
{
return new OptionList
{
OptionType = "Test Option",
Name = "Test Name",
IconDefault = "Test Icon",
Color = "Test Color",
Description = "Test Description",
InitDate = DateTime.UtcNow,
EndDate = DateTime.UtcNow.AddDays(1)
};
}
///
/// Creates a valid instance populated with default test data for use in test scenarios.
///
/// A with predefined unit name, bed, and room values.
private static PatientLocation CreateValidPatientLocation()
{
return new PatientLocation
{
UnitName = "Test Unit",
Bed = "Test Bed",
Room = "Test Room"
};
}
///
/// Creates a new instance populated with valid default values, typically used for testing or seeding purposes.
///
/// A new object with a generated unique identifier, default title and name, no last update timestamp, an empty list of point of care IDs, an OK status, and a configuration with auto ADT enabled.
public static Unit CreateValidUnit()
{
return new Unit
{
Id = ObjectId.GenerateNewId(),
Title = "Test Unit",
Name = "Test Unit",
LastUpdate = null,
PointOfCareIds = [],
Status = StatusEnum.Type.Ok,
Configuration = new UnitConfiguration
{
AutoAdt = true,
}
};
}
///
/// Creates and returns a valid instance populated with sample test data, including generated unique identifiers, a test person, option lists for origin, diagnosis, insulation, language barrier, allergies, and a patient location.
///
/// A new object fully initialized with valid test values.
public static Admission CreateValidAdmission()
{
return new Admission
{
//Id = ObjectId.GenerateNewId(),
AdmissionDate = DateTime.UtcNow,
Nhc = ObjectId.GenerateNewId().ToString(),
UnitId = ObjectId.GenerateNewId(),
PointOfCareId = ObjectId.GenerateNewId(),
Person = new Person
{
FirstName = "Test First Name",
LastName = "Test Last Name"
// Initialize other properties as needed
},
Origin = CreateValidOptionList(),
OriginAux = "Test Origin Aux",
Diagnosis = CreateValidOptionList(),
DiagnosisAux = "Test Diagnosis Aux",
Allergies =
[
CreateValidOptionList(),
CreateValidOptionList()
// Add more allergies as needed
],
Insulation = CreateValidOptionList(),
LanguageBarrier = [CreateValidOptionList()],
PatientLocation = CreateValidPatientLocation()
// Initialize other properties as needed
};
}
///
/// Creates a valid instance with a default structure consisting of a single row containing one wrapped in a with a grow priority of 1.
///
/// The optional identifier for the configuration. If null, a new is generated.
/// A newly created populated with the default valid configuration.
public static CardConfig CreateValidCardConfig(ObjectId? id = null)
{
return new CardConfig
{
Id = id ?? ObjectId.GenerateNewId(),
Rows = new List
{
new()
{
Cells = new List|
{
new() { Type = DisplayConfigEnums.CellType.DemographicCell }
},
GrowPriority = 1,
Type = DisplayConfigEnums.CellType.CellWrapper
}
}
};
}
///
/// Creates a valid instance configured for the nurse display, including a demographic row containing allergy and demographic cells. If no identifier is supplied, a new is generated.
///
/// The optional identifier to assign to the configuration. When null, a new is generated.
/// A populated with the nurse display configuration.
public static CardDetailsConfig CreateValidCardDetailsNurseConfig(ObjectId? id = null)
{
return new CardDetailsConfig
{
Id = id ?? ObjectId.GenerateNewId(),
NurseRows = new List
{
new()
{
Type = DisplayConfigEnums.RowType.Demographic,
Title = "Title details",
Cells = new List
{
new()
{
Type = DisplayConfigEnums.CellType.CellWrapper,
Cells = new List
{
new()
{
Type = DisplayConfigEnums.CellType.AllergyCell
},
new()
{
Type = DisplayConfigEnums.CellType.DemographicCell
}
}
}
}
}
}
};
}
///
/// Creates a valid instance populated with a default smart section layout, including a general row that contains beacon color and isolation observations. If no identifier is supplied, a new is generated for the configuration.
///
/// The optional identifier to assign to the configuration. When null, a new is generated.
/// A configured with a predefined smart section layout.
public static CardDetailsConfig CreateValidCardDetailsSmartConfig(ObjectId? id = null)
{
return new CardDetailsConfig
{
Id = id ?? ObjectId.GenerateNewId(),
SmartSections = new List
{
new()
{
Type = DisplayConfigEnums.RowType.General,
Name = "Title details",
Rows = new List
{
new()
{
Type = DisplayConfigEnums.CellType.CellWrapper,
Observations = new List
{
new()
{
Type = DisplayConfigEnums.CellType.BeaconColor
},
new()
{
Type = DisplayConfigEnums.CellType.Isolation
}
}
}
}
}
}
};
}
///
/// Creates a valid instance, generating new values for any ID parameters that are null. Intended for use in test scenarios.
///
/// The display type to assign to the configuration.
/// The optional identifier for the display config. A new is generated when null.
/// The optional card config identifier. A new is generated when null.
/// The optional detail config identifier. A new is generated when null.
/// A fully populated with default field and hospital values.
public static DisplayConfig CreateValidDisplayConfig(DisplayConfigEnums.DisplayType type, ObjectId? id,
ObjectId? idCard, ObjectId? idDetail)
{
return new DisplayConfig
{
Id = id ?? ObjectId.GenerateNewId(),
CardConfigId = idCard ?? ObjectId.GenerateNewId(),
DetailConfigId = idDetail ?? ObjectId.GenerateNewId(),
Type = type,
FieldList = new List { new() { Name = "FR", Last = 2 } },
Hospital = "Test Hospital"
};
}
} |