feat(appointment): add expires_at and patient fields to Appointment
Add a 15-minute payment TTL (expires_at) plus patient_name/mobile/ national_code/gender/reason columns so a booking can hold a slot temporarily and record a patient distinct from the paying user. New markPendingWithTtl() sets the lock; transitioning out of pending clears expires_at. All columns nullable (migration added). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -25,6 +25,8 @@ class Appointment
|
||||
public const STATUS_EXPIRED = 'expired';
|
||||
public const STATUS_NO_SHOW = 'no_show';
|
||||
|
||||
public const PAYMENT_TTL = 900; // 15 minutes to pay before a pending booking expires
|
||||
|
||||
public const ALLOWED_TRANSITIONS = [
|
||||
self::STATUS_PENDING => [self::STATUS_CONFIRMED, self::STATUS_CANCELLED_BY_DOCTOR, self::STATUS_CANCELLED_BY_USER, self::STATUS_EXPIRED],
|
||||
self::STATUS_CONFIRMED => [self::STATUS_COMPLETED, self::STATUS_CANCELLED_BY_DOCTOR, self::STATUS_CANCELLED_BY_USER, self::STATUS_NO_SHOW],
|
||||
@@ -63,6 +65,24 @@ class Appointment
|
||||
#[ORM\Column(type: 'string', length: 255, nullable: true)]
|
||||
private ?string $note = null;
|
||||
|
||||
#[ORM\Column(name: 'expires_at', type: 'integer', nullable: true)]
|
||||
private ?int $expiresAt = null;
|
||||
|
||||
#[ORM\Column(name: 'patient_name', type: 'string', length: 150, nullable: true)]
|
||||
private ?string $patientName = null;
|
||||
|
||||
#[ORM\Column(name: 'patient_mobile', type: 'string', length: 20, nullable: true)]
|
||||
private ?string $patientMobile = null;
|
||||
|
||||
#[ORM\Column(name: 'patient_national_code', type: 'string', length: 20, nullable: true)]
|
||||
private ?string $patientNationalCode = null;
|
||||
|
||||
#[ORM\Column(name: 'patient_gender', type: 'string', length: 10, nullable: true)]
|
||||
private ?string $patientGender = null;
|
||||
|
||||
#[ORM\Column(name: 'patient_reason', type: 'text', nullable: true)]
|
||||
private ?string $patientReason = null;
|
||||
|
||||
#[ORM\Column(name: 'created_at', type: 'integer')]
|
||||
private int $createdAt;
|
||||
|
||||
@@ -89,8 +109,26 @@ class Appointment
|
||||
public function getStatus(): string { return $this->status; }
|
||||
public function getNote(): ?string { return $this->note; }
|
||||
public function getVersion(): int { return $this->version; }
|
||||
public function getExpiresAt(): ?int { return $this->expiresAt; }
|
||||
public function getPatientName(): ?string { return $this->patientName; }
|
||||
public function getPatientMobile(): ?string { return $this->patientMobile; }
|
||||
public function getPatientNationalCode(): ?string { return $this->patientNationalCode; }
|
||||
public function getPatientGender(): ?string { return $this->patientGender; }
|
||||
public function getPatientReason(): ?string { return $this->patientReason; }
|
||||
|
||||
public function setNote(?string $v): self { $this->note = $v; return $this; }
|
||||
public function setPatientName(?string $v): self { $this->patientName = $v; return $this; }
|
||||
public function setPatientMobile(?string $v): self { $this->patientMobile = $v; return $this; }
|
||||
public function setPatientNationalCode(?string $v): self { $this->patientNationalCode = $v; return $this; }
|
||||
public function setPatientGender(?string $v): self { $this->patientGender = $v; return $this; }
|
||||
public function setPatientReason(?string $v): self { $this->patientReason = $v; return $this; }
|
||||
|
||||
public function markPendingWithTtl(int $ttl): self
|
||||
{
|
||||
$this->expiresAt = time() + $ttl;
|
||||
$this->updatedAt = time();
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function canTransitionTo(string $newStatus): bool
|
||||
{
|
||||
@@ -107,6 +145,9 @@ class Appointment
|
||||
}
|
||||
$this->status = $newStatus;
|
||||
$this->updatedAt = time();
|
||||
if ($newStatus !== self::STATUS_PENDING) {
|
||||
$this->expiresAt = null;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -126,6 +167,12 @@ class Appointment
|
||||
'slot_end' => $this->slotEnd,
|
||||
'status' => $this->status,
|
||||
'note' => $this->note,
|
||||
'expires_at' => $this->expiresAt,
|
||||
'patient_name' => $this->patientName,
|
||||
'patient_mobile' => $this->patientMobile,
|
||||
'patient_national_code' => $this->patientNationalCode,
|
||||
'patient_gender' => $this->patientGender,
|
||||
'patient_reason' => $this->patientReason,
|
||||
'version' => $this->version,
|
||||
'created_at' => $this->createdAt,
|
||||
'updated_at' => $this->updatedAt,
|
||||
|
||||
Reference in New Issue
Block a user