R5 subscription via rest-hokk and message to rabbitmq

60 views
Skip to first unread message

Francesco Docimo

unread,
Apr 16, 2024, 5:19:33 AM4/16/24
to HAPI FHIR
Hi all is there any kind of suggestion to use rest hook or message channel?
The requisite is to send a message to rabbit mq based on particular criteria , but we don't know how to achieve this issue.

We'd like to know how to set up communication channel to send message to rabbitmq when a resource change or at least is created .

we have used this subscription and subscription topic


 

 

{

      "resourceType": "SubscriptionTopic",

      "id": "83157",

      "meta": {

        "versionId": "1",

        "lastUpdated": "2023-08-11T09:13:13.486+00:00",

        "source": "#mDxF30t1PYFQVxbi"

      },

      "text": {

        "status": "generated",

        "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p><b>Generated Narrative: SubscriptionTopic</b><a name=\"example\"> </a></p><div style=\"display: inline-block; background-color: #d9e0e7; padding: 6px; margin: 4px; border: 1px solid #8da1b4; border-radius: 5px; line-height: 60%\"><p style=\"margin-bottom: 0px\">Resource SubscriptionTopic &quot;example&quot; </p></div><p><b>url</b>: <code>http://example.org/FHIR/R5/SubscriptionTopic/example</code></p><p><b>identifier</b>: id: urn:uuid:1caa02ba-051b-4602-8856-65921748ae76</p><p><b>version</b>: 1.0.0-beta.1</p><p><b>title</b>: example</p><p><b>status</b>: draft</p><p><b>date</b>: 2019-01-01</p><p><b>description</b>: Example topic for completed encounters</p><blockquote><p><b>resourceTrigger</b></p><p><b>description</b>: An Encounter has been completed</p><p><b>resource</b>: <a href=\"encounter.html\">Encounter</a></p><p><b>supportedInteraction</b>: update</p><h3>QueryCriteria</h3><table class=\"grid\"><tr><td>-</td><td><b>Previous</b></td><td><b>ResultForCreate</b></td><td><b>Current</b></td><td><b>ResultForDelete</b></td><td><b>RequireBoth</b></td></tr><tr><td>*</td><td>status:not=completed</td><td>test-passes</td><td>status=completed</td><td>test-fails</td><td>true</td></tr></table><p><b>fhirPathCriteria</b>: (%previous.empty() | (%previous.status != 'completed')) and (%current.status = 'completed')</p></blockquote><blockquote><p><b>canFilterBy</b></p><p><b>description</b>: Filter based on the subject of an encounter.</p><p><b>resource</b>: <a href=\"encounter.html\">Encounter</a></p><p><b>filterParameter</b>: subject</p></blockquote><blockquote><p><b>canFilterBy</b></p><p><b>description</b>: Filter based on the group membership of the subject of an encounter.</p><p><b>resource</b>: <a href=\"encounter.html\">Encounter</a></p><p><b>filterParameter</b>: _in</p></blockquote><blockquote><p><b>canFilterBy</b></p><p><b>description</b>: Filter based on the length of an encounter.</p><p><b>resource</b>: <a href=\"encounter.html\">Encounter</a></p><p><b>filterParameter</b>: length</p><p><b>comparator</b>: gt, lt, ge, le</p></blockquote><blockquote><p><b>canFilterBy</b></p><p><b>description</b>: Filter based on the account for billing an encounter.</p><p><b>resource</b>: <a href=\"encounter.html\">Encounter</a></p><p><b>filterParameter</b>: account</p><p><b>modifier</b>: missing, not, identifier</p></blockquote><h3>NotificationShapes</h3><table class=\"grid\"><tr><td>-</td><td><b>Resource</b></td><td><b>Include</b></td></tr><tr><td>*</td><td><a href=\"encounter.html\">Encounter</a></td><td>Encounter:patient&amp;iterate=Patient.link, Encounter:practitioner, Encounter:service-provider, Encounter:account, Encounter:diagnosis, Encounter:observation, Encounter:location</td></tr></table></div>"

      },

      "url": "localhost:8080/fhir/SubscriptionTopic/example",

      "version": "1.0.0-beta.1",

      "title": "example",

      "status": "draft",

      "date": "2019-01-01",

      "description": "Example topic for completed patient",

       "resourceTrigger": [{

    "description": "A Patient has been updated",

    "resource": "Patient",

    "supportedInteraction": ["update"]

  }]

}

 

 

{

    "resourceType": "SubscriptionTopic",

    "id": "104",

    "meta": {

        "versionId": "1",

        "lastUpdated": "2024-04-15T10:29:07.508+00:00",

        "source": "#uE4U4tC8Lrb8AALg"

    },

    "text": {

        "status": "generated",

        "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p><b>Generated Narrative: SubscriptionTopic</b><a name=\"example\"> </a></p><div style=\"display: inline-block; background-color: #d9e0e7; padding: 6px; margin: 4px; border: 1px solid #8da1b4; border-radius: 5px; line-height: 60%\"><p style=\"margin-bottom: 0px\">Resource SubscriptionTopic &quot;example&quot; </p></div><p><b>url</b>: <code>http://example.org/FHIR/R5/SubscriptionTopic/example</code></p><p><b>identifier</b>: id: urn:uuid:1caa02ba-051b-4602-8856-65921748ae76</p><p><b>version</b>: 1.0.0-beta.1</p><p><b>title</b>: example</p><p><b>status</b>: draft</p><p><b>date</b>: 2019-01-01</p><p><b>description</b>: Example topic for completed encounters</p><blockquote><p><b>resourceTrigger</b></p><p><b>description</b>: An Encounter has been completed</p><p><b>resource</b>: <a href=\"encounter.html\">Encounter</a></p><p><b>supportedInteraction</b>: update</p><h3>QueryCriteria</h3><table class=\"grid\"><tr><td>-</td><td><b>Previous</b></td><td><b>ResultForCreate</b></td><td><b>Current</b></td><td><b>ResultForDelete</b></td><td><b>RequireBoth</b></td></tr><tr><td>*</td><td>status:not=completed</td><td>test-passes</td><td>status=completed</td><td>test-fails</td><td>true</td></tr></table><p><b>fhirPathCriteria</b>: (%previous.empty() | (%previous.status != 'completed')) and (%current.status = 'completed')</p></blockquote><blockquote><p><b>canFilterBy</b></p><p><b>description</b>: Filter based on the subject of an encounter.</p><p><b>resource</b>: <a href=\"encounter.html\">Encounter</a></p><p><b>filterParameter</b>: subject</p></blockquote><blockquote><p><b>canFilterBy</b></p><p><b>description</b>: Filter based on the group membership of the subject of an encounter.</p><p><b>resource</b>: <a href=\"encounter.html\">Encounter</a></p><p><b>filterParameter</b>: _in</p></blockquote><blockquote><p><b>canFilterBy</b></p><p><b>description</b>: Filter based on the length of an encounter.</p><p><b>resource</b>: <a href=\"encounter.html\">Encounter</a></p><p><b>filterParameter</b>: length</p><p><b>comparator</b>: gt, lt, ge, le</p></blockquote><blockquote><p><b>canFilterBy</b></p><p><b>description</b>: Filter based on the account for billing an encounter.</p><p><b>resource</b>: <a href=\"encounter.html\">Encounter</a></p><p><b>filterParameter</b>: account</p><p><b>modifier</b>: missing, not, identifier</p></blockquote><h3>NotificationShapes</h3><table class=\"grid\"><tr><td>-</td><td><b>Resource</b></td><td><b>Include</b></td></tr><tr><td>*</td><td><a href=\"encounter.html\">Encounter</a></td><td>Encounter:patient&amp;iterate=Patient.link, Encounter:practitioner, Encounter:service-provider, Encounter:account, Encounter:diagnosis, Encounter:observation, Encounter:location</td></tr></table></div>"

    },

    "url": "localhost:8080/fhir/SubscriptionTopic/example",

    "version": "1.0.0-beta.1",

    "title": "example",

    "status": "draft",

    "date": "2019-01-01",

    "description": "Example topic for completed patient",

    "resourceTrigger": [

        {

            "description": "A Patient has been updated",

            "resource": "Patient",

            "supportedInteraction": [

                "update"

            ]

        }

    ]

}

 

Creazione subscription

 

 

{

      "resourceType": "Subscription",

      "id": "754654",

      "meta": {

        "versionId": "2",

        "lastUpdated": "2024-04-10T15:38:12.784+00:00",

        "tag": [ {

          "system": "localhost:8080/fhir/StructureDefinition/subscription-matching-strategy",

          "code": "TOPIC",

          "display": "SubscriptionTopic"

        } ]

      },

      "name": "Fulfilled Appointments",

      "status": "active",

      "topic": "localhost:8080/fhir/SubscriptionTopic/example",

      "reason": "Subscription for fulfilled appointments of all patients",

      "channelType": {

        "code": "rest-hook"

      },

      "endpoint": "localhost:8080/fhir/$subscription-hook"

    }

 

 

Response

 

{

    "resourceType": "Subscription",

    "id": "105",

    "meta": {

        "versionId": "1",

        "lastUpdated": "2024-04-15T10:45:00.142+00:00",

        "source": "#SA5ySCmlRhY1X31K",

        "tag": [

            {

                "system": "localhost:8080/fhir/StructureDefinition/subscription-matching-strategy",

                "code": "TOPIC",

                "display": "SubscriptionTopic"

            },

            {

                "system": "http://hapifhir.io/fhir/StructureDefinition/subscription-matching-strategy",

                "code": "TOPIC",

                "display": "SubscriptionTopic"

            }

        ]

    },

    "name": "Fulfilled Appointments",

    "status": "active",

    "topic": "localhost:8080/fhir/SubscriptionTopic/example",

    "reason": "Subscription for fulfilled appointments of all patients",

    "channelType": {

        "code": "rest-hook"

    },

    "endpoint": "localhost:8080/fhir/$subscription-hook"

}

 

 

 

from the log ...

 

2024-04-15 12:47:15.171 [hapi-fhir-jpa-scheduler-local-1] INFO  c.u.f.j.s.m.r.SubscriptionRegistry [SubscriptionChannelRegistry.java:63] Adding subscription 105 to channel subscription-delivery-rest-hook-105

2024-04-15 12:47:17.183 [hapi-fhir-jpa-scheduler-local-1] INFO  c.u.f.j.s.m.r.SubscriptionRegistry [SubscriptionRegistry.java:136] Registered active subscription Subscription/105 - Have 3 registered

 

 

patient creation

 

http://localhost:8080/fhir/Patient

POST

{

  "resourceType": "Patient",

  "id": "1756",

  "meta": {

    "versionId": "1",

    "lastUpdated": "2021-01-08T11:57:03.703+00:00",

    "source": "#L7wmcmgSg2sBolOy"

  },

  "name": [

    {

      "use": "official",

      "family": "Peroni de Almeida",

      "given": [

        "Joao"

      ]

    }

  ],

  "telecom": [

    {

      "system": "phone",

      "value": "918106512",

      "use": "mobile"

    },

    {

      "system": "email",

      "value": "alme...@alunos.utfpr.edu.br"

    }

  ],

  "gender": "male",

  "birthDate": "1993-03-31",

  "address": [

    {

      "use": "home",

      "line": [

        "Av. Sa Carneiro, 368"

      ],

      "city": "Bragança",

      "country": "Portugal"

    }

  ]

}

 

 

 

http://localhost:8080/fhir/Patient/106

GET

{

    "resourceType": "Patient",

    "id": "106",

    "meta": {

        "versionId": "1",

        "lastUpdated": "2024-04-15T12:52:24.125+02:00",

        "source": "#XCgi2b6mBWQoexgO"

    },

    "text": {

        "status": "generated",

        "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\">Joao <b>PERONI DE ALMEIDA </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Address</td><td><span>Av. Sa Carneiro, 368 </span><br/><span>Bragança </span><span>Portugal </span></td></tr><tr><td>Date of birth</td><td><span>31 March 1993</span></td></tr></tbody></table></div>"

    },

    "name": [

        {

            "use": "official",

            "family": "Peroni de Almeida",

            "given": [

                "Joao"

            ]

        }

    ],

    "telecom": [

        {

            "system": "phone",

            "value": "918106512",

            "use": "mobile"

        },

        {

            "system": "email",

            "value": "alme...@alunos.utfpr.edu.br"

        }

    ],

    "gender": "male",

    "birthDate": "1993-03-31",

    "address": [

        {

            "use": "home",

            "line": [

                "Av. Sa Carneiro, 368"

            ],

            "city": "Bragança",

            "country": "Portugal"

        }

    ]

}

 

hfj_spidx_string



kind regards


Francesco

Reply all
Reply to author
Forward
0 new messages