diff --git a/src/Microsoft.Health.Fhir.SqlServer/Features/Search/Expressions/Visitors/QueryGenerators/SqlQueryGenerator.cs b/src/Microsoft.Health.Fhir.SqlServer/Features/Search/Expressions/Visitors/QueryGenerators/SqlQueryGenerator.cs index bc23704a96..13ec35c98d 100644 --- a/src/Microsoft.Health.Fhir.SqlServer/Features/Search/Expressions/Visitors/QueryGenerators/SqlQueryGenerator.cs +++ b/src/Microsoft.Health.Fhir.SqlServer/Features/Search/Expressions/Visitors/QueryGenerators/SqlQueryGenerator.cs @@ -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) diff --git a/src/Microsoft.Health.Fhir.Tests.Common/Microsoft.Health.Fhir.Tests.Common.csproj b/src/Microsoft.Health.Fhir.Tests.Common/Microsoft.Health.Fhir.Tests.Common.csproj index ada76bc838..89524374d1 100644 --- a/src/Microsoft.Health.Fhir.Tests.Common/Microsoft.Health.Fhir.Tests.Common.csproj +++ b/src/Microsoft.Health.Fhir.Tests.Common/Microsoft.Health.Fhir.Tests.Common.csproj @@ -22,6 +22,7 @@ + diff --git a/src/Microsoft.Health.Fhir.Tests.Common/TestFiles/Normative/Flag.json b/src/Microsoft.Health.Fhir.Tests.Common/TestFiles/Normative/Flag.json new file mode 100644 index 0000000000..a6a2b720f3 --- /dev/null +++ b/src/Microsoft.Health.Fhir.Tests.Common/TestFiles/Normative/Flag.json @@ -0,0 +1,48 @@ +{ + "resourceType": "Flag", + "id": "example", + "text": { + "status": "generated", + "div": "
Large Dog warning for Peter Patient
" + }, + "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" + } +} diff --git a/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/DeleteTests.cs b/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/DeleteTests.cs index 4b934818c5..e2ee0b15f1 100644 --- a/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/DeleteTests.cs +++ b/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/DeleteTests.cs @@ -73,6 +73,19 @@ async Task ExecuteAndValidateGoneStatus(Func action) } } + [Fact] + public async Task GivenADeletedResource_WhenSearchWithNotModifier_ThenDeletedResourcesShouldNotBeReturned() + { + FhirResponse response = await _client.CreateAsync(Samples.GetJsonSample("Flag").ToPoco()); + + // 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()