diff --git a/.serena/project.yml b/.serena/project.yml index 4cfc21a..45b857a 100644 --- a/.serena/project.yml +++ b/.serena/project.yml @@ -125,3 +125,8 @@ language_backend: # list of regex patterns which, when matched, mark a memory entry as read‑only. # Extends the list from the global configuration, merging the two lists. read_only_memory_patterns: [] + +# line ending convention to use when writing source files. +# Possible values: unset (use global setting), "lf", "crlf", or "native" (platform default) +# This does not affect Serena's own files (e.g. memories and configuration files), which always use native line endings. +line_ending: diff --git a/app/Controllers/SamplesController.php b/app/Controllers/SamplesController.php index 691c27d..38d21e9 100644 --- a/app/Controllers/SamplesController.php +++ b/app/Controllers/SamplesController.php @@ -9,11 +9,32 @@ class SamplesController extends BaseController { use ResponseTrait; - public function show($accessnumber) + public function show($input) { $db = \Config\Database::connect(); - $sql = "SELECT right(p.PATNUMBER,16) as [patnumber], ISNULL(p.FIRSTNAME,'') + ' ' + ISNULL(p.NAME,'') as [Name], + $scannedSampleCode = ''; + + if (strlen($input) == 10) { + $accessnumber = $input; + } else { + $redacc = substr($input, 3, 5); + $scannedSampleCode = substr($input, 0, 3); + + $sql = "SELECT TOP 1 SPR.SP_ACCESSNUMBER + FROM SP_REQUESTS SPR + WHERE SPR.SP_ACCESSNUMBER LIKE '%$redacc' AND YEAR(SPR.REQDATE) = YEAR(GETDATE()) + ORDER BY SPR.REQDATE DESC"; + $query = $db->query($sql); + $row = $query->getRowArray(); + $accessnumber = $row['SP_ACCESSNUMBER'] ?? null; + + if (!$accessnumber) { + return $this->response->setJSON(['data' => null]); + } + } + + $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 @@ -38,6 +59,7 @@ class SamplesController extends BaseController 'ktp' => $results['DMG_CKTPNO'] ?? '', 'comment' => $results['COMMENTTEXT'] ?? '', 'accessnumber' => $accessnumber, + 'scannedSampleCode' => $scannedSampleCode, ]; $samples = []; diff --git a/app/Views/phlebo/collect.php b/app/Views/phlebo/collect.php index fcb64c4..f4c5c3a 100644 --- a/app/Views/phlebo/collect.php +++ b/app/Views/phlebo/collect.php @@ -100,7 +100,10 @@ $roleConfig = $config['phlebo'];
-