add label creation

This commit is contained in:
mahdahar 2025-11-18 16:20:31 +07:00
parent 75062e00a5
commit 11111aeed3
6 changed files with 270 additions and 13 deletions

View File

@ -17,6 +17,9 @@ $routes->match(['get','post'],'/login', 'Auth::login', ['filter' => 'guest']);
$routes->get('/logout', 'Auth::logout');
$routes->get('result/(:any)', 'Result::show/$1');
$routes->get('label/coll/(:any)', 'Label::coll/$1');
$routes->get('label/dispatch/(:any)/(:any)', 'Label::dispatch/$1/$2');
$routes->get('label/all/(:any)', 'Label::print_all/$1');
// ------------------------------------------------------Page Based on Role------------------------------------------------------ //
$routes->group('admin', ['filter' => 'role:1'], function($routes) {
$routes->get('/', 'Admin::index');

152
app/Controllers/Label.php Normal file
View File

@ -0,0 +1,152 @@
<?php
namespace App\Controllers;
class Label extends BaseController {
public function coll($reqnum) {
$db = \Config\Database::connect();
//$reqnum = str_pad($reqnum, 10, 0, STR_PAD_LEFT);
$sql = "select p.PATNUMBER,
[Name] = case
when p.TITLEID is not null then ISNULL(p.FIRSTNAME,'') + ' ' + ISNULL(p.NAME,'') + ', ' + tx.SHORTTEXT
else ISNULL(p.FIRSTNAME,'') + ' ' + ISNULL(p.NAME,'')
end,
format(p.BIRTHDATE,'dd/MMM/yyyy') as dob,
age = case
when year(spr.COLLECTIONDATE) - year(p.BIRTHDATE) > 0 then (
case
when format(p.BIRTHDATE,'MMdd')=format(spr.COLLECTIONDATE,'MMdd') then cast(DATEDIFF(YEAR,p.BIRTHDATE, spr.COLLECTIONDATE) as varchar) + 'Y'
else cast( DATEDIFF(hour,p.BIRTHDATE, spr.COLLECTIONDATE)/8766 as varchar) + 'Y' end
)
when month(spr.COLLECTIONDATE) - month(p.BIRTHDATE) > 0 then cast( DATEDIFF(MM,p.BIRTHDATE,spr.COLLECTIONDATE) as varchar) + 'M'
else cast ( floor ( ( day(spr.COLLECTIONDATE) - day(p.BIRTHDATE) ) / 7) as varchar ) + 'W'
end,
[Gender] = case
when p.SEX = 1 then 'M'
when p.SEX = 2 then 'F'
else ''
end,
spr.HOSTORDERNUMBER
from SP_REQUESTS spr
left join PATIENTS p on spr.PATID=p.PATID
left join DICT_TEXTS tx on tx.TEXTID=p.TITLEID
where spr.SP_ACCESSNUMBER='$reqnum'";
$rows = $db->query($sql)->getResultArray();
//print_r($rows);
$row = $rows[0];
$patnum = $row['PATNUMBER'];
$patnum = substr($patnum,14);
//$patnum = str_pad(substr($row[0],5),17," ");
$patname = $row['Name'];
$dob = $row['dob'];
$age = $row['age'];
$sex = $row['Gender'];
$hospnum = $row['HOSTORDERNUMBER'];
$date = date("d/M/Y H:i");
$bar = "[
N
OD
q400
Q224,24+0
I8,A,001
D10
A10,3,0,3,1,1,N,\"$patname\"
A10,27,0,2,1,1,N,\"$sex $dob $age\"
A225,27,0,3,1,1,N,\"$reqnum\"
B120,50,0,1,2,8,90,N,\"$reqnum\"
A80,150,0,2,2,1,N,\"$hospnum\"
A10,195,0,1,1,1,N,\"HIS : $hospnum\"
A190,190,0,2,1,1,N,\"$date\"
P1\n]";
$handle = fopen("./file.txt","a+");
fwrite($handle,$bar);
fclose($handle);
/*exec($command);*/
}
public function dispatch($reqnum, $samid) {
$db = \Config\Database::connect();
$sql = "select p.PATNUMBER,
[Name] = case
when p.TITLEID is not null then ISNULL(p.FIRSTNAME,'') + ' ' + ISNULL(p.NAME,'') + ', ' + tx.SHORTTEXT
else ISNULL(p.FIRSTNAME,'') + ' ' + ISNULL(p.NAME,'')
end,
format(p.BIRTHDATE,'dd/MMM/yyyy') as dob,
age = case
when year(spr.COLLECTIONDATE) - year(p.BIRTHDATE) > 0 then (
case
when format(p.BIRTHDATE,'MMdd')=format(spr.COLLECTIONDATE,'MMdd') then cast(DATEDIFF(YEAR,p.BIRTHDATE, spr.COLLECTIONDATE) as varchar) + 'Y'
else cast( DATEDIFF(hour,p.BIRTHDATE, spr.COLLECTIONDATE)/8766 as varchar) + 'Y' end
)
when month(spr.COLLECTIONDATE) - month(p.BIRTHDATE) > 0 then cast( DATEDIFF(MM,p.BIRTHDATE,spr.COLLECTIONDATE) as varchar) + 'M'
else cast ( floor ( ( day(spr.COLLECTIONDATE) - day(p.BIRTHDATE) ) / 7) as varchar ) + 'W'
end,
[Gender] = case
when p.SEX = 1 then 'M'
when p.SEX = 2 then 'F'
else ''
end,
spr.HOSTORDERNUMBER
from SP_REQUESTS spr
left join PATIENTS p on spr.PATID=p.PATID
left join DICT_TEXTS tx on tx.TEXTID=p.TITLEID
where spr.SP_ACCESSNUMBER='$reqnum'";
$rows = $db->query($sql)->getResultArray();
$row = $rows[0];
$patnum = $row['PATNUMBER'];
$patnum = substr($patnum,14);
$patname = $row['Name'];
$age = $row['age'];
$sex = $row['Gender'];
$hospnum = $row['HOSTORDERNUMBER'];
$sql = "select SAMPCODE, SHORTTEXT, TESTS, TESTS1 from GDC_CMOD.dbo.v_sp_reqtube where SP_ACCESSNUMBER='$reqnum' and SAMPCODE='$samid'";
$rows = $db->query($sql)->getResultArray();
$row = $rows[0];
$sampcode = $row['SAMPCODE'];
$samptext = $row['SHORTTEXT'];
$tests = $row['TESTS'];
$tests1 = $row['TESTS1'];
if($tests == '') {$tests = $tests1;}
$tubeid = $sampcode.substr("$reqnum",5,5);
$date = date("d/M/Y H:i");
$bar = "[
N
OD
q400
Q224,24+0
I8,A,001
D10
A10,3,0,3,1,1,N,\"$patname \"
A10,27,0,2,1,1,N,\"$sex $age\"
B130,50,0,1,2,8,90,N,\"$tubeid\"
A380,27,5,3,1,1,N,\"$tubeid\"
A10,80,0,2,1,2,R,\"$samptext\"
A10,150,0,2,1,1,N,\"$tests\"
A10,180,0,1,1,1,N,\"LIS : $reqnum\"
A10,195,0,1,1,1,N,\"HIS : $hospnum\"
A190,190,0,2,1,1,N,\"$date\"
P1
]";
$handle = fopen("./file.txt","a+");
fwrite($handle,$bar);
fclose($handle);
//exec($command);
}
public function print_all($accessnumber) {
$db = \Config\Database::connect();
$this->coll($accessnumber);
$sql = "select SAMPCODE from GDC_CMOD.dbo.v_sp_reqtube where SP_ACCESSNUMBER='$accessnumber'";
$rows = $db->query($sql)->getResultArray();
foreach($rows as $row) {
$sampcode = $row['SAMPCODE'];
$this->dispatch($accessnumber, $sampcode);
}
}
}

View File

@ -49,7 +49,7 @@ class Specimen extends BaseController {
];
}
$data = ['patientIdentity' => $patientIdentity, 'samples' => $samples];
$data = ['patientIdentity' => $patientIdentity, 'samples' => $samples, 'accessnumber' => $access];
return $this->response->setJSON($data);
}

View File

@ -132,7 +132,7 @@
<!-- Modal Specimen Collection-->
<div class="modal fade" id="detailModal" aria-hidden="true" aria-labelledby="detailModal" tabindex="-1">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-dialog modal-xl modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fw-bold fs-4" id="detailModal">Specimen Collection</h1>

View File

@ -1,6 +1,6 @@
<div class="row mb-4 p-3">
<div class="col-md-6">
<div class="col-8">
<div class="info-pair d-flex">
<div class="info-label w-25 fw-bold">Patient</div>
<div class="info-value">: {{patientIdentity.name}}</div>
@ -15,7 +15,11 @@
</div>
</div>
<div class="col-md-6">
<div class="col-4">
<div class="info-pair d-flex">
<div class="info-label w-50 fw-bold">Lab#</div>
<div class="info-value">: {{accessnumber}}</div>
</div>
<div class="info-pair d-flex">
<div class="info-label w-50 fw-bold">MR#</div>
<div class="info-value">: {{patientIdentity.rm}}</div>
@ -24,10 +28,6 @@
<div class="info-label w-50 fw-bold">KTP</div>
<div class="info-value">: {{patientIdentity.ktp}}</div>
</div>
<div class="info-pair d-flex">
<div class="info-label w-50 fw-bold">Place of Birth</div>
<div class="info-value">: {{patientIdentity.placeofbirth}}</div>
</div>
</div>
</div>
@ -38,7 +38,7 @@
<i class="bi bi-flask-florence-fill"></i> Tube
</h5>
<table class="table fs-6 text-start">
<table class="table fs-6 text-start table-hover">
<thead>
<tr>
<th>Sample Code</th>
@ -46,10 +46,24 @@
<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="bi bi-printer"></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="bi bi-printer"></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>
{{#samples}}
<tr>
<td>{{sampcode}}</td>
@ -67,15 +81,19 @@
>
</td>
<td>
<button type="button" class="btn btn-success m-0 px-2 py-1" onclick=""><h6 class="p-0 m-0">Coll.</h6></button>
<button type="button" class="btn btn-warning m-0 px-2 py-1" onclick=""><h6 class="p-0 m-0">Un-Coll.</h6></button>
<button type="button" class="btn btn-warning m-0 px-2 py-1" onclick=""><h6 class="p-0 m-0">Un-Recv.</h6></button>
<button class="btn btn-sm btn-secondary px-2 py-1"><i class="bi bi-printer"></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>
<td>
</td>
</tr>
{{/samples}}
<tr class="text-center">
<td colspan="4">
<td colspan="6">
<h6 class="p-0 m-0">
<i class="bi bi-pencil-square" role="button" onclick="commentValue()"></i>
</h6>

84
public/file.txt Normal file
View File

@ -0,0 +1,84 @@
[
N
OD
q400
Q224,24+0
I8,A,001
D10
A10,3,0,3,1,1,N," CHRISTINA TANJUNG, MS"
A10,27,0,2,1,1,N,"F 26/Nov/1995 29Y"
A225,27,0,3,1,1,N,"5111825322"
B120,50,0,1,2,8,90,N,"5111825322"
A80,150,0,2,2,1,N,"01251101328"
A10,195,0,1,1,1,N,"HIS : 01251101328"
A190,190,0,2,1,1,N,"18/Nov/2025 09:11"
P1
][
N
OD
q400
Q224,24+0
I8,A,001
D10
A10,3,0,3,1,1,N," CHRISTINA TANJUNG, MS "
A10,27,0,2,1,1,N,"F 29Y"
B130,50,0,1,2,8,90,N,"10125322"
A380,27,5,3,1,1,N,"10125322"
A10,80,0,2,1,2,R,"EDTA"
A10,150,0,2,1,1,N,"G6PD,DL"
A10,180,0,1,1,1,N,"LIS : 5111825322"
A10,195,0,1,1,1,N,"HIS : 01251101328"
A190,190,0,2,1,1,N,"18/Nov/2025 09:11"
P1
][
N
OD
q400
Q224,24+0
I8,A,001
D10
A10,3,0,3,1,1,N," CHRISTINA TANJUNG, MS "
A10,27,0,2,1,1,N,"F 29Y"
B130,50,0,1,2,8,90,N,"25025322"
A380,27,5,3,1,1,N,"25025322"
A10,80,0,2,1,2,R,"Serum"
A10,150,0,2,1,1,N,"TOXM,RUBM,TPHA,VD25,AHBSM"
A10,180,0,1,1,1,N,"LIS : 5111825322"
A10,195,0,1,1,1,N,"HIS : 01251101328"
A190,190,0,2,1,1,N,"18/Nov/2025 09:11"
P1
][
N
OD
q400
Q224,24+0
I8,A,001
D10
A10,3,0,3,1,1,N," CHRISTINA TANJUNG, MS "
A10,27,0,2,1,1,N,"F 29Y"
B130,50,0,1,2,8,90,N,"35025322"
A380,27,5,3,1,1,N,"35025322"
A10,80,0,2,1,2,R,"Urin"
A10,150,0,2,1,1,N,"UL"
A10,180,0,1,1,1,N,"LIS : 5111825322"
A10,195,0,1,1,1,N,"HIS : 01251101328"
A190,190,0,2,1,1,N,"18/Nov/2025 09:11"
P1
][
N
OD
q400
Q224,24+0
I8,A,001
D10
A10,3,0,3,1,1,N," CHRISTINA TANJUNG, MS "
A10,27,0,2,1,1,N,"F 29Y"
B130,50,0,1,2,8,90,N,"90025322"
A380,27,5,3,1,1,N,"90025322"
A10,80,0,2,1,2,R,"Other"
A10,150,0,2,1,1,N,"SFPL"
A10,180,0,1,1,1,N,"LIS : 5111825322"
A10,195,0,1,1,1,N,"HIS : 01251101328"
A190,190,0,2,1,1,N,"18/Nov/2025 09:11"
P1
]