Merge remote-tracking branch 'origin/staging' into origin/production

This commit is contained in:
Linksehat Staging Server
2024-05-20 08:49:14 +07:00
107 changed files with 9366 additions and 105 deletions

View File

@@ -0,0 +1,44 @@
<?php
namespace App\Events;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class ChatMessageSent implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
/**
* Create a new event instance.
*
* @return void
*/
public $message;
public function __construct($message)
{
$this->message = $message;
$this->dontBroadcastToCurrentUser();
}
/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
{
return new PrivateChannel('chat.' . $this->message->channel_id);
}
public function broadcastAs(): string
{
return 'chat.sent';
}
}

View File

@@ -0,0 +1,167 @@
<?php
namespace App\Helpers;
class DuitkuHelper
{
public static function configuration()
{
$duitkuConfig = new \Duitku\Config(env('API_KEY_DUITKU'), env('CODE_MERCHANT_DUITKU'));
// false for production mode
// true for sandbox mode
$duitkuConfig->setSandboxMode(true);
// set sanitizer (default : true)
$duitkuConfig->setSanitizedMode(false);
// set log parameter (default : true)
$duitkuConfig->setDuitkuLogs(false);
return $duitkuConfig;
}
public static function paymentMethod()
{
$duitkuConfig = self::configuration();
try {
$paymentAmount = "10000"; //"YOUR_AMOUNT";
$paymentMethodList = \Duitku\Pop::getPaymentMethod($paymentAmount, $duitkuConfig);
header('Content-Type: application/json');
return $paymentMethodList;
} catch (Exception $e) {
return $e->getMessage();
}
}
public static function checkStatus($merchantOrderId)
{
$duitkuConfig = self::configuration();
$data = [
'merchantOrderId' => $merchantOrderId
];
try {
$transactionList = \Duitku\Pop::transactionStatus($merchantOrderId, $duitkuConfig);
$transaction = json_decode($transactionList);
if ($transaction->statusCode == "00" || $transaction->statusCode == "01") {
// Transaksi berhasil atau dalam proses
return $transaction;
} else {
// Transaksi gagal atau kedaluwarsa
return ['error' => true];
}
} catch (\Duitku\Exceptions\DuitkuException $e) {
// Tangani pengecualian yang terkait dengan Duitku
return ['error' => true, 'message' => $e->getMessage()];
} catch (Exception $e) {
// Tangani pengecualian umum
return ['error' => true, 'message' => $e->getMessage()];
}
}
public static function createInvoice($data)
{
#CONTOH DARI DUITKU
// $paymentMethod = ""; // PaymentMethod list => https://docs.duitku.com/pop/id/#payment-method
// $paymentAmount = 10000; // Amount
// $email = "customer@gmail.com"; // your customer email
// $phoneNumber = "081234567890"; // your customer phone number (optional)
// $productDetails = "Test Payment";
// $merchantOrderId = "2"; // from merchant, unique
// $additionalParam = ''; // optional
// $merchantUserInfo = ''; // optional
// $customerVaName = 'John Doe'; // display name on bank confirmation display
// $callbackUrl = 'http://YOUR_SERVER/callback'; // url for callback
// $returnUrl = 'http://YOUR_SERVER/return'; // url for redirect
// $expiryPeriod = 60; // set the expired time in minutes
// // Customer Detail
// $firstName = "John";
// $lastName = "Doe";
// // Address
// $alamat = "Jl. Kembangan Raya";
// $city = "Jakarta";
// $postalCode = "11530";
// $countryCode = "ID";
$paymentMethod = $data['paymentMethod']; // PaymentMethod list => https://docs.duitku.com/pop/id/#payment-method
$paymentAmount = $data['paymentAmount']; // Amount
$email = $data['email']; // your customer email
$phoneNumber = $data['phoneNumber']; // your customer phone number (optional)
$productDetails = $data['productDetails'];
$merchantOrderId = $data['merchantOrderId']; // from merchant, unique
$additionalParam = $data['additionalParam']; // optional
$merchantUserInfo = $data['merchantUserInfo']; // optional
$customerVaName = $data['customerVaName']; // display name on bank confirmation display
$callbackUrl = env('DUITKU_PAYMENT_CALLBACK_URL'); // url for callback
$returnUrl = env('APP_URL').'/api/linksehat/redirect-duitku';; // url for redirect
$expiryPeriod = 60; // set the expired time in minutes
// Customer Detail
$firstName = $data['firstName'];
$lastName = $data['lastName'];
// Address
$alamat = $data['alamat'];
$city = $data['city'];
$postalCode = $data['postalCode'];
$countryCode = "ID";
$address = array(
'firstName' => $firstName,
'lastName' => $lastName,
'address' => $alamat,
'city' => $city,
'postalCode' => $postalCode,
'phone' => $phoneNumber,
'countryCode' => $countryCode
);
$customerDetail = array(
'firstName' => $firstName,
'lastName' => $lastName,
'email' => $email,
'phoneNumber' => $phoneNumber,
'billingAddress' => $address,
'shippingAddress' => $address
);
// Item Details
$item1 = array(
'name' => $productDetails,
'price' => $paymentAmount,
'quantity' => 1
);
$itemDetails = array(
$item1
);
$params = array(
'paymentAmount' => $paymentAmount,
'merchantOrderId' => $merchantOrderId,
'productDetails' => $productDetails,
'additionalParam' => $additionalParam,
'merchantUserInfo' => $merchantUserInfo,
'customerVaName' => $customerVaName,
'email' => $email,
'phoneNumber' => $phoneNumber,
'itemDetails' => $itemDetails,
'customerDetail' => $customerDetail,
'callbackUrl' => $callbackUrl,
'returnUrl' => $returnUrl,
'expiryPeriod' => $expiryPeriod
);
$duitkuConfig = self::configuration();
try {
// createInvoice Request
$responseDuitkuPop = \Duitku\Pop::createInvoice($params, $duitkuConfig);
header('Content-Type: application/json');
return json_decode($responseDuitkuPop);
} catch (Exception $e) {
return json_decode($e->getMessage());
}
}
}

View File

@@ -11,6 +11,7 @@ use Illuminate\Support\Facades\DB;
use App\Models\Member;
use App\Models\User;
use App\Models\Service;
use App\Models\Icd;
use DateTime;
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)
{
return [
@@ -258,11 +269,14 @@ class Helper
*
* @param array|object $data
* @param int $statusCode
* @param string $message
* @param string|array|object $message
* @return JsonResponse
*/
public static function responseJson(array|object $data = [], string $status = 'success', int $statusCode = Response::HTTP_OK, string $message = 'Data berhasil di ambil'): JsonResponse
public static function responseJson(array|object $data = [], string $status = 'success', int $statusCode = Response::HTTP_OK, string|array|object $message = 'Data berhasil di ambil'): JsonResponse
{
if ($message instanceof \Illuminate\Support\MessageBag) {
$message = $message->first();
}
return response()->json([
'status' => $status,
'statusCode' => $statusCode,
@@ -377,9 +391,7 @@ class Helper
$mail->send();
return true;
} catch (\Exception $e) {
dd($e);
return ($mail->ErrorInfo);
return false;
return $mail->ErrorInfo;
}
}
@@ -439,8 +451,52 @@ class Helper
}
} else {
// throw new ImportRowException(__('Format Date Invalid'), 0, null, $date_from_row);
return null;
return null;
}
}
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;
}
public static function calculateAge($date_brith_day){
// Konversi tanggal lahir ke dalam format UNIX timestamp
$dob = strtotime($date_brith_day);
// Hitung umur berdasarkan tanggal lahir
$umur = date('Y') - date('Y', $dob);
// Periksa apakah ulang tahun sudah lewat atau belum
if (date('md', $dob) > date('md')) {
$umur--;
}
// Mengembalikan umur dalam format "x years old"
return $umur . ' years old';
}
public static function calculateDateDifference($startDate, $endDate)
{
$start = Carbon::parse($startDate);
$end = Carbon::parse($endDate);
return $start->diffInDays($end) + 1;
}
}

View File

@@ -4,6 +4,12 @@ namespace App\Http\Resources\OLDLMS;
use App\Services\ClaimService;
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;
@@ -21,7 +27,46 @@ class MemberResource extends JsonResource
$currentMemberPlan = $this->memberPlans?->first();
$limitTelecon = $currentMemberPlan->plan->limit_telecon ?? null;
$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 = [
'id' => $this->id,
'member_name' => $this->full_name,
@@ -33,6 +78,9 @@ class MemberResource extends JsonResource
'start_date' => $this->members_effective_date,
'corporate_logo' => $_ENV['LMS_APP_STORAGE'] . $this->corporateLogo,
'valid_until' => $this->members_expire_date,
'total_benefit_usage' => $totalBenefit,
'service' => $dataServices,
'histor_log' => $dataLog
];
return $data;

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Listeners;
use App\Events\ChatMessageSent;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
class ProcessChatMessage
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param object $event
* @return void
*/
public function handle(ChatMessageSent $event)
{
// Proses pesan yang diterima dari event
$message = $event->message;
}
}

17
app/Models/Channel.php Normal file
View File

@@ -0,0 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Channel extends Model
{
use HasFactory;
protected $fillable = [
'name',
'type',
'member_id',
'doctor_id',
];
}

View File

@@ -52,6 +52,7 @@ class File extends Model
'final-log-kondisi' => 'final-log/',
'docs' => 'docs/',
'additional-files' => 'additional-files/',
'chat' => 'chat/',
];
public function fileable()
@@ -89,4 +90,15 @@ class File extends Model
$file->storeAs('public/' . $directory, $fileName . '.' . $extension);
return $path;
}
public static function storeFileChat($type, $id, $file)
{
// $fileName = self::getFileName($type, $id);
$fileName = $file->getClientOriginalName();
$directory = self::getDirectory($type);
$extension = $file->getClientOriginalExtension();
$path = $directory . $fileName . '.' . $extension;
$file->store('public/' .$path);
return $path;
}
}

44
app/Models/Livechat.php Normal file
View File

@@ -0,0 +1,44 @@
<?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 Livechat extends Model
{
use HasFactory, SoftDeletes, Blameable;
protected $fillable = [
'uuid',
'doctor_id',
'patient_id',
'organization_id',
'timezone',
'descriptions',
'payment_method',
'request_date',
'accept_date',
'start_date',
'end_date',
'status',
'subject',
'object',
'assessment',
'plan',
'health_certificate_start',
'health_certificate_end',
];
public function doctor() {
return $this->belongsTo(Person::class, 'doctor_id', 'id');
}
public function practitioner() {
return $this->belongsTo(Practitioner::class, 'doctor_id', 'id');
}
}

25
app/Models/Message.php Normal file
View File

@@ -0,0 +1,25 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Message extends Model
{
use HasFactory;
protected $connection = 'mysql';
protected $fillable = [
'user_id',
'channel_id',
'content',
'type',
'from_user'
];
public function files()
{
return $this->morphMany(File::class, 'fileable')->whereNull('deleted_at');
}
}

View File

@@ -70,4 +70,8 @@ class Livechat extends Model
{
return $this->belongsTo(Healthcare::class, 'nIDHealthCare', 'nID');
}
public function summary(){
return $this->belongsTo(LivechatSummary::class, 'nID', 'nIDLivechat');
}
}

View File

@@ -0,0 +1,40 @@
<?php
namespace App\Models\OLDLMS;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
class LivechatSummary extends Model
{
use HasFactory;
// public $sStatusNames = [
// 0 => 'Menunggu Konfirmasi',
// 1 => 'Diterima',
// 3 => 'Ditolak',
// 2 => 'Selesai',
// 4 => 'Expired',
// ];
public $sStatusNames = [
0 => 'Request TC',
1 => 'Accepted by Doctor but User not Payment',
3 => 'Decline by Doctor',
2 => 'Payment Success',
4 => 'Payment Expired',
5 => 'Cancel by Patient'
];
const CREATED_AT = 'dCreateOn';
const UPDATED_AT = 'dUpdateOn';
const DELETED_AT = 'dDeleteOn';
protected $connection = 'oldlms';
protected $table = 'tx_livechat_summary';
protected $primaryKey = 'nID';
}

View File

@@ -10,6 +10,20 @@ class Prescription extends Model
{
use HasFactory;
protected $fillable = [
'nIDLivechat',
'nIDLivechatSummary',
'nIDDokter',
'sDokterName',
'dTanggalResep',
'sSource',
'nIDUser',
'sRegID',
'sKodeResep',
'sDiagnose',
'sKodeRS',
];
// public $sStatusNames = [
// 0 => 'Menunggu Konfirmasi',
@@ -27,6 +41,8 @@ class Prescription extends Model
protected $table = 'tx_prescriptions';
protected $primaryKey = 'nID';
// protected $appends = [
// 'status_name',
// ];

View 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 PrescriptionItem extends Model
{
use HasFactory;
protected $fillable = [
'nIDPrescription',
'sItemCode',
'sOriginCode',
'sItemName',
'nQty',
'sSatuan',
'sSigna',
'sNote',
'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_items';
// protected $appends = [
// 'status_name',
// ];
protected $casts = [
'dTanggalResep' => 'datetime',
];
protected $primaryKey = 'nID';
}

View File

@@ -38,6 +38,7 @@ class User extends Authenticatable
'sEmail',
'nIDHubunganKeluarga',
'dUpdateOn',
'sIPAddress',
];
protected function fullName(): Attribute

View File

@@ -0,0 +1,20 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class PaymentsMethods extends Model
{
use HasFactory;
protected $table = 'payment_methods';
protected $fillable = [
'config_pmc_id',
'code',
'name',
'image',
'timeout',
'active'
];
}

View File

@@ -23,6 +23,8 @@ class Person extends Model
'birth_date',
'birth_place',
'language',
'isOnline',
'review',
'race',
'citizenship',
'current_employment',

View File

@@ -0,0 +1,18 @@
<?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 Prescription extends Model
{
use HasFactory;
protected $fillable = [
'livechat_id',
'organization_id',
'icd_code'
];
}

View File

@@ -0,0 +1,20 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class PrescriptionItem extends Model
{
use HasFactory;
protected $fillable = [
'prescription_id',
'drug_id',
'qty',
'unit_id',
'note',
'signa',
'direction'
];
}

View File

@@ -20,6 +20,8 @@ class RequestLog extends Model
public $fillable = [
'uuid',
'invoice_no',
'billing_no',
'submission_date',
'discharge_date',
'member_id',

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class UserChannel extends Model
{
use HasFactory;
protected $connection = 'mysql';
protected $fillable = [
'user_id',
'channel_id',
];
}

View File

@@ -5,6 +5,7 @@ namespace App\Providers;
use App\Events\ClaimApproved;
use App\Listeners\LogClaimJournal;
use App\Listeners\NotifyClaimRequested;
use App\Listeners\ProcessChatMessage;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
@@ -29,6 +30,10 @@ class EventServiceProvider extends ServiceProvider
ClaimApproved::class => [
LogClaimJournal::class,
],
ChatMessageSent::class => [
ProcessChatMessage::class,
],
];

View File

@@ -44,7 +44,7 @@ class Duitku
$merchantUserInfo = ''; // optional
$customerVaName = $patient->name ?? ''; // display name on bank confirmation display
$callbackUrl = env('DUITKU_PAYMENT_CALLBACK_URL'); // url for callback
$returnUrl = 'https://dev-superapp.primaya.id';
$returnUrl = env('');
$expiryPeriod = $paymentMethods->timeout; // set the expired time in minutes
// Customer Detail
@@ -53,9 +53,9 @@ class Duitku
$lastName = $patient->last_name ?? '';
// Address
$alamat = $patient->address->first()->line ?? '';
$alamat = $patient->address?? '';
// dd($alamat);
$city = $patient->address->first()->city->name ?? '';
$city = $patient->city ?? '';
// dd($city);
$postalCode = $patient->postal_code ?? '';
$countryCode = "ID";