updates
This commit is contained in:
parent
3ba510a0b2
commit
64dfa4ac3d
25
app/Http/Requests/StudyHistoryRequest.php
Normal file
25
app/Http/Requests/StudyHistoryRequest.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class StudyHistoryRequest extends FormRequest
|
||||||
|
{
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'study_id' => ['required', 'exists:studies'],
|
||||||
|
'user_id' => ['required', 'exists:users'],
|
||||||
|
'clinical_history' => ['nullable'],
|
||||||
|
'surgical_history' => ['nullable'],
|
||||||
|
'lab_results' => ['nullable'],
|
||||||
|
'clinical_diagnosis' => ['nullable'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
10
app/Models/BaseModel.php
Normal file
10
app/Models/BaseModel.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
abstract class BaseModel extends Model
|
||||||
|
{
|
||||||
|
protected $guarded = ['id'];
|
||||||
|
}
|
@ -3,9 +3,8 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
class Institute extends Model
|
class Institute extends BaseModel
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
|
|
||||||
use App\Models\Enums\ReportStatus;
|
use App\Models\Enums\ReportStatus;
|
||||||
use App\Models\Enums\StudyLevelStatus;
|
use App\Models\Enums\StudyLevelStatus;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||||
|
|
||||||
class Study extends Model
|
class Study extends BaseModel
|
||||||
{
|
{
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'is_locked' => 'boolean',
|
'is_locked' => 'boolean',
|
||||||
@ -15,5 +15,8 @@ class Study extends Model
|
|||||||
'report_status' => ReportStatus::class,
|
'report_status' => ReportStatus::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $guarded = ['id'];
|
public function history(): HasOne
|
||||||
|
{
|
||||||
|
return $this->hasOne(StudyHistory::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,4 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
class StudyAttachment extends BaseModel {}
|
||||||
|
|
||||||
class StudyAttachment extends Model {}
|
|
||||||
|
@ -2,6 +2,4 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
class StudyDeleteRequest extends BaseModel {}
|
||||||
|
|
||||||
class StudyDeleteRequest extends Model {}
|
|
||||||
|
18
app/Models/StudyHistory.php
Normal file
18
app/Models/StudyHistory.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
|
class StudyHistory extends BaseModel
|
||||||
|
{
|
||||||
|
public function study(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Study::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function user(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class);
|
||||||
|
}
|
||||||
|
}
|
@ -2,10 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
class StudyReport extends Model
|
class StudyReport extends BaseModel
|
||||||
{
|
{
|
||||||
public function study(): BelongsTo
|
public function study(): BelongsTo
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,4 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
class Template extends BaseModel {}
|
||||||
|
|
||||||
class Template extends Model {}
|
|
||||||
|
@ -2,6 +2,4 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
class TemplateCategory extends BaseModel {}
|
||||||
|
|
||||||
class TemplateCategory extends Model {}
|
|
||||||
|
@ -12,6 +12,24 @@
|
|||||||
/** @psalm-type Int32BitMask = int<0, 2147483647> */
|
/** @psalm-type Int32BitMask = int<0, 2147483647> */
|
||||||
trait BitmaskFunctionality
|
trait BitmaskFunctionality
|
||||||
{
|
{
|
||||||
|
/** @param Int32BitMask $value */
|
||||||
|
public static function hasCase(int $value): bool
|
||||||
|
{
|
||||||
|
return self::tryFrom($value) !== null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return Int32BitMask */
|
||||||
|
public static function build(self ...$bits): int
|
||||||
|
{
|
||||||
|
return self::set(0, ...$bits);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return Int32BitMask */
|
||||||
|
public static function set(int $value, self ...$bits): int
|
||||||
|
{
|
||||||
|
return $value | self::mask(...$bits);
|
||||||
|
}
|
||||||
|
|
||||||
/** @return Int32BitMask */
|
/** @return Int32BitMask */
|
||||||
public static function mask(self ...$bits): int
|
public static function mask(self ...$bits): int
|
||||||
{
|
{
|
||||||
@ -22,39 +40,6 @@ public static function mask(self ...$bits): int
|
|||||||
return array_reduce($bits, static fn (?int $sum, self $case) => ($sum ?? 0) | $case->value);
|
return array_reduce($bits, static fn (?int $sum, self $case) => ($sum ?? 0) | $case->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param Int32BitMask $value */
|
|
||||||
public static function hasCase(int $value): bool
|
|
||||||
{
|
|
||||||
return self::tryFrom($value) !== null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @param Int32BitMask $value */
|
|
||||||
public static function valueToString(int $value): string
|
|
||||||
{
|
|
||||||
return '0b'.substr(chunk_split(sprintf('%\'032b', $value), 4, '_'), 0, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function toString(): string
|
|
||||||
{
|
|
||||||
return self::valueToString($this->value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @return Int32BitMask */
|
|
||||||
public static function build(self ...$bits): int
|
|
||||||
{
|
|
||||||
return self::set(0, ...$bits);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @param Int32BitMask $value */
|
|
||||||
|
|
||||||
/** @return Int32BitMask */
|
|
||||||
public static function set(int $value, self ...$bits): int
|
|
||||||
{
|
|
||||||
return $value | self::mask(...$bits);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @param Int32BitMask $value */
|
|
||||||
|
|
||||||
/** @return Int32BitMask */
|
/** @return Int32BitMask */
|
||||||
public static function clear(int $value, self ...$bits): int
|
public static function clear(int $value, self ...$bits): int
|
||||||
{
|
{
|
||||||
@ -70,10 +55,6 @@ public static function toggle(int $value, self ...$bits): int
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @param Int32BitMask $value */
|
/** @param Int32BitMask $value */
|
||||||
public static function on(int $value, self $bit): bool
|
|
||||||
{
|
|
||||||
return ($value & $bit->value) === $bit->value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @param Int32BitMask $value */
|
/** @param Int32BitMask $value */
|
||||||
public static function off(int $value, self $bit): bool
|
public static function off(int $value, self $bit): bool
|
||||||
@ -81,6 +62,8 @@ public static function off(int $value, self $bit): bool
|
|||||||
return ($value & $bit->value) === 0;
|
return ($value & $bit->value) === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @param Int32BitMask $value */
|
||||||
|
|
||||||
/** @param Int32BitMask $value */
|
/** @param Int32BitMask $value */
|
||||||
public static function any(int $value, self ...$bits): bool
|
public static function any(int $value, self ...$bits): bool
|
||||||
{
|
{
|
||||||
@ -123,4 +106,21 @@ public static function parse(int $value): array
|
|||||||
{
|
{
|
||||||
return array_filter(self::cases(), static fn (self $case) => self::on($value, $case));
|
return array_filter(self::cases(), static fn (self $case) => self::on($value, $case));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @param Int32BitMask $value */
|
||||||
|
public static function on(int $value, self $bit): bool
|
||||||
|
{
|
||||||
|
return ($value & $bit->value) === $bit->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toString(): string
|
||||||
|
{
|
||||||
|
return self::valueToString($this->value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @param Int32BitMask $value */
|
||||||
|
public static function valueToString(int $value): string
|
||||||
|
{
|
||||||
|
return '0b'.substr(chunk_split(sprintf('%\'032b', $value), 4, '_'), 0, -1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||||
|
use Database\Factories\UserFactory;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
@ -15,7 +16,7 @@ class User extends Authenticatable
|
|||||||
{
|
{
|
||||||
use HasApiTokens;
|
use HasApiTokens;
|
||||||
|
|
||||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
/** @use HasFactory<UserFactory> */
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
use HasProfilePhoto;
|
use HasProfilePhoto;
|
||||||
|
2
composer.lock
generated
2
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "3007185579b2e8489eae9546920efd9e",
|
"content-hash": "f59da96d435c5fdc613f4228c47309af",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "bacon/bacon-qr-code",
|
"name": "bacon/bacon-qr-code",
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('study_histories', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('study_id')->index()->constrained('studies')->cascadeOnDelete();
|
||||||
|
$table->foreignId('user_id')->constrained('users');
|
||||||
|
$table->text('clinical_history')->nullable();
|
||||||
|
$table->text('surgical_history')->nullable();
|
||||||
|
$table->text('lab_results')->nullable();
|
||||||
|
$table->text('clinical_diagnosis')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('study_histories');
|
||||||
|
}
|
||||||
|
};
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "radsparc",
|
"name": "html",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
|
Loading…
Reference in New Issue
Block a user