diff --git a/app/Controllers/PrintLabel.php b/app/Controllers/PrintLabel.php index 28e8b48..43825c3 100644 --- a/app/Controllers/PrintLabel.php +++ b/app/Controllers/PrintLabel.php @@ -55,11 +55,12 @@ class PrintLabel extends BaseController { $networkPath = ""; $db = \Config\Database::connect(); - $sql = "select p.PATNUMBER as UHID, sr.HOSTORDERNUMBER as BV, concat (p.FIRSTNAMESK, ' ', p.NAME) as NAME, p.SEX, + $sql = "select p.PATNUMBER as UHID, ctr.REQNUMBER as BV, concat (p.FIRSTNAMESK, ' ', p.NAME) as NAME, p.SEX, DATEDIFF(YEAR, BirthDate, GETDATE()) - CASE WHEN MONTH(BirthDate) > MONTH(GETDATE()) OR (MONTH(BirthDate) = MONTH(GETDATE()) AND DAY(BirthDate) > DAY(GETDATE())) THEN 1 ELSE 0 END AS AGE, sr.COLLECTIONDATE, p.BIRTHDATE from SP_REQUESTS sr + left join cmod.dbo.CM_TM_REQUESTS ctr on ctr.REFFID=sr.HOSTORDERNUMBER left join SP_REQUESTS st on sr.SP_ACCESSNUMBER=st.SP_ACCESSNUMBER left join PATIENTS p on p.PATID=sr.PATID where st.SP_ACCESSNUMBER='$access'"; @@ -67,7 +68,7 @@ class PrintLabel extends BaseController { $results = $query->getResultArray(); $item = $results[0]; - $uhid = substr($item['UHID'], -10); + $uhid = ltrim($item['UHID'], '0'); $bv = $item['BV']; $sex = $item['SEX'] == 1 ? "M" : "F"; $title = $item['SEX'] == 1 ? "Mr" : "Mrs"; @@ -109,15 +110,15 @@ q400 Q200,10+0 I8,A,001 D10 -A4,3,0,2,1,1,N,\"$title.$name1\" +A5,3,0,2,1,1,N,\"$title.$name1\" A$jarak,20,0,2,1,1,N,\"$name2\" -A4,42,0,1,1,1,N,\"DoB: $birthdate\" +A5,42,0,1,1,1,N,\"DoB: $birthdate\" A337,42,0,1,1,1,N,\"$sex {$age}Y\" -B15,57,0,1,4,8,70,N,\"$access\" +B16,57,0,1,4,8,70,N,\"$access\" A120,132,0,1,1,1,N,\"REQ# $access\" -A4,164,0,2,1,1,N,\"RM:$uhid\" -A4,147,0,2,1,1,N,\"VN:$bv\" -A195,164,0,2,1,1,N,\"$collectiondate\" +A5,149,0,2,1,1,N,\"VN:$bv\" +A5,166,0,2,1,1,N,\"RM:$uhid\" +A195,166,0,2,1,1,N,\"$collectiondate\" P1 "; @@ -199,14 +200,14 @@ q400 Q200,10+0 I8,A,001 D10 -A4,3,0,2,1,1,N,\"$title.$name1\" +A5,3,0,2,1,1,N,\"$title.$name1\" A$jarak,20,0,2,1,1,N,\"$name2\" A325,25,0,2,1,1,N,\"$sex {$age}Y\" -A4,47,0,2,1,1,N,\"$sample\" +A5,47,0,2,1,1,N,\"$sample\" A204,47,0,2,1,1,N,\"DoB: $birthdate\" B37,68,0,1,4,8,70,N,\"$barcode\" A115,143,0,2,1,1,N,\"SAM# $barcode\" -A4,165,0,2,1,1,N,\"RM:$uhid\" +A5,165,0,2,1,1,N,\"RM:$uhid\" A195,165,0,2,1,1,N,\"$collection_date\" P1 @@ -272,7 +273,7 @@ P1 $results = $query->getResultArray(); $item = $results[0]; - $uhid = substr($item['UHID'], -10); + $uhid = ltrim($item['UHID'], '0'); $bv = $item['BV']; $sex = $item['SEX'] == 1 ? "M" : "F"; $title = $item['SEX'] == 1 ? "Mr" : "Mrs";