modifyHealthElements method
Future<List<DecryptedHealthElementDto> >
modifyHealthElements(
- UserDto user,
- List<
DecryptedHealthElementDto> healthElements, - CryptoConfig<
DecryptedHealthElementDto, HealthElementDto> config
Implementation
Future<List<DecryptedHealthElementDto>> modifyHealthElements(UserDto user, List<DecryptedHealthElementDto> healthElements,
CryptoConfig<DecryptedHealthElementDto, HealthElementDto> config) async {
final Set<String> delegations = <String>{...(user.autoDelegations["all"] ?? {}), ...(user.autoDelegations["medicalInformation"] ?? {})};
final List<HealthElementDto> encryptedHealthElements =
await Future.wait(healthElements.map((e) => config.encryptHealthElement(user.dataOwnerId()!, delegations, e)));
final List<HealthElementDto>? modifiedHealthElements = await this.rawModifyHealthElements(encryptedHealthElements);
return modifiedHealthElements != null
? await Future.wait(modifiedHealthElements.map((e) => config.decryptHealthElement(user.dataOwnerId()!, e)))
: List<DecryptedHealthElementDto>.empty();
}