# Interface IMedicineService

Namespace
  adas_core.Application.Services.Interfaces

Assembly
  adas-core.Application.dll

    public interface IMedicineService

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

## Methods

### DeleteMedicineById(ObjectId)

Deletes a medicine record identified by the specified identifier.

    Task DeleteMedicineById(ObjectId medicineId)

#### Parameters

`medicineId` ObjectId

  The unique identifier of the medicine to delete.

#### Returns

Task

### GetActiveMedicinesByPatient(ObjectId)

Asynchronously retrieves the collection of active medicines associated with the specified patient.

    Task<IEnumerable<Medicine>> GetActiveMedicinesByPatient(ObjectId patientId)

#### Parameters

`patientId` ObjectId

  The unique identifier of the patient whose active medicines are being queried.

#### Returns

Task<IEnumerable<Medicine>>

  A task that represents the asynchronous operation, containing an enumerable collection of active Medicine records for the patient.

### GetAll()

Asynchronously retrieves all medicines from the data store.

    Task<List<Medicine>> GetAll()

#### Returns

Task<List<Medicine>>

  A task that represents the asynchronous operation, containing a list of all Medicine entities.

### GetAllCodes()

Asynchronously retrieves the complete list of available codes from the data source.

    Task<List<string>> GetAllCodes()

#### Returns

Task<List<string>>

  A task representing the asynchronous operation, containing a list of code strings.

### GetAllGroups()

Asynchronously retrieves all available groups, returning their identifiers or names as a list of strings.

    Task<List<string>> GetAllGroups()

#### Returns

Task<List<string>>

  A task that represents the asynchronous operation. The task result contains a list of strings representing all groups.

### GetAllNames()

Asynchronously retrieves all available names.

    Task<List<string>> GetAllNames()

#### Returns

Task<List<string>>

  A task that represents the asynchronous operation. The task result contains a list of all names.

### GetAllTypes()

Asynchronously retrieves all available types as a list of string identifiers.

    Task<List<string>> GetAllTypes()

#### Returns

Task<List<string>>

  A task representing the asynchronous operation, containing a list of type identifiers.

### GetByCode(string)

Asynchronously retrieves a Medicine entity by its unique code identifier. Returns `null` when no matching medicine is found.

    Task<Medicine?> GetByCode(string code)

#### Parameters

`code` string

  The unique code used to look up the medicine.

#### Returns

Task<Medicine>

  A task that represents the asynchronous operation, containing the matching Medicine or `null` if not found.

### GetByCodeOrNote(List<string>)

Retrieves a list of medicines that match the provided codes or notes.

    Task<List<Medicine>> GetByCodeOrNote(List<string> codeNote)

#### Parameters

`codeNote` List<string>

  A list of strings representing the codes or notes used to look up medicines.

#### Returns

Task<List<Medicine>>

  A task that represents the asynchronous operation. The task result contains a list of Medicine objects matching the provided codes or notes.

### GetByName(string)

Retrieves a medicine by its name, returning null if no matching medicine is found.

    Task<Medicine?> GetByName(string name)

#### Parameters

`name` string

  The name of the medicine to look up.

#### Returns

Task<Medicine>

  A task that represents the asynchronous operation, containing the matching Medicine or null if not found.

### GetMedicineById(ObjectId)

Retrieves a medicine by its unique identifier.

    Task<Medicine?> GetMedicineById(ObjectId medicineId)

#### Parameters

`medicineId` ObjectId

  The unique identifier of the medicine to retrieve.

#### Returns

Task<Medicine>

  A task that represents the asynchronous operation, containing the Medicine if found; otherwise, `null`.

### GetMedicinesOfTreatments(IEnumerable<PatientTreatment?>)

Retrieves the medicines associated with the specified patient treatments.

    Task<IEnumerable<Medicine>> GetMedicinesOfTreatments(IEnumerable<PatientTreatment?> treatments)

#### Parameters

`treatments` IEnumerable<PatientTreatment>

  The collection of patient treatments, which may include null entries, whose medicines are to be obtained.

#### Returns

Task<IEnumerable<Medicine>>

  A task that represents the asynchronous operation, containing the collection of medicines linked to the provided treatments.

### GetPaginatedMedicines(PaginationFilter)

Retrieves a paginated list of medicines based on the provided filter criteria.

    Task<PaginationResponse<Medicine>> GetPaginatedMedicines(PaginationFilter filter)

#### Parameters

`filter` PaginationFilter

  The pagination filter containing page size, page number, and optional search criteria.

#### Returns

Task<PaginationResponse<Medicine>>

  A task that represents the asynchronous operation, containing a PaginationResponse<T> with the requested Medicine items and pagination metadata.

### PostMedicine(Medicine)

Asynchronously posts a new medicine and returns the created medicine, or null if the operation fails.

    Task<Medicine?> PostMedicine(Medicine medicine)

#### Parameters

`medicine` Medicine

  The medicine entity to be posted.

#### Returns

Task<Medicine>

  A task that represents the asynchronous operation. The task result contains the posted Medicine, or null if the medicine could not be posted.

### UpdateMedicine(Medicine)

Updates an existing medicine in the data store and returns the updated entity, or `null` if no matching medicine was found.

    Task<Medicine?> UpdateMedicine(Medicine medicine)

#### Parameters

`medicine` Medicine

  The medicine entity containing the updated values to be persisted.

#### Returns

Task<Medicine>

  A task that represents the asynchronous update operation. The result is the updated Medicine when the update succeeds, or `null` when the medicine does not exist.