JavaScript Validation

HL7 Message JavaScript Engine API

The JavaScript engine allows you to create custom validation rules, which will be used during the conformance validation of your HL7 messages.

You can add custom javascript validation rules at the profile, trigger-event, segment and data-type levels. The javascript rules will be evaluated during the HL7 message validation, depending on the element of the message being validated.

Profile: Validation rules added at the Profile level will be evaluated first and only once per message.

Trigger-Event: Validation rules added at the Trigger-Event level will be evaluated only once per message and will only be evaluated for matching messages. The MSH.9 – Message Type is used to match messages and trigger-events.

Segment: Validation rules added at the Segment level will be evaluated for each instances of the segment in a message.

Data-Type: Validation rules added at the Data-Type level will be evaluated for each instances of the data-type in a message.

 

HL7 Message Validation Context

During HL7 message validation, the JavaScript engine context is updated, allowing you to access the current element being validated.  The context has the following properties you can refer to:

  • profile: Allows you to fetch data from profile. See the Profile object definition.
  • message: Allows you to access the message being validated and any of its properties or methods. See the Message object definition
  • segment: Allows you to access the current segment being validated and any of its properties or methods. See the Segment object definition.
  • field: Allows you to access the current field being validated and any of its properties or methods. See the Field object definition.
  • component: Allows you to access the current component being validated and any of its properties or methods. See the Component object definition.
  • subComponent: Allows you to access the current sub-component being validated. See the SubComponent object definition.
  • dataType: Allows you to access the current data-type instance being validated. The dataType can be any of Field, Component or SubComponent. See the DataType object definition.

 

Profile

The profile object allows you to fetch data from profile.

Methods

getTable(tableId: string): Table
  • Returns a table object if the table exist, otherwise it returns null. See the Table object definition.

var administrativeSexTable = profile.getTable('0001');
log('Table : ' + administrativeSexTable.Name);
// Table : Administrative Sex

 

Table

The table object allows you to get details about a given table in a profile.

Properties

name: string
  • The name of the table.

var administrativeSexTable = profile.getTable('0001');
log('Name: ' + administrativeSexTable.name);
// Name: Administrative Sex

values: TableEntry[]
  • An array containing all of the table’s entries. See the TableEntry object definition.

var administrativeSexTable = profile.getTable('0001');
log('First Value: ' + administrativeSexTable.values[0]);
log('Second Value: ' + administrativeSexTable.values[1]);
// First value: A
// Second value: F

Methods

contains(value: string): bool
  • Returns true if the given value exists in the table’s entries. The value is case-sensitive.

var administrativeSexTable = profile.getTable('0001');
log('Contains M: ' + administrativeSexTable.contains('M'));
// Contains M: true

get(value: string): TableEntry
  • Returns a the first entry which matches the given value, otherwise it returns null. See the TableEntry object definition.

var administrativeSexTable = profile.getTable('0001');
var maleEntry = administrativeSexTable.get('M');
log('Male Entry: ' + maleEntry);
// Male Entry: M

 

TableEntry

The TableEntry object allows you to get the details of a table entry.

Properties

label: string
  • The display name of the table entry.

var maleEntry = administrativeSexTable.get('M');
log('Label: ' + maleEntry.label);
// Label: Male

value: string
  • Value of the table entry.

var maleEntry = administrativeSexTable.get('M');
log('Value: ' + maleEntry.value);
// Value: M

Methods

getExtraContentValue(columnName: string): bool
  • Returns the given custom-column property value.

var maleEntry = administrativeSexTable.get('M');
log('Deprecated : ' + maleEntry.getExtraContentValue('DEPRECATED'));
// Deprecated : false

toString()
  • Returns the value of a table entry.

var maleEntry = administrativeSexTable.get('M');
log('ToString: ' + maleEntry.toString());
// ToString: M