-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* * Address issue #184, observations not being updated when changed. - Defect was due to using two different references to the same object for the change comparison. - Updated CodeValueFhirTemplateProcessor.MergeObservation to perform a DeepCopy of the passed in Observation parameter. The copy is what is returned now by the function to ensure modifications are made to a new instance. - Moved the logic to set the status of the Observation from the MergeObservation function to the R4FhirImportService.SaveObservationAsync logic. Without the move, the first time a created observation is "updated" will always result in the FHIR resource being saved even if nothing else changed because we were always setting the status to amended. - Updated unit tests to account for new logic. - Added extension methods for some common scenarios * Rename FhirClientValidator to FhirClientValidatorExtensions to match other extension class names * Rename ServiceCollectionExtrensions to FhirClientExtensions to match purpose. * Merge content of HttpClientBuilderRegistraionExtensions into FhirClientExtensions. * Remove registering ITelemetryLogger singleton with FhirClient. ITelemetryLogger is resolved from the service provider now. This was preventing local debugging with the Azure Function. * Update AddAuthenticationHandler to use the registered singletons for the auth service instead of creating new instances. * Prior update that changed the FHIR Client lost the isVersionAware parameter. Update the FHIR Service UpdateResourceAsync to automatically set the ifMatchVersion if one isn't already specified and the resource being updated has a version set (i.e. not new). * Fix comment typo
- Loading branch information
1 parent
0600d80
commit 27ee606
Showing
10 changed files
with
205 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 0 additions & 42 deletions
42
src/lib/Microsoft.Health.Extensions.Fhir.R4/HttpClientBuilderRegistrationExtensions.cs
This file was deleted.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
src/lib/Microsoft.Health.Extensions.Fhir.R4/ObservationExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// ------------------------------------------------------------------------------------------------- | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. | ||
// ------------------------------------------------------------------------------------------------- | ||
|
||
using EnsureThat; | ||
using Hl7.Fhir.Model; | ||
|
||
namespace Microsoft.Health.Extensions.Fhir | ||
{ | ||
public static class ObservationExtensions | ||
{ | ||
/// <summary> | ||
/// Compares two observations to see if they are different. If they are different the <paramref name="updatedObservation"/> status is changed to Amended. | ||
/// </summary> | ||
/// <param name="originalObservation">The original unmodified observation.</param> | ||
/// <param name="updatedObservation">The potentially modified observation.</param> | ||
/// <returns>Returns true if the <paramref name="updatedObservation"/> is different than the <paramref name="originalObservation"/>. Otherwise false is returned.</returns> | ||
public static bool AmendIfChanged(this Observation originalObservation, Observation updatedObservation) | ||
{ | ||
EnsureArg.IsNotNull(originalObservation, nameof(originalObservation)); | ||
EnsureArg.IsNotNull(updatedObservation, nameof(updatedObservation)); | ||
EnsureArg.IsFalse(originalObservation == updatedObservation, optsFn: o => o.WithMessage($"Parameters {nameof(originalObservation)} and {nameof(updatedObservation)} are the same reference.")); | ||
|
||
if (!originalObservation.IsExactly(updatedObservation)) | ||
{ | ||
updatedObservation.Status = ObservationStatus.Amended; | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/lib/Microsoft.Health.Extensions.Fhir.R4/ResourceExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// ------------------------------------------------------------------------------------------------- | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. | ||
// ------------------------------------------------------------------------------------------------- | ||
|
||
using EnsureThat; | ||
using Hl7.Fhir.Model; | ||
|
||
namespace Microsoft.Health.Extensions.Fhir | ||
{ | ||
public static class ResourceExtensions | ||
{ | ||
/// <summary> | ||
/// Performs full deep copy of the resource. | ||
/// </summary> | ||
/// <typeparam name="TResource">Type of resource to return.</typeparam> | ||
/// <param name="resource">Resource to copy.</param> | ||
/// <returns>New resource object with the contents of the original.</returns> | ||
public static TResource FullCopy<TResource>(this TResource resource) | ||
where TResource : class, IDeepCopyable | ||
{ | ||
EnsureArg.IsNotNull(resource, nameof(resource)); | ||
|
||
return resource.DeepCopy() as TResource; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.