Schedule a demo
Segment

Query response instance

Provides match-quality metadata for individual records returned in a conformance-based query response. It carries a numeric confidence score indicating how well the record matches the query criteria, and an algorithm descriptor identifying the matching method used. QRI appears once per candidate record in RSP response messages, enabling the querying system to rank or filter results by relevance.

3fields
0required
v2.9HL7 version
qri.py
from zato.hl7v2 import QRI

qri = QRI()
qri.candidate_confidence = '95'

Build QRI segments in Python

How to construct and work with real-world QRI segments.

1

High-confidence match

Record matched with 95% confidence using a phonetic algorithm

from zato.hl7v2.v2_9 import QRI
from zato.hl7v2.v2_9 import CWE

qri = QRI()
qri.candidate_confidence = '95'
qri.algorithm_descriptor = CWE(
    identifier='PHON',
    text='Phonetic',
    name_of_coding_system='HL70393'
)
2

Exact match result

Record matched with 100% confidence using an exact algorithm

from zato.hl7v2.v2_9 import QRI
from zato.hl7v2.v2_9 import CWE

qri = QRI()
qri.candidate_confidence = '100'
qri.algorithm_descriptor = CWE(
    identifier='EXACT',
    text='Exact',
    name_of_coding_system='HL70393'
)
3

Low-confidence candidate

Partial match with 40% confidence and no algorithm specified

from zato.hl7v2.v2_9 import QRI

qri = QRI()
qri.candidate_confidence = '40'

Learn by building

Step-by-step guides for working with HL7 v2 in Zato.

Frequently asked questions

QRI provides match-quality metadata for each record in a query response. It tells the querying system how confident the match is (0-100) and which algorithm produced it, so results can be ranked or filtered by relevance.

It is a numeric score (typically 0-100) indicating how well the returned record matches the query criteria. Higher values mean a stronger match:

from zato.hl7v2.v2_9 import QRI

qri = QRI()
qri.candidate_confidence = '95'

score = qri.candidate_confidence

It uses the CWE datatype with HL7 table 0393. Common values include EXACT (exact match), PHON (phonetic), and SOUNDEX:

from zato.hl7v2.v2_9 import QRI, CWE

qri = QRI()
qri.algorithm_descriptor = CWE(
    identifier='PHON',
    text='Phonetic',
    name_of_coding_system='HL70393'
)

Position 2 was reserved but never defined in the HL7 v2 standard. The segment jumps from position 1 (candidate_confidence) to position 3 (algorithm_descriptor). This is a known gap in the segment definition.

Read the confidence score from each QRI and apply a threshold to decide which candidates to present to the user:

from zato.hl7v2.v2_9 import QRI

qri = QRI()
qri.candidate_confidence = '80'

score = int(qri.candidate_confidence)
is_strong = score >= 75

Zato connects to any system that speaks HL7v2 over MLLP or FHIR over REST. This includes Epic, Cerner, Meditech, Allscripts, and other EHR platforms.

Yes, Zato has built-in MLLP support for sending and receiving HL7v2 messages. MLLP channels handle the framing protocol automatically.

Zato supports HL7 v2.9, which is backward compatible with earlier versions including v2.3, v2.5, and v2.7. Standard segments and datatypes are available as typed Python classes.

Yes. Zato handles both HL7v2 and FHIR natively, so you can parse v2 messages and build FHIR resources with IG-specific extensions in the same service. Typed Python classes are available for both protocols, including extensions from US Core, UK Core, Da Vinci, and other Implementation Guides.

QRI field reference

Complete list of fields in the QRI segment, HL7 v2.9.

#Python nameDatatypeUsageRepeatableTable
1candidate_confidenceNMOptionalNo-
2match_reason_codeCWEOptionalYesHL70392
3algorithm_descriptorCWEOptionalNoHL70393

Ready to build integrations?

Get started with Zato and connect your systems in minutes.

Open source In Python