Skip to content
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 @@ -48,13 +48,6 @@ public override SearchParameterQueryGeneratorContext VisitString(StringExpressio
return context;

case FieldName.TokenCode:
// Temporary fix, once all of the databases are reindexed truncation128 should be removed.
bool truncation128 = expression.Value.Length > 128;
if (truncation128)
{
context.StringBuilder.Append("((");
}

if (expression.Value.Length < VLatest.TokenSearchParam.Code.Metadata.MaxLength)
{
// In this case CodeOverflow in the DB table is always NULL, no need to test. There are SQL constraints in each table to enforce this.
Expand Down Expand Up @@ -82,13 +75,6 @@ public override SearchParameterQueryGeneratorContext VisitString(StringExpressio
VisitSimpleString(expression, context, VLatest.TokenSearchParam.CodeOverflow, expression.Value[codeLength..]);
}

if (truncation128)
{
context.StringBuilder.Append(") OR (");
VisitSimpleString(expression, context, VLatest.TokenSearchParam.Code, expression.Value[..128]);
context.StringBuilder.Append("))");
}

break;
default:
throw new InvalidOperationException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2335,12 +2335,6 @@ public IEnumerable<TokenListRow> GenerateRows(IList<Token> tokens)
}

yield return new TokenListRow(code, codeOverflow, token.SystemId, token.SystemValue);

// truncation128 logic: see TokenQueryGenerator or ask RB
if (token.Code.Length > 128)
{
yield return new TokenListRow(code[..128], null, token.SystemId, token.SystemValue);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public class SqlComplexQueryTests : IClassFixture<FhirStorageTestsFixture>
{
private readonly FhirStorageTestsFixture _fixture;
private readonly ITestOutputHelper _output;
private string _truncation128code = $"prefix {new string('z', 128)}";
private string _codeWithOverflow = $"prefix {new string('z', 256)}";

public SqlComplexQueryTests(FhirStorageTestsFixture fixture, ITestOutputHelper output)
Expand Down Expand Up @@ -92,10 +91,8 @@ public async Task SearchByTokens_GetResourcesByTokensIsUsed()
await CheckStoredProcedureUsage([Tuple.Create("identifier", "NotExisting|A")], 0, spName);
//// not existing system plus
await CheckStoredProcedureUsage([Tuple.Create("identifier", "NotExisting|A,TestSystem|B")], 1, spName);
//// truncation
await CheckStoredProcedureUsage([Tuple.Create("identifier", _truncation128code)], 2, spName);
//// overflow. 1 with exact match + 1 from truncate 128 logic
await CheckStoredProcedureUsage([Tuple.Create("identifier", _codeWithOverflow)], 2, spName);
//// overflow.
await CheckStoredProcedureUsage([Tuple.Create("identifier", _codeWithOverflow)], 1, spName);
}

private async Task CheckStoredProcedureUsage(IReadOnlyList<Tuple<string, string>> queryParameters, int expectedResources, string spName, bool validateSpIsUsed = true)
Expand Down Expand Up @@ -369,8 +366,6 @@ private async Task PrepareData()
await _fixture.Mediator.UpsertResourceAsync(CreateTestPatient(null, new Identifier(null, "A")).ToResourceElement());
await _fixture.Mediator.UpsertResourceAsync(CreateTestPatient(null, new Identifier("TestSystem", "B")).ToResourceElement());
await _fixture.Mediator.UpsertResourceAsync(CreateTestPatient(null, new Identifier(null, "B")).ToResourceElement());
await _fixture.Mediator.UpsertResourceAsync(CreateTestPatient(null, new Identifier(null, _truncation128code[..128])).ToResourceElement());
await _fixture.Mediator.UpsertResourceAsync(CreateTestPatient(null, new Identifier(null, _truncation128code)).ToResourceElement());
await _fixture.Mediator.UpsertResourceAsync(CreateTestPatient(null, new Identifier(null, _codeWithOverflow)).ToResourceElement());
//// search indexes are not calculated for whatever reason, so populating TokenSearchParam manually
await _fixture.SqlHelper.ExecuteSqlCmd(@$"
Expand All @@ -390,11 +385,9 @@ SELECT ResourceTypeId
,Code = CASE
WHEN RowId IN (1,2) THEN 'A'
WHEN RowId IN (3,4) THEN 'B'
WHEN RowId = 5 THEN '{_truncation128code[..128]}'
WHEN RowId = 6 THEN '{_truncation128code}'
WHEN RowId = 7 THEN '{_codeWithOverflow[..256]}'
WHEN RowId = 5 THEN '{_codeWithOverflow[..256]}'
END
,CodeOverflow = CASE WHEN RowId = 7 THEN '{_codeWithOverflow[256..]}' END
,CodeOverflow = CASE WHEN RowId = 5 THEN '{_codeWithOverflow[256..]}' END
FROM (SELECT RowId = row_number() OVER (ORDER BY ResourceSurrogateId), * FROM dbo.Resource) A
");
}
Expand Down
Loading