Merge remote-tracking branch 'origin/staging' into origin/production
This commit is contained in:
@@ -29,11 +29,19 @@ class Claim extends Model
|
||||
'currency',
|
||||
'plan_id',
|
||||
'benefit_id',
|
||||
'organization_id',
|
||||
'status',
|
||||
'service_code',
|
||||
'benefit_code',
|
||||
'benefit_desc',
|
||||
'amount_incurred',
|
||||
'amount_approved',
|
||||
'amount_not_approved',
|
||||
'excess_paid',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
// 'created_at',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
'created_by',
|
||||
@@ -195,6 +203,11 @@ class Claim extends Model
|
||||
return $this->belongsTo(Member::class, 'member_id');
|
||||
}
|
||||
|
||||
public function organization()
|
||||
{
|
||||
return $this->belongsTo(Organization::class, 'organization_id');
|
||||
}
|
||||
|
||||
public function encounters()
|
||||
{
|
||||
return $this->belongsToMany(Encounter::class, 'claim_encounter');
|
||||
@@ -251,5 +264,11 @@ class Claim extends Model
|
||||
{
|
||||
return $this->items->sum('nominal_ditagihkan');
|
||||
}
|
||||
|
||||
public function historyHospitalCare()
|
||||
{
|
||||
return $this->hasMany(ClaimHistoryCare::class, 'claim_id');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
12
app/Models/ClaimEncounter.php
Normal file
12
app/Models/ClaimEncounter.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ClaimEncounter extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'claim_encounter';
|
||||
}
|
||||
60
app/Models/ClaimHistoryCare.php
Normal file
60
app/Models/ClaimHistoryCare.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ClaimHistoryCare extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $fillable = [
|
||||
'service_code',
|
||||
'admission_date',
|
||||
'discharge_date',
|
||||
'claim_id',
|
||||
'organization_id',
|
||||
'practitioner_id',
|
||||
'medical_record_number',
|
||||
'symptoms',
|
||||
'sign',
|
||||
'main_diagnosis_id',
|
||||
'status'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function organization()
|
||||
{
|
||||
return $this->belongsTo(Organization::class, 'organization_id');
|
||||
}
|
||||
|
||||
public function practitioner()
|
||||
{
|
||||
return $this->belongsTo(Practitioner::class, 'practitioner_id');
|
||||
}
|
||||
|
||||
public function icd()
|
||||
{
|
||||
return $this->belongsTo(Icd::class, 'main_diagnosis_id');
|
||||
}
|
||||
|
||||
public function claim()
|
||||
{
|
||||
return $this->hasOne(Claim::class, 'claim_id');
|
||||
}
|
||||
|
||||
public function person()
|
||||
{
|
||||
return $this->belongsTo(Person::class, 'practitioner_id');
|
||||
}
|
||||
|
||||
public function comparativeDiagnosis()
|
||||
{
|
||||
return $this->hasMany(DiagnosisSecondaryClaimHistoryCare::class, 'claim_history_care_id');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,6 +25,11 @@ class ClaimItem extends Model
|
||||
return $this->belongsTo(Claim::class, 'claim_id');
|
||||
}
|
||||
|
||||
public function benefit()
|
||||
{
|
||||
return $this->belongsTo(Benefit::class, 'claim_itemable_id');
|
||||
}
|
||||
|
||||
public function claim_itemable()
|
||||
{
|
||||
return $this->morphTo();
|
||||
|
||||
@@ -14,7 +14,8 @@ class ClaimRequest extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes, Blameable;
|
||||
|
||||
protected static $code_prefix = 'CRQ';
|
||||
// protected static $code_prefix_hospital = 'CRQ-H';
|
||||
// protected static $code_prefix_client = 'CRQ-R';
|
||||
|
||||
public $fillable = [
|
||||
'uuid',
|
||||
@@ -24,7 +25,10 @@ class ClaimRequest extends Model
|
||||
'service_code',
|
||||
'policy_id',
|
||||
'status',
|
||||
'claim_id'
|
||||
'claim_id',
|
||||
'organization_id',
|
||||
'code',
|
||||
'request_log_id'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
@@ -36,6 +40,73 @@ class ClaimRequest extends Model
|
||||
'deleted_by',
|
||||
];
|
||||
|
||||
public static $doc_headers_to_field_map = [
|
||||
"PAYOR ID" => "payor_id",
|
||||
"CORPORATE ID" => "corporate_id",
|
||||
"POLICY NUMBER" => "policy_number",
|
||||
"MEMBER ID" => "member_id",
|
||||
"MEMBER NAME" => "member_name",
|
||||
"RECORD TYPE (P/D)" => "record_type",
|
||||
"BENEFIT CODE" => "benefit_code",
|
||||
"BENEFIT DESC" => "benefit_desc",
|
||||
"CLAIM TYPE" => "claim_type",
|
||||
"CLAIM PROCESS STATUS" => "status",
|
||||
"CLIENT CLAIM ID" => "client_claim_id",
|
||||
"REFERENCE NO" => "reference_no",
|
||||
"ADMEDIKA CLAIM ID" => "admika_claim_id",
|
||||
"PROVIDER CODE" => "provider_code",
|
||||
"ADMISSION DATE" => "admission_date",
|
||||
"DISCUTRGE DATE" => "discutrge_date",
|
||||
"DURATION DAYS" => "duration_days",
|
||||
"COVERAGE TYPE" => "coverage_type",
|
||||
"PLAN ID" => "plan_id",
|
||||
"DIAGNOSIS CODE" => "diagnosis_code",
|
||||
"DIAGNOSIS DESC" => "diagnosis_desc",
|
||||
"TOT AMT INCURRED" => "tot_amt_insurred",
|
||||
"TOT AMT APPROVED" => "tot_amt_approved",
|
||||
"TOT AMT NOT APPROVED" => "tot_amt_not_approved",
|
||||
"TOT EXCESS PAID" => "tot_excess_paid",
|
||||
"REMARKS" => "remarks",
|
||||
"SECONDARY DIAGNOSIS CODE" => "secondary_diagnosis",
|
||||
"APPROVED DATE" => "approved_date",
|
||||
"APPROVED BY" => "approved_by",
|
||||
"DATE RECEIVED" => "data_received",
|
||||
"HOSPITAL INVOICE DATE" => "hospital_invoice_date",
|
||||
];
|
||||
|
||||
public static $listing_doc_headers = [
|
||||
"PAYOR ID",
|
||||
"CORPORATE ID",
|
||||
"POLICY NUMBER",
|
||||
"MEMBER ID",
|
||||
"MEMBER NAME",
|
||||
"RECORD TYPE (P/D)",
|
||||
"CLAIM TYPE",
|
||||
"CLAIM PROCESS STATUS",
|
||||
"CLIENT CLAIM ID",
|
||||
"REFERENCE NO",
|
||||
"ADMEDIKA CLAIM ID",
|
||||
"PROVIDER CODE",
|
||||
"ADMISSION DATE",
|
||||
"DISCUTRGE DATE",
|
||||
"DURATION DAYS",
|
||||
"COVERAGE TYPE",
|
||||
"PLAN ID",
|
||||
"DIAGNOSIS CODE",
|
||||
"DIAGNOSIS DESC",
|
||||
"TOT AMT INCURRED",
|
||||
"TOT AMT APPROVED",
|
||||
"TOT AMT NOT APPROVED",
|
||||
"TOT EXCESS PAID",
|
||||
"REMARKS",
|
||||
"SECONDARY DIAGNOSIS CODE",
|
||||
"APPROVED DATE",
|
||||
"APPROVED BY",
|
||||
"DATE RECEIVED",
|
||||
"HOSPITAL INVOICE DATE",
|
||||
];
|
||||
|
||||
|
||||
public static $status = [
|
||||
'draft' => 'Draft',
|
||||
'requested' => 'Requested',
|
||||
@@ -59,7 +130,7 @@ class ClaimRequest extends Model
|
||||
static::creating(function ($model) {
|
||||
try {
|
||||
$model->uuid = (string) Str::orderedUuid(); // generate uuid
|
||||
$model->code = self::getNextCode();
|
||||
// $model->code = self::getNextCode();
|
||||
} catch (\Exception $e) {
|
||||
abort(500, $e->getMessage());
|
||||
}
|
||||
@@ -112,19 +183,19 @@ class ClaimRequest extends Model
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static function getNextCode()
|
||||
{
|
||||
$last_number = self::withTrashed()->max('code');
|
||||
$next_number = empty($last_number) ? 1 : ((int) explode('-', $last_number)[1] + 1);
|
||||
|
||||
return self::makeCode($next_number);
|
||||
}
|
||||
// public static function getNextCode()
|
||||
// {
|
||||
// $last_number = self::withTrashed()->max('code');
|
||||
// $next_number = empty($last_number) ? 1 : ((int) explode('-', $last_number)[1] + 1);
|
||||
|
||||
public static function makeCode($next_number)
|
||||
{
|
||||
return (string) self::$code_prefix .'-'. str_pad($next_number, 5, 0, STR_PAD_LEFT);
|
||||
}
|
||||
// return self::makeCode($next_number);
|
||||
// }
|
||||
|
||||
// public static function makeCode($next_number)
|
||||
// {
|
||||
// return (string) self::$code_prefix .'-'. str_pad($next_number, 5, 0, STR_PAD_LEFT);
|
||||
// }
|
||||
|
||||
public function claim()
|
||||
{
|
||||
@@ -141,6 +212,21 @@ class ClaimRequest extends Model
|
||||
return $this->morphMany(File::class, 'fileable');
|
||||
}
|
||||
|
||||
public function claimResults()
|
||||
{
|
||||
return $this->files()->where('type', 'claim-result')->whereNull('deleted_at');
|
||||
}
|
||||
|
||||
public function claimConditions()
|
||||
{
|
||||
return $this->files()->where('type', 'claim-kondisi')->whereNull('deleted_at');
|
||||
}
|
||||
|
||||
public function claimDiagnosis()
|
||||
{
|
||||
return $this->files()->where('type', 'claim-diagnosis')->whereNull('deleted_at');
|
||||
}
|
||||
|
||||
public function generatedDocuments()
|
||||
{
|
||||
return $this->morphMany(GeneratedDocument::class, 'generated_documentable');
|
||||
@@ -151,6 +237,11 @@ class ClaimRequest extends Model
|
||||
return $this->morphMany(ClaimHistory::class, 'historiable');
|
||||
}
|
||||
|
||||
public function organization()
|
||||
{
|
||||
return $this->belongsTo(Organization::class, 'organization_id');
|
||||
}
|
||||
|
||||
public function member()
|
||||
{
|
||||
return $this->belongsTo(Member::class, 'member_id', 'id');
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Traits\Blameable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Altek\Accountant\Contracts\Recordable;
|
||||
|
||||
class CorporateFormularium extends Model
|
||||
{
|
||||
@@ -15,7 +16,8 @@ class CorporateFormularium extends Model
|
||||
|
||||
protected $fillable = [
|
||||
'corporate_id',
|
||||
'formularium_id'
|
||||
'formularium_template_id',
|
||||
'active'
|
||||
];
|
||||
|
||||
public function corporate()
|
||||
@@ -23,8 +25,8 @@ class CorporateFormularium extends Model
|
||||
return $this->belongsTo(Corporate::class);
|
||||
}
|
||||
|
||||
public function formularium()
|
||||
public function formularium_template()
|
||||
{
|
||||
return $this->belongsTo(Formularium::class);
|
||||
return $this->belongsTo(FormulariumTemplate::class);
|
||||
}
|
||||
}
|
||||
|
||||
36
app/Models/CorporateHospital.php
Normal file
36
app/Models/CorporateHospital.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Blameable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class CorporateHospital extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes, Blameable;
|
||||
|
||||
protected $fillable = [
|
||||
'corporate_id',
|
||||
'organization_id',
|
||||
'code',
|
||||
'name',
|
||||
'description',
|
||||
'active',
|
||||
];
|
||||
|
||||
public function corporate()
|
||||
{
|
||||
return $this->belongsTo(Corporate::class);
|
||||
}
|
||||
|
||||
public function scopeFilter($query, array $filters)
|
||||
{
|
||||
$query->when($filters['search'] ?? false, function ($query, $search) {
|
||||
return $query
|
||||
->where('code', 'like', "%" . $search . "%")
|
||||
->orWhere('name', 'like', "%" . $search . "%");
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -11,4 +11,19 @@ class CorporateManager extends Model
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $table = 'corporate_manager';
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'corporate_id'
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->hasOne(User::class, 'id', 'user_id');
|
||||
}
|
||||
|
||||
public function corporate()
|
||||
{
|
||||
return $this->hasOne(Corporate::class, 'id', 'corporate_id');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,10 @@ class CorporatePlan extends Model
|
||||
'code',
|
||||
'name',
|
||||
'description',
|
||||
'corporate_plan_id',
|
||||
'service_code',
|
||||
'type',
|
||||
'limit_rules',
|
||||
'active',
|
||||
'reason'
|
||||
];
|
||||
|
||||
61
app/Models/DailyMonitoring.php
Normal file
61
app/Models/DailyMonitoring.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use DB;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DailyMonitoring extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = "claim_daily_monitoring";
|
||||
|
||||
protected $fillable = [
|
||||
'claim_id',
|
||||
'subject',
|
||||
'body_temperature',
|
||||
'respiration_rate',
|
||||
'sistole',
|
||||
'diastole',
|
||||
'analysis',
|
||||
'complaints'
|
||||
];
|
||||
|
||||
protected $appends = ['medical_plan'];
|
||||
|
||||
public function getBodyTemperatureAttribute()
|
||||
{
|
||||
return round($this->attributes['body_temperature'], 0);
|
||||
}
|
||||
|
||||
public function getSistoleAttribute()
|
||||
{
|
||||
return round($this->attributes['sistole'], 0);
|
||||
}
|
||||
|
||||
public function getDiastoleAttribute()
|
||||
{
|
||||
return round($this->attributes['diastole'], 0);
|
||||
}
|
||||
|
||||
public function getRespirationRateAttribute()
|
||||
{
|
||||
return round($this->attributes['respiration_rate'], 0);
|
||||
}
|
||||
|
||||
public function getMedicalPlanAttribute()
|
||||
{
|
||||
$arr_medical_plan = [];
|
||||
$medical_plan = DB::table('medical_plan')->where('claim_daily_monitoring_id','=',$this->attributes['id'])->get();
|
||||
|
||||
foreach ($medical_plan as $row) {
|
||||
$arr_medical_plan[] = [
|
||||
'medical_plan_str' => $row->plan
|
||||
];
|
||||
}
|
||||
|
||||
return $arr_medical_plan;
|
||||
}
|
||||
}
|
||||
28
app/Models/DiagnosisSecondaryClaimHistoryCare.php
Normal file
28
app/Models/DiagnosisSecondaryClaimHistoryCare.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DiagnosisSecondaryClaimHistoryCare extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'diagnosis_secondary_claim_history_care';
|
||||
|
||||
protected $fillable = [
|
||||
'claim_history_care_id',
|
||||
'icd_id',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function icd()
|
||||
{
|
||||
return $this->belongsTo(Icd::class, 'icd_id');
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,8 @@ class Drug extends Model
|
||||
'dosage',
|
||||
'remark',
|
||||
'selling_unit_id',
|
||||
'status'
|
||||
'status',
|
||||
'active',
|
||||
];
|
||||
|
||||
public function categories()
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Traits\Blameable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Altek\Accountant\Contracts\Recordable;
|
||||
|
||||
class Exclusion extends Model
|
||||
{
|
||||
@@ -17,6 +18,8 @@ class Exclusion extends Model
|
||||
'type',
|
||||
'exclusionable_id',
|
||||
'exclusionable_type',
|
||||
'active',
|
||||
'reason'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
|
||||
24
app/Models/ExclusionImport.php
Normal file
24
app/Models/ExclusionImport.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Altek\Accountant\Contracts\Recordable;
|
||||
|
||||
class ExclusionImport extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'corporate_id',
|
||||
'file_name',
|
||||
'file_path',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Traits\Blameable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Altek\Accountant\Contracts\Recordable;
|
||||
|
||||
class ExclusionRules extends Model
|
||||
{
|
||||
|
||||
@@ -19,6 +19,8 @@ class File extends Model
|
||||
'original_name',
|
||||
'extension',
|
||||
'path',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
@@ -43,6 +45,12 @@ class File extends Model
|
||||
'claim-result' => 'claim/',
|
||||
'claim-diagnosis' => 'claim/',
|
||||
'claim-kondisi' => 'claim/',
|
||||
'claim-invoice' => 'claim/',
|
||||
'final-log-result' => 'final-log/',
|
||||
'final-log-diagnosis' => 'final-log/',
|
||||
'final-log-kondisi' => 'final-log/',
|
||||
'docs' => 'docs/',
|
||||
'additional-files' => 'additional-files/',
|
||||
];
|
||||
|
||||
public function fileable()
|
||||
@@ -52,7 +60,7 @@ class File extends Model
|
||||
|
||||
public static function getDirectory($type)
|
||||
{
|
||||
return self::$file_directories[$type] ?? 'any';
|
||||
return self::$file_directories[$type] ?? 'any/';
|
||||
}
|
||||
|
||||
public static function getFileName($type, $id)
|
||||
|
||||
14
app/Models/FilesDoc.php
Normal file
14
app/Models/FilesDoc.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class FilesDoc extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'files_doc';
|
||||
protected $primaryKey = 'id';
|
||||
protected $fillable = ['corporate_id', 'original_name', 'path','status_download', 'created_by','updated_by', 'created_at', 'updated_at'];
|
||||
}
|
||||
@@ -17,6 +17,19 @@ class Formularium extends Model
|
||||
protected $fillable = [
|
||||
'code',
|
||||
'name',
|
||||
'description',
|
||||
'manufacturer',
|
||||
'category_name',
|
||||
'kategori_obat',
|
||||
'uom',
|
||||
'general_indication',
|
||||
'composition',
|
||||
'atc_code',
|
||||
'class',
|
||||
'bpom_registration',
|
||||
'classifications',
|
||||
'cat_for',
|
||||
'formularium_template_id'
|
||||
];
|
||||
|
||||
public function setCodeAttribute($value)
|
||||
@@ -24,11 +37,6 @@ class Formularium extends Model
|
||||
$this->attributes['code'] = !empty($value) ? $value : Str::upper(Str::random('6'));
|
||||
}
|
||||
|
||||
public function corporateFormulariums()
|
||||
{
|
||||
return $this->hasMany(CorporateFormularium::class);
|
||||
}
|
||||
|
||||
public function items()
|
||||
{
|
||||
return $this->belongsToMany(Drug::class, 'formularium_items', 'formularium_id', 'item_id');
|
||||
|
||||
32
app/Models/FormulariumTemplate.php
Normal file
32
app/Models/FormulariumTemplate.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Altek\Accountant\Contracts\Recordable;
|
||||
|
||||
class FormulariumTemplate extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'description',
|
||||
'active',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
// 'deleted_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
// 'deleted_by',
|
||||
];
|
||||
|
||||
// public function corporateFormulariums()
|
||||
// {
|
||||
// return $this->hasMany(CorporateFormularium::class, 'formularium_template_id', 'id');
|
||||
// }
|
||||
}
|
||||
@@ -6,6 +6,7 @@ use App\Traits\Blameable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Altek\Accountant\Contracts\Recordable;
|
||||
|
||||
class Icd extends Model
|
||||
{
|
||||
@@ -20,11 +21,13 @@ class Icd extends Model
|
||||
'name',
|
||||
'description',
|
||||
'parent_code',
|
||||
'active',
|
||||
'icd_template_id'
|
||||
];
|
||||
|
||||
public $appends = [
|
||||
'type',
|
||||
'active'
|
||||
// 'active'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
@@ -41,10 +44,10 @@ class Icd extends Model
|
||||
return 'ICD-'.$this->rev;
|
||||
}
|
||||
|
||||
public function getActiveAttribute()
|
||||
{
|
||||
return empty($this->deleted_at);
|
||||
}
|
||||
// public function getActiveAttribute()
|
||||
// {
|
||||
// return empty($this->deleted_at);
|
||||
// }
|
||||
|
||||
public function subCategories()
|
||||
{
|
||||
@@ -71,4 +74,14 @@ class Icd extends Model
|
||||
});
|
||||
}
|
||||
|
||||
public function claim_history_care()
|
||||
{
|
||||
return $this->hasMany(CliamHistoryCare::class, 'main_diagnosis_id', 'id');
|
||||
}
|
||||
|
||||
public function diagnosis_secondary_claim_history_care()
|
||||
{
|
||||
return $this->hasMany(DiagnosisSecondaryCliamHistoryCare::class, 'icd_id', 'id');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
32
app/Models/IcdTemplate.php
Normal file
32
app/Models/IcdTemplate.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Blameable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
// use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Altek\Accountant\Contracts\Recordable;
|
||||
|
||||
class IcdTemplate extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'icd_template';
|
||||
|
||||
protected $fillable = [
|
||||
'code',
|
||||
'name',
|
||||
'description',
|
||||
'active'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
// 'deleted_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
// 'deleted_by',
|
||||
];
|
||||
}
|
||||
39
app/Models/LaboratoriumResult.php
Normal file
39
app/Models/LaboratoriumResult.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use DB;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class LaboratoriumResult extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = "laboratorium_result";
|
||||
protected $fillable = [
|
||||
'claim_id',
|
||||
'date',
|
||||
'location',
|
||||
'examination',
|
||||
];
|
||||
|
||||
protected $appends = ['lab_result_file'];
|
||||
protected $path_for_public = 'storage/lab_result';
|
||||
|
||||
public function getLabResultFileAttribute()
|
||||
{
|
||||
$arr_files = [];
|
||||
$files = DB::table('files')->select('name','original_name','path','extension')->where("type","=","laboratorium-result")->where('fileable_id','=',$this->attributes['id'])->get();
|
||||
|
||||
foreach ($files as $row) {
|
||||
$row->path = url($this->path_for_public . "/" . $row->original_name);
|
||||
|
||||
$arr_files[] = [
|
||||
'lab_result_file_obj' => $row
|
||||
];
|
||||
}
|
||||
|
||||
return $arr_files;
|
||||
}
|
||||
}
|
||||
18
app/Models/MedicalPlan.php
Normal file
18
app/Models/MedicalPlan.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class MedicalPlan extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = "medical_plan";
|
||||
|
||||
protected $fillable = [
|
||||
'claim_daily_monitoring_id',
|
||||
'plan'
|
||||
];
|
||||
}
|
||||
@@ -63,6 +63,7 @@ class Member extends Model
|
||||
"policy_in_force",
|
||||
"start_no_claim",
|
||||
"end_no_claim",
|
||||
"suspended"
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
@@ -98,6 +99,12 @@ class Member extends Model
|
||||
return $this->hasMany(Claim::class, 'member_id', 'id');
|
||||
}
|
||||
|
||||
public function claimRequest()
|
||||
{
|
||||
return $this->hasMany(ClaimRequest::class, 'member_id', 'id')->where('claim_id', '!=', null);
|
||||
}
|
||||
|
||||
|
||||
public function postponedClaims()
|
||||
{
|
||||
return $this->hasMany(Claim::class, 'member_id', 'id')->where('status', 'postpone');
|
||||
@@ -142,12 +149,35 @@ class Member extends Model
|
||||
return $this->hasManyThrough(Plan::class, MemberPlan::class, 'member_id', 'id', 'id', 'plan_id');
|
||||
}
|
||||
|
||||
public function currentPlans()
|
||||
{
|
||||
return $this->hasManyThrough(Plan::class, MemberPlan::class, 'member_id', 'id', 'id', 'plan_id');
|
||||
// ->latest(); // TODO Fix This
|
||||
}
|
||||
|
||||
public function currentPlan()
|
||||
{
|
||||
return $this->hasOneThrough(Plan::class, MemberPlan::class, 'member_id', 'id', 'id', 'plan_id')
|
||||
->latest(); // TODO Fix This
|
||||
return $this->hasOneThrough(Plan::class, MemberPlan::class, 'member_id', 'id', 'id', 'plan_id', )
|
||||
->latest();
|
||||
// ->where('plans.service_code', $this->claimRequest->service_code); // TODO Fix This
|
||||
}
|
||||
|
||||
// public function currentPlan()
|
||||
// {
|
||||
// return $this->hasOneThrough(
|
||||
// Plan::class,
|
||||
// MemberPlan::class,
|
||||
// 'member_id',
|
||||
// 'id',
|
||||
// 'id',
|
||||
// 'plan_id'
|
||||
// )
|
||||
// ->join('claim_requests', 'claim_requests.service_code', '=', 'plans.service_code')
|
||||
// ->latest('claim_requests.created_at') // Atau sesuaikan dengan kolom timestamp yang sesuai
|
||||
// ->select('plans.*');
|
||||
// }
|
||||
|
||||
|
||||
public function currentEmployeds()
|
||||
{
|
||||
return $this->hasOneThrough(CorporateEmployee::class, Person::class, 'nik', 'id', 'id', 'nik')
|
||||
@@ -240,5 +270,20 @@ class Member extends Model
|
||||
get: fn () => $this->person->gender ?? null
|
||||
);
|
||||
}
|
||||
|
||||
protected function corporateLogo(): Attribute
|
||||
{
|
||||
$avatar = File::where(['type' => 'avatar', 'fileable_id' => $this->currentPolicy->corporate->id])->orderBy('id', 'desc')->get()->first();
|
||||
if ($avatar){
|
||||
$path = $_ENV['LMS_APP_STORAGE'] . $avatar->path ? $avatar->path :'';
|
||||
return Attribute::make(
|
||||
get: fn () => $avatar ? $path : null
|
||||
);
|
||||
} else {
|
||||
return Attribute::make(
|
||||
get: fn () => null
|
||||
);
|
||||
}
|
||||
}
|
||||
/* -------------------------------------------------------------------------- */
|
||||
}
|
||||
|
||||
18
app/Models/OLDLMS/PersonalAccessToken.php
Normal file
18
app/Models/OLDLMS/PersonalAccessToken.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\OLDLMS;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Laravel\Sanctum\PersonalAccessToken as SanctumPersonalAccessToken;
|
||||
|
||||
|
||||
class PersonalAccessToken extends SanctumPersonalAccessToken
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'personal_access_tokens';
|
||||
protected $connection = 'oldlms';
|
||||
|
||||
|
||||
}
|
||||
@@ -2,14 +2,20 @@
|
||||
|
||||
namespace App\Models\OLDLMS;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
class User extends Model
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
use HasFactory, SoftDeletes, HasApiTokens, HasRoles, Notifiable, Notifiable;
|
||||
|
||||
const CREATED_AT = 'dCreateOn';
|
||||
const UPDATED_AT = 'dUpdateOn';
|
||||
@@ -55,9 +61,14 @@ class User extends Model
|
||||
{
|
||||
return $this->hasOne(UserDetail::class, 'nIDUser', 'nID');
|
||||
}
|
||||
|
||||
|
||||
public function insurances()
|
||||
{
|
||||
return $this->hasMany(UserInsurance::class, 'nIDUser', 'nID');
|
||||
}
|
||||
|
||||
public function notificationTokens()
|
||||
{
|
||||
return $this->morphMany(NotificationToken::class, 'notifiabletoken');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,10 @@ class UserDetail extends Model
|
||||
'nIDJenisKelamin',
|
||||
'sCreateBy',
|
||||
'sKTP',
|
||||
'sImages',
|
||||
'sWeight',
|
||||
'sHeight',
|
||||
'nIDGolonganDarah',
|
||||
|
||||
];
|
||||
|
||||
|
||||
@@ -26,5 +26,7 @@ class UserInsurance extends Model
|
||||
'dTanggalLahir',
|
||||
'nNoKTP',
|
||||
'sNoPolis',
|
||||
'nIDInsurance',
|
||||
'sLayanan',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -98,4 +98,17 @@ class Organization extends Model
|
||||
{
|
||||
return $this->hasMany(PractitionerRole::class, 'organization_id');
|
||||
}
|
||||
|
||||
public function claims()
|
||||
{
|
||||
return $this->hasMany(Claim::class, 'organization_id', 'id');
|
||||
}
|
||||
public function claim_request()
|
||||
{
|
||||
return $this->hasMany(ClaimRequest::class, 'organization_id', 'id');
|
||||
}
|
||||
public function claim_history_care()
|
||||
{
|
||||
return $this->hasOne(ClaimHistoryCare::class, 'organization_id', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
20
app/Models/OrganizationUser.php
Normal file
20
app/Models/OrganizationUser.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class OrganizationUser extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'organization_user';
|
||||
protected $connection = 'mysql';
|
||||
protected $fillable = [
|
||||
'organization_id',
|
||||
];
|
||||
|
||||
public function organization(){
|
||||
return $this->hasOne(Organization::class, 'id', 'organization_id');
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,9 @@ class Person extends Model
|
||||
|
||||
public function currentAddress()
|
||||
{
|
||||
return $this->belongsTo(Address::class, 'main_address_id');
|
||||
return $this->belongsTo(Address::class, 'main_address_id')->withDefault([
|
||||
'text' => '',
|
||||
]);
|
||||
}
|
||||
|
||||
public function domicileAddress()
|
||||
|
||||
@@ -47,4 +47,11 @@ class Practitioner extends Model
|
||||
{
|
||||
return $this->hasMany(PractitionerRole::class, 'practitioner_id');
|
||||
}
|
||||
|
||||
public function claim_history_care()
|
||||
{
|
||||
return $this->hasMany(ClaimHistoryCare::class, 'practitioner_id');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
220
app/Models/RequestLog.php
Normal file
220
app/Models/RequestLog.php
Normal file
@@ -0,0 +1,220 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Events\ClaimReceived;
|
||||
use App\Events\ClaimRequested;
|
||||
use App\Traits\Blameable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Str;
|
||||
|
||||
class RequestLog extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes, Blameable;
|
||||
|
||||
// protected static $code_prefix_hospital = 'CRQ-H';
|
||||
// protected static $code_prefix_client = 'CRQ-R';
|
||||
|
||||
public $fillable = [
|
||||
'uuid',
|
||||
'submission_date',
|
||||
'member_id',
|
||||
'payment_type',
|
||||
'service_code',
|
||||
'policy_id',
|
||||
'final_log',
|
||||
'status',
|
||||
'status_final_log',
|
||||
'source',
|
||||
'claim_id',
|
||||
'organization_id',
|
||||
'code'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
// 'created_at',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
];
|
||||
|
||||
public static $doc_headers_to_field_map = [
|
||||
"ID REQUEST LOG" => "id",
|
||||
"STATUS (approved, declined, requested)" => "status",
|
||||
];
|
||||
|
||||
public static $listing_doc_headers = [
|
||||
"ID REQUEST LOG",
|
||||
"STATUS (approved, declined, requested)",
|
||||
];
|
||||
|
||||
public static $listing_data_doc_headers = [
|
||||
"ID REQUEST LOG",
|
||||
"CODE",
|
||||
"NAME",
|
||||
"DATE OF SUBMISSION",
|
||||
"SERVICE TYPE",
|
||||
"CLAIM METHOD",
|
||||
"STATUS",
|
||||
];
|
||||
|
||||
|
||||
public static $status = [
|
||||
'draft' => 'Draft',
|
||||
'requested' => 'Requested',
|
||||
'approved' => 'Approved',
|
||||
'declined' => 'Declined'
|
||||
];
|
||||
|
||||
public static $payment_types = [
|
||||
'cashless' => 'Cashless',
|
||||
'reimbursement' => 'Reimbursement'
|
||||
];
|
||||
|
||||
public $appends = [
|
||||
'payment_type_name'
|
||||
];
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::creating(function ($model) {
|
||||
try {
|
||||
$model->uuid = (string) Str::orderedUuid(); // generate uuid
|
||||
// $model->code = self::getNextCode();
|
||||
} catch (\Exception $e) {
|
||||
abort(500, $e->getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
static::created(function ($model) {
|
||||
// try {
|
||||
// if (!empty($model->status) && $model->status == 'requested') {
|
||||
// $model->histories()->create([
|
||||
// 'title' => 'New Claim Requested',
|
||||
// 'description' => "Claim Requested for Member : {$model->member->member_id} - ({$model->member->full_name})",
|
||||
// 'type' => 'info'
|
||||
// ]);
|
||||
// }
|
||||
// } catch (\Exception $e) {
|
||||
// abort(500, $e->getMessage());
|
||||
// }
|
||||
});
|
||||
|
||||
static::updated(function ($model) {
|
||||
if ($model->hasChanges(['status'])) {
|
||||
|
||||
// if ($model->status == 'requested') {
|
||||
// $model->histories()->create([
|
||||
// 'title' => 'New Claim Requested',
|
||||
// 'description' => "Claim Requested for Member : {$model->member->member_id} - ({$model->member->full_name})",
|
||||
// 'type' => 'info'
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// if ($model->status == 'received') {
|
||||
// ClaimReceived::dispatch($model);
|
||||
// }
|
||||
|
||||
// if ($model->status == 'approved') {
|
||||
// ClaimApproved::dispatch($model);
|
||||
// }
|
||||
|
||||
// if ($model->status == 'postpone') {
|
||||
// ClaimPostpone::dispatch($model);
|
||||
// }
|
||||
|
||||
// if ($model->status == 'paid') {
|
||||
// ClaimPaid::dispatch($model);
|
||||
// }
|
||||
|
||||
// if ($model->status == 'declined') {
|
||||
// ClaimDeclined::dispatch($model);
|
||||
// }
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// public static function getNextCode()
|
||||
// {
|
||||
// $last_number = self::withTrashed()->max('code');
|
||||
// $next_number = empty($last_number) ? 1 : ((int) explode('-', $last_number)[1] + 1);
|
||||
|
||||
// return self::makeCode($next_number);
|
||||
// }
|
||||
|
||||
// public static function makeCode($next_number)
|
||||
// {
|
||||
// return (string) self::$code_prefix .'-'. str_pad($next_number, 5, 0, STR_PAD_LEFT);
|
||||
// }
|
||||
|
||||
public function claim()
|
||||
{
|
||||
return $this->belongsTo(Claim::class, 'claim_id');
|
||||
}
|
||||
|
||||
public function claims()
|
||||
{
|
||||
return $this->hasMany(Claim::class, 'claim_request_id');
|
||||
}
|
||||
|
||||
public function files()
|
||||
{
|
||||
return $this->morphMany(File::class, 'fileable');
|
||||
}
|
||||
|
||||
public function claimResults()
|
||||
{
|
||||
return $this->files()->where('type', 'claim-result')->whereNull('deleted_at');
|
||||
}
|
||||
|
||||
public function claimConditions()
|
||||
{
|
||||
return $this->files()->where('type', 'claim-kondisi')->whereNull('deleted_at');
|
||||
}
|
||||
|
||||
public function claimDiagnosis()
|
||||
{
|
||||
return $this->files()->where('type', 'claim-diagnosis')->whereNull('deleted_at');
|
||||
}
|
||||
|
||||
public function generatedDocuments()
|
||||
{
|
||||
return $this->morphMany(GeneratedDocument::class, 'generated_documentable');
|
||||
}
|
||||
|
||||
public function histories()
|
||||
{
|
||||
return $this->morphMany(ClaimHistory::class, 'historiable');
|
||||
}
|
||||
|
||||
public function organization()
|
||||
{
|
||||
return $this->belongsTo(Organization::class, 'organization_id');
|
||||
}
|
||||
|
||||
public function member()
|
||||
{
|
||||
return $this->belongsTo(Member::class, 'member_id', 'id');
|
||||
}
|
||||
|
||||
public function service()
|
||||
{
|
||||
return $this->belongsTo(Service::class, 'service_code', 'code');
|
||||
}
|
||||
|
||||
public function getPaymentTypeNameAttribute()
|
||||
{
|
||||
return self::$payment_types[$this->payment_type] ?? $this->payment_type;
|
||||
}
|
||||
|
||||
public function getStatusAttribute($value)
|
||||
{
|
||||
return self::$payment_types[$value] ?? $value;
|
||||
}
|
||||
}
|
||||
27
app/Models/RequestLogBenefit.php
Normal file
27
app/Models/RequestLogBenefit.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class RequestLogBenefit extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'request_log_benefits';
|
||||
|
||||
public $fillable = [
|
||||
'request_log_id',
|
||||
'benefit_id',
|
||||
'amount_incurred',
|
||||
'amount_approved',
|
||||
'amount_not_approved',
|
||||
'excess_paid',
|
||||
'keterangan',
|
||||
];
|
||||
|
||||
public function benefit(){
|
||||
return $this->belongsTo(Benefit::class, 'benefit_id', 'id');
|
||||
}
|
||||
}
|
||||
30
app/Models/RequestLogMedicine.php
Normal file
30
app/Models/RequestLogMedicine.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class RequestLogMedicine extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public $fillable = [
|
||||
'request_log_id',
|
||||
'medicine',
|
||||
'price',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
];
|
||||
|
||||
public function benefit(){
|
||||
return $this->belongsTo(Benefit::class, 'benefit_id', 'id');
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,8 @@ class User extends Authenticatable
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
|
||||
protected $connection = 'mysql';
|
||||
protected $fillable = [
|
||||
'person_id',
|
||||
'name',
|
||||
@@ -103,4 +105,9 @@ class User extends Authenticatable
|
||||
{
|
||||
return $this->morphMany(NotificationToken::class, 'notifiabletoken');
|
||||
}
|
||||
|
||||
public function getOrganization()
|
||||
{
|
||||
return $this->hasOne(OrganizationUser::class, 'user_id');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user