The module has a hand-rolled PhoneNormalizer::toE164() that uses regex-based normalization. OpenEMR core now provides OpenEMR\Common\ValueObjects\PhoneNumber, a proper value object backed by libphonenumber with:
PhoneNumber::tryParse() / PhoneNumber::parse() — robust parsing with region support
->toE164() — proper E.164 formatting
->isValid() / ->isPossible() — validation against real area codes
->toNational(), ->toInternational(), ->toHL7() — multiple format outputs
Also relevant: OpenEMR\Common\Utils\ValidationUtils::isValidPhoneNumber() for validation-only checks.
Steps
- Replace all
PhoneNormalizer::toE164() call sites with PhoneNumber::tryParse()?->toE164()
- Consider passing
PhoneNumber value objects through the service layer instead of raw E.164 strings
- Remove
PhoneNormalizer class and its tests
- Verify libphonenumber is available at runtime via OpenEMR (no new Composer dependency needed)
The module has a hand-rolled
PhoneNormalizer::toE164()that uses regex-based normalization. OpenEMR core now providesOpenEMR\Common\ValueObjects\PhoneNumber, a proper value object backed by libphonenumber with:PhoneNumber::tryParse()/PhoneNumber::parse()— robust parsing with region support->toE164()— proper E.164 formatting->isValid()/->isPossible()— validation against real area codes->toNational(),->toInternational(),->toHL7()— multiple format outputsAlso relevant:
OpenEMR\Common\Utils\ValidationUtils::isValidPhoneNumber()for validation-only checks.Steps
PhoneNormalizer::toE164()call sites withPhoneNumber::tryParse()?->toE164()PhoneNumbervalue objects through the service layer instead of raw E.164 stringsPhoneNormalizerclass and its tests