Esempio n. 1
0
        public Task WithingsRunDeviceDeletion(
            [ActivityTrigger] IDurableActivityContext context,
            CancellationToken cancellationToken)
        {
            return(exceptionFilter.FilterExceptions(async() =>
            {
                var message = context.GetInput <StartDeviceDeletionMessage>();
                var userId = message.UserId;
                var withingsDeviceIds = message.WithingsDeviceIds;

                var consent = await consentStore.FetchConsent(userId, cancellationToken);
                consent = consent.Verify(userId);

                var devices = await withingsClient.FetchDevices(userId, cancellationToken);
                var fhirDevices = converter.Convert(devices, withingsDeviceIds).ToArray();

                await fhirClient.DeleteObservations(userId, consent.FhirId, converter.ShouldDelete(withingsDeviceIds), cancellationToken);

                await SendNotifications(
                    consent,
                    messages: fhirDevices.Select(device => $"Data is now removed for {device.Display}"),
                    silent: false,
                    cancellationToken);
            }));
        }
Esempio n. 2
0
        public Task AccountDeletionFhir(
            [ActivityTrigger] IDurableActivityContext context,
            CancellationToken cancellationToken)
        {
            return(exceptionFilter.FilterExceptions(async() =>
            {
                var message = context.GetInput <StartAccountDeletionMessage>();
                var userId = message.UserId;

                var consent = await consentStore.FetchConsent(userId, cancellationToken);

                if (consent?.FhirId == null)
                {
                    return;
                }

                await fhirClient.DeleteObservations(userId, consent.FhirId, DeleteAll, cancellationToken);

                await fhirClient.DeletePatient(userId, consent.FhirId, cancellationToken);
            }));
        }