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

Added custom search example for sort by date #3646

Merged
merged 4 commits into from
Dec 22, 2023
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
64 changes: 64 additions & 0 deletions docs/rest/Data/CustomSearchPatientsAdditional.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"resourceType": "Bundle",
"type": "batch",
"entry": [
{
"resource": {
"resourceType": "Patient",
"extension": [
{
"url": "http://mycompany.org/fhir/StructureDefinition/resource-created-date",
"valueDate": "2023-07-05"
}
]
},
"request": {
"method": "POST",
"url": "Patient"
}
},
{
"resource": {
"resourceType": "Patient",
"extension": [
{
"url": "http://mycompany.org/fhir/StructureDefinition/resource-created-date",
"valueDate": "2023-06-13"
}
]
},
"request": {
"method": "POST",
"url": "Patient"
}
},
{
"resource": {
"resourceType": "Patient",
"extension": [
{
"url": "http://mycompany.org/fhir/StructureDefinition/resource-created-date",
"valueDate": "2023-12-02"
}
]
},
"request": {
"method": "POST",
"url": "Patient"
}
},
{
"resource": {
"resourceType": "Patient",
"text": {
"status": "additional",
"div": "<div><p>Null example for resource-created-date to show without :missing</p></div>"
}
},
"request": {
"method": "POST",
"url": "Patient"
}
}
]
}
17 changes: 17 additions & 0 deletions docs/rest/Data/DateCustomSearchSearchParameter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"resourceType" : "SearchParameter",
"id" : "resource-created-date",
"url" : "http://mycompany.org/fhir/SearchParameter/resource-created-date",
"version" : "1.0.0",
"name" : "ResourceCreatedDate",
"status" : "active",
"date" : "2023-12-12",
"publisher" : "My Company",
"description" : "Returns the created date on resources.",
"code" : "CreatedDate",
"base" : [
"DomainResource"
],
"type" : "date",
"expression" : "DomainResource.extension.where(url='http://mycompany.org/fhir/StructureDefinition/resource-created-date').value"
}
29 changes: 28 additions & 1 deletion docs/rest/customSearchExample.http
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ Authorization: Bearer {{bearer.response.body.access_token}}

< .\Data\CustomSearchSearchParameter2.json

### Another search param example.
PUT https://{{hostname}}/SearchParameter/resource-created-date
content-type: application/json
Authorization: Bearer {{bearer.response.body.access_token}}

< .\Data\DateCustomSearchSearchParameter.json

### Composite custom search parameter (this test data requires R4 or higher)
POST https://{{hostname}}/SearchParameter
content-type: application/json
Expand Down Expand Up @@ -105,4 +112,24 @@ x-ms-use-partial-indices: true
### A search query showing the Composite custom search parameter with Use/Postcode pair.
# The usecase would be to evaluate multiple values together in chained search queries
GET https://{{hostname}}/Patient?address-use-postcode=home$74047
Authorization: Bearer {{bearer.response.body.access_token}}
Authorization: Bearer {{bearer.response.body.access_token}}

### POST additional patient data to demonstrate sorting by a custom search parameter.
# @name patientBundle
POST https://{{hostname}}
content-type: application/json
Authorization: Bearer {{bearer.response.body.access_token}}

< ./Data/CustomSearchPatientsAdditional.json

### A search query showing sorting by a custom search parameter.
GET https://{{hostname}}/Patient?_sort=CreatedDate
Authorization: Bearer {{bearer.response.body.access_token}}

### Same as above but does not include resources that do not have the extension.
GET https://{{hostname}}/Patient?CreatedDate:missing=false&_sort=CreatedDate
Authorization: Bearer {{bearer.response.body.access_token}}

### Same as above but reversed.
GET https://{{hostname}}/Patient?CreatedDate:missing=false&_sort=-CreatedDate
Authorization: Bearer {{bearer.response.body.access_token}}