update
This commit is contained in:
@@ -9,7 +9,9 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Models\Member;
|
||||
use App\Models\RequestLogBenefit;
|
||||
use App\Models\User;
|
||||
use App\Models\CorporatePolicy;
|
||||
use App\Models\Service;
|
||||
use App\Models\Icd;
|
||||
use DateTime;
|
||||
@@ -534,5 +536,138 @@ class Helper
|
||||
}
|
||||
}
|
||||
|
||||
public static function getUsageMember($corporateId, $id, $benefitData) {
|
||||
// Menghitung jumlah total approved dan mengkategorikan berdasarkan benefit_id
|
||||
$amountApprovedByBenefit = [];
|
||||
foreach($benefitData as $benefit) {
|
||||
if ($benefit['limit_amount'] != 999999999 || $benefit['limit_amount_plan'] != 999999999) {
|
||||
if ($benefit['family_plan'] == 'S' || $benefit['family_plan'] == 'F'){ // Menghitung usage per family
|
||||
$memberFamilys = Helper::getMemberFamily($id);
|
||||
$usageLogs = 0;
|
||||
|
||||
$today = date('Y-m-d');
|
||||
$periods = [
|
||||
0 => [
|
||||
'start' => '2024-01-05',
|
||||
'end' => '2025-01-05'
|
||||
],
|
||||
1 => [
|
||||
'start' => $today,
|
||||
'end' => $today
|
||||
]
|
||||
// Tambahkan kondisi lainnya jika diperlukan
|
||||
];
|
||||
|
||||
// if (array_key_exists($benefit['max_frequency_period'], $periods)) {
|
||||
$usageLogs = RequestLogBenefit::query()
|
||||
->whereHas('requestLog', function ($query) use ($benefit, $memberFamilys, $periods) {
|
||||
// $period = $periods[$benefit['max_frequency_period']];
|
||||
$query->where('benefit_id', $benefit['id'])
|
||||
// ->where('submission_date', '>=', $period['start'])
|
||||
// ->where('submission_date', '<=', $period['end'])
|
||||
->whereIn('member_id', $memberFamilys);
|
||||
})
|
||||
->sum('amount_approved');
|
||||
// }
|
||||
// Mengkategorikan sum berdasarkan benefit_id
|
||||
$amountApprovedByBenefit[$benefit['id']] = $usageLogs;
|
||||
} else { // Menghitung usage permember
|
||||
$usageLog = RequestLogBenefit::query()
|
||||
->whereHas('requestLog', function ($query) use ($benefit, $id) {
|
||||
$query->where('benefit_id', $benefit['id'])
|
||||
->where('member_id', $id);
|
||||
})
|
||||
->sum('amount_approved');
|
||||
|
||||
// Mengkategorikan sum berdasarkan benefit_id
|
||||
$amountApprovedByBenefit[$benefit['id']] = $usageLog;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($amountApprovedByBenefit);
|
||||
|
||||
}
|
||||
|
||||
public static function getLimitMemberService($corporateId, $id, $benefitData) {
|
||||
// Menghitung jumlah total approved dan mengkategorikan berdasarkan benefit_id
|
||||
$amountApprovedByBenefit = [];
|
||||
foreach($benefitData as $benefit) {
|
||||
if ($benefit['limit_amount'] != 999999999) {
|
||||
if ($benefit['family_plan'] == 'S' || $benefit['family_plan'] == 'F'){ // Menghitung usage per family
|
||||
$memberFamilys = Helper::getMemberFamily($id);
|
||||
$usageLogs = 0;
|
||||
|
||||
$today = date('Y-m-d');
|
||||
$periods = [
|
||||
0 => [
|
||||
'start' => '2024-01-05',
|
||||
'end' => '2025-01-05'
|
||||
],
|
||||
1 => [
|
||||
'start' => $today,
|
||||
'end' => $today
|
||||
]
|
||||
// Tambahkan kondisi lainnya jika diperlukan
|
||||
];
|
||||
|
||||
if (array_key_exists($benefit['max_frequency_period'], $periods)) {
|
||||
$usageLogs = RequestLogBenefit::query()
|
||||
->whereHas('requestLog', function ($query) use ($benefit, $memberFamilys, $periods) {
|
||||
$period = $periods[$benefit['max_frequency_period']];
|
||||
$query->where('benefit_id', $benefit['id'])
|
||||
// ->where('submission_date', '>=', $period['start'])
|
||||
// ->where('submission_date', '<=', $period['end'])
|
||||
->whereIn('member_id', $memberFamilys);
|
||||
})
|
||||
->sum('amount_approved');
|
||||
}
|
||||
// Mengkategorikan sum berdasarkan benefit_id
|
||||
$amountApprovedByBenefit[$benefit['id']] = $usageLogs;
|
||||
} else { // Menghitung usage permember
|
||||
$usageLog = RequestLogBenefit::query()
|
||||
->whereHas('requestLog', function ($query) use ($benefit, $id) {
|
||||
$query->where('benefit_id', $benefit['id'])
|
||||
->where('member_id', $id);
|
||||
})
|
||||
->sum('amount_approved');
|
||||
|
||||
// Mengkategorikan sum berdasarkan benefit_id
|
||||
$amountApprovedByBenefit[$benefit['id']] = $usageLog;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($amountApprovedByBenefit);
|
||||
|
||||
}
|
||||
|
||||
public static function getMemberFamily($memberId){
|
||||
// Mengambil data member berdasarkan ID
|
||||
$member = Member::where('id', $memberId)->first();
|
||||
|
||||
// Memastikan member ditemukan
|
||||
if ($member) {
|
||||
// Mengambil keluarga berdasarkan member_id atau principal_id
|
||||
if (!$member->principal_id){
|
||||
$memberFamily = Member::where(function($query) use ($member) {
|
||||
$query->where('principal_id', $member->member_id)
|
||||
->orWhere('member_id', $member->member_id);
|
||||
})->pluck('id')->toArray();
|
||||
} else {
|
||||
$memberFamily = Member::where(function($query) use ($member) {
|
||||
$query->where('principal_id', $member->principal_id)
|
||||
->orWhere('member_id', $member->principal_id)
|
||||
->orWhere('member_id', $member->member_id);
|
||||
})->pluck('id')->toArray();
|
||||
}
|
||||
// Mengembalikan data keluarga
|
||||
return $memberFamily;
|
||||
}
|
||||
|
||||
// Jika member tidak ditemukan, mengembalikan array kosong
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,10 @@ class Corporate extends Model
|
||||
'help_text',
|
||||
'active',
|
||||
'linking_rules',
|
||||
'automatic_linking'
|
||||
'automatic_linking',
|
||||
'phone',
|
||||
'phone_alarm_canter',
|
||||
'description_information',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
|
||||
@@ -28,6 +28,7 @@ class Drug extends Model
|
||||
'status',
|
||||
'price',
|
||||
'active',
|
||||
'unit'
|
||||
];
|
||||
|
||||
public function categories()
|
||||
|
||||
@@ -55,6 +55,12 @@ class Livechat extends Model
|
||||
return $this->belongsTo(User::class, 'nIDUser', 'nID');
|
||||
}
|
||||
|
||||
public function userInsurance()
|
||||
{
|
||||
return $this->belongsTo(UserInsurance::class, 'nIDUser', 'nIDUser');
|
||||
}
|
||||
|
||||
|
||||
public function doctor()
|
||||
{
|
||||
return $this->belongsTo(Dokter::class, 'nIDDokter', 'nIDUser');
|
||||
@@ -74,4 +80,12 @@ class Livechat extends Model
|
||||
public function summary(){
|
||||
return $this->belongsTo(LivechatSummary::class, 'nID', 'nIDLivechat');
|
||||
}
|
||||
|
||||
public function prescription(){
|
||||
return $this->belongsTo(Prescription::class, 'nID', 'nIDLivechat');
|
||||
}
|
||||
|
||||
public function rujukan(){
|
||||
return $this->belongsTo(Rujukan::class, 'nID', 'nIDLivechat');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,4 +52,28 @@ class Prescription extends Model
|
||||
'dTanggalResep' => 'datetime',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'nIDUser', 'nID');
|
||||
}
|
||||
|
||||
public function items()
|
||||
{
|
||||
return $this->hasMany(PrescriptionItem::class, 'nIDPrescription', 'nID');
|
||||
}
|
||||
|
||||
public function livechat(){
|
||||
return $this->belongsTo(Livechat::class, 'nIDLivechat', 'nID');
|
||||
}
|
||||
|
||||
public function order()
|
||||
{
|
||||
return $this->hasMany(PrescriptionItem::class, 'nIDPrescription', 'nID');
|
||||
}
|
||||
|
||||
public function payment()
|
||||
{
|
||||
return $this->hasOne(PrescriptionOrder::class, 'nIDPrescription', 'nID');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,4 +50,10 @@ class PrescriptionItem extends Model
|
||||
];
|
||||
|
||||
protected $primaryKey = 'nID';
|
||||
|
||||
public function prescription()
|
||||
{
|
||||
return $this->belongsTo(Prescription::class, 'nIDPrescription', 'nID');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
59
app/Models/OLDLMS/PrescriptionOrder.php
Executable file
59
app/Models/OLDLMS/PrescriptionOrder.php
Executable file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\OLDLMS;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PrescriptionOrder extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'nIDPrescription',
|
||||
'sItemCode',
|
||||
'sOriginCode',
|
||||
'sItemName',
|
||||
'nQty',
|
||||
'sSatuan',
|
||||
'sSigna',
|
||||
'sNote',
|
||||
'nHarga',
|
||||
'isRacikan',
|
||||
'ParentCode',
|
||||
];
|
||||
|
||||
|
||||
// public $sStatusNames = [
|
||||
// 0 => 'Menunggu Konfirmasi',
|
||||
// 1 => 'Diterima',
|
||||
// 2 => 'Ditolak',
|
||||
// 3 => 'Selesai',
|
||||
// 4 => 'Expired',
|
||||
// ];
|
||||
|
||||
const CREATED_AT = 'dCreateOn';
|
||||
const UPDATED_AT = 'dUpdateOn';
|
||||
const DELETED_AT = 'dDeleteOn';
|
||||
|
||||
protected $connection = 'oldlms';
|
||||
|
||||
protected $table = 'tx_prescription_orders';
|
||||
|
||||
// protected $appends = [
|
||||
// 'status_name',
|
||||
// ];
|
||||
|
||||
protected $casts = [
|
||||
'dTanggalResep' => 'datetime',
|
||||
];
|
||||
|
||||
protected $primaryKey = 'nID';
|
||||
|
||||
public function order()
|
||||
{
|
||||
return $this->belongsTo(Prescription::class, 'nIDPrescription', 'nIDPrescription');
|
||||
}
|
||||
|
||||
}
|
||||
25
app/Models/OLDLMS/Relationship.php
Executable file
25
app/Models/OLDLMS/Relationship.php
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\OLDLMS;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Relationship extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
const CREATED_AT = 'dCreateOn';
|
||||
const UPDATED_AT = 'dUpdateOn';
|
||||
const DELETED_AT = 'dDeleteOn';
|
||||
|
||||
protected $connection = 'oldlms';
|
||||
protected $primaryKey = 'nID';
|
||||
|
||||
protected $table = 'tm_hubungan_keluarga';
|
||||
protected $fillable = [
|
||||
'nID',
|
||||
'sHubunganKeluarga'
|
||||
];
|
||||
}
|
||||
52
app/Models/OLDLMS/Rujukan.php
Normal file
52
app/Models/OLDLMS/Rujukan.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\OLDLMS;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Rujukan extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'nIDLivechat',
|
||||
'sNoRujukan',
|
||||
'nIDHealthcare',
|
||||
'sDepartement',
|
||||
];
|
||||
|
||||
|
||||
// public $sStatusNames = [
|
||||
// 0 => 'Menunggu Konfirmasi',
|
||||
// 1 => 'Diterima',
|
||||
// 2 => 'Ditolak',
|
||||
// 3 => 'Selesai',
|
||||
// 4 => 'Expired',
|
||||
// ];
|
||||
|
||||
const CREATED_AT = 'dCreateOn';
|
||||
const UPDATED_AT = 'dUpdateOn';
|
||||
const DELETED_AT = 'dDeleteOn';
|
||||
|
||||
protected $connection = 'oldlms';
|
||||
|
||||
protected $table = 'tx_rujukan';
|
||||
|
||||
protected $primaryKey = 'nID';
|
||||
|
||||
// protected $appends = [
|
||||
// 'status_name',
|
||||
// ];
|
||||
|
||||
public function livechat(){
|
||||
return $this->belongsTo(Livechat::class, 'nIDLivechat', 'nID');
|
||||
}
|
||||
|
||||
public function healthcare(){
|
||||
return $this->belongsTo(Healthcare::class, 'nIDHealthcare', 'nID');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -64,6 +64,11 @@ class User extends Authenticatable
|
||||
return $this->hasOne(UserDetail::class, 'nIDUser', 'nID');
|
||||
}
|
||||
|
||||
public function relation()
|
||||
{
|
||||
return $this->hasOne(Relationship::class, 'nID', 'nIDHubunganKeluarga');
|
||||
}
|
||||
|
||||
public function insurances()
|
||||
{
|
||||
return $this->hasMany(UserInsurance::class, 'nIDUser', 'nID');
|
||||
|
||||
@@ -19,6 +19,8 @@ class Organization extends Model
|
||||
'part_of',
|
||||
'main_address_id',
|
||||
'corporate_id_partner',
|
||||
'phone',
|
||||
'email',
|
||||
];
|
||||
|
||||
// public $with = [
|
||||
|
||||
11
app/Models/PrescriptionOrder.php
Normal file
11
app/Models/PrescriptionOrder.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PrescriptionOrder extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
@@ -208,6 +208,7 @@ class CorporateMemberService
|
||||
|
||||
return RequestLog::query()
|
||||
->leftJoin('members', 'request_logs.member_id', '=', 'members.id')
|
||||
->leftJoin('corporate_employees', 'request_logs.member_id', '=', 'corporate_employees.member_id')
|
||||
// ->joinMemberPlans('left')
|
||||
// ->joinPlans('left')
|
||||
// ->with(['currentPlan', 'person'])
|
||||
@@ -215,6 +216,7 @@ class CorporateMemberService
|
||||
// ->whereHas('currentCorporate', function (Builder $query) use ($corporateId) {
|
||||
// // $query->where('corporate_id', $corporateId);
|
||||
// })
|
||||
->where('corporate_employees.corporate_id', $corporateId)
|
||||
->when($request->input('search'), function (Builder $query, $search) {
|
||||
$query->where(function (Builder $query) use ($search) {
|
||||
$query->orWhere('members.member_id', 'like', "%" . $search . "%")
|
||||
@@ -261,8 +263,6 @@ class CorporateMemberService
|
||||
// ->selectRaw("(select sum(`claims`.`total_claim`) from `claims` where `members`.`id` = `claims`.`member_id` AND `claims`.`deleted_at` IS NULL) AS `claims_sum_total_claim`")
|
||||
->groupBy('member_id')
|
||||
->paginate($limit);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function getAllMemberEmployeeData(int $corporateId, Request $request)
|
||||
|
||||
Reference in New Issue
Block a user