# Interface IGroupedObservationService

Namespace
  adas_core.Application.Services.Interfaces

Assembly
  adas-core.Application.dll

    public interface IGroupedObservationService

Extension Methods
  NumberUtils.IsNumber(object)
  NumberUtils.ToDouble(object)
  ObjectUtils.ToStr(object?)

## Methods

### CreateNextEmptyObs(WsSubscriberGrouped)

Asynchronously creates a new empty observation for the next available slot in the grouped web service subscription.

    Task<GroupedObservation> CreateNextEmptyObs(WsSubscriberGrouped ws)

#### Parameters

`ws` WsSubscriberGrouped

  The grouped web service subscriber for which the next empty observation is created.

#### Returns

Task<GroupedObservation>

  A task that represents the asynchronous operation, containing the newly created GroupedObservation.

### FindLastObservations(ObjectId, int, List<string>?)

Retrieves the most recent observations for a specified patient, optionally filtered by observation types.

    Task<List<PatientObservation>> FindLastObservations(ObjectId patientId, int num = 2, List<string>? filterObservations = null)

#### Parameters

`patientId` ObjectId

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

`num` int

  The maximum number of recent observations to return. Defaults to 2.

`filterObservations` List<string>

  An optional list of observation names to include; if null, all observation types are considered.

#### Returns

Task<List<PatientObservation>>

  A task that resolves to a list of the most recent PatientObservation entries for the patient.

### GenerateGroupedObservation(ObjectId, GroupedField, List<GroupedObservationObs>, PatientObservation, string)

Generates a GroupedObservation for the specified patient based on the provided patient observation, grouped field configuration, and any previously recorded grouped observations, applying the supplied time zone for date and time handling.

    Task<GroupedObservation> GenerateGroupedObservation(ObjectId obsPatientId, GroupedField groupedField, List<GroupedObservation.GroupedObservationObs> wsgLastGroupedObservationObs, PatientObservation obs, string timeZoneId = "Romance Standard Time")

#### Parameters

`obsPatientId` ObjectId

  The identifier of the patient whose observation is being grouped.

`groupedField` GroupedField

  The grouped field definition that drives how the observation is categorized and aggregated.

`wsgLastGroupedObservationObs` List<GroupedObservation.GroupedObservationObs>

  The list of the most recent grouped observation entries used as context when building the new grouped observation.

`obs` PatientObservation

  The patient observation to be processed and grouped.

`timeZoneId` string

  The time zone identifier used when computing date and time values for the grouped observation. Defaults to "Romance Standard Time".

#### Returns

Task<GroupedObservation>

  A Task<TResult> that resolves to the generated grouped observation for the patient.

### GenerateGroupedObservation(ObjectId, GroupedField, string, bool, CancellationToken)

Generates a grouped observation for the specified identifier and grouped field, applying the provided time zone for time-based calculations.

    Task<GroupedObservation> GenerateGroupedObservation(ObjectId id, GroupedField groupedField, string timeZoneId = "Romance Standard Time", bool cacheIsChecked = false, CancellationToken ct = default)

#### Parameters

`id` ObjectId

  The unique identifier of the source entity used to produce the grouped observation.

`groupedField` GroupedField

  The field definition that determines how the observation is grouped.

`timeZoneId` string

  The identifier of the time zone to apply when interpreting time values. Defaults to "Romance Standard Time".

`cacheIsChecked` bool

  Indicates whether the cache should be consulted before generating the result. Defaults to `false`.

`ct` CancellationToken

  The cancellation token used to cancel the operation.

#### Returns

Task<GroupedObservation>

  A task that represents the asynchronous generation, producing the resulting GroupedObservation.