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
+41
View File
@@ -66,6 +66,10 @@ class Claim
#[ORM\Column(name: 'reject_reason', type: 'text', nullable: true)]
private ?string $rejectReason = null;
/** شماره پرونده/پیگیری نزد بیمه‌گر — هنگام ارسال وارد می‌شود. */
#[ORM\Column(name: 'tracking_number', type: 'string', length: 60, nullable: true)]
private ?string $trackingNumber = null;
#[ORM\Column(name: 'submitted_at', type: 'integer', nullable: true)]
private ?int $submittedAt = null;
@@ -119,6 +123,41 @@ class Claim
return in_array($status, self::TRANSITIONS[$this->status] ?? [], true);
}
/**
* انتقال‌های مجاز از وضعیت فعلی. پنل دکمه‌ها را از همین می‌سازد تا فهرست
* مجاز فقط یک‌جا تعریف شده باشد.
*
* @return string[]
*/
public function allowedTransitions(): array
{
return self::transitionsFrom($this->status);
}
/**
* همان جدول انتقال، برای مسیرهایی که ردیف خام (array hydration) دارند و
* موجودیت را هیدریت نمی‌کنند.
*
* @return string[]
*/
public static function transitionsFrom(string $status): array
{
return self::TRANSITIONS[$status] ?? [];
}
public function getTrackingNumber(): ?string { return $this->trackingNumber; }
public function getRejectReason(): ?string { return $this->rejectReason; }
public function getSubmittedAt(): ?int { return $this->submittedAt; }
public function getSettledAt(): ?int { return $this->settledAt; }
public function getCreatedAt(): int { return $this->createdAt; }
public function setTrackingNumber(?string $v): self
{
$this->trackingNumber = $v !== null && trim($v) !== '' ? trim($v) : null;
$this->updatedAt = time();
return $this;
}
public function submit(): void
{
$this->status = self::STATUS_SUBMITTED;
@@ -162,6 +201,8 @@ class Claim
'total_paid_rials' => $this->totalPaidRials,
'status' => $this->status,
'reject_reason' => $this->rejectReason,
'tracking_number' => $this->trackingNumber,
'allowed_transitions' => $this->allowedTransitions(),
'submitted_at' => $this->submittedAt,
'settled_at' => $this->settledAt,
'created_at' => $this->createdAt,