fix: return patient national code from profile in patients list

National code is stored on the profiles table, not users, so the patients
search returned null user_national_code for patients that actually have one
— which blocked selecting an existing patient on the appointment create
form. Backfill user_national_code from the profile (batch query) in the
list endpoint. On the create page, show a picked patient's stored national
code read-only and only prompt for input when the record genuinely lacks
one. Add backend tests and update docs/api/patient.md.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
hamed
2026-07-16 09:57:03 +03:30
co-authored by Claude Opus 4.8
parent 110c210cf4
commit 3e8126c520
5 changed files with 118 additions and 13 deletions
+8 -2
View File
@@ -45,9 +45,13 @@ Returns a paginated list of patient records belonging to the authenticated entit
"uuid": "...",
"entity_type": "doctor",
"entity_id": 5,
"user": { "uuid": "...", "fullName": "علی رضایی", "phone": "09123456789" },
"user_uuid": "...",
"user_name": "علی رضایی",
"user_mobile": "09123456789",
"user_national_code": "0012345675",
"record_number": "1024",
"tags": [],
"created_by_type": "doctor",
"created_by_id": 5,
"created_at": 1718375000
}
],
@@ -59,6 +63,8 @@ Returns a paginated list of patient records belonging to the authenticated entit
}
```
> `user_national_code` منبعِ حقیقتش جدول `profiles` است (نه `users`). اگر روی خودِ کاربر خالی باشد، از پروفایل پر می‌شود؛ اگر هیچ‌کدام نداشته باشند `null` است.
**Errors:**
| Code | HTTP | Description |