Creating GRM objects

grmcreate initializes a new GRM object and returns its handle. When a GRM object is created, it is assigned a type. This general type identifies the realm of record types the object manipulates. Legal types are FRL (frl), VRL (vrl), HRL (hrl), XML (xml), HL7 (hl7), UN/EDIFACT (edifact), NCPDP (ncpdp), and X12 (x12).

In FRL, a GRM object handles only one FRL definition at a time. When an FRL GRM is created, supply the name of the FRL definition to use.

For example:

Input: grmcreate frl my.frl
Output: grm0

In HL7, access requires three parameters: version, variant, and message type.

For example:

Input: grmcreate hl7 2.1 my-variant ADT_A01
Output: grm1

Use an empty string in place of the variant name to access the base HL7 v2.1 definitions.

For example:

Input: grmcreate hl7 2.1 {} ADT_A01
Output: grm2

For message parsing, grmcreate can parse a message object's contents immediately. Use the -msg option to specify the message to use.

For example:

Input: grmcreate -msg message0 frl my.frl
Output: grm3

The GRM object copies the message's contents and parses them according to the record definition. Modifying or destroying the message does not disturb the GRM object.

If the record type specifies any parse-time data validation (for example, FRL), then collect validation warnings with the -warn option. The interpreter places any warnings in the specified variable name.

For example:

Input: grmcreate -msg message0 -warn w frl my.frl
Output: grm4 

Input: echo $w
Output: {TSFIELD: not valid ts data} {AIFIELD: not valid ai data} 

Available handles

The grmlist command shows the GRM handles in the interpreter.

For example:

Input: grmlist
Output: grm0 grm1 grm2 grm3 grm4

Destroying GRM handles

You can destroy a GRM object at any time. Destroying a GRM object removes its handle from the interpreter and frees up the memory associated with the object. The grmdestroy command destroys any number of GRM handles, returning an empty string.

Input: grmlist
Output: grm0 grm1 grm2 grm3 grm4

Input: grmdestroy grm0 grm1 grm2
Output:

Input: grmlist
Output: grm3 grm4

Destroying a GRM handle does not affect any messages it has parsed or encoded, any retrieved datum objects, or any objects in the interpreter.