This project is read-only.
HL7Query will search HL7 formatted text files for a specific element, identified by the segment name, and optionally the field, component, sub-component. The values are returned to the console. If the HL7 element requested repeats, each repeat will be displayed (one line per repeat). Options are provided to return unique results only.

Running HL7Query

HL7Query.exe <filename> <HL7Element> [-IgnoreWarnings] [-ListFilenames] [-Unique] [-Filter <HL7Element>=<Value>]

filename is the path to a single HL7 file, or a folder containing multiple HL7 files
HL7Element identifes the HL7 element to return. Formatted as Segment[repeat]-Field[repeat].Component.SubComponent
Segment is the 3 letter segment code.
Field, Component and SubComponent are identified by number. e.g 'PID' or 'PID-3' or or 'PID-3.1' or 'PID-3.1.1'.
The specific repeat of a segment or field can be specified. e.g. NK1[2] identifies the second repeat of the NK1 segment. NK1-5[1] identifies the first repeat of the NK1-5 field.
-IgnoreWarnings, -I is an optional switch to suppress warnings when a segment, field, component or sub component is not present in the message.
-ListFilenames, -L is an optional switch list the file name the values were obtained from.
-Unique, -U display unique results only. If -ListFileNames is also supplied it will be ignored. Warnings will also be suppressed.
-Filter <HL7Element>=<Value>, -F <HL7Element>=<Value> Only search messages where the HL7Element matches the Value specified.
e.g. '-Filter MSH-9=ADT^A01' will only search messages with a trigger of 'ADT^A01'
If <HL7Element> identifies multiple items in a file (ie repeating segments or fields) all repeats will be checked for a match. You can specify a specif repeat number if needed. e.g 'PID-3[2]=E1234567' will only examine the second repeat of PID-3. The filter allows exact matches only. If a value isn't provided (e.g. 'PV1-19=', it will match empty or missing HL7Elements.
Examples
HL7Query.exe c:\HL7Files\ PID-3.1 -ListFilenames -Filter MSH-9=ADT^A08

HL7Query.exe c:\HL7Files\MDM_D4923.txt TXA-2

HL7Query.exe c:\HL7Files NK1[2]-5[1]

HL7Query.exe c:\HL7Files\ PID-42.1.1 -Unique


The following example illustrates piping the output into the Powershell 'Group-Object' cmdlet to report on the number of unique occurrences of the results returned.
.\HL7Query.exe 'E:\Samples' MSH-9.2 | Group-Object | Format-Table Count,Name
     Count       Name
     -----       ------
       307        A31
         2        A27
        43        A28
         7        A04
        37        A03
         4        A05
        43        A14
        71        A01
       171        A08
         3        A02
         5        A60
         2        A11
         1        A38

Last edited Jun 22, 2015 at 10:08 AM by RobHolme, version 14