feat(claims): add tracking number and status history for claims

- Introduced `tracking_number` field in the `claims` table to store the insurance tracking number.
- Created `claim_status_logs` table to maintain a history of status changes for claims, including who made the change and when.
- Implemented `ClaimStatusLog` entity and repository for managing status log entries.
- Updated `ClaimService` to log transitions and handle tracking numbers during claim submissions.
- Added new API endpoint for fetching claims by patient, including detailed claim history and status logs.
- Enhanced frontend with a new `ClaimPatientDetailPage` to display claims and their status history.
- Added tests to ensure correct aggregation of claims and proper handling of status transitions.
This commit is contained in:
hamed
2026-07-18 23:38:02 +03:30
parent b3a5cda808
commit 20bdc49e89
15 changed files with 1412 additions and 309 deletions
@@ -0,0 +1,51 @@
<?php
namespace App\Billing\Repository;
use App\Billing\Entity\ClaimStatusLog;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
class ClaimStatusLogRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, ClaimStatusLog::class);
}
/**
* تاریخچه‌ی چند مطالبه در یک رفت‌وآمد، گروه‌بندی‌شده بر اساس claim_id.
*
* @param int[] $claimIds
* @return array<int, array<int, array<string, mixed>>>
*/
public function timelinesForClaims(array $claimIds): array
{
if ($claimIds === []) {
return [];
}
$logs = $this->createQueryBuilder('l')
->where('l.claimId IN (:ids)')
->setParameter('ids', $claimIds)
->orderBy('l.createdAt', 'ASC')
->addOrderBy('l.id', 'ASC')
->getQuery()
->getResult();
$grouped = [];
foreach ($logs as $log) {
$grouped[$log->getClaimId()][] = $log->toArray();
}
return $grouped;
}
public function save(ClaimStatusLog $entity, bool $flush = true): void
{
$this->getEntityManager()->persist($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
}