Ë
    Ã?ÆiÇ  ã                  óV   — d Z ddlmZ ddl­ ddlmZmZ dd„Zdd„Zdd„Z	dd„Z
dd	„Zy
)uÂ  BC PHN (British Columbia Personal Health Number).

A unique, numerical, lifetime identifier used in the specific identification
of an individual client or patient who has had any interaction with the
British Columbia health system. It is assigned only to and used by one person
and will not be assigned to any other person.

The existence of a PHN does not imply eligibility for health care services in
BC or provide any indication of an individualâ€™s benefit status.

The PNH is a 10-digit number where the first digit is always 9, and the last
digit is a MOD-11 check digit.

More information:

* https://www2.gov.bc.ca/gov/content/health/health-drug-coverage/msp/bc-residents/personal-health-identification
* https://www2.gov.bc.ca/assets/gov/health/practitioner-pro/software-development-guidelines/conformance-standards/vol-4b-app-rules-client-registry.pdf


>>> validate('9698 658 215')
'9698658215'
>>> format('9698658215')
'9698 658 215'
>>> validate('9698648215')
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> validate('5736504210')
Traceback (most recent call last):
    ...
InvalidComponent: ...
>>> validate('9736A04212')
Traceback (most recent call last):
    ...
InvalidFormat: ...
é    )Úannotations)Ú*)ÚcleanÚisdigitsc                ó6   — t        | d«      j                  «       S )zˆConvert the number to the minimal representation. This strips the
    number of any valid separators and removes surrounding whitespace.z- )r   Ústrip©Únumbers    úW/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/ca/bc_phn.pyÚcompactr   @   s   € ô �˜Ó×$Ñ$Ó&Ð&ó    c                ó`   — d}t        d„ t        || «      D «       «      }t        d|z
  dz  «      S )zZCalculate the check digit. The number passed should not have the check
    digit included.)é   é   é   é   é
   é	   é   é   c              3  óD   K  — | ]  \  }}|t        |«      z  d z  –— Œ y­w)é   N)Úint)Ú.0ÚwÚns      r   ú	<genexpr>z#calc_check_digit.<locals>.<genexpr>J   s!   è ø€ Ò?¡$ ! QˆQ”�Q“‰Z˜2ÕÑ?ùs   ‚ r   )ÚsumÚzipÚstr)r
   ÚweightsÚss      r   Úcalc_check_digitr#   F   s3   € ð (€GÜÑ?¬#¨g°vÓ*>Ô?Ó?€AÜ��Q‘˜"‰}ÓÐr   c                óÖ   — t        | «      } t        | «      dk7  r
t        «       ‚t        | «      s
t	        «       ‚| d   dk7  r
t        «       ‚| d   t        | dd «      k7  r
t        «       ‚| S )z[Check if the number is a valid PHN. This checks the length,
    formatting and check digit.r   r   Ú9r   é   )r   ÚlenÚInvalidLengthr   ÚInvalidFormatÚInvalidComponentr#   ÚInvalidChecksumr	   s    r   Úvalidater,   N   sl   € ô �V‹_€FÜ
ˆ6ƒ{�bÒÜ‹oÐÜ�FÔÜ‹oÐØˆa�y�CÒÜÓ Ð Øˆa�yÔ$ V¨A¨a [Ó1Ò1ÜÓÐØ€Mr   c                óJ   — 	 t        t        | «      «      S # t        $ r Y yw xY w)z#Check if the number is a valid PHN.F)Úboolr,   ÚValidationErrorr	   s    r   Úis_validr0   ]   s)   € ðÜ”H˜VÓ$Ó%Ð%øÜò Ùðús   ‚ –	"¡"c                óR   — t        | «      } dj                  | dd | dd | dd f«      S )z8Reformat the number to the standard presentation format.ú r   r   r   N)r   Újoinr	   s    r   Úformatr4   e   s3   € ä�V‹_€FØ�8‰8�V˜A˜a�[ &¨¨1 +¨v°a°b¨zÐ:Ó;Ð;r   N)r
   r    Úreturnr    )r
   r    r5   r.   )Ú__doc__Ú
__future__r   Ústdnum.exceptionsÚstdnum.utilr   r   r   r#   r,   r0   r4   © r   r   ú<module>r;      s/   ðñ*#õJ #ä ß 'ó'óóóô<r   