Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IsDeleted check in search queries #3925

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,7 @@ public override object VisitSqlRoot(SqlRootExpression expression, SearchOptions

AppendHistoryClause(delimitedClause, context.ResourceVersionTypes); // This does not hurt today, but will be neded with resource history separation

if (expression.SearchParamTableExpressions.Count == 0)
{
AppendDeletedClause(delimitedClause, context.ResourceVersionTypes);
}
AppendDeletedClause(delimitedClause, context.ResourceVersionTypes);
}

if (!searchOptions.CountOnly)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<ItemGroup>
<EmbeddedResource Include="TestFiles\Normative\Bundle-BatchWithDuplicatedItems.json" />
<EmbeddedResource Include="TestFiles\Normative\Bundle-BatchWithConditionalUpdateByIdentifier.json" />
<EmbeddedResource Include="TestFiles\Normative\Flag.json" />
<EmbeddedResource Include="TestFiles\Normative\Import-Observation.ndjson" />
<EmbeddedResource Include="TestFiles\Normative\LegacyRawReindexJobRecord.json" />
<EmbeddedResource Include="DefinitionFiles\R5\SearchParameters.json" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"resourceType": "Flag",
"id": "example",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">Large Dog warning for Peter Patient</div>"
},
"identifier": [
{
"value": "12345"
}
],
"status": "inactive",
"category": [
{
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/flag-category",
"code": "safety",
"display": "Safety"
}
],
"text": "Safety"
}
],
"code": {
"coding": [
{
"system": "http://example.org/local",
"code": "bigdog",
"display": "Big dog"
}
],
"text": "Patient has a big dog at his home. Always always wear a suit of armor or take other active counter-measures"
},
"subject": {
"reference": "Patient/example",
"display": "Peter Patient"
},
"period": {
"start": "2015-01-17",
"end": "2016-12-01"
},
"author": {
"reference": "Practitioner/example",
"display": "Nancy Nurse"
}
}
13 changes: 13 additions & 0 deletions test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/DeleteTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,19 @@
}
}

[Fact]
public async Task GivenADeletedResource_WhenSearchWithNotModifier_ThenDeletedResourcesShouldNotBeReturned()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to write this test using tags? I don't like relying on us never using the Flag resource type in the future, it looks like it could cause hard to debug failures down the road.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did think about that, but I can't use the tag value later to search, because the resources will be deleted, and the tags should also be deleted at that point.

{
FhirResponse<Flag> response = await _client.CreateAsync(Samples.GetJsonSample("Flag").ToPoco<Flag>());
Dismissed Show dismissed Hide dismissed

// Delete all Flag resources
await _client.DeleteAllResources(ResourceType.Flag, null);

var searchResults = await _client.SearchAsync("Flag?identifier:not=123");

Assert.True(searchResults.Resource.Entry == null || searchResults.Resource.Entry.Count == 0);
}

[Fact]
[Trait(Traits.Priority, Priority.One)]
public async Task GivenAResource_WhenHardDeleting_ThenServerShouldDeleteAllRelatedResourcesSuccessfully()
Expand Down
Loading