feat(patients): phase B4 — messages (پیام‌ها)

Add a patient message/communication log: a new PatientMessage entity
(record-scoped, CASCADE) + repository, and owner-scoped endpoints
(GET messages, POST message, DELETE message) with a validated channel
(sms/note/call/email). Wire the "پیام‌ها" tab in PatientDetailPage
(send box + list + delete). PHPUnit covers create/list/delete + ownership
+ validation; Vitest covers the tab. API docs updated.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
hamed
2026-07-13 15:35:10 +03:30
co-authored by Claude Opus 4.8
parent 976c4f0c0a
commit 5fb4c52246
8 changed files with 358 additions and 1 deletions
+59
View File
@@ -0,0 +1,59 @@
<?php
namespace App\Patient\Entity;
use App\Patient\Repository\PatientMessageRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\Uuid;
/** A logged message/communication with a patient (the «پیام‌ها» tab). */
#[ORM\Entity(repositoryClass: PatientMessageRepository::class)]
#[ORM\Table(name: 'patient_messages')]
#[ORM\Index(columns: ['record_id'], name: 'idx_patient_messages_record')]
class PatientMessage
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private ?int $id = null;
#[ORM\Column(type: 'string', length: 36, unique: true)]
private string $uuid;
#[ORM\ManyToOne(targetEntity: PatientRecord::class)]
#[ORM\JoinColumn(name: 'record_id', nullable: false, onDelete: 'CASCADE')]
private PatientRecord $record;
#[ORM\Column(type: 'text')]
private string $body;
/** Channel: sms | note | call | email … */
#[ORM\Column(type: 'string', length: 20)]
private string $channel = 'sms';
#[ORM\Column(name: 'created_at', type: 'integer')]
private int $createdAt;
public function __construct(PatientRecord $record, string $body, string $channel = 'sms')
{
$this->uuid = Uuid::v4()->toRfc4122();
$this->record = $record;
$this->body = $body;
$this->channel = $channel;
$this->createdAt = time();
}
public function getId(): ?int { return $this->id; }
public function getUuid(): string { return $this->uuid; }
public function getRecord(): PatientRecord { return $this->record; }
public function toArray(): array
{
return [
'uuid' => $this->uuid,
'body' => $this->body,
'channel' => $this->channel,
'created_at' => $this->createdAt,
];
}
}