- 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.
52 lines
1.4 KiB
PHP
52 lines
1.4 KiB
PHP
<?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();
|
|
}
|
|
}
|
|
}
|