65 lines
1.4 KiB
PHP
65 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
use App\Models\PasienModel;
|
|
|
|
class RmController extends BaseController
|
|
{
|
|
public function cek()
|
|
{
|
|
$rm = $this->request->getPost('rm');
|
|
|
|
$db = \Config\Database::connect();
|
|
|
|
$data = $db->table('pasien')
|
|
->where('rm', $rm)
|
|
->get()
|
|
->getRowArray();
|
|
|
|
if ($data) {
|
|
return $this->response->setJSON([
|
|
'status' => 'found',
|
|
'data' => $data
|
|
]);
|
|
}
|
|
|
|
return $this->response->setJSON([
|
|
'status' => 'not_found'
|
|
]);
|
|
}
|
|
|
|
public function search()
|
|
{
|
|
$q = $this->request->getPost('q');
|
|
|
|
$db = \Config\Database::connect();
|
|
|
|
$data = $db->table('pasien')
|
|
->like('rm', $q)
|
|
->orLike('nama', $q)
|
|
->limit(10)
|
|
->get()
|
|
->getResultArray();
|
|
|
|
return $this->response->setJSON([
|
|
'data' => $data
|
|
]);
|
|
}
|
|
|
|
public function link()
|
|
{
|
|
$rm = $this->request->getPost('rm');
|
|
$register_id = $this->request->getPost('register_id');
|
|
|
|
$db = \Config\Database::connect();
|
|
|
|
$db->table('register_ambulans')
|
|
->where('id', $register_id)
|
|
->update(['rm' => $rm]);
|
|
|
|
return $this->response->setJSON([
|
|
'status' => 'success'
|
|
]);
|
|
}
|
|
} |