getDataOwner method

Future<DataOwnerDto?> getDataOwner(
  1. String dataOwnerId
)

Implementation

Future<DataOwnerDto?> getDataOwner(String dataOwnerId) async {
  return Future.wait([
    _getHcpDataOwner(dataOwnerId),
    _getPatientDataOwner(dataOwnerId),
    _getDeviceDataOwner(dataOwnerId)
  ]).then((foundDataOwners) {
    final validDataOwners = foundDataOwners.where((dataOwner) => dataOwner != null);
    if (validDataOwners.length > 1) {
      throw FormatException("$dataOwnerId corresponds to multiple data owners");
    }
    return validDataOwners.firstOrNull;
  });
}