Skip to content

Custom identifier: define a regex pattern and redact what it matches

Source: 13-custom-identifier.phisql

PhiSQL

-- Custom identifier: define a regex pattern and redact what it matches.
-- Here, a medical record number (MRN) like "MRN: 12345". Matching is
-- case-insensitive. Compiles to 13-custom-identifier.json.

POLICY custom_identifier;

DEFINE IDENTIFIER 'MRN' MATCHING '\bMRN[\s:#]*\d{5,}\b' CASE INSENSITIVE
  WITH REDACT(format='{{{REDACTED-MRN}}}');

Compiles to

{
  "identifiers" : {
    "identifiers" : [ {
      "classification" : "MRN",
      "pattern" : "\\bMRN[\\s:#]*\\d{5,}\\b",
      "caseSensitive" : false,
      "identifierFilterStrategies" : [ {
        "strategy" : "REDACT",
        "redactionFormat" : "{{{REDACTED-MRN}}}"
      } ]
    } ]
  }
}