Compare commits

..

No commits in common. "ef908dd4bd3f1b781f28f696db4ea2234a4e30c4" and "a7228b8a6151945fa134452bdc81c07827a8dbfa" have entirely different histories.

6 changed files with 6 additions and 20 deletions

View File

@ -627,7 +627,7 @@ private function generateActionButtons(Study $study): string
foreach (WorklistGuard::worklistButtons($study) as $button) { foreach (WorklistGuard::worklistButtons($study) as $button) {
switch ($button) { switch ($button) {
case WorklistButton::StudyMetadata: case WorklistButton::StudyMetadata:
$btns[] = $this->renderImageLink($study->hash, $study->hasHistory() ? 'info-green.png' : 'info.png', 'show-study', 'Info'); $btns[] = $this->renderImageLink($study->hash, 'info.png', 'show-study', 'Info');
break; break;
case WorklistButton::Assign: case WorklistButton::Assign:
$btns[] = $this->renderImageLink($study->hash, 'assign.png', 'show-assign', 'Assign'); $btns[] = $this->renderImageLink($study->hash, 'assign.png', 'show-assign', 'Assign');

View File

@ -9,13 +9,12 @@
use App\Models\StudyDetails; use App\Models\StudyDetails;
use App\Services\AuditTrail\Activity; use App\Services\AuditTrail\Activity;
use App\Services\SessionHelper; use App\Services\SessionHelper;
use Illuminate\Support\Facades\Cache;
class HistoryController extends HashidControllerBase class HistoryController extends HashidControllerBase
{ {
public function view() public function view()
{ {
abort_unless(may(Permission::StudyHistoryView), 403); abort_unless(auth()->user()->may(Permission::StudyHistoryView), 403);
$this->decodeKeys(); $this->decodeKeys();
$details = StudyDetails::historyOnly($this->key); $details = StudyDetails::historyOnly($this->key);
$study = Study::findOrFail($this->key); $study = Study::findOrFail($this->key);
@ -26,7 +25,7 @@ public function view()
public function edit() public function edit()
{ {
// SessionHelper::setIntendedUrl(); // SessionHelper::setIntendedUrl();
abort_unless(may(Permission::StudyHistoryEdit), 403); abort_unless(auth()->user()->may(Permission::StudyHistoryEdit), 403);
$this->decodeKeys(); $this->decodeKeys();
$details = StudyDetails::historyOnly($this->key); $details = StudyDetails::historyOnly($this->key);
$study = Study::findOrFail($this->key); $study = Study::findOrFail($this->key);
@ -36,13 +35,12 @@ public function edit()
public function save(StudyHistoryRequest $request) public function save(StudyHistoryRequest $request)
{ {
abort_unless(may(Permission::StudyHistoryEdit), 403); abort_unless(auth()->user()->may(Permission::StudyHistoryEdit), 403);
$this->decodeKeys(); $this->decodeKeys();
$details = StudyDetails::historyOnly($this->key); $details = StudyDetails::historyOnly($this->key);
$payload = array_trim_strings($request->validated()); $payload = array_trim_strings($request->validated());
unset($payload['study_id']); unset($payload['study_id']);
$details->update($payload); $details->update($payload);
Cache::forget("study.has_history.{$this->key}");
audit() audit()
->did(Activity::Study_History_Edit) ->did(Activity::Study_History_Edit)

View File

@ -12,13 +12,12 @@
use App\Services\Pacs\PacsUrlGen; use App\Services\Pacs\PacsUrlGen;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Concerns\HasTimestamps;
use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Support\Facades\Blade; use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Spatie\MediaLibrary\HasMedia; use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia; use Spatie\MediaLibrary\InteractsWithMedia;
@ -29,6 +28,7 @@ class Study extends BaseModel implements HasMedia
use HasDepartment; use HasDepartment;
use HashableId; use HashableId;
use HasOrganization; use HasOrganization;
use HasTimestamps;
use InteractsWithMedia; use InteractsWithMedia;
public const string MEDIA_COLLECTION = 'attachments'; public const string MEDIA_COLLECTION = 'attachments';
@ -543,16 +543,4 @@ protected function casts(): array
'patient_birthdate' => 'immutable_date', 'patient_birthdate' => 'immutable_date',
]; ];
} }
public function hasHistory(): bool
{
return Cache::remember("study.has_history.{$this->id}",
now()->addMinutes(15),
function () {
return DB::table('study_details')
->where('study_id', $this->id)
->whereNotNull('clinical_history')
->exists();
});
}
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 902 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 915 B