feat: enhance doctor import process with source profile ID for improved idempotency and deduplication

This commit is contained in:
hamed
2026-07-19 20:19:35 +03:30
parent 74577c2ff6
commit e670b38821
11 changed files with 593 additions and 13 deletions
+38
View File
@@ -0,0 +1,38 @@
<?php
namespace App\Tests\Doctor;
use App\Doctor\Service\SourceProfileId;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
/**
* شناسهٔ پروفایل، کلید اصلی idempotency ایمپورت است؛ استخراجش باید در برابر تغییر
* قالب URL (دامنه/پارامتر اضافه) پایدار بماند و برای قالب ناشناخته null بدهد
* تا مسیر روی medical_system_code fallback کند.
*/
class SourceProfileIdTest extends TestCase
{
#[DataProvider('refs')]
public function testFromRef(?string $ref, ?string $expected): void
{
$this->assertSame($expected, SourceProfileId::fromRef($ref));
}
public static function refs(): array
{
$uuid = 'ad600622-b98a-48ac-a448-89ef68fd2c46';
return [
'irimc profile url' => ["https://membersearch.irimc.org/member/profile?id=$uuid", $uuid],
'extra query params' => ["https://membersearch.irimc.org/member/profile?lang=fa&id=$uuid&x=1", $uuid],
'different host, same id' => ["http://example.test/x?id=$uuid", $uuid],
'uppercase normalized to lowercase' => ['?id=' . strtoupper($uuid), $uuid],
'no id param' => ['https://membersearch.irimc.org/member/profile', null],
'plain code, not a url' => ['42507', null],
'empty' => ['', null],
'whitespace' => [' ', null],
'null' => [null, null],
];
}
}