feat(patients): phase B3 — medical records (پرونده پزشکی)

Add patient medical-exam entries: a new PatientMedicalRecord entity
(record-scoped, CASCADE) + repository, and owner-scoped CRUD endpoints
(GET list, POST create, PATCH, DELETE) under /api/v1/patient. Wire the
"پرونده پزشکی" tab in PatientDetailPage (list + add/edit modal with title,
date and notes + delete). PHPUnit covers CRUD + ownership + validation;
Vitest covers the tab. API docs updated.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
hamed
2026-07-13 15:27:34 +03:30
co-authored by Claude Opus 4.8
parent 98943ac249
commit 293eb8a0d2
8 changed files with 450 additions and 0 deletions
@@ -0,0 +1,44 @@
<?php
namespace App\Patient\Repository;
use App\Patient\Entity\PatientMedicalRecord;
use App\Patient\Entity\PatientRecord;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
class PatientMedicalRecordRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, PatientMedicalRecord::class);
}
public function findByUuid(string $uuid): ?PatientMedicalRecord
{
return $this->findOneBy(['uuid' => $uuid]);
}
/** @return PatientMedicalRecord[] */
public function findByRecord(PatientRecord $record): array
{
return $this->createQueryBuilder('m')
->where('m.record = :record')
->setParameter('record', $record)
->orderBy('m.recordedAt', 'DESC')
->getQuery()
->getResult();
}
public function save(PatientMedicalRecord $m): void
{
$this->getEntityManager()->persist($m);
$this->getEntityManager()->flush();
}
public function remove(PatientMedicalRecord $m): void
{
$this->getEntityManager()->remove($m);
$this->getEntityManager()->flush();
}
}