decryptPatient method
Implementation
Future<DecryptedPatientDto> decryptPatient(String dataOwnerId, PatientDto patient) async {
final es = patient.encryptedSelf;
if (es != null) {
final secret = (await this.crypto.decryptEncryptionKeys(dataOwnerId, patient.encryptionKeys)).firstOrNull?.formatAsKey().fromHexString();
if (secret == null) {
throw FormatException("Cannot get encryption key for ${patient.id} and hcp $dataOwnerId");
}
return this.unmarshaller(patient, base64.decoder.convert(es).decryptAES(secret));
} else {
return this.unmarshaller(patient, null);
}
}