-
Notifications
You must be signed in to change notification settings - Fork 519
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
940406b
commit f4665e3
Showing
5 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
src/Microsoft.Health.Fhir.Core/Features/Persistence/SoftDeletedFhirPathExtension.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,19 @@ | ||
// ------------------------------------------------------------------------------------------------- | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. | ||
// ------------------------------------------------------------------------------------------------- | ||
|
||
using Microsoft.Health.Fhir.Core.Models; | ||
|
||
namespace Microsoft.Health.Fhir.Core.Features.Persistence; | ||
|
||
public static class SoftDeletedFhirPathExtension | ||
{ | ||
/// <summary> | ||
/// Return true if this resource contains the Azure 'soft-deleted' extension in meta data | ||
/// </summary> | ||
public static bool IsSoftDeleted(this ResourceElement resourceElement) | ||
{ | ||
return resourceElement.Predicate(KnownFhirPaths.IsSoftDeletedExtension); | ||
} | ||
} |
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
32 changes: 32 additions & 0 deletions
32
src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Extensions/KnowFhirPathsTests.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,32 @@ | ||
// ------------------------------------------------------------------------------------------------- | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. | ||
// ------------------------------------------------------------------------------------------------- | ||
|
||
using Microsoft.Health.Fhir.Core.Extensions; | ||
using Microsoft.Health.Fhir.Core.Features.Persistence; | ||
using Microsoft.Health.Fhir.Core.Models; | ||
using Microsoft.Health.Fhir.Tests.Common; | ||
using Microsoft.Health.Test.Utilities; | ||
using Xunit; | ||
|
||
namespace Microsoft.Health.Fhir.Shared.Core.UnitTests.Extensions; | ||
|
||
[Trait(Traits.OwningTeam, OwningTeam.Fhir)] | ||
[Trait(Traits.Category, Categories.Import)] | ||
public class KnowFhirPathsTests | ||
{ | ||
[Fact] | ||
public void GivenAResource_WhenEvaluatingIfSoftDeleted_ThenTheCorrectFlagIsReturned() | ||
{ | ||
ResourceElement patient = Samples.GetDefaultPatient(); | ||
|
||
var isDeleted = patient.IsSoftDeleted(); | ||
Assert.False(isDeleted); | ||
|
||
ResourceElement withExtension = patient.TryAddSoftDeletedExtension(); | ||
|
||
isDeleted = withExtension.IsSoftDeleted(); | ||
Assert.True(isDeleted); | ||
} | ||
} |
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