Class DisplayService
- Namespace
- adas_core.Application.Services
- Assembly
- adas-core.Application.dll
public class DisplayService : IDisplayService
- Inheritance
-
DisplayService
- Implements
- Inherited Members
- Extension Methods
Constructors
DisplayService(IDisplayRepository, IPointOfCareService, Lazy<IUnitService>, IDisplayConfigService, ISubscribersService, IClientMessageService, IUserRepository, IAuthService, ILogger<DisplayService>, IHttpContextAccessor, ILocalAuditService, Lazy<IPermissionService>, ICacheService, IOptions<CacheSettings>)
public DisplayService(IDisplayRepository displayRepository, IPointOfCareService pointOfCareService, Lazy<IUnitService> unitService, IDisplayConfigService displayConfigService, ISubscribersService subscribersService, IClientMessageService clientMessageService, IUserRepository userRepository, IAuthService authorityService, ILogger<DisplayService> logger, IHttpContextAccessor httpContextAccessor, ILocalAuditService auditService, Lazy<IPermissionService> permissionService, ICacheService cacheService, IOptions<CacheSettings> cacheSettings)
Parameters
displayRepositoryIDisplayRepositorypointOfCareServiceIPointOfCareServiceunitServiceLazy<IUnitService>displayConfigServiceIDisplayConfigServicesubscribersServiceISubscribersServiceclientMessageServiceIClientMessageServiceuserRepositoryIUserRepositoryauthorityServiceIAuthServiceloggerILogger<DisplayService>httpContextAccessorIHttpContextAccessorauditServiceILocalAuditServicepermissionServiceLazy<IPermissionService>cacheServiceICacheServicecacheSettingsIOptions<CacheSettings>
Methods
CountDisplaysByUnitId(ObjectId)
Asynchronously counts the number of displays associated with the specified unit identifier.
public Task<long> CountDisplaysByUnitId(ObjectId unitId)
Parameters
unitIdObjectIdThe unique identifier of the unit whose displays should be counted.
Returns
- Task<long>
A task that represents the asynchronous operation. The task result contains the total number of displays for the given unit.
DeleteDisplay(ObjectId)
Deletes a display by its identifier, removing the record, invalidating the related cache, clearing associated authorities, and recording an audit log entry.
public Task<bool> DeleteDisplay(ObjectId id)
Parameters
idObjectIdThe unique identifier of the display to delete.
Returns
Exceptions
- NotFoundException
Thrown when no display is found for the specified
id.
DeleteDisplaysByUnitId(ObjectId)
Deletes all displays associated with the specified unit identifier, invalidates the displays cache, and removes related authority data for the unit.
public Task DeleteDisplaysByUnitId(ObjectId unitId)
Parameters
unitIdObjectIdThe unique identifier of the unit whose displays and related authority data will be removed.
Returns
GetAll(string?)
Retrieves all display items, optionally filtered by the specified user name.
public Task<List<Display>> GetAll(string? userName)
Parameters
Returns
- Task<List<Display>>
A task that represents the asynchronous operation. The task result contains a list of Display items.
Exceptions
- NotImplementedException
The method has not been implemented yet.
GetAllAvailablePoc(List<string>, bool)
Retrieves all available points of care (POC) and their associated unit information for the specified display identifiers. Invalid display ID strings are silently skipped, virtual points of care can optionally be excluded, and a NotFoundException is thrown when a resolved unit cannot be found; any unexpected error is logged and an empty result is returned.
public Task<PocAndUnitDto> GetAllAvailablePoc(List<string> displayIds, bool excludeVirtual = false)
Parameters
displayIdsList<string>A list of display identifier strings used to resolve the related units and their available points of care.
excludeVirtualboolWhen set to
true, virtual points of care are excluded from the result; otherwise, they are included.
Returns
- Task<PocAndUnitDto>
A PocAndUnitDto containing the available points of care and their associated unit details.
Exceptions
- NotFoundException
Thrown when a unit associated with one of the resolved display identifiers cannot be found.
GetAllByUser(string?)
Retrieves all displays accessible to the specified user, together with their associated permissions, by resolving the user's authorizations (both unit-scoped and display-scoped). Returns an empty list when the username is null, when the user cannot be found, or when no authorizations are available; throws an exception if permissions for a unit-scoped display cannot be resolved.
public Task<List<DisplayWithPermissionsDto>> GetAllByUser(string? userName)
Parameters
userNamestringThe username whose displays should be retrieved; when null, the method returns an empty list.
Returns
- Task<List<DisplayWithPermissionsDto>>
A task that yields a list of DisplayWithPermissionsDto containing the displays the user can access along with their permissions.
Exceptions
- ForbbidenException
Thrown when permissions for a unit-scoped display cannot be obtained for the user.
GetAllCompact()
Retrieves all displays from the repository and maps them to a compact representation.
public Task<List<DisplayMinimalDto>> GetAllCompact()
Returns
- Task<List<DisplayMinimalDto>>
A task that represents the asynchronous operation, containing a list of DisplayMinimalDto with the mapped display data.
GetAllDisplaySection()
Asynchronously retrieves all display configurations of type DisplayNurse and SmartDisplay, mapping them into minimal display sections and grouping them within a display list DTO.
public Task<MinimalDisplayListDto> GetAllDisplaySection()
Returns
- Task<MinimalDisplayListDto>
A task that represents the asynchronous operation. The task result contains a MinimalDisplayListDto with the populated DisplayNurse and SmartDisplay collections.
GetAllPocsByDisplayId(ObjectId)
Retrieves all points of care associated with the specified display. Returns an empty list when the display is not found, when no associated points of care exist, or when an error occurs during retrieval.
public Task<List<PointOfCare>> GetAllPocsByDisplayId(ObjectId id)
Parameters
idObjectIdThe ObjectId of the display whose points of care should be retrieved.
Returns
- Task<List<PointOfCare>>
A list of points of care linked to the display, or an empty list if the display cannot be found or if an error is encountered.
GetByCardConfigId(ObjectId)
Retrieves a list of displays associated with the specified card configuration identifier by delegating to the underlying repository.
public Task<List<Display>> GetByCardConfigId(ObjectId configId)
Parameters
configIdObjectIdThe unique identifier of the card configuration used to look up the associated displays.
Returns
- Task<List<Display>>
A task that represents the asynchronous operation, containing a list of Display objects matching the provided card configuration identifier.
GetByConfigId(ObjectId)
Retrieves the list of displays associated with the specified configuration identifier by delegating to the display repository.
public Task<List<Display>> GetByConfigId(ObjectId configId)
Parameters
configIdObjectIdThe configuration identifier used to look up the associated displays.
Returns
- Task<List<Display>>
A task that returns the list of Display objects matching the given configuration identifier.
GetById(ObjectId)
Retrieves a Display by its unique identifier from the repository.
public Task<Display?> GetById(ObjectId id)
Parameters
idObjectIdThe unique identifier of the display to retrieve.
Returns
GetByIdWithPermissions(ObjectId, LocaleEnum)
Retrieves a display by its identifier, enriches it with localized point-of-care information, its display configuration, and the permissions available to the current user.
public Task<DisplayWithPermissionsDto> GetByIdWithPermissions(ObjectId id, LocaleEnum localeEnum)
Parameters
idObjectIdThe unique identifier of the display to retrieve.
localeEnumLocaleEnumThe locale used to localize the related point-of-care information.
Returns
- Task<DisplayWithPermissionsDto>
A DisplayWithPermissionsDto containing the display and its associated permissions.
Exceptions
- NotFoundException
Thrown when the current user cannot be identified from the JWT or when no display is found for the specified
id.
GetByName(string)
Retrieves a Display by its name. Throws a NotFoundException if no matching display is found.
public Task<Display?> GetByName(string name)
Parameters
namestringThe name of the display to look up.
Returns
Exceptions
- NotFoundException
Thrown when no display is found for the given name.
GetByPointOfCare(PointOfCare)
Retrieves a list of displays associated with the specified point of care.
public Task<List<Display>> GetByPointOfCare(PointOfCare pointOfCare)
Parameters
pointOfCarePointOfCareThe point of care used to filter the displays.
Returns
- Task<List<Display>>
A task that represents the asynchronous operation. The task result contains the list of displays matching the specified point of care.
GetByType(DisplayType)
Retrieves all displays associated with the specified display type by resolving the matching display configurations and loading their corresponding displays. Each returned display is enriched with its parent configuration, and configurations without associated displays are skipped.
public Task<List<Display>> GetByType(DisplayConfigEnums.DisplayType type)
Parameters
typeDisplayConfigEnums.DisplayTypeThe display type used to filter the display configurations.
Returns
- Task<List<Display>>
A list of displays matching the specified type, each with its related configuration assigned; an empty list is returned when no displays are found.
GetByUnitId(ObjectId)
Retrieves the list of displays associated with the specified unit identifier by delegating to the display repository.
public Task<List<Display>> GetByUnitId(ObjectId unitId)
Parameters
unitIdObjectIdThe identifier of the unit whose displays should be returned.
Returns
- Task<List<Display>>
A task that represents the asynchronous operation, containing the list of Display objects for the given unit.
GetDisplayConfigLocations(ObjectId)
Retrieves the display configuration locations associated with the specified display configuration ID, mapping each display to its corresponding unit name. If a unit cannot be found for a display, the resulting location's unit name will be null.
public Task<List<DisplayConfigLocationDto>> GetDisplayConfigLocations(ObjectId displayConfigId)
Parameters
displayConfigIdObjectIdThe identifier of the display configuration whose locations are being retrieved.
Returns
- Task<List<DisplayConfigLocationDto>>
A task that represents the asynchronous operation. The task result contains a list of DisplayConfigLocationDto objects with display and unit information.
GetDisplaySectionByUser(DisplayType, ObjectId?, string?, List<Authorization>?)
Retrieves the display sections accessible to a specific user, filtered by display type, based on the user's authorities (either provided or fetched from the authority service). Supports both direct display references and unit-based references, marks the currently selected display, and returns an empty list if the user is not found or no matching sections exist.
public Task<List<MinimalDisplaySection>> GetDisplaySectionByUser(DisplayConfigEnums.DisplayType type, ObjectId? currentDisplay, string? userName, List<Authorization>? authorizations)
Parameters
typeDisplayConfigEnums.DisplayTypeThe display type used to filter the returned sections.
currentDisplayObjectId?The identifier of the currently selected display, which will be flagged as selected in the result; may be null.
userNamestringThe username used to look up the user and their authorities; if null, an empty list is returned.
authorizationsList<Authorization>Optional pre-fetched list of user authorities; when null, authorities are retrieved from the authority service.
Returns
- Task<List<MinimalDisplaySection>>
A task that resolves to a list of MinimalDisplaySection items accessible to the user and matching the specified display type.
GetInfo(ObjectId, string?, List<Authorization>?, LocaleEnum?, bool, bool, bool, bool, CancellationToken)
Retrieves display information by id, with optional enrichment of point-of-care, patient data, and section list based on the provided flags. Uses cached data when display configuration is requested; otherwise fetches the base display and caches the result. Fetches user authorizations from the user repository when not supplied, and logs an error if the display list cannot be populated due to a missing configuration.
public Task<Display?> GetInfo(ObjectId id, string? userName, List<Authorization>? authorizations, LocaleEnum? locale, bool fillPointOfCare = true, bool fillPatientData = false, bool fillDisplayList = true, bool fillDisplayConfig = true, CancellationToken ct = default)
Parameters
idObjectIdIdentifier of the display to retrieve.
userNamestringOptional user name used to look up authorizations when none are provided.
authorizationsList<Authorization>Optional pre-resolved authorizations used to filter the display section list.
localeLocaleEnum?Optional locale applied when loading point-of-care data.
fillPointOfCareboolIf true, populates the point-of-care entries for the display.
fillPatientDataboolIf true, includes patient data when retrieving point-of-care information.
fillDisplayListboolIf true, populates the display section list filtered by the resolved authorizations.
fillDisplayConfigboolIf true, retrieves the full display including its configuration (cached); otherwise retrieves the base display.
ctCancellationTokenCancellation token to cancel the operation.
Returns
GetPaginatedDisplays(PaginationFilter)
Retrieves a paginated list of Display items along with the total document count, applying page number and page size from the provided filter.
public Task<PaginationResponse<Display>> GetPaginatedDisplays(PaginationFilter filter)
Parameters
filterPaginationFilterThe pagination filter containing the page number and page size used to determine the slice of results to return.
Returns
- Task<PaginationResponse<Display>>
A Task<TResult> containing the requested page of displays, the current page number, the page size, and the total number of documents.
InsertOne(Display)
Inserts a new Display using the default configuration for its type. If no default configuration exists for the display type, a NotFoundException is thrown. An audit log entry is created after the display is persisted.
public Task<Display> InsertOne(Display display)
Parameters
displayDisplayThe display to insert. Its
DisplayConfigIdis assigned from the resolved default configuration.
Returns
Exceptions
- NotFoundException
Thrown when no default configuration is found for the specified display type.
InsertOneTest()
Inserts a test Display record into the repository and records a corresponding audit log entry using the current HTTP context user.
public Task<Display> InsertOneTest()
Returns
IsDisplayConfigInUse(ObjectId)
Determines whether the specified display configuration is currently in use by checking if it is referenced by any related entity.
public Task<bool> IsDisplayConfigInUse(ObjectId displayConfigId)
Parameters
displayConfigIdObjectIdThe unique identifier of the display configuration to check.
Returns
- Task<bool>
trueif the display configuration is referenced by at least one entity; otherwise,false.
UpdateConfig(Display, DisplayConfig?)
Updates the configuration of an existing display by casting the new configuration to its specific type based on DisplayConfigEnums.DisplayType, supporting DisplayNurse and SmartDisplay. On a successful update, broadcasts the change, creates an audit log entry, and invalidates the related cache entry. Returns null if the provided configuration type is not supported or the cast results in null.
public Task<Display?> UpdateConfig(Display oldDisplay, DisplayConfig? newDisplayConfig)
Parameters
oldDisplayDisplayThe existing display whose configuration will be updated.
newDisplayConfigDisplayConfigThe new configuration to apply, or
nullif no update is provided.
Returns
UpdateConfigId(Display, ObjectId)
Updates the configuration ID associated with the specified display. On a successful update, the related cache entries are invalidated, a display update broadcast is sent, and an audit log entry is created.
public Task<Display?> UpdateConfigId(Display oldDisplay, ObjectId configId)
Parameters
oldDisplayDisplayThe display whose configuration ID is being updated.
configIdObjectIdThe new configuration ID to assign to the display.
Returns
UpdateConfigPreset(ObjectId, ObjectId)
Updates the configuration preset associated with the specified display, invalidates the display cache, records an audit log entry, and broadcasts a notification to subscribers based on the resolved display type (DisplayNurse, SmartDisplay, or Unknown). Throws a not-found exception when the update result or configuration cannot be resolved, and an invalid-format exception when the configuration type is not one of the handled types.
public Task<Display?> UpdateConfigPreset(ObjectId objectIdDisplay, ObjectId objectIdConfigDisplay)
Parameters
objectIdDisplayObjectIdThe identifier of the display whose configuration preset is being updated.
objectIdConfigDisplayObjectIdThe identifier of the new configuration preset to apply to the display.
Returns
Exceptions
- NotFoundException
Thrown when the update result or the resolved configuration is
null.- InvalidFormatException
Thrown when the configuration type is not one of the handled display types.
UpdateName(ObjectId, string)
Updates the name of an existing display identified by the given identifier, invalidates the related cache entries, and records an audit log entry for the change.
public Task<Display?> UpdateName(ObjectId id, string name)
Parameters
idObjectIdThe unique identifier of the display to update.
namestringThe new name to assign to the display.
Returns
Exceptions
- NotFoundException
Thrown when no display is found for the specified
id.
UpdatePointOfCareList(ObjectId, List<ObjectId>)
Updates the point of care list associated with the specified display, invalidating the related cache entries and broadcasting the change to subscribers.
public Task<Display?> UpdatePointOfCareList(ObjectId objectId, List<ObjectId> listPocObId)
Parameters
objectIdObjectIdThe identifier of the display whose point of care list is being updated.
listPocObIdList<ObjectId>The list of point of care object identifiers to assign to the display.
Returns
Exceptions
- NotFoundException
Thrown when no display exists for the specified
objectId.- ConflictException
Thrown when the point of care list update cannot be persisted.