FHIR Chat · 3.4.3.2 Asynchronous Operation · fhir-messages

Stream: fhir-messages

Topic: 3.4.3.2 Asynchronous Operation


view this post on Zulip Władysław Węglarz (Aug 13 2018 at 09:35):

I'd like use asynchronous messaging to implement offline communication between Patient and Practitioner.
Solution is based on concept described bellow:
3.4.4.1 Asynchronous Messaging using the RESTful API
It is possible to exchange messages using the RESTful end-point as a central point of exchange. This is not particularly efficient compared to other methods, but is useful for low-volume asynchronous exchange.

To send a message, a sender posts the message bundle to the /Bundle end-point, with a uri that identifies the receiver at MessageHeader.destination.endpoint. The RESTful server accepts the bundle, stores it as a single bundle, and indexes it on the MessageHeader.

To receive messages, a receiver searches for all messages destined for itself, since its last check:

GET [base]/Bundle?message.destination-uri=[rcv]&_lastUpdated=>2015-03-01T02:00:02+01:00
The receiver works through the response, processing each message. As each message is processed, the receiver creates a response message, reversing the source and destination, and posts it back to the server.

To check for responses, the original sender searches for response messages destined for itself, since its last check:

GET [base]/Bundle?message.destination-uri=[snd]&message.response-id:missing=false
&_lastUpdated=>2015-03-03T06:03:522+01:00
This lightweight protocol needs ongoing administration to ensure that multiple parties do not interfere with each other by re-using the same system identifier (and against malicious attack).

I post Bundle :
{
"resourceType": "Bundle",
"id": "19203",
"meta": {
"versionId": "1",
"lastUpdated": "2018-08-13T08:25:12.840+02:00"
},
"type": "message",
"entry": [
{
"fullUrl": "http://localhost:9182/MessageHeader/19003",
"resource": {
"resourceType": "MessageHeader",
"id": "19003",
"event": {
"system": "http://example.org/fhir/message-events",
"code": "diagnosticreport-provide"
},
"destination": [
{
"endpoint": "https://vps.mymedic.com.pl/fhir/Practitioner/debb3012-01e7-4f57-afd6-95883c1f8f54"
}
],
"timestamp": "2018-08-10T11:15:33+10:00",
"source": {
"name": "Władysław Węglarz",
"contact": {
"system": "email",
"value": "wladyslaw.weglarz@telemedis.pl",
"use": "home"
},
"endpoint": "https://vps.mymedic.com.pl/Patient/d9df0576-ad4c-4a82-bfa7-993cb3420d8a"
},
"responsible": {
"reference": "https://vps.mymedic.com.pl/fhir/Practitioner/debb3012-01e7-4f57-afd6-95883c1f8f54"
},
"reason": {
"coding": [
{
"system": "https://vps.mymedic.com.pl/fhir/ValueSet/kategoriaSerwisu",
"code": "2",
"display": "e-Porada"
}
]
}
}
},
{
"fullUrl": "http://localhost:9182/QuestionnaireResponse/19002",
"resource": {
"resourceType": "QuestionnaireResponse",
"id": "19002",
"status": "completed",
"item": [
{
"linkId": "3",
"text": "Temat wiadomości:",
"answer": [
{
"valueString": "Temat wiadomosci"
}
]
},
{
"linkId": "4",
"text": "Treść wiadomości:",
"answer": [
{
"valueString": "tresc wiadomosci"
}
]
},
{
"linkId": "7",
"text": "Załączniki:",
"item": [
{
"linkId": "7.1",
"text": "WEB MyMedic-React (Nowa Rehabilitacja).postman_collection.json",
"answer": [
{
"valueString": "http://localhost:8089/upload/16835"
}
]
},
{
"linkId": "7.2",
"text": "foto.jpeg",
"answer": [
{
"valueString": "http://localhost:8089/upload/16833"
}
]
},
{
"linkId": "7.3",
"text": "foto.jpeg",
"answer": [
{
"valueString": "http://localhost:8089/upload/16834"
}
]
}
]
}
]
}
}
]
}

Receiver can't search this Bundle using GET:
vps.mymedic.com.pl/fhir/Bundle/?message.destination-uri=https://vps.mymedic.com.pl/fhir/Practitioner/debb3012-01e7-4f57-afd6-95883c1f8f54

Server returns error:
"diagnostics": "Don't know how to convert param type: URI"

The server is based on HAPI FHIR version 3.5.0 SNAPSHOT.

And second problem when i POST
vps.mymedic.com.pl/fhir/$process-message?async=true

I receive :
"diagnostics": "Invalid request: The FHIR endpoint on this server does not know how to handle POST operation[$process-message] with parameters [[async]]"

My question is "HAPI FHIR versio 3.5.9 SNAPSHOT has'nt implementation operation $process-message ?

Please information from users HAPI FHIR

view this post on Zulip Lloyd McKenzie (Aug 13 2018 at 14:20):

@James Agnew ?

view this post on Zulip Władysław Węglarz (Aug 13 2018 at 17:33):

Hi James
Could You help me in my problems with messaging in HAPI FHIR version 3.5.0 SNAPSHOT - please

view this post on Zulip James Agnew (Aug 13 2018 at 20:32):

The $process-message endpoint is an operation like any other operation. You can implement t using the standard operation framework

view this post on Zulip James Agnew (Aug 13 2018 at 20:33):

Basically you're just implementing an operation on a IResourceProvider for the MessageHeader resource type with the name process-message.

view this post on Zulip James Agnew (Aug 13 2018 at 20:33):

HAPI FHIR doesn't come with this out of the box because you need to actually implement whatever processing logic you want to have, so you create the processor as a part of that. I've implemented a few message processors that work this way, it works quite nicely.

view this post on Zulip James Agnew (Aug 13 2018 at 20:35):

For the other problem, can you please provide a brief code snippet or unit test that demonstrates your issue? As brief a snippet as possible to show the issue would be helpful, ideally against a public server.

view this post on Zulip Władysław Węglarz (Aug 13 2018 at 21:08):

The message Bundle was POST to public server.
1. GET http://hapi.fhir.org/baseDstu3/Bundle/4737566

2. GET http://hapi.fhir.org/baseDstu3/Bundle?message.destination-uri=https://vps.mymedic.com.pl/fhir/Practitioner/debb3012-01e7-4f57-afd6-95883c1f8f54

the result is:
{
"resourceType": "OperationOutcome",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><h1>Operation Outcome</h1><table border=\"0\"><tr><td style=\"font-weight: bold;\">ERROR</td><td>[]</td><td><pre>Don't know how to convert param type: URI</pre></td>\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t</tr>\n\t\t</table>\n\t</div>"
},
"issue": [
{
"severity": "error",
"code": "processing",
"diagnostics": "Don't know how to convert param type: URI"
}
]
}

The same wrong as on my server ?

view this post on Zulip Władysław Węglarz (Aug 13 2018 at 21:10):

on my server information about this error is the following:
2018-08-13 19:20:02.002 INFO ca.uhn.fhir.context.FhirContext Creating new FHIR context for FHIR version [DSTU3]
2018-08-13 19:20:02.078 INFO c.u.f.n.BaseThymeleafNarrativeGenerator Initializing narrative generator
2018-08-13 19:20:52.553 INFO c.u.f.j.s.SearchCoordinatorSvcImpl Search initial phase completed in 2ms
2018-08-13 19:20:52.611 ERROR c.u.f.j.s.SearchCoordinatorSvcImpl Failed during search loading after 57ms
ca.uhn.fhir.rest.server.exceptions.InternalErrorException: Don't know how to convert param type: URI
at ca.uhn.fhir.jpa.dao.SearchBuilder.toParameterType(SearchBuilder.java:2017)
at ca.uhn.fhir.jpa.dao.SearchBuilder.toParameterType(SearchBuilder.java:2023)
at ca.uhn.fhir.jpa.dao.SearchBuilder.addPredicateReference(SearchBuilder.java:501)
at ca.uhn.fhir.jpa.dao.SearchBuilder.searchForIdsWithAndOr(SearchBuilder.java:1931)
at ca.uhn.fhir.jpa.dao.SearchBuilder.searchForIdsWithAndOr(SearchBuilder.java:1858)
at ca.uhn.fhir.jpa.dao.SearchBuilder.createQuery(SearchBuilder.java:1389)
at ca.uhn.fhir.jpa.dao.SearchBuilder.access$700(SearchBuilder.java:87)
at ca.uhn.fhir.jpa.dao.SearchBuilder$QueryIterator.fetchNext(SearchBuilder.java:2238)
at ca.uhn.fhir.jpa.dao.SearchBuilder$QueryIterator.hasNext(SearchBuilder.java:2310)
at ca.uhn.fhir.jpa.search.SearchCoordinatorSvcImpl$SearchTask.doSearch(SearchCoordinatorSvcImpl.java:594)
at ca.uhn.fhir.jpa.search.SearchCoordinatorSvcImpl$SearchTask.access$700(SearchCoordinatorSvcImpl.java:459)
at ca.uhn.fhir.jpa.search.SearchCoordinatorSvcImpl$SearchTask$1.doInTransactionWithoutResult(SearchCoordinatorSvcImpl.java:524)
at org.springframework.transaction.support.TransactionCallbackWithoutResult.doInTransaction(TransactionCallbackWithoutResult.java:36)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140)
at ca.uhn.fhir.jpa.search.SearchCoordinatorSvcImpl$SearchTask.call(SearchCoordinatorSvcImpl.java:521)
at ca.uhn.fhir.jpa.search.SearchCoordinatorSvcImpl$SearchTask.call(SearchCoordinatorSvcImpl.java:459)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
2018-08-13 19:20:52.628 ERROR c.u.f.r.s.i.ExceptionHandlingInterceptor Failure during REST processing
ca.uhn.fhir.rest.server.exceptions.InternalErrorException: Don't know how to convert param type: URI
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException.newInstance(BaseServerResponseException.java:301)
at ca.uhn.fhir.jpa.search.SearchCoordinatorSvcImpl.verifySearchHasntFailedOrThrowInternalErrorException(SearchCoordinatorSvcImpl.java:442)
at ca.uhn.fhir.jpa.search.PersistedJpaSearchFirstPageBundleProvider.size(PersistedJpaSearchFirstPageBundleProvider.java:84)
at ca.uhn.fhir.rest.server.method.BaseResourceReturningMethodBinding.doInvokeServer(BaseResourceReturningMethodBinding.java:323)
at ca.uhn.fhir.rest.server.method.BaseResourceReturningMethodBinding.invokeServer(BaseResourceReturningMethodBinding.java:379)
at ca.uhn.fhir.rest.server.RestfulServer.handleRequest(RestfulServer.java:917)
at ca.uhn.fhir.rest.server.RestfulServer.doGet(RestfulServer.java:331)
at ca.uhn.fhir.rest.server.RestfulServer.service(RestfulServer.java:1485)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:865)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:535)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1253)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1155)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:531)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:352)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:281)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:760)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:678)
at java.lang.Thread.run(Thread.java:748)

view this post on Zulip Aditya Joshi (Sep 11 2018 at 19:21):

Hi James. Thanks for the explanation. Does the processors you have created as part of implementing $process-message available for reference?


Last updated: Apr 12 2022 at 19:14 UTC