public class MessageQuery extends Object
x = /.MSH-18(*)
. The * is
replaced by numbers 0, 1, 2, etc. as you loop through the results, so this
example would loop through repetitions of MSH-18. If there are multiple loop
points, the loops are nested so that each possible combination is returned.
Looping stops when none of the fields under a loop point are valued. The name
of the loop point ('x' in the example above) is arbitrary.
SELECTING FIELDS: The syntax is similar to SQL, except that Terser paths are
used in place of table.field. You can use the "as" keyword to give a field a
name, like this: select /.MSH-7 as msg_date
. If your field is
under a loop point, replace the path up to the loop point with a loop point
reference, like this: select {foo}-1 loop foo = /.PID-3(*)
SELECTING ROWS: A "row" is a combination of all selected fields at one
iteration. You can filter which rows are returned using a where clause
similar to that in SQL. Use exact values or regular expressions, for example:
where {1} like '.*blood.*'
or
where {1}/PID-3-1 = '111'
Multiple filters can be separated with
commas (which mean 'and'). Future versions may support 'or', negation,
brackets, etc., but this version doesn't.
FULL EXAMPLE: select {pat-id}-1 as id loop pat-id = ./PID-3(*) where
{pat-id}-2 = 'mrn'
SUBTLETIES OF LOOPING: A loop point can be under another loop point. For
example consider the message:
MSH|etc.|etc. Z01|one~two|a Z01|three~four|b
The query, "select {a}-2, {b} loop a = /Z01(*), b = {a}-1(*)" would return: a
one a two b three b four
While the query "select {a}-2, {b} loop a = /Z01(*), b = /Z01(1)-1(*)" would
return: a one a two b one b two
In the first case, one loop point refers to another. In the second case the
loops are treated as independent, just as if they referred to different
branches of the message.
TODO: could support distinct easily by keeping record of rows and comparing
each one to previous rowsModifier and Type | Class and Description |
---|---|
static interface |
MessageQuery.Result
Deprecated.
A result set for a message query.
|
Constructor and Description |
---|
MessageQuery()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
static MessageQuery.Result |
query(Message theMessage,
String theQuery)
Deprecated.
|
public MessageQuery()
public static MessageQuery.Result query(Message theMessage, String theQuery)
theMessage
- an HL7 message from which data are to be queriedtheQuery
- the query (see class docs for syntax)Copyright © 2001–2017 University Health Network. All rights reserved.