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
+52
View File
@@ -201,6 +201,58 @@ export interface Payment {
export type SettlementStatus = "pending" | "approved" | "rejected";
/** `mixed` فقط در نمای تجمیعی بیمار معنا دارد: مطالبات آن بیمار وضعیت یکسان ندارند. */
export type ClaimStatus = "pending" | "submitted" | "approved" | "rejected" | "paid" | "mixed";
export interface ClaimPatientRow {
patient_uuid: string;
record_uuid: string;
full_name: string | null;
mobile: string | null;
national_code: string | null;
claims_count: number;
total_services_rials: number;
total_insurance_rials: number;
total_patient_rials: number;
total_approved_rials: number;
total_paid_rials: number;
overall_status: ClaimStatus;
last_activity_at: number;
}
export interface ClaimStatusLogEntry {
uuid: string;
from_status: string | null;
to_status: string;
note: string | null;
by: string | null;
at: number;
}
export interface ClaimDetailRow {
uuid: string;
invoice_uuid: string | null;
visit_date: number | null;
doctor_name: string | null;
insurance_id: number;
insurance_name: string | null;
insurance_kind: "base" | "supplementary";
service_base_rials: number;
coverage_percent: number;
insurance_share_rials: number;
patient_share_rials: number;
total_approved_rials: number | null;
total_paid_rials: number | null;
status: ClaimStatus;
tracking_number: string | null;
reject_reason: string | null;
submitted_at: number | null;
settled_at: number | null;
created_at: number;
allowed_transitions: string[];
logs: ClaimStatusLogEntry[];
}
export interface Settlement {
uuid: string;
representation_name: string;