# Class CacheKeys

Namespace
  adas_core.Domain.Utils

Assembly
  adas-core.Domain.dll

Generador centralizado de claves de caché.

- Prefijos normalizados para que el CacheDispatcher clasifique el backend.
- Overloads "KeyWithTtl" para devolver (key, ttl) en una llamada.

    public static class CacheKeys

Inheritance
  object
  CacheKeys

Inherited Members
  object.Equals(object)
  object.Equals(object, object)
  object.GetHashCode()
  object.GetType()
  object.MemberwiseClone()
  object.ReferenceEquals(object, object)
  object.ToString()

## Methods

### ConfigObservationsAll()

Returns the configuration key string "configObservations:all", typically used to identify a setting or cache entry related to all configuration observations.

    public static string ConfigObservationsAll()

#### Returns

string

  The string "configObservations:all".

### ConfigObservationsAllKeyWithTtl(CacheSettings?)

    public static (string Key, TimeSpan? Ttl) ConfigObservationsAllKeyWithTtl(CacheSettings? settings)

#### Parameters

`settings` CacheSettings

#### Returns

(string Key, TimeSpan? Ttl)

### DisplayBase(ObjectId)

Builds the base configuration key used to reference a display entry.

    public static string DisplayBase(ObjectId displayId)

#### Parameters

`displayId` ObjectId

  The identifier of the display whose base key is being generated.

#### Returns

string

  A formatted key string combining the display section, the display identifier, and the "base" suffix.

### DisplayBaseKeyWithTtl(CacheSettings?, ObjectId)

Builds a cache key for a display entity along with its resolved time-to-live (TTL) based on the provided cache settings.

    public static (string Key, TimeSpan? Ttl) DisplayBaseKeyWithTtl(CacheSettings? settings, ObjectId displayId)

#### Parameters

`settings` CacheSettings

  Optional cache settings used to resolve the TTL for display entities. When null, a default TTL is applied.

`displayId` ObjectId

  The identifier of the display used to compose the base cache key.

#### Returns

(string Key, TimeSpan? Ttl)

  A tuple containing the generated cache key and the resolved TTL for the display entity.

### DisplayWithConfig(ObjectId)

Builds a configuration display key for the specified display identifier, used to look up or cache the associated configuration entry.

    public static string DisplayWithConfig(ObjectId displayId)

#### Parameters

`displayId` ObjectId

  The identifier of the display whose configuration key is being generated.

#### Returns

string

  A formatted string key in the form "configDisplays:display:{displayId}:config" representing the display's configuration entry.

### DisplayWithConfigKeyWithTtl(CacheSettings?, ObjectId)

Builds a cache key and resolves its associated time-to-live (TTL) for a display entity using the provided configuration settings.

    public static (string Key, TimeSpan? Ttl) DisplayWithConfigKeyWithTtl(CacheSettings? settings, ObjectId displayId)

#### Parameters

`settings` CacheSettings

  The cache settings used to resolve the TTL for the display entity; may be `null`.

`displayId` ObjectId

  The identifier of the display entity for which the cache key is generated.

#### Returns

(string Key, TimeSpan? Ttl)

  A tuple containing the generated cache key and the resolved TTL, which may be `null` if no TTL is configured.

### GroupedObs(ObjectId, string)

Builds a formatted cache key for grouped observations associated with a specific patient, combining the grouped field name and the patient identifier.

    public static string GroupedObs(ObjectId patientId, string groupedFieldName)

#### Parameters

`patientId` ObjectId

  The unique identifier of the patient whose grouped observations are being addressed.

`groupedFieldName` string

  The name of the grouped field used to categorize the observations.

#### Returns

string

  A formatted string in the pattern `groupedObs:{groupedFieldName}:patient:{patientId}`.

### GroupedObsKeyWithTtl(CacheSettings?, ObjectId, string)

Builds a cache key for a patient's grouped observations and resolves the associated time-to-live (TTL) from the supplied cache settings.

    public static (string Key, TimeSpan? Ttl) GroupedObsKeyWithTtl(CacheSettings? settings, ObjectId patientId, string groupedFieldName)

#### Parameters

`settings` CacheSettings

  The cache settings used to resolve the TTL; may be `null`, in which case a default TTL is applied.

`patientId` ObjectId

  The identifier of the patient whose grouped observations are being cached.

`groupedFieldName` string

  The name of the grouped field used to compose the cache key.

#### Returns

(string Key, TimeSpan? Ttl)

  A tuple containing the generated cache key and the resolved TTL, which may be `null` when no expiry is configured.

### LatestObservations(ObjectId, IEnumerable<string>, int?)

Builds a cache key for retrieving the latest observations of a patient, optionally scoped to specific fields and a trailing count.

    public static string LatestObservations(ObjectId patientId, IEnumerable<string> fieldNames, int? last = null)

#### Parameters

`patientId` ObjectId

  The unique identifier of the patient whose observations are being keyed.

`fieldNames` IEnumerable<string>

  The collection of field names to include in the key, normalized via `Normalize`.

`last` int?

  Optional maximum number of recent observations to consider; when `null`, defaults to `0`.

#### Returns

string

  A formatted cache key string combining the patient id, normalized field names, and the last value.

### LatestObservationsKeyWithTtl(CacheSettings?, ObjectId, IEnumerable<string>, int?)

Generates a cache key for the latest patient observations along with its associated Time-To-Live (TTL) duration. The TTL is resolved from the provided cache settings for the PatientObservations entity type.

    public static (string Key, TimeSpan? Ttl) LatestObservationsKeyWithTtl(CacheSettings? settings, ObjectId patientId, IEnumerable<string> fieldNames, int? last = null)

#### Parameters

`settings` CacheSettings

  The optional cache settings used to resolve the TTL for the cache key.

`patientId` ObjectId

  The identifier of the patient whose latest observations are being queried.

`fieldNames` IEnumerable<string>

  The collection of field names to include in the latest observations cache key.

`last` int?

  The optional number of most recent observations to consider when building the cache key.

#### Returns

(string Key, TimeSpan? Ttl)

  A tuple containing the generated cache key and the resolved TTL for the cache entry.

### LatestPumps(ObjectId, int?)

Builds a cache key for retrieving the latest pump observations associated with the specified patient, using an optional entry count that defaults to zero when not provided.

    public static string LatestPumps(ObjectId patientId, int? last = null)

#### Parameters

`patientId` ObjectId

  The unique identifier of the patient whose latest pump observations are being requested.

`last` int?

  The optional number of most recent pump observation entries to include; when null, zero is used as a fallback.

#### Returns

string

  A formatted cache key string of the form `pumpObs:latest:{patientId}:{last}`, with `last` resolved to `0` when null.

### LatestPumpsKeyWithTtl(CacheSettings, ObjectId, int?)

Builds the cache key and resolves the TTL for the latest pump observations of a patient, optionally limited to a specified number of entries.

    public static (string Key, TimeSpan? Ttl) LatestPumpsKeyWithTtl(CacheSettings settings, ObjectId patientId, int? last = null)

#### Parameters

`settings` CacheSettings

  The cache settings used to resolve the TTL for pump observation entries.

`patientId` ObjectId

  The identifier of the patient whose latest pump observations are being cached.

`last` int?

  The optional maximum number of latest pump entries to include in the cache key.

#### Returns

(string Key, TimeSpan? Ttl)

  A tuple containing the generated cache key and the resolved TTL, which may be null if no TTL is configured.

### Normalize(IEnumerable<string>)

Normalizes a collection of strings by removing null or whitespace entries, trimming the remaining values, sorting them using ordinal (case-sensitive) comparison, and joining them with a pipe (|) delimiter to produce a canonical, comparable representation.

    public static string Normalize(IEnumerable<string> items)

#### Parameters

`items` IEnumerable<string>

  The collection of strings to normalize.

#### Returns

string

  A pipe-delimited string of the cleaned and sorted values, or an empty string if no valid entries are supplied.

### PatientAppointmentsToday(ObjectId)

Generates a cache key for a patient's appointments scheduled on the current UTC day.

    public static string PatientAppointmentsToday(ObjectId patientId)

#### Parameters

`patientId` ObjectId

  The unique identifier of the patient whose appointments are being keyed.

#### Returns

string

  A formatted cache key string combining the patient identifier and the current UTC date.

### PatientAppointmentsTodayKeyWithTtl(CacheSettings?, ObjectId)

Builds the cache key for a patient's appointments scheduled for today and resolves the associated time-to-live from the provided cache settings.

    public static (string Key, TimeSpan? Ttl) PatientAppointmentsTodayKeyWithTtl(CacheSettings? settings, ObjectId patientId)

#### Parameters

`settings` CacheSettings

  Optional cache settings used to resolve the TTL for the appointments entity.

`patientId` ObjectId

  The identifier of the patient whose appointments cache key is being generated.

#### Returns

(string Key, TimeSpan? Ttl)

  A tuple containing the generated cache key and the resolved TTL, which may be null when no TTL is configured.

### PocAppointmentsToday(ObjectId)

Builds a cache key for the appointments associated with the specified Point of Contact for the current UTC day.

    public static string PocAppointmentsToday(ObjectId pocId)

#### Parameters

`pocId` ObjectId

  The identifier of the Point of Contact whose appointments are being keyed.

#### Returns

string

  A formatted cache key string combining the PoC identifier and today's UTC date in `yyyyMMdd` format.

### PocAppointmentsTodayKeyWithTtl(CacheSettings?, ObjectId)

Builds a cache key for today's appointments associated with a Point of Care and resolves its corresponding time-to-live (TTL) using the provided cache settings for the Point of Care entity type.

    public static (string Key, TimeSpan? Ttl) PocAppointmentsTodayKeyWithTtl(CacheSettings? settings, ObjectId pocId)

#### Parameters

`settings` CacheSettings

  The cache settings used to resolve the TTL; may be `null` when no settings are supplied.

`pocId` ObjectId

  The identifier of the Point of Care whose today's appointments cache key is being generated.

#### Returns

(string Key, TimeSpan? Ttl)

  A tuple containing the generated cache key and the resolved TTL as a nullable TimeSpan.

### PointOfCareBase(ObjectId)

Generates a formatted identifier string for a Point of Care base entity, used as a cache key or lookup reference in the format "pointOfCare:{pocId}:base".

    public static string PointOfCareBase(ObjectId pocId)

#### Parameters

`pocId` ObjectId

  The unique identifier of the Point of Care entity whose base reference key is being generated.

#### Returns

string

  A formatted string that combines the "pointOfCare" prefix, the provided `pocId`, and the "base" suffix to uniquely identify the base resource of the Point of Care.

### PointOfCareBaseKeyWithTtl(CacheSettings?, ObjectId)

Builds a cache key for a Point of Care entity and resolves the associated time-to-live (TTL) from the supplied cache settings.

    public static (string Key, TimeSpan? Ttl) PointOfCareBaseKeyWithTtl(CacheSettings? settings, ObjectId pocId)

#### Parameters

`settings` CacheSettings

  The cache settings used by the TTL resolver. May be null, in which case the resolver falls back to its default behavior.

`pocId` ObjectId

  The identifier of the Point of Care entity used to generate the cache key.

#### Returns

(string Key, TimeSpan? Ttl)

  A tuple containing the generated cache key and the resolved TTL, which may be null when no expiration is configured.

### PointOfCareWithInfoKeyWithTtl(ObjectId)

Builds a cache key for a point of care entry that includes its associated information and is intended to be stored with a time-to-live (TTL).

    public static string PointOfCareWithInfoKeyWithTtl(ObjectId pocId)

#### Parameters

`pocId` ObjectId

  The identifier of the point of care used to compose the cache key.

#### Returns

string

  A formatted cache key string in the form `pointOfCare:{pocId}:withInfo`.

### PointOfCareWithInfoKeyWithTtl(CacheSettings?, ObjectId)

Builds the cache key and resolves the associated time-to-live (TTL) for caching a point of care entry, including its related information.

    public static (string Key, TimeSpan? Ttl) PointOfCareWithInfoKeyWithTtl(CacheSettings? settings, ObjectId pocId)

#### Parameters

`settings` CacheSettings

  Optional cache settings used to resolve the TTL for the point of care entity. May be `null`.

`pocId` ObjectId

  The identifier of the point of care used to build the cache key.

#### Returns

(string Key, TimeSpan? Ttl)

  A tuple containing the generated cache key and the resolved TTL, which may be `null` when no TTL is configured.