Skip to content

Commit

Permalink
New secondary indexes plus plus (#3674)
Browse files Browse the repository at this point in the history
* Secondary indexes

* Update to allow *:* _revinclude search

* Remove IsHistory filter from reference table WHERE clause

* 73

* removed ResourceType expansion and isHistory for global searches

* fix lines after merge

* ref index

* changed GivenACrossSystemQuery_WhenRewritten_GetsAllResourceTypes(

* reverted generator changes

* 27 -> 3

* temp disable _rev

* _rev back

* Skip wring history clause for search params

* sql client

* Stop resource type expansion

* resource type expansion is back

* View access

* transactions and unit test code

* Commented test script

* Extra IsHistory

* comment

---------

Co-authored-by: Jared Erwin <jaerwin@microsoft.com>
Co-authored-by: rajithaaluri <rajithaaluri@microsoft.com>
  • Loading branch information
3 people authored Jan 22, 2024
1 parent e0adbbd commit ac1852a
Show file tree
Hide file tree
Showing 26 changed files with 6,345 additions and 226 deletions.
71 changes: 70 additions & 1 deletion docs/rest/SearchExamples.http
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,73 @@ POST {{hostname}}/Patient/_search
Content-Type: application/x-www-form-urlencoded
Authorization: Bearer {{bearer.response.body.access_token}}

name=Jon
name=Jon

# The following queries and updates support testing _revinclude=*.*
# this still uses the SearchDataBatch.json above

### RevInclude=*.*
GET {{hostname}}/Patient?_id=searchpatient3&_revinclude=*:*
Authorization: Bearer {{bearer.response.body.access_token}}

### Update Good Health Clinic
PUT {{hostname}}/Organization/good
Authorization: Bearer {{bearer.response.body.access_token}}
Content-Type: application/json

{
"resourceType": "Organization",
"id": "good",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">\n \n <p>Good Health Clinic</p>\n \n </div>"
},
"identifier": [
{
"system": "urn:ietf:rfc:3986",
"value": "2.16.840.1.113883.19.5"
}
],
"name": "Good Health Clinic"
}

### Update patient 3
PUT {{hostname}}/Patient/searchpatient3
Authorization: Bearer {{bearer.response.body.access_token}}
Content-Type: application/json

{
"resourceType": "Patient",
"id": "searchpatient3",
"meta": {
"versionId": "1",
"lastUpdated": "2023-11-07T18:23:18.037+00:00"
},
"active": true,
"name": [
{
"family": "Chalmers",
"given": [
"jon"
]
}
],
"gender": "male",
"birthDate": "1975-01-12",
"address": [
{
"line": [
"Dismal Drive"
]
}
],
"generalPractitioner": [
{
"reference": "Practitioner/searchpractitioner3"
}
],
"managingOrganization" :
{
"reference" : "Organization/good"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,13 @@ private SearchResult CreateSearchResult(SearchOptions searchOptions, IEnumerable
Expression.SearchParameter(_resourceTypeSearchParameter, Expression.StringEquals(FieldName.TokenCode, null, g.Key, false)),
Expression.SearchParameter(_resourceIdSearchParameter, Expression.In(FieldName.TokenCode, null, g.Select(x => x.ResourceId))))).ToList())));

Expression expression = Expression.And(sourceTypeExpression, referenceExpression);
Expression expression = referenceExpression;

// If source type is a not a wildcard, include the sourceTypeExpression in the subquery
if (revIncludeExpression.SourceResourceType != "*")
{
expression = Expression.And(sourceTypeExpression, referenceExpression);
}

var revIncludeSearchOptions = new SearchOptions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,13 +615,13 @@ private void LogExpresssionSearchParameters(Expression expression)
}
else if (expression is IncludeExpression includeExpression)
{
LogSearchParameterData(includeExpression.ReferenceSearchParameter.Url);
LogSearchParameterData(includeExpression.ReferenceSearchParameter?.Url);
}
}

private void LogSearchParameterData(Uri url, bool isMissing = false)
{
string logOutput = string.Format("SearchParameters in search. Url: {0}.", url.OriginalString);
string logOutput = string.Format("SearchParameters in search. Url: {0}.", url?.OriginalString);

if (isMissing)
{
Expand Down
Loading

0 comments on commit ac1852a

Please sign in to comment.