remove pat* from APIorder, add resend success alert
This commit is contained in:
parent
e5b46367a5
commit
2b8832e32e
@ -65,7 +65,7 @@ $routes->get('api/dictChapters/detail/(:any)', 'API_DictChapters::detail/$1');
|
||||
// API - Orders
|
||||
$routes->POST('api/orders/index', 'API_HISOrders::index');
|
||||
$routes->POST('api/orders/save', 'API_HISOrders::save');
|
||||
$routes->POST('api/orders/resend', 'API_HISOrders::resend');
|
||||
$routes->GET('api/orders/resend/(:any)', 'API_HISOrders::resend/$1');
|
||||
$routes->get('api/orders/detail/(:any)', 'API_HISOrders::detail/$1');
|
||||
|
||||
// API - Patients
|
||||
|
||||
@ -13,7 +13,7 @@ class API_HISOrders extends ResourceController {
|
||||
$sql = "select o.ORDERID, 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
|
||||
where t.ORDERID=o.ORDERID and t.TESTSTATUS is null
|
||||
) as T
|
||||
for xml path('')),1,1,'')
|
||||
from cmod.dbo.CM_HIS_ORDERS o
|
||||
@ -30,7 +30,7 @@ class API_HISOrders extends ResourceController {
|
||||
$query = $db->query($sql);
|
||||
$results = $query->getResultArray();
|
||||
$data['orders'] = $results;
|
||||
$sql = "select * from cmod.dbo.CM_HIS_TESTS where ORDERID='$orderid'";
|
||||
$sql = "select * from cmod.dbo.CM_HIS_TESTS where ORDERID='$orderid' and TESTSTATUS is null";
|
||||
$query = $db->query($sql);
|
||||
$results = $query->getResultArray();
|
||||
$data['tests'] = $results;
|
||||
@ -72,6 +72,8 @@ class API_HISOrders extends ResourceController {
|
||||
USING ( VALUES
|
||||
$test
|
||||
) AS s (ORDERID, HISCODE) on s.ORDERID=t.ORDERID and s.HISCODE=t.HISCODE
|
||||
WHEN MATCHED THEN
|
||||
UPDATE SET TESTSTATUS=null
|
||||
WHEN NOT MATCHED BY TARGET THEN
|
||||
INSERT (ORDERID, HISCODE)
|
||||
VALUES (s.ORDERID, s.HISCODE)
|
||||
@ -99,48 +101,6 @@ class API_HISOrders extends ResourceController {
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public function resend($visitnumber) {
|
||||
$db = \Config\Database::connect();
|
||||
$sql = "update cmod.dbo.CM_HIS_ORDERS set ISTAKEN=null where VISITNUMBER='$visitnumber'";
|
||||
|
||||
@ -241,7 +241,7 @@ function save() {
|
||||
if (window.opener) { window.opener.location.reload(); }
|
||||
},
|
||||
error: function(response) {
|
||||
alert(response.responseJSON.messages.errors);
|
||||
console.log(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
<?= $this->extend($_SESSION['userrole'].'/layout/main.php') ?>
|
||||
|
||||
<?= $this->section('content') ?>
|
||||
<div id="alert">
|
||||
|
||||
</div>
|
||||
<div class="card border-0">
|
||||
<div class="card-body">
|
||||
<div class='card-title'>Order List</div>
|
||||
@ -95,8 +98,14 @@ function resend(visitnumber) {
|
||||
let url = '<?=base_url('');?>api/orders/resend/'+visitnumber;
|
||||
$.ajax({
|
||||
url: url,
|
||||
method: 'url',
|
||||
success: function(response) { console.log(response.responseJSON); },
|
||||
method: 'GET',
|
||||
success: function(response) {
|
||||
alert = '<div class="alert alert-primary alert-dismissible fade show" role="alert">' +
|
||||
'Re-send '+visitnumber+' success.' +
|
||||
'<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>'+
|
||||
'</div>';
|
||||
$('#alert').html(alert);
|
||||
},
|
||||
error: function(response) { console.log(response.responseJSON); }
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user