add HIS order CRUD
This commit is contained in:
parent
5efe2b1218
commit
12783ee72e
@ -62,10 +62,21 @@ $routes->get('api/dictChapters/index', 'API_DictChapters::index');
|
||||
$routes->POST('api/dictChapters/save', 'API_DictChapters::save');
|
||||
$routes->get('api/dictChapters/detail/(:any)', 'API_DictChapters::detail/$1');
|
||||
|
||||
// API - Orders
|
||||
$routes->POST('api/orders/index', 'API_Orders::index');
|
||||
$routes->POST('api/orders/save', 'API_Orders::save');
|
||||
$routes->get('api/orders/detail/(:any)', 'API_Orders::detail/$1');
|
||||
$routes->get('api/orders/patSearch/(:any)', 'API_Orders::patSearch/$1');
|
||||
$routes->get('api/orders/patDetail/(:any)', 'API_Orders::patDetail/$1');
|
||||
$routes->POST('api/orders/patSave', 'API_Orders::patSave');
|
||||
|
||||
// admin
|
||||
$routes->group('admin', ['filter' => 'role:admin'], static function ($routes) {
|
||||
$routes->get('', 'AdminController::index');
|
||||
$routes->get('dashboard/viewAccess/(:any)', 'AdminController::viewAccess/$1');
|
||||
$routes->get('orders/', 'AdminController::orders_index');
|
||||
$routes->get('orders/create/', 'AdminController::orders_update/0');
|
||||
$routes->get('orders/update/(:any)', 'AdminController::orders_update/$1');
|
||||
$routes->get('userroles/', 'AdminController::userroles_index');
|
||||
$routes->get('users/', 'AdminController::users_index');
|
||||
$routes->get('dictTests/', 'AdminController::dictTests_index');
|
||||
|
||||
116
app/Controllers/API_Orders.php
Normal file
116
app/Controllers/API_Orders.php
Normal file
@ -0,0 +1,116 @@
|
||||
<?php
|
||||
namespace App\Controllers;
|
||||
|
||||
use CodeIgniter\RESTful\ResourceController;
|
||||
|
||||
class API_Orders extends ResourceController {
|
||||
protected $format = 'json';
|
||||
|
||||
public function index() {
|
||||
$db = \Config\Database::connect();
|
||||
$date1 = $this->request->getPost('date1');
|
||||
$date2 = $this->request->getPost('date2');
|
||||
$sql = "select o.VISITNUMBER, o.VISITDATE, o.PAYERNAME, o.TREATDOC, p.PATNUMBER, p.SEX, p.PATNAME,
|
||||
TESTS=stuff(( select ', '+t.HISCODE from
|
||||
( select t.HISCODE from cmod.dbo.CM_HIS_TESTS t
|
||||
where t.ORDERID=o.ORDERID
|
||||
) as T
|
||||
for xml path('')),1,1,'')
|
||||
from cmod.dbo.CM_HIS_ORDERS o
|
||||
left join cmod.dbo.CM_HIS_PATIENTS p on p.PATID=o.PATID";
|
||||
$query = $db->query($sql);
|
||||
$results = $query->getResultArray();
|
||||
$data['data'] = $results;
|
||||
return $this->respond($data,200);
|
||||
}
|
||||
|
||||
public function save() {
|
||||
$db = \Config\Database::connect();
|
||||
//Object { patid: "9", visitnumber: "9989", visitdate: "2024-12-13", treatdoc: "alam", payername: "mala", tests: (2) […] }
|
||||
$orderid = '0';
|
||||
$patid = $this->request->getPost('patid');
|
||||
$visitnumber = $this->request->getPost('visitnumber');
|
||||
$visitdate = $this->request->getPost('visitdate');
|
||||
$treatdoc = $this->request->getPost('treatdoc');
|
||||
$payername = $this->request->getPost('payername');
|
||||
$tests = $this->request->getPost('tests');
|
||||
|
||||
if($orderid == '0') {
|
||||
$sql = "INSERT INTO cmod.dbo.CM_HIS_ORDERS (PATID, VISITNUMBER, VISITDATE, TREATDOC, PAYERNAME)
|
||||
VALUES ('$patid', '$visitnumber', '$visitdate', '$treatdoc', '$payername')";
|
||||
} else {
|
||||
$sql = "UPDATE cmod.dbo.CM_HIS_ORDERS set PATID='$patid', VISITNUMBER='$visitnumber', VISITDATE='$visitdate',
|
||||
TREATDOC='$treatdoc', PAYERNAME='$payername' where ORDERID='$orderid'";
|
||||
}
|
||||
|
||||
// query HIS_ORDERS
|
||||
if( $db->query($sql) ) {
|
||||
if($orderid == '0') {
|
||||
$orderid = $db->insertID();
|
||||
$test = '';
|
||||
foreach($tests as $qtest) { $test .= "('$orderid', '$qtest'),"; }
|
||||
$test = rtrim($test, ",");
|
||||
$sql = "INSERT into cmod.dbo.CM_HIS_TESTS(ORDERID,HISCODE) VALUES $test";
|
||||
}
|
||||
|
||||
// done
|
||||
if( $db->query($sql) ) {
|
||||
return $this->respond(['message' => 'Save Success'],201);
|
||||
} else {
|
||||
$response = [
|
||||
'errors' => $db->errors(),
|
||||
'message' => 'Query test error'
|
||||
];
|
||||
return $this->fail($response , 409);
|
||||
}
|
||||
} else {
|
||||
$response = [
|
||||
'errors' => $db->errors(),
|
||||
'message' => 'Query order error'
|
||||
];
|
||||
return $this->fail($response , 409);
|
||||
}
|
||||
}
|
||||
|
||||
public function patSearch($patnumber) {
|
||||
$db = \Config\Database::connect();
|
||||
$sql = "select * from cmod.dbo.CM_HIS_PATIENTS where PATNUMBER like '%$patnumber%'";
|
||||
$query = $db->query($sql);
|
||||
$results = $query->getResultArray();
|
||||
$data['patients'] = $results;
|
||||
return $this->respond($data,200);
|
||||
}
|
||||
|
||||
public function patDetail($patnumber) {
|
||||
$db = \Config\Database::connect();
|
||||
$sql = "select * from cmod.dbo.CM_HIS_PATIENTS where PATNUMBER='$patnumber'";
|
||||
$query = $db->query($sql);
|
||||
$results = $query->getResultArray();
|
||||
$data['patient'] = $results[0];
|
||||
return $this->respond($data,200);
|
||||
}
|
||||
|
||||
public function patSave() {
|
||||
$db = \Config\Database::connect();
|
||||
$patid = $this->request->getPost('patid');
|
||||
$patnumber = $this->request->getPost('patnumber');
|
||||
$patname = $this->request->getPost('patname');
|
||||
$sex = $this->request->getPost('sex');
|
||||
$birthdate = $this->request->getPost('birthdate');
|
||||
$address = $this->request->getPost('address');
|
||||
$phone = $this->request->getPost('phone');
|
||||
if($patid == 0) {
|
||||
$sql = "INSERT INTO cmod.dbo.CM_HIS_PATIENTS (PATNUMBER, PATNAME, SEX, BIRTHDATE, ADDRESS, PHONE)
|
||||
VALUES ('$patnumber', '$patname', '$sex', '$birthdate', '$address','$phone')";
|
||||
} else {
|
||||
$sql = "update cmod.dbo.CM_HIS_PATIENTS set PATNUMBER='$patnumber', PATNAME='$patname',
|
||||
SEX='$sex', BIRTHDATE='$birthdate', ADDRESS='$address', PHONE='$phone' Where PATID='$patid'";
|
||||
}
|
||||
$query = $db->query($sql);
|
||||
if($patid == 0 ) { $patid = $db->insertID(); }
|
||||
$data['patid'] = $patid;
|
||||
$data['patnumber'] = $patnumber;
|
||||
$data['sql'] = $sql;
|
||||
return $this->respond($data , 200);
|
||||
}
|
||||
}
|
||||
@ -91,4 +91,18 @@ class AdminController extends BaseController {
|
||||
$data['tests'] = $results;
|
||||
return view('admin/dictMappings_index', $data);
|
||||
}
|
||||
|
||||
public function orders_index() {
|
||||
return view('orders_index');
|
||||
}
|
||||
|
||||
public function orders_update($orderid) {
|
||||
$db = \Config\Database::connect();
|
||||
$sql = "select * from cmod.dbo.CM_DICT_MAPPINGS";
|
||||
$query = $db->query($sql);
|
||||
$results = $query->getResultArray();
|
||||
$data['tests'] = $results;
|
||||
$data['orderid'] = $orderid;
|
||||
return view('orders_update', $data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,56 +1,35 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="<?=base_url();?>/assets/favicon.png">
|
||||
<title>Summit CRM</title>
|
||||
<link href="<?=base_url();?>/assets/style.css" rel="stylesheet">
|
||||
<link href="<?=base_url();?>/assets/select2/select2.min.css" rel="stylesheet">
|
||||
<link href="<?=base_url();?>/assets/select2/select2-bootstrap-5-theme.min.css" rel="stylesheet">
|
||||
<style>
|
||||
.select2-results__option { font-size: 0.75rem !important; margin: 5px !important; padding: 5px !important; }
|
||||
li.select2-selection__choice { background-color : #000 !important; padding:5px !improtant; }
|
||||
.select2 {width:100%!important;}
|
||||
</style>
|
||||
<script src="<?=base_url();?>/assets/jquery/jquery.min.js"></script>
|
||||
<script src="<?=base_url();?>/assets/select2/select2.min.js"></script>
|
||||
<?= $this->renderSection('head'); ?>
|
||||
</head>
|
||||
|
||||
<body class="skin-megna-dark fixed-layout">
|
||||
<div class="preloader">
|
||||
<div class="loader">
|
||||
<div class="loader__figure"></div>
|
||||
<p class="loader__label">Summit-CRM</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-wrapper">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
|
||||
<div class="card mt-2">
|
||||
<div class="card-body">
|
||||
<?= $this->renderSection('content'); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
|
||||
<meta name="description" content="" />
|
||||
<meta name="author" content="" />
|
||||
<title>Analis Dashboard</title>
|
||||
<link rel="stylesheet" href="<?=base_url();?>assets/css/icons/font/bootstrap-icons.min.css">
|
||||
<link href="<?=base_url();?>assets/css/styles.css" rel="stylesheet" />
|
||||
<link href="<?=base_url();?>assets/select2/select2.min.css" rel="stylesheet" />
|
||||
<style>
|
||||
.sb-form {
|
||||
min-height:calc(100vh);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<!-- <body class="sb-nav-fixed sb-sidenav-toggled"> -->
|
||||
<body class='sb-form'>
|
||||
<main>
|
||||
<div class="container-fluid px-2 py-2">
|
||||
<?= $this->renderSection('content'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="<?=base_url();?>/assets/bootstrap.bundle.min.js"></script>
|
||||
<script src="<?=base_url();?>/assets/perfect-scrollbar.jquery.min.js"></script>
|
||||
<script src="<?=base_url();?>/assets/app.js"></script>
|
||||
<?= $this->renderSection('script'); ?>
|
||||
<script>
|
||||
$('.select2').select2();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</main>
|
||||
<script src="<?=base_url();?>assets/jquery-3.7.1.min.js"></script>
|
||||
<script src="<?=base_url();?>assets/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="<?=base_url();?>assets/datatables/datatables.min.js"></script>
|
||||
<script src="<?=base_url();?>assets/select2/select2.min.js"></script>
|
||||
<script src="<?=base_url();?>assets/select2/select2.min.js"></script>
|
||||
<script src="<?=base_url();?>assets/js/scripts.js"></script>
|
||||
<?= $this->renderSection('script'); ?>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
56
app/Views/admin/layout/form.php_bak
Normal file
56
app/Views/admin/layout/form.php_bak
Normal file
@ -0,0 +1,56 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="<?=base_url();?>/assets/favicon.png">
|
||||
<title>Summit CRM</title>
|
||||
<link href="<?=base_url();?>/assets/style.css" rel="stylesheet">
|
||||
<link href="<?=base_url();?>/assets/select2/select2.min.css" rel="stylesheet">
|
||||
<link href="<?=base_url();?>/assets/select2/select2-bootstrap-5-theme.min.css" rel="stylesheet">
|
||||
<style>
|
||||
.select2-results__option { font-size: 0.75rem !important; margin: 5px !important; padding: 5px !important; }
|
||||
li.select2-selection__choice { background-color : #000 !important; padding:5px !improtant; }
|
||||
.select2 {width:100%!important;}
|
||||
</style>
|
||||
<script src="<?=base_url();?>/assets/jquery/jquery.min.js"></script>
|
||||
<script src="<?=base_url();?>/assets/select2/select2.min.js"></script>
|
||||
<?= $this->renderSection('head'); ?>
|
||||
</head>
|
||||
|
||||
<body class="skin-megna-dark fixed-layout">
|
||||
<div class="preloader">
|
||||
<div class="loader">
|
||||
<div class="loader__figure"></div>
|
||||
<p class="loader__label">Summit-CRM</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-wrapper">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
|
||||
<div class="card mt-2">
|
||||
<div class="card-body">
|
||||
<?= $this->renderSection('content'); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="<?=base_url();?>/assets/bootstrap.bundle.min.js"></script>
|
||||
<script src="<?=base_url();?>/assets/perfect-scrollbar.jquery.min.js"></script>
|
||||
<script src="<?=base_url();?>/assets/app.js"></script>
|
||||
<?= $this->renderSection('script'); ?>
|
||||
<script>
|
||||
$('.select2').select2();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@ -5,6 +5,9 @@
|
||||
<div class="sb-sidenav-menu-heading">Main</div>
|
||||
<a class="nav-link" href="<?=base_url();?>admin/"><div class="sb-nav-link-icon"><i class="bi bi-speedometer"></i></div>Dashboard</a>
|
||||
<a class="nav-link" href="<?=base_url();?>changePass/"><div class="sb-nav-link-icon"><i class="bi bi-key"></i></div>Change Password</a>
|
||||
<div class="sb-sidenav-menu-heading">Order</div>
|
||||
<a class="nav-link" href="<?=base_url();?>admin/orders/"><div class="sb-nav-link-icon"><i class="bi bi-clipboard-pulse"></i></div>Order List</a>
|
||||
<a class="nav-link" href="#" onclick='createOrder()'><div class="sb-nav-link-icon"><i class="bi bi-clipboard-plus"></i></div>Create Order</a>
|
||||
<div class="sb-sidenav-menu-heading">Administration</div>
|
||||
<a class="nav-link" href="<?=base_url();?>admin/dictMappings/"> <div class="sb-nav-link-icon"><i class="bi bi-diagram-2"></i></div> Dict. Mapping Order </a>
|
||||
<a class="nav-link" href="<?=base_url();?>admin/dictChapters/"> <div class="sb-nav-link-icon"><i class="bi bi-journal-medical"></i></div> Dict. Chapter</a>
|
||||
@ -17,4 +20,11 @@
|
||||
<div class="small">Logged in as: <b>Administrator</b></div>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function createOrder() {
|
||||
window.open("<?php echo base_url();echo $_SESSION['userrole']?>/orders/create",
|
||||
'_blank', "width=1200,height=700,location=no,toolbar=no,menubar=no"
|
||||
);
|
||||
}
|
||||
</script>
|
||||
82
app/Views/orders_index.php
Normal file
82
app/Views/orders_index.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?= $this->extend($_SESSION['userrole'].'/layout/main.php') ?>
|
||||
|
||||
<?= $this->section('content') ?>
|
||||
<div class="card border-0">
|
||||
<div class="card-body">
|
||||
<div class='card-title'>Order List</div>
|
||||
<div class="row g-3 justify-content-between align-items-end">
|
||||
<div class='col col-auto'>
|
||||
<button class='btn btn-sm btn-success' onclick='create()'><i class="bi bi-plus-circle"></i> New Order</button>
|
||||
</div>
|
||||
<div class="col col-auto">
|
||||
<b>Date</b> <input class='date1' type='date' value=''> - <input class='date2' type='date'> <button class='btn btn-sm btn-primary' onclick='index()'><i class="bi bi-calendar2-event"></i> Filter</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table id="myTable" class="table">
|
||||
<thead>
|
||||
<th>VisitDate</th>
|
||||
<th>Visit#</th>
|
||||
<th>MR#</th>
|
||||
<th>Patient Name</th>
|
||||
<th>Payer Name</th>
|
||||
<th>Test</th>
|
||||
</thead>
|
||||
<tbody id="table-body">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="modal_orderdetail" aria-hidden="true" tabindex="-1">
|
||||
<div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable">
|
||||
<div class="modal-content">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
<?= $this->section('script') ?>
|
||||
<script>
|
||||
let curDate = new Date().toJSON().slice(0, 10);
|
||||
$('.date1').val(curDate);
|
||||
$('.date2').val(curDate);
|
||||
index();
|
||||
|
||||
function index() {
|
||||
let url = '<?=base_url('');?>api/orders/index';
|
||||
date1 = $('.date1').val();
|
||||
date2 = $('.date2').val();
|
||||
$.ajax({
|
||||
url: url,
|
||||
method: 'POST',
|
||||
data : {date1:date1, date2:date2},
|
||||
success: function(response) {
|
||||
$("#table-body").html("");
|
||||
var data = response['data'];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
visitdate = data[i].VISITDATE;
|
||||
visitnumber = data[i].VISITNUMBER;
|
||||
patnumber = data[i].PATNUMBER;
|
||||
patname = data[i].PATNAME;
|
||||
payername = data[i].PAYERNAME;
|
||||
tests = data[i].TESTS;
|
||||
let datarow = '<tr class="align-middle">' +
|
||||
'<td>' + visitdate + '</td> <td>' + visitnumber + '</td> <td>' + patnumber + '</td> <td>' + patname +
|
||||
'</td> <td>' + payername + '</td> <td>' + tests + '</td>' + '</tr>';
|
||||
$("#table-body").append(datarow);
|
||||
}
|
||||
//$('#myTable').DataTable();
|
||||
},
|
||||
error: function(response) { console.log(response.responseJSON); }
|
||||
});
|
||||
}
|
||||
|
||||
function create() {
|
||||
window.open("<?php echo base_url();echo $_SESSION['userrole']?>/orders/create",
|
||||
'_blank', "width=1200,height=700,location=no,toolbar=no,menubar=no"
|
||||
);
|
||||
}
|
||||
</script>
|
||||
<?= $this->endSection() ?>
|
||||
368
app/Views/orders_update.php
Normal file
368
app/Views/orders_update.php
Normal file
@ -0,0 +1,368 @@
|
||||
<?= $this->extend($_SESSION['userrole'].'/layout/form.php') ?>
|
||||
|
||||
<?= $this->section('content') ?>
|
||||
<?php
|
||||
$now = date('Y-m-d');
|
||||
$visitdate = $now;
|
||||
?>
|
||||
<style>
|
||||
.table > tbody > tr > td {
|
||||
vertical-align: middle;
|
||||
}
|
||||
.testtable {
|
||||
height: 330px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
</style>
|
||||
<div class="card border-0">
|
||||
<div class="card-body">
|
||||
<h3>Order Creation</h3>
|
||||
<div id='alert'>
|
||||
</div>
|
||||
<div class='row border gap-1 p-1'>
|
||||
<div class='col border'>
|
||||
|
||||
<!-- Patient Data -->
|
||||
<p>Patient Information</p>
|
||||
<input type='hidden' id='patid' value='' />
|
||||
<div class='table-responsive border-1'>
|
||||
<table class='table table-sm table-borderless'>
|
||||
<tr>
|
||||
<td>MR#</td>
|
||||
<td colspan='3'>
|
||||
<div class="input-group">
|
||||
<input type="text" id="patnumber" class="form-control form-control-sm" oninput="this.value = this.value.toUpperCase();patClear();">
|
||||
<div class="input-group-append">
|
||||
<button class='btn btn-sm btn-primary' onclick='patSearch()'><i class='bi bi-search'></i> Search</button>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr> <td>Patient Name</td> <td id='patname'></td></tr>
|
||||
<tr> <td>BirthDate</td> <td id='birthdate'></td> </tr>
|
||||
<tr> <td>Sex</td> <td id='sex'></td> </tr>
|
||||
<tr> <td>Address</td> <td id='address'></td></tr>
|
||||
<tr> <td>Phone#</td> <td id='phone'></td></tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Order Data -->
|
||||
<p>Order Information</p>
|
||||
<div class='table-responsive border-1'>
|
||||
<table class='table table-sm table-borderless'>
|
||||
<tr>
|
||||
<td>Visit#</td>
|
||||
<td><input type="text" id="visitnumber" class="form-control form-control-sm"></td>
|
||||
<td>Visit Date</td>
|
||||
<td><input type="date" id="visitdate" class="form-control form-control-sm" value='<?=$visitdate;?>'></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Treating Doctor</td>
|
||||
<td colspan='3'><input type="text" id="treatdoc" class="form-control form-control-sm"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Payer Name</td>
|
||||
<td colspan='3'><input type="text" id="payername" class="form-control form-control-sm"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class='col border'>
|
||||
|
||||
<!-- Tests Data -->
|
||||
<p>Tests</p>
|
||||
<div class='table-responsive testtable border'>
|
||||
<table class='table table-sm '>
|
||||
<colgroup>
|
||||
<col style='width:5%'>
|
||||
<col style='width:95%'>
|
||||
<col style='width:5%'>
|
||||
</colgroup>
|
||||
<tbody>
|
||||
<?php
|
||||
for($i=0;$i<50;$i++) {
|
||||
?>
|
||||
<tr>
|
||||
<td class='px-2'> <?=$i+1;?></td>
|
||||
<td>
|
||||
<select class='form-control form-control-sm test<?=$i+1;?>'>
|
||||
<option value=''></option>
|
||||
<?php
|
||||
foreach($tests as $data) {
|
||||
$qhiscode = $data['HISCODE'];
|
||||
$qdesc = $data['DESCS'];
|
||||
echo "<option value='$qhiscode'>$qhiscode - $qdesc</option> \r\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p class='m-3'>
|
||||
<button class='btn btn-success' onclick='save()'>Save</button>
|
||||
<button class='btn btn-secondary' onclick='cancel()'>Cancel</button>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="modal_patEditor" aria-hidden="true" tabindex="-1">
|
||||
<div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h1 class="modal-title fs-5" id="exampleModalToggleLabel">Edit Patient</h1>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" ></button>
|
||||
</div>
|
||||
<div class="modal-body" style='background-color:#F4F6FF'>
|
||||
<table class="table table-sm table-borderless">
|
||||
<input type='hidden' id='qpatid' value='' />
|
||||
<tr class="align-middle"> <th>MR#</th> <th>:</th>
|
||||
<td><input class='form-control' type='text' id='qpatnumber' /></td>
|
||||
</tr>
|
||||
<tr class="align-middle"> <th>Patient Name</th> <th>:</th> <td><input class='form-control' type='text' id='qpatname'/></td> </tr>
|
||||
<tr class="align-middle"> <th>BirthDate</th> <th>:</th> <td><input class='form-control' type='date' id='qbirthdate'/></td> </tr>
|
||||
<tr class="align-middle">
|
||||
<th>Sex</th> <th>:</th>
|
||||
<td>
|
||||
<select class='form-control' id='qsex'>
|
||||
<option value=''></option>
|
||||
<option value='F'>Female</option>
|
||||
<option value='M'>Male</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="align-middle"> <th>Address</th> <th>:</th> <td><textarea class='form-control' id='qaddress'></textarea></td> </tr>
|
||||
<tr class="align-middle"> <th>Phone</th> <th>:</th> <td><input class='form-control' type='text' id='qphone'/></td> </tr>
|
||||
</table>
|
||||
<button class='btn btn-sm btn-success' onclick='patSave()'>Save</button>
|
||||
<button class='btn btn-sm btn-secondary' data-bs-dismiss="modal">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="modal_patList" aria-hidden="true" tabindex="-1">
|
||||
<div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h1 class="modal-title fs-5" id="exampleModalToggleLabel">Patient List</h1>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" ></button>
|
||||
</div>
|
||||
<div class="modal-body" style='background-color:#F4F6FF'>
|
||||
<table class="table table-sm table-borderless">
|
||||
<tbody id='patList_tbody' >
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
<?= $this->section('script') ?>
|
||||
<script>
|
||||
function save() {
|
||||
confirm('Are you sure?');
|
||||
if(confirm) {
|
||||
var patid = $("#patid").val();
|
||||
var visitnumber = $("#visitnumber").val();
|
||||
var visitdate = $("#visitdate").val();
|
||||
var treatdoc = $("#treatdoc").val();
|
||||
var payername = $("#payername").val();
|
||||
let data = { patid:patid, visitnumber:visitnumber, visitdate:visitdate, treatdoc:treatdoc, payername:payername ,tests:new Array() };
|
||||
for (let i = 1; i <= 50; i++) {
|
||||
let className = `.test${i}`;
|
||||
let value = $(className).val();
|
||||
if (value !== undefined && value != '') {
|
||||
data['tests'].push(value);
|
||||
}
|
||||
}
|
||||
alert = '';
|
||||
errorTxt = '';
|
||||
if(patid == '') { errorTxt += '<br/>patient is empty. '; }
|
||||
if(visitnumber == '') { errorTxt += '<br/>visitnumber is empty. '; }
|
||||
if(visitdate == '') { errorTxt += '<br/>visitdate is empty. '; }
|
||||
if(data['tests'].length == 0) { errorTxt += '<br/>tests is empty. '; }
|
||||
if(errorTxt != '') {
|
||||
alert = '<div class="alert alert-danger alert-dismissible fade show" role="alert">' +
|
||||
'<strong>Error!</strong>' + errorTxt +
|
||||
'<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>'+
|
||||
'</div>';
|
||||
$('#alert').html(alert);
|
||||
} else {
|
||||
console.log(data);
|
||||
let url = '<?=base_url('');?>api/orders/save';
|
||||
$.ajax({
|
||||
url: url,
|
||||
method: "POST",
|
||||
data: data,
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
window.close();
|
||||
if (window.opener) { window.opener.location.reload(); }
|
||||
},
|
||||
error: function(response) {
|
||||
alert(response.responseJSON.messages.errors);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function cancel() {
|
||||
confirm('Your data will be discarded. Are you sure?');
|
||||
if(confirm) {
|
||||
window.close();
|
||||
}
|
||||
}
|
||||
|
||||
function patClear() {
|
||||
$('#patid').val('');
|
||||
$('#patname').html('');
|
||||
$('#sex').html('');
|
||||
$('#birthdate').html('');
|
||||
$('#address').html('');
|
||||
$('#phone').html('');
|
||||
}
|
||||
|
||||
function patSelect(patnumber) {
|
||||
$('#modal_patList').modal('hide');
|
||||
$('#modal_patEditor').modal('hide');
|
||||
$('#patid').val('');
|
||||
let url = '<?=base_url('');?>api/orders/patDetail/'+patnumber;
|
||||
$.ajax({
|
||||
url: url,
|
||||
method: "GET",
|
||||
success: function(response) {
|
||||
let data = response['patient'];
|
||||
$('#patname').html(data.PATNAME);
|
||||
$('#sex').html(data.SEX);
|
||||
$('#birthdate').html(data.BIRTHDATE);
|
||||
$('#address').html(data.ADDRESS);
|
||||
$('#phone').html(data.PHONE);
|
||||
$("#patid").val(data.PATID);
|
||||
$("#patnumber").val(patnumber);
|
||||
},
|
||||
error: function(response) {
|
||||
alert(response.responseJSON.messages.errors);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function patCreate(patnumber) {
|
||||
$('#modal_patList').modal('hide');
|
||||
$("#qpatid").val('0');
|
||||
$("#qpatnumber").val(patnumber);
|
||||
$("#qpatname").val("");
|
||||
$("#qsex").val("");
|
||||
$("#qbirthdate").val("");
|
||||
$("#qaddress").val('');
|
||||
$('#modal_patEditor').modal('show');
|
||||
}
|
||||
|
||||
function patEdit(patnumber) {
|
||||
$('#modal_patList').modal('hide');
|
||||
let url = '<?=base_url('');?>api/orders/patDetail/'+patnumber;
|
||||
$.ajax({
|
||||
url: url,
|
||||
method: "GET",
|
||||
success: function(response) {
|
||||
let data = response['patient'];
|
||||
console.log(data);
|
||||
$("#qpatnumber").val(patnumber);
|
||||
$("#qpatid").val(data.PATID);
|
||||
$("#qpatname").val(data.PATNAME);
|
||||
$("#qsex").val(data.SEX);
|
||||
$("#qbirthdate").val(data.BIRTHDATE);
|
||||
$("#qaddress").val(data.ADDRESS);
|
||||
$("#qphone").val(data.PHONE);
|
||||
$("#modal_patEditor").modal('show');
|
||||
},
|
||||
error: function(response) {
|
||||
alert(response.responseJSON.messages.errors);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function patSearch() {
|
||||
patnumber = $("#patnumber").val();
|
||||
let url = '<?=base_url('');?>api/orders/patSearch/'+patnumber;
|
||||
$.ajax({
|
||||
url: url,
|
||||
method: "GET",
|
||||
success: function(response) {
|
||||
$("#patList_tbody").html("");
|
||||
var data = response['patients'];
|
||||
datarow = '<tr> <td><button class="btn btn-sm btn-primary" onclick="patCreate(\''+patnumber+'\')"><i class="bi bi-plus-circle"></i> Create</button></td> </tr>';
|
||||
$("#patList_tbody").append(datarow);
|
||||
if(data.length != 0) {
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
patid = data[i].PATID;
|
||||
qpatnumber = data[i].PATNUMBER;
|
||||
patname = data[i].PATNAME;
|
||||
sex = data[i].SEX;
|
||||
birthdate = data[i].BIRTHDATE;
|
||||
editBtn = '<button class="btn btn-sm btn-warning" ' + ' onclick="patEdit(\'' + qpatnumber + '\')">Edit' + '</button> ';
|
||||
selectBtn = '<button class="btn btn-sm btn-success" ' + ' onclick="patSelect(\'' + qpatnumber + '\')">Select' + '</button> ';
|
||||
if(data[i].LISCODE == null) { liscode = '-'; }
|
||||
let datarow = '<tr class="align-middle">' +
|
||||
'<td>' + qpatnumber + '</td>' + '<td>' + patname+ '</td> <td>' + sex + '</td>' + '<td>' + birthdate+ '</td>' + '<td>' + selectBtn + editBtn + '</td>' +
|
||||
'</tr>';
|
||||
$("#patList_tbody").append(datarow);
|
||||
}
|
||||
}
|
||||
$('#modal_patList').modal('show');
|
||||
},
|
||||
error: function(response) {
|
||||
alert(response.responseJSON.messages.errors);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function patSave() {
|
||||
patid = $("#qpatid").val();
|
||||
patnumber = $("#qpatnumber").val();
|
||||
patname = $("#qpatname").val();
|
||||
birthdate = $('#qbirthdate').val();
|
||||
sex = $('#qsex').val();
|
||||
address = $('#qaddress').val();
|
||||
phone = $('#qphone').val();
|
||||
if(patid == '') {
|
||||
|
||||
} else {
|
||||
let data = { patid: patid, patnumber: patnumber, patname:patname, birthdate:birthdate, sex:sex, address:address, phone:phone };
|
||||
let url = '<?=base_url('');?>api/orders/patSave';
|
||||
$.ajax({
|
||||
url: url,
|
||||
method: "POST",
|
||||
data:data,
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
patSelect(patnumber);
|
||||
},
|
||||
error: function(response) {
|
||||
alert(response.responseJSON.messages.errors);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
<?php
|
||||
for($i=1;$i<=50;$i++) {
|
||||
echo "$('.test$i').select2();";
|
||||
}
|
||||
?>
|
||||
});
|
||||
</script>
|
||||
<?= $this->endSection() ?>
|
||||
1
public/assets/select2/select2.min.css
vendored
Normal file
1
public/assets/select2/select2.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
2
public/assets/select2/select2.min.js
vendored
Normal file
2
public/assets/select2/select2.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user