Restrict Code IDs In A Codelist

From Fusion Registry Wiki
Jump to navigation Jump to search

Restrict Codes in a Codelist

Overview

It is possible to create a Codelist which specifies a restriction on the code IDs that can be created within that Codelist. This is useful if you wish to ensure that the codes in your codelist conform to a specific format.

To achieve this, on step 1 of the Codelist Wizard, there is an input area titled: "Restrict Codes". This area accepts a Regular Expression which you can use to specify the restriction. For example to restrict the codes to only be 3 upper-case alphabetic characters, you could use the Regular Expression: [A-Z]{3}.


RC1.PNG

When you define your codes within the Codelist you should specify IDs that conform to this restriction. When creating or editing codes, the Registry User Interface will not warn you if the restriction is not adhered to. Only when you click "Finish" and submit the Codelist to the Registry are all the codes checked to ensure that they meet the standard defined in the Regular Expression.

Applying a Restriction to a new Codelist

The permitted IDs of the codes in the codelist can be restricted by use of a Regular Expression. This allows a code standard to be enforced, such as all codes must be 5 digits exactly.

Examples:

  • To restrict the code IDs to 5 numeric characters use: ^[0-9]{5}$
  • To restrict the code IDs to 4-6 numeric characters use: ^[0-9]{4,6}$
  • To restrict the code IDs to 3 alpha-numerics use: ^[A-Za-z0-9]{3}$

The feature to generate a Regular Expression from the existing codes in the Codelist can assist you as it creates a simple Regular Expression by analysing the existing code IDs

Applying a Restriction to an existing Codelist

If you have a Codelist with code IDs already in it, it is permissible to apply a restriction. This is achieved by editing the existing codelist and on step 1, entering the Regular Expression in the appropriate field. Clicking "Finish" will attempt to save the Codelist in the Registry.

If any of the code IDs do not conform to the Regular Expression, you will be informed by way of an error message on the screen. You will then need to either change the codes or change the Regular Expression.

Generating a Restriction from an existing Codelist

If the Codelist already has codes, the Registry has the ability to generate a Regular Expression from the existing codes. This feature can be found on Step 1 of the Codelist Wizard. Next to the "Restrict Codes" input area, there is a "plus" button shown below:

CodelistWizard-RestrictCodesInput.png

Clicking this button will make the Registry analyse the codes in the Codelist to determine what the Regular Expression should be. The result will be displayed in both human-readable form and in Regular Expression form in a modal as shown below:

Clicking the "Apply Regular Expression" button will dismiss the modal and fill in the "Restrict Codes" field on Step 1 of the Codelist Wizard with the Regular Expression.

The generated Regular Expression will only analyse the existing code IDs for minimum and maximum length, and whether alphabetcs, numerics or special characters are used in the code IDs. It will not attempt to enforce if all codes have a special prefix or that special characters appear at certain positions in the code ID. For example, the codes: MT_A1, MT_FOO, MT_EXAMPLE quite clearly show that the codes all begine with "MT_". This analysis tool would only state that the minimum length of a code is 5 characters, the maximum length of a code ID is 10 characters and the alphabetics, numerics and the underscore character are permissable. If you wish to specify that the restriction is the characters "MT_" followed by a specific number of characters, then the appropriate Regular Expression must be defined by yourself.


RC2.PNG

Manifistation

If a user attempts to add a code which does not fit into the restriction, at the end of the Codelist Wizard the Registry will preform a check. If an invalid code is detected, it will not be possible to save the codelist without removing (or editing) the offending code.