Message definitions
Your HL7 v2 message layouts, shared across a workspace. Name Z-segment fields, set structure and allowed values, and validate messages against them.
On this page
A message definition describes how your HL7 v2 messages are laid out: the Z-segments a sender adds and what their fields mean, fields you call by another name, which segments come and how often, and the values a field may hold. It is the MedHook equivalent of a Rhapsody message definition, a Cloverleaf variant, an Iguana VMD file or a Mirth custom data type.
You keep definitions in Settings → Message definitions. Each one belongs to a workspace, and everything in that workspace uses it:
- the message inspector shows a definition's segment and field names (a
ZPIcard reads "Patient extras" and its first field "Preferred pharmacy", where it would otherwise say "Custom segment"); - the data map shows the names in its Specification column, lists the defined fields a sample doesn't carry so you can map them by name, and offers them in Add row;
- a Validate HL7 step can use a definition as its profile, with its code table checks.
Creating a definition
Choose New definition, give it a name, and list the message types it applies to (ADT^A01, ADT^A08), or leave them empty for any message. Then add segments in message order. For each segment you can set a description, whether it is required, and how many may come (0 for any number). For each field you can set:
| Setting | What it does |
|---|---|
| Field | The field number: ZPI-1 is 1. |
| Name | What the inspector and the data map call it. |
| Datatype | Any HL7 datatype. ST, ID, IS, NM, SI, TS, DTM, DT and TM are checked when validating. |
| Required | An empty value is a FIELD_REQUIRED error when validating. |
| Allowed values | A code table in the workspace. Its first column lists the values the field may hold. |
| Outside the table | Warning (the default) or Error. An error makes the ACK AE. |
Start from a sample message reads a message you paste and adds its segments, with one field for each non-empty position of a Z-segment (named "Field 1", "Field 2" until you rename them). The sample is read in your browser and dropped: no value from it is saved or sent. You can also start from a built-in profile (ADT^A01, ORU^R01, …) and change it.
A code table a definition names that doesn't exist yet is a warning when you save, not a refusal. A Validate HL7 step using the definition fails until the table exists, the same way a code table lookup does.
Viewers can read definitions; operators and admins can change them. Creating, saving and deleting one is in the audit log as message_definition.created, .updated and .deleted. A definition a workflow's Validate HL7 step uses can't be deleted until the step uses another profile.
Validating with a definition
In a Validate HL7 step, choose Message definition: NAME as the profile. In the workflow JSON that is the definition's id: "config": { "profile": "<definition id>" }. The step checks the message the same way it checks a built-in profile, plus:
- the message type must be one the definition lists (any, when it lists none);
- a field with allowed values must hold one of them. A value outside the table is a
FIELD_TABLEfinding, such asPID-8 is not in code table sex-codes. Like every finding it names the field and the table, never the value.
A definition is read once and kept in memory. A save takes effect at once on the engine that saved it, and within a second on the others. A definition from another workspace, or an id no definition has, is PROFILE_NOT_FOUND.
Moving definitions between workspaces and engines
A workflow export carries the definitions its Validate HL7 steps use, and the code tables they check against. On import, a definition with no namesake in the workspace is created; one that matches is reused; one that differs is kept, with a warning, and the workflow uses it. Either way the steps are pointed at the definition in the new workspace.
The engine configuration bundle in Settings → Backup & restore carries every workspace's definitions.
API
| Method and path | What it does |
|---|---|
GET /api/message-definitions | The workspace's definitions. |
POST /api/message-definitions | Create one. The answer's warnings lists code tables it lacks. |
GET /api/message-definitions/:id | One definition, and the workflows whose Validate HL7 steps use it. |
PUT /api/message-definitions/:id | Replace it. |
DELETE /api/message-definitions/:id | Delete it; 409 names the workflows still using it. |