Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

Medicare HICN Number Regex

Last post 11-15-2009, 5:45 PM by Aussie Susan. 4 replies.
Sort Posts: Previous Next
  •  09-24-2009, 1:02 PM 56431

    Medicare HICN Number Regex

    I am writing a Javascript validation routine to check that a medicare HICN number is valid.  This is a requirement with Medicare data.

    There are too many rules to fully describe here, but since many developers will need this validation, I'm posting here in hopes that someone has already written a working regex. 

    This is a highly ruled is an excerpt from hhs' requirements:

    (HICN)...are 9-digit numbers with at least one letter suffix (called a beneficiary identification code or BIC) in the tenth position. If there is an eleventh position, it may be either a letter or number e.g. 123-45-6789A or 987-65-4321D4. The HICN issued by the RRB, may contain either 6 or 9 digit numbers with up to a 3-position letter prefix e.g., A123456 or MA123-45-6789 ...

    The numeric portion of a 9-digit HICN consists of a Social Security Number (SSN). If the BIC is A, T, TA, M, M1, J1, J2, J3, J4 or the RRB prefix is A or H the number is the beneficiary's own SSN...

    From :



    Filed under:
  •  09-24-2009, 3:13 PM 56432 in reply to 56431

    Re: Medicare HICN Number Regex

    I just started working on this as well.  I have to do the validation in oracle.  I've had to break it into a series of checks.  Is the first position a number, if so, if the length is over 9 what letter is in the 10th position.  Once I've found out the character in the 10th position I used this as a validation (assumes 'B' in the 10th position):

    if not owa_pattern.match(i_hicn, '^\d{9,9}B{1}[A,D,G,H,J,K,L,N,P,Q,R,T,W,Y,1-9]{0,1}$') then
         result := 'HICN is invalid';
    end if;

    9 and only 9 numbers, B then either a number 1 through 9 or a letter in the list.  I'm relatively new to regular expressions so take this with a grain of salt.

  •  09-25-2009, 5:01 PM 56442 in reply to 56432

    Re: Medicare HICN Number Regex

    Thanks for the input.  It goes far deeper, of course.  The spec allows railroad retirees to begin with Alpha, and other rules apply for different suffixes.

    I'm not sure how far to take this or allow some sort of override for my users who have a special HICN.  I'll post my best shot at it when I find or invent it (seems like HHC should have to post a Regex for us :-)


  •  11-13-2009, 9:29 PM 57322 in reply to 56432

    Re: Medicare HICN Number Regex

    Were any modifications needed to the HICN regex? 



  •  11-15-2009, 5:45 PM 57337 in reply to 57322

    Re: Medicare HICN Number Regex

    I have no idea about HICN numbers etc., but some comments on the the pattern you have given.

    '{9,9}' is exactly the same as '{9}'.

    '{1}' is redundant as the lack of a quantifier is always taken as the related item occurring exactly once.

    '{0,1}', while not wrong, can be written as '?' which many (i.e. me!) find easier to understand.

    Within a character set definition, a character need only be defined once. Therefore in the above pattern, specifying the "," multiple times is redundant.

    Therefore the pattern can become:



View as RSS news feed in XML