feat(treatment): filter treatment cases by patient record
The list could be narrowed by status, search and open-date, but not by patient — so a patient's own file had no way to ask which courses belong to them. `?record=` adds that bound. patientRecord is joined once and shared with the search branch; joining it twice under the same alias is a DQL error, and search already needed it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -299,6 +299,32 @@ class TreatmentCaseEditTest extends ApiTestCase
|
||||
self::assertSame([], $payload['assigned_staff']);
|
||||
}
|
||||
|
||||
/** نمای «پروندهٔ بیمار»: فقط دورههای همان بیمار. */
|
||||
public function testFilteringByPatientRecord(): void
|
||||
{
|
||||
[$case, $clinic] = $this->scenario('بیمار الف ' . uniqid());
|
||||
$recordUuid = $case->getPatientRecord()->getUuid();
|
||||
|
||||
// دورهٔ دومی برای بیمار دیگری در همان محیط
|
||||
[$other] = $this->scenario('بیمار ب ' . uniqid());
|
||||
|
||||
$type = 'clinic';
|
||||
$id = (int) $clinic->getId();
|
||||
|
||||
$mine = $this->cases()->findForTenant($type, $id, null, null, null, null, $recordUuid);
|
||||
self::assertCount(1, $mine);
|
||||
self::assertSame($case->getId(), $mine[0]->getId());
|
||||
|
||||
// uuid ناموجود → آرایهٔ خالی، نه خطا
|
||||
self::assertSame([], $this->cases()->findForTenant($type, $id, null, null, null, null, 'does-not-exist'));
|
||||
|
||||
// فیلتر بیمار و جستجو با هم — یک join مشترک، نه دو تا
|
||||
$name = $case->getPatientRecord()->getUser()->getRealName();
|
||||
self::assertCount(1, $this->cases()->findForTenant($type, $id, null, $name, null, null, $recordUuid));
|
||||
|
||||
self::assertNotSame($case->getId(), $other->getId());
|
||||
}
|
||||
|
||||
/** فیلتر بازه روی تاریخِ باز شدن پرونده است، نه سررسید جلسه. */
|
||||
public function testDateRangeFiltersByOpenedAt(): void
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user