fix(doctor): strip «دکتر» prefix on IRIMC import + name-fix & purge commands
Root cause of "دکتر دکتر …" (and ellipsis-truncated "…نی") in admin: IRIMC
names already contain the «دکتر» title, while the panel renders «دکتر {name}».
Convention is to store the bare name.
- DoctorImportService: normalize name via PersianText::stripDoctorTitle
(also fixes ي/ی, ك/ک, half-space)
- PersianText::stripDoctorTitle now strips consecutive «دکتر دکتر …» prefixes
- app:doctors:fix-irimc-names: one-off backfill for existing source='irimc'
rows (dry-run supported) — fixed 340 rows
- app:doctors:purge: FK-safe full wipe of doctors + all dependent tables +
orphan surrogate users, for a clean test DB (dry-run default, --force to
apply, prod-guarded)
- tests: PersianTextTest cases for the title stripping; DoctorImportTest
asserts stored name has no «دکتر» prefix
- docs/api/doctor-import.md: name convention + the two new commands
Verified: import "دکتر صفورا حجازی نیا" → stored "صفورا حجازی نیا" → panel
shows single «دکتر صفورا حجازی نیا».
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -15,7 +15,7 @@ class DoctorImportTest extends ApiTestCase
|
||||
private function importPayload(string $code): array
|
||||
{
|
||||
return [
|
||||
'name' => 'دکتر تست ایمپورت',
|
||||
'name' => 'دکتر صفورا حجازی نیا',
|
||||
'medical_system_code' => $code,
|
||||
'source_ref' => 'https://membersearch.irimc.org/member/profile?id=test',
|
||||
'gender' => 'man',
|
||||
@@ -46,6 +46,8 @@ class DoctorImportTest extends ApiTestCase
|
||||
$this->assertSame('unclaimed', $doctor->getOwnerStatus());
|
||||
$this->assertSame('irimc', $doctor->getSource());
|
||||
$this->assertFalse($doctor->isActiveDoctorAppointment());
|
||||
// نام بدون پیشوند «دکتر» ذخیره میشود (UI خودش «دکتر» را جلو میگذارد)
|
||||
$this->assertSame('صفورا حجازی نیا', $doctor->getName());
|
||||
|
||||
$surrogate = $doctor->getUser();
|
||||
$this->assertStringStartsWith('imp_', $surrogate->getMobileNumber());
|
||||
@@ -74,7 +76,8 @@ class DoctorImportTest extends ApiTestCase
|
||||
|
||||
$this->em->clear();
|
||||
$doctor = $this->em->getRepository(Doctor::class)->findOneBy(['uuid' => $first['data']['uuid']]);
|
||||
$this->assertSame('دکتر تست ویرایششده', $doctor->getName());
|
||||
// نیمفاصله در normalize به فاصله تبدیل میشود
|
||||
$this->assertSame('تست ویرایش شده', $doctor->getName());
|
||||
}
|
||||
|
||||
public function testClaimedDoctorIsNeverOverwritten(): void
|
||||
|
||||
@@ -28,6 +28,10 @@ class PersianTextTest extends TestCase
|
||||
$this->assertSame('فرخنده حسینی', PersianText::stripDoctorTitle('دکتر فرخنده حسینی'));
|
||||
$this->assertSame('فرخنده حسینی', PersianText::stripDoctorTitle(' دکتر فرخنده حسینی '));
|
||||
$this->assertSame('فرخنده حسینی', PersianText::stripDoctorTitle('فرخنده حسینی'));
|
||||
$this->assertSame('صفورا حجازی نیا', PersianText::stripDoctorTitle('دکتر صفورا حجازی نیا'));
|
||||
// پیشوند متوالی و کافِ عربی
|
||||
$this->assertSame('صفورا حجازی نیا', PersianText::stripDoctorTitle('دکتر دکتر صفورا حجازی نیا'));
|
||||
$this->assertSame('علی اکبری', PersianText::stripDoctorTitle('دكتر علي اكبري'));
|
||||
}
|
||||
|
||||
public function testDifferentNamesStayDifferent(): void
|
||||
|
||||
Reference in New Issue
Block a user