Version: 1.3
Pcackage is currently marked as deprecated. A new version is coming soon.
PHP library based on Symfony Validator Component to validate various medical identification numbers used in Poland.
Only algorithmical validation mostly based on a check digit. It does not query official medical registries to fetch any data or if a record (ID) exists at all.
-
Numer Prawa Wykonywania Zawodu Lekarza (PWZ) (Polish medical licence ID for physicians)
<?php use Czachor\PolishIdValidators\Entities\PwzEntity; $id = new PwzEntity('5425740');
Example:
5425740
, total 7 digits:- check digit
- 6 digits
Source:
-
Numer Prawa Wykonywania Zawodu Farmaceuty (PWZF) (pharmacists ID)
<?php use Czachor\PolishIdValidators\Entities\PwzfEntity; $id = new PwzfEntity('09014954');
EAN-8 code, example:
09014954
, total 8 digits:- 2-digits local district chamber (
01
to22
) - 5-digits sequential number
- check digit
Source:
- 2-digits local district chamber (
-
Numer Prawa Wykonywania Zawodu Pielęgniarki/Położnej (PWZP) (nurses and midwives ID)
<?php use Czachor\PolishIdValidators\Entities\PwzpEntity; $id = new PwzpEntity('0201234P');
Example:
0201234P
, total 8 chars: 7 digits and letter:- 2-digits ID of local District Chamber of Nurses and Midwives (
01
to45
) - 5-digits sequential number
- letter
P
orA
Source:
- 2-digits ID of local District Chamber of Nurses and Midwives (
-
Numer Prawa Wykonywania Zawodu Diagnosty Laboratoryjnego (PWZDL) (laboratory diagnostician ID)
<?php use Czachor\PolishIdValidators\Entities\PwzdlEntity; $id = new PwzdlEntity('3143');
Example:
3143
, PWZDL ID are simple sequential numbers, so there is very simple "is numeric" validation.
PHP 7.2+.
Via Composer
$ composer require czachor/polish-id-validators
All ID must be passed as strings.
<?php
use Czachor\PolishIdValidators\Entities\PwzEntity;
use Czachor\PolishIdValidators\Validator;
$pwz_id = new PwzEntity('5425740'); // Polish medical licence ID
/** @var Symfony\Component\Validator\ConstraintViolationListInterface $obj_validator */
$violations = Validator::validate($pwz_id);
if ($violations->count() > 0) {
foreach ($violations as $violation) {
echo 'Error! ' . $violation->getMessage();
}
} else {
echo 'Valid!';
}
<?php
use Czachor\PolishIdValidators\Entities\PwzEntity;
use Symfony\Component\Validator\Validation;
$pwz_id = new PwzEntity('5425740'); // Polish medical licence ID
$validator = Validation::createValidatorBuilder()
->addMethodMapping('loadValidatorMetadata')
->getValidator();
$violations = $validator->validate($pwz_id);
// ...
Translation uses Symfony Translation Component.
Available languages:
- English (default) -
en_US
- Polish -
pl_PL
How to use:
<php
$violations = Validator::validate($pwz_id, 'pl_PL');
If your language is unsupported, you can add it manually:
<?php
$violations = Validator::validate($pwz_id, 'pt_BR', $path_to_your_php_resource_file);
Or if you want to use a different loader:
use Symfony\Component\Translation\Translator;
use Symfony\Component\Translation\Loader\ArrayLoader;
use Symfony\Component\Validator\Validation;
use Czachor\PolishIdValidators\Entities\PwzEntity;
$translator = new Translator('fr_FR');
$translator->addLoader('array', new ArrayLoader());
$translator->addResource('array', [
'Hello World!' => 'Bonjour',
], 'fr_FR');
$validator = Validation::createValidatorBuilder()
->addMethodMapping('loadValidatorMetadata')
->setTranslator($translator)
->getValidator();
$pwz_id = new PwzEntity('5425740'); // Polish medical licence ID
$violations = $validator->validate($pwz_id);
// ...
- More validators
- Annotations
- More translations
The MIT License (MIT).