This commit is contained in:
Dr Masroor Ehsan 2024-12-31 09:45:16 +06:00
parent 6ba22397a4
commit a20ff58614
4 changed files with 23 additions and 15 deletions

View File

@ -9,12 +9,19 @@
class Study extends BaseModel class Study extends BaseModel
{ {
protected $casts = [ protected function casts(): array
{
return [
'is_locked' => 'boolean', 'is_locked' => 'boolean',
'is_archived' => 'boolean', 'is_archived' => 'boolean',
'study_status' => StudyLevelStatus::class, 'study_status' => StudyLevelStatus::class,
'report_status' => ReportStatus::class, 'report_status' => ReportStatus::class,
'received_at' => 'datetime',
'reported_at' => 'datetime',
'assigned_at' => 'datetime',
'study_date' => 'datetime',
]; ];
}
public function details(): HasOne public function details(): HasOne
{ {

View File

@ -114,7 +114,7 @@ private function prepareData(mixed $orthanc_src): array
'body_part_examined' => data_get($orthanc_src, 'RequestedTags.BodyPartExamined'), 'body_part_examined' => data_get($orthanc_src, 'RequestedTags.BodyPartExamined'),
'study_date' => DicomUtils::dateTimeToCarbon($orthanc_src['MainDicomTags']['StudyDate'], $orthanc_src['MainDicomTags']['StudyTime']), 'study_date' => DicomUtils::dateTimeToCarbon($orthanc_src['MainDicomTags']['StudyDate'], $orthanc_src['MainDicomTags']['StudyTime']),
'receive_date' => Carbon::parse($orthanc_src['LastUpdate'], 'UTC'), 'received_at' => Carbon::parse($orthanc_src['LastUpdate'], 'UTC'),
'image_count' => data_get($orthanc_src, 'Statistics.CountInstances'), 'image_count' => data_get($orthanc_src, 'Statistics.CountInstances'),
'series_count' => data_get($orthanc_src, 'Statistics.CountSeries'), 'series_count' => data_get($orthanc_src, 'Statistics.CountSeries'),
@ -175,7 +175,7 @@ private function prepareData(mixed $orthanc_src): array
$params = [ $params = [
'orthanc_uuid' => strtolower($ser['ID']), 'orthanc_uuid' => strtolower($ser['ID']),
'series_instance_uid' => data_get($ser, 'MainDicomTags.SeriesInstanceUID'), 'series_instance_uid' => data_get($ser, 'MainDicomTags.SeriesInstanceUID'),
'series_date' => DicomUtils::dateTimeToCarbon($ser['MainDicomTags']['SeriesDate'], $ser['MainDicomTags']['SeriesTime']), 'series_date' => DicomUtils::dateTimeToCarbon(data_get($ser, 'MainDicomTags.SeriesDate'), data_get($ser, 'MainDicomTags.SeriesTime')),
'series_number' => data_get($ser, 'MainDicomTags.SeriesNumber'), 'series_number' => data_get($ser, 'MainDicomTags.SeriesNumber'),
'series_description' => data_get($ser, 'MainDicomTags.SeriesDescription'), 'series_description' => data_get($ser, 'MainDicomTags.SeriesDescription'),
'protocol_name' => data_get($ser, 'MainDicomTags.ProtocolName'), 'protocol_name' => data_get($ser, 'MainDicomTags.ProtocolName'),
@ -193,6 +193,9 @@ private function prepareData(mixed $orthanc_src): array
if (empty($series)) { if (empty($series)) {
$series = null; $series = null;
} else {
// $series = array_multisort(array_column($series, 'series_number'), SORT_ASC, $series);
usort($series, fn ($a, $b): int => (int) $a['series_number'] <=> (int) $b['series_number']);
} }
if (empty($properties)) { if (empty($properties)) {
$properties = null; $properties = null;

View File

@ -34,8 +34,10 @@ public function up(): void
$table->string('referring_physician_name')->nullable(); $table->string('referring_physician_name')->nullable();
$table->string('study_modality', 4)->nullable(); $table->string('study_modality', 4)->nullable();
$table->dateTime('study_date'); $table->dateTime('study_date');
$table->dateTime('receive_date');
$table->dateTime('report_date')->nullable(); $table->dateTime('received_at');
$table->dateTime('reported_at')->nullable();
$table->dateTime('assigned_at')->nullable();
$table->foreignIdFor(Institute::class)->constrained()->onDelete('cascade'); $table->foreignIdFor(Institute::class)->constrained()->onDelete('cascade');
$table->unsignedTinyInteger('study_status')->default(StudyLevelStatus::Pending->value); $table->unsignedTinyInteger('study_status')->default(StudyLevelStatus::Pending->value);
$table->unsignedTinyInteger('report_status')->default(ReportStatus::Pending->value); $table->unsignedTinyInteger('report_status')->default(ReportStatus::Pending->value);
@ -50,11 +52,6 @@ public function up(): void
$table->foreignIdFor(User::class, 'reading_physician_id')->nullable()->constrained()->onDelete('set null'); $table->foreignIdFor(User::class, 'reading_physician_id')->nullable()->constrained()->onDelete('set null');
$table->timestamps(); $table->timestamps();
$table->index(['referring_physician_id', 'receive_date']);
$table->index(['institute_id', 'receive_date', 'is_archived']);
$table->index(['institute_id', 'report_status', 'study_priority', 'receive_date']);
$table->index(['assigned_physician_id', 'report_status', 'study_priority', 'receive_date']);
}); });
} }

View File

@ -18,6 +18,7 @@ public function up(): void
$table->text('clinical_diagnosis')->nullable(); $table->text('clinical_diagnosis')->nullable();
$table->jsonb('properties')->nullable(); $table->jsonb('properties')->nullable();
$table->jsonb('series')->nullable(); $table->jsonb('series')->nullable();
$table->jsonb('assignment_log')->nullable();
$table->timestamps(); $table->timestamps();
}); });
} }