API Home dan Linking
This commit is contained in:
@@ -61,6 +61,8 @@ class DoctorResource extends JsonResource
|
|||||||
'speciality_id' => $item->speciality->id,
|
'speciality_id' => $item->speciality->id,
|
||||||
];
|
];
|
||||||
}),
|
}),
|
||||||
|
'period_start' => $items->pluck('period_start')->first(),
|
||||||
|
'period_end' => $items->pluck('period_end')->first(),
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
75
Modules/Linksehat/Http/Controllers/Api/HomeController.php
Normal file
75
Modules/Linksehat/Http/Controllers/Api/HomeController.php
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Linksehat\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Helpers\Helper;
|
||||||
|
use App\Models\Organization;
|
||||||
|
use App\Models\PractitionerRole;
|
||||||
|
use App\Models\OLDLMS\User;
|
||||||
|
use Illuminate\Routing\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Modules\Linksehat\Transformers\Article\ArticleResource;
|
||||||
|
use Modules\Linksehat\Transformers\Home\HomeResource;
|
||||||
|
use Modules\Linksehat\Transformers\Doctor\DoctorResource;
|
||||||
|
use Modules\Linksehat\Transformers\Hospital\HospitalResource;
|
||||||
|
|
||||||
|
class HomeController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$user = User::with('detail')
|
||||||
|
->where('nId', $request->id)
|
||||||
|
->first();
|
||||||
|
return Helper::responseJson([
|
||||||
|
'home' => HomeResource::make($user, $request),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function listHospital(Request $request){
|
||||||
|
// Hospital List
|
||||||
|
$hospitalList = [];
|
||||||
|
$hospitals = Organization::where([
|
||||||
|
'type' => 'hospital',
|
||||||
|
'status' => 'active',
|
||||||
|
])
|
||||||
|
->with('currentAddress')
|
||||||
|
->get()->toArray();
|
||||||
|
foreach($hospitals as $hospital){
|
||||||
|
$lat = 0;
|
||||||
|
$lang = 0;
|
||||||
|
if ($hospital['current_address']['lat']){
|
||||||
|
$lat = $hospital['current_address']['lat'];
|
||||||
|
}
|
||||||
|
if ($hospital['current_address']['lng']){
|
||||||
|
$lang = $hospital['current_address']['lng'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$address = '';
|
||||||
|
if ($hospital['current_address']['text']){
|
||||||
|
$address = $hospital['current_address']['text'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$radius = 0;
|
||||||
|
if ($lat && $lang && $request->longitude && $request->latitude){
|
||||||
|
$radius = round(Helper::calculateDistance($lat, $lang, $request->latitude, $request->longitude), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'name' => $hospital['name'],
|
||||||
|
'radius' => $radius,
|
||||||
|
'image' => '',
|
||||||
|
'address' => $address
|
||||||
|
];
|
||||||
|
|
||||||
|
array_push($hospitalList, $data);
|
||||||
|
}
|
||||||
|
usort($hospitalList, function($a, $b) {
|
||||||
|
return $a['radius'] <=> $b['radius'];
|
||||||
|
});
|
||||||
|
return Helper::responseJson([
|
||||||
|
'hospital' => $hospitalList
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,8 @@ namespace Modules\Linksehat\Http\Controllers\Api;
|
|||||||
use App\Helpers\Helper;
|
use App\Helpers\Helper;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Person;
|
use App\Models\Person;
|
||||||
|
use App\Models\RequestLogBenefit;
|
||||||
|
use App\Models\RequestLog;
|
||||||
use App\Models\Corporate;
|
use App\Models\Corporate;
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
use App\Models\OLDLMS\User;
|
use App\Models\OLDLMS\User;
|
||||||
@@ -135,4 +137,39 @@ class LinkingController extends Controller
|
|||||||
$message = $member->currentPolicy->corporate->welcome_message;
|
$message = $member->currentPolicy->corporate->welcome_message;
|
||||||
return Helper::responseJson(data: MemberResource::make($member), message: $message);
|
return Helper::responseJson(data: MemberResource::make($member), message: $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function card_detail($member_id, $id){
|
||||||
|
$member = Member::where('member_id', $member_id)->get()->toArray();
|
||||||
|
$requestLogBenefits = RequestLogBenefit::where('request_log_id', $id)->with('benefit')->get()->toArray();
|
||||||
|
$requestLog = RequestLog::find($id)->first();
|
||||||
|
$benefitItem = [];
|
||||||
|
$dataRequestLog = [
|
||||||
|
'code' => $requestLog['code'],
|
||||||
|
'diagnosis' => Helper::diagnosisName($requestLog['diagnosis']),
|
||||||
|
'service_type' => Helper::serviceName($requestLog['service_code']),
|
||||||
|
|
||||||
|
];
|
||||||
|
foreach($requestLogBenefits as $requestLogBenefit) {
|
||||||
|
$data = [
|
||||||
|
'benefit_item' => $requestLogBenefit['benefit']['description'],
|
||||||
|
'amount_incurred' => $requestLogBenefit['amount_incurred'],
|
||||||
|
'amount_approved' => $requestLogBenefit['amount_approved'],
|
||||||
|
'amount_not_approved' => $requestLogBenefit['amount_not_approved'],
|
||||||
|
'excess_paid' => $requestLogBenefit['excess_paid'],
|
||||||
|
];
|
||||||
|
|
||||||
|
$benefitItem[] = $data;
|
||||||
|
};
|
||||||
|
$dataRequestLog['benefit_item'] = $benefitItem;
|
||||||
|
|
||||||
|
// dd($dataRequestLog);
|
||||||
|
// $data = [
|
||||||
|
// 'id' => $requestLog['id'],
|
||||||
|
// 'code' => $requestLog['code'],
|
||||||
|
// 'submission_date' => Carbon::parse($requestLog['submission_date'])->format('d M Y H:i:s'),
|
||||||
|
// 'provider_name' => $requestLog['organization']['name'],
|
||||||
|
// 'service' => Helper::serviceName($requestLog['service_code'])
|
||||||
|
// ];
|
||||||
|
return Helper::responseJson(data:$dataRequestLog);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ use Modules\Linksehat\Http\Controllers\Api\ProfileController;
|
|||||||
use Modules\Linksehat\Http\Controllers\Api\SearchController;
|
use Modules\Linksehat\Http\Controllers\Api\SearchController;
|
||||||
use Modules\Linksehat\Http\Controllers\Api\SpecialityController;
|
use Modules\Linksehat\Http\Controllers\Api\SpecialityController;
|
||||||
use Modules\Linksehat\Http\Controllers\Api\LinkingController;
|
use Modules\Linksehat\Http\Controllers\Api\LinkingController;
|
||||||
|
use Modules\Linksehat\Http\Controllers\Api\HomeController;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
@@ -63,6 +64,11 @@ Route::prefix('linksehat')->group(function () {
|
|||||||
Route::get('doctors/{id}', 'show')->name('doctors.show');
|
Route::get('doctors/{id}', 'show')->name('doctors.show');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Route::controller(HomeController::class)->group(function () {
|
||||||
|
Route::get('home', 'index')->name('homes.index');
|
||||||
|
Route::get('home/hospital', 'listHospital')->name('homes.listHospital');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
Route::middleware('auth:sanctum')->group(function () {
|
Route::middleware('auth:sanctum')->group(function () {
|
||||||
Route::get('profile/{id}', [ProfileController::class, 'index'])->name('profile');
|
Route::get('profile/{id}', [ProfileController::class, 'index'])->name('profile');
|
||||||
@@ -81,6 +87,7 @@ Route::prefix('linksehat')->group(function () {
|
|||||||
Route::post('manual-linking', [LinkingController::class, 'linkingValidate']);
|
Route::post('manual-linking', [LinkingController::class, 'linkingValidate']);
|
||||||
|
|
||||||
Route::get('card/{member_id}', [LinkingController::class, 'card']);
|
Route::get('card/{member_id}', [LinkingController::class, 'card']);
|
||||||
|
Route::get('card/{member_id}/{log_id}', [LinkingController::class, 'card_detail']);
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
297
Modules/Linksehat/Transformers/Home/HomeResource.php
Normal file
297
Modules/Linksehat/Transformers/Home/HomeResource.php
Normal file
@@ -0,0 +1,297 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Linksehat\Transformers\Home;
|
||||||
|
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
use App\Models\OLDLMS\User;
|
||||||
|
use App\Models\OLDLMS\UserDetail;
|
||||||
|
use App\Models\OLDLMS\UserInsurance;
|
||||||
|
use App\Models\Organization;
|
||||||
|
use App\Models\Practitioner;
|
||||||
|
use App\Models\PractitionerRole;
|
||||||
|
use App\Models\Member;
|
||||||
|
use App\Models\Person;
|
||||||
|
use App\Models\CorporateEmployee;
|
||||||
|
use App\Models\Corporate;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use App\Helpers\Helper;
|
||||||
|
use DB;
|
||||||
|
|
||||||
|
|
||||||
|
class HomeResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
|
||||||
|
protected $request;
|
||||||
|
|
||||||
|
protected $connection = 'oldlms';
|
||||||
|
|
||||||
|
public function __construct($resource, $request)
|
||||||
|
{
|
||||||
|
$this->request = $request;
|
||||||
|
parent::__construct($resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toArray($request)
|
||||||
|
{
|
||||||
|
$memberProfile = User::with('detail')->where('nIDUser', $this->nID)->get()->toArray();
|
||||||
|
$dataMemberProfile = [];
|
||||||
|
|
||||||
|
$userInsurance = UserInsurance::where('nIDUser', $this->nID)->get()->first();
|
||||||
|
$memberId = null;
|
||||||
|
$linking = false;
|
||||||
|
|
||||||
|
$jam = date('G'); // Ambil jam dalam format 24 jam
|
||||||
|
|
||||||
|
if ($jam < 12) {
|
||||||
|
$wellcome = "Good Morning!";
|
||||||
|
} elseif ($jam < 18) {
|
||||||
|
$wellcome = "Good Afternoon!";
|
||||||
|
} else {
|
||||||
|
$wellcome = "Good Evening!";
|
||||||
|
}
|
||||||
|
|
||||||
|
if($userInsurance){
|
||||||
|
$memberId = $userInsurance->sNoPolis;
|
||||||
|
$linking = true;
|
||||||
|
} else {
|
||||||
|
$member = Member::where('email', $this->sEmail)->get()->first();
|
||||||
|
$person = Person::where('phone', $this->sPhone)->get()->first();
|
||||||
|
if ($member || $person){ // Autolinking
|
||||||
|
$corporateEmployee = CorporateEmployee::where('member_id', $member->id)->get()->first(); // cek corporate id empolyee/member
|
||||||
|
if ($corporateEmployee){
|
||||||
|
$corporate = Corporate::findOrFail($corporateEmployee->corporate_id)->automatic_linking; // cek autocomplete
|
||||||
|
if ($corporate){
|
||||||
|
if($member) {
|
||||||
|
// Insert into database linksehat
|
||||||
|
$insurance = UserInsurance::updateOrCreate(
|
||||||
|
[
|
||||||
|
'nIDUser' => $this->nID,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'nIDUser' => $this->nID,
|
||||||
|
'nIDInsurance' => $_ENV['LINKSEHAT_ASO_INSURANCE_ID'],
|
||||||
|
'sNoPolis' => $member->member_id,
|
||||||
|
'sNamaPeserta' => $member->fullName,
|
||||||
|
'sKartuPeserta' => '',
|
||||||
|
'sLayanan' => 'RJ,TC',
|
||||||
|
'dStartDate' => $member->members_effective_date,
|
||||||
|
'dExpireDate' => $member->members_expire_date,
|
||||||
|
'dTanggalLahir' => $member->birth_date,
|
||||||
|
'nNoKTP' => $member->nric != '' ? $member->nric : 0 ,
|
||||||
|
'sIsConfrimed' => 1,
|
||||||
|
'sStatus' => 1,
|
||||||
|
]);
|
||||||
|
$message = $member->currentPolicy->corporate->welcome_message;
|
||||||
|
$linking = true;
|
||||||
|
|
||||||
|
$memberId = $member->member_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (count($memberProfile) > 0){
|
||||||
|
|
||||||
|
$urlAvatarDefault = $this->detail->nIDJenisKelamin == 1 ? 'https://linksehat.dev/assets/img/users/male-avatar.png' : 'https://linksehat.dev/assets/img/users/female-avatar.png';
|
||||||
|
$avatarMember = $this->detail->sImage ?? $urlAvatarDefault;
|
||||||
|
$relationship = DB::connection('oldlms')->table('tm_hubungan_keluarga')->where('nID', $this->nIDHubunganKeluarga)->first('sHubunganKeluarga');
|
||||||
|
|
||||||
|
$dataUser = [
|
||||||
|
'id' => $this->nID,
|
||||||
|
'name' => $this->sFirstName . ' ' . $this->sLastName,
|
||||||
|
'relationship' => $relationship ? $relationship->sHubunganKeluarga : '-',
|
||||||
|
'avatar' => $avatarMember
|
||||||
|
];
|
||||||
|
|
||||||
|
array_push($dataMemberProfile, $dataUser);
|
||||||
|
|
||||||
|
foreach($memberProfile as $m){
|
||||||
|
$urlAvatarDefault = $m['detail']['nIDJenisKelamin'] == 1 ? 'https://linksehat.dev/assets/img/users/male-avatar.png' : 'https://linksehat.dev/assets/img/users/female-avatar.png';
|
||||||
|
$avatarMember = $m['detail']['sImage'] ?? $urlAvatarDefault;
|
||||||
|
$relationship = DB::connection('oldlms')->table('tm_hubungan_keluarga')->where('nID', $m['nIDHubunganKeluarga'])->first('sHubunganKeluarga');
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'id' => $m['nID'],
|
||||||
|
'name' => $m['full_name'],
|
||||||
|
'relationship' => $relationship ? $relationship->sHubunganKeluarga : '-',
|
||||||
|
'avatar' => $avatarMember,
|
||||||
|
];
|
||||||
|
|
||||||
|
array_push( $dataMemberProfile, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$nID = $this->nIDUser ? $this->nIDUser : $this->nID;
|
||||||
|
if ($nID){
|
||||||
|
$memberProfile = User::with('detail')->where('nIDUser', $nID)->get()->toArray();
|
||||||
|
|
||||||
|
$dataMember = User::with('detail')->where('nID', $nID)->get()->first();
|
||||||
|
|
||||||
|
if ($this->detail){
|
||||||
|
$urlAvatarDefault = $this->detail->nIDJenisKelamin == 1 ? 'https://linksehat.dev/assets/img/users/male-avatar.png' : 'https://linksehat.dev/assets/img/users/female-avatar.png';
|
||||||
|
} else {
|
||||||
|
$urlAvatarDefault = 'https://linksehat.dev/assets/img/users/male-avatar.png';
|
||||||
|
}
|
||||||
|
$avatar = $this->detail->sImage ?? $urlAvatarDefault;
|
||||||
|
|
||||||
|
$avatarMember = $dataMember->detail->sImage ?? $urlAvatarDefault;
|
||||||
|
$relationship = DB::connection('oldlms')->table('tm_hubungan_keluarga')->where('nID', $this->nIDHubunganKeluarga)->first('sHubunganKeluarga');
|
||||||
|
|
||||||
|
$dataUser = [
|
||||||
|
'id' => $dataMember->nID,
|
||||||
|
'name' => $dataMember->sFirstName . ' ' . $dataMember->sLastName,
|
||||||
|
'relationship' => 'Me',
|
||||||
|
'avatar' => $avatarMember
|
||||||
|
];
|
||||||
|
array_push($dataMemberProfile, $dataUser);
|
||||||
|
|
||||||
|
if (count($memberProfile) > 0){
|
||||||
|
foreach($memberProfile as $m){
|
||||||
|
$urlAvatarDefault = $m['detail']['nIDJenisKelamin'] == 1 ? 'https://linksehat.dev/assets/img/users/male-avatar.png' : 'https://linksehat.dev/assets/img/users/female-avatar.png';
|
||||||
|
$avatarMember = $m['detail']['sImage'] ?? $urlAvatarDefault;
|
||||||
|
$relationship = DB::connection('oldlms')->table('tm_hubungan_keluarga')->where('nID', $m['nIDHubunganKeluarga'])->first('sHubunganKeluarga');
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'id' => $m['nID'],
|
||||||
|
'name' => $m['full_name'],
|
||||||
|
'relationship' => $relationship->sHubunganKeluarga,
|
||||||
|
'avatar' => $avatarMember,
|
||||||
|
];
|
||||||
|
|
||||||
|
array_push( $dataMemberProfile, $data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Principal
|
||||||
|
if ($this->detail){
|
||||||
|
$urlAvatarDefault = $this->detail->nIDJenisKelamin == 1 ? 'https://linksehat.dev/assets/img/users/male-avatar.png' : 'https://linksehat.dev/assets/img/users/female-avatar.png';
|
||||||
|
} else {
|
||||||
|
$urlAvatarDefault = 'https://linksehat.dev/assets/img/users/male-avatar.png';
|
||||||
|
}
|
||||||
|
$avatar = $this->detail->sImage ?? $urlAvatarDefault;
|
||||||
|
|
||||||
|
// Doctor livechat
|
||||||
|
$doctors = Practitioner::with('person', 'practitionerRoles.organization', 'practitionerRoles.speciality')
|
||||||
|
->whereHas('person', function ($query) {
|
||||||
|
$query->where('isOnline', 1); // hanya online
|
||||||
|
})
|
||||||
|
->get()
|
||||||
|
->toArray();
|
||||||
|
$doctorsLivechat = [];
|
||||||
|
foreach($doctors as $doctor){
|
||||||
|
$specialist = 'Umum';
|
||||||
|
$year = 0;
|
||||||
|
$price = 0;
|
||||||
|
if (!empty($doctor['person']['start_date_work'])) {
|
||||||
|
$starExperience = Carbon::parse($doctor['person']['start_date_work'])->format('Y-m-d');
|
||||||
|
$experience = Carbon::createFromFormat('Y-m-d', $starExperience);
|
||||||
|
$year = $experience->diffInYears(Carbon::now());
|
||||||
|
}
|
||||||
|
if ($doctor['practitioner_roles']) {
|
||||||
|
if ($doctor['practitioner_roles'][0]['speciality']){
|
||||||
|
$specialist = $doctor['practitioner_roles'][0]['speciality']['name'];
|
||||||
|
}
|
||||||
|
if ($doctor['practitioner_roles'][0]['price']){
|
||||||
|
$price = $doctor['practitioner_roles'][0]['price'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$data = [
|
||||||
|
'full_name' => $doctor['person']['name'],
|
||||||
|
'specialist' => $specialist,
|
||||||
|
'experience' => $year,
|
||||||
|
'review' => $doctor['person']['review'],
|
||||||
|
'price' => $price,
|
||||||
|
'price_real' => $price
|
||||||
|
];
|
||||||
|
array_push($doctorsLivechat, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hospital List
|
||||||
|
$hospitalList = [];
|
||||||
|
|
||||||
|
$hospitals = Organization::where([
|
||||||
|
'type' => 'hospital',
|
||||||
|
'status' => 'active',
|
||||||
|
])
|
||||||
|
->with('currentAddress')
|
||||||
|
->get()->toArray();
|
||||||
|
foreach($hospitals as $hospital){
|
||||||
|
$lat = 0;
|
||||||
|
$lang = 0;
|
||||||
|
if ($hospital['current_address']['lat']){
|
||||||
|
$lat = $hospital['current_address']['lat'];
|
||||||
|
}
|
||||||
|
if ($hospital['current_address']['lng']){
|
||||||
|
$lang = $hospital['current_address']['lng'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$address = '';
|
||||||
|
if ($hospital['current_address']['text']){
|
||||||
|
$address = $hospital['current_address']['text'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$radius = 0;
|
||||||
|
if ($lat && $lang && $request->longitude && $request->latitude){
|
||||||
|
$radius = round(Helper::calculateDistance($lat, $lang, $request->latitude, $request->longitude), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'name' => $hospital['name'],
|
||||||
|
'radius' => $radius,
|
||||||
|
'image' => '',
|
||||||
|
'address' => $address
|
||||||
|
];
|
||||||
|
|
||||||
|
array_push($hospitalList, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
usort($hospitalList, function($a, $b) {
|
||||||
|
return $a['radius'] <=> $b['radius'];
|
||||||
|
});
|
||||||
|
|
||||||
|
$hospitalList = array_slice($hospitalList, 0, 5);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'id' => $this->nID,
|
||||||
|
'message' => $wellcome,
|
||||||
|
'full_name' => $this->sFirstName . ' '. $this->sLastName,
|
||||||
|
'avatar' => $avatar,
|
||||||
|
// 'member_type' => $this->nIDUser ? 'Dependent' : 'Principal',
|
||||||
|
// 'member_profile' => $dataMemberProfile,
|
||||||
|
'member_id' => $memberId,
|
||||||
|
'linking' => $linking,
|
||||||
|
'doctors_livechat' => [
|
||||||
|
$doctorsLivechat
|
||||||
|
],
|
||||||
|
'hospital' => $hospitalList
|
||||||
|
|
||||||
|
|
||||||
|
// [
|
||||||
|
// [
|
||||||
|
// 'name' => 'PRIMAYA HOSPITAL NORTH BEKASI',
|
||||||
|
// 'image' => '',
|
||||||
|
// 'range' => 6
|
||||||
|
// ],
|
||||||
|
// [
|
||||||
|
// 'name' => 'PRIMAYA HOSPITAL TANGERANG',
|
||||||
|
// 'image' => '',
|
||||||
|
// 'range' => 10
|
||||||
|
// ],
|
||||||
|
// ]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ use Illuminate\Support\Facades\DB;
|
|||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Models\Service;
|
use App\Models\Service;
|
||||||
|
use App\Models\Icd;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
class Helper
|
class Helper
|
||||||
@@ -117,6 +118,16 @@ class Helper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function diagnosisName($code)
|
||||||
|
{
|
||||||
|
$icd = Icd::where('code', $code)->get()->first();
|
||||||
|
if ($icd){
|
||||||
|
return $icd->name;
|
||||||
|
} else {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static function paginateResources($resource)
|
public static function paginateResources($resource)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@@ -443,4 +454,23 @@ class Helper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function calculateDistance($latitudeFrom, $longitudeFrom, $latitudeTo, $longitudeTo, $earthRadius = 6371) {
|
||||||
|
// Convert degrees to radians
|
||||||
|
$latFrom = deg2rad($latitudeFrom);
|
||||||
|
$lonFrom = deg2rad($longitudeFrom);
|
||||||
|
$latTo = deg2rad($latitudeTo);
|
||||||
|
$lonTo = deg2rad($longitudeTo);
|
||||||
|
|
||||||
|
// Calculate the change in coordinates
|
||||||
|
$deltaLat = $latTo - $latFrom;
|
||||||
|
$deltaLon = $lonTo - $lonFrom;
|
||||||
|
|
||||||
|
// Apply Haversine formula
|
||||||
|
$a = sin($deltaLat / 2) * sin($deltaLat / 2) + cos($latFrom) * cos($latTo) * sin($deltaLon / 2) * sin($deltaLon / 2);
|
||||||
|
$c = 2 * atan2(sqrt($a), sqrt(1 - $a));
|
||||||
|
$distance = $earthRadius * $c;
|
||||||
|
|
||||||
|
return $distance;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,12 @@ namespace App\Http\Resources\OLDLMS;
|
|||||||
|
|
||||||
use App\Services\ClaimService;
|
use App\Services\ClaimService;
|
||||||
use App\Models\Corporate;
|
use App\Models\Corporate;
|
||||||
|
use App\Models\CorporateBenefit;
|
||||||
|
use App\Models\RequestLog;
|
||||||
|
use App\Models\RequestLogBenefit;
|
||||||
|
use App\Models\MemberPlan;
|
||||||
|
use App\Helpers\Helper;
|
||||||
|
use Carbon\Carbon;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
|
||||||
@@ -21,7 +27,46 @@ class MemberResource extends JsonResource
|
|||||||
$currentMemberPlan = $this->memberPlans?->first();
|
$currentMemberPlan = $this->memberPlans?->first();
|
||||||
$limitTelecon = $currentMemberPlan->plan->limit_telecon ?? null;
|
$limitTelecon = $currentMemberPlan->plan->limit_telecon ?? null;
|
||||||
$limitTelecon = $this->totalUsage >= 6 ? null : $limitTelecon;
|
$limitTelecon = $this->totalUsage >= 6 ? null : $limitTelecon;
|
||||||
|
$services = MemberPlan::where('member_id', $this->id)->with('plan')->get()->toArray();
|
||||||
|
$dataServices = [];
|
||||||
|
if ($services) {
|
||||||
|
foreach($services as $service) {
|
||||||
|
$serviceName = Helper::serviceName($service['plan']['service_code']);
|
||||||
|
$benefits = CorporateBenefit::where('plan_id', $service['plan_id'])->with('benefit')->get()->toArray();
|
||||||
|
$dataBenefit = [];
|
||||||
|
foreach($benefits as $benefit){
|
||||||
|
$dataBenefitItem = $benefit['benefit']['description'];
|
||||||
|
array_push($dataBenefit, $dataBenefitItem);
|
||||||
|
}
|
||||||
|
$data = [
|
||||||
|
'name' => $serviceName,
|
||||||
|
'benefit' => $dataBenefit
|
||||||
|
];
|
||||||
|
|
||||||
|
array_push($dataServices, $data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// LOG
|
||||||
|
$dataLog = [];
|
||||||
|
$requestLogs = RequestLog::where('member_id', $this->id)->with('organization')->get()->toArray();
|
||||||
|
$totalBenefit = 0;
|
||||||
|
if ($requestLogs) {
|
||||||
|
foreach($requestLogs as $requestLog) {
|
||||||
|
$requestLogBenefit = RequestLogBenefit::where('request_log_id', $requestLog['id'])->sum('amount_approved');
|
||||||
|
$totalBenefit += $requestLogBenefit;
|
||||||
|
$data = [
|
||||||
|
'id' => $requestLog['id'],
|
||||||
|
'code' => $requestLog['code'],
|
||||||
|
'submission_date' => Carbon::parse($requestLog['submission_date'])->format('d M Y H:i:s'),
|
||||||
|
'provider_name' => $requestLog['organization']['name'],
|
||||||
|
'service' => Helper::serviceName($requestLog['service_code'])
|
||||||
|
];
|
||||||
|
|
||||||
|
array_push($dataLog, $data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'member_name' => $this->full_name,
|
'member_name' => $this->full_name,
|
||||||
@@ -33,6 +78,9 @@ class MemberResource extends JsonResource
|
|||||||
'start_date' => $this->members_effective_date,
|
'start_date' => $this->members_effective_date,
|
||||||
'corporate_logo' => $_ENV['LMS_APP_STORAGE'] . $this->corporateLogo,
|
'corporate_logo' => $_ENV['LMS_APP_STORAGE'] . $this->corporateLogo,
|
||||||
'valid_until' => $this->members_expire_date,
|
'valid_until' => $this->members_expire_date,
|
||||||
|
'total_benefit_usage' => $totalBenefit,
|
||||||
|
'service' => $dataServices,
|
||||||
|
'histor_log' => $dataLog
|
||||||
|
|
||||||
];
|
];
|
||||||
return $data;
|
return $data;
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ class Person extends Model
|
|||||||
'birth_date',
|
'birth_date',
|
||||||
'birth_place',
|
'birth_place',
|
||||||
'language',
|
'language',
|
||||||
|
'isOnline',
|
||||||
|
'review',
|
||||||
'race',
|
'race',
|
||||||
'citizenship',
|
'citizenship',
|
||||||
'current_employment',
|
'current_employment',
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('benefits', function (Blueprint $table) {
|
||||||
|
$table->integer('type')->nullable()->default(1)->comment('1=Non COB, 2=Cob');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('benefits', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('type');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('persons', function (Blueprint $table) {
|
||||||
|
$table->dateTime('start_date_work')->nullable()->after('birth_place');
|
||||||
|
$table->integer('isOnline')
|
||||||
|
->default(0)
|
||||||
|
->comment('0=offline, 1=online')
|
||||||
|
->after('start_date_work');
|
||||||
|
$table->double('review')->after('isOnline');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('persons', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('start_date_work');
|
||||||
|
$table->dropColumn('isOnline');
|
||||||
|
$table->dropColumn('review');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('practitioner_roles', function (Blueprint $table) {
|
||||||
|
$table->integer('price')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('practitioner_roles', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('price');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user