Skip to content

Commit

Permalink
Merge pull request #20 from microsoft/personal/namalu/version-conflic…
Browse files Browse the repository at this point in the history
…t-bug-fix

Fixed issue where observation version conflicts weren't always handled
  • Loading branch information
namalu authored Jan 3, 2020
2 parents 4b5d764 + 25c5a00 commit 6bc1386
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,24 @@ public virtual async Task<string> SaveObservationAsync(ILookupTemplate<IFhirTemp
else
{
var policyResult = await Policy<Model.Observation>
.Handle<FhirOperationException>(ex => ex.Status == System.Net.HttpStatusCode.Conflict)
.FallbackAsync(async ct =>
.Handle<FhirOperationException>(ex => ex.Status == System.Net.HttpStatusCode.Conflict || ex.Status == System.Net.HttpStatusCode.PreconditionFailed)
.RetryAsync(2, async (polyRes, attempt) =>
{
var refreshObservation = await GetObservationFromServerAsync(identifier).ConfigureAwait(false);
var mergedObservation = MergeObservation(config, refreshObservation, observationGroup);
return await _client.UpdateAsync(mergedObservation, versionAware: true).ConfigureAwait(false);
existingObservation = await GetObservationFromServerAsync(identifier).ConfigureAwait(false);
})
.ExecuteAndCaptureAsync(async () =>
{
var mergedObservation = MergeObservation(config, existingObservation, observationGroup);
return await _client.UpdateAsync(mergedObservation, versionAware: true).ConfigureAwait(false);
}).ConfigureAwait(false);

var exception = policyResult.FinalException;

if (exception != null)
{
throw exception;
}

result = policyResult.Result;
}

Expand Down

0 comments on commit 6bc1386

Please sign in to comment.