Stream: hapi
Topic: Search resources based on extension values
Markku Nikkanen (Jul 15 2020 at 08:52):
Hello,
I have some extensions in Encounter FHIR object. How do I implement "query matcher" against extension? Any reference implementation available?
Br,
Markku
Grahame Grieve (Jul 15 2020 at 10:11):
what's a 'query matcher'?
Markku Nikkanen (Jul 16 2020 at 05:33):
Grahame Grieve said:
what's a 'query matcher'?
By "query matcher" I mean a way of doing queries against attributes in an extension. As an example, how to query Encounters having valueString "checkin"?
{
"resourceType": "Encounter",
"extension": [
{
"url": "http://something.com/fhir/#currentQueueStatus",
"valueString": "checkin"
}
],
...
}
James Agnew (Jul 16 2020 at 09:36):
You need to create a custom search parameter. This blog goes over the process: https://blog.smilecdr.com/2017/02/08/custom-search-parameters-in-hapi-fhir/
Markku Nikkanen (Jul 17 2020 at 09:30):
James Agnew Thank you for this information. I got it working in Unit Test by creating SearchParam object before adding any test data to h2 database.
private static void initialiseTestDatabase() throws ParseException {
client.create().resource(createSearchParam()).execute();
// Location with room
Location l = LocationFactory.create();
IIdType locationId = client.create().resource(l).execute().getId();
...
What would be proper way to create SearchParam object in hapi-fhir-jpaserver-starter fork? I tried create object at the very end of the JpaRestfulServer initialise with no luck:
protected void initialize() throws ServletException {
...
IGenericClient client = ctx.newRestfulGenericClient(serverAddress);
client.create().resource(createSearchParam()).execute();
It did not work. It seems you cannot call create inside initialise method:
ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException: Failed to retrieve the server metadata statement during client initialization. URL used was http://localhost:8888/fhir/metadata
at ca.uhn.fhir.rest.client.impl.RestfulClientFactory.validateServerBase(RestfulClientFactory.java:312)
Should I start listening Spring or Jetty's lifecycle events that are called after initialisation is ready?
Markku Nikkanen (Jul 17 2020 at 09:52):
(deleted)
Markku Nikkanen (Jul 20 2020 at 17:12):
I did not get servlet approach operating. I think that the issue is that no one is listening port 8080 when servlets is being initialised.
~/repos/my-fhir-service/src/main/webapp/WEB-INF/web.xml
<servlet>
<servlet-name>fhirServlet</servlet-name>
<servlet-class>ca.uhn.fhir.jpa.starter.JpaRestfulServer</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet>
<servlet-name>myMigration</servlet-name>
<servlet-class>my.project.MyMigration</servlet-class>
<load-on-startup>3</load-on-startup>
</servlet>
public class MyMigration extends RestfulServer {
@Override
protected void initialize() throws ServletException {
String serverAddress = HapiProperties.getServerAddress();
IGenericClient client = ctx.newRestfulGenericClient(serverAddress);
client.create().resource(createExtensionSearchParam()).execute();
}
Is there any events (Pointcut?) that are sent when JpaRestfulServer initialisation is ready and servlet is listening in port 8080?
https://smilecdr.com/hapi-fhir/apidocs/hapi-fhir-base/ca/uhn/fhir/interceptor/api/Pointcut.html
Or would it be better to have a separate project that runs all sort of migrations to database like ads the Search Params? Perhaps there is already something ready made frameworks for this e.g.
https://hapifhir.io/hapi-fhir/docs/server_jpa/upgrading.html
Alex Vilensky (Jul 22 2020 at 00:19):
Is this the only Java implementation of the FHIR standard?
Grahame Grieve (Jul 22 2020 at 00:30):
no there are others, but none are complete or open source or tested/reliable anything like HAPI
Markku Nikkanen (Jul 22 2020 at 09:05):
I do not know any other approaches than implementing a migration application that runs creates. Search Param objects to HAPI FHIR.
Last updated: Apr 12 2022 at 19:14 UTC