HL7 EQQ_Q04 Embedded Query Language Query

HL7 message structure EQQ_Q04 groups and segments from HL7 v2.5.1 Hide structure

These are the generated groups and segments for the version selected at the top of the page. The article explains the workflow, and this panel follows the chosen HL7 version.

Message Structure

SegmentNameRequiredRepeatable
Message Header Yes No
Software Segment No Yes
EQL Yes No
Continuation Pointer No No

EQQ_Q04 carries an embedded query language statement in an EQL segment. Older descriptions often use SQL as the example, but the real contract is whatever the receiver agreed to support.

Use this pattern carefully. It is flexible, but flexibility is exactly why many modern interfaces prefer named query definitions with explicit parameters.

A small EQQ Q04 example

MSH|^~\&|PORTAL|CITYHOSP|RESULTS|CITYHOSP|20260718151000||EQQ^Q04^EQQ_Q04|EQQQ040001|P|2.5.1 EQL|QDISPLAY001|D|RECENT_NOTES^Recent notes display^L|SELECT note_text FROM clinical_notes WHERE patient_id = :patient

What systems do with it

The requester sends a query tag, expected response format, query name, and query statement. The responder evaluates the query according to its local rules and returns an appropriate response, often display or tabular data.

In real interfaces, EQQ_Q04 is usually found in old query brokers, departmental systems, or compatibility layers that predate more constrained QBP/RSP designs.

How to read the structure

MSH identifies EQQ^Q04^EQQ_Q04. Optional SFT can identify software. EQL carries the query tag, response format, query name, and query statement. Optional DSC handles continuation when the query itself is being continued.

The query tag is important. It is how the response and continuation behavior are tied back to this request.

Implementation traps

Never execute a received query string as raw database SQL unless a tightly controlled private contract makes that safe. Treat the query text as untrusted input, even when the sender is another internal system.

Also avoid depending on this for new cross-organization interfaces. Named, parameterized query profiles are much easier to secure, audit, test, and monitor.

Reference notes

HL7 v2.3.1 describes EQQ as an embedded query language query used with related display and tabular query responses. See the HL7 v2.3.1 control/query chapter.