Files
clinicpro/src/Doctor/Service/SourceProfileId.php
T

27 lines
910 B
PHP

<?php
namespace App\Doctor\Service;
/**
* استخراج شناسهٔ پایدارِ پروفایل مبدأ از `source_ref`/`profile_url`.
*
* برای irimc، URL به شکل `.../member/profile?id=<uuid>` است؛ خودِ URL ممکن است
* قالبش (دامنه/پارامتر اضافه) تغییر کند، ولی UUID پروفایل ثابت و authoritative است
* و کلید اصلی idempotency ایمپورت را می‌سازد.
*/
final class SourceProfileId
{
/** UUID داخل query param `id=`؛ قالب ناشناخته → null (fallback روی medical_system_code). */
public static function fromRef(?string $ref): ?string
{
if ($ref === null || trim($ref) === '') {
return null;
}
if (preg_match('/[?&]id=([0-9a-f-]{8,})/i', $ref, $m) === 1) {
return strtolower($m[1]);
}
return null;
}
}