Adding custom search parameter for a resource

696 views
Skip to first unread message

Harsha Kumara

unread,
Feb 14, 2015, 11:59:09 PM2/14/15
to hapi...@googlegroups.com, Suranga Kasthurirathne, James Agnew
Hi All,

Is that possible to add a custom search parameter for a resource? As the fhir work carrying out in the openmrs, we need to add search composition resource by encounter. How that we can support it? Is there any way to add that search parameter?

Thanks,
Harsha

Suranga Kasthurirathne

unread,
Feb 15, 2015, 1:06:27 AM2/15/15
to Harsha Kumara, hapi...@googlegroups.com, James Agnew

Hi everyone, 

We'd appreciate feedback from the HAPI community on how to do this.
To elaborate, we currently have a task on FHIR gforge to add a search parameter for Composition.encounter. Since this change won't be published as official until late July 2015, we were advised to use custom search parameters for this purpose.

How may we do this using HAPI ? :-) 


--
Best Regards,
Suranga

James Agnew

unread,
Feb 16, 2015, 11:50:14 AM2/16/15
to Suranga Kasthurirathne, Harsha Kumara, hapi...@googlegroups.com
Hi Harsha, Suranga,

You can definitely add your own search parameters, and this is in fact quite a normal thing to do.

Assuming you're talking about a server implementation, the usual pattern (for non-custom parameters) looks like:
   @RequiredParam(name=Patient.SP_NAME) StringDt theName

But in this example, SP_NAME is really just a string constant for "name". If you wanted to define your own parameters, it's as simple as using your own strings, eg.
   @RequiredParam(name="hairColour") StringDt theHairColour

Your server will then automatically declare that it supports this parameter in its conformance statement. You may also wish to add a @Description annotation to the parameter to give the conformance statement more information about what this parameter is used for. There's an example of using @Description here: http://jamesagnew.github.io/hapi-fhir/doc_rest_operations#Adding_Descriptions

Obviously you should avoid using custom parameters when you can, since client software will need to be specially programmed in order to take advantage of them, but it's perfectly legal and I'd imagine most software is going to end up finding at least a few query patterns that FHIR hasn't thought of yet. We use a few custom parameters in our FHIR applications at UHN for sure.

Cheers,
James

Harsha Kumara

unread,
Mar 15, 2015, 12:14:27 AM3/15/15
to hapi...@googlegroups.com, suran...@gmail.com, har...@gmail.com
Thanks James :).
Reply all
Reply to author
Forward
0 new messages