Merge remote-tracking branch 'origin/staging' into origin/production
This commit is contained in:
@@ -34,24 +34,51 @@ class AuthController extends Controller
|
||||
|
||||
return Helper::responseJson(statusCode: Response::HTTP_NOT_FOUND, message: $message);
|
||||
}
|
||||
|
||||
|
||||
// $token = rand(1000, 9999); // Menghasilkan angka acak antara 100000 dan 999999
|
||||
$token = 4444; // Menghasilkan angka acak antara 100000 dan 999999
|
||||
if($request->phoneOrEmail == 'manager+one@gmail.com' || $request->phoneOrEmail == 'manager+two@gmail.com')
|
||||
{
|
||||
$token = 4444;
|
||||
}
|
||||
if (filter_var($request->phoneOrEmail, FILTER_VALIDATE_EMAIL)) {
|
||||
User::query()->find($user->id)->update([
|
||||
'email' => $request->phoneOrEmail,
|
||||
'otp' => $token,
|
||||
'otp_created_at' => now()
|
||||
]);
|
||||
} else {
|
||||
User::query()->find($user->id)->update([
|
||||
'phone' => $request->phoneOrEmail,
|
||||
'otp' => $token,
|
||||
'otp_created_at' => now()
|
||||
]);
|
||||
// if($request->phoneOrEmail == 'manager+one@gmail.com' || $request->phoneOrEmail == 'manager+two@gmail.com')
|
||||
// {
|
||||
// $token = 4444;
|
||||
// }
|
||||
// if (filter_var($request->phoneOrEmail, FILTER_VALIDATE_EMAIL)) {
|
||||
// User::query()->find($user->id)->update([
|
||||
// 'email' => $request->phoneOrEmail,
|
||||
// 'otp' => $token,
|
||||
// 'otp_created_at' => now()
|
||||
// ]);
|
||||
// } else {
|
||||
// User::query()->find($user->id)->update([
|
||||
// 'phone' => $request->phoneOrEmail,
|
||||
// 'otp' => $token,
|
||||
// 'otp_created_at' => now()
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// // TODO Send the OTP
|
||||
// if (filter_var($request->phoneOrEmail, FILTER_VALIDATE_EMAIL)) {
|
||||
// // Send Email
|
||||
// //send to alarm
|
||||
// if($request->phoneOrEmail != 'manager+one@gmail.com' && $request->phoneOrEmail != 'manager+two@gmail.com')
|
||||
// {
|
||||
// $nameTo = 'User';
|
||||
// $dataEmail = [
|
||||
// 'email' => $request->phoneOrEmail,
|
||||
// 'name' => $nameTo,
|
||||
// 'subject' => 'OTP Login Client Portal Tanggal '. date('Y-m-d H:i:s'),
|
||||
// 'body' => View::make('email/forgot_password', ['token' => $token])->render(),
|
||||
// ];
|
||||
// Helper::sendEmail($dataEmail);
|
||||
// }
|
||||
// } else {
|
||||
// // Send Whatsapp
|
||||
// }
|
||||
|
||||
// return Helper::responseJson(message: 'OTP Terkirim');
|
||||
|
||||
|
||||
if (!Hash::check($request->password, $user->password)) {
|
||||
return response(['message' => 'Password Salah'], 403);
|
||||
}
|
||||
|
||||
return Helper::responseJson(
|
||||
|
||||
93
Modules/HospitalPortal/Helpers/GrabHelper.php
Normal file
93
Modules/HospitalPortal/Helpers/GrabHelper.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\HospitalPortal\Helpers;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Psr7\Request;
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
|
||||
class GrabHelper
|
||||
{
|
||||
protected $client;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->client = new Client();
|
||||
}
|
||||
|
||||
public function getToken()
|
||||
{
|
||||
$url = env('TOKEN_URL_GRAB');
|
||||
$headers = [
|
||||
'Content-Type' => 'application/json',
|
||||
];
|
||||
$body = json_encode([
|
||||
'client_id' => env('CLIENT_ID_GRAB'),
|
||||
'client_secret' => env('CLIENT_SECRET_GRAB'),
|
||||
'grant_type' => 'client_credentials',
|
||||
'scope' => 'grab_express.partner_deliveries',
|
||||
]);
|
||||
|
||||
$request = new Request('POST', $url, $headers, $body);
|
||||
$response = $this->client->send($request);
|
||||
$data = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
return $data['access_token'] ?? null;
|
||||
}
|
||||
|
||||
public function createDelivery($token,$body)
|
||||
{
|
||||
$url = env('BASE_URL_GRAB').'/v1/deliveries';
|
||||
$headers = [
|
||||
'Content-Type' => 'application/json',
|
||||
'Authorization' => 'Bearer ' . $token,
|
||||
];
|
||||
$request = new Request('POST', $url, $headers, $body);
|
||||
$response = $this->client->send($request);
|
||||
|
||||
return $response->getBody()->getContents();
|
||||
}
|
||||
|
||||
public function normalizePhoneNumber($phoneNumber) {
|
||||
// Remove any non-digit characters (e.g., '+', '-', spaces)
|
||||
$phoneNumber = preg_replace('/\D/', '', $phoneNumber);
|
||||
|
||||
// Check if the cleaned phone number is numeric
|
||||
if (!is_numeric($phoneNumber)) {
|
||||
return null; // Return false or handle the error as needed
|
||||
}
|
||||
|
||||
// Handle phone numbers starting with '62' or '+62'
|
||||
if (substr($phoneNumber, 0, 2) === '62') {
|
||||
$phoneNumber = '0' . substr($phoneNumber, 2);
|
||||
}
|
||||
|
||||
// Handle phone numbers that already start with '8'
|
||||
if (substr($phoneNumber, 0, 1) === '8') {
|
||||
$phoneNumber = '0' . $phoneNumber;
|
||||
}
|
||||
|
||||
return $phoneNumber;
|
||||
}
|
||||
|
||||
public function getScheduleTimes()
|
||||
{
|
||||
// Create a DateTime object for the current time in Jakarta timezone
|
||||
$pickupTimeFrom = new DateTime('now', new DateTimeZone('Asia/Jakarta'));
|
||||
|
||||
// Add 30 minutes to the current time for pickupTimeFrom
|
||||
$pickupTimeFrom->modify('+30 minutes');
|
||||
|
||||
// Clone the pickupTimeFrom to calculate pickupTimeTo
|
||||
$pickupTimeTo = clone $pickupTimeFrom;
|
||||
// Add 1 hour to pickupTimeFrom for pickupTimeTo
|
||||
$pickupTimeTo->modify('+1 hour');
|
||||
|
||||
// Format the times to ISO 8601 format (e.g., 2024-10-02T12:37:28+07:00)
|
||||
return [
|
||||
"pickupTimeFrom" => $pickupTimeFrom->format(DateTime::ATOM),
|
||||
"pickupTimeTo" => $pickupTimeTo->format(DateTime::ATOM),
|
||||
];
|
||||
}
|
||||
}
|
||||
695
Modules/HospitalPortal/Http/Controllers/ApotekController.php
Normal file
695
Modules/HospitalPortal/Http/Controllers/ApotekController.php
Normal file
@@ -0,0 +1,695 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\HospitalPortal\Http\Controllers;
|
||||
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use App\Helpers\Helper;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Modules\HospitalPortal\Helpers\ApiResponse;
|
||||
use Modules\HospitalPortal\Helpers\GrabHelper;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Ramsey\Uuid\Exception\UnsatisfiedDependencyException;
|
||||
|
||||
class ApotekController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$limit = $request->has('per_page') ? $request->input('per_page') : 10;
|
||||
|
||||
$results = DB::connection('oldlms')->table('tx_prescriptions')
|
||||
->join('tx_prescription_orders', 'tx_prescription_orders.nIDPrescription', '=', 'tx_prescriptions.nID')
|
||||
->join('tm_users', 'tm_users.nID', '=', 'tx_prescriptions.nIDUser')
|
||||
->when(auth()->user()->organization_id, function ($query, $organizationId) {
|
||||
$query->where('tx_prescription_orders.nIDApotek', '=', $organizationId);
|
||||
})
|
||||
->when($request->input('search'), function ($query, $search) {
|
||||
$query->where(function ($query) use ($search) {
|
||||
$query->orWhere('tx_prescriptions.sKodeResep', 'like', "%" . $search . "%")
|
||||
->orWhere('tm_users.sFirstName', 'like', "%" . $search . "%");
|
||||
});
|
||||
})
|
||||
->when($request->has('orderBy'), function ($query) use ($request) {
|
||||
$orderBy = $request->orderBy;
|
||||
$direction = $request->order ?? 'asc';
|
||||
|
||||
if($orderBy == 'apotek')
|
||||
{
|
||||
$orderBy = 'nIDApotek';
|
||||
}
|
||||
|
||||
$query->orderBy($orderBy, $direction);
|
||||
})
|
||||
->when($request->input('start_date') && !$request->input('end_date'), function ($query, $start_date) {
|
||||
$query->where(function ($query) use ($start_date) {
|
||||
$query->where('tx_prescriptions.dTanggalresep', '<', $start_date);
|
||||
});
|
||||
})
|
||||
->when($request->input('status'), function ($query, $status) {
|
||||
$query->where(function ($query) use ($status) {
|
||||
$query->where('tx_prescription_orders.sStatus', '=', $status);
|
||||
});
|
||||
})
|
||||
->select(
|
||||
'tx_prescriptions.nID as id',
|
||||
'tx_prescription_orders.nID as nID_orders',
|
||||
'tx_prescriptions.nIDUser',
|
||||
'tx_prescriptions.sKodeResep as no_resep',
|
||||
'tx_prescriptions.dTanggalResep as tanggal',
|
||||
'tx_prescription_orders.nIDApotek',
|
||||
'tx_prescription_orders.sStatus as status',
|
||||
'tx_prescription_orders.sStatus',
|
||||
DB::raw('
|
||||
CASE
|
||||
WHEN tx_prescription_orders.sStatus = "waiting_pharmacy" THEN "Diterima"
|
||||
WHEN tx_prescription_orders.sStatus = "order_prepared" THEN "Siap Diambil"
|
||||
WHEN tx_prescription_orders.sStatus = "ready" THEN "Cari Kurir"
|
||||
WHEN tx_prescription_orders.sStatus = "failed" THEN "Cari Kurir"
|
||||
WHEN tx_prescription_orders.sStatus = "waiting_for_courir" THEN "Kurir Sudah Ambil Pesanan"
|
||||
WHEN tx_prescription_orders.sStatus = "package_picked_up" THEN "Sedang diantar ke Alamat Tujuan"
|
||||
WHEN tx_prescription_orders.sStatus = "package_on_delivery" THEN "Selesai"
|
||||
ELSE ""
|
||||
END AS button_accept'),
|
||||
DB::raw('CONCAT(
|
||||
COALESCE(tm_users.sFirstName, ""),
|
||||
" ",
|
||||
COALESCE(tm_users.sMiddleName, ""),
|
||||
" ",
|
||||
COALESCE(tm_users.sLastName, "")
|
||||
) as pasien'),
|
||||
DB::raw('
|
||||
(SELECT CONCAT(
|
||||
COALESCE(u.sFirstName, ""),
|
||||
" ",
|
||||
COALESCE(u.sMiddleName, ""),
|
||||
" ",
|
||||
COALESCE(u.sLastName, "")
|
||||
)
|
||||
FROM tm_dokter d
|
||||
LEFT JOIN tm_users u ON u.nID = d.nIDUser
|
||||
WHERE d.nID = tx_prescriptions.nIDDokter LIMIT 1) AS nama_dokter
|
||||
'),
|
||||
DB::raw('
|
||||
(SELECT s.sSpesialis
|
||||
FROM tm_dokter d
|
||||
LEFT JOIN tm_spesialis s ON s.nID = d.nIDSpesialis
|
||||
WHERE d.nID = tx_prescriptions.nIDDokter LIMIT 1) AS spesialis
|
||||
'),
|
||||
DB::raw('
|
||||
(SELECT t.sSIP
|
||||
FROM tm_dokter d
|
||||
LEFT JOIN tx_jadwal_dokter t ON t.nIDDokter = d.nID
|
||||
WHERE d.nID = tx_prescriptions.nIDDokter LIMIT 1) AS sip
|
||||
'),
|
||||
DB::raw('
|
||||
(SELECT u.sPhone
|
||||
FROM tm_dokter d
|
||||
LEFT JOIN tm_users u ON u.nID = d.nIDUser
|
||||
WHERE d.nID = tx_prescriptions.nIDDokter LIMIT 1) AS no_ponsel_dokter
|
||||
'),
|
||||
DB::raw('
|
||||
(SELECT tm_users_detail.dTanggalLahir
|
||||
FROM tm_users_detail
|
||||
WHERE tm_users_detail.nIDUser = tm_users.nID LIMIT 1) AS tgl_lahir_pasien
|
||||
'),
|
||||
DB::raw('
|
||||
(SELECT CASE
|
||||
WHEN tm_users_detail.nIDJenisKelamin = 1 THEN "Male"
|
||||
ELSE "Female"
|
||||
END
|
||||
FROM tm_users_detail
|
||||
WHERE tm_users_detail.nIDUser = tm_users.nID LIMIT 1) AS jenis_kelamin_pasien
|
||||
'),
|
||||
DB::raw('
|
||||
(SELECT CONCAT(tm_users_detail.sHeight, "/", tm_users_detail.sWeight)
|
||||
FROM tm_users_detail
|
||||
WHERE tm_users_detail.nIDUser = tm_users.nID LIMIT 1) AS tinggi_berat
|
||||
'),
|
||||
DB::raw('
|
||||
(SELECT tm_users_insurance.sNoPolis
|
||||
FROM tm_users_insurance
|
||||
LEFT JOIN tm_insurance ON tm_users_insurance.nIDInsurance = tm_insurance.nID
|
||||
WHERE tm_users_insurance.nIDUser = tx_prescriptions.nIDUser LIMIT 1) AS no_polis
|
||||
'),
|
||||
DB::raw('
|
||||
(SELECT tm_insurance.sInsurance
|
||||
FROM tm_users_insurance
|
||||
LEFT JOIN tm_insurance ON tm_users_insurance.nIDInsurance = tm_insurance.nID
|
||||
WHERE tm_users_insurance.nIDUser = tx_prescriptions.nIDUser LIMIT 1) AS perusahaan_asuransi
|
||||
'),
|
||||
DB::raw('
|
||||
(SELECT tm_users_insurance.sCorporateName
|
||||
FROM tm_users_insurance
|
||||
LEFT JOIN tm_insurance ON tm_users_insurance.nIDInsurance = tm_insurance.nID
|
||||
WHERE tm_users_insurance.nIDUser = tx_prescriptions.nIDUser LIMIT 1) AS nama_perusahaan
|
||||
'),
|
||||
DB::raw('
|
||||
(SELECT tm_users_insurance.sProductCode
|
||||
FROM tm_users_insurance
|
||||
LEFT JOIN tm_insurance ON tm_users_insurance.nIDInsurance = tm_insurance.nID
|
||||
WHERE tm_users_insurance.nIDUser = tx_prescriptions.nIDUser LIMIT 1) AS kode_produk
|
||||
'),
|
||||
DB::raw('
|
||||
(
|
||||
SELECT
|
||||
CASE
|
||||
WHEN tm_users_insurance.sPlanCode = "A" THEN "Alba"
|
||||
WHEN tm_users_insurance.sPlanCode = "B" THEN "Blue"
|
||||
WHEN tm_users_insurance.sPlanCode = "S" THEN "Silver"
|
||||
WHEN tm_users_insurance.sPlanCode = "G" THEN "Gold"
|
||||
WHEN tm_users_insurance.sPlanCode = "P" THEN "Platinum"
|
||||
WHEN tm_users_insurance.sPlanCode = "D" THEN "Diamond"
|
||||
ELSE ""
|
||||
END AS kelas_asuransi
|
||||
FROM tm_users_insurance
|
||||
LEFT JOIN tm_insurance ON tm_users_insurance.nIDInsurance = tm_insurance.nID
|
||||
WHERE tm_users_insurance.nIDUser = tx_prescriptions.nIDUser
|
||||
LIMIT 1
|
||||
) AS kelas_asuransi
|
||||
'),
|
||||
DB::raw('
|
||||
(
|
||||
SELECT
|
||||
CASE
|
||||
WHEN tm_hubungan_keluarga.sHubunganKeluarga = "Husband" THEN "S"
|
||||
WHEN tm_hubungan_keluarga.sHubunganKeluarga = "Wife" THEN "I"
|
||||
WHEN tm_hubungan_keluarga.sHubunganKeluarga = "Child" THEN "A"
|
||||
ELSE "P"
|
||||
END AS tipe_member
|
||||
FROM tm_hubungan_keluarga
|
||||
WHERE tm_hubungan_keluarga.nID = tm_users.nIDHubunganKeluarga
|
||||
LIMIT 1
|
||||
) AS tipe_member
|
||||
'),
|
||||
'tx_prescription_orders.sAddress AS alamat_penerima',
|
||||
'tx_prescription_orders.sDeliveryMethod AS pengiriman',
|
||||
'tx_prescription_orders.sDeliveryPrice AS total_kirim',
|
||||
'tx_prescriptions.sNoRefProvider AS noref_dokter',
|
||||
DB::raw('DATE_ADD(tx_prescriptions.dTanggalResep, INTERVAL 1 DAY) as valid_tanggal'),
|
||||
'tx_prescriptions.sNomorPenjamin AS nomor_penjamin',
|
||||
DB::raw('
|
||||
(SELECT tx_livechat.dCreateOn
|
||||
FROM tx_livechat
|
||||
WHERE tx_livechat.nID = tx_prescriptions.nIDLivechat LIMIT 1) AS tgl_livechat
|
||||
'),
|
||||
'tx_prescriptions.sDiagnose as diagnosa',
|
||||
'tx_prescription_orders.nDeliveryID',
|
||||
'tx_prescription_orders.sDeliveryStatus'
|
||||
)
|
||||
->paginate($limit);
|
||||
|
||||
// Secret key for generating the token
|
||||
$secret_key = env('SECRET_KEY_LMS');
|
||||
|
||||
// Transform the results to include the download link
|
||||
$results->getCollection()->transform(function ($item) use ($secret_key) {
|
||||
// Generate the token with the timestamp
|
||||
$expiry_time = time() + 86400; // Token expiry time (1 day)
|
||||
$token = hash_hmac('sha256', $item->id . $expiry_time, $secret_key);
|
||||
|
||||
// Construct the download link
|
||||
$path = 'prescription/barcode-print-pdf/' . $item->id . '?token=' . urlencode($token) . '&expiry=' . $expiry_time;
|
||||
$host = $_SERVER['HTTP_HOST']; // This will give you the host like 'linksehat.dev' or 'linksehat.com'
|
||||
$base_url = "https://m.linksehat.dev/";
|
||||
// Check if the host contains '.dev'
|
||||
if (strpos($host, '.com') !== false) {
|
||||
$base_url = "https://m.linksehat.com/";
|
||||
}
|
||||
$item->link_download = $base_url.$path;
|
||||
|
||||
return $item;
|
||||
});
|
||||
|
||||
$apotekIds = $results->pluck(value: 'nIDApotek')->unique()->filter();
|
||||
$organizations = DB::connection('mysql')->table('organizations')
|
||||
->whereIn('id', $apotekIds)
|
||||
->pluck('name', 'id');
|
||||
$results->getCollection()->transform(function ($item) use ($organizations) {
|
||||
$item->apotek = $organizations->get($item->nIDApotek, '-'); // Default to 'Unknown' if not found
|
||||
return $item;
|
||||
});
|
||||
// Transform results to include allergies
|
||||
$results->getCollection()->transform(function ($item) use ($organizations) {
|
||||
// Get the allergies for each user
|
||||
$allergies = $this->getAllergies($item->nIDUser);
|
||||
|
||||
// Concatenate the allergy description
|
||||
$alergi_desc = '';
|
||||
foreach ($allergies as $row) {
|
||||
$alergi_desc .= $row->sAlergi . ' - ' . $row->sKeterangan . ', ';
|
||||
}
|
||||
|
||||
// Set apotek and allergies data
|
||||
$item->apotek = $organizations->get($item->nIDApotek, '-'); // Default to 'Unknown' if not found
|
||||
$item->alergi_desc = rtrim($alergi_desc, ', '); // Remove the trailing comma
|
||||
|
||||
return $item;
|
||||
});
|
||||
// Extract unique Prescription IDs from the results
|
||||
$prescriptionIDs = $results->pluck('id')->unique()->filter();
|
||||
|
||||
// Fetch prescription items based on Prescription IDs
|
||||
$items = DB::connection('oldlms')->table('tx_prescription_items')
|
||||
->whereIn('nIDPrescription', $prescriptionIDs)
|
||||
->select('nIDPrescription', 'sItemName', 'sSigna', 'sTiming', 'sDuration', 'nQty', 'sNote')
|
||||
->get()
|
||||
->groupBy('nIDPrescription'); // Group items by their Prescription ID
|
||||
// Final transformation: Attach prescription items to each prescription
|
||||
$results->getCollection()->transform(function ($item) use ($items) {
|
||||
$item->prescription_items = $items->get($item->id, collect())->map(function ($prescriptionItem) {
|
||||
return [
|
||||
'sItemName' => $prescriptionItem->sItemName,
|
||||
'sSigna' => $prescriptionItem->sSigna,
|
||||
'sTiming' => $prescriptionItem->sTiming,
|
||||
'sDuration' => $prescriptionItem->sDuration,
|
||||
'nQty' => $prescriptionItem->nQty,
|
||||
'sNote' => $prescriptionItem->sNote,
|
||||
];
|
||||
});
|
||||
return $item;
|
||||
});
|
||||
return response()->json(Helper::paginateResources($results));
|
||||
}
|
||||
|
||||
public function getAllergies($nIDUser) {
|
||||
return DB::connection('oldlms')
|
||||
->table('tx_alergi_users as txa')
|
||||
->join('tm_alergi as ta', 'ta.nID', '=', 'txa.nIDAlergi')
|
||||
->select('ta.sAlergi', 'ta.sKeterangan')
|
||||
->where('txa.nIDUser', $nIDUser)
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('hospitalportal::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
* @param Request $request
|
||||
* @return Renderable
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('hospitalportal::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('hospitalportal::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$data = ['sStatus' => $request->sStatus];
|
||||
$validator = Validator::make($request->all(), [
|
||||
'sStatus' => 'required|string|max:255',
|
||||
], [
|
||||
'sStatus.required' => trans('Validation.required',['attribute' => 'Status']),
|
||||
]);
|
||||
|
||||
if ($validator->fails())
|
||||
{
|
||||
return ApiResponse::apiResponse('Bad Request', $data, $validator->errors(), 400);
|
||||
}
|
||||
else
|
||||
{
|
||||
try {
|
||||
// Define the valid transitions
|
||||
$valid_transitions = [
|
||||
'waiting_for_payment' => 'waiting_pharmacy',
|
||||
'waiting_pharmacy' => 'order_prepared',
|
||||
'order_prepared' => 'ready',
|
||||
'ready' => 'waiting_for_courir',
|
||||
'waiting_for_courir' => 'package_picked_up',
|
||||
'package_picked_up' => 'package_on_delivery',
|
||||
'package_on_delivery' => 'package_delivered'
|
||||
];
|
||||
|
||||
// Get the current status from the request
|
||||
$inputStatus = $request->sStatus;
|
||||
|
||||
// Check if the input status has a valid next status in the map
|
||||
if (isset($valid_transitions[$inputStatus])) {
|
||||
// Get the next status
|
||||
$status = $valid_transitions[$inputStatus];
|
||||
|
||||
// Start the transaction
|
||||
DB::connection('oldlms')->beginTransaction();
|
||||
|
||||
// Update the status in the database
|
||||
DB::connection('oldlms')->table('tx_prescription_orders')
|
||||
->where('tx_prescription_orders.nID', '=', $id)
|
||||
->update([
|
||||
'sStatus' => $status,
|
||||
'sUpdateBy' => auth()->user()->id,
|
||||
'dUpdateOn' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
|
||||
// Insert the log
|
||||
$prescriptionOrder = DB::connection('oldlms')
|
||||
->table('tx_prescription_orders')
|
||||
->where('tx_prescription_orders.nID', '=', $id)
|
||||
->join('tx_delivery_orders', 'tx_delivery_orders.nIDPrescriptionOrder', '=', 'tx_prescription_orders.nID')
|
||||
->select('tx_prescription_orders.*', 'tx_delivery_orders.*', 'tx_delivery_orders.nID as nIDDelivery') // Add specific columns you want to select
|
||||
->first();
|
||||
|
||||
if ($prescriptionOrder) {
|
||||
$createdBy = $prescriptionOrder->sCreateBy;
|
||||
$nIDPrescription = $prescriptionOrder->nIDPrescription;
|
||||
$nIDDeliveryOrder = $prescriptionOrder->nIDDelivery;
|
||||
|
||||
// Insert data into the tx_delivery_log table
|
||||
DB::connection('oldlms')->table('tx_delivery_log')->insert([
|
||||
'sStatus' => $prescriptionOrder->sDeliveryStatus,
|
||||
'sStatusPrescription' => $status,
|
||||
'nIDDeliveryOrder' => $nIDDeliveryOrder,
|
||||
'nIDPrescription' => $nIDPrescription,
|
||||
'dCreatedOn' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
// Commit the transaction
|
||||
DB::connection('oldlms')->commit();
|
||||
|
||||
// Return success response
|
||||
return ApiResponse::apiResponse("Success", $data, trans('Message.success'), 200);
|
||||
} else {
|
||||
// If the input status is not valid, return an error
|
||||
return ApiResponse::apiResponse('Invalid Status', $data, 'The input status is not valid.', 400);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// Rollback the transaction if an error occurs
|
||||
DB::connection('oldlms')->rollBack();
|
||||
|
||||
// Handle error, could log or return as response
|
||||
return ApiResponse::apiResponse('Server Error', $data, $e->getMessage(), 500);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function getDriver(Request $request, $id)
|
||||
{
|
||||
$data = ['sStatus' => $request->sStatus];
|
||||
|
||||
// Validation
|
||||
$validator = Validator::make($request->all(), [
|
||||
'sStatus' => 'required|string|max:255',
|
||||
], [
|
||||
'sStatus.required' => trans('Validation.required', ['attribute' => 'Status']),
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return ApiResponse::apiResponse('Bad Request', $data, $validator->errors(), 400);
|
||||
}
|
||||
|
||||
try {
|
||||
// Fetch prescription data
|
||||
$prescriptions = DB::connection('oldlms')->table('tx_prescription_orders')
|
||||
->leftJoin('tx_prescriptions', 'tx_prescriptions.nID', '=', 'tx_prescription_orders.nIDPrescription')
|
||||
->where('tx_prescription_orders.nID', '=', $id)
|
||||
->select(
|
||||
'tx_prescriptions.nIDUser',
|
||||
'tx_prescriptions.nID as id_prescription',
|
||||
'tx_prescriptions.sKodeResep as merchantOrderID',
|
||||
'tx_prescription_orders.nIDApotek'
|
||||
)
|
||||
->first();
|
||||
|
||||
if (!$prescriptions) {
|
||||
return ApiResponse::apiResponse('Not Found', [], 'Prescription not found', 404);
|
||||
}
|
||||
|
||||
// Fetch prescription items (medicine data)
|
||||
$items = DB::connection('oldlms')->table('tx_prescription_items')
|
||||
->where('nIDPrescription', $prescriptions->id_prescription)
|
||||
->select('nIDPrescription', 'sItemName', 'nQty', 'nHarga')
|
||||
->get();
|
||||
|
||||
$packages = [];
|
||||
foreach ($items as $item) {
|
||||
$packages[] = [
|
||||
'name' => $item->sItemName,
|
||||
'description' => $item->sItemName,
|
||||
'quantity' => (float)$item->nQty,
|
||||
'price' => (float)$item->nHarga,
|
||||
'dimensions' => [
|
||||
'height' => 0,
|
||||
'width' => 0,
|
||||
'depth' => 0,
|
||||
'weight' => 0,
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
// Fetch pharmacy (apotek) data
|
||||
$apotek = DB::connection('mysql')->table('organizations')
|
||||
->leftJoin('addresses', 'addresses.id', '=', 'organizations.main_address_id')
|
||||
->where('organizations.id', '=', $prescriptions->nIDApotek)
|
||||
->select('organizations.name as nama_apotek', 'addresses.text as alamat_apotek', 'addresses.lat', 'addresses.lng')
|
||||
->first();
|
||||
|
||||
// Fetch patient (pasien) data
|
||||
$pasien = DB::connection('oldlms')->table('tm_users')
|
||||
->leftJoin('tm_users_detail', 'tm_users_detail.nIDuser', '=', 'tm_users.nID')
|
||||
->where('tm_users.nID', '=', $prescriptions->nIDUser)
|
||||
->select(
|
||||
DB::raw('CONCAT(
|
||||
COALESCE(tm_users.sFirstName, ""),
|
||||
" ",
|
||||
COALESCE(tm_users.sMiddleName, ""),
|
||||
" ",
|
||||
COALESCE(tm_users.sLastName, "")
|
||||
) as nama_pasien'),
|
||||
'tm_users.sFirstName as firstname',
|
||||
'tm_users.sLastName as lastname',
|
||||
'tm_users.sEmail as email',
|
||||
'tm_users.sPhone as phone',
|
||||
'tm_users_detail.sLatitude as latitude',
|
||||
'tm_users_detail.sLongitude as longitude',
|
||||
DB::raw('(SELECT tm_provinsi.sProvinsi FROM tm_provinsi WHERE tm_provinsi.nID = tm_users_detail.nIDProvinsi LIMIT 1) AS provinsi'),
|
||||
DB::raw('(SELECT tm_kota.sKota FROM tm_kota WHERE tm_kota.nID = tm_users_detail.nIDKota LIMIT 1) AS kota'),
|
||||
DB::raw('(SELECT tm_kecamatan.sKecamatan FROM tm_kecamatan WHERE tm_kecamatan.nID = tm_users_detail.nIDKecamatan LIMIT 1) AS kecamatan'),
|
||||
DB::raw('(SELECT tm_kelurahan.sKelurahan FROM tm_kelurahan WHERE tm_kelurahan.nID = tm_users_detail.nIDKelurahan LIMIT 1) AS kelurahan'),
|
||||
DB::raw('(SELECT tm_kelurahan.nKodePos FROM tm_kelurahan WHERE tm_kelurahan.nID = tm_users_detail.nIDKelurahan LIMIT 1) AS kode_pos')
|
||||
)
|
||||
->first();
|
||||
|
||||
if (!$pasien) {
|
||||
return ApiResponse::apiResponse('Not Found', [], 'Patient not found', 404);
|
||||
}
|
||||
|
||||
if(!$pasien->email)
|
||||
{
|
||||
return ApiResponse::apiResponse('Not Found', [], 'Email Patient not found', 404);
|
||||
}
|
||||
|
||||
if(!$pasien->phone)
|
||||
{
|
||||
return ApiResponse::apiResponse('Not Found', [], 'Phone Patient not found', 404);
|
||||
}
|
||||
|
||||
// Use GrabHelper to handle the API calls
|
||||
$grabHelper = new GrabHelper();
|
||||
$token = $grabHelper->getToken();
|
||||
$serviceType = 'INSTANT';
|
||||
$body = json_encode([
|
||||
"merchantOrderID" => $prescriptions->merchantOrderID,
|
||||
"serviceType" => $serviceType,
|
||||
"vehicleType" => "BIKE",
|
||||
"codType" => "REGULAR",
|
||||
"paymentMethod" => "CASHLESS",
|
||||
"highValue" => false,
|
||||
"packages" => $packages,
|
||||
"origin" => [
|
||||
"address" => $apotek->alamat_apotek,
|
||||
"coordinates" => [
|
||||
"latitude" => (float)$apotek->lat,
|
||||
"longitude" => (float)$apotek->lng
|
||||
]
|
||||
],
|
||||
"destination" => [
|
||||
"address" => "{$pasien->provinsi}, {$pasien->kota}, {$pasien->kecamatan}, {$pasien->kelurahan}, {$pasien->kode_pos}",
|
||||
"coordinates" => [
|
||||
"latitude" => (float)$pasien->latitude,
|
||||
"longitude" => (float)$pasien->longitude
|
||||
]
|
||||
],
|
||||
"recipient" => [
|
||||
"firstName" => $pasien->firstname,
|
||||
"lastName" => $pasien->lastname,
|
||||
"email" => $pasien->email,
|
||||
"phone" => $grabHelper->normalizePhoneNumber($pasien->phone),
|
||||
"smsEnabled" => true
|
||||
],
|
||||
"sender" => [
|
||||
"firstName" => env('SENDER_NAME_GRAB'),
|
||||
"companyName" => env('SENDER_COMPANY_NAME_GRAB'),
|
||||
"email" => env('SENDER_EMAIL_GRAB'),
|
||||
"phone" => env('SENDER_PHONE_GRAB'),
|
||||
"smsEnabled" => true
|
||||
],
|
||||
"schedule" => $grabHelper->getScheduleTimes()
|
||||
]);
|
||||
|
||||
// Create the delivery request
|
||||
$response = $grabHelper->createDelivery($token, $body);
|
||||
$data_grab = json_decode($response, true);
|
||||
|
||||
// Transaction to update status
|
||||
DB::connection('oldlms')->beginTransaction();
|
||||
|
||||
//insert to api logs
|
||||
$data_logs = [
|
||||
'sType' => 'out',
|
||||
'sContext' => 'grab',
|
||||
'sTarget' => 'deliveries/create-grab',
|
||||
'sRequest' => $body,
|
||||
'sResponse' => $response,
|
||||
'sCreateBy' => auth()->user()->id,
|
||||
'dCreateOn' => now(),
|
||||
];
|
||||
|
||||
DB::connection('oldlms')->table('api_logs')
|
||||
->insert($data_logs);
|
||||
|
||||
|
||||
DB::connection('oldlms')->table('tx_prescription_orders')
|
||||
->where('tx_prescription_orders.nID', '=', $id)
|
||||
->update([
|
||||
'nDeliveryID' => $data_grab['deliveryID'],
|
||||
'sDeliveryStatus' => $data_grab['status'],
|
||||
'sStatus' => 'waiting_for_courir',
|
||||
'sUpdateBy' => auth()->user()->id,
|
||||
'dUpdateOn' => now(),
|
||||
]);
|
||||
//insert to delivery order
|
||||
$tm_delivery_statuses = DB::connection('oldlms')->table('tm_delivery_statuses')
|
||||
->where('tm_delivery_statuses.sStatus', 'LIKE', '%' . $data_grab['status'] . '%')
|
||||
->where('tm_delivery_statuses.nIDDelivery', '=', 3)
|
||||
->select('tm_delivery_statuses.sStatusDescription')
|
||||
->first();
|
||||
$data_delivery_orders = [
|
||||
'nIDPrescriptionOrder' => $id,
|
||||
'sUUID' => $this->generateUuid($id),
|
||||
'nIDDelivery' => 3, //grab
|
||||
'sType' => $serviceType,
|
||||
'nOrderID' => $data_grab['deliveryID'],
|
||||
'nVehicleTypeID' => null,
|
||||
'sCreatedDateTime' => $data_grab['schedule']['pickupTimeFrom'],
|
||||
'sFinishDateTime' => $data_grab['schedule']['pickupTimeTo'],
|
||||
'sStatus' => $data_grab['status'],
|
||||
'sStatusDescription' => $tm_delivery_statuses->sStatusDescription,
|
||||
'sMatter' => 'medicine',
|
||||
'nTotalWeightKg' => 0,
|
||||
'nPaymentAmount' => $data_grab['quote']['amount'],
|
||||
'nDeliveryFeeAmount' => $data_grab['quote']['amount'],
|
||||
'sPaymentMethod' => 'cash',
|
||||
'sCreateBy' => auth()->user()->id,
|
||||
'dCreateOn' => now(),
|
||||
];
|
||||
// Use insertGetId to insert the data and get the last inserted ID
|
||||
$lastInsertId = DB::connection('oldlms')->table('tx_delivery_orders')->insertGetId($data_delivery_orders);
|
||||
$data_points = [
|
||||
'origin' => [
|
||||
'nIDDeliveryOrder' => $lastInsertId,
|
||||
'sUUID' => $this->generateUuid($lastInsertId),
|
||||
'nDeliveryID' => $data_grab['deliveryID'],
|
||||
'nPointID' => 1,
|
||||
'nType' => 1,
|
||||
'sAddress' => $data_grab['quote']['origin']['address'],
|
||||
'nLatitude' => $data_grab['quote']['origin']['coordinates']['latitude'] ?? null,
|
||||
'nLongitude' => $data_grab['quote']['origin']['coordinates']['longitude'] ?? null,
|
||||
'sName' => $data_grab['sender']['companyName'],
|
||||
'sPhone' => $data_grab['sender']['phone'],
|
||||
'sTrackingUrl' => null,
|
||||
'sCreateBy' => auth()->user()->id,
|
||||
'dCreateOn' => now(),
|
||||
],
|
||||
'destination' => [
|
||||
'nIDDeliveryOrder' => $lastInsertId,
|
||||
'sUUID' => $this->generateUuid($lastInsertId),
|
||||
'nDeliveryID' => $data_grab['deliveryID'],
|
||||
'nPointID' => 2,
|
||||
'nType' => 2,
|
||||
'sAddress' => $data_grab['quote']['destination']['address'],
|
||||
'nLatitude' => $data_grab['quote']['destination']['coordinates']['latitude'] ?? null,
|
||||
'nLongitude' => $data_grab['quote']['destination']['coordinates']['longitude'] ?? null,
|
||||
'sName' => $data_grab['recipient']['firstName'] . " " . $data_grab['recipient']['lastName'],
|
||||
'sPhone' => $data_grab['recipient']['phone'],
|
||||
'sTrackingUrl' => null,
|
||||
'sCreateBy' => auth()->user()->id,
|
||||
'dCreateOn' => now(),
|
||||
]
|
||||
];
|
||||
|
||||
foreach ($data_points as $value_point) {
|
||||
DB::connection('oldlms')->table('tx_delivery_order_points')->insert($value_point);
|
||||
}
|
||||
|
||||
DB::connection('oldlms')->commit();
|
||||
|
||||
// Return success response
|
||||
return ApiResponse::apiResponse("Success", $data_grab, trans('Message.success'), 200);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
// Rollback transaction on error
|
||||
DB::connection('oldlms')->rollBack();
|
||||
|
||||
return ApiResponse::apiResponse('Server Error', [], $e->getMessage(), 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function generateUuid($id_prescription_order)
|
||||
{
|
||||
// Define the namespace (using DNS in this example)
|
||||
$namespace = Uuid::NAMESPACE_DNS;
|
||||
|
||||
$uuidV5 = Uuid::uuid5($namespace, $id_prescription_order);
|
||||
return $uuidV5->toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,8 +7,10 @@ use Modules\HospitalPortal\Http\Controllers\Api\MemberController;
|
||||
use Modules\HospitalPortal\Http\Controllers\ClaimController;
|
||||
use Modules\HospitalPortal\Http\Controllers\Api\NotificationController;
|
||||
use Modules\HospitalPortal\Http\Controllers\Api\RequestLogController;
|
||||
use Modules\HospitalPortal\Http\Controllers\ApotekController;
|
||||
use Modules\HospitalPortal\Http\Middleware\Authentication;
|
||||
use Modules\HospitalPortal\Http\Middleware\Authorization;
|
||||
use Modules\Internal\Http\Controllers\Api\NavigationController;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -36,6 +38,10 @@ Route::prefix('v1')->group(function() {
|
||||
|
||||
Route::middleware('auth:sanctum')->group(function () {
|
||||
|
||||
// Navigation
|
||||
Route::get('navigations', [NavigationController::class, 'index']);
|
||||
|
||||
|
||||
Route::post('logout', [AuthController::class, 'logout'])->name('logout');
|
||||
Route::get('/user', function (Request $request) {
|
||||
return $request->user();
|
||||
@@ -66,6 +72,9 @@ Route::prefix('v1')->group(function() {
|
||||
//Set read notification
|
||||
Route::post('set-read-notification', 'setReadNotification');
|
||||
});
|
||||
Route::get('get-prescription-orders',[ApotekController::class, 'index']);
|
||||
Route::put('put-prescription-orders/{id}',[ApotekController::class, 'update']);
|
||||
Route::put('put-driver-prescription-orders/{id}',[ApotekController::class, 'getDriver']);
|
||||
});
|
||||
// Request Final LOG
|
||||
Route::controller(RequestLogController::class)->group(function () {
|
||||
|
||||
@@ -26,7 +26,14 @@ class PrescriptionController extends Controller
|
||||
{
|
||||
// return $request->toArray();
|
||||
$prescription = Prescription::query()
|
||||
->with(['livechat', 'user', 'items']);
|
||||
->with(['livechat', 'user', 'items'])
|
||||
->join('tx_prescription_orders', 'tx_prescriptions.nID', '=', 'tx_prescription_orders.nIDPrescription')
|
||||
->select(
|
||||
'tx_prescriptions.*',
|
||||
'tx_prescription_orders.sStatus as status_prescription',
|
||||
'tx_prescription_orders.sAddress as kirim_ke',
|
||||
'tx_prescription_orders.sDeliveryMethod as delivery',
|
||||
);
|
||||
if ($request->has('search')) {
|
||||
$search = $request->search;
|
||||
$prescription->where(function ($query) use ($search) {
|
||||
@@ -34,13 +41,12 @@ class PrescriptionController extends Controller
|
||||
->orWhere('sKodeResep', 'LIKE', '%' . $search . "%");
|
||||
});
|
||||
}
|
||||
|
||||
if (($request->has('prescription_start') || $request->has('prescription_end'))
|
||||
&& !empty($request->prescription_start)
|
||||
&& !empty($request->prescription_end)
|
||||
) {
|
||||
|
||||
|
||||
|
||||
|
||||
$prescription = $prescription->where(function($q) use ($request) {
|
||||
$q->where('dTanggalResep', '>=', $request->prescription_start)
|
||||
->where('dTanggalResep', '<=', $request->prescription_end);
|
||||
@@ -156,6 +162,7 @@ class PrescriptionController extends Controller
|
||||
'Date Consultation',
|
||||
'Patient',
|
||||
'Doctor',
|
||||
'Status',
|
||||
'Jenis Obat (Drugs)',
|
||||
'Jumlah Obat (QTY)',
|
||||
'Cara Minum Obat',
|
||||
@@ -178,7 +185,7 @@ class PrescriptionController extends Controller
|
||||
});
|
||||
}
|
||||
|
||||
if ($request->has('prescription_start') && $request->has('prescription_end') &&
|
||||
if ($request->has('prescription_start') && $request->has('prescription_end') &&
|
||||
!empty($request->prescription_start) && !empty($request->prescription_end)) {
|
||||
$prescriptionQuery->whereBetween('dTanggalResep', [$request->prescription_start, $request->prescription_end]);
|
||||
}
|
||||
|
||||
@@ -88,8 +88,8 @@ class LivechatController extends Controller
|
||||
}
|
||||
})
|
||||
->orderBy('nID', 'desc')
|
||||
->get(['nID', 'nIDUser', 'dRequestTime', 'dAcceptTime', 'dStartTime', 'dEndTime', 'nIDDokter', 'nIDHealthCare', 'nIDAppointment', 'sStatus', 'sMediaDokter', 'sMedia', 'dCreateOn']);
|
||||
|
||||
->get(['nID', 'nIDUser', 'nIDDokter', 'nIDHealthCare', 'nIDAppointment', 'sStatus', 'sMediaDokter', 'sMedia', 'dCreateOn']);
|
||||
|
||||
$headers = [
|
||||
['value' => 'No', 'cell' => 'A1', 'mergeCell' => true, 'mergeToCell' => 'A2'],
|
||||
['value' => 'Kode TC', 'cell' => 'B1', 'mergeCell' => true, 'mergeToCell' => 'B2'],
|
||||
@@ -150,18 +150,18 @@ class LivechatController extends Controller
|
||||
$nIDUser = $liveChat->user->nIDUser ?? 0; // Principal or Dependent
|
||||
$paymentMethod = $liveChat->appointment ? Helper::sPaymentMethod($liveChat->appointment->sPaymentMethod) : 'N/A';
|
||||
$fullNameDoctor = '-';
|
||||
if ($liveChat->doctor->user !== null) {
|
||||
if (!empty($liveChat->doctor->user)) {
|
||||
$fullNameDoctor = '';
|
||||
|
||||
|
||||
if ($liveChat->doctor->user->detail !== null) {
|
||||
if ($liveChat->doctor->user->detail->sTitlePrefix !== null) {
|
||||
$fullNameDoctor .= $liveChat->doctor->user->detail->sTitlePrefix . '. ';
|
||||
}
|
||||
|
||||
|
||||
if ($liveChat->doctor->user->full_name !== null) {
|
||||
$fullNameDoctor .= $liveChat->doctor->user->full_name . ' ';
|
||||
}
|
||||
|
||||
|
||||
if ($liveChat->doctor->user->detail->sTitleSuffix !== null) {
|
||||
$fullNameDoctor .= $liveChat->doctor->user->detail->sTitleSuffix;
|
||||
}
|
||||
@@ -171,7 +171,7 @@ class LivechatController extends Controller
|
||||
$recordType = 'P';
|
||||
if ($nIDUser){
|
||||
$recordType = 'D';
|
||||
}
|
||||
}
|
||||
switch ($status) {
|
||||
case 0:
|
||||
$statusLivechat = "Request TC";
|
||||
|
||||
@@ -54,6 +54,7 @@ class NavigationController extends Controller
|
||||
'permission' => $child['permission'],
|
||||
];
|
||||
}, $navItem['children']),
|
||||
'icon' => $navItem['icon'],
|
||||
'permission' => $navItem['permission'],
|
||||
];
|
||||
}, $navigationMaster)
|
||||
|
||||
@@ -48,6 +48,8 @@ class OrganizationController extends Controller
|
||||
public function store(Request $request)
|
||||
{
|
||||
$organization = [
|
||||
'phone' => $request->no_hp,
|
||||
'email' => $request->email,
|
||||
'code' => $request->code,
|
||||
'name' => $request->name,
|
||||
'type' => 'hospital',
|
||||
@@ -119,6 +121,8 @@ class OrganizationController extends Controller
|
||||
$update_organization = Organization::find($id);
|
||||
|
||||
$update_organization->update([
|
||||
'phone' => $request->no_hp,
|
||||
'email' => $request->email,
|
||||
'code' => $request->code,
|
||||
'name' => $request->name,
|
||||
'type' => 'hospital',
|
||||
@@ -152,7 +156,7 @@ class OrganizationController extends Controller
|
||||
'lat' => $request->lat,
|
||||
'lng' => $request->lng,
|
||||
]);
|
||||
|
||||
|
||||
$update_organization->main_address_id = $newAddres->id;
|
||||
$update_organization->save();
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace Modules\Internal\Http\Controllers\Api;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Organization;
|
||||
use App\Models\CorporateManager;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
@@ -110,14 +112,30 @@ class UserManagementController extends Controller
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
public function list_organization(Request $request)
|
||||
{
|
||||
$query = Organization::where('type', 'hospital')->get();
|
||||
$data = [
|
||||
'data' => $query
|
||||
];
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
public function store_access(Request $request){
|
||||
$user = User::create([
|
||||
'email' => $request->email,
|
||||
'username' => $request->username,
|
||||
'role_id' => $request->roles,
|
||||
'organization_id' => !empty($request->organizations) ? $request->organizations : null ,
|
||||
'password' => Hash::make($request->password),
|
||||
]);
|
||||
|
||||
if ($request->corporates){
|
||||
CorporateManager::create([
|
||||
'user_id' => $user->id,
|
||||
'corporate_id' => $request->corporates
|
||||
]);
|
||||
}
|
||||
$person = Person::updateOrCreate(
|
||||
[
|
||||
'id' => $user->person_id
|
||||
@@ -164,6 +182,7 @@ class UserManagementController extends Controller
|
||||
$userAccess->email = $request->email;
|
||||
$userAccess->username = $request->username;
|
||||
$userAccess->role_id = $request->roles;
|
||||
$userAccess->organization_id = $request->organizations;
|
||||
|
||||
if ($request->password){
|
||||
$userAccess->password = Hash::make($request->password);
|
||||
|
||||
@@ -50,6 +50,7 @@ use Modules\Internal\Http\Controllers\Api\LaboratoriumResultController;
|
||||
use Modules\Internal\Http\Controllers\Api\CorporateManageController;
|
||||
use Modules\Internal\Http\Controllers\Api\UserManagementController;
|
||||
use Modules\Internal\Http\Controllers\ClaimEncounterController;
|
||||
use Modules\Linksehat\Http\Controllers\Api\AutocompleteController;
|
||||
|
||||
// Report
|
||||
use Modules\Internal\Http\Controllers\Api\ReportLogController;
|
||||
@@ -80,9 +81,12 @@ Route::prefix('internal')->group(function () {
|
||||
|
||||
|
||||
Route::get('diagnosis', [RequestLogController::class, 'diagnosis']);
|
||||
Route::get('drugs', [DrugController::class, 'drugList']);
|
||||
Route::get('units', [DrugController::class, 'unitList']);
|
||||
Route::get('cekphp', [RequestLogController::class, 'cekphp']);
|
||||
Route::get('drugs', [AutocompleteController::class, 'drugList']);
|
||||
Route::get('units', [AutocompleteController::class, 'unitList']);
|
||||
|
||||
|
||||
Route::get('signa', [AutocompleteController::class, 'signaList']);
|
||||
Route::post('signa-add', [AutocompleteController::class, 'signaAdd']);
|
||||
|
||||
|
||||
|
||||
@@ -395,6 +399,7 @@ Route::prefix('internal')->group(function () {
|
||||
Route::get('user/access/{id}', [UserManagementController::class, 'edit_access']);
|
||||
Route::put('user/access/{id}', [UserManagementController::class, 'update_access']);
|
||||
Route::get('role-list', [UserManagementController::class, 'list_role']);
|
||||
Route::get('organization-list', [UserManagementController::class, 'list_organization']);
|
||||
|
||||
// Navigation
|
||||
Route::get('navigations', [NavigationController::class, 'index']);
|
||||
|
||||
@@ -27,12 +27,14 @@ class OrganizationResource extends JsonResource
|
||||
}
|
||||
$corporatePartner = implode(', ', $corporateName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
$organization = [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'type' => $this->type,
|
||||
'no_hp' => $this->phone,
|
||||
'email' => $this->email,
|
||||
'code' => $this->code,
|
||||
'description' => $this->description,
|
||||
'kodeRs' => $this->meta->KodeRS ?? null,
|
||||
|
||||
@@ -16,7 +16,6 @@ class ReportPrescriptionResource extends JsonResource
|
||||
public function toArray($request)
|
||||
{
|
||||
$patientName = $this->user ? $this->user->sFirstName .' '. $this->user->sLastName : '-';
|
||||
|
||||
$data = [
|
||||
'id' => $this->nID,
|
||||
'patient_name' => $patientName,
|
||||
@@ -25,6 +24,7 @@ class ReportPrescriptionResource extends JsonResource
|
||||
'date_consultation' => $this->dTanggalResep ? Carbon::parse($this->dTanggalResep)->format('Y-m-d H:i:s') : null,
|
||||
'doctor_name' => $this->sDokterName ? $this->sDokterName : '-',
|
||||
'items' => $this->items ? $this->items : [],
|
||||
'status_prescription' => $this->status_prescription
|
||||
];
|
||||
|
||||
return $data;
|
||||
|
||||
@@ -111,18 +111,23 @@ class AutocompleteController extends Controller {
|
||||
return Helper::responseJson(data: $manipulatedIcds);
|
||||
}
|
||||
|
||||
|
||||
public function drugList(Request $request){
|
||||
|
||||
$drugs = Drug::query()
|
||||
->where([
|
||||
'atc_code' => 'lms', // ini untuk menggunakan list obat yang baru
|
||||
'atc_code' => $request->provider, // ini untuk menggunakan list obat yang baru
|
||||
])
|
||||
->get();
|
||||
|
||||
$manipulatedDrugs = $drugs->map(function ($drug) {
|
||||
// Contoh manipulasi, tambahkan atau ubah properti sesuai kebutuhan
|
||||
return [
|
||||
'value' => $drug->id, // Ganti dengan properti yang sesuai dari model Icd
|
||||
'label' => $drug->name, // Ganti dengan properti yang sesuai dari model Icd
|
||||
'value' => $drug->id,
|
||||
'label' => $drug->name,
|
||||
'code' => $drug->code,
|
||||
'price' => $drug->price,
|
||||
'unit' => $drug->unit,
|
||||
];
|
||||
});
|
||||
return Helper::responseJson(data: $manipulatedDrugs);
|
||||
@@ -142,5 +147,38 @@ class AutocompleteController extends Controller {
|
||||
return Helper::responseJson(data: $manipulatedUnits);
|
||||
}
|
||||
|
||||
public function signaList(Request $request){
|
||||
$signa = DB::connection('oldlms')->table('tm_signa')->get()->toArray();
|
||||
$data = [];
|
||||
|
||||
if ($signa){
|
||||
$temp = [];
|
||||
foreach($signa as $d){
|
||||
$temp['id'] = $d->nID;
|
||||
$temp['value'] = $d->signa;
|
||||
$temp['label'] = $d->signa;
|
||||
|
||||
array_push($data, $temp);
|
||||
}
|
||||
|
||||
}
|
||||
return Helper::responseJson($data);
|
||||
}
|
||||
|
||||
public function signaAdd(Request $request){
|
||||
$validatedData = $request->validate([
|
||||
'signa' => 'required|string|max:255',
|
||||
]);
|
||||
|
||||
// Insert the new signa into the tm_signa table
|
||||
DB::connection('oldlms')->table('tm_signa')->insert([
|
||||
'sStatusPernikahan' => $validatedData['signa']
|
||||
]);
|
||||
|
||||
// Return a success response
|
||||
return Helper::responseJson(['message' => 'Signa added successfully']);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user