Stream: implementers
Topic: REST searching extensions
Dave Henderson (Sep 08 2017 at 10:06):
Hi all,
I'm trying to find out how I can do a GET on a resource that has been extended. For example if I have the following extension to the Organization resource to add a an organization role:
<extension url="https://fhir.com/StructureDefinition/STU3/Extension-OrganizationRole-1"> <extension url="role"> <valueCoding> <system value="https://fhir.com/STU3/OrganizationRole-1"/> <code value="176"/> <display value="A TYPE OF ORGANIZATION"/> </valueCoding> </extension>
How can I GET all records that have the code 176 ?
I've tried various GET statements and cannot get records returned that match the criteria. e.g
Any help would be appreciated.
Dave
Grahame Grieve (Sep 08 2017 at 10:07):
searching for extensions is an FAQ - possibly the number one FAQ - but it is discussed here:
Grahame Grieve (Sep 08 2017 at 10:08):
http://hl7.org/fhir/searchparameter.html#srch
Dave Henderson (Sep 08 2017 at 10:16):
Thanks Grahame, I'll take a look. I did check the HL7 FHIR website, but its not the most intuitive site to navigate and find answers, which is why I've missed information on this topic.
Grahame Grieve (Sep 08 2017 at 10:23):
we are always interested in suggestions to make it more intuitive
Dave Henderson (Sep 14 2017 at 09:04):
Hi Grahame,
Once I have confirmed how to search using extensions I'll post suggestions here. A step by step guide with examples would be useful, similar to what l have below.
This is how I think a search on extension works:
The following extension is added to lets say, a Patient profile:
<extension url="https://fhir.hl7.org.uk/STU3/StructureDefinition/Extension-EthnicCategory-1">
<valueCodeableConcept>
<coding>
<system value="https://fhir.hl7.org.uk/EthnicCategory-1"/>
<code value="01"/>
<display value="British, Mixed British"/>
</coding>
</valueCodeableConcept>
</extension>
and POSt'd to a FHIR server.
To search using this extension I create a new SearchParameter like this:
<?xml version="1.0" encoding="UTF-8"?>
<SearchParameter xmlns="http://hl7.org/fhir">
<url value="https://fhir.nhs.uk/STU3/SearchParameter/ethnic-extension-1"/>
<name value="Search Parameter on ethnic extension"/>
<status value="active"/>
<publisher value="NHS Digital"/>
<code value="ethnic"/>
<base value="Patient"/>
<type value="string"/>
<description value="Test search"/>
<expression value="Patient.extension.('https://fhir.hl7.org.uk/STU3/StructureDefinition/Extension-EthnicCategory-1')"/>
<xpathUsage value="normal"/>
</SearchParameter>
and POST to same server.
I now need to register this SearchParameter with the FHIR server by updating the CapabilityStatement rest.resource.searchParam for Patient to include:
<searchParam>
<name value="ethnic"/>
<definition value="https://fhir.nhs.uk/STU3/SearchParameter/ethnic-extension-1"/>
<type value="token"/>
</searchParam>
If all is well, I should be able to do a GET using the ethnic search parameter:
GET http://vonk.furore.com/Patient?ethnic=https://fhir.hl7.org.uk/EthnicCategory-1|01
Comments and corrections to anything incorrect would be welcomed, since this solution has not been tested yet.
Cheers
Dave
Christiaan Knaap (Sep 14 2017 at 16:22):
Hello Dave, you're on the right track but as for Vonk a few details are different:
- If not already so, get version 0.3.1 or higher of Vonk at the download page, currently at version 0.3.2
- Make sure you POST the extension to the /administration/StructureDefinition endpoint see doc
- You can not POST the SearchParameter (yet), but you feed it to Vonk at startup see doc. If you want to search existing data on this new parameter, be sure to reindex (see same page).
- You don't need to adjust the CapabilityStatement, Vonk will report the new SearchParameter automatically in it's CapabilityStatement, under the right resourcetype (in this case Patient).
Let me know how things went. If you happen to be at the WGM, I'm here as well.
Dave Henderson (Sep 15 2017 at 15:33):
Thanks for the comments Christiaan, much appreciated and very helpful in my quest to use extensions in my searches. I'll take a look and report back on my success next week. Have a nice weekend.
Dave Henderson (Sep 19 2017 at 10:59):
Hi Christiaan,
Still unable to get any results from my tests. I've POSt'd the extension, added c:\vonk\searchparams as a directory into appsettings.json and placed a searchparameters-1.xml file into that directory. Restart vonk, POST a org resource and then tried a GET using my new searchparameter, but Vonk doesn't recognize the new search code and returns all instances of Organization. I have a feeling Vonk has not loaded the searchparameter from the file in the directory.
I must be doing something wrong. Any guidance would be appreciated. Anyone else who wishes to jump in as well, please do.
Some supporting info below.
appsettings.json:
"SearchParametersImportOptions": {
"Enabled": true,
"Sets": [
{
"Path": "",
"Source": "Api"
},
{ "Path": "c:/vonk/searchparams",
"Source": "Directory"
}
]
},
The searchparameter-1.xml
<SearchParameter>
<url value="https://fhir.nhs.uk/STU3/SearchParameter/ODSAPI-OrganizationRole-Role-1" />
<name value="ODS API Organization Role" />
<status value="draft" />
<experimental value="true" />
<date value="2017-09-12" />
<publisher value="A publisher" />
<purpose value="This search parameter has been defined to enable the ability to query on the role of an ODS Organization." />
<code value="ods-org-role" />
<base value="Organization" />
<type value="token" />
<description value="A search parameter to query on the role of an ODS Organization." />
<expression value="Organization.extension('https://fhir.nhs.uk/STU3/StructureDefinition/Extension-ODSAPI-OrganizationRole-1').extension('role')" />
<xpath value="f:Organization/f:extension[@url='https://fhir.nhs.uk/STU3/StructureDefinition/Extension-ODSAPI-OrganizationRole-1']/f:extension[@url='role']" />
<xpathUsage value="normal" />
<comparator value="eq" />
<modifier value="exact" />
</SearchParameter>
POST http://localhost:4080/administration/StructureDefinition
and place structuredefintion of extension into body.
Organization:
<?xml version="1.0" encoding="UTF-8"?>
<Organization xmlns="http://hl7.org/fhir">
<meta>
<lastUpdated value="2017-09-14T00:01:00+00:00"/>
</meta>
<extension url="https://fhir.nhs.uk/StructureDefinition/STU3/Extension-ODSAPI-ActivePeriod-1">
<valuePeriod>
<extension url="https://fhir.nhs.uk/StructureDefinition/STU3/Extension-ODSAPI-DateType-1">
<valueString value="Operational"/>
</extension>
<start value="2005-04-01"/>
</valuePeriod>
</extension>
<extension url="https://fhir.nhs.uk/StructureDefinition/STU3/Extension-ODSAPI-OrganizationRole-1">
<extension url="role">
<valueCoding>
<system value="https://fhir.nhs.uk/STU3/ODSAPI-OrganizationRole-1"/>
<code value="197"/>
<display value="NHS TRUST"/>
</valueCoding>
</extension>
<extension url="primaryRole">
<valueBoolean value="true"/>
</extension>
<extension url="activePeriod">
<valuePeriod>
<extension url="https://fhir.nhs.uk/StructureDefinition/STU3/Extension-ODSAPI-DateType-1">
<valueString value="Operational"/>
</extension>
<start value="2005-04-01"/>
</valuePeriod>
</extension>
<extension url="status">
<valueString value="Active"/>
</extension>
</extension>
<identifier>
<system value="https://fhir.nhs.uk/Id/ods-organization-code"/>
<value value="RXX"/>
</identifier>
<active value="true"/>
<type>
<coding>
<system value="https://fhir.nhs.uk/STU3/ODSAPI-OrganizationRecordClass-1"/>
<code value="2"/>
<display value="HSCSite"/>
</coding>
</type>
<name value="A Location Name"/>
<telecom>
<system value="phone"/>
<value value="01111 205822"/>
</telecom>
<telecom>
<system value="fax"/>
<value value="01999 383511"/>
</telecom>
<address>
<line value="20 BUSINESS PARK"/>
<line value="RANDALLS ROAD"/>
<city value="LEATHERHEAD"/>
<district value="SURREY"/>
<postalCode value="KT11 7AD"/>
<country value="ENGLAND"/>
</address>
</Organization>
Computer says no :-(
Cheers
Dave
Christiaan Knaap (Sep 21 2017 at 18:22):
Well, that's annoying.
Christiaan Knaap (Sep 21 2017 at 18:34):
I've investigated quickly, first by validating the SearchParameter (https://vonk.furore.com/SearchParameter/$validate) and that reveiled that the namespace is missing. If you start with
<SearchParameter xmlns="http://hl7.org/fhir">
It will validate.
This is probably the cause why Vonk did not pick up the SearchParameter. We're aware that the error is not logged properly and will improve that.
Kevin Mayfield (Sep 22 2017 at 20:54):
Are you trying to use the example you’ve given in the real world? I believe the extension you’re searching on should ideally be a NHS / CareConnect ValueSet on organisation.type. I’m having this issue at the moment loading loading in ODS/ SDS data files.
Kevin Mayfield (Sep 22 2017 at 20:57):
FYI UK guidance can be found here for organisation https://nhsconnect.github.io/CareConnectAPI/api_entity_organisation.html
Haseeb (Oct 04 2017 at 15:12):
Hi @Christiaan this seems to be the most relevant thread. Basically I am trying to get 'actor' SearchParameter to work with Schedule like this: /Schedule/?actor=HealthcareService/dbf07ab6-db6e-4230-8fea-6ceffde5c2f3
Following the example in SearchParameter resource of FHIR website, I created the following json and posted saved it in C:\vonk\searchparameter:
{
"resourceType": "SearchParameter",
"url": "http://hl7.org/fhir/SearchParameter/ov",
"name": "Actor Search Parameter",
"status": "draft",
"experimental": true,
"date": "2017-10-04",
"publisher": "OV",
"contact": [
{
"name": "[string]",
"telecom": [
{
"system": "url",
"value": "http://hl7.org/fhir"
}
]
}
],
"purpose": "Need to search Schedule by actor",
"code": "actor",
"base": [
"Schedule"
],
"type": "reference",
"description": "Search by Schedule actor",
"expression": "Schedule/?actor",
"xpathUsage": "normal",
"target": [
"Schedule"
],
"modifier": [
"missing"
],
"chain": [
"name",
"identifier"
]
}
I have also updated my appsettings.json. Then I created new resources for HealthcareService and Schedule but I am still getting the error:
{
"resourceType": "OperationOutcome",
"id": "b0970070-de01-4d0e-aa23-289e571969bf",
"meta": {
"versionId": "4879fffa-502c-49d8-93d6-74b528266477",
"lastUpdated": "2017-10-04T14:56:13.208+00:00"
},
"issue": [
{
"code": "not-supported",
"details": {
"coding": [
{
"code": "not handled"
}
],
"text": "actor=HealthcareService/dbf07ab6-db6e-4230-8fea-6ceffde5c2f3"
},
"diagnostics": ""
}
]
}
Can you please let me know if I am using the artifacts properly and how can I get this actor searchparameter up and running. Thanks a mil.
Christiaan Knaap (Oct 04 2017 at 19:12):
My current phone interface is insufficient to check all of the SearchParameter, but the expression should be a fhirpath expression, and you could validate the SearchParameter on /SearchParameter/$validate to see whether it is correct. If not, Vonk won't pick it up. Don't forget to reindex any existing data for this new SearchParameter, see http://docs.simplifier.net/vonk/features/customsearchparameters.html#re-indexing-for-new-or-changed-searchparameters
Christiaan Knaap (Oct 10 2017 at 07:07):
Hi Haseeb, I revisited your question and maybe you are looking for a totally different answer:
- Schedule.actor is an existing search parameter in the spec, it is supported by Vonk by default and there is no need to create and/or register it yourself.
- Your search url should look like https://vonk.furore.com/Schedule?actor=HealthcareService/dbf07ab6-db6e-4230-8fea-6ceffde5c2f3
Note the absence of the '/' between Schedule and the '?'. For a quick reference on the RESTful API you could check the cheatsheet
Last updated: Apr 12 2022 at 19:14 UTC