Custom search parameter unique indexing with Partition/multitenancy

389 views
Skip to first unread message

Ajay shekar

unread,
Jan 29, 2021, 5:49:33 AM1/29/21
to HAPI FHIR
I was able to create custom search parameter with unique indexing without enabling partition as below.

req.body: 
{
"resourceType": "SearchParameter",
"id": "patient-identifier",
"base": [ "Patient" ],
"status": "active",
"code": "patient-identifier",
"type": "token",
"expression": "Patient.identifier"
}

req.body: 
{
"resourceType": "SearchParameter",
"id": "patient-uniq-identifier",
"extension": [
{
"valueBoolean": true
}
],
"base": [ "Patient" ],
"status": "active",
"code": "patient-uniq-identifier",
"type": "composite",
"expression": "Patient.identifier",
"component": [
{
"definition" : {
"reference": "/SearchParameter/patient-identifier"
},
"expression" : "Patient"
}]
}

But the same isnt working with partitioning being enabled.

Is unique indexing for custom search parameter is available with partitioning/multitenancy ? If so any help would be appreciable.

James Agnew

unread,
Jan 29, 2021, 10:59:37 AM1/29/21
to Ajay shekar, HAPI FHIR
Hi Ajay,

Can you elaborate on what isn't working? I believe it should work, although it may be enforcing uniqueness across all partitions as opposed to across each partition.

Cheers,
James

--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hapi-fhir/400cd739-1989-4e0f-b085-d3dbe30099a2n%40googlegroups.com.

Ajay shekar

unread,
Feb 5, 2021, 2:42:36 PM2/5/21
to HAPI FHIR
Hi James,

Thanks for your reply.
I am using hapi-fhir-jpaserver-starter 5.2.0.
With above unique indexing identifier in Patient resource, I am able to create multiple Patient resource with same identifier(which shouldn't be the case). 
But Unique indexing seems to work when i disable the partitioning.

Again with partition, custom search parameter isnt working for me:
req.body - 
{
"resourceType": "SearchParameter",
"id": "patient-eye-colour",
"title": "Eye Colour",
"base": [ "Patient" ],
"status": "active",
"code": "eyecolour",
"type": "token",
"expression": "Patient.extension('http://acme.org/eyecolour')",
"xpathUsage": "normal"
}

I get the following error - 
"issue": [
{
"severity": "error",
"code": "processing",
"diagnostics": "Unknown search parameter \"eyecolour\" for resource type \"Patient\". Valid search parameters for this search are: [_id, _language, _lastUpdated, active, address, address-city, address-country, address-postalcode, address-state, address-use, birthdate, death-date, deceased, email, family, gender, general-practitioner, given, identifier, language, link, name, organization, phone, phonetic, telecom]"
},

But the same is working without partitioning in jpa 5.2.0.

Ajay shekar

unread,
Feb 8, 2021, 11:30:27 PM2/8/21
to HAPI FHIR

Some more information on it..

With Partitioning enabled, searchParameter resource gets stored in db with partition id = 0(I used this link hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/registry/SearchParamRegistryImpl.java).
But
IBundleProvider allSearchParamsBp = mySearchParamProvider.search(params);(hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/registry/SearchParamRegistryImpl.java)
is not picking up the searchParameter resource with partition id=0. On contrary it is picking the searchParameter with Partition id = null(Stored during partitioning was disabled).

Any help would be appreciable to make custom search parameter work with Partitioning.

James Agnew

unread,
Feb 9, 2021, 8:36:01 AM2/9/21
to Ajay shekar, HAPI FHIR
How are you creating this search parameter resource? It should not be possible to put a SP in a partition other than the default/null partition. If it's allowing you to put it elsewhere, that sounds like a bug..

Ajay shekar

unread,
Feb 10, 2021, 6:30:17 AM2/10/21
to HAPI FHIR
Hello James,  

Thanks for your response.

1. I am creating SearchParameter(SP) resource like mentioned here - https://smilecdr.com/docs/fhir_repository/custom_search_parameters.html#an-example-search-parameter
req.body - 
{
"resourceType": "SearchParameter",
"id": "patient-eye-colour",
"title": "Eye Colour",
"base": [ "Patient" ],
"status": "active",
"code": "eyecolour",
"type": "token",
"expression": "Patient.extension('http://acme.org/eyecolour')",
"xpathUsage": "normal"
}


2.My main issue is, I am not able to make query with my custom Search Parameter - eyecolour.
Error - Unknown search parameter \"eyecolour\" for resource type \"Patient\". 
In line 123 -  IBundleProvider allSearchParamsBp = mySearchParamProvider.search(params);

When this line tries to search all SP's for every Refresh interval/fetching SPs internally, it is reading SP's only from null partition(partition_id=null) and it is ignoring my SPs stored in DEFAULT partition(partition_id=0).

3. I was able to put SP and even Questionnaire in a partition other than DEFAULT/null partition.
But these resources are accessed across partitions.

James Agnew

unread,
Feb 10, 2021, 6:43:00 AM2/10/21
to Ajay shekar, HAPI FHIR
The default partition has the ID of  null though, not 0.

When I try this locally, my SP correctly gets a partition ID of null. I'm not sure what's happening here..

sent from my phone.

Ajay shekar

unread,
Feb 10, 2021, 8:42:21 AM2/10/21
to HAPI FHIR
I am using hapi-fhir-jpaserver-starter 5.2.0 and I tried again with new clean Postgres database.
But for me SP gets a partition ID of 0. 
Which is the hapi-fhir-jpa version you are using ?

Ajay shekar

unread,
Feb 10, 2021, 10:24:57 AM2/10/21
to HAPI FHIR
In hapi-fhir 5.3.0 snapshot, SP gets a partition ID of null.
Reply all
Reply to author
Forward
0 new messages