Add a record-scoped PatientCall entity (subject, summary, outcome
success/missed, called_at, personnel) with its repository and three
owner-gated endpoints on PatientController:
GET /patient/{uuid}/calls — call log, newest first, optional ?outcome
POST /patient/{uuid}/call — log a call (subject required)
DELETE /patient/call/{uuid} — delete an entry
Wire the previously-placeholder "کال سنتر" tab as a CallCenterTab: a register
form (date/time/subject/summary + success/missed toggle, personnel taken from
the logged-in user) beside a filterable call history (all / success / missed).
With this every patient-detail tab is now backed by a real endpoint, so the
generic Placeholder is no longer reachable. PatientCallTest covers create/list/
delete, the outcome filter, the invalid-outcome fallback, and ownership scoping.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
54 lines
1.4 KiB
PHP
54 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Patient\Repository;
|
|
|
|
use App\Patient\Entity\PatientCall;
|
|
use App\Patient\Entity\PatientRecord;
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
use Doctrine\Persistence\ManagerRegistry;
|
|
|
|
class PatientCallRepository extends ServiceEntityRepository
|
|
{
|
|
public function __construct(ManagerRegistry $registry)
|
|
{
|
|
parent::__construct($registry, PatientCall::class);
|
|
}
|
|
|
|
public function findByUuid(string $uuid): ?PatientCall
|
|
{
|
|
return $this->findOneBy(['uuid' => $uuid]);
|
|
}
|
|
|
|
/**
|
|
* Newest-first call log for a record, optionally filtered by outcome.
|
|
*
|
|
* @return PatientCall[]
|
|
*/
|
|
public function findByRecord(PatientRecord $record, ?string $outcome = null): array
|
|
{
|
|
$qb = $this->createQueryBuilder('c')
|
|
->where('c.record = :record')
|
|
->setParameter('record', $record)
|
|
->orderBy('c.calledAt', 'DESC')
|
|
->addOrderBy('c.id', 'DESC');
|
|
|
|
if ($outcome !== null) {
|
|
$qb->andWhere('c.outcome = :outcome')->setParameter('outcome', $outcome);
|
|
}
|
|
|
|
return $qb->getQuery()->getResult();
|
|
}
|
|
|
|
public function save(PatientCall $c): void
|
|
{
|
|
$this->getEntityManager()->persist($c);
|
|
$this->getEntityManager()->flush();
|
|
}
|
|
|
|
public function remove(PatientCall $c): void
|
|
{
|
|
$this->getEntityManager()->remove($c);
|
|
$this->getEntityManager()->flush();
|
|
}
|
|
}
|