[x] Strip each piece of leading and trailing spaces
[x] There should be 3 pieces: Health card #, Province code, Date of birth. If the number is different, the line is invalid. Error message: Line \ has \ components instead of 3. Each line should contain the patient's Health Card number, the province code, and the patient's date of birth.
[x] Next, validate each of the 3 pieces
Date of birth:
[x] Check against this regular expression: ^\d{4}[\-\/\s]?((((0[13578])|(1[02]))[\-\/\s]?(([0-2][0-9])|(3[01])))|(((0[469])|(11))[\-\/\s]?(([0-2][0-9])|(30)))|(02[\-\/\s]?[0-2][0-9]))$. If invalid, the error message should be: The date of birth "..." appears to be invalid. Please enter a correct date of birth in the format YYYY-MM-DD.
[x] The regexp above will also accept dates in the format yyyy/MM/dd and yyyy MM dd in addition to yyyy-MM-dd. If valid according to the regexp, replace \ and space with - before encryption.
Province code:
[x] Should be one of: AB, BC, MB, NB, NL, NS, NT, NU, ON, PE, QC, SK, YT. Lower case version is accepted.
[x] If the province code is invalid, the error message should be: Province code "..." is invalid. It should be one of : \.
Health card number:
Should be validated after the province code, as algorithm depends on province
Should be validated after the date of birth, as in some provinces the number depends on the date of birth
For ON:
[x] Remove spaces, dashes, trailing letters (E.g. if the user enters "2345-678-904 AB", obtain "2345678904"). If the result is not composed of 10 digits, it is invalid. Error message: Health card number "..." is invalid for the province of ON. A 10 digit number is expected.
If the input is found valid, concatenate the post-processed health card number and date of birth and generate the GUID. If the input is found invalid at any of the verification steps, do not generate a GUID and display the corresponding error message in red instead of a GUID in the list of GUIDs generated as specified by #1.
Output:
$2a$10$SquWSeGnbm78j.ljlahwXunebEo.mEDyiDiShRH0HR4C.tSCL3eWq
Health card number 2345678913 is invalid for the province of ON. Please check the number and try again.
$2a$10$zTN.dLDCtFr.GzgKkA9FyewMM7dEDsYlXNmbSZjg8EVi53J0BXPFS
For each line:
[x] Split by separator [,\t]
[x] Strip each piece of leading and trailing spaces
[x] There should be 3 pieces: Health card #, Province code, Date of birth. If the number is different, the line is invalid. Error message: Line \ has \ components instead of 3. Each line should contain the patient's Health Card number, the province code, and the patient's date of birth.
[x] Next, validate each of the 3 pieces
Date of birth:
[x] Check against this regular expression:
^\d{4}[\-\/\s]?((((0[13578])|(1[02]))[\-\/\s]?(([0-2][0-9])|(3[01])))|(((0[469])|(11))[\-\/\s]?(([0-2][0-9])|(30)))|(02[\-\/\s]?[0-2][0-9]))$
. If invalid, the error message should be: The date of birth "..." appears to be invalid. Please enter a correct date of birth in the format YYYY-MM-DD.[x] The regexp above will also accept dates in the format
yyyy/MM/dd
andyyyy MM dd
in addition toyyyy-MM-dd
. If valid according to the regexp, replace\
and space with-
before encryption.Province code:
[x] Should be one of: AB, BC, MB, NB, NL, NS, NT, NU, ON, PE, QC, SK, YT. Lower case version is accepted.
[x] If the province code is invalid, the error message should be: Province code "..." is invalid. It should be one of : \
.
Health card number:
For ON:
[x] Remove spaces, dashes, trailing letters (E.g. if the user enters "2345-678-904 AB", obtain "2345678904"). If the result is not composed of 10 digits, it is invalid. Error message: Health card number "..." is invalid for the province of ON. A 10 digit number is expected.
[x] If the result is composed of 10 digits, run the check from http://health.gov.on.ca/english/providers/pub/ohip/tech_specific/pdf/5_13.pdf . If the check fails, error message: Health card number "..." is invalid for the province of ON. Please check the number and try again.
For other provinces and territories:
If the input is found valid, concatenate the post-processed health card number and date of birth and generate the GUID. If the input is found invalid at any of the verification steps, do not generate a GUID and display the corresponding error message in red instead of a GUID in the list of GUIDs generated as specified by #1.
Example
Input:
Output: $2a$10$SquWSeGnbm78j.ljlahwXunebEo.mEDyiDiShRH0HR4C.tSCL3eWq Health card number 2345678913 is invalid for the province of ON. Please check the number and try again. $2a$10$zTN.dLDCtFr.GzgKkA9FyewMM7dEDsYlXNmbSZjg8EVi53J0BXPFS