Preconditions

Preconditions

When creating a de-identification rule, you can optionally create and apply a precondition to decide whether or not to apply the rule to a given field. Preconditions are scripts that are written with our JavaScript API.

You can add a precondition to an existing de-identification rule by going into Advanced Mode and selecting “Add Precondition.” This will open a window that allows you to write the script for the precondition and to test it by supplying messages in the Test Data window.

To decide whether or not the precondition is satisfied, use the callback() method. The callback() method accepts a boolean (true or false) which determines whether or not the precondition is satisfied. If the precondition is satisfied, the de-identification rule will be applied to the given field. If it is not satisfied, the de-identification rule will not be applied.

 

HL7 Messaging De-Identification Context

During HL7 message de-identification, 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 de-identified and any of its properties or methods. See the Message object definition
  • segment: Allows you to access the current segment being de-identified and any of its properties or methods. See the Segment object definition.
  • field: Allows you to access the current field being de-identified and any of its properties or methods. See the Field object definition.
  • component: Allows you to access the current component being de-identified and any of its properties or methods. See the Component object definition.
  • subComponent: Allows you to access the current sub-component being de-identified. See the SubComponent object definition.
  • dataType: Allows you to access the current data-type instance being de-identified if de-identifying using a data-type de-identification rule. The data-type can be any Field, Component or SubComponent.

 

Example

The following is an example of a precondition.

Suppose that you only wanted to apply a de-identification rule to the PID.3.1 – ID Number component in a message if the ID was a medical record number. In other words, if the value of the PID.3.5 – Identifier Type Code component was “MR.” The precondition you’d use would like this:
 

var patientIdTypeCode = context.field.get('5');
callback(patientIdTypeCode == 'MR');

 
Here, the precondition context’s field is the PID.3 – Patient Identifier List field.