feat(patient): add SessionAuditLog entity for financial/service change trail

New SessionAuditLog (mirrors AppointmentEvent): session FK, field, operation
(create/update/delete), old_value/new_value, actor id+name, note, created_at.
Repository saves and lists a session's history (newest first, array hydration).
Migration creates the table.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
hamed
2026-07-17 15:06:25 +03:30
co-authored by Claude Fable 5
parent 0d943d8fc5
commit d8c8ba0df7
3 changed files with 149 additions and 0 deletions
@@ -0,0 +1,31 @@
<?php
namespace App\Patient\Repository;
use App\Patient\Entity\SessionAuditLog;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
class SessionAuditLogRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry) { parent::__construct($registry, SessionAuditLog::class); }
public function save(SessionAuditLog $e, bool $flush = true): void
{
$this->getEntityManager()->persist($e);
if ($flush) {
$this->getEntityManager()->flush();
}
}
/** تاریخچه‌ی یک مراجعه (جدید → قدیم)، آرایه‌ای. */
public function findBySessionUuid(string $sessionUuid): array
{
return $this->createQueryBuilder('l')
->select('l.field AS field', 'l.operation AS operation', 'l.oldValue AS old_value', 'l.newValue AS new_value', 'l.actorName AS actor_name', 'l.note AS note', 'l.createdAt AS created_at')
->join('l.session', 's')
->where('s.uuid = :uuid')->setParameter('uuid', $sessionUuid)
->orderBy('l.createdAt', 'DESC')->addOrderBy('l.id', 'DESC')
->getQuery()->getArrayResult();
}
}