Query for all lab results on patient #12233. The query is made at 11:00 a.m., 9/11/87. The Query anticipates an immediate display-oriented response.
MSH|^~\&|ICU||LAB01|||QRY^Q01|MSG00001|P|2.1<CR>
QRD|198709111012|D|I|4387|||20^LI|12233|RES|ALL<CR>
The response to the above query might look like the following:
MSH|^~\&|LAB01||ICU|||DSR|ZXT23461|P|2.1<CR>
MSA|AA|MSG00001P<CR>
QRD|198709111012|D|I|4387|||20^LI|12233|RES|ALL<CR>
DSP|||RESULTS FOR PATIENT#12233 SMITH, JOHN H. 09/11/87<CR>
DSP|||SPECIMEN#H85 COLLECTED 09/11/87 /07/0/0<CR>
DSP<CR>
DSP|||ELECTROLYTES<CR>
DSP||| SODIUM 140 [135-148] MEQ/L STAT<CR>
DSP||| POTASSIUM 4.0 [3.5-5.0] MEQ/L STAT<CR>
DSP||| CHLORIDE 89 [95-111] MEQ/L STAT<CR>
DSP||| CO2 20 [20-30] MEQ/L STAT<CR>
DSP||||LB<CR>
DSP|||CBC<CR>
DSP||| HEMOGLOBIN [13.5-18.0]<CR>
DSP||| HEMATOCRIT 45 [40-54] %<CR>
DSP||| RED CELL COUNT 5.0 [4.6-6.2] M/MM3<CR>
DSP||| MCHC 32 [32-36] G/DL<CR>
DSP||| MCH 28 [26-32] PG<CR>
DSP||| MCV 85 [81-101] FL<CR>
DSP||| WHITE CELL CNT 7.5 [5.0-10.0] K/MM3<CR>
DSP||||LB<CR>
DSP|||SPECIMEN#B24 COLLECTED 9/10/87<CR>
DSC|12333H85;12<CR>
A continuation query would echo back the contents of DSC-1-continuation pointer as follows:
MSH|^~\&|ICU||LAB01|||QRY^Q01|MSG00003|P|2.1<CR>
QRD|198709111012|D|I|4387|||20^LI|12233|RES|ALL<CR>
DSC|12333H85;12<CR>
The following response shows that there is no further data by leaving DSC-1-continuation pointer not present. This could be done by sending the DSC segment with no data, but the example does the same thing by totally omitting the DSC segment.
MSH|^~\&|LAB01||ICU|||DSR|ZXT23469|P|2.1<CR>
MSA|AA|MSG00003|<CR>
QRD|198709111012|D|I|4387|||20^LI|12233|RES|ALL<CR>
DSP|||RESULTS FOR PATIENT#12233 SMITH, JOHN H. 09/11/87<CR>
DSP|||SPECIMEN#H85 COLLECTED 09/10/87 /07/0/0<CR>
DSP<CR>
DSP|||ELECTROLYTES<CR>
DSP||| SODIUM 136 [135-148] MEQ/L STAT<CR>
DSP||| POTASSIUM 4.2 [3.5-5.0] MEQ/L STAT<CR>
DSP||| CHLORIDE 91 [95-111] MEQ/L STAT<CR>
DSP||| CO2 25 [20-30] MEQ/L STAT<CR>
DSP||||LB<CR>
Note: For illustration purposes, these examples assume that the following are defined in the ADT chapter: |
The VQQ (using SQL) and EQQ selection criteria
The virtual table named PID
The stored procedure named PID_QRY_01
The following example illustrates a query for the last and first names, address, social security number and date of birth of patients whose last name is "Evans." The fields comprising the query and response are identified by their HL7 item numbers. Where a field is composed of components, the particular component is identified with a ".n" suffix (e.g., the patient last name is the first component of the patient name field (HL7 item #00108), and therefore is identified as "@00108.1."
The following examples illustrate this query expressed as an SQL select statement, as a virtual table query and as a stored procedure call
MSH|^~\|CLINIC||CENTRAL-REG|||EQQ|MSG00001|P|2.3<CR>
EQL|TAG001|T|SQL_PID_QRY_01|SELECT @00108.1,@00108.2,@00114.1,@00114.2,
@00114.3,@00114.4,@00114.5,@00122,@00110
FROM PID WHERE @00108.1=EVANS<CR>
MSH|^~\|CLINIC||CENTRAL-REG|||VQQ|MSG00001|P|2.3<CR>
VTQ| TAG001|T | VTQ_PID_QRY_01|PID|@00108.1^EQ^EVANS <CR>
RDF|9|@00108.1^ST^20~@00108.2^ST^20~@00114.1^ST^30~@00114.2^ST^30~
@00114.3^ST^20~@00114.4^ST^2~@00114.5^ST^5~@00122^ST^11~
@00110^TS^8<CR>
MSH|^~\|CLINIC||CENTRAL-REG|||SPQ|MSG00001|P|2.3<CR>
SPR|TAG0001|T|SPR_PID_QRY_01|@00108.1^EVANS<CR>
RDF|9|@00108.1^ST^20~@00108.2^ST^20~@00114.1^ST^30~@00114.2^ST^30~
@00114.3^ST^20~@00114.4^ST^2~@00114.5^ST^5~@00122^ST^11~
@00110^TS^8<CR>
MSH|^~\|CENTRAL-REG||CLINIC|||TBR|MSG99001|P|2.3<CR>
MSA|AA|MSG00001<CR>
QAK|TAG0001|OK<CR>
RDF|9|@00108.1^ST^20~@00108.2^ST^20~@00114.1^ST^30~@00114.2^ST^30~
@00114.3^ST^20~@00114.4^ST^2~@00114.5^ST^5~@00122^ST^11~
@00110^TS^8<CR>
RDT|Evans|Aaron|105 Maple St.||Lancaster|PA|19786|156-96-2542|19520809<cr>
RDT|Evans|Bart|166 Norwood Ln.||Hershey|PA|19987|765-58-4615|19701217<cr>
RDT|Evans|Beth|15 Elmwood Ct.|Apt. 15|Gap|PA|19724|58-96-7619|19401119<cr>
RDT|Evans|Carolyn|903 Diane Circle||Phoenixville|PA|19460|156-96-2542|19620324<cr>
DSC|00005<cr>
A continuation query would echo back the contents of DSC-1- continuation pointert.
MSH|^~\|CLINIC||CENTRAL-REG|||EQQ|MSG00002|P|2.3<CR>
EQL|TAG001|T|SQL_PID_QRY_01|SELECT @00108.1,@00108.2,@00114.1,@00114.2,
@00114.3,@00114.4,@00114.5,@00122,@00110
FROM PID WHERE @00108.1=EVANS<CR>
DSC|00005<cr>
MSH|^~\|CLINIC||CENTRAL-REG|||VQQ|MSG00002|P|2.3<CR>
VTQ| TAG001|T | VTQ_PID_QRY_01|PID|@00108.1^EQ^EVANS<CR>
RDF|9|@00108.1^ST^20~@00108.2^ST^20~@00114.1^ST^30~@00114.2^ST^30~
@00114.3^ST^20~@00114.4^ST^2~@00114.5^ST^5~@00122^ST^11~
@00110^TS^8<CR>
DSC|00005<cr>
MSH|^~\|CLINIC||CENTRAL-REG|||SPQ|MSG00002|P|2.3<CR>
SPR|TAG0001|T|SPR_PID_QRY_01|@00108.1^EVANS<CR>
RDF|9|@00108.1^ST^20~@00108.2^ST^20~@00114.1^ST^30~@00114.2^ST^30~
@00114.3^ST^20~@00114.4^ST^2~@00114.5^ST^5~@00122^ST^11~
@00110^TS^8<CR>
DSC|00005<cr>
MSH|^~\|CENTRAL-REG||CLINIC|||TBR|MSG00003|P|2.3<CR>
MSA|AA|MSG00002<CR>
QAK|TAG0001|OK<CR>
RDF|9|@00108.1^ST^20~@00108.2^ST^20~@00114.1^ST^30~@00114.2^ST^30~
@00114.3^ST^20~@00114.4^ST^2~@00114.5^ST^5~@00122^ST^11~
@00110^TS^8<CR>
RDT|Evans|William|609 N. 3rd St.||Manheim|PA|19898|169-03-9872|19290726<cr>
RDT|Evans|Zachary|111 North Ln.||Lancaster|PA|19987|539-43-8725|19340926<cr>
MSH|^~\|CLINIC||CENTRAL-REG|||RQQ|MSG00004|P|2.3<CR>
ERQ|TAG0002|A04|@00122^156-96-2542<CR>
MSH|^~\|CLINIC||CENTRAL-REG|||ERP|MSG00005|P|2.3<CR>
MSA|AA|MSG00004<CR>
ERQ|TAG0002|A04|@00122^156-96-2542<CR>
QAK|TAG0002|OK<CR>
EVN|A04|199405151259||<cr>
PID|||2-68708-5|253763|EVANS^CAROLYN||19620324|F|||903
Diane Circle^^PHOENIXVILLE^PA^19460|(610)555-1212|
(610)555-1212||S|C||156-96-2542||<cr>
NK1||EVANS^RICHARD|SPOUSE|903Diane Circle^^PHOENIXVILLE^
PA^19460|(610)555-1212|<cr>
PV1||E|EMERG||||0148^ADDISON^JAMES<cr>
..etc
Error responses to the above queries might look like the following:
MSH|^~\|CENTRAL-REG||CLINIC|||TBR|MSG99001|P|2.3<CR>
MSA|AE|MSG00001||||^REQUESTED TABLE "PID" IS UNKNOWN<CR>
QAK|TAG0001|AE<CR>
MSH|^~\|CENTRAL-REG||CLINIC|||ERP|MSG00005|P|2.3<CR>
MSA|AE|MSG00004||||^REQUESTED EVENT TYPE "A04" NOT SUPPORTED ON THIS SYSTEM<CR>
QAK|TAG0002|AE<CR>