Querying field data

GRM objects give symbolic access to message data. grmfetch takes an address string and returns DAT objects containing the requested field data. Use the -warn option with grmfetch. You can also use -warn with grmcreate, grmreset, and xpmfetch.

Examples

To retrieve FRL data, assume $grmIdFrl is the GRM handle for a parsed FRL message record containing a NAME field with two subfields. For example:

Input: grmfetch $grmIdFrl NAME
Output: datum0 datum1

To retrieve subfields in definition order, the DAT handles returned correspond to the retrieved subfields. If the NAME subfields are first and last name, respectively, then datum0 contains the first-name data and datum1 contains the last name.

For example:

Input: datget datum0 VALUE
Output: Firstname
Input: datget datum1 VALUE
Output: Lastname

To retrieve specific subfields, request specific subfields by enclosing them in square-brackets. Because these characters usually have a special meaning in Tcl, surround the entire address in curly braces.

For example:
Input: grmfetch $grmIdFrl {NAME.[1]}
Output: datum2

Input: datget datum2 VALUE
Output: Lastname

Retrieve specific subfields in any order by separating the subfield numbers with commas.

For example:

Input: grmfetch $grmIdFrl {NAME.[1,0]}
Output: datum3 datum4

Input: datget datum3 VALUE
Output: Lastname

Input: datget datum4 VALUE
Output: Firstname

grmfetch returns an error when the field address does not match the record definition.

For example:

Input: grmfetch $grmIdFrl NO_SUCH_FIELD
Output: Error: unable to resolve address "NO_SUCH_FIELD..."

Input: grmfetch $grmIdFrl {NAME.[2]}
Output: Error: unable to resolve address "NAME.[2]"

Input: grmfetch $grmIdFrl {NAME.[1,2]}
Output: Error: unable to resolve address "NAME.[2]"

When parsing and retrieving from a message object, grmfetch generates an error when a field's starting offset is beyond the end of the message object.

To retrieve HL7 data, in this example $grmIdHl7 is the GRM handle for a parsed HL7 v2.1 message record containing a PID segment.

For example:

Input: grmfetch $grmIdHl7 0(0).PID(0).00041
Output: datum5 datum6 datum7

Input: datget datum5 VALUE
Output: Lastname

Input: datget datum6 VALUE
Output: Firstname

Input: datget datum7 VALUE
Output: MI

Order of retrieval

Retrieve component values in any order.

For example:

Input: grmfetch $grmIdHl7\ {0(0).PID(0).00041(0).[1,2,0]}
Output: datum8 datum9 datum10

Input: datget datum8 VALUE
Output: Firstname

Input: datget datum9 VALUE
Output: MI

Input: datget datum10 VALUE
Output: Lastname