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:
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user