# Interface IAdmissionRepository

Namespace
  adas_core.Application.Repositories.Interfaces

Assembly
  adas-core.Application.dll

    public interface IAdmissionRepository : IMongoRepository<Admission>

Inherited Members
  IMongoRepository<Admission>.Collection
  IMongoRepository<Admission>.GetCollectionName()
  IMongoRepository<Admission>.InsertOneAsync(Admission)
  IMongoRepository<Admission>.DeleteAsync(ObjectId)
  IMongoRepository<Admission>.UpdateOneAsync(ObjectId, Admission)

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

## Methods

### CountByUnitId(ObjectId)

Asynchronously counts the number of records associated with the specified unit identifier.

    Task<long> CountByUnitId(ObjectId unitId)

#### Parameters

`unitId` ObjectId

  The identifier of the unit used to filter the records.

#### Returns

Task<long>

  A task that represents the asynchronous operation. The task result contains the count of matching records.

### Delete(ObjectId)

Deletes the entity identified by the specified identifier.

    Task Delete(ObjectId id)

#### Parameters

`id` ObjectId

  The unique identifier of the entity to delete.

#### Returns

Task

### DeleteAdmissionsByUnitId(ObjectId)

Asynchronously deletes admissions associated with the specified unit identifier.

    Task<bool> DeleteAdmissionsByUnitId(ObjectId unitId)

#### Parameters

`unitId` ObjectId

  The identifier of the unit whose admissions will be deleted.

#### Returns

Task<bool>

  A task that represents the asynchronous operation, containing a value indicating the result of the deletion.

### DeleteMasterListOption(List<ObjectId>, OptionList, string)

Deletes the specified option from the master list for the given units and type, returning the affected admissions.

    Task<IEnumerable<Admission>> DeleteMasterListOption(List<ObjectId> unitIds, OptionList opt, string typeName)

#### Parameters

`unitIds` List<ObjectId>

  The list of unit identifiers whose master list option should be deleted.

`opt` OptionList

  The option to be removed from the master list.

`typeName` string

  The name of the type associated with the master list option.

#### Returns

Task<IEnumerable<Admission>>

  A task that represents the asynchronous operation, containing the collection of Admission records affected by the deletion.

### FindAll()

Asynchronously retrieves all admission records.

    Task<IEnumerable<Admission>> FindAll()

#### Returns

Task<IEnumerable<Admission>>

  A task that represents the asynchronous operation. The task result contains an IEnumerable<T> with all available admissions.

### FindById(ObjectId)

Asynchronously retrieves an Admission entity by its unique identifier, returning `null` when no matching record is found.

    Task<Admission?> FindById(ObjectId id)

#### Parameters

`id` ObjectId

  The MongoDB.Bson.ObjectId of the Admission to look up.

#### Returns

Task<Admission>

  A task that represents the asynchronous operation. The task result contains the matching Admission, or `null` if no admission exists with the specified identifier.

### FindByLocation(PatientLocation)

Asynchronously retrieves a list of admissions associated with the specified patient location.

    Task<List<Admission>> FindByLocation(PatientLocation location)

#### Parameters

`location` PatientLocation

  The patient location used to filter and find the relevant admissions.

#### Returns

Task<List<Admission>>

  A task that represents the asynchronous operation, containing a list of admissions matching the given location.

### FindByNhc(string)

Retrieves an admission record that matches the specified NHC (Número de Historia Clínica) identifier, or `null` when no matching admission exists.

    Task<Admission?> FindByNhc(string nhc)

#### Parameters

`nhc` string

  The NHC (clinical history number) used to look up the admission.

#### Returns

Task<Admission>

  A task that resolves to the matching Admission, or `null` if no admission is found for the given NHC.

### FindByOrigin(string)

Asynchronously retrieves a collection of admissions filtered by the specified origin.

    Task<IEnumerable<Admission>?> FindByOrigin(string origin)

#### Parameters

`origin` string

  The origin value used to filter the admissions.

#### Returns

Task<IEnumerable<Admission>>

  A task that represents the asynchronous operation, containing a collection of matching admissions, or `null` if no admissions are found for the given origin.

### FindByPointOfCareId(ObjectId)

Retrieves a list of admissions associated with the specified point of care identifier.

    Task<List<Admission>> FindByPointOfCareId(ObjectId pocId)

#### Parameters

`pocId` ObjectId

  The unique identifier of the point of care used to filter the admissions.

#### Returns

Task<List<Admission>>

  A task that represents the asynchronous operation, containing the list of admissions matching the specified point of care identifier.

### FindByUnitIds(List<ObjectId>)

Asynchronously retrieves a list of admissions associated with the specified unit identifiers.

    Task<List<Admission>> FindByUnitIds(List<ObjectId> unitIds)

#### Parameters

`unitIds` List<ObjectId>

  The list of unit identifiers used to look up the corresponding admissions.

#### Returns

Task<List<Admission>>

  A task that represents the asynchronous operation, containing the list of admissions matching the provided unit identifiers.

### GetAdmissionByUnitIdWithOutPoC(ObjectId)

Asynchronously retrieves a list of admissions associated with the specified unit, excluding Point of Care (PoC) entries.

    Task<List<Admission>> GetAdmissionByUnitIdWithOutPoC(ObjectId unitId)

#### Parameters

`unitId` ObjectId

  The unique identifier of the unit whose admissions are being retrieved.

#### Returns

Task<List<Admission>>

  A task that represents the asynchronous operation, containing a list of Admission records linked to the given unit, with PoC entries excluded.

### InsertOneAsyncAndReturn(Admission)

Asynchronously inserts a new Admission record into the data store and returns the resulting entity.

    Task<Admission?> InsertOneAsyncAndReturn(Admission origin)

#### Parameters

`origin` Admission

  The Admission entity to be inserted.

#### Returns

Task<Admission>

  A task that represents the asynchronous insert operation, containing the inserted Admission, or `null` if no result is returned.

### SearchByPatientNumberAndDistinctUnit(string, ObjectId)

Searches for an admission matching the specified patient number and unit, returning a distinct result.

    Task<Admission?> SearchByPatientNumberAndDistinctUnit(string patientNumber, ObjectId unitId)

#### Parameters

`patientNumber` string

  The patient's identifier used to locate the admission.

`unitId` ObjectId

  The unique identifier of the unit to filter the search.

#### Returns

Task<Admission>

  A Admission if a matching record is found; otherwise, `null`.

### Update(Admission)

Updates the specified admission record asynchronously.

    Task Update(Admission admission)

#### Parameters

`admission` Admission

  The admission entity containing the updated information.

#### Returns

Task

### UpdateLocation(ObjectId, ObjectId)

Updates the location of an entity identified by the specified identifier to a new location.

    Task UpdateLocation(ObjectId id, ObjectId newLocation)

#### Parameters

`id` ObjectId

  The unique identifier of the entity whose location is to be updated.

`newLocation` ObjectId

  The identifier of the new location to assign to the entity.

#### Returns

Task

### UpdateMasterListOption(List<ObjectId>, UpdateOptionMasterListDto, string)

Updates the master list option for the specified units based on the provided options and type, returning the affected admissions.

    Task<IEnumerable<Admission>> UpdateMasterListOption(List<ObjectId> unitIds, UpdateOptionMasterListDto opt, string typeName)

#### Parameters

`unitIds` List<ObjectId>

  The list of unit identifiers whose master list option should be updated.

`opt` UpdateOptionMasterListDto

  The data transfer object containing the new master list option values to apply.

`typeName` string

  The name of the option type to be updated.

#### Returns

Task<IEnumerable<Admission>>

  A task that represents the asynchronous operation, containing the collection of admissions affected by the update.

### UpdatePatient(ObjectId, Person)

Updates an existing patient record identified by the specified identifier with the provided patient information.

    Task UpdatePatient(ObjectId id, Person patient)

#### Parameters

`id` ObjectId

  The unique identifier of the patient to update.

`patient` Person

  The patient object containing the updated information to apply.

#### Returns

Task