Skip to content

Conversation

@denniskigen
Copy link
Member

@denniskigen denniskigen commented Apr 16, 2025

The previous regex for the SSN identifier was missing start (^) and end ($) anchors, allowing partial matches and permitting invalid formats such as extra characters (e.g., X-A-1234567-Y) or too many digits (e.g., A-123456789). This caused the validation to accept identifiers that did not exactly match the required format: one uppercase letter, a dash, and exactly seven digits (e.g., A-0010902).

This commit adds the necessary anchors to enforce strict matching and updates the regex description for clarity and accuracy, improving data quality by ensuring only valid identifiers are accepted.

Relates to: openmrs/openmrs-esm-patient-management#1553

The regex for the SSN identifier format was missing the anchors (^ and $),
which caused the validation to fail for identifiers that did not exactly
match the required format of one uppercase letter, followed by a dash and
exactly 7 digits (e.g., "A-0010902"). Without these anchors, the pattern
could match invalid formats like "X-A-1234567-Y" (extra characters), or
"A-123456789" (too many digits), leading to potential data quality issues.
This PR adds start and end anchors to ensure the identifier strictly follows
the required format. It also updates the regex description to be more
descriptive and accurate.
@ibacher ibacher merged commit 9984a50 into main Apr 16, 2025
1 check passed
@ibacher
Copy link
Member

ibacher commented Apr 16, 2025

Java distinguishes between calls to Matcher#matches() and Matcher#find(); with matches, it basically ensures that it only returns true if the match covers the full string, so roughly equivalent to what this does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants