feat(doctor): prevent duplicate doctor imports based on medical system code

This commit is contained in:
hamed
2026-07-11 19:56:58 +03:30
parent 6c67d522ba
commit 23590370b2
3 changed files with 44 additions and 0 deletions
@@ -65,6 +65,15 @@ class DoctorImportService
return new DoctorImportResult($doctor, false, 'claimed');
}
if ($doctor === null) {
// جلوگیری از تکرار بین منابع: اگر همین کد نظام پزشکی با هر source دیگری
// (مثلاً ثبت دستی) وجود دارد، ایمپورت نه می‌سازد و نه بازنویسی می‌کند.
$existing = $doctorRepo->findOneBy(['medicalSystemCode' => $code]);
if ($existing !== null) {
return new DoctorImportResult($existing, false, 'duplicate');
}
}
if ($doctor === null) {
// کاربر جانشینِ یکتا و غیرفعال؛ شناسهٔ مصنوعی قطعی از روی کد نظام پزشکی
$synthetic = 'imp_' . substr(md5($source . ':' . $code), 0, 14); // ≤ ۱۸ کاراکتر، ASCII، یکتا