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:
@@ -217,11 +217,20 @@ export default function AppointmentCreatePage() {
|
||||
<button type="button" className="btn sm ghost"
|
||||
onClick={() => { setPicked(null); setNationalCode(''); }}>تغییر</button>
|
||||
</div>
|
||||
<label style={label}>کد ملی</label>
|
||||
<div className="field" style={{ marginTop: 6, height: 44 }}>
|
||||
<DigitInput value={nationalCode} onChange={setNationalCode} maxDigits={10}
|
||||
placeholder="کد ملی مراجعه کننده" />
|
||||
</div>
|
||||
{/^\d{10}$/.test((picked.user_national_code ?? '').replace(/\D/g, '')) ? (
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', fontSize: 13 }}>
|
||||
<span style={{ color: 'var(--text-3)' }}>کد ملی</span>
|
||||
<span dir="ltr" style={{ fontWeight: 600 }}>{nationalCode}</span>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
<label style={label}>کد ملی (ثبتنشده — وارد کنید)</label>
|
||||
<div className="field" style={{ marginTop: 6, height: 44 }}>
|
||||
<DigitInput value={nationalCode} onChange={setNationalCode} maxDigits={10}
|
||||
placeholder="کد ملی مراجعه کننده" />
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user