Add a patient message/communication log: a new PatientMessage entity (record-scoped, CASCADE) + repository, and owner-scoped endpoints (GET messages, POST message, DELETE message) with a validated channel (sms/note/call/email). Wire the "پیامها" tab in PatientDetailPage (send box + list + delete). PHPUnit covers create/list/delete + ownership + validation; Vitest covers the tab. API docs updated. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Patient\Repository;
|
|
|
|
use App\Patient\Entity\PatientMessage;
|
|
use App\Patient\Entity\PatientRecord;
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
use Doctrine\Persistence\ManagerRegistry;
|
|
|
|
class PatientMessageRepository extends ServiceEntityRepository
|
|
{
|
|
public function __construct(ManagerRegistry $registry)
|
|
{
|
|
parent::__construct($registry, PatientMessage::class);
|
|
}
|
|
|
|
public function findByUuid(string $uuid): ?PatientMessage
|
|
{
|
|
return $this->findOneBy(['uuid' => $uuid]);
|
|
}
|
|
|
|
/** @return PatientMessage[] */
|
|
public function findByRecord(PatientRecord $record): array
|
|
{
|
|
return $this->createQueryBuilder('m')
|
|
->where('m.record = :record')
|
|
->setParameter('record', $record)
|
|
->orderBy('m.id', 'DESC')
|
|
->getQuery()
|
|
->getResult();
|
|
}
|
|
|
|
public function save(PatientMessage $m): void
|
|
{
|
|
$this->getEntityManager()->persist($m);
|
|
$this->getEntityManager()->flush();
|
|
}
|
|
|
|
public function remove(PatientMessage $m): void
|
|
{
|
|
$this->getEntityManager()->remove($m);
|
|
$this->getEntityManager()->flush();
|
|
}
|
|
}
|