Merge branch 'main' of https://github.com/mikael-zakaria/gdc_cmod_v2
This commit is contained in:
commit
1603a4fabd
@ -55,6 +55,7 @@ $routes->get('api/request/validate/(:any)', 'Request::show/$1');
|
|||||||
$routes->post('api/request/validate/(:any)', 'Request::val/$1');
|
$routes->post('api/request/validate/(:any)', 'Request::val/$1');
|
||||||
$routes->delete('api/request/validate/(:any)', 'Request::unval/$1');
|
$routes->delete('api/request/validate/(:any)', 'Request::unval/$1');
|
||||||
$routes->get('api/request', 'Request::index');
|
$routes->get('api/request', 'Request::index');
|
||||||
|
$routes->get('api/sample/(:any)', 'Sample::show/$1');
|
||||||
|
|
||||||
$routes->get('api/specimen/(:any)', 'Specimen::show/$1');
|
$routes->get('api/specimen/(:any)', 'Specimen::show/$1');
|
||||||
$routes->post('api/specimen/collect/(:any)', 'Specimen::collect/$1');
|
$routes->post('api/specimen/collect/(:any)', 'Specimen::collect/$1');
|
||||||
|
|||||||
114
app/Controllers/Sample.php
Normal file
114
app/Controllers/Sample.php
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Controllers;
|
||||||
|
use CodeIgniter\API\ResponseTrait;
|
||||||
|
|
||||||
|
class Sample extends BaseController {
|
||||||
|
use ResponseTrait;
|
||||||
|
|
||||||
|
public function show($accessnumber) {
|
||||||
|
$db = \Config\Database::connect();
|
||||||
|
|
||||||
|
$sql = "SELECT right(p.PATNUMBER,16) as [patnumber], ISNULL(p.FIRSTNAME,'') + ' ' + ISNULL(p.NAME,'') as [Name],
|
||||||
|
case when format(p.BIRTHDATE,'MMdd')=format(spr.COLLECTIONDATE,'MMdd') then DATEDIFF(YEAR,p.BIRTHDATE, spr.COLLECTIONDATE)
|
||||||
|
else FLOOR(DATEDIFF(DAY, p.BIRTHDATE, spr.COLLECTIONDATE) / 365.25) end ,
|
||||||
|
[Gender] = case
|
||||||
|
when p.SEX = 1 then 'M'
|
||||||
|
when p.SEX = 2 then 'F'
|
||||||
|
else ''
|
||||||
|
end, spr.REQDATE, spo.COMMENTTEXT, dmg.DMG_CKTPNO, dmg.DMG_CPLACEOFBIRTH
|
||||||
|
from SP_REQUESTS spr
|
||||||
|
left join PATIENTS p on p.PATID=spr.PATID
|
||||||
|
left join SP_REQUESTS_OCOM spo on spr.SP_ACCESSNUMBER=spo.SP_ACCESSNUMBER
|
||||||
|
left join GDC_CMOD.dbo.TDL_DEMOGRAPHIC dmg on right(dmg.DMG_CPATNUMBER,15)=right(p.PATNUMBER,15)
|
||||||
|
where spr.PATID=p.PATID and spr.SP_ACCESSNUMBER='$accessnumber'";
|
||||||
|
$query = $db->query($sql);
|
||||||
|
$results = $query->getRowArray();
|
||||||
|
$data = [
|
||||||
|
'patnumber' => $results["patnumber"],
|
||||||
|
'age' => $results[""],
|
||||||
|
'patname' => $results['Name'] ?? '',
|
||||||
|
'reqdate' => $results['REQDATE'] ?? '',
|
||||||
|
'gender' => $results['Gender'] ?? '',
|
||||||
|
'placeofbirth' => $results['DMG_CPLACEOFBIRTH'] ?? '',
|
||||||
|
'ktp' => $results['DMG_CKTPNO'] ?? '',
|
||||||
|
'comment' => $results['COMMENTTEXT'] ?? '',
|
||||||
|
'accessnumber' => $accessnumber,
|
||||||
|
];
|
||||||
|
|
||||||
|
$samples = [];
|
||||||
|
$sql = "SELECT req.SAMPTYPEID, req.SAMPCODE, req.SHORTTEXT, tu.STATUS, st.TUBESTATUS
|
||||||
|
from GDC_CMOD.dbo.v_sp_reqtube req
|
||||||
|
left join GDC_CMOD.dbo.TUBES tu on req.SP_ACCESSNUMBER=tu.ACCESSNUMBER and req.SAMPCODE=tu.TUBENUMBER
|
||||||
|
left join glendb.dbo.SP_TUBES st on st.SP_ACCESSNUMBER=req.SP_ACCESSNUMBER and req.SAMPCODE=st.SAMPLETYPE
|
||||||
|
where req.SP_ACCESSNUMBER='$accessnumber'";
|
||||||
|
$query = $db->query($sql);
|
||||||
|
$results = $query->getResultArray();
|
||||||
|
foreach ($results as $row) {
|
||||||
|
$samples[] = [
|
||||||
|
'samptypeid' => $row['SAMPTYPEID'] ?? null,
|
||||||
|
'sampcode' => $row['SAMPCODE'] ?? null,
|
||||||
|
'name' => $row['SHORTTEXT'] ?? '',
|
||||||
|
'colstatus' => $row['STATUS'] ?? '',
|
||||||
|
'tubestatus' => $row['TUBESTATUS'] ?? '',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
$data['samples'] = $samples;
|
||||||
|
|
||||||
|
$resp = [ 'data' => $data ];
|
||||||
|
|
||||||
|
return $this->response->setJSON($resp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function collect($accessnumber) {
|
||||||
|
$db = \Config\Database::connect();
|
||||||
|
$input = $this->request->getJSON(true);
|
||||||
|
$samplenumber = $input['samplenumber'];
|
||||||
|
$status = $input['status'];
|
||||||
|
$userid = $input['userid'];
|
||||||
|
$sql = "if not exists (select * from GDC_CMOD.dbo.TUBES where ACCESSNUMBER='$accessnumber' and TUBENUMBER='$samplenumber' and STATUS='$status')
|
||||||
|
begin
|
||||||
|
update GDC_CMOD.dbo.TUBES set USERID='$userid',STATUS='$status', COLLECTIONDATE=getdate() where ACCESSNUMBER='$accessnumber' and TUBENUMBER='$samplenumber'
|
||||||
|
end";
|
||||||
|
$db->query($sql);
|
||||||
|
$sql = "INSERT INTO GDC_CMOD.dbo.AUDIT_TUBES(ACCESSNUMBER, TUBENUMBER, USERID, STATUS, LOGDATE)
|
||||||
|
VALUES ('$accessnumber', '$samplenumber', '$userid', '$status', getdate())";
|
||||||
|
$db->query($sql);
|
||||||
|
return $this->respondCreated([ 'status' => 'success', 'message' => 'Data updated successfully', 'data' => "$accessnumber-$samplenumber" ], 201);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function unreceive($accessnumber) {
|
||||||
|
$db = \Config\Database::connect();
|
||||||
|
$input = $this->request->getJSON(true);
|
||||||
|
$samplenumber = $input['samplenumber'];
|
||||||
|
// update firebird
|
||||||
|
$sql = "select r.EXTERNALORDERNUMBER, dt.TESTCODE, do.HISCODE from glendb.dbo.TESTS t
|
||||||
|
left join glendb.dbo.DICT_TESTS dt on dt.TESTID=t.TESTID
|
||||||
|
left join glendb.dbo.REQUESTS r on r.REQUESTID=t.REQUESTID
|
||||||
|
left join glendb.dbo.DICT_TEST_SAMPLES dts on dts.TESTID=t.TESTID
|
||||||
|
left join glendb.dbo.DICT_SAMPLES_TYPES ds on ds.SAMPTYPEID=dts.SAMPTYPEID
|
||||||
|
left join GDC_CMOD.dbo.DICT_TESTS_ORDER do on do.TESTCODE=dt.TESTCODE
|
||||||
|
where t.DEPTH=0
|
||||||
|
and r.ACCESSNUMBER='$req' and ds.SAMPCODE='$samplenumber'";
|
||||||
|
$rows = $db->query($sql)->getResultArray();
|
||||||
|
$his_test = '';
|
||||||
|
foreach( $rows as $row ) {
|
||||||
|
$hon = $row['EXTERNALORDERNUMBER'];
|
||||||
|
$testcode = $row['TESTCODE'];
|
||||||
|
$hiscode = $row['HISCODE'];
|
||||||
|
$his_test .= "'$hiscode',";
|
||||||
|
$lis_test .= "'$testcode',";
|
||||||
|
}
|
||||||
|
$his_test = rtrim($his_test,',');
|
||||||
|
$lis_test = rtrim($lis_test,',');
|
||||||
|
$conn = odbc_connect('GLENEAGLES','','');
|
||||||
|
$sql = "UPDATE TDL_ORDERDT SET ODD_NRECEIVED=NULL , ODD_DTRECEIVE=NULL WHERE ODR_CNOLAB='$hon' and ODD_CPRODUCTCODE IN ($his_test)";
|
||||||
|
$rs = odbc_exec($conn,$sql);
|
||||||
|
if (!$rs) {exit("Error in Update FB");}
|
||||||
|
|
||||||
|
$sql = "update SP_TUBES set TUBESTATUS=0 where SP_ACCESSNUMBER='$accessnumber' and SAMPLETYPE='$samplenumber' ";
|
||||||
|
$db->query($sql);
|
||||||
|
$sql = "update SP_TESTS set SP_TESTSTATUS=NULL where SP_ACCESSNUMBER='$req' and SP_TESTCODE in ($lis_test)";
|
||||||
|
$db->query($sql);
|
||||||
|
return $this->respondCreated([ 'status' => 'success', 'message' => 'Data updated successfully', 'data' => "$accessnumber-$samplenumber" ], 201);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,15 +1,81 @@
|
|||||||
|
|
||||||
<dialog id="form" class="modal" :open="isDialogSampleOpen">
|
<dialog id="form" class="modal" :open="isDialogSampleOpen">
|
||||||
<div class="modal-box w-2/3 max-w-5xl">
|
<div class="modal-box w-2/3 max-w-5xl">
|
||||||
<p class='text-right'><button class="btn btn-xs btn-neutral" @click="closeSampleDialog()">X</button></p>
|
<p class='text-right'><button class="btn btn-xs btn-neutral" @click="closeSampleDialog()">X</button></p>
|
||||||
|
|
||||||
<div class="table">
|
<table class="table table-xs table-compact w-full">
|
||||||
<table>
|
<tr>
|
||||||
<tr>
|
<td>MR# </td> <td x-text="': '+item.patnumber"></td>
|
||||||
<td>Patient Name </td> <td x-text="':'+item.PatName"></td>
|
<td>Patient Name </td> <td x-text="': '+item.patname"></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
<tr>
|
||||||
</div>
|
<td>KTP# </td> <td x-text="': '+item.ktp"></td>
|
||||||
|
<td>Sex / Age </td> <td x-text="': '+item.placeofbirth+' '+item.gender+' / '+item.age"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Note</td> <td colspan='3' x-text="': '+item.comment"></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<table class="table table-xs table-compact w-full">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Sample Code</th>
|
||||||
|
<th>Sample Name</th>
|
||||||
|
<th class='text-center'>Collected</th>
|
||||||
|
<th class='text-center'>Received</th>
|
||||||
|
<th>Action</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td></td> <td>Collection</td> <td></td> <td></td>
|
||||||
|
<td><button class="btn btn-sm btn-secondary px-2 py-1"><i class="fa-solid fa-print"></i></button></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td></td> <td>All</td> <td></td> <td></td>
|
||||||
|
<td>
|
||||||
|
<button class="btn btn-sm btn-secondary px-2 py-1"><i class="fa-solid fa-print"></i></i></button>
|
||||||
|
<button class="btn btn-success px-2 py-1" onclick=""><h6 class="p-0 m-0">Coll.</h6></button>
|
||||||
|
<button class="btn btn-warning px-2 py-1" onclick=""><h6 class="p-0 m-0">Un-Coll.</h6></button>
|
||||||
|
<button class="btn btn-warning px-2 py-1" onclick=""><h6 class="p-0 m-0">Un-Recv.</h6></button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
[{"samptypeid":40,"sampcode":"900","name":"Other","colstatus":"1","tubestatus":0}]
|
||||||
|
<template x-for="samples as sample" :key="sample.samptypeid">
|
||||||
|
<tr>
|
||||||
|
<td x-text="sample.sampcode"></td>
|
||||||
|
<td x-text="sample.name"></td>
|
||||||
|
<td class='text-center'>
|
||||||
|
<input type="checkbox" class="checkbox" x-bind:checked="sample.colstatus === 1" disabled>
|
||||||
|
</td>
|
||||||
|
<td class='text-center'>
|
||||||
|
<input type="checkbox" class="checkbox" x-bind:checked="sample.tubestatus != 0" disabled>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<button class="btn btn-sm btn-secondary px-2 py-1"><i class="fa-solid fa-printer"></i></button>
|
||||||
|
<button class="btn btn-sm btn-success px-2 py-1" onclick="collect({{accessnumber}}, {{sampcode}}, 1)"><h6 class="p-0 m-0">Coll.</h6></button>
|
||||||
|
<button class="btn btn-sm btn-warning px-2 py-1" onclick="collect({{accessnumber}}, {{sampcode}}, 0)"><h6 class="p-0 m-0">Un-Coll.</h6></button>
|
||||||
|
<button class="btn btn-sm gbtn-warning px-2 py-1" onclick="unreceive({{accessnumber}}, {{sampcode}})"><h6 class="p-0 m-0">Un-Recv.</h6></button>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<tr class="text-center">
|
||||||
|
<td colspan="6">
|
||||||
|
<h6 class="p-0 m-0">
|
||||||
|
<i class="fa-solid fa-pencil" role="button" onclick="commentValue()"></i>
|
||||||
|
</h6>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</dialog>
|
</dialog>
|
||||||
|
|||||||
@ -212,11 +212,12 @@
|
|||||||
/*
|
/*
|
||||||
sample dialog
|
sample dialog
|
||||||
*/
|
*/
|
||||||
item : [],
|
item : '',
|
||||||
isDialogSampleOpen : false,
|
isDialogSampleOpen : false,
|
||||||
|
|
||||||
openSampleDialog (accessnumber) {
|
openSampleDialog (accessnumber) {
|
||||||
this.isDialogSampleOpen = true;
|
this.isDialogSampleOpen = true;
|
||||||
|
this.fetchItem(accessnumber)
|
||||||
},
|
},
|
||||||
|
|
||||||
closeSampleDialog () {
|
closeSampleDialog () {
|
||||||
@ -225,7 +226,7 @@
|
|||||||
|
|
||||||
fetchItem(accessnumber){
|
fetchItem(accessnumber){
|
||||||
this.item = [];
|
this.item = [];
|
||||||
fetch(`${BASEURL}/api/request/${accessnumber}`, { method: 'GET', headers: {'Content-Type': 'application/json'}})
|
fetch(`${BASEURL}/api/sample/${accessnumber}`, { method: 'GET', headers: {'Content-Type': 'application/json'}})
|
||||||
.then(res => res.json()).then(data => {
|
.then(res => res.json()).then(data => {
|
||||||
this.item = data.data ?? [];
|
this.item = data.data ?? [];
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user