createPatients method
Future<List<IdWithRevDto> >
createPatients(
- UserDto user,
- List<
DecryptedPatientDto> patients, - CryptoConfig<
DecryptedPatientDto, PatientDto> config
Implementation
Future<List<IdWithRevDto>> createPatients(
UserDto user, List<DecryptedPatientDto> patients, CryptoConfig<DecryptedPatientDto, PatientDto> config) async {
final Set<String> delegations = <String>{...(user.autoDelegations["all"] ?? {}), ...(user.autoDelegations["medicalInformation"] ?? {})};
final List<PatientDto> encryptedPatients = await Future.wait(patients.map((patient) async {
final initialisedPatient = await patient.initPatient().initDelegations(user, config);
return config.encryptPatient(user.dataOwnerId()!, delegations, initialisedPatient);
}));
final List<IdWithRevDto>? createdIdsAndRevs = await this.rawCreatePatients(encryptedPatients);
return createdIdsAndRevs != null ? createdIdsAndRevs : List<IdWithRevDto>.empty();
}