feat(doctor): prevent duplicate doctor imports based on medical system code
This commit is contained in:
@@ -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، یکتا
|
||||
|
||||
Reference in New Issue
Block a user