filterPatients method

  1. @override
Future<PaginatedListPatient?> filterPatients(
  1. Filter<Patient> filter, {
  2. String? nextPatientId,
  3. int? limit,
  4. String? startKey,
})
override

Load patients from the database by filtering them using the provided filter.

Filters are complex selectors that are built by combining basic building blocks. Examples of filters available for Patient are AllPatientsFilter and PatientsByIdsFilter. This method returns a paginated list of patient (with a cursor that lets you query the following items).

Parameters:

  • Filter filter (required): The Filter object that describes which condition(s) the elements whose the ids should be returned must fulfill

  • String nextPatientId: The id of the first patient in the next page

  • int limit: The number of patients to return in the queried page

Implementation

@override
Future<PaginatedListPatient?> filterPatients(Filter<Patient> filter, {String? nextPatientId, int? limit, String? startKey}) async {
  final localCrypto = _api.crypto;
  final currentUser = (await _api.baseUserApi.getCurrentUser())
      ?? (throw StateError("There is no user currently logged in. You must call this method from an authenticated MedTechApi"));
  final ccPatient = patientCryptoConfig(localCrypto);

  return (await base_api.PatientApiCrypto(_api.basePatientApi).filterPatientsBy(
          currentUser, base_api.FilterChain<base_api.PatientDto>(filter.toAbstractFilterDto()), startKey, nextPatientId, limit, ccPatient))
      ?.toPaginatedListPatient();
}