Custom ACKs

Query Response Example

This is a great technique for implementing a query response interface. Say you have an incoming message that looks like:

MSH|^~&|Acme||||20100927160935||QRY^A19|2010927169956|P|2.4|
QRD|20100927160935|R|I|92716934|||1^RD|4525285|DEM|

For which you need to send back an ADR^A19 message giving patients matching the given ID.

Here’s an example. As you can see the principle is simple. The query comes in. It’s parsed and used to generate a SQL query against the database. The data from the SQL query is used to populate the HL7 message that is returned. The logic can be made more elaborate but the principle is the same.

Note: We set live = true to execute SQL queries interactively in the Iguana script editor.

Tip: For a production version it is recommended best practice to escape the Id to avoid a SQL injection attack, see escaping values correctly for SQL.

Here’s the vmd query.vmd and you can get the Query Response ACK code from our code repository.

Leave A Comment?

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.