report
This commit is contained in:
parent
53da38c6f5
commit
6104f1735e
@ -3,6 +3,7 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Casts\Compressed;
|
use App\Casts\Compressed;
|
||||||
|
use App\Domain\Report\ReportStatus;
|
||||||
use Illuminate\Database\Eloquent\Concerns\HasTimestamps;
|
use Illuminate\Database\Eloquent\Concerns\HasTimestamps;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
@ -20,12 +21,38 @@ public function radiologist(): BelongsTo
|
|||||||
return $this->belongsTo(User::class, 'read_by_id');
|
return $this->belongsTo(User::class, 'read_by_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function updateStatus(ReportStatus $status, User|int|null $user = null): void
|
||||||
|
{
|
||||||
|
$user_id = me($user)->id;
|
||||||
|
$params = ['report_status' => $status->value, 'read_by_id' => $user_id];
|
||||||
|
$this->update($params);
|
||||||
|
|
||||||
|
$params = ['report_status' => $status->value];
|
||||||
|
switch ($status) {
|
||||||
|
case ReportStatus::Finalized:
|
||||||
|
$params['reporting_physician_id'] = $user_id;
|
||||||
|
$params['reported_at'] = now();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ReportStatus::Approved:
|
||||||
|
if ($this->study->reporting_physician_id === null) {
|
||||||
|
$params['reporting_physician_id'] = $user_id;
|
||||||
|
$params['reported_at'] = now();
|
||||||
|
}
|
||||||
|
$params['approving_physician_id'] = $user_id;
|
||||||
|
$params['approved_at'] = now();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$this->study->update($params);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array<string, string>
|
* @return array<string, string>
|
||||||
*/
|
*/
|
||||||
protected function casts(): array
|
protected function casts(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
'report_status' => ReportStatus::class,
|
||||||
'content' => Compressed::class,
|
'content' => Compressed::class,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user