Backend:
- Add profile columns field_of_study, province_id, city_id, postal_code,
referral_source (UserProfile + migration).
- Extend PATCH /api/v1/patient/{uuid} to persist all demographic fields
and return them in the patient profile payload.
- Support editable mobile (login identifier): validation, uniqueness,
User.setMobileNumber, new ERR_PROFILE_002.
- Update docs/api/patient.md.
Frontend:
- New reusable Input, Field, and PatientRecordInfoForm (RHF + Zod).
- usePatient/useUpdatePatient hooks and patientForm mapping helpers.
- Extend the existing "info" tab in MyPatientsPage to the full field set
via the shared form (province/city/insurance options, Jalali date).
Tests: Patient entity + PATCH integration (PHPUnit); form, hooks, and
mapping helpers (Vitest).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
65 lines
2.1 KiB
PHP
65 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Tests\Patient;
|
|
|
|
use App\Auth\Entity\User;
|
|
use App\UserProfile\Entity\UserProfile;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* Unit coverage for the patient demographic columns added to UserProfile
|
|
* (field_of_study, province_id, city_id, postal_code, referral_source):
|
|
* setters round-trip through the getters and toArray() exposes the API keys.
|
|
*/
|
|
class UserProfileDemographicsTest extends TestCase
|
|
{
|
|
private function profile(): UserProfile
|
|
{
|
|
return new UserProfile(new User('09121234567'));
|
|
}
|
|
|
|
public function testNewDemographicSettersRoundTrip(): void
|
|
{
|
|
$p = $this->profile();
|
|
$p->setFieldOfStudy('نرمافزار')
|
|
->setProvinceId(8)
|
|
->setCityId(42)
|
|
->setPostalCode('8913746351')
|
|
->setReferralSource('اینستاگرام');
|
|
|
|
self::assertSame('نرمافزار', $p->getFieldOfStudy());
|
|
self::assertSame(8, $p->getProvinceId());
|
|
self::assertSame(42, $p->getCityId());
|
|
self::assertSame('8913746351', $p->getPostalCode());
|
|
self::assertSame('اینستاگرام', $p->getReferralSource());
|
|
}
|
|
|
|
public function testNewFieldsDefaultToNull(): void
|
|
{
|
|
$p = $this->profile();
|
|
|
|
self::assertNull($p->getFieldOfStudy());
|
|
self::assertNull($p->getProvinceId());
|
|
self::assertNull($p->getCityId());
|
|
self::assertNull($p->getPostalCode());
|
|
self::assertNull($p->getReferralSource());
|
|
}
|
|
|
|
public function testToArrayExposesNewKeys(): void
|
|
{
|
|
$arr = $this->profile()
|
|
->setFieldOfStudy('پزشکی')
|
|
->setProvinceId(1)
|
|
->setCityId(2)
|
|
->setPostalCode('1234567890')
|
|
->setReferralSource('معرفی دوستان')
|
|
->toArray();
|
|
|
|
self::assertSame('پزشکی', $arr['field_of_study']);
|
|
self::assertSame(1, $arr['province_id']);
|
|
self::assertSame(2, $arr['city_id']);
|
|
self::assertSame('1234567890', $arr['postal_code']);
|
|
self::assertSame('معرفی دوستان', $arr['referral_source']);
|
|
}
|
|
}
|