API Reference
Your code class inherits from BaseCustomFunction. The following sections describe all the properties and methods available to you.
Lifecycle Hooks
Override these methods to hook into the execution lifecycle. All are optional.
Method | Thread | Description |
|---|---|---|
| UI | Called once before the first message. Initialize objects, prompt for user input. |
| Background | Called once per message when F5 is pressed. |
| Background | Called once for the selected message when F10 is pressed. |
| UI | Called once after all messages are processed. Cleanup, summary output. |
| UI | Called if an unhandled exception occurs during message processing. |
| UI | Customize toolbar buttons before execution begins. |
Message Access
Member | Type | Description |
|---|---|---|
|
| The raw message data for the current message. |
|
| The parsed HL7 message (lazy; same as calling |
|
| Returns a parsed |
|
| The message collection from the active tab. |
|
| The zero-based index of the current message within the collection. |
|
| All message collections currently loaded in HL7Spy (all open tabs). |
Saving Output
Use SaveMessage() to collect messages into named output collections. After execution, each collection opens as a new tab in HL7Spy.
Method | Description |
|---|---|
| Save a parsed message to the named collection. |
| Save a raw HL7 string to the named collection. |
| Save a message data object to the named collection. |
| Save multiple messages at once to the named collection. |
Property | Type | Description |
|---|---|---|
|
| All output collections created during execution. |
|
| Set this to an HL7 path to sort each output collection by that field. Leave |
Logging
Log entries appear in the Events tab. Double-clicking an event navigates to the associated message.
Method | Description |
|---|---|
| Log a message with the given severity. |
| Log a message associated with a specific HL7 node. |
| Log a message associated with a specific HL7 path. |
Severity levels: Informational, Warning, Error.
Property | Type | Description |
|---|---|---|
|
| Returns |
|
| The full list of log entries for the current execution. |
|
| The most recent exception that occurred during a lifecycle hook. |
Assertions
The Assert property provides validation helpers. Each failed assertion logs an Error to the Events tab. This is useful for building message validation functions.
Method | Description |
|---|---|
| Log an error if |
| Log an error if |
| Log an error if the node value does not equal |
| Log an error if the node value equals |
| Log an error if the node is not empty. |
| Log an error if the node is empty. |
| Log an error if the node value is not a valid number. |
| Log an error if the node value is not in the allowed list. |
| Log an error if the node value is not in the allowed list (enumerable overload). |
| Validate state transitions. Transition format: |
| Log an error if the value is not a valid timestamp matching |
| Log an error if the field value exceeds |
| Log an error if the node string exceeds |
| Log an error if the field repetition count does not match |
| Log an error if the segment order does not match the expected regex pattern. |
Translations
Translations let you define field-level transformations and apply them in bulk.
Method | Description |
|---|---|
| Register a custom translator. |
| Register a conditional translation: |
| Apply all registered translations to the message. |
Anonymization
The Anonymizer class tracks replacement values by a key (typically a patient identifier like PID-3). This ensures consistent anonymization across all messages for the same patient.
Method | Description |
|---|---|
| Get or create an |
| Get a |
Key Anonymizer methods:
Method | Description |
|---|---|
| Register a text replacement. Returns |
| Replace the value of an HL7 node and optionally include it in free-text search-and-replace. |
| Replace a date/time value. |
| Shift a date/time value by the given delta. |
| Perform a bulk search-and-replace on the full message text using all registered replacements. |
| Check if a replacement has already been registered for this node. |
| Retrieve the |
Progress and Cancellation
Member | Description |
|---|---|
| Update the status bar with a message and percentage (0–100). |
| Update the status bar with a message and progress calculated from |
| Set to |
UI Thread Access
Because Run() and RunOnce() execute on a background thread, you must marshal any UI operations (such as showing a dialog) to the UI thread.
Method | Description |
|---|---|
| Execute |
Embedded Resources
Method | Description |
|---|---|
| Returns a |
| Returns the full text content of the named embedded resource as a |
Debugging
Method | Description |
|---|---|
| Trigger a debugger break. If a debugger is attached, it breaks immediately. Otherwise, it launches the debugger attach dialog. |
State Properties
Property | Type | Description |
|---|---|---|
|
| The execution mode: |
|
|
|
|
| All log entries for the current execution. |
|
| The most recent exception from a lifecycle hook. |