Table of Contents

Class MasterListServiceFactory

Namespace
adas_core.Application.Services
Assembly
adas-core.Application.dll
public class MasterListServiceFactory : IMasterListServiceFactory
Inheritance
MasterListServiceFactory
Implements
Inherited Members
Extension Methods

Constructors

MasterListServiceFactory(IServiceProvider, ILogger<MasterListServiceFactory>, IOptions<ListSettings>)

public MasterListServiceFactory(IServiceProvider serviceProvider, ILogger<MasterListServiceFactory> logger, IOptions<ListSettings> listSettings)

Parameters

serviceProvider IServiceProvider
logger ILogger<MasterListServiceFactory>
listSettings IOptions<ListSettings>

Methods

GetMasterListById(MasterListType, ObjectId, LocaleEnum?)

Asynchronously retrieves a master list item by its identifier, using reflection to dispatch the call to the appropriate service based on the specified master list type.

public Task<object?> GetMasterListById(MasterListType masterListType, ObjectId masterListId, LocaleEnum? dataLocale)

Parameters

masterListType MasterListType

The type of master list used to resolve the underlying service that will handle the request.

masterListId ObjectId

The unique identifier of the master list item to retrieve.

dataLocale LocaleEnum?

An optional locale used to localize the returned data; may be null when localization is not required.

Returns

Task<object>

A task that resolves to the retrieved master list item as an object, or null when the awaited result has no value.

Exceptions

InvalidOperationException

Thrown when no service is registered for the supplied masterListType, or when the target service does not expose a compatible GetMasterListById method matching the expected parameters.

GetMasterListOptionById(MasterListType, ObjectId, ObjectId, LocaleEnum?)

Retrieves a master list option by its identifier using reflection to dynamically resolve and invoke the appropriate service method based on the specified master list type.

public Task<object?> GetMasterListOptionById(MasterListType masterListType, ObjectId masterListId, ObjectId masterListOptionId, LocaleEnum? dataLocale)

Parameters

masterListType MasterListType

The type of master list whose service implementation should be resolved.

masterListId ObjectId

The identifier of the master list containing the option to retrieve.

masterListOptionId ObjectId

The identifier of the specific option to look up within the master list.

dataLocale LocaleEnum?

Optional locale used to localize the returned data; falls back to Default when not provided.

Returns

Task<object>

A task that resolves to the located master list option as an object, or null if the underlying task produced no result.

Exceptions

InvalidOperationException

Thrown when no service implementation is registered for the given masterListType.

InvalidOperationException

Thrown when the resolved service does not expose the expected FindOptionItemById method.

GetMasterListSpecificType(MasterListType)

Returns the specific Type associated with the given masterListType, mapping each enumeration value to its corresponding concrete list type (e.g., AllergyList, DiagnosisList, DoctorList, etc.). If no specific mapping is found, the base MasterList type is returned as the fallback.

public Type GetMasterListSpecificType(MasterListType masterListType)

Parameters

masterListType MasterListType

The enumeration value identifying which master list category to resolve to its concrete type.

Returns

Type

The Type that implements the requested master list category, or MasterList when no specific type applies.

GetPatientTraslated(Unit?, LocaleEnum?, Patient?)

Returns a patient with its option list fields translated to the specified locale, using the master list identifiers from the provided unit. If the patient is null, returns null; if the locale is Default or the unit is null, the patient is returned unchanged. Translations are applied to single or collection OptionList properties (origin, diagnosis, visits, allergies, procedures, etc.) by resolving each option's id against the matching master list and updating its Name.

public Task<Patient?> GetPatientTraslated(Unit? unit, LocaleEnum? locale, Patient? patient)

Parameters

unit Unit

The unit whose master list identifiers are used to resolve translations for each patient field.

locale LocaleEnum?

The target locale for translation; when set to Default, no translation is performed.

patient Patient

The patient whose option list values will be translated in place.

Returns

Task<Patient>

A task that resolves to the same Patient instance with translated option names, or null if the input patient is null.

GetService(Type)

Resolves a generic IMasterListService<T> instance when the requested service type is a generic MasterListService<T>. Throws an exception if the service type is not compatible or if the underlying service cannot be resolved.

public object GetService(Type serviceType)

Parameters

serviceType Type

The type of the service to resolve. Must be a generic type based on MasterListService<> to be successfully handled.

Returns

object

The resolved service instance implementing IMasterListService<T> for the corresponding item type.

Exceptions

InvalidOperationException

Thrown when the requested serviceType is not a generic MasterListService<>, or when no implementation of IMasterListService<T> can be resolved for the requested item type.

GetService(MasterListType)

Resolves and returns a service instance for the specified master list type by dynamically constructing the generic MasterListService<T> type and retrieving the registered service.

public object GetService(MasterListType serviceName)

Parameters

serviceName MasterListType

The master list type used to resolve the corresponding service type from the adas_core.Domain.Models.Masters namespace.

Returns

object

An object representing the resolved service instance for the requested master list type.

Exceptions

BadRequestException

Thrown when the type corresponding to serviceName cannot be resolved in the adas_core.Domain.Models.Masters namespace.

NotFoundException

Thrown when the generic service type cannot be constructed for the resolved type parameter.

GetTypedMasterList(MasterListType, MasterList)

Returns a specific MasterList subtype instance resolved from masterListType, with properties mapped from the provided masterList. Returns null when the specific type cannot be instantiated via reflection.

public object? GetTypedMasterList(MasterListType masterListType, MasterList masterList)

Parameters

masterListType MasterListType

The discriminator used to resolve the concrete MasterList subtype to create.

masterList MasterList

The source MasterList whose properties are mapped onto the created specific instance.

Returns

object

The created specific MasterList instance with mapped properties, or null if reflection failed to create the instance.

InsertMasterList(MasterListType, MasterList)

Inserts a master list by dynamically resolving the appropriate service for the given masterListType and invoking its InsertMasterList method via reflection.

public Task<object?> InsertMasterList(MasterListType masterListType, MasterList masterList)

Parameters

masterListType MasterListType

The type used to resolve the target service and the specific typed master list instance.

masterList MasterList

The master list entity to be converted and inserted.

Returns

Task<object>

The result produced by the dynamically invoked InsertMasterList method, or null when the awaited task exposes no result value.

Exceptions

InvalidOperationException

Thrown when no service is registered for the specified masterListType, when the master list cannot be converted to its expected typed instance, or when the InsertMasterList method cannot be found on the resolved service.

StringNurseObs()

Retrieves the list of nurse observation names by reflecting over the configured ListSettings instance, collecting the ManualObservationName of every ListSettingItem property whose value is not null or empty, and appending the fixed observation "PatientIncomingData".

public List<string> StringNurseObs()

Returns

List<string>

A list of nurse observation names, including all configured manual observations and the fixed "PatientIncomingData" entry.

UpdateMasterList(MasterListType, MasterList)

Updates a master list entry by dynamically resolving the appropriate service for the given masterListType and invoking its UpdateMasterList method via reflection on the typed master list.

public Task<object?> UpdateMasterList(MasterListType masterListType, MasterList masterList)

Parameters

masterListType MasterListType

The type of master list that determines which service to resolve and which target method to invoke.

masterList MasterList

The master list instance to be updated, which is converted to its specific type before the service method is invoked.

Returns

Task<object>

The Result value of the awaited task returned by the invoked UpdateMasterList method, or null if the result property is not available.

Exceptions

InvalidOperationException

Thrown when no service is registered for the specified masterListType.

InvalidOperationException

Thrown when the provided masterList cannot be converted to its specific typed master list.

InvalidOperationException

Thrown when the resolved service does not expose an UpdateMasterList method matching the typed master list argument.