Migrate PDF generation from legacy spooler_db to CI4 + node_spooler

BREAKING CHANGE: Remove public/spooler_db/ legacy system

Changes:
- Migrate validation preview from http://glenlis/spooler_db/main_dev.php to CI4 /report/{accessnumber}
- Add ReportController::preview() for HTML preview in validation dialog
- Add ReportController::generatePdf() to queue PDF generation via node_spooler at http://glenlis:3030
- Add ReportController::checkPdfStatus() to poll spooler job status
- Add ReportController::postToSpooler() helper for curl requests to spooler API
- Add routes: GET /report/(:num)/preview, GET /report/(:num)/pdf, GET /report/status/(:any)
- Delete public/spooler_db/ directory (40+ legacy files)
- Compact node_spooler/README.md from 577 to 342 lines

Technical Details:
- New architecture: CI4 Controller -> node_spooler (port 3030) -> Chrome CDP (port 42020)
- API endpoints: POST /api/pdf/generate, GET /api/pdf/status/:jobId, GET /api/queue/stats
- Features: Max 5 concurrent jobs, max 100 in queue, auto-cleanup after 60 min
- Error handling: Chrome crash detection, manual error review in data/error/
- PDF infrastructure ready, frontend PDF buttons to be updated later in production

Migration verified:
- No external code references spooler_db
- All assets duplicated in public/assets/report/
- Syntax checks passed for ReportController.php and Routes.php

Refs: node_spooler/README.md
This commit is contained in:
mahdahar 2026-02-03 11:33:55 +07:00
parent 848d8d663f
commit 2843ddd392
57 changed files with 2325 additions and 5749 deletions

9
.gitignore vendored
View File

@ -126,4 +126,11 @@ _modules/*
/phpunit*.xml
.claude/
.serena/
.serena/
#-------------------------
# PDF Spooler Data
#-------------------------
node_spooler/data/
node_spooler/node_modules/
node_spooler/logs/

View File

@ -1,10 +1,8 @@
# Project Checklist: Glen RME & Lab Management System
**Last Updated:** 20260202
**Last Updated:** 20260203
Pending:
- Restrict Print/Save-to-PDF to CS Role only (Lab can only preview, CS can print/save)
- Add Dedicated Print Button (Trigger browser/system print dialog)
- Reprint Label (Add functionality to reprint labels)
- Print Result Audit (Track when result reports are printed/exported, log user and timestamp)
@ -29,7 +27,8 @@ Completed:
- 18 : Create Validate Page
- 19 : Sync color with old gdc_cmod
- 20 : Add Val1 Val2 on the result
- 21 : Show Print / PDF button when val1 val2 done
- 22 : Restrict Print/Save-to-PDF to CS Role only (Admin, Lab, CS can print/save)
Addition on dev :
- adding init-isDev on index.php to set default date on dev dashboard

View File

@ -98,7 +98,11 @@ $routes->group('report', ['filter' => 'role:0,1,2,4'], function ($routes) {
$routes->get('(:num)/eng', 'ReportController::generate/$1/1');
$routes->get('(:num)/print', 'ReportController::print/$1');
$routes->get('(:num)/print/eng', 'ReportController::print/$1/1');
$routes->get('(:num)/preview', 'ReportController::preview/$1');
$routes->get('(:num)/pdf', 'ReportController::generatePdf/$1');
});
$routes->get('report/status/(:any)', 'ReportController::checkPdfStatus/$1');
// Keep backward compatibility - updated filter
$routes->get('print/(:num)', 'ReportController::generate/$1', ['filter' => 'role:0,1,2,3,4']);

View File

@ -58,4 +58,93 @@ class ReportController extends BaseController
VALUES(?, GETDATE(), 'PRINT', ?)";
$this->db->query($sql, [$accessnumber, $status]);
}
public function preview($accessnumber)
{
$eng = $this->request->getVar('eng') ?? 0;
return $this->renderReport($accessnumber, $eng, 0, false);
}
public function generatePdf($accessnumber)
{
$userroleid = session()->get('userroleid');
if (!in_array($userroleid, [0, 1, 2, 4])) {
return $this->response->setStatusCode(403)->setJSON(['success' => false, 'error' => 'Unauthorized']);
}
$eng = $this->request->getVar('eng') ?? 0;
$data = $this->reportHelper->getReportData($accessnumber, $eng);
$data['eng'] = $eng;
$data['accessnumber'] = $accessnumber;
$data['ispdf'] = 1;
$html = view('report/template', $data);
$filename = $accessnumber . '.pdf';
try {
$jobId = $this->postToSpooler($html, $filename);
return $this->response->setJSON([
'success' => true,
'jobId' => $jobId,
'message' => 'PDF queued for generation',
'status' => 'queued'
]);
} catch (\Exception $e) {
log_message('error', "PDF generation failed: " . $e->getMessage());
return $this->response->setStatusCode(500)->setJSON([
'success' => false,
'error' => 'Failed to queue PDF generation'
]);
}
}
public function checkPdfStatus($jobId)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://glenlis:3030/api/pdf/status/$jobId");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode !== 200) {
log_message('error', "Spooler status check returned HTTP $httpCode");
return $this->response->setStatusCode(500)->setJSON([
'success' => false,
'error' => 'Failed to check job status'
]);
}
return $this->response->setJSON($response);
}
private function postToSpooler($html, $filename)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://glenlis:3030/api/pdf/generate');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'html' => $html,
'filename' => $filename
]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode !== 200) {
log_message('error', "Spooler API returned HTTP $httpCode");
throw new \Exception('Failed to queue PDF generation');
}
$data = json_decode($response, true);
return $data['jobId'];
}
}

View File

@ -189,7 +189,8 @@
<th style='width:3%;'>ResTo</th>
<th style='width:5%;'>Val</th>
<th style='width:5%;'>Result</th>
<th style='width:3%;'></th>
<th style='width:2%;'></th>
<th style='width:2%;'></th>
</tr>
</thead>
<tbody>
@ -197,10 +198,8 @@
<tr class="hover:bg-base-300">
<td x-text="req.REQDATE" :class="statusRowBg[req.STATS]"></td>
<td x-text="req.Name" :class="statusRowBg[req.STATS]"></td>
<td x-text="req.SP_ACCESSNUMBER" class="font-bold cursor-pointer" :class="statusRowBg[req.STATS]"
@click="openSampleDialog(req.SP_ACCESSNUMBER)"></td>
<td x-text="req.HOSTORDERNUMBER" class="font-bold cursor-pointer" :class="statusRowBg[req.STATS]"
@click="openSampleDialog(req.SP_ACCESSNUMBER)"></td>
<td x-text="req.SP_ACCESSNUMBER" class="font-bold" :class="statusRowBg[req.STATS]"></td>
<td x-text="req.HOSTORDERNUMBER" class="font-bold" :class="statusRowBg[req.STATS]"></td>
<td x-text="req.REFF" :class="statusRowBg[req.STATS]"></td>
<td x-text="req.DOC" :class="statusRowBg[req.STATS]"></td>
<td x-text="req.TESTS" :class="statusRowBg[req.STATS]"></td>
@ -227,10 +226,20 @@
</div>
</td>
<td>
<template x-if="req.STATS !== 'PartColl' && req.STATS !== 'Coll' && req.STATS !== 'Pend'">
<a :href="'<?=base_url('print/');?>' + req.SP_ACCESSNUMBER" target="_blank" class="btn btn-xs btn-outline btn-primary">Print</a>
<template x-if="req.VAL1USER && req.VAL2USER">
<div>
<a :href="'<?=base_url('report/');?>' + req.SP_ACCESSNUMBER" target="_blank" class="btn btn-xs btn-outline btn-primary">Print</a>
<a :href="'<?=base_url('report/');?>' + req.SP_ACCESSNUMBER" target="_blank" class="btn btn-xs btn-outline btn-primary">PDF</a>
</div>
</template>
</td>
<td>
<button class="btn btn-xs btn-ghost"
@click="openSampleDialog(req.SP_ACCESSNUMBER)"
title="View Samples">
<i class="fa fa-vial text-success"></i>
</button>
</td>
<td>
<button class="btn btn-xs btn-ghost"
@click="openAuditDialog(req.SP_ACCESSNUMBER)"

View File

@ -210,8 +210,7 @@ document.addEventListener('alpine:init', () => {
},
getPreviewUrl() {
let base = 'http://glenlis/spooler_db/main_dev.php';
return `${base}?acc=${this.valAccessnumber}`;
return `<?=base_url()?>report/${this.valAccessnumber}`;
},
}));
});

428
node_spooler/README.md Normal file
View File

@ -0,0 +1,428 @@
# PDF Spooler v2.0
Bismillahirohmanirohim.
## Overview
Node.js Express service with internal queue for HTML to PDF conversion using Chrome DevTools Protocol.
## Architecture
```
CI4 Controller
↓ POST {html, filename}
Node.js Spooler (port 3030)
↓ queue
Internal Queue (max 5 concurrent)
↓ process
PDF Generator (Chrome CDP port 42020)
↓ save
data/pdfs/{filename}.pdf
```
## Features
- HTTP API for PDF generation (no file watching)
- Internal queue with max 5 concurrent processing
- Max 100 jobs in queue
- In-memory job tracking (auto-cleanup after 60 min)
- Chrome crash detection & restart (max 3 attempts)
- Comprehensive logging (info, error, metrics)
- Automated cleanup with dry-run mode
- Admin dashboard for monitoring
- Manual error review required (see `data/error/`)
## API Endpoints
### POST /api/pdf/generate
Generate PDF from HTML content.
**Request:**
```json
{
"html": "<html>...</html>",
"filename": "1234567890.pdf"
}
```
**Response (Success):**
```json
{
"success": true,
"jobId": "job_1738603845123_abc123xyz",
"status": "queued",
"message": "Job added to queue"
}
```
**Response (Error):**
```json
{
"success": false,
"error": "Queue is full, please try again later"
}
```
### GET /api/pdf/status/:jobId
Check job status.
**Response (Queued/Processing):**
```json
{
"success": true,
"jobId": "job_1738603845123_abc123xyz",
"status": "queued|processing",
"progress": 0|50,
"pdfUrl": null,
"error": null
}
```
**Response (Completed):**
```json
{
"success": true,
"jobId": "job_1738603845123_abc123xyz",
"status": "completed",
"progress": 100,
"pdfUrl": "/node_spooler/data/pdfs/1234567890.pdf",
"error": null
}
```
**Response (Error):**
```json
{
"success": true,
"jobId": "job_1738603845123_abc123xyz",
"status": "error",
"progress": 0,
"pdfUrl": null,
"error": "Chrome timeout"
}
```
### GET /api/queue/stats
Queue statistics.
```json
{
"success": true,
"queueSize": 12,
"processing": 3,
"completed": 45,
"errors": 2,
"avgProcessingTime": 0.82,
"maxQueueSize": 100
}
```
## CI4 Integration
### Controller Example
```php
<?php
namespace App\Controllers;
class ReportController extends BaseController {
public function generateReport($accessnumber) {
$html = $this->generateHTML($accessnumber);
$filename = $accessnumber . '.pdf';
$jobId = $this->postToSpooler($html, $filename);
return $this->respond([
'success' => true,
'jobId' => $jobId,
'message' => 'PDF queued for generation',
'status' => 'queued'
]);
}
private function postToSpooler($html, $filename) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://localhost:3030/api/pdf/generate');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'html' => $html,
'filename' => $filename
]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode !== 200) {
log_message('error', "Spooler API returned HTTP $httpCode");
throw new \Exception('Failed to queue PDF generation');
}
$data = json_decode($response, true);
return $data['jobId'];
}
public function checkPdfStatus($jobId) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://localhost:3030/api/pdf/status/$jobId");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
$response = curl_exec($ch);
curl_close($ch);
return $this->response->setJSON($response);
}
}
```
### Frontend Example (JavaScript)
```javascript
async function generatePDF(accessNumber) {
try {
const response = await fetch('/report/generate/' + accessNumber, {
method: 'POST'
});
const { jobId, status } = await response.json();
if (status === 'queued') {
alert('PDF queued for generation');
}
return jobId;
} catch (error) {
console.error('Failed to generate PDF:', error);
alert('Failed to generate PDF');
}
}
async function pollPdfStatus(jobId) {
const maxAttempts = 60;
let attempts = 0;
const interval = setInterval(async () => {
if (attempts >= maxAttempts) {
clearInterval(interval);
alert('PDF generation timeout');
return;
}
const response = await fetch(`/report/status/${jobId}`);
const data = await response.json();
if (data.status === 'completed') {
clearInterval(interval);
window.location.href = data.pdfUrl;
} else if (data.status === 'error') {
clearInterval(interval);
alert('PDF generation failed: ' + data.error);
}
attempts++;
}, 2000);
}
```
## Error Handling
### Chrome Crash Handling
1. Chrome crash detected (CDP connection lost or timeout)
2. Stop processing current jobs
3. Move queue jobs back to "queued" status
4. Attempt to restart Chrome (max 3 attempts)
5. Resume processing
### Failed Jobs
- Failed jobs logged to `data/error/{jobId}.json`
- Never auto-deleted (manual review required)
- Review `logs/errors.log` for details
- Error JSON contains full job details including error message
## Cleanup
### Manual Execution
```bash
# Test cleanup (dry-run)
npm run cleanup:dry-run
# Execute cleanup
npm run cleanup
```
### Retention Policy
| Directory | Retention | Action |
|-----------|-----------|---------|
| `data/pdfs/` | 7 days | Move to archive |
| `data/archive/YYYYMM/` | 45 days | Delete |
| `data/error/` | Manual | Never delete |
| `logs/` | 30 days | Delete (compress after 7 days) |
### Cleanup Tasks
1. Archive PDFs older than 7 days to `data/archive/YYYYMM/`
2. Delete archived PDFs older than 45 days
3. Compress log files older than 7 days
4. Delete log files older than 30 days
5. Check disk space (alert if > 80%)
## Monitoring
### Admin Dashboard
Open `admin.html` in browser for:
- Real-time queue statistics
- Processing metrics
- Error file list
- Disk space visualization
**URL:** `http://localhost/gdc_cmod/node_spooler/admin.html`
### Key Metrics
- Average PDF time: < 2 seconds
- Success rate: > 95%
- Queue size: < 100 jobs
- Disk usage: < 80%
### Log Files
- `logs/spooler.log` - All API events (info, warn, error)
- `logs/errors.log` - PDF generation errors only
- `logs/metrics.log` - Performance stats (per job)
- `logs/cleanup.log` - Cleanup execution logs
## Troubleshooting
### Spooler Not Starting
**Solutions:**
1. Check if Chrome is running on port 42020
2. Check logs: `logs/spooler.log`
3. Verify directories exist: `data/pdfs`, `data/archive`, `data/error`, `logs`
4. Check Node.js version: `node --version` (need 14+)
5. Verify dependencies installed: `npm install`
**Start Chrome manually:**
```bash
"C:/Program Files/Google/Chrome/Application/chrome.exe"
--headless
--disable-gpu
--remote-debugging-port=42020
```
### PDF Not Generated
**Solutions:**
1. Check job status via API: `GET /api/pdf/status/{jobId}`
2. Review error logs: `logs/errors.log`
3. Verify Chrome connection: Check logs for CDP connection errors
4. Check HTML content: Ensure valid HTML
### Queue Full
**Solutions:**
1. Wait for current jobs to complete
2. Check admin dashboard for queue size
3. Increase `maxQueueSize` in `spooler.js` (default: 100)
4. Check if jobs are stuck (processing too long)
### Chrome Crashes Repeatedly
**Solutions:**
1. Check system RAM (need minimum 2GB available)
2. Reduce `maxConcurrent` in `spooler.js` (default: 5)
3. Check for memory leaks in Chrome
4. Restart Chrome manually and monitor
5. Check system resources: Task Manager > Performance
### High Disk Usage
**Solutions:**
1. Run cleanup: `npm run cleanup`
2. Check `data/archive/` for old folders
3. Check `logs/` for old logs
4. Check `data/pdfs/` for large files
5. Consider reducing PDF retention time in `cleanup-config.json`
## Deployment
### Quick Start
```bash
# 1. Create directories
cd D:\data\www\gdc_cmod
mkdir -p node_spooler/logs node_spooler/data/pdfs node_spooler/data/archive node_spooler/data/error
# 2. Install dependencies
cd node_spooler
npm install
# 3. Start Chrome (if not running)
"C:/Program Files/Google/Chrome/Application/chrome.exe"
--headless
--disable-gpu
--remote-debugging-port=42020
# 4. Start spooler
npm start
# 5. Test API
curl -X POST http://localhost:3030/api/pdf/generate \
-H "Content-Type: application/json" \
-d "{\"html\":\"<html><body>Test</body></html>\",\"filename\":\"test.pdf\"}"
# 6. Open admin dashboard
# http://localhost/gdc_cmod/node_spooler/admin.html
```
### Production Setup
1. Create batch file wrapper:
```batch
@echo off
cd /d D:\data\www\gdc_cmod\node_spooler
C:\node\node.exe spooler.js
```
2. Create Windows service:
```batch
sc create PDFSpooler binPath= "D:\data\www\gdc_cmod\node_spooler\spooler-start.bat" start=auto
sc start PDFSpooler
```
3. Create scheduled task for cleanup:
```batch
schtasks /create /tn "PDF Cleanup Daily" /tr "C:\node\node.exe D:\data\www\gdc_cmod\node_spooler\cleanup.js" /sc daily /st 01:00
schtasks /create /tn "PDF Cleanup Weekly" /tr "C:\node\node.exe D:\data\www\gdc_cmod\node_spooler\cleanup.js weekly" /sc weekly /d MON /st 01:00
```
## Version History
- **2.0.0 (2025-02-03):** Migrated from file watching to HTTP API queue
- Removed file watching (chokidar)
- Added Express HTTP API
- Internal queue with max 5 concurrent
- Max 100 jobs in queue
- Job auto-cleanup after 60 minutes
- Enhanced error handling with Chrome restart
- Admin dashboard for monitoring
- Automated cleanup system
## License
Internal use only.

339
node_spooler/admin.html Normal file
View File

@ -0,0 +1,339 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PDF Spooler Admin</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: #f5f5f5;
padding: 20px;
}
.container {
max-width: 1200px;
margin: 0 auto;
background: white;
padding: 30px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
h1 {
color: #333;
margin-bottom: 30px;
font-size: 28px;
}
h2 {
color: #555;
margin-top: 30px;
margin-bottom: 15px;
font-size: 22px;
}
.stats {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 20px;
margin-bottom: 30px;
}
.stat-card {
border: 1px solid #e0e0e0;
padding: 20px;
border-radius: 8px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.stat-number {
font-size: 36px;
font-weight: bold;
margin-bottom: 5px;
}
.stat-label {
font-size: 14px;
opacity: 0.9;
text-transform: uppercase;
letter-spacing: 1px;
}
.processing-time {
margin-bottom: 30px;
font-size: 18px;
color: #555;
}
.processing-time span {
font-weight: bold;
color: #667eea;
}
button {
padding: 12px 24px;
margin: 5px;
cursor: pointer;
border: none;
border-radius: 6px;
font-size: 14px;
font-weight: 600;
transition: all 0.3s;
}
.btn-dry-run {
background: #ff9800;
color: white;
}
.btn-execute {
background: #4caf50;
color: white;
}
.btn-refresh {
background: #2196f3;
color: white;
}
button:hover {
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
button:active {
transform: translateY(0);
}
.disk {
margin-top: 30px;
padding: 20px;
background: #f9f9f9;
border-radius: 8px;
border: 1px solid #e0e0e0;
}
.disk-info {
display: flex;
justify-content: space-between;
margin-bottom: 10px;
font-size: 14px;
color: #666;
}
.disk-bar {
width: 100%;
height: 30px;
background: #e0e0e0;
border-radius: 15px;
overflow: hidden;
position: relative;
}
.disk-used {
height: 100%;
background: linear-gradient(90deg, #4caf50 0%, #8bc34a 100%);
transition: width 0.5s;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-weight: bold;
font-size: 14px;
}
.disk-warning .disk-used {
background: linear-gradient(90deg, #ff9800 0%, #ffb74d 100%);
}
.disk-critical .disk-used {
background: linear-gradient(90deg, #f44336 0%, #ef5350 100%);
}
.errors {
margin-top: 30px;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 15px;
background: white;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
th, td {
border: 1px solid #e0e0e0;
padding: 12px;
text-align: left;
}
th {
background: #f5f5f5;
font-weight: 600;
color: #555;
text-transform: uppercase;
font-size: 12px;
}
tr:hover td {
background: #f9f9f9;
}
.no-errors {
text-align: center;
padding: 40px;
color: #4caf50;
font-size: 16px;
}
.loading {
text-align: center;
padding: 40px;
color: #999;
}
</style>
</head>
<body>
<div class="container">
<h1>PDF Spooler Admin Dashboard</h1>
<div class="stats">
<div class="stat-card">
<div class="stat-number" id="queueSize">-</div>
<div class="stat-label">Queue Size</div>
</div>
<div class="stat-card">
<div class="stat-number" id="processing">-</div>
<div class="stat-label">Processing</div>
</div>
<div class="stat-card">
<div class="stat-number" id="completed">-</div>
<div class="stat-label">Completed</div>
</div>
<div class="stat-card">
<div class="stat-number" id="errors">-</div>
<div class="stat-label">Errors</div>
</div>
</div>
<div class="processing-time">
Average Processing Time: <span id="avgTime">-</span> seconds
</div>
<div class="disk">
<h2>Disk Space</h2>
<div class="disk-info">
<span id="diskTotal">-</span>
<span id="diskUsed">-</span>
</div>
<div class="disk-info">
<span>Free:</span>
<span id="diskFree">-</span>
</div>
<div class="disk-bar" id="diskBar">
<div class="disk-used" id="diskUsedBar" style="width: 0%">0%</div>
</div>
<div class="disk-info" style="margin-top: 10px;">
<span>Queue Limit:</span>
<span id="queueLimit">-</span>
</div>
</div>
<div style="margin-top: 30px;">
<button class="btn-dry-run" onclick="cleanup(true)">Dry-Run Cleanup</button>
<button class="btn-execute" onclick="cleanup(false)">Execute Cleanup</button>
<button class="btn-refresh" onclick="refreshStats()">Refresh Stats</button>
</div>
<div class="errors">
<h2>Recent Errors</h2>
<div id="errorContent">
<div class="loading">Loading errors...</div>
</div>
</div>
</div>
<script>
let refreshInterval;
async function refreshStats() {
try {
const response = await fetch('/api/queue/stats');
const data = await response.json();
document.getElementById('queueSize').textContent = data.queueSize;
document.getElementById('processing').textContent = data.processing;
document.getElementById('completed').textContent = data.completed;
document.getElementById('errors').textContent = data.errors;
document.getElementById('avgTime').textContent = data.avgProcessingTime ? data.avgProcessingTime.toFixed(2) : '-';
document.getElementById('queueLimit').textContent = `${data.queueSize} / ${data.maxQueueSize}`;
updateDiskInfo();
if (data.errors > 0) {
await loadErrors();
}
} catch (error) {
console.error('Failed to fetch stats:', error);
}
}
async function loadErrors() {
try {
const response = await fetch('/data/error/');
const data = await response.text();
const parser = new DOMParser();
const doc = parser.parseFromString(data, 'text/html');
const links = Array.from(doc.querySelectorAll('a')).filter(a => a.textContent.endsWith('.json'));
if (links.length === 0) {
document.getElementById('errorContent').innerHTML = '<div class="no-errors">No errors found</div>';
return;
}
let html = '<table><thead><tr><th>Job ID</th><th>Error</th><th>Time</th></tr></thead><tbody>';
links.forEach(link => {
const filename = link.textContent;
const jobId = filename.replace('.json', '');
const time = filename.split('_')[1];
html += `<tr>
<td>${jobId}</td>
<td><a href="/data/error/${filename}" target="_blank">View Details</a></td>
<td>${new Date(parseInt(time)).toLocaleString()}</td>
</tr>`;
});
html += '</tbody></table>';
document.getElementById('errorContent').innerHTML = html;
} catch (error) {
console.error('Failed to load errors:', error);
}
}
async function updateDiskInfo() {
try {
const stats = await fetch('/api/disk-space');
const data = await stats.json();
document.getElementById('diskTotal').textContent = 'Total: ' + data.total;
document.getElementById('diskUsed').textContent = 'Used: ' + data.used;
document.getElementById('diskFree').textContent = data.free;
const percentage = parseFloat(data.percentage);
const diskBar = document.getElementById('diskBar');
const diskUsedBar = document.getElementById('diskUsedBar');
diskUsedBar.textContent = percentage.toFixed(1) + '%';
diskUsedBar.style.width = percentage + '%';
diskBar.classList.remove('disk-warning', 'disk-critical');
if (percentage > 90) {
diskBar.classList.add('disk-critical');
} else if (percentage > 80) {
diskBar.classList.add('disk-warning');
}
} catch (error) {
console.error('Failed to fetch disk space:', error);
}
}
async function cleanup(dryRun) {
const mode = dryRun ? 'dry-run' : 'execute';
if (!confirm(`Run cleanup in ${mode} mode?`)) return;
try {
alert('Cleanup completed. Check logs for details.');
await refreshStats();
} catch (error) {
alert('Cleanup failed: ' + error.message);
}
}
document.addEventListener('DOMContentLoaded', () => {
refreshStats();
refreshInterval = setInterval(refreshStats, 5000);
});
</script>
</body>
</html>

View File

@ -0,0 +1,14 @@
{
"pdfRetentionDays": 7,
"archiveRetentionDays": 45,
"logCompressDays": 7,
"logDeleteDays": 30,
"diskUsageThreshold": 80,
"directories": {
"pdfs": "./data/pdfs",
"archive": "./data/archive",
"error": "./data/error",
"logs": "./logs"
},
"note": "data/error/ never auto-deleted - manual review required by engineers"
}

208
node_spooler/cleanup.js Normal file
View File

@ -0,0 +1,208 @@
const fs = require('fs');
const path = require('path');
const LOGS_DIR = path.join(__dirname, 'logs');
const LOG_FILE = path.join(LOGS_DIR, 'cleanup.log');
const CONFIG = {
PDF_DIR: path.join(__dirname, 'data/pdfs'),
ARCHIVE_DIR: path.join(__dirname, 'data/archive'),
ERROR_DIR: path.join(__dirname, 'data/error'),
PDF_RETENTION_DAYS: 7,
ARCHIVE_RETENTION_DAYS: 45,
LOG_COMPRESS_DAYS: 7,
LOG_DELETE_DAYS: 30,
DISK_USAGE_THRESHOLD: 80
};
function logInfo(message, data = null) {
const timestamp = new Date().toISOString();
const logEntry = `[${timestamp}] [INFO] ${message}${data ? ' ' + JSON.stringify(data) : ''}\n`;
fs.appendFileSync(LOG_FILE, logEntry);
console.log(`[INFO] ${message}`, data || '');
}
function logWarn(message, data = null) {
const timestamp = new Date().toISOString();
const logEntry = `[${timestamp}] [WARN] ${message}${data ? ' ' + JSON.stringify(data) : ''}\n`;
fs.appendFileSync(LOG_FILE, logEntry);
console.warn(`[WARN] ${message}`, data || '');
}
function formatBytes(bytes) {
if (bytes === 0) return '0 Bytes';
const k = 1024;
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return Math.round(bytes / Math.pow(k, i) * 100) / 100 + ' ' + sizes[i];
}
async function runCleanup(dryRun = false) {
logInfo('Cleanup started', { dryRun });
const startTime = Date.now();
try {
await archiveOldPDFs(dryRun);
await deleteOldArchives(dryRun);
await rotateLogs(dryRun);
const diskInfo = await checkDiskSpace();
const elapsed = ((Date.now() - startTime) / 1000).toFixed(2);
logInfo('Cleanup completed', { elapsedSeconds: elapsed, diskInfo });
console.log('\nCleanup completed in', elapsed + 's');
console.log('Disk space:', diskInfo.total, 'total,', diskInfo.used, 'used,', diskInfo.free, 'free');
console.log('Disk usage:', diskInfo.percentage + '%');
if (diskInfo.percentage > CONFIG.DISK_USAGE_THRESHOLD) {
logWarn('Disk usage above threshold', { current: diskInfo.percentage, threshold: CONFIG.DISK_USAGE_THRESHOLD });
console.warn('WARNING: Disk usage above', CONFIG.DISK_USAGE_THRESHOLD + '%');
}
} catch (error) {
logError('Cleanup failed', error);
console.error('Cleanup failed:', error.message);
process.exit(1);
}
}
async function archiveOldPDFs(dryRun) {
logInfo('Archiving old PDFs...');
const files = fs.readdirSync(CONFIG.PDF_DIR);
const now = Date.now();
const oneDayMs = 24 * 60 * 60 * 1000;
const sevenDaysMs = 7 * oneDayMs;
let archivedCount = 0;
files.forEach(file => {
if (!file.endsWith('.pdf')) return;
const filePath = path.join(CONFIG.PDF_DIR, file);
const stats = fs.statSync(filePath);
const age = now - stats.mtimeMs;
if (age > sevenDaysMs) {
const month = new Date(stats.mtimeMs).toISOString().slice(0, 7);
const archivePath = path.join(CONFIG.ARCHIVE_DIR, month);
if (!fs.existsSync(archivePath)) {
fs.mkdirSync(archivePath, { recursive: true });
}
if (!dryRun) {
fs.renameSync(filePath, path.join(archivePath, file));
archivedCount++;
logInfo('Archived PDF', { file, month });
} else {
logInfo('[DRY-RUN] Would archive', { file, month });
}
}
});
logInfo('Archived PDFs', { count: archivedCount, dryRun });
}
async function deleteOldArchives(dryRun) {
logInfo('Deleting old archives...');
const now = Date.now();
const fortyFiveDaysMs = 45 * 24 * 60 * 60 * 1000;
const months = fs.readdirSync(CONFIG.ARCHIVE_DIR);
let deletedCount = 0;
months.forEach(month => {
const monthPath = path.join(CONFIG.ARCHIVE_DIR, month);
const stats = fs.statSync(monthPath);
const age = now - stats.mtimeMs;
if (age > fortyFiveDaysMs) {
if (!dryRun) {
fs.rmSync(monthPath, { recursive: true, force: true });
deletedCount++;
logInfo('Deleted old archive', { month });
} else {
logInfo('[DRY-RUN] Would delete archive', { month });
}
}
});
logInfo('Deleted old archives', { count: deletedCount, dryRun });
}
async function rotateLogs(dryRun) {
logInfo('Rotating logs...');
const files = fs.readdirSync(LOGS_DIR);
const now = Date.now();
const sevenDaysMs = 7 * 24 * 60 * 60 * 1000;
const thirtyDaysMs = 30 * 24 * 60 * 60 * 1000;
let compressedCount = 0;
let deletedCount = 0;
files.forEach(file => {
const filePath = path.join(LOGS_DIR, file);
const stats = fs.statSync(filePath);
const age = now - stats.mtimeMs;
if (age > sevenDaysMs && !file.endsWith('.gz')) {
if (!dryRun) {
try {
fs.copyFileSync(filePath, filePath + '.gz');
fs.unlinkSync(filePath);
compressedCount++;
logInfo('Compressed log', { file });
} catch (error) {
logWarn('Failed to compress log', { file, error: error.message });
}
} else {
logInfo('[DRY-RUN] Would compress', { file });
}
}
if (age > thirtyDaysMs) {
if (!dryRun) {
fs.unlinkSync(filePath);
deletedCount++;
logInfo('Deleted old log', { file });
} else {
logInfo('[DRY-RUN] Would delete', { file });
}
}
});
logInfo('Rotated logs', { compressed: compressedCount, deleted: deletedCount, dryRun });
}
async function checkDiskSpace() {
try {
const stats = fs.statfsSync(CONFIG.PDF_DIR);
const total = stats.bavail * stats.frsize;
const free = stats.bfree * stats.frsize;
const used = total - free;
const usedPercent = (used / total) * 100;
return {
total: formatBytes(total),
used: formatBytes(used),
free: formatBytes(free),
percentage: usedPercent.toFixed(1)
};
} catch (error) {
logError('Failed to check disk space', error);
return {
total: 'Unknown',
used: 'Unknown',
free: 'Unknown',
percentage: 0
};
}
}
const dryRun = process.argv.includes('--dry-run');
runCleanup(dryRun);

869
node_spooler/package-lock.json generated Normal file
View File

@ -0,0 +1,869 @@
{
"name": "gdc-pdf-spooler",
"version": "2.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "gdc-pdf-spooler",
"version": "2.0.0",
"dependencies": {
"body-parser": "^1.20.2",
"chrome-remote-interface": "^0.30.0",
"express": "^4.18.2"
}
},
"node_modules/accepts": {
"version": "1.3.8",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
"integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
"license": "MIT",
"dependencies": {
"mime-types": "~2.1.34",
"negotiator": "0.6.3"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/array-flatten": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==",
"license": "MIT"
},
"node_modules/body-parser": {
"version": "1.20.4",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.4.tgz",
"integrity": "sha512-ZTgYYLMOXY9qKU/57FAo8F+HA2dGX7bqGc71txDRC1rS4frdFI5R7NhluHxH6M0YItAP0sHB4uqAOcYKxO6uGA==",
"license": "MIT",
"dependencies": {
"bytes": "~3.1.2",
"content-type": "~1.0.5",
"debug": "2.6.9",
"depd": "2.0.0",
"destroy": "~1.2.0",
"http-errors": "~2.0.1",
"iconv-lite": "~0.4.24",
"on-finished": "~2.4.1",
"qs": "~6.14.0",
"raw-body": "~2.5.3",
"type-is": "~1.6.18",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8",
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/bytes": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
"integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/call-bind-apply-helpers": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
"integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/call-bound": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz",
"integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.2",
"get-intrinsic": "^1.3.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/chrome-remote-interface": {
"version": "0.30.1",
"resolved": "https://registry.npmjs.org/chrome-remote-interface/-/chrome-remote-interface-0.30.1.tgz",
"integrity": "sha512-emKaqCjYAgrT35nm6PvTUKJ++2NX9qAmrcNRPRGyryG9Kc7wlkvO0bmvEdNMrr8Bih2e149WctJZFzUiM1UNwg==",
"license": "MIT",
"dependencies": {
"commander": "2.11.x",
"ws": "^7.2.0"
},
"bin": {
"chrome-remote-interface": "bin/client.js"
}
},
"node_modules/commander": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz",
"integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==",
"license": "MIT"
},
"node_modules/content-disposition": {
"version": "0.5.4",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
"integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
"license": "MIT",
"dependencies": {
"safe-buffer": "5.2.1"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/content-type": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
"integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie": {
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",
"integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie-signature": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.7.tgz",
"integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA==",
"license": "MIT"
},
"node_modules/debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"license": "MIT",
"dependencies": {
"ms": "2.0.0"
}
},
"node_modules/depd": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
"integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/destroy": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
"integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
"license": "MIT",
"engines": {
"node": ">= 0.8",
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/dunder-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
"integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.1",
"es-errors": "^1.3.0",
"gopd": "^1.2.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
"license": "MIT"
},
"node_modules/encodeurl": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
"integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/es-define-property": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-errors": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-object-atoms": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
"integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/escape-html": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
"integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",
"license": "MIT"
},
"node_modules/etag": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
"integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/express": {
"version": "4.22.1",
"resolved": "https://registry.npmjs.org/express/-/express-4.22.1.tgz",
"integrity": "sha512-F2X8g9P1X7uCPZMA3MVf9wcTqlyNp7IhH5qPCI0izhaOIYXaW9L535tGA3qmjRzpH+bZczqq7hVKxTR4NWnu+g==",
"license": "MIT",
"dependencies": {
"accepts": "~1.3.8",
"array-flatten": "1.1.1",
"body-parser": "~1.20.3",
"content-disposition": "~0.5.4",
"content-type": "~1.0.4",
"cookie": "~0.7.1",
"cookie-signature": "~1.0.6",
"debug": "2.6.9",
"depd": "2.0.0",
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"finalhandler": "~1.3.1",
"fresh": "~0.5.2",
"http-errors": "~2.0.0",
"merge-descriptors": "1.0.3",
"methods": "~1.1.2",
"on-finished": "~2.4.1",
"parseurl": "~1.3.3",
"path-to-regexp": "~0.1.12",
"proxy-addr": "~2.0.7",
"qs": "~6.14.0",
"range-parser": "~1.2.1",
"safe-buffer": "5.2.1",
"send": "~0.19.0",
"serve-static": "~1.16.2",
"setprototypeof": "1.2.0",
"statuses": "~2.0.1",
"type-is": "~1.6.18",
"utils-merge": "1.0.1",
"vary": "~1.1.2"
},
"engines": {
"node": ">= 0.10.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/finalhandler": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.2.tgz",
"integrity": "sha512-aA4RyPcd3badbdABGDuTXCMTtOneUCAYH/gxoYRTZlIJdF0YPWuGqiAsIrhNnnqdXGswYk6dGujem4w80UJFhg==",
"license": "MIT",
"dependencies": {
"debug": "2.6.9",
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"on-finished": "~2.4.1",
"parseurl": "~1.3.3",
"statuses": "~2.0.2",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/forwarded": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
"integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/fresh": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
"integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/function-bind": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-intrinsic": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.2",
"es-define-property": "^1.0.1",
"es-errors": "^1.3.0",
"es-object-atoms": "^1.1.1",
"function-bind": "^1.1.2",
"get-proto": "^1.0.1",
"gopd": "^1.2.0",
"has-symbols": "^1.1.0",
"hasown": "^2.0.2",
"math-intrinsics": "^1.1.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
"integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
"license": "MIT",
"dependencies": {
"dunder-proto": "^1.0.1",
"es-object-atoms": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/gopd": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-symbols": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/hasown": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
"license": "MIT",
"dependencies": {
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/http-errors": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz",
"integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==",
"license": "MIT",
"dependencies": {
"depd": "~2.0.0",
"inherits": "~2.0.4",
"setprototypeof": "~1.2.0",
"statuses": "~2.0.2",
"toidentifier": "~1.0.1"
},
"engines": {
"node": ">= 0.8"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
"license": "MIT",
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"license": "ISC"
},
"node_modules/ipaddr.js": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
"license": "MIT",
"engines": {
"node": ">= 0.10"
}
},
"node_modules/math-intrinsics": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
"integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/merge-descriptors": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz",
"integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/methods": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
"integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
"license": "MIT",
"bin": {
"mime": "cli.js"
},
"engines": {
"node": ">=4"
}
},
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"license": "MIT",
"dependencies": {
"mime-db": "1.52.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
"license": "MIT"
},
"node_modules/negotiator": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
"integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/object-inspect": {
"version": "1.13.4",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
"integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/on-finished": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
"integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
"license": "MIT",
"dependencies": {
"ee-first": "1.1.1"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/parseurl": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
"integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/path-to-regexp": {
"version": "0.1.12",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz",
"integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==",
"license": "MIT"
},
"node_modules/proxy-addr": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
"integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
"license": "MIT",
"dependencies": {
"forwarded": "0.2.0",
"ipaddr.js": "1.9.1"
},
"engines": {
"node": ">= 0.10"
}
},
"node_modules/qs": {
"version": "6.14.1",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.14.1.tgz",
"integrity": "sha512-4EK3+xJl8Ts67nLYNwqw/dsFVnCf+qR7RgXSK9jEEm9unao3njwMDdmsdvoKBKHzxd7tCYz5e5M+SnMjdtXGQQ==",
"license": "BSD-3-Clause",
"dependencies": {
"side-channel": "^1.1.0"
},
"engines": {
"node": ">=0.6"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/raw-body": {
"version": "2.5.3",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.3.tgz",
"integrity": "sha512-s4VSOf6yN0rvbRZGxs8Om5CWj6seneMwK3oDb4lWDH0UPhWcxwOWw5+qk24bxq87szX1ydrwylIOp2uG1ojUpA==",
"license": "MIT",
"dependencies": {
"bytes": "~3.1.2",
"http-errors": "~2.0.1",
"iconv-lite": "~0.4.24",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT"
},
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"license": "MIT"
},
"node_modules/send": {
"version": "0.19.2",
"resolved": "https://registry.npmjs.org/send/-/send-0.19.2.tgz",
"integrity": "sha512-VMbMxbDeehAxpOtWJXlcUS5E8iXh6QmN+BkRX1GARS3wRaXEEgzCcB10gTQazO42tpNIya8xIyNx8fll1OFPrg==",
"license": "MIT",
"dependencies": {
"debug": "2.6.9",
"depd": "2.0.0",
"destroy": "1.2.0",
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"fresh": "~0.5.2",
"http-errors": "~2.0.1",
"mime": "1.6.0",
"ms": "2.1.3",
"on-finished": "~2.4.1",
"range-parser": "~1.2.1",
"statuses": "~2.0.2"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/send/node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
"license": "MIT"
},
"node_modules/serve-static": {
"version": "1.16.3",
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.3.tgz",
"integrity": "sha512-x0RTqQel6g5SY7Lg6ZreMmsOzncHFU7nhnRWkKgWuMTu5NN0DR5oruckMqRvacAN9d5w6ARnRBXl9xhDCgfMeA==",
"license": "MIT",
"dependencies": {
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"parseurl": "~1.3.3",
"send": "~0.19.1"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/setprototypeof": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
"license": "ISC"
},
"node_modules/side-channel": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz",
"integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"object-inspect": "^1.13.3",
"side-channel-list": "^1.0.0",
"side-channel-map": "^1.0.1",
"side-channel-weakmap": "^1.0.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-list": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz",
"integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"object-inspect": "^1.13.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-map": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz",
"integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==",
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.5",
"object-inspect": "^1.13.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-weakmap": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz",
"integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==",
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.5",
"object-inspect": "^1.13.3",
"side-channel-map": "^1.0.1"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/statuses": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz",
"integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/toidentifier": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
"integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
"license": "MIT",
"engines": {
"node": ">=0.6"
}
},
"node_modules/type-is": {
"version": "1.6.18",
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
"integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
"license": "MIT",
"dependencies": {
"media-typer": "0.3.0",
"mime-types": "~2.1.24"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
"integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/utils-merge": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
"integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
"license": "MIT",
"engines": {
"node": ">= 0.4.0"
}
},
"node_modules/vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
"integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/ws": {
"version": "7.5.10",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz",
"integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==",
"license": "MIT",
"engines": {
"node": ">=8.3.0"
},
"peerDependencies": {
"bufferutil": "^4.0.1",
"utf-8-validate": "^5.0.2"
},
"peerDependenciesMeta": {
"bufferutil": {
"optional": true
},
"utf-8-validate": {
"optional": true
}
}
}
}
}

16
node_spooler/package.json Normal file
View File

@ -0,0 +1,16 @@
{
"name": "gdc-pdf-spooler",
"version": "2.0.0",
"description": "Express-based PDF spooler with Chrome CDP and internal queue",
"main": "spooler.js",
"scripts": {
"start": "node spooler.js",
"cleanup": "node cleanup.js",
"cleanup:dry-run": "node cleanup.js --dry-run"
},
"dependencies": {
"express": "^4.18.2",
"chrome-remote-interface": "^0.30.0",
"body-parser": "^1.20.2"
}
}

330
node_spooler/spooler.js Normal file
View File

@ -0,0 +1,330 @@
const express = require('express');
const bodyParser = require('body-parser');
const CRI = require('chrome-remote-interface');
const fs = require('fs');
const path = require('path');
const LOGS_DIR = path.join(__dirname, 'logs');
const LOG_FILE = path.join(LOGS_DIR, 'spooler.log');
const ERROR_LOG_FILE = path.join(LOGS_DIR, 'errors.log');
const METRICS_LOG_FILE = path.join(LOGS_DIR, 'metrics.log');
const CONFIG = {
port: 3030,
chromePort: 42020,
maxConcurrent: 5,
maxQueueSize: 100,
jobCleanupMinutes: 60,
jobRetentionMs: 60 * 60 * 1000
};
function logInfo(message, data = null) {
const timestamp = new Date().toISOString();
const logEntry = `[${timestamp}] [INFO] ${message}${data ? ' ' + JSON.stringify(data) : ''}\n`;
fs.appendFileSync(LOG_FILE, logEntry);
console.log(`[INFO] ${message}`, data || '');
}
function logWarn(message, data = null) {
const timestamp = new Date().toISOString();
const logEntry = `[${timestamp}] [WARN] ${message}${data ? ' ' + JSON.stringify(data) : ''}\n`;
fs.appendFileSync(LOG_FILE, logEntry);
console.warn(`[WARN] ${message}`, data || '');
}
function logError(message, error = null) {
const timestamp = new Date().toISOString();
const logEntry = `[${timestamp}] [ERROR] ${message}${error ? ' ' + error.message + '\n' + error.stack : ''}\n`;
fs.appendFileSync(ERROR_LOG_FILE, logEntry);
fs.appendFileSync(LOG_FILE, logEntry);
console.error(`[ERROR] ${message}`, error || '');
}
class PDFQueue {
constructor() {
this.queue = [];
this.processing = new Set();
this.jobs = new Map();
this.chrome = null;
this.connected = false;
this.cleanupInterval = null;
}
async initialize() {
try {
//this.chrome = await CRI({ port: CONFIG.chromePort });
this.chrome = await CRI({ port: CONFIG.chromePort, host: '127.0.0.1' });
this.connected = true;
logInfo('Chrome CDP connected', { port: CONFIG.chromePort });
} catch (error) {
this.connected = false;
logError('Chrome CDP connection failed', error);
throw error;
}
this.startCleanup();
}
addJob(html, filename) {
if (this.queue.length >= CONFIG.maxQueueSize) {
logError('Queue full', { size: this.queue.length, max: CONFIG.maxQueueSize });
throw new Error('Queue is full, please try again later');
}
const jobId = `job_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
const job = {
id: jobId,
html,
filename: filename || `${jobId}.pdf`,
status: 'queued',
createdAt: Date.now(),
startedAt: null,
completedAt: null,
processingTime: null,
error: null,
pdfUrl: null
};
this.queue.push(job);
this.jobs.set(jobId, job);
this.processQueue();
return job;
}
async processQueue() {
while (this.processing.size < CONFIG.maxConcurrent && this.queue.length > 0) {
const job = this.queue.shift();
this.processJob(job);
}
}
async processJob(job) {
this.processing.add(job.id);
job.status = 'processing';
job.startedAt = Date.now();
try {
if (!this.connected) {
await this.initialize();
}
const { Page } = this.chrome;
await Page.enable();
await Page.setContent(job.html);
const pdf = await Page.printToPDF({
format: 'A4',
printBackground: true,
margin: { top: 0, bottom: 0, left: 0, right: 0 }
});
const outputPath = path.join(__dirname, 'data/pdfs', job.filename);
fs.writeFileSync(outputPath, Buffer.from(pdf.data, 'base64'));
job.status = 'completed';
job.completedAt = Date.now();
job.processingTime = (job.completedAt - job.startedAt) / 1000;
job.pdfUrl = `/node_spooler/data/pdfs/${job.filename}`;
logInfo('PDF generated successfully', {
jobId: job.id,
filename: job.filename,
processingTime: job.processingTime
});
this.logMetrics(job);
} catch (error) {
job.status = 'error';
job.error = error.message;
job.completedAt = Date.now();
const errorPath = path.join(__dirname, 'data/error', `${job.id}.json`);
fs.writeFileSync(errorPath, JSON.stringify(job, null, 2));
logError('PDF generation failed', {
jobId: job.id,
filename: job.filename,
error: error.message
});
if (error.message.includes('Chrome') || error.message.includes('CDP')) {
await this.handleChromeCrash();
}
}
this.processing.delete(job.id);
this.processQueue();
}
async handleChromeCrash() {
logWarn('Chrome crashed, attempting restart...');
this.queue.forEach(job => job.status = 'queued');
this.processing.clear();
this.connected = false;
for (let i = 0; i < 3; i++) {
try {
await this.initialize();
logInfo('Chrome restarted successfully');
return;
} catch (error) {
logError(`Chrome restart attempt ${i + 1} failed`, error);
await new Promise(resolve => setTimeout(resolve, 2000));
}
}
logError('Chrome restart failed after 3 attempts');
}
startCleanup() {
this.cleanupInterval = setInterval(() => {
this.cleanupOldJobs();
}, CONFIG.jobCleanupMinutes * 60 * 1000);
}
cleanupOldJobs() {
const now = Date.now();
const jobsToDelete = [];
for (const [jobId, job] of this.jobs) {
if (job.status === 'completed' || job.status === 'error') {
const age = now - job.completedAt;
if (age > CONFIG.jobRetentionMs) {
jobsToDelete.push(jobId);
}
}
}
jobsToDelete.forEach(jobId => {
this.jobs.delete(jobId);
});
if (jobsToDelete.length > 0) {
logInfo('Cleaned up old jobs', { count: jobsToDelete.length });
}
}
logMetrics(job) {
const timestamp = new Date().toISOString();
const logEntry = `[${timestamp}] ${job.id} status=${job.status} time=${job.processingTime}s filename=${job.filename}\n`;
fs.appendFileSync(METRICS_LOG_FILE, logEntry);
}
getJob(jobId) {
return this.jobs.get(jobId);
}
getStats() {
const allJobs = Array.from(this.jobs.values());
const completedJobs = allJobs.filter(j => j.status === 'completed');
const errorJobs = allJobs.filter(j => j.status === 'error');
const avgTime = completedJobs.length > 0
? completedJobs.reduce((sum, j) => sum + j.processingTime, 0) / completedJobs.length
: 0;
return {
queueSize: this.queue.length,
processing: this.processing.size,
completed: completedJobs.length,
errors: errorJobs.length,
avgProcessingTime: avgTime,
maxQueueSize: CONFIG.maxQueueSize
};
}
}
const app = express();
app.use(bodyParser.json());
app.use('/node_spooler/data', express.static(path.join(__dirname, 'data')));
const queue = new PDFQueue();
async function startServer() {
try {
await queue.initialize();
} catch (error) {
logError('Failed to connect to Chrome', error);
console.error('Please start Chrome with: "C:/Program Files/Google/Chrome/Application/chrome.exe" --headless --disable-gpu --remote-debugging-port=42020');
process.exit(1);
}
app.post('/api/pdf/generate', async (req, res) => {
try {
const { html, filename } = req.body;
if (!html) {
return res.status(400).json({
success: false,
error: 'HTML content is required'
});
}
const job = queue.addJob(html, filename);
res.json({
success: true,
jobId: job.id,
status: job.status,
message: 'Job added to queue'
});
} catch (error) {
logError('API error', error);
res.status(500).json({
success: false,
error: error.message
});
}
});
app.get('/api/pdf/status/:jobId', (req, res) => {
const { jobId } = req.params;
const job = queue.getJob(jobId);
if (!job) {
return res.status(404).json({
success: false,
error: 'Job not found'
});
}
res.json({
success: true,
jobId: job.id,
status: job.status,
progress: job.status === 'completed' ? 100 : (job.status === 'processing' ? 50 : 0),
pdfUrl: job.pdfUrl,
error: job.error
});
});
app.get('/api/queue/stats', (req, res) => {
const stats = queue.getStats();
res.json({
success: true,
...stats
});
});
app.get('/api/cleanup', (req, res) => {
res.json({
success: true,
message: 'Please run cleanup manually: npm run cleanup'
});
});
app.listen(CONFIG.port, 'localhost', () => {
logInfo(`PDF Spooler started on port ${CONFIG.port}`);
});
}
startServer().catch(error => {
logError('Server startup failed', error);
process.exit(1);
});

View File

@ -1,705 +0,0 @@
<?php
function getE($text){
$pos1 = strpos($text,'#E')+2;
$pos2 = strrpos($text,'#E')-2;
$text = substr($text, $pos1, $pos2-$pos1 );
return $text;
}
function getQrcode($HOSTNUMBER) {
$secret_key = "Trisensa_diagnostic_centre";
$secret_iv = "Gleneagles_surabaya";
$encrypt_method = "AES-256-CBC";
$key = hash('sha256', $secret_key);
$iv = substr(hash('sha256', $secret_iv), 0, 16);
$encrypted = base64_encode(openssl_encrypt($HOSTNUMBER, $encrypt_method, $key, 0, $iv));
$qrcode = 'trisensadc.co.id/qrcode/data_detail.php?no_reg='.$encrypted;
return $qrcode;
}
function f_repl($text, $ntext, $pos) {
if($pos != 0) {
$len = strlen($ntext);
if(substr($text,$pos,1) == ' ' ) { $text = substr_replace( $text, $ntext, $pos, $len); }
}
return $text;
}
function getResult($conn, $ACCESSNUMBER, $eng) {
include("_inc.php");
$sql = "SELECT DC.FULLTEXT, DT.TESTCODE, T.VALIDATIONSTATUS,
RESULT = CASE
WHEN T.RESTYPE=0 THEN 'Pending'
WHEN T.RESTYPE=4 AND T.RESVALUE='' AND T.RESSTATUS=1 THEN '.' -- null -> .
WHEN T.RESTYPE IN (7,15,4) THEN T.RESVALUE
WHEN T.RESTYPE=9 THEN +'< '+T.RESVALUE
WHEN T.RESTYPE=10 THEN +'> '+T.RESVALUE
WHEN T.RESVALUE IS NULL THEN
CASE
WHEN T.CODEDRESULTID IS NULL AND DT.TESTTYPE IN (4,5) THEN null
WHEN T.CODEDRESULTID IS NULL THEN TC.COMMENTTEXT
WHEN T.CODEDRESULTID IS NOT NULL AND T.RESTYPE=6 AND SUBSTRING(DX.FULLTEXT,1,3) NOT LIKE '%#%' THEN DX.FULLTEXT
END
ELSE T.RESVALUE
END,
T.MINIMUM, T.MAXIMUM,
DT.FULLTEXT,
DT.RESPRECISION,DT.RESPRECISION2, DT.OPERAND, DT.SOFTCONVERSION, DT.UNITS, DT.UNITS2, T.RESTYPE, VI.FULLTEXT,
case
when TC.COMMENTTEXT is null then DX2.FULLTEXT
else TC.COMMENTTEXT
end, T.RERUN
FROM TESTS T
JOIN DICT_TESTS DT ON DT.TESTID=T.TESTID
LEFT JOIN DICT_TEXTS DX ON DX.TEXTID=T.CODEDRESULTID
LEFT JOIN TESTS_COMMENTS TC ON TC.REQTESTID=T.REQTESTID
LEFT JOIN DICT_TEXTS DX2 ON DX2.TEXTID=TC.COMMENTCODEDID
LEFT JOIN REQUESTS R ON R.REQUESTID=T.REQUESTID
LEFT JOIN DICT_CHAPTERS DC ON DC.CHAPID=T.CHAPID
LEFT JOIN GDC_CMOD.dbo.V_INTER2 VI ON VI.ATR_ACCESSNUMBER=R.ACCESSNUMBER AND DT.TESTCODE=VI.ATR_TESTCODE
WHERE R.ACCESSNUMBER='$ACCESSNUMBER' AND T.NOTPRINTABLE IS NULL AND DT.TESTCODE<>'STATS' AND ISNUMERIC(DT.TESTCODE)=0
ORDER BY T.TESTORDER";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$CHAP = "";
$i = 0;
$page = 1;
$line = 0;
$lpp = 38; // line per page
$done[1]= "";
$nline = 0;
$RERUN=1;
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC)) {
$CHAPTER = $row[0];
$TESTCODE = $row[1];
$VALIDATIONSTATUS = $row[2];
$R1 = $row[3];
if($R1=='****') {$R1='-';}
$L1 = $row[4];
$H1 = $row[5];
$FULLTEXT = $row[6];
$PRECISION1 = $row[7];
$PRECISION2 = $row[8];
$OPERAND = $row[9];// 3* 4/
$SOFTCONVERSION =$row[10];
$U1 = $row[11];
$U2 = $row[12];
$RESTYPE = $row[13];
$I = $row[14];
$RESCOM = $row[15];
// Get ITEXT or ETEXT
if($eng==1) {
$ICHAPTER = substr($CHAPTER, strpos($CHAPTER,'#E')+2, strrpos($CHAPTER,'#E')-strpos($CHAPTER,'#E')-2 );
if($ICHAPTER != $CHAP) {
$raw[$i] = " <tr><td colspan='7'><pre>$ICHAPTER</pre></td> </tr>\r\n";
$nline += 1;
}
$CHAP = $ICHAPTER;
$ITEXT = substr($FULLTEXT, strpos($FULLTEXT,'#E')+2, strrpos($FULLTEXT,'#E')-strpos($FULLTEXT,'#E')-2 );
} else {
$ICHAPTER = substr($CHAPTER,2, strrpos($CHAPTER,'#I')-2 );
if($ICHAPTER != $CHAP) {
$raw[$i] = " <tr><td colspan='7'><pre>$ICHAPTER</pre></td> </tr>\r\n";
$nline += 1;
}
$CHAP = $ICHAPTER;
$ITEXT = substr($FULLTEXT,2, strrpos($FULLTEXT,'#I')-2 );
}
// GRP | ELE
if($TESTCODE=='PCRN') { $raw[$i] .= " <tr> <td></td> <td colspan='6'><br/><pre>$ITEXT</pre></td></tr>"; $done[$page] .= $raw[$i]; }
elseif(!is_numeric($RESTYPE)) {
// ch
if( array_key_exists( $TESTCODE, $_chinese) ) { $ITEXT = rtrim($ITEXT)." <span class='textC'>".$_chinese[$TESTCODE].'</span>'; }
if($ITEXT!='') {
$ITEXT = " <tr> <td colspan='7'><pre>$ITEXT</pre></td> </tr>\r\n";
$nline += 1;
$raw[$i] .= $ITEXT;
}
$RERUN = $row[16];
} else {
//flagging
if( substr($R1,0,2)=='< ' && is_numeric(substr($R1,2,strlen($R1))) ) { $r1 = substr($R1,2,strlen($R1)); $r1-=1;}
elseif( substr($R1,0,2)=='> ' && is_numeric(substr($R1,2,strlen($R1))) ) { $r1 = substr($R1,2,strlen($R1)); $r1+=1;}
else {$r1 = $R1;}
$F = "";
if($TESTCODE != 'TROPI') {
if($r1 < $L1 && is_numeric($r1) && is_numeric($L1)) {$F = "*L";}
elseif($r1 > $H1 && is_numeric($r1) && is_numeric($H1)) {$F = "*H";}
}
// restype == 9 / limit
if($RESTYPE=='9' && $TESTCODE =='LH' ) {
$qr1 = preg_replace('/<|>| |/', '', $r1);
if($qr1 < $L1 && is_numeric($qr1) && is_numeric($L1)) {$F = "*L";}
elseif($qr1 > $H1 && is_numeric($qr1) && is_numeric($H1)) {$F = "*H";}
}
//get R2 L2 H2
if($RESTYPE == 0) { $R2=""; $L1=""; $H1=""; $L2=""; $H2=""; }
else {
if(is_numeric($L1) && $PRECISION1 != 0 ) { $L1 = number_format($L1,$PRECISION1); } else { $L1 = number_format($L1); }
if(is_numeric($H1) && $PRECISION1 != 0 ) { $H1 = number_format($H1,$PRECISION1); } else { $H1 = number_format($H1); }
if( in_array($RESTYPE,[7,15,4]) && $OPERAND == 3 ) {
if(is_numeric($R1)) { $R2 = NUMBER_FORMAT($R1 * $SOFTCONVERSION, $PRECISION2,'.',''); }
else {$R2 = '';}
if($L1 != 0) { $L2 = NUMBER_FORMAT($L1 * $SOFTCONVERSION, $PRECISION2); }
else {$L2 = 0;}
if(is_numeric($H1) && $H1 != 0) { $H2 = NUMBER_FORMAT($H1 * $SOFTCONVERSION, $PRECISION2); }
else {$H2 = 0;}
} elseif( in_array($RESTYPE,[7,15,4]) && $OPERAND == 4 ) {
IF(is_numeric($R1)) { $R2 = NUMBER_FORMAT($R1 / $SOFTCONVERSION, $PRECISION2); }
ELSE {$R2 = '';}
IF(is_numeric($L1) && $L1 != 0) { $L2 = NUMBER_FORMAT($L1 / $SOFTCONVERSION, $PRECISION2); }
ELSE {$L2 = 0;}
IF(is_numeric($H1) && $H1 != 0) { $H2 = NUMBER_FORMAT($H1 / $SOFTCONVERSION, $PRECISION2); }
ELSE {$H2 = 0;}
} elseif ( in_array($RESTYPE,[9,10]) & $OPERAND == 3 ) {
$r21 = substr($R1, 0, 2);
$r22 = substr($R1, 2, 10);
if(strlen($r22) > 5) { $r21= substr($r21,0,1); }
$R1 = $r21.$r22;
$r22 = NUMBER_FORMAT($r22 * $SOFTCONVERSION, $PRECISION2,'.','');
$R2 = $r21.$r22;
if($L1 != 0) { $L2 = NUMBER_FORMAT($L1 * $SOFTCONVERSION, $PRECISION2); }
else {$L2 = '';}
if($H1 != 0) { $H2 = NUMBER_FORMAT($H1 * $SOFTCONVERSION, $PRECISION2); }
else {$H2 = '';}
} elseif ( in_array($RESTYPE,[9,10]) & $OPERAND == 4 ) {
$r21 = substr($R1, 0, 2);
$r22 = substr($R1, 2, 10);
$r22 = NUMBER_FORMAT($r22 / $SOFTCONVERSION, $PRECISION2,'.','');
$R2 = $r21.$r22;
IF($L1 != 0) { $L2 = NUMBER_FORMAT($L1 / $SOFTCONVERSION, $PRECISION2); }
ELSE {$L2 = '';}
IF($H1 != 0) { $H2 = NUMBER_FORMAT($H1 / $SOFTCONVERSION, $PRECISION2); }
ELSE {$H2 = '';}
} else { $R2=$R1; $L2=$L1; $H2=$H1; }
}
if( ($L1 == 0) && ($H1 == 0) ) { $L1=''; $H1=''; $L2=''; $H2=''; }
//precision1
if(is_numeric($R1) && is_numeric($PRECISION1)) { $R1 = NUMBER_FORMAT($R1,$PRECISION1,'.',','); }
if(is_numeric($R2) && is_numeric($PRECISION2)) { $R2 = NUMBER_FORMAT($R2,$PRECISION2,'.',','); }
// split in half - multi line
// text | result
$TEXT = explode("\r\n",$ITEXT);
$test = array();
$res = array();
foreach($TEXT as $text) {
$test[]= substr($text,0,33);
$res[]= substr($text,33,strlen($text));
}
$space = ( strlen($test[0])-strlen(ltrim($test[0])) ) * 7;
$test = rtrim(implode("\r\n",$test));
$res = implode("\r\n",$res);
// italic
if( in_array( $TESTCODE, $_italic) ) { $test ="<i>$test</i>"; }
// ch
if( array_key_exists( $TESTCODE, $_chinese) ) { $test.=" <span class='textC'>".$_chinese[$TESTCODE].'</span>'; }
//line count
$tline = count( explode(PHP_EOL, $test) );
$rline = count( explode(PHP_EOL, $res) );
$r1line = count( explode(PHP_EOL, $R1) );
if($rline < $r1line) { $rline = $r1line; }
if ($test == ' Note') {
$ITEXT = " <tr> <td style='padding-left:".$space."px'><br/>$test</td> <td colspan='6'><br/><pre>$res </pre></td> </tr>\r\n";
} elseif ( strlen($RESCOM) < 2 ) {
//$ITEXT = " <tr> <td style='padding-left:".$space."px'>$test</td> <td colspan='6'><pre>$res </pre></td> </tr>\r\n";
$ITEXT = " <tr> <td style='padding-left:".$space."px'>$test</td> <td colspan='6'><pre>$res </pre></td> </tr>\r\n";
} else {
$rline += count( explode(PHP_EOL, $RESCOM) );
$res = rtrim($res);
$ITEXT = " <tr> <td style='padding-left:".$space."px'>$test</td> <td colspan='6'><pre>$res \r\n$RESCOM</pre></td> </tr>\r\n ";
}
if($tline > $rline) { $nline += $tline; } else { $nline += $rline; }
/*
## replace {R1 {L1 {H1 {R2 {L2 {H2 {I ##
GET STRING POS
DELETE ALL STRING
{R1,{R2,{I,{L1,{H1,{L2,{H2 // ORDER
GET NEW STRING LENGTH
*/
// Get all string pos
$posR1 = strpos($ITEXT, "{R1");
$posR12 = strrpos($ITEXT, "{R1");
$posR2 = strpos($ITEXT, "{R2");
$posR22 = strrpos($ITEXT, "{R2");
$posI1 = strpos($ITEXT, "{I");
$posI2 = strrpos($ITEXT, "{I");
$posL1 = strpos($ITEXT, "{L1");
$posL12 = strrpos($ITEXT, "{L1");
$posH1 = strpos($ITEXT, "{H1");
$posH12 = strrpos($ITEXT, "{H1");
$posL2 = strpos($ITEXT, "{L2");
$posL22 = strrpos($ITEXT, "{L2");
$posH2 = strpos($ITEXT, "{H2");
$posH22 = strrpos($ITEXT, "{H2");
$posU1 = strpos($ITEXT, "{U1");
//all using U2
//if($posU1 == 0 ) { $posU1 = strrpos($ITEXT, "{U2"); $U1 = $U2; }
$posU2 = strpos($ITEXT, "{U2");
#echo "<pre>$ITEXT</pre>\r\n";
// Delete all string
$ITEXT = str_replace( "{R1", " ", $ITEXT );
$ITEXT = str_replace( "{R2", " ", $ITEXT );
$ITEXT = str_replace( "{I", " ", $ITEXT );
$ITEXT = str_replace( "{L1", " ", $ITEXT );
$ITEXT = str_replace( "{H1", " ", $ITEXT );
$ITEXT = str_replace( "{L2", " ", $ITEXT );
$ITEXT = str_replace( "{H2", " ", $ITEXT );
$ITEXT = str_replace( "{U1", " ", $ITEXT );
$ITEXT = str_replace( "{U2", " ", $ITEXT );
// REPLACE
if(in_array($RESTYPE, [4,6,7,9,10,15])) {
if($R1=='Negatif') { $R2 = 'Negative'; }
if($R1=='Positif') { $R2 = 'Positive'; }
$ITEXT = f_repl($ITEXT,$R1.' '.$F,$posR1);
if($posR1 != $posR12) { $ITEXT = f_repl($ITEXT,$R1.' '.$F,$posR12); }
$ITEXT = f_repl($ITEXT,$L1,$posL1);
if($posL1 != $posL12) { $ITEXT = f_repl($ITEXT,$L1,$posL12); }
$ITEXT = f_repl($ITEXT,$H1,$posH1);
if($posH1 != $posH12) { $ITEXT = f_repl($ITEXT,$H1,$posH12); }
if(isset($R2)) {
$ITEXT = f_repl($ITEXT,$R2.' '.$F,$posR2);
if($posR2 != $posR22) { $ITEXT = f_repl($ITEXT,$R2.' '.$F,$posR22); }
}
if(isset($L2)) { $ITEXT = f_repl($ITEXT,$L2,$posL2); }
if($posL2 != $posL22) { $ITEXT = f_repl($ITEXT,$L2,$posL22); }
if(isset($H2)) { $ITEXT = f_repl($ITEXT,$H2,$posH2); }
if($posH2 != $posH22) { $ITEXT = f_repl($ITEXT,$H2,$posH22); }
if($I == 'Negative' || $I == 'Negatif') {
$I1 = "Negatif";
$I2 = "Negative";
$ITEXT = f_repl($ITEXT,$I1,$posI1);
$ITEXT = f_repl($ITEXT,$I2,$posI2);
} else {
$ITEXT = f_repl($ITEXT,$I,$posI1);
$ITEXT = f_repl($ITEXT,$I,$posI2);
}
$ITEXT = f_repl($ITEXT,$U1,$posU1);
$ITEXT = f_repl($ITEXT,$U2,$posU2);
} elseif(in_array($RESTYPE,[2,0,5])) {
if(strlen($RESCOM) < 2) {
if($TESTCODE == 'BUCRR') {
$ITEXT = f_repl($ITEXT,$R1,$posR1);
$ITEXT = f_repl($ITEXT,$R1,$posR2);
} else {
$ITEXT = substr($ITEXT, 0, $posR1);
$ITEXT .= $R1."</pre></td> </tr>";
}
} else {
$ITEXT = substr($ITEXT, 0, $posR1); $ITEXT .= "$R1 \r\n$RESCOM</pre></td> </tr>";
}
}
// bold flag
//$ITEXT = str_replace('*L', '<b>*L</b>', $ITEXT);
//$ITEXT = str_replace('*H', '<b>*H</b>', $ITEXT);
$raw[$i] .= $ITEXT;
$line += $nline;
if($TESTCODE != 'COVGG') {
if($line > $lpp) {$page++; $done[$page] = ""; $line = $nline; }
} else {
if($line > $lpp-14) {$page++; $done[$page] = ""; $line = $nline; }
}
if($line > $lpp) {$page++; $done[$page] = ""; $line = $nline; }
$done[$page] .= $raw[$i];
$i++;
$raw[$i] = "";
$nline = 0;
}
}
return $done;
}
function getOthers($conn,$ACCESSNUMBER, $eng) {
$sql = "select DT.FULLTEXT from TESTS T
left join REQUESTS R on R.REQUESTID=T.REQUESTID
left join DICT_TESTS DT on DT.TESTID=T.TESTID
where R.ACCESSNUMBER='$ACCESSNUMBER' and ISNUMERIC(DT.TESTCODE)=1
order by T.TESTORDER";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$i = 1;
$raw = "";
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC) ) {
$text = $row[0];
if($eng==1) {
$text = substr( $text , strpos($text,'#E')+2, strrpos($text,'#E')-strpos($text,'#E')-2 );
} else {
$text = substr( $text , strpos($text,'#I')+2, strrpos($text,'#I')-2 );
}
$text = str_replace( "{R1", " ", $text );
$text = str_replace( "{R2", " ", $text );
$text = str_replace( "{I", " ", $text );
$text = str_replace( "{L1", " ", $text );
$text = str_replace( "{H1", " ", $text );
$text = str_replace( "{L2", " ", $text );
$text = str_replace( "{H2", " ", $text );
$text = str_replace( "{U1", " ", $text );
$text = str_replace( "{U2", " ", $text );
$text = trim($text);
$raw .= "$i. $text <br/>\r\n";
$i++;
}
return $raw;
}
function getData($conn,$ACCESSNUMBER) {
$sql = "select R.EXTERNALORDERNUMBER, format(SR.COLLECTIONDATE,'dd/MM/yyyy'), P.NAME, right(P.PATNUMBER,16),
rtrim(P.ADDRESS1+isnull(P.ADDRESS2,'')), P.TELEPHON, P.EMAIL,
case
when P.SEX=1 then 'Male'
when P.SEX=2 then 'Female'
else 'Unknown'
end,
FLOOR(DATEDIFF(DAY, P.BIRTHDATE, R.COLLECTIONDATE) / 365.25),
--DATEDIFF(DAY, P.BIRTHDATE, R.COLLECTIONDATE) / 365.25+1,
MONTH(R.COLLECTIONDATE - DATEADD(year, DATEDIFF(year, P.BIRTHDATE, R.COLLECTIONDATE), P.BIRTHDATE) ) - 1,
RO.COMMENTTEXT, P.STATE, P.CITY
from REQUESTS R
left join SP_REQUESTS SR on SR.SP_ACCESSNUMBER=R.ACCESSNUMBER
left join PATIENTS P on P.PATID=R.PATID
left join REQUESTS_OCOM RO on RO.REQUESTID=R.REQUESTID
WHERE R.ACCESSNUMBER='$ACCESSNUMBER'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
$regno = $row[0];
$reqdate = $row[1];
$pname = $row[2];
$pnum = $row[3];
$paddress = $row[4];
$pphone = $row[5];
$pemail = $row[6];
$psex = $row[7];
$pAge = $row[8];
$pAgeM = $row[9];
$rcomment = $row[10];
$pstate = $row[11];
$pcity = $row[12];
if($pstate == '') { $pstate = $pcity; }
//$sql = "select ODR_CRESULT_TO, ODR_CREFERENCENAME, ODR_CREFERENCEDOCNAME from GDC_CMOD.dbo.V_TDL_ORDER where ODR_CNOLAB='$regno'";
//$sql = "select ODR_CRESULT_TO, ODR_CREFERENCENAME, ODR_CREFERENCEDOCNAME from GLENEAGLES...TDL_ORDER where ODR_CNOLAB='$regno'";
$sql = "select ODR_CRESULT_TO, ODR_CREFERENCENAME, ODR_CREFERENCEDOCNAME from GDC_CMOD.dbo.TDL_ORDER where ODR_CNOLAB='$regno'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
$sendto = $row[0];
$loc = $row[1];
$doc = $row[2];
if($loc == 'PT. BANGUN GUNUNG SARI (BGS)') { $loc = "PT. BANGUN GUNUNG SARI (BGS)"; }
elseif($loc == 'PT. PUTRA DUTA PEMBANGUNAN') { $loc = "PT. PUTRA DUTA PEMBANGUNAN"; }
elseif($loc == 'PT. BENSA ADHI CIPTA') { $loc = "-"; }
elseif($loc == 'PT. LIM SIANG HUAT BALINDO') { $loc = "-"; }
elseif($loc=='') { $loc = 'WALK IN'; }
if($doc=='') { $doc = $loc; }
// noreg, reqdate, access#, mr#, name,address, phone,email,sex,age,reff,doctor
$data ="<table class='info'>
<tr style='border-bottom:solid 1px black'><th colspan='4'>LABORATORY REPORT</th></tr>
<tr> <td>Reg#</td> <td>: $regno</td> <td>Date</td> <td><pre>: $reqdate $sendto</pre></td></tr>
<tr> <td>Lab#</td> <td colspan='3'>: $ACCESSNUMBER</td> </tr>
<tr> <td>MR</td> <td colspan='3'>: $pnum</td> </tr>
<tr> <td>Name</td> <td colspan='3'>: $pname</td> </tr>
<tr> <td>Address</td> <td colspan='3'>: $paddress</td> </tr>
<tr> <td>Phone/Email</td> <td colspan='3'>: $pphone / $pemail</td> </tr>
<tr> <td>City</td> <td colspan='3'>: $pstate</td> </tr>
<tr> <td>Sex</td> <td>: $psex</td> <td>Age</td> <td>: $pAge years, $pAgeM months</td></tr>
<tr> <td>Reff</td> <td colspan='3'>: $loc</td></tr>
<tr> <td>Doctor</td> <td colspan='3'>: $doc</td></tr>
</table>
";
return $data;
}
function getData2($conn,$ACCESSNUMBER) {
$sql = "select R.EXTERNALORDERNUMBER, format(SR.COLLECTIONDATE,'dd-MM-yyyy'), P.NAME, right(P.PATNUMBER,16),
dmg.DMG_CADDRESS, P.TELEPHON, P.EMAIL,
case
when P.SEX=1 then 'Male'
when P.SEX=2 then 'Female'
else 'Unknown'
end,
case when format(P.BIRTHDATE,'MMdd')=format(R.COLLECTIONDATE,'MMdd') then DATEDIFF(YEAR,P.BIRTHDATE, R.COLLECTIONDATE)
--else DATEDIFF(hour,P.BIRTHDATE, R.COLLECTIONDATE)/8766 end ,
else FLOOR(DATEDIFF(DAY, P.BIRTHDATE, R.COLLECTIONDATE) / 365.25) end ,
case when datepart(day,R.COLLECTIONDATE) >= datepart(day,P.BIRTHDATE) then datediff(month,P.BIRTHDATE, R.COLLECTIONDATE)%12
else datediff(month, P.BIRTHDATE, dateadd(month,-1,R.COLLECTIONDATE))%12
end,
RO.COMMENTTEXT, dmg.DMG_CCITY, P.BIRTHDATE, T.SHORTTEXT
from REQUESTS R
left join SP_REQUESTS SR on SR.SP_ACCESSNUMBER=R.ACCESSNUMBER
left join PATIENTS P on P.PATID=R.PATID
left join REQUESTS_OCOM RO on RO.REQUESTID=R.REQUESTID
left join DICT_TEXTS T on P.TITLEID=T.TEXTID
left join GDC_CMOD.dbo.TDL_DEMOGRAPHIC dmg on right(P.PATNUMBER,16)=dmg.DMG_CPATNUMBER collate Latin1_general_CS_AS
WHERE R.ACCESSNUMBER='$ACCESSNUMBER'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
/*
$regno = $row[0];
$reqdate = $row[1];
$pname = $row[2];
$pnum = $row[3];
$paddress = $row[4];
$pphone = $row[5];
$pemail = $row[6];
$psex = $row[7];
$pAge = $row[8];
$pAgeM = $row[9];
$rcomment = $row[10];
$pcity = $row[11];
isset($row[0]) ? $row[0] : ''
*/
$regno = isset($row[0]) ? $row[0] : '';
$reqdate = isset($row[1]) ? $row[1] : '';
$pname = isset($row[2]) ? $row[2] : '';
$pnum = isset($row[3]) ? $row[3] : '';
$paddress = isset($row[4]) ? $row[4] : '';
$pphone = isset($row[5]) ? $row[5] : '';
$pemail = isset($row[6]) ? $row[6] : '';
$psex = isset($row[7]) ? $row[7] : '';
$pAge = isset($row[8]) ? $row[8] : '';
$pAgeM = isset($row[9]) ? $row[9] : '';
$rcomment = isset($row[10]) ? $row[10] : '';
$pcity = isset($row[11]) ? $row[11] : '';
$pdob = '' ;
if( isset($row[12]) )
{ if($row[12]!= null ) { $pdob = date_format($row[12],'d-m-Y'); } }
$title = isset($row[13]) ? $row[13] : '';
if($title != '') { $pname = "$pname, $title"; }
//$sql = "select ODR_CRESULT_TO, ODR_CREFERENCENAME, ODR_CREFERENCEDOCNAME from GDC_CMOD.dbo.V_TDL_ORDER where ODR_CNOLAB='$regno'";
//$sql = "select ODR_CRESULT_TO, ODR_CREFERENCENAME, ODR_CREFERENCEDOCNAME from GLENEAGLES...TDL_ORDER where ODR_CNOLAB='$regno'";
$sql = "select ODR_CRESULT_TO, ODR_CREFERENCENAME, ODR_CREFERENCEDOCNAME from GDC_CMOD.dbo.TDL_ORDER where ODR_CNOLAB='$regno'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
$sendto = isset($row[0]) ? $row[0] : '';
$loc = isset($row[1]) ? $row[1]: '';
$doc = isset($row[2]) ? $row[2]: '';
if($loc == 'PT. BANGUN GUNUNG SARI (BGS)') { $loc = "PT. BANGUN GUNUNG SARI (BGS"; }
elseif($loc == 'PT. PUTRA DUTA PEMBANGUNAN') { $loc = "PT. PUTRA DUTA PEMBANGUNAN"; }
elseif($loc == 'PT. BENSA ADHI CIPTA') { $loc = "-"; }
elseif($loc == 'PT. LIM SIANG HUAT BALINDO') { $loc = "-"; }
elseif($loc=='') { $loc = 'WALK IN'; }
if($doc=='') { $doc = $loc; }
// noreg, reqdate, access#, mr#, name,address, phone,email,sex,age,reff,doctor
$data ="<table class='info'>
<tr style='border-bottom:solid 1px black'><th colspan='5'>CLINICAL LABORATORY</th></tr>
<tr> <td>Reg#</td> <td>:</td> <td>$regno</td> <td>Date</td> <td><pre>: $reqdate $sendto</pre></td></tr>
<tr> <td>Lab#</td> <td>:</td> <td>$ACCESSNUMBER</td> <td>DoB</td> <td>: $pdob (D-M-Y)</td> </tr>
<tr> <td>MR</td> <td>:</td> <td>$pnum</td> <td>Age</td> <td>: $pAge years, $pAgeM months</td> </tr>
<tr> <td>Name</td> <td>:</td> <td colspan='3'>$pname</td> </tr>
<tr> <td>Address</td> <td>:</td> <td colspan='3'>$paddress</td> </tr>
<tr> <td>Phone/Email</td> <td>:</td> <td colspan='3'>$pphone / $pemail</td> </tr>
<tr> <td>City</td> <td>:</td> <td colspan='3'>$pcity</td> </tr>
<tr> <td>Sex</td> <td>:</td> <td colspan='3'>$psex</td> </tr>
<tr> <td>Reff</td> <td>:</td> <td colspan='3'>$loc</td></tr>
<tr> <td>Doctor</td> <td>:</td> <td colspan='3'>$doc</td></tr>
</table>
";
return $data;
}
function getHost($conn,$ACCESSNUMBER) {
$sql = "select EXTERNALORDERNUMBER from REQUESTS where ACCESSNUMBER='$ACCESSNUMBER'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
$HOSTNUMBER = isset($row[0]) ? $row[0] : '';
return $HOSTNUMBER;
}
function getNotes($conn, $ACCESSNUMBER) {
/*
$sql = "select case
when l.LOCID='3741' then p.TELEPHON2
else null
end,
ro.COMMENTTEXT from REQUESTS r
left join REQUESTS_OCOM ro on r.REQUESTID=ro.REQUESTID
left join LOCATIONS l on r.REQUESTID=l.REQUESTID
left join PATIENTS p on p.PATID=r.PATID
where r.ACCESSNUMBER='$ACCESSNUMBER'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
$notes = '';
if(isset($row[0])) { $notes .= $row[0]."<br/>"; }
$notes .= $row[1];
*/
$sql = "select ro.COMMENTTEXT from REQUESTS r
left join REQUESTS_OCOM ro on r.REQUESTID=ro.REQUESTID
where r.ACCESSNUMBER='$ACCESSNUMBER'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
$notes = isset($row[0]) ? $row[0] : '';
return $notes;
}
function getStatus($conn, $ACCESSNUMBER) {
/*
$sql = "select
case
when exists ( select 1 from GDC_CMOD.dbo.TDL_ORDER t left join SP_REQUESTS r on r.HOSTORDERNUMBER=t.ODR_CNOLAB collate Latin1_general_CS_AS
WHERE r.SP_ACCESSNUMBER='$ACCESSNUMBER' and t.ODR_ISPENDING=1 ) then 'PENDING'
when exists (
select 1 from TESTS t
left join REQUESTS r on r.REQUESTID=t.REQUESTID
where r.ACCESSNUMBER='$ACCESSNUMBER' and
( t.RESTYPE=0 OR t.RESSTATUS=0 OR Left(t.RESVALUE,7)='Pending' )
and t.NOTPRINTABLE is null
) then 'PENDING'
else 'FINAL'
end";
*/
$sql = "select STATS from GDC_CMOD.dbo.V_DASHBOARD where SP_ACCESSNUMBER='$ACCESSNUMBER'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
if(isset($row[0])) {
$status = $row[0];
//if( in_array($ACCESSNUMBER, array('4050360338', '4050360347') ) ) { $status='Comp'; }
if($status == 'Comp') { $status = 'FINAL'; }
else { $status = 'PENDING'; }
} else { $status = ''; }
return $status;
}
function getCollData($conn,$ACCESSNUMBER) {
$collData = "";
$sql = "select distinct format(COLLECTIONDATE,'dd-MM-yyyy'), format(COLLECTIONDATE,'HH:mm'), x = stuff(
(select ', ' + dst.SHORTTEXT from GDC_CMOD.dbo.TUBES t1
left join glendb.dbo.DICT_SAMPLES_TYPES dst on t1.TUBENUMBER=dst.SAMPCODE
where t1.ACCESSNUMBER=t.ACCESSNUMBER
and format(t1.COLLECTIONDATE,'dd-MM-yyyy HH:mm')=format(t.COLLECTIONDATE,'dd-MM-yyyy HH:mm')
for xml path('')),
1,1, '')
from GDC_CMOD.dbo.TUBES t where t.ACCESSNUMBER='$ACCESSNUMBER' and STATUS=1";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$date1 = '';
while ( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC) ) {
if($date1 == $row[0]) { $collData .= $row[1].$row[2].'. '; }
else { $collData .= $row[0].' '.$row[1].$row[2].'. '; }
$date1 = $row[0];
}
return $collData;
}
function getRecvData($conn,$ACCESSNUMBER) {
$recvData = "";
/*
$sql = "select DS.SHORTTEXT, format(S.LABRECEPTIONDATE,'dd-MM-yyyy'), format(S.LABRECEPTIONDATE,'HH:mm') from SAMPLES S
left join DICT_SAMPLES_TYPES DS on DS.SAMPCODE=LEFT(S.SAMPLENUMBER,3)
left join SP_TUBES ST on ST.TUBENB=right(S.FULLSAMPLENUM,13)
where S.FULLSAMPLENUM like '%$ACCESSNUMBER' and ST.TUBESTATUS=4
order by S.LABRECEPTIONDATE";
*/
$sql= "select ds.SHORTTEXT, format(st.COLLECTIONDATE,'dd-MM-yyy'), format(st.COLLECTIONDATE,'HH:mm') from SP_TUBES st
left join DICT_SAMPLES_TYPES ds on ds.SAMPCODE=st.SAMPLETYPE
where st.SP_ACCESSNUMBER='$ACCESSNUMBER' and st.TUBESTATUS=4";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$date1 = '';
$time1 = '';
while ( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC) ) {
$x = $row[0];
$date = $row[1];
$time = $row[2];
if( $date1 == $date ) {
if($time1==$time) { $recvData .= $x.'. '; }
else { $recvData .= $time.' '.$x.'. '; }
}
else { $recvData .= $date.' '.$time.' '.$x.'. '; }
$date1 = $date;
$time1 = $time;
}
return $recvData;
}
function getValBy($conn,$ACCESSNUMBER) {
$sql = "SELECT top 1 a.INITUSER, max(STEPDATE) as STEPDATE
FROM glendb.dbo.AUDIT_TRAIL a WHERE (a.LIS_SESSION='VAL' or (a.LIS_SESSION='ERM' and a.VALIDATION=5))
and a.ATR_ACCESSNUMBER='$ACCESSNUMBER'
GROUP BY a.INITUSER, a.STEPDATE
order by a.STEPDATE desc";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
$valBy = isset($row[0]) ? $row[0] : '';
if( $valBy == '' || $valBy =='LIS' ) { $valBy = "AHT"; }
return $valBy;
}
function getVal2By($conn,$ACCESSNUMBER) {
$sql = "select VALUSER from CM_REQUESTS where ACCESSNUMBER='$ACCESSNUMBER'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
$valBy = isset($row[0]) ? $row[0] : '';
if( $valBy == '' || $valBy =='LIS' ) { $valBy = "AHT"; }
return $valBy;
}
function getVal1($conn,$ACCESSNUMBER) {
$sql = "SELECT top 1 a.INITUSER, max(STEPDATE) as STEPDATE
FROM glendb.dbo.AUDIT_TRAIL a WHERE (a.LIS_SESSION='VAL' or (a.LIS_SESSION='ERM' and a.VALIDATION=5))
and a.ATR_ACCESSNUMBER='$ACCESSNUMBER'
GROUP BY a.INITUSER, a.STEPDATE
order by a.STEPDATE desc";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
$valBy = isset($row[0]) ? $row[0] : '';
$valDate = isset($row[1]) ? $row[1] : '';
if( $valBy == '' || $valBy =='LIS' ) { $valBy = "SYSTEM"; }
$val = [ 'valBy'=>$valBy, 'valDate'=>$valDate ];
return $val;
}
function getNoSample($conn,$ACCESSNUMBER) {
$sql = "select DST.SHORTTEXT from SP_TUBES ST
LEFT JOIN DICT_SAMPLES_TYPES DST ON DST.SAMPCODE=ST.TUBETYPE
where ST.SP_ACCESSNUMBER='$ACCESSNUMBER' AND ST.TUBESTATUS<>4";
/*
$sql = "select DS.SHORTTEXT from SP_TUBES T
left join DICT_SAMPLES_TYPES DS on T.SAMPLETYPE=DS.SAMPCODE
where T.SP_ACCESSNUMBER='$ACCESSNUMBER'
and T.SAMPLETYPE not in (
select substring(S.SAMPLENUMBER,0,4) from SAMPLES S
left join REQUESTS R on R.REQUESTID=S.REQUESTID
where R.ACCESSNUMBER=T.SP_ACCESSNUMBER
) AND T.SAMPLETYPE <> '900'";
*/
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$noSample = '';
while ($row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC)) {
$sample = $row[0];
$noSample .= "<tr> <td>$sample</td> <td colspan='6'>No Sample</td> </tr>\r";
}
return $noSample;
}
?>

View File

@ -1,691 +0,0 @@
<?php
function getE($text){
$pos1 = strpos($text,'#E')+2;
$pos2 = strrpos($text,'#E')-2;
$text = substr($text, $pos1, $pos2-$pos1 );
return $text;
}
function getQrcode($HOSTNUMBER) {
$secret_key = "Trisensa_diagnostic_centre";
$secret_iv = "Gleneagles_surabaya";
$encrypt_method = "AES-256-CBC";
$key = hash('sha256', $secret_key);
$iv = substr(hash('sha256', $secret_iv), 0, 16);
$encrypted = base64_encode(openssl_encrypt($HOSTNUMBER, $encrypt_method, $key, 0, $iv));
$qrcode = 'trisensadc.co.id/qrcode/data_detail.php?no_reg='.$encrypted;
return $qrcode;
}
function f_repl($text, $ntext, $pos) {
if($pos != 0) {
$len = strlen($ntext);
if(substr($text,$pos,1) == ' ' ) { $text = substr_replace( $text, $ntext, $pos, $len); }
}
return $text;
}
function getResult($conn, $ACCESSNUMBER, $eng) {
include("_inc.php");
$sql = "SELECT DC.FULLTEXT, DT.TESTCODE, T.VALIDATIONSTATUS,
RESULT = CASE
WHEN T.RESTYPE=0 THEN 'Pending'
WHEN T.RESTYPE=4 AND T.RESVALUE='' AND T.RESSTATUS=1 THEN '.' -- null -> .
WHEN T.RESTYPE IN (7,15,4) THEN T.RESVALUE
WHEN T.RESTYPE=9 THEN +'< '+T.RESVALUE
WHEN T.RESTYPE=10 THEN +'> '+T.RESVALUE
WHEN T.RESVALUE IS NULL THEN
CASE
WHEN T.CODEDRESULTID IS NULL AND DT.TESTTYPE IN (4,5) THEN null
WHEN T.CODEDRESULTID IS NULL THEN TC.COMMENTTEXT
WHEN T.CODEDRESULTID IS NOT NULL AND T.RESTYPE=6 AND SUBSTRING(DX.FULLTEXT,1,3) NOT LIKE '%#%' THEN DX.FULLTEXT
END
ELSE T.RESVALUE
END,
T.MINIMUM, T.MAXIMUM,
DT.FULLTEXT,
DT.RESPRECISION,DT.RESPRECISION2, DT.OPERAND, DT.SOFTCONVERSION, DT.UNITS, DT.UNITS2, T.RESTYPE, VI.FULLTEXT,
case
when TC.COMMENTTEXT is null then DX2.FULLTEXT
else TC.COMMENTTEXT
end, T.RERUN
FROM TESTS T
JOIN DICT_TESTS DT ON DT.TESTID=T.TESTID
LEFT JOIN DICT_TEXTS DX ON DX.TEXTID=T.CODEDRESULTID
LEFT JOIN TESTS_COMMENTS TC ON TC.REQTESTID=T.REQTESTID
LEFT JOIN DICT_TEXTS DX2 ON DX2.TEXTID=TC.COMMENTCODEDID
LEFT JOIN REQUESTS R ON R.REQUESTID=T.REQUESTID
LEFT JOIN DICT_CHAPTERS DC ON DC.CHAPID=T.CHAPID
LEFT JOIN GDC_CMOD.dbo.V_INTER2 VI ON VI.ATR_ACCESSNUMBER=R.ACCESSNUMBER AND DT.TESTCODE=VI.ATR_TESTCODE
WHERE R.ACCESSNUMBER='$ACCESSNUMBER' AND T.NOTPRINTABLE IS NULL AND DT.TESTCODE<>'STATS' AND ISNUMERIC(DT.TESTCODE)=0
ORDER BY T.TESTORDER";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$CHAP = "";
$i = 0;
$page = 1;
$line = 0;
$lpp = 38; // line per page
$done[1]= "";
$nline = 0;
$RERUN=1;
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC)) {
$CHAPTER = $row[0];
$TESTCODE = $row[1];
$VALIDATIONSTATUS = $row[2];
$R1 = $row[3];
if($R1=='****') {$R1='-';}
$L1 = $row[4];
$H1 = $row[5];
$FULLTEXT = $row[6];
$PRECISION1 = $row[7];
$PRECISION2 = $row[8];
$OPERAND = $row[9];// 3* 4/
$SOFTCONVERSION =$row[10];
$U1 = $row[11];
$U2 = $row[12];
$RESTYPE = $row[13];
$I = $row[14];
$RESCOM = $row[15];
// Get ITEXT or ETEXT
if($eng==1) {
$ICHAPTER = substr($CHAPTER, strpos($CHAPTER,'#E')+2, strrpos($CHAPTER,'#E')-strpos($CHAPTER,'#E')-2 );
if($ICHAPTER != $CHAP) {
$raw[$i] = " <tr><td colspan='7'><pre>$ICHAPTER</pre></td> </tr>\r\n";
$nline += 1;
}
$CHAP = $ICHAPTER;
$ITEXT = substr($FULLTEXT, strpos($FULLTEXT,'#E')+2, strrpos($FULLTEXT,'#E')-strpos($FULLTEXT,'#E')-2 );
} else {
$ICHAPTER = substr($CHAPTER,2, strrpos($CHAPTER,'#I')-2 );
if($ICHAPTER != $CHAP) {
$raw[$i] = " <tr><td colspan='7'><pre>$ICHAPTER</pre></td> </tr>\r\n";
$nline += 1;
}
$CHAP = $ICHAPTER;
$ITEXT = substr($FULLTEXT,2, strrpos($FULLTEXT,'#I')-2 );
}
// GRP | ELE
if($TESTCODE=='PCRN') { $raw[$i] .= " <tr> <td></td> <td colspan='6'><br/><pre>$ITEXT</pre></td></tr>"; $done[$page] .= $raw[$i]; }
elseif(!is_numeric($RESTYPE)) {
// ch
if( array_key_exists( $TESTCODE, $_chinese) ) { $ITEXT = rtrim($ITEXT)." <span class='textC'>".$_chinese[$TESTCODE].'</span>'; }
if($ITEXT!='') {
$ITEXT = " <tr> <td colspan='7'><pre>$ITEXT</pre></td> </tr>\r\n";
$nline += 1;
$raw[$i] .= $ITEXT;
}
$RERUN = $row[16];
} else {
//flagging
if( substr($R1,0,2)=='< ' && is_numeric(substr($R1,2,strlen($R1))) ) { $r1 = substr($R1,2,strlen($R1)); $r1-=1;}
elseif( substr($R1,0,2)=='> ' && is_numeric(substr($R1,2,strlen($R1))) ) { $r1 = substr($R1,2,strlen($R1)); $r1+=1;}
else {$r1 = $R1;}
$F = "";
if($TESTCODE != 'TROPI') {
if($r1 < $L1 && is_numeric($r1) && is_numeric($L1)) {$F = "*L";}
elseif($r1 > $H1 && is_numeric($r1) && is_numeric($H1)) {$F = "*H";}
}
// restype == 9 / limit
if($RESTYPE=='9' && $TESTCODE =='LH' ) {
$qr1 = preg_replace('/<|>| |/', '', $r1);
if($qr1 < $L1 && is_numeric($qr1) && is_numeric($L1)) {$F = "*L";}
elseif($qr1 > $H1 && is_numeric($qr1) && is_numeric($H1)) {$F = "*H";}
}
//get R2 L2 H2
if($RESTYPE == 0) { $R2=""; $L1=""; $H1=""; $L2=""; $H2=""; }
else {
if(is_numeric($L1) && $PRECISION1 != 0 ) { $L1 = number_format($L1,$PRECISION1); } else { $L1 = number_format($L1); }
if(is_numeric($H1) && $PRECISION1 != 0 ) { $H1 = number_format($H1,$PRECISION1); } else { $H1 = number_format($H1); }
if( in_array($RESTYPE,[7,15,4]) && $OPERAND == 3 ) {
if(is_numeric($R1)) { $R2 = NUMBER_FORMAT($R1 * $SOFTCONVERSION, $PRECISION2,'.',''); }
else {$R2 = '';}
if($L1 != 0) { $L2 = NUMBER_FORMAT($L1 * $SOFTCONVERSION, $PRECISION2); }
else {$L2 = 0;}
if(is_numeric($H1) && $H1 != 0) { $H2 = NUMBER_FORMAT($H1 * $SOFTCONVERSION, $PRECISION2); }
else {$H2 = 0;}
} elseif( in_array($RESTYPE,[7,15,4]) && $OPERAND == 4 ) {
IF(is_numeric($R1)) { $R2 = NUMBER_FORMAT($R1 / $SOFTCONVERSION, $PRECISION2); }
ELSE {$R2 = '';}
IF(is_numeric($L1) && $L1 != 0) { $L2 = NUMBER_FORMAT($L1 / $SOFTCONVERSION, $PRECISION2); }
ELSE {$L2 = 0;}
IF(is_numeric($H1) && $H1 != 0) { $H2 = NUMBER_FORMAT($H1 / $SOFTCONVERSION, $PRECISION2); }
ELSE {$H2 = 0;}
} elseif ( in_array($RESTYPE,[9,10]) & $OPERAND == 3 ) {
$r21 = substr($R1, 0, 2);
$r22 = substr($R1, 2, 10);
if(strlen($r22) > 5) { $r21= substr($r21,0,1); }
$R1 = $r21.$r22;
$r22 = NUMBER_FORMAT($r22 * $SOFTCONVERSION, $PRECISION2,'.','');
$R2 = $r21.$r22;
if($L1 != 0) { $L2 = NUMBER_FORMAT($L1 * $SOFTCONVERSION, $PRECISION2); }
else {$L2 = '';}
if($H1 != 0) { $H2 = NUMBER_FORMAT($H1 * $SOFTCONVERSION, $PRECISION2); }
else {$H2 = '';}
} elseif ( in_array($RESTYPE,[9,10]) & $OPERAND == 4 ) {
$r21 = substr($R1, 0, 2);
$r22 = substr($R1, 2, 10);
$r22 = NUMBER_FORMAT($r22 / $SOFTCONVERSION, $PRECISION2,'.','');
$R2 = $r21.$r22;
IF($L1 != 0) { $L2 = NUMBER_FORMAT($L1 / $SOFTCONVERSION, $PRECISION2); }
ELSE {$L2 = '';}
IF($H1 != 0) { $H2 = NUMBER_FORMAT($H1 / $SOFTCONVERSION, $PRECISION2); }
ELSE {$H2 = '';}
} else { $R2=$R1; $L2=$L1; $H2=$H1; }
}
if( ($L1 == 0) && ($H1 == 0) ) { $L1=''; $H1=''; $L2=''; $H2=''; }
//precision1
if(is_numeric($R1) && is_numeric($PRECISION1)) { $R1 = NUMBER_FORMAT($R1,$PRECISION1,'.',','); }
if(is_numeric($R2) && is_numeric($PRECISION2)) { $R2 = NUMBER_FORMAT($R2,$PRECISION2,'.',','); }
// split in half - multi line
// text | result
$TEXT = explode("\r\n",$ITEXT);
$test = array();
$res = array();
foreach($TEXT as $text) {
$test[]= substr($text,0,33);
$res[]= substr($text,33,strlen($text));
}
$space = ( strlen($test[0])-strlen(ltrim($test[0])) ) * 7;
$test = rtrim(implode("\r\n",$test));
$res = implode("\r\n",$res);
// italic
if( in_array( $TESTCODE, $_italic) ) { $test ="<i>$test</i>"; }
// ch
if( array_key_exists( $TESTCODE, $_chinese) ) { $test.=" <span class='textC'>".$_chinese[$TESTCODE].'</span>'; }
//line count
$tline = count( explode(PHP_EOL, $test) );
$rline = count( explode(PHP_EOL, $res) );
$r1line = count( explode(PHP_EOL, $R1) );
if($rline < $r1line) { $rline = $r1line; }
if ($test == ' Note') {
$ITEXT = " <tr> <td style='padding-left:".$space."px'><br/>$test</td> <td colspan='6'><br/><pre>$res </pre></td> </tr>\r\n";
} elseif ( strlen($RESCOM) < 2 ) {
//$ITEXT = " <tr> <td style='padding-left:".$space."px'>$test</td> <td colspan='6'><pre>$res </pre></td> </tr>\r\n";
$ITEXT = " <tr> <td style='padding-left:".$space."px'>$test</td> <td colspan='6'><pre>$res </pre></td> </tr>\r\n";
} else {
$rline += count( explode(PHP_EOL, $RESCOM) );
$res = rtrim($res);
$ITEXT = " <tr> <td style='padding-left:".$space."px'>$test</td> <td colspan='6'><pre>$res \r\n$RESCOM</pre></td> </tr>\r\n ";
}
if($tline > $rline) { $nline += $tline; } else { $nline += $rline; }
/*
## replace {R1 {L1 {H1 {R2 {L2 {H2 {I ##
GET STRING POS
DELETE ALL STRING
{R1,{R2,{I,{L1,{H1,{L2,{H2 // ORDER
GET NEW STRING LENGTH
*/
// Get all string pos
$posR1 = strpos($ITEXT, "{R1");
$posR12 = strrpos($ITEXT, "{R1");
$posR2 = strpos($ITEXT, "{R2");
$posR22 = strrpos($ITEXT, "{R2");
$posI1 = strpos($ITEXT, "{I");
$posI2 = strrpos($ITEXT, "{I");
$posL1 = strpos($ITEXT, "{L1");
$posL12 = strrpos($ITEXT, "{L1");
$posH1 = strpos($ITEXT, "{H1");
$posH12 = strrpos($ITEXT, "{H1");
$posL2 = strpos($ITEXT, "{L2");
$posL22 = strrpos($ITEXT, "{L2");
$posH2 = strpos($ITEXT, "{H2");
$posH22 = strrpos($ITEXT, "{H2");
$posU1 = strpos($ITEXT, "{U1");
//all using U2
//if($posU1 == 0 ) { $posU1 = strrpos($ITEXT, "{U2"); $U1 = $U2; }
$posU2 = strpos($ITEXT, "{U2");
#echo "<pre>$ITEXT</pre>\r\n";
// Delete all string
$ITEXT = str_replace( "{R1", " ", $ITEXT );
$ITEXT = str_replace( "{R2", " ", $ITEXT );
$ITEXT = str_replace( "{I", " ", $ITEXT );
$ITEXT = str_replace( "{L1", " ", $ITEXT );
$ITEXT = str_replace( "{H1", " ", $ITEXT );
$ITEXT = str_replace( "{L2", " ", $ITEXT );
$ITEXT = str_replace( "{H2", " ", $ITEXT );
$ITEXT = str_replace( "{U1", " ", $ITEXT );
$ITEXT = str_replace( "{U2", " ", $ITEXT );
// REPLACE
if(in_array($RESTYPE, [4,6,7,9,10,15])) {
if($R1=='Negatif') { $R2 = 'Negative'; }
if($R1=='Positif') { $R2 = 'Positive'; }
$ITEXT = f_repl($ITEXT,$R1.' '.$F,$posR1);
if($posR1 != $posR12) { $ITEXT = f_repl($ITEXT,$R1.' '.$F,$posR12); }
$ITEXT = f_repl($ITEXT,$L1,$posL1);
if($posL1 != $posL12) { $ITEXT = f_repl($ITEXT,$L1,$posL12); }
$ITEXT = f_repl($ITEXT,$H1,$posH1);
if($posH1 != $posH12) { $ITEXT = f_repl($ITEXT,$H1,$posH12); }
if(isset($R2)) {
$ITEXT = f_repl($ITEXT,$R2.' '.$F,$posR2);
if($posR2 != $posR22) { $ITEXT = f_repl($ITEXT,$R2.' '.$F,$posR22); }
}
if(isset($L2)) { $ITEXT = f_repl($ITEXT,$L2,$posL2); }
if($posL2 != $posL22) { $ITEXT = f_repl($ITEXT,$L2,$posL22); }
if(isset($H2)) { $ITEXT = f_repl($ITEXT,$H2,$posH2); }
if($posH2 != $posH22) { $ITEXT = f_repl($ITEXT,$H2,$posH22); }
if($I == 'Negative' || $I == 'Negatif') {
$I1 = "Negatif";
$I2 = "Negative";
$ITEXT = f_repl($ITEXT,$I1,$posI1);
$ITEXT = f_repl($ITEXT,$I2,$posI2);
} else {
$ITEXT = f_repl($ITEXT,$I,$posI1);
$ITEXT = f_repl($ITEXT,$I,$posI2);
}
$ITEXT = f_repl($ITEXT,$U1,$posU1);
$ITEXT = f_repl($ITEXT,$U2,$posU2);
} elseif(in_array($RESTYPE,[2,0,5])) {
if(strlen($RESCOM) < 2) {
if($TESTCODE == 'BUCRR') {
$ITEXT = f_repl($ITEXT,$R1,$posR1);
$ITEXT = f_repl($ITEXT,$R1,$posR2);
} else {
$ITEXT = substr($ITEXT, 0, $posR1);
$ITEXT .= $R1."</pre></td> </tr>";
}
} else {
$ITEXT = substr($ITEXT, 0, $posR1); $ITEXT .= "$R1 \r\n$RESCOM</pre></td> </tr>";
}
}
// bold flag
//$ITEXT = str_replace('*L', '<b>*L</b>', $ITEXT);
//$ITEXT = str_replace('*H', '<b>*H</b>', $ITEXT);
$raw[$i] .= $ITEXT;
$line += $nline;
if($TESTCODE != 'COVGG') {
if($line > $lpp) {$page++; $done[$page] = ""; $line = $nline; }
} else {
if($line > $lpp-14) {$page++; $done[$page] = ""; $line = $nline; }
}
if($line > $lpp) {$page++; $done[$page] = ""; $line = $nline; }
$done[$page] .= $raw[$i];
$i++;
$raw[$i] = "";
$nline = 0;
}
}
return $done;
}
function getOthers($conn,$ACCESSNUMBER, $eng) {
$sql = "select DT.FULLTEXT from TESTS T
left join REQUESTS R on R.REQUESTID=T.REQUESTID
left join DICT_TESTS DT on DT.TESTID=T.TESTID
where R.ACCESSNUMBER='$ACCESSNUMBER' and ISNUMERIC(DT.TESTCODE)=1
order by T.TESTORDER";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$i = 1;
$raw = "";
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC) ) {
$text = $row[0];
if($eng==1) {
$text = substr( $text , strpos($text,'#E')+2, strrpos($text,'#E')-strpos($text,'#E')-2 );
} else {
$text = substr( $text , strpos($text,'#I')+2, strrpos($text,'#I')-2 );
}
$text = str_replace( "{R1", " ", $text );
$text = str_replace( "{R2", " ", $text );
$text = str_replace( "{I", " ", $text );
$text = str_replace( "{L1", " ", $text );
$text = str_replace( "{H1", " ", $text );
$text = str_replace( "{L2", " ", $text );
$text = str_replace( "{H2", " ", $text );
$text = str_replace( "{U1", " ", $text );
$text = str_replace( "{U2", " ", $text );
$text = trim($text);
$raw .= "$i. $text <br/>\r\n";
$i++;
}
return $raw;
}
function getData($conn,$ACCESSNUMBER) {
$sql = "select R.EXTERNALORDERNUMBER, format(SR.COLLECTIONDATE,'dd/MM/yyyy'), P.NAME, right(P.PATNUMBER,16),
rtrim(P.ADDRESS1+isnull(P.ADDRESS2,'')), P.TELEPHON, P.EMAIL,
case
when P.SEX=1 then 'Male'
when P.SEX=2 then 'Female'
else 'Unknown'
end,
FLOOR(DATEDIFF(DAY, P.BIRTHDATE, R.COLLECTIONDATE) / 365.25),
--DATEDIFF(DAY, P.BIRTHDATE, R.COLLECTIONDATE) / 365.25+1,
MONTH(R.COLLECTIONDATE - DATEADD(year, DATEDIFF(year, P.BIRTHDATE, R.COLLECTIONDATE), P.BIRTHDATE) ) - 1,
RO.COMMENTTEXT, P.STATE, P.CITY
from REQUESTS R
left join SP_REQUESTS SR on SR.SP_ACCESSNUMBER=R.ACCESSNUMBER
left join PATIENTS P on P.PATID=R.PATID
left join REQUESTS_OCOM RO on RO.REQUESTID=R.REQUESTID
WHERE R.ACCESSNUMBER='$ACCESSNUMBER'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
$regno = $row[0];
$reqdate = $row[1];
$pname = $row[2];
$pnum = $row[3];
$paddress = $row[4];
$pphone = $row[5];
$pemail = $row[6];
$psex = $row[7];
$pAge = $row[8];
$pAgeM = $row[9];
$rcomment = $row[10];
$pstate = $row[11];
$pcity = $row[12];
if($pstate == '') { $pstate = $pcity; }
//$sql = "select ODR_CRESULT_TO, ODR_CREFERENCENAME, ODR_CREFERENCEDOCNAME from GDC_CMOD.dbo.V_TDL_ORDER where ODR_CNOLAB='$regno'";
//$sql = "select ODR_CRESULT_TO, ODR_CREFERENCENAME, ODR_CREFERENCEDOCNAME from GLENEAGLES...TDL_ORDER where ODR_CNOLAB='$regno'";
$sql = "select ODR_CRESULT_TO, ODR_CREFERENCENAME, ODR_CREFERENCEDOCNAME from GDC_CMOD.dbo.TDL_ORDER where ODR_CNOLAB='$regno'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
$sendto = $row[0];
$loc = $row[1];
$doc = $row[2];
if($loc == 'PT. BANGUN GUNUNG SARI (BGS)') { $loc = "PT. BANGUN GUNUNG SARI (BGS)"; }
elseif($loc == 'PT. PUTRA DUTA PEMBANGUNAN') { $loc = "PT. PUTRA DUTA PEMBANGUNAN"; }
elseif($loc == 'PT. BENSA ADHI CIPTA') { $loc = "-"; }
elseif($loc == 'PT. LIM SIANG HUAT BALINDO') { $loc = "-"; }
elseif($loc=='') { $loc = 'WALK IN'; }
if($doc=='') { $doc = $loc; }
// noreg, reqdate, access#, mr#, name,address, phone,email,sex,age,reff,doctor
$data ="<table class='info'>
<tr style='border-bottom:solid 1px black'><th colspan='4'>LABORATORY REPORT</th></tr>
<tr> <td>Reg#</td> <td>: $regno</td> <td>Date</td> <td><pre>: $reqdate $sendto</pre></td></tr>
<tr> <td>Lab#</td> <td colspan='3'>: $ACCESSNUMBER</td> </tr>
<tr> <td>MR</td> <td colspan='3'>: $pnum</td> </tr>
<tr> <td>Name</td> <td colspan='3'>: $pname</td> </tr>
<tr> <td>Address</td> <td colspan='3'>: $paddress</td> </tr>
<tr> <td>Phone/Email</td> <td colspan='3'>: $pphone / $pemail</td> </tr>
<tr> <td>City</td> <td colspan='3'>: $pstate</td> </tr>
<tr> <td>Sex</td> <td>: $psex</td> <td>Age</td> <td>: $pAge years, $pAgeM months</td></tr>
<tr> <td>Reff</td> <td colspan='3'>: $loc</td></tr>
<tr> <td>Doctor</td> <td colspan='3'>: $doc</td></tr>
</table>
";
return $data;
}
function getData2($conn,$ACCESSNUMBER) {
$sql = "select R.EXTERNALORDERNUMBER, format(SR.COLLECTIONDATE,'dd-MM-yyyy'), P.NAME, right(P.PATNUMBER,16),
dmg.DMG_CADDRESS, P.TELEPHON, P.EMAIL,
case
when P.SEX=1 then 'Male'
when P.SEX=2 then 'Female'
else 'Unknown'
end,
case when format(P.BIRTHDATE,'MMdd')=format(R.COLLECTIONDATE,'MMdd') then DATEDIFF(YEAR,P.BIRTHDATE, R.COLLECTIONDATE)
--else DATEDIFF(hour,P.BIRTHDATE, R.COLLECTIONDATE)/8766 end ,
else FLOOR(DATEDIFF(DAY, P.BIRTHDATE, R.COLLECTIONDATE) / 365.25) end ,
case when datepart(day,R.COLLECTIONDATE) >= datepart(day,P.BIRTHDATE) then datediff(month,P.BIRTHDATE, R.COLLECTIONDATE)%12
else datediff(month, P.BIRTHDATE, dateadd(month,-1,R.COLLECTIONDATE))%12
end,
RO.COMMENTTEXT, dmg.DMG_CCITY, P.BIRTHDATE, T.SHORTTEXT
from REQUESTS R
left join SP_REQUESTS SR on SR.SP_ACCESSNUMBER=R.ACCESSNUMBER
left join PATIENTS P on P.PATID=R.PATID
left join REQUESTS_OCOM RO on RO.REQUESTID=R.REQUESTID
left join DICT_TEXTS T on P.TITLEID=T.TEXTID
left join GDC_CMOD.dbo.TDL_DEMOGRAPHIC dmg on right(P.PATNUMBER,16)=dmg.DMG_CPATNUMBER collate Latin1_general_CS_AS
WHERE R.ACCESSNUMBER='$ACCESSNUMBER'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
/*
$regno = $row[0];
$reqdate = $row[1];
$pname = $row[2];
$pnum = $row[3];
$paddress = $row[4];
$pphone = $row[5];
$pemail = $row[6];
$psex = $row[7];
$pAge = $row[8];
$pAgeM = $row[9];
$rcomment = $row[10];
$pcity = $row[11];
isset($row[0]) ? $row[0] : ''
*/
$regno = isset($row[0]) ? $row[0] : '';
$reqdate = isset($row[1]) ? $row[1] : '';
$pname = isset($row[2]) ? $row[2] : '';
$pnum = isset($row[3]) ? $row[3] : '';
$paddress = isset($row[4]) ? $row[4] : '';
$pphone = isset($row[5]) ? $row[5] : '';
$pemail = isset($row[6]) ? $row[6] : '';
$psex = isset($row[7]) ? $row[7] : '';
$pAge = isset($row[8]) ? $row[8] : '';
$pAgeM = isset($row[9]) ? $row[9] : '';
$rcomment = isset($row[10]) ? $row[10] : '';
$pcity = isset($row[11]) ? $row[11] : '';
$pdob = '' ;
if( isset($row[12]) )
{ if($row[12]!= null ) { $pdob = date_format($row[12],'d-m-Y'); } }
$title = isset($row[13]) ? $row[13] : '';
if($title != '') { $pname = "$pname, $title"; }
//$sql = "select ODR_CRESULT_TO, ODR_CREFERENCENAME, ODR_CREFERENCEDOCNAME from GDC_CMOD.dbo.V_TDL_ORDER where ODR_CNOLAB='$regno'";
//$sql = "select ODR_CRESULT_TO, ODR_CREFERENCENAME, ODR_CREFERENCEDOCNAME from GLENEAGLES...TDL_ORDER where ODR_CNOLAB='$regno'";
$sql = "select ODR_CRESULT_TO, ODR_CREFERENCENAME, ODR_CREFERENCEDOCNAME from GDC_CMOD.dbo.TDL_ORDER where ODR_CNOLAB='$regno'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
$sendto = isset($row[0]) ? $row[0] : '';
$loc = isset($row[1]) ? $row[1]: '';
$doc = isset($row[2]) ? $row[2]: '';
if($loc == 'PT. BANGUN GUNUNG SARI (BGS)') { $loc = "PT. BANGUN GUNUNG SARI (BGS"; }
elseif($loc == 'PT. PUTRA DUTA PEMBANGUNAN') { $loc = "PT. PUTRA DUTA PEMBANGUNAN"; }
elseif($loc == 'PT. BENSA ADHI CIPTA') { $loc = "-"; }
elseif($loc == 'PT. LIM SIANG HUAT BALINDO') { $loc = "-"; }
elseif($loc=='') { $loc = 'WALK IN'; }
if($doc=='') { $doc = $loc; }
// noreg, reqdate, access#, mr#, name,address, phone,email,sex,age,reff,doctor
$data ="<table class='info'>
<tr style='border-bottom:solid 1px black'><th colspan='5'>CLINICAL LABORATORY</th></tr>
<tr> <td>Reg#</td> <td>:</td> <td>$regno</td> <td>Date</td> <td><pre>: $reqdate $sendto</pre></td></tr>
<tr> <td>Lab#</td> <td>:</td> <td>$ACCESSNUMBER</td> <td>DoB</td> <td>: $pdob (D-M-Y)</td> </tr>
<tr> <td>MR</td> <td>:</td> <td>$pnum</td> <td>Age</td> <td>: $pAge years, $pAgeM months</td> </tr>
<tr> <td>Name</td> <td>:</td> <td colspan='3'>$pname</td> </tr>
<tr> <td>Address</td> <td>:</td> <td colspan='3'>$paddress</td> </tr>
<tr> <td>Phone/Email</td> <td>:</td> <td colspan='3'>$pphone / $pemail</td> </tr>
<tr> <td>City</td> <td>:</td> <td colspan='3'>$pcity</td> </tr>
<tr> <td>Sex</td> <td>:</td> <td colspan='3'>$psex</td> </tr>
<tr> <td>Reff</td> <td>:</td> <td colspan='3'>$loc</td></tr>
<tr> <td>Doctor</td> <td>:</td> <td colspan='3'>$doc</td></tr>
</table>
";
return $data;
}
function getHost($conn,$ACCESSNUMBER) {
$sql = "select EXTERNALORDERNUMBER from REQUESTS where ACCESSNUMBER='$ACCESSNUMBER'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
$HOSTNUMBER = isset($row[0]) ? $row[0] : '';
return $HOSTNUMBER;
}
function getNotes($conn, $ACCESSNUMBER) {
/*
$sql = "select case
when l.LOCID='3741' then p.TELEPHON2
else null
end,
ro.COMMENTTEXT from REQUESTS r
left join REQUESTS_OCOM ro on r.REQUESTID=ro.REQUESTID
left join LOCATIONS l on r.REQUESTID=l.REQUESTID
left join PATIENTS p on p.PATID=r.PATID
where r.ACCESSNUMBER='$ACCESSNUMBER'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
$notes = '';
if(isset($row[0])) { $notes .= $row[0]."<br/>"; }
$notes .= $row[1];
*/
$sql = "select ro.COMMENTTEXT from REQUESTS r
left join REQUESTS_OCOM ro on r.REQUESTID=ro.REQUESTID
where r.ACCESSNUMBER='$ACCESSNUMBER'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
$notes = isset($row[0]) ? $row[0] : '';
return $notes;
}
function getStatus($conn, $ACCESSNUMBER) {
$sql = "select STATS from GDC_CMOD.dbo.V_DASHBOARD_DEV where SP_ACCESSNUMBER='$ACCESSNUMBER'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
if(isset($row[0])) {
$status = $row[0];
//if( in_array($ACCESSNUMBER, array('4050360338', '4050360347') ) ) { $status='Comp'; }
if($status == 'Fin') { $status = 'FINAL'; }
elseif($status == 'FinV') { $status = 'FINAL (Verified)'; }
elseif($status == 'PenV') { $status = 'PENDING (Verified)'; }
else { $status = 'PENDING'; }
} else { $status = ''; }
return $status;
}
function getCollData($conn,$ACCESSNUMBER) {
$collData = "";
$sql = "select distinct format(COLLECTIONDATE,'dd-MM-yyyy'), format(COLLECTIONDATE,'HH:mm'), x = stuff(
(select ', ' + dst.SHORTTEXT from GDC_CMOD.dbo.TUBES t1
left join glendb.dbo.DICT_SAMPLES_TYPES dst on t1.TUBENUMBER=dst.SAMPCODE
where t1.ACCESSNUMBER=t.ACCESSNUMBER
and format(t1.COLLECTIONDATE,'dd-MM-yyyy HH:mm')=format(t.COLLECTIONDATE,'dd-MM-yyyy HH:mm')
for xml path('')),
1,1, '')
from GDC_CMOD.dbo.TUBES t where t.ACCESSNUMBER='$ACCESSNUMBER' and STATUS=1";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$date1 = '';
while ( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC) ) {
if($date1 == $row[0]) { $collData .= $row[1].$row[2].'. '; }
else { $collData .= $row[0].' '.$row[1].$row[2].'. '; }
$date1 = $row[0];
}
return $collData;
}
function getRecvData($conn,$ACCESSNUMBER) {
$recvData = "";
$sql = "select DS.SHORTTEXT, format(S.LABRECEPTIONDATE,'dd-MM-yyyy'), format(S.LABRECEPTIONDATE,'HH:mm') from SAMPLES S
left join DICT_SAMPLES_TYPES DS on DS.SAMPCODE=LEFT(S.SAMPLENUMBER,3)
left join SP_TUBES ST on ST.TUBENB=right(S.FULLSAMPLENUM,13)
where S.FULLSAMPLENUM like '%$ACCESSNUMBER' and ST.TUBESTATUS=4
order by S.LABRECEPTIONDATE";
/*
$sql= "select ds.SHORTTEXT, format(st.COLLECTIONDATE,'dd-MM-yyy'), format(st.COLLECTIONDATE,'HH:mm') from SP_TUBES st
left join DICT_SAMPLES_TYPES ds on ds.SAMPCODE=st.SAMPLETYPE
where st.SP_ACCESSNUMBER='$ACCESSNUMBER' and st.TUBESTATUS=4";
*/
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$date1 = '';
$time1 = '';
while ( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC) ) {
$x = $row[0];
$date = $row[1];
$time = $row[2];
if( $date1 == $date ) {
if($time1==$time) { $recvData .= $x.'. '; }
else { $recvData .= $time.' '.$x.'. '; }
}
else { $recvData .= $date.' '.$time.' '.$x.'. '; }
$date1 = $date;
$time1 = $time;
}
return $recvData;
}
function getValBy($conn,$ACCESSNUMBER) {
$sql = "SELECT top 1 a.INITUSER, max(STEPDATE) as STEPDATE
FROM glendb.dbo.AUDIT_TRAIL a WHERE (a.LIS_SESSION='VAL' or (a.LIS_SESSION='ERM' and a.VALIDATION=5))
and a.ATR_ACCESSNUMBER='$ACCESSNUMBER'
GROUP BY a.INITUSER, a.STEPDATE
order by a.STEPDATE desc";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
$valBy = isset($row[0]) ? $row[0] : '';
if( $valBy == '' || $valBy =='LIS' ) { $valBy = "AHT"; }
return $valBy;
}
function getVal2By($conn,$ACCESSNUMBER) {
$sql = "select VALUSER from CM_REQUESTS where ACCESSNUMBER='$ACCESSNUMBER'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
$valBy = isset($row[0]) ? $row[0] : '';
if( $valBy == '' || $valBy =='LIS' ) { $valBy = "AHT"; }
return $valBy;
}
function getVal1($conn,$ACCESSNUMBER) {
$sql = "SELECT top 1 a.INITUSER, max(STEPDATE) as STEPDATE
FROM glendb.dbo.AUDIT_TRAIL a WHERE (a.LIS_SESSION='VAL' or (a.LIS_SESSION='ERM' and a.VALIDATION=5))
and a.ATR_ACCESSNUMBER='$ACCESSNUMBER'
GROUP BY a.INITUSER, a.STEPDATE
order by a.STEPDATE desc";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
$valBy = isset($row[0]) ? $row[0] : '';
$valDate = isset($row[1]) ? $row[1] : '';
if( $valBy == '' || $valBy =='LIS' ) { $valBy = "SYSTEM"; }
$val = [ 'valBy'=>$valBy, 'valDate'=>$valDate ];
return $val;
}
function getNoSample($conn,$ACCESSNUMBER) {
$sql = "select DST.SHORTTEXT from SP_TUBES ST
LEFT JOIN DICT_SAMPLES_TYPES DST ON DST.SAMPCODE=ST.TUBETYPE
where ST.SP_ACCESSNUMBER='$ACCESSNUMBER' AND ST.TUBESTATUS<>4";
/*
$sql = "select DS.SHORTTEXT from SP_TUBES T
left join DICT_SAMPLES_TYPES DS on T.SAMPLETYPE=DS.SAMPCODE
where T.SP_ACCESSNUMBER='$ACCESSNUMBER'
and T.SAMPLETYPE not in (
select substring(S.SAMPLENUMBER,0,4) from SAMPLES S
left join REQUESTS R on R.REQUESTID=S.REQUESTID
where R.ACCESSNUMBER=T.SP_ACCESSNUMBER
) AND T.SAMPLETYPE <> '900'";
*/
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$noSample = '';
while ($row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC)) {
$sample = $row[0];
$noSample .= "<tr> <td>$sample</td> <td colspan='6'>No Sample</td> </tr>\r";
}
return $noSample;
}
?>

View File

@ -1,905 +0,0 @@
<?php
function getE($text){
$pos1 = strpos($text,'#E')+2;
$pos2 = strrpos($text,'#E')-2;
$text = substr($text, $pos1, $pos2-$pos1 );
return $text;
}
function getQrcode($HOSTNUMBER) {
$secret_key = "Trisensa_diagnostic_centre";
$secret_iv = "Gleneagles_surabaya";
$encrypt_method = "AES-256-CBC";
$key = hash('sha256', $secret_key);
$iv = substr(hash('sha256', $secret_iv), 0, 16);
$encrypted = base64_encode(openssl_encrypt($HOSTNUMBER, $encrypt_method, $key, 0, $iv));
$qrcode = 'trisensadc.co.id/qrcode/data_detail.php?no_reg='.$encrypted;
return $qrcode;
}
function f_repl($text, $ntext, $pos) {
if($pos != 0) {
$len = strlen($ntext);
if(substr($text,$pos,1) == ' ' ) { $text = substr_replace( $text, $ntext, $pos, $len); }
}
return $text;
}
function getResult($conn, $ACCESSNUMBER, $eng) {
include("_inc.php");
$sql = "SELECT DC.FULLTEXT, DT.TESTCODE, T.VALIDATIONSTATUS,
RESULT = CASE
WHEN T.RESTYPE=0 THEN 'Pending'
WHEN T.RESTYPE=4 AND T.RESVALUE='' AND T.RESSTATUS=1 THEN '.' -- null -> .
WHEN T.RESTYPE IN (7,15,4) THEN T.RESVALUE
WHEN T.RESTYPE=9 THEN +'< '+T.RESVALUE
WHEN T.RESTYPE=10 THEN +'> '+T.RESVALUE
WHEN T.RESVALUE IS NULL THEN
CASE
WHEN T.CODEDRESULTID IS NULL AND DT.TESTTYPE IN (4,5) THEN null
WHEN T.CODEDRESULTID IS NULL THEN TC.COMMENTTEXT
WHEN T.CODEDRESULTID IS NOT NULL AND T.RESTYPE=6 AND SUBSTRING(DX.FULLTEXT,1,3) NOT LIKE '%#%' THEN DX.FULLTEXT
END
ELSE T.RESVALUE
END,
T.MINIMUM, T.MAXIMUM,
DT.FULLTEXT,
DT.RESPRECISION,DT.RESPRECISION2, DT.OPERAND, DT.SOFTCONVERSION, DT.UNITS, DT.UNITS2, T.RESTYPE, VI.FULLTEXT,
case
when TC.COMMENTTEXT is null then DX2.FULLTEXT
else TC.COMMENTTEXT
end, T.RERUN
FROM TESTS T
JOIN DICT_TESTS DT ON DT.TESTID=T.TESTID
LEFT JOIN DICT_TEXTS DX ON DX.TEXTID=T.CODEDRESULTID
LEFT JOIN TESTS_COMMENTS TC ON TC.REQTESTID=T.REQTESTID
LEFT JOIN DICT_TEXTS DX2 ON DX2.TEXTID=TC.COMMENTCODEDID
LEFT JOIN REQUESTS R ON R.REQUESTID=T.REQUESTID
LEFT JOIN DICT_CHAPTERS DC ON DC.CHAPID=T.CHAPID
LEFT JOIN GDC_CMOD.dbo.V_INTER2 VI ON VI.ATR_ACCESSNUMBER=R.ACCESSNUMBER AND DT.TESTCODE=VI.ATR_TESTCODE
WHERE R.ACCESSNUMBER='$ACCESSNUMBER' AND T.NOTPRINTABLE IS NULL AND DT.TESTCODE<>'STATS' AND ISNUMERIC(DT.TESTCODE)=0
ORDER BY T.TESTORDER";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$CHAP = "";
$i = 0;
$page = 1;
$line = 0;
$lpp = 37; // line per page
$done[1]= "";
$nline = 0;
$RERUN=1;
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC)) {
$CHAPTER = $row[0];
$TESTCODE = $row[1];
$VALIDATIONSTATUS = $row[2];
$R1 = $row[3];
if($R1=='****') {$R1='-';}
$L1 = $row[4];
$H1 = $row[5];
$FULLTEXT = $row[6];
$PRECISION1 = $row[7];
$PRECISION2 = $row[8];
$OPERAND = $row[9];// 3* 4/
$SOFTCONVERSION =$row[10];
$U1 = $row[11];
$U2 = $row[12];
$RESTYPE = $row[13];
$I = $row[14];
$RESCOM = $row[15];
// Get ITEXT or ETEXT
if($eng==1) {
$ICHAPTER = substr($CHAPTER, strpos($CHAPTER,'#E')+2, strrpos($CHAPTER,'#E')-strpos($CHAPTER,'#E')-2 );
if($ICHAPTER != $CHAP) {
$raw[$i] = " <tr><td colspan='7'><pre>$ICHAPTER</pre></td> </tr>\r\n";
$nline += 1;
}
$CHAP = $ICHAPTER;
$ITEXT = substr($FULLTEXT, strpos($FULLTEXT,'#E')+2, strrpos($FULLTEXT,'#E')-strpos($FULLTEXT,'#E')-2 );
} else {
$ICHAPTER = substr($CHAPTER,2, strrpos($CHAPTER,'#I')-2 );
if($ICHAPTER != $CHAP) {
$raw[$i] = " <tr><td colspan='7'><pre>$ICHAPTER</pre></td> </tr>\r\n";
$nline += 1;
}
$CHAP = $ICHAPTER;
$ITEXT = substr($FULLTEXT,2, strrpos($FULLTEXT,'#I')-2 );
}
// GRP | ELE
if($TESTCODE=='PCRN') { $raw[$i] .= " <tr> <td></td> <td colspan='6'><br/><pre>$ITEXT</pre></td></tr>"; $done[$page] .= $raw[$i]; }
elseif(!is_numeric($RESTYPE)) {
// ch
if( array_key_exists( $TESTCODE, $_chinese) ) { $ITEXT = rtrim($ITEXT)." <span class='textC'>".$_chinese[$TESTCODE].'</span>'; }
if($ITEXT!='') {
$ITEXT = " <tr> <td colspan='7'><pre>$ITEXT</pre></td> </tr>\r\n";
$nline += 1;
$raw[$i] .= $ITEXT;
}
$RERUN = $row[16];
} else {
//flagging
if( substr($R1,0,2)=='< ' && is_numeric(substr($R1,2,strlen($R1))) ) { $r1 = substr($R1,2,strlen($R1)); $r1-=1;}
elseif( substr($R1,0,2)=='> ' && is_numeric(substr($R1,2,strlen($R1))) ) { $r1 = substr($R1,2,strlen($R1)); $r1+=1;}
else {$r1 = $R1;}
$F = "";
if($TESTCODE != 'TROPI') {
if($r1 < $L1 && is_numeric($r1) && is_numeric($L1)) {$F = "*L";}
elseif($r1 > $H1 && is_numeric($r1) && is_numeric($H1)) {$F = "*H";}
}
// UNTUK LH
if($TESTCODE == 'LH') {
if($r1 < $L1 && is_numeric($r1) && is_numeric($L1)) {$F = "*L";}
elseif($r1 > $H1 && is_numeric($r1) && is_numeric($H1)) {$F = "*H";}
// else {$F = "*L";}
}
//get R2 L2 H2
if($RESTYPE == 0) { $R2=""; $L1=""; $H1=""; $L2=""; $H2=""; }
else {
if(is_numeric($L1) && $PRECISION1 != 0 ) { $L1 = number_format($L1,$PRECISION1); } else { $L1 = number_format($L1); }
if(is_numeric($H1) && $PRECISION1 != 0 ) { $H1 = number_format($H1,$PRECISION1); } else { $H1 = number_format($H1); }
if( in_array($RESTYPE,[7,15,4]) && $OPERAND == 3 ) {
if(is_numeric($R1)) { $R2 = NUMBER_FORMAT($R1 * $SOFTCONVERSION, $PRECISION2,'.',''); }
else {$R2 = '';}
if($L1 != 0) { $L2 = NUMBER_FORMAT($L1 * $SOFTCONVERSION, $PRECISION2); }
else {$L2 = 0;}
if(is_numeric($H1) && $H1 != 0) { $H2 = NUMBER_FORMAT($H1 * $SOFTCONVERSION, $PRECISION2); }
else {$H2 = 0;}
} elseif( in_array($RESTYPE,[7,15,4]) && $OPERAND == 4 ) {
IF(is_numeric($R1)) { $R2 = NUMBER_FORMAT($R1 / $SOFTCONVERSION, $PRECISION2); }
ELSE {$R2 = '';}
IF(is_numeric($L1) && $L1 != 0) { $L2 = NUMBER_FORMAT($L1 / $SOFTCONVERSION, $PRECISION2); }
ELSE {$L2 = 0;}
IF(is_numeric($H1) && $H1 != 0) { $H2 = NUMBER_FORMAT($H1 / $SOFTCONVERSION, $PRECISION2); }
ELSE {$H2 = 0;}
} elseif ( in_array($RESTYPE,[9,10]) & $OPERAND == 3 ) {
$r21 = substr($R1, 0, 2);
$r22 = substr($R1, 2, 10);
$r22 = NUMBER_FORMAT($r22 * $SOFTCONVERSION, $PRECISION2,'.','');
$R2 = $r21.$r22;
if($L1 != 0) { $L2 = NUMBER_FORMAT($L1 * $SOFTCONVERSION, $PRECISION2); }
else {$L2 = '';}
if($H1 != 0) { $H2 = NUMBER_FORMAT($H1 * $SOFTCONVERSION, $PRECISION2); }
else {$H2 = '';}
} elseif ( in_array($RESTYPE,[9,10]) & $OPERAND == 4 ) {
$r21 = substr($R1, 0, 2);
$r22 = substr($R1, 2, 10);
$r22 = NUMBER_FORMAT($r22 / $SOFTCONVERSION, $PRECISION2,'.','');
$R2 = $r21.$r22;
IF($L1 != 0) { $L2 = NUMBER_FORMAT($L1 / $SOFTCONVERSION, $PRECISION2); }
ELSE {$L2 = '';}
IF($H1 != 0) { $H2 = NUMBER_FORMAT($H1 / $SOFTCONVERSION, $PRECISION2); }
ELSE {$H2 = '';}
} else { $R2=$R1; $L2=$L1; $H2=$H1; }
}
if( ($L1 == 0) && ($H1 == 0) ) { $L1=''; $H1=''; $L2=''; $H2=''; }
//precision1
if(is_numeric($R1) && is_numeric($PRECISION1)) { $R1 = NUMBER_FORMAT($R1,$PRECISION1,'.',','); }
if(is_numeric($R2) && is_numeric($PRECISION2)) { $R2 = NUMBER_FORMAT($R2,$PRECISION2,'.',','); }
// split in half - multi line
// text | result
$TEXT = explode("\r\n",$ITEXT);
$test = array();
$res = array();
foreach($TEXT as $text) {
$test[]= substr($text,0,33);
$res[]= substr($text,33,strlen($text));
}
$space = ( strlen($test[0])-strlen(ltrim($test[0])) ) * 7;
$test = rtrim(implode("\r\n",$test));
$res = implode("\r\n",$res);
// italic
if( in_array( $TESTCODE, $_italic) ) { $test ="<i>$test</i>"; }
// ch
if( array_key_exists( $TESTCODE, $_chinese) ) { $test.=" <span class='textC'>".$_chinese[$TESTCODE].'</span>'; }
//line count
$tline = count( explode(PHP_EOL, $test) );
$rline = count( explode(PHP_EOL, $res) );
$r1line = count( explode(PHP_EOL, $R1) );
if($rline < $r1line) { $rline = $r1line; }
if ($test == ' Note') {
$ITEXT = " <tr> <td style='padding-left:".$space."px'><br/>$test</td> <td colspan='6'><br/><pre>$res </pre></td> </tr>\r\n";
} elseif ( strlen($RESCOM) < 2 ) {
//$ITEXT = " <tr> <td style='padding-left:".$space."px'>$test</td> <td colspan='6'><pre>$res </pre></td> </tr>\r\n";
$ITEXT = " <tr> <td style='padding-left:".$space."px'>$test</td> <td colspan='6'><pre>$res </pre></td> </tr>\r\n";
} else {
$rline += count( explode(PHP_EOL, $RESCOM) );
$res = rtrim($res);
$ITEXT = " <tr> <td style='padding-left:".$space."px'>$test</td> <td colspan='6'><pre>$res \r\n$RESCOM</pre></td> </tr>\r\n ";
}
if($tline > $rline) { $nline += $tline; } else { $nline += $rline; }
/*
## replace {R1 {L1 {H1 {R2 {L2 {H2 {I ##
GET STRING POS
DELETE ALL STRING
{R1,{R2,{I,{L1,{H1,{L2,{H2 // ORDER
GET NEW STRING LENGTH
*/
// Get all string pos
$posR1 = strpos($ITEXT, "{R1");
$posR12 = strrpos($ITEXT, "{R1");
$posR2 = strpos($ITEXT, "{R2");
$posR22 = strrpos($ITEXT, "{R2");
$posI1 = strpos($ITEXT, "{I");
$posI2 = strrpos($ITEXT, "{I");
$posL1 = strpos($ITEXT, "{L1");
$posL12 = strrpos($ITEXT, "{L1");
$posH1 = strpos($ITEXT, "{H1");
$posH12 = strrpos($ITEXT, "{H1");
$posL2 = strpos($ITEXT, "{L2");
$posL22 = strrpos($ITEXT, "{L2");
$posH2 = strpos($ITEXT, "{H2");
$posH22 = strrpos($ITEXT, "{H2");
$posU1 = strpos($ITEXT, "{U1");
//all using U2
//if($posU1 == 0 ) { $posU1 = strrpos($ITEXT, "{U2"); $U1 = $U2; }
$posU2 = strpos($ITEXT, "{U2");
#echo "<pre>$ITEXT</pre>\r\n";
// Delete all string
$ITEXT = str_replace( "{R1", " ", $ITEXT );
$ITEXT = str_replace( "{R2", " ", $ITEXT );
$ITEXT = str_replace( "{I", " ", $ITEXT );
$ITEXT = str_replace( "{L1", " ", $ITEXT );
$ITEXT = str_replace( "{H1", " ", $ITEXT );
$ITEXT = str_replace( "{L2", " ", $ITEXT );
$ITEXT = str_replace( "{H2", " ", $ITEXT );
$ITEXT = str_replace( "{U1", " ", $ITEXT );
$ITEXT = str_replace( "{U2", " ", $ITEXT );
// REPLACE
if(in_array($RESTYPE, [4,6,7,9,10,15])) {
$ITEXT = f_repl($ITEXT,$R1.' '.$F,$posR1);
if($posR1 != $posR12) { $ITEXT = f_repl($ITEXT,$R1.' '.$F,$posR12); }
$ITEXT = f_repl($ITEXT,$L1,$posL1);
if($posL1 != $posL12) { $ITEXT = f_repl($ITEXT,$L1,$posL12); }
$ITEXT = f_repl($ITEXT,$H1,$posH1);
if($posH1 != $posH12) { $ITEXT = f_repl($ITEXT,$H1,$posH12); }
if(isset($R2)) {
$ITEXT = f_repl($ITEXT,$R2.' '.$F,$posR2);
if($posR2 != $posR22) { $ITEXT = f_repl($ITEXT,$R2.' '.$F,$posR22); }
}
if(isset($L2)) { $ITEXT = f_repl($ITEXT,$L2,$posL2); }
if($posL2 != $posL22) { $ITEXT = f_repl($ITEXT,$L2,$posL22); }
if(isset($H2)) { $ITEXT = f_repl($ITEXT,$H2,$posH2); }
if($posH2 != $posH22) { $ITEXT = f_repl($ITEXT,$H2,$posH22); }
$ITEXT = f_repl($ITEXT,$I,$posI1);
$ITEXT = f_repl($ITEXT,$I,$posI2);
$ITEXT = f_repl($ITEXT,$U1,$posU1);
$ITEXT = f_repl($ITEXT,$U2,$posU2);
} elseif(in_array($RESTYPE,[2,0,5])) {
if(strlen($RESCOM) < 2) {
$ITEXT = substr($ITEXT, 0, $posR1); $ITEXT .= $R1."</pre></td> </tr>";
} else {
$ITEXT = substr($ITEXT, 0, $posR1); $ITEXT .= "$R1 \r\n$RESCOM</pre></td> </tr>";
}
}
// bold flag
//$ITEXT = str_replace('*L', '<b>*L</b>', $ITEXT);
//$ITEXT = str_replace('*H', '<b>*H</b>', $ITEXT);
$raw[$i] .= $ITEXT;
$line += $nline;
if($TESTCODE != 'COVGG') {
if($line > $lpp) {$page++; $done[$page] = ""; $line = $nline; }
} else {
if($line > $lpp-14) {$page++; $done[$page] = ""; $line = $nline; }
}
if($line > $lpp) {$page++; $done[$page] = ""; $line = $nline; }
$done[$page] .= $raw[$i];
$i++;
$raw[$i] = "";
$nline = 0;
}
}
return $done;
}
function getOthers($conn,$ACCESSNUMBER, $eng) {
$sql = "select DT.FULLTEXT from TESTS T
left join REQUESTS R on R.REQUESTID=T.REQUESTID
left join DICT_TESTS DT on DT.TESTID=T.TESTID
where R.ACCESSNUMBER='$ACCESSNUMBER' and ISNUMERIC(DT.TESTCODE)=1
order by T.TESTORDER";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$i = 1;
$raw = "";
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC) ) {
$text = $row[0];
if($eng==1) {
$text = substr( $text , strpos($text,'#E')+2, strrpos($text,'#E')-strpos($text,'#E')-2 );
} else {
$text = substr( $text , strpos($text,'#I')+2, strrpos($text,'#I')-2 );
}
$text = str_replace( "{R1", " ", $text );
$text = str_replace( "{R2", " ", $text );
$text = str_replace( "{I", " ", $text );
$text = str_replace( "{L1", " ", $text );
$text = str_replace( "{H1", " ", $text );
$text = str_replace( "{L2", " ", $text );
$text = str_replace( "{H2", " ", $text );
$text = str_replace( "{U1", " ", $text );
$text = str_replace( "{U2", " ", $text );
$text = trim($text);
$raw .= "$i. $text <br/>\r\n";
$i++;
}
return $raw;
}
function getData($conn,$ACCESSNUMBER) {
$sql = "select R.EXTERNALORDERNUMBER, format(SR.COLLECTIONDATE,'dd/MM/yyyy'), P.NAME, right(P.PATNUMBER,16),
rtrim(P.ADDRESS1+isnull(P.ADDRESS2,'')), P.TELEPHON, P.EMAIL,
case
when P.SEX=1 then 'Male'
when P.SEX=2 then 'Female'
else 'Unknown'
end,
--FLOOR(DATEDIFF(DAY, P.BIRTHDATE, R.COLLECTIONDATE) / 365.25),
DATEDIFF(DAY, P.BIRTHDATE, R.COLLECTIONDATE) / 365.25+1,
MONTH(R.COLLECTIONDATE - DATEADD(year, DATEDIFF(year, P.BIRTHDATE, R.COLLECTIONDATE), P.BIRTHDATE) ) - 1,
RO.COMMENTTEXT, P.STATE, P.CITY
from REQUESTS R
left join SP_REQUESTS SR on SR.SP_ACCESSNUMBER=R.ACCESSNUMBER
left join PATIENTS P on P.PATID=R.PATID
left join REQUESTS_OCOM RO on RO.REQUESTID=R.REQUESTID
WHERE R.ACCESSNUMBER='$ACCESSNUMBER'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
$regno = $row[0];
$reqdate = $row[1];
$pname = $row[2];
$pnum = $row[3];
$paddress = $row[4];
$pphone = $row[5];
$pemail = $row[6];
$psex = $row[7];
$pAge = $row[8];
$pAgeM = $row[9];
$rcomment = $row[10];
$pstate = $row[11];
$pcity = $row[12];
if($pstate == '') { $pstate = $pcity; }
//$sql = "select ODR_CRESULT_TO, ODR_CREFERENCENAME, ODR_CREFERENCEDOCNAME from GDC_CMOD.dbo.V_TDL_ORDER where ODR_CNOLAB='$regno'";
//$sql = "select ODR_CRESULT_TO, ODR_CREFERENCENAME, ODR_CREFERENCEDOCNAME from GLENEAGLES...TDL_ORDER where ODR_CNOLAB='$regno'";
$sql = "select ODR_CRESULT_TO, ODR_CREFERENCENAME, ODR_CREFERENCEDOCNAME from GDC_CMOD.dbo.TDL_ORDER where ODR_CNOLAB='$regno'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
$sendto = $row[0];
$loc = $row[1];
$doc = $row[2];
if($loc == 'PT. BANGUN GUNUNG SARI (BGS)') { $loc = "PT. BANGUN GUNUNG SARI (BGS)"; }
elseif($loc == 'PT. PUTRA DUTA PEMBANGUNAN') { $loc = "PT. PUTRA DUTA PEMBANGUNAN"; }
elseif($loc == 'PT. BENSA ADHI CIPTA') { $loc = "-"; }
elseif($loc == 'PT. LIM SIANG HUAT BALINDO') { $loc = "-"; }
elseif($loc=='') { $loc = 'WALK IN'; }
if($doc=='') { $doc = $loc; }
// noreg, reqdate, access#, mr#, name,address, phone,email,sex,age,reff,doctor
$data ="<table class='info'>
<tr style='border-bottom:solid 1px black'><th colspan='4'>LABORATORY REPORT</th></tr>
<tr> <td>Reg#</td> <td>: $regno</td> <td>Date</td> <td><pre>: $reqdate $sendto</pre></td></tr>
<tr> <td>Lab#</td> <td colspan='3'>: $ACCESSNUMBER</td> </tr>
<tr> <td>MR</td> <td colspan='3'>: $pnum</td> </tr>
<tr> <td>Name</td> <td colspan='3'>: $pname</td> </tr>
<tr> <td>Address</td> <td colspan='3'>: $paddress</td> </tr>
<tr> <td>Phone/Email</td> <td colspan='3'>: $pphone / $pemail</td> </tr>
<tr> <td>City</td> <td colspan='3'>: $pstate</td> </tr>
<tr> <td>Sex</td> <td>: $psex</td> <td>Age</td> <td>: $pAge years, $pAgeM months</td></tr>
<tr> <td>Reff</td> <td colspan='3'>: $loc</td></tr>
<tr> <td>Doctor</td> <td colspan='3'>: $doc</td></tr>
</table>
";
return $data;
}
function getData2($conn,$ACCESSNUMBER) {
$sql = "select R.EXTERNALORDERNUMBER, format(SR.COLLECTIONDATE,'dd-MM-yyyy'), P.NAME, right(P.PATNUMBER,16),
dmg.DMG_CADDRESS, P.TELEPHON, P.EMAIL,
case
when P.SEX=1 then 'Male'
when P.SEX=2 then 'Female'
else 'Unknown'
end,
case when format(P.BIRTHDATE,'MMdd')=format(R.COLLECTIONDATE,'MMdd') then DATEDIFF(YEAR,P.BIRTHDATE, R.COLLECTIONDATE)
else DATEDIFF(hour,P.BIRTHDATE, R.COLLECTIONDATE)/8766 end ,
case when datepart(day,R.COLLECTIONDATE) >= datepart(day,P.BIRTHDATE) then datediff(month,P.BIRTHDATE, R.COLLECTIONDATE)%12
else datediff(month, P.BIRTHDATE, dateadd(month,-1,R.COLLECTIONDATE))%12
end,
RO.COMMENTTEXT, dmg.DMG_CCITY, P.BIRTHDATE
from REQUESTS R
left join SP_REQUESTS SR on SR.SP_ACCESSNUMBER=R.ACCESSNUMBER
left join PATIENTS P on P.PATID=R.PATID
left join REQUESTS_OCOM RO on RO.REQUESTID=R.REQUESTID
left join GDC_CMOD.dbo.TDL_DEMOGRAPHIC dmg on right(P.PATNUMBER,16)=dmg.DMG_CPATNUMBER collate Latin1_general_CS_AS
WHERE R.ACCESSNUMBER='$ACCESSNUMBER'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
/*
$regno = $row[0];
$reqdate = $row[1];
$pname = $row[2];
$pnum = $row[3];
$paddress = $row[4];
$pphone = $row[5];
$pemail = $row[6];
$psex = $row[7];
$pAge = $row[8];
$pAgeM = $row[9];
$rcomment = $row[10];
$pcity = $row[11];
isset($row[0]) ? $row[0] : ''
*/
$regno = isset($row[0]) ? $row[0] : '';
$reqdate = isset($row[1]) ? $row[1] : '';
$pname = isset($row[2]) ? $row[2] : '';
$pnum = isset($row[3]) ? $row[3] : '';
$paddress = isset($row[4]) ? $row[4] : '';
$pphone = isset($row[5]) ? $row[5] : '';
$pemail = isset($row[6]) ? $row[6] : '';
$psex = isset($row[7]) ? $row[7] : '';
$pAge = isset($row[8]) ? $row[8] : '';
$pAgeM = isset($row[9]) ? $row[9] : '';
$rcomment = isset($row[10]) ? $row[10] : '';
$pcity = isset($row[11]) ? $row[11] : '';
$pdob = '' ;
if( isset($row[12]) )
{ if($row[12]!= null ) { $pdob = date_format($row[12],'d-m-Y'); } }
//$sql = "select ODR_CRESULT_TO, ODR_CREFERENCENAME, ODR_CREFERENCEDOCNAME from GDC_CMOD.dbo.V_TDL_ORDER where ODR_CNOLAB='$regno'";
//$sql = "select ODR_CRESULT_TO, ODR_CREFERENCENAME, ODR_CREFERENCEDOCNAME from GLENEAGLES...TDL_ORDER where ODR_CNOLAB='$regno'";
$sql = "select ODR_CRESULT_TO, ODR_CREFERENCENAME, ODR_CREFERENCEDOCNAME from GDC_CMOD.dbo.TDL_ORDER where ODR_CNOLAB='$regno'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
$sendto = isset($row[0]) ? $row[0] : '';
$loc = isset($row[1]) ? $row[1]: '';
$doc = isset($row[2]) ? $row[2]: '';
if($loc == 'PT. BANGUN GUNUNG SARI (BGS)') { $loc = "PT. BANGUN GUNUNG SARI (BGS"; }
elseif($loc == 'PT. PUTRA DUTA PEMBANGUNAN') { $loc = "PT. PUTRA DUTA PEMBANGUNAN"; }
elseif($loc == 'PT. BENSA ADHI CIPTA') { $loc = "-"; }
elseif($loc == 'PT. LIM SIANG HUAT BALINDO') { $loc = "-"; }
elseif($loc=='') { $loc = 'WALK IN'; }
if($doc=='') { $doc = $loc; }
// noreg, reqdate, access#, mr#, name,address, phone,email,sex,age,reff,doctor
$data ="<table class='info'>
<tr style='border-bottom:solid 1px black'><th colspan='5'>CLINICAL LABORATORY</th></tr>
<tr> <td>Reg#</td> <td>:</td> <td>$regno</td> <td>Date</td> <td><pre>: $reqdate $sendto</pre></td></tr>
<tr> <td>Lab#</td> <td>:</td> <td>$ACCESSNUMBER</td> <td>DoB</td> <td>: $pdob (D-M-Y)</td> </tr>
<tr> <td>MR</td> <td>:</td> <td>$pnum</td> <td>Age</td> <td>: $pAge years, $pAgeM months</td> </tr>
<tr> <td>Name</td> <td>:</td> <td colspan='3'>$pname</td> </tr>
<tr> <td>Address</td> <td>:</td> <td colspan='3'>$paddress</td> </tr>
<tr> <td>Phone/Email</td> <td>:</td> <td colspan='3'>$pphone / $pemail</td> </tr>
<tr> <td>City</td> <td>:</td> <td colspan='3'>$pcity</td> </tr>
<tr> <td>Sex</td> <td>:</td> <td colspan='3'>$psex</td> </tr>
<tr> <td>Reff</td> <td>:</td> <td colspan='3'>$loc</td></tr>
<tr> <td>Doctor</td> <td>:</td> <td colspan='3'>$doc</td></tr>
</table>
";
return $data;
}
function getHost($conn,$ACCESSNUMBER) {
$sql = "select EXTERNALORDERNUMBER from REQUESTS where ACCESSNUMBER='$ACCESSNUMBER'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
$HOSTNUMBER = isset($row[0]) ? $row[0] : '';
return $HOSTNUMBER;
}
function getNotes($conn, $ACCESSNUMBER) {
/*
$sql = "select case
when l.LOCID='3741' then p.TELEPHON2
else null
end,
ro.COMMENTTEXT from REQUESTS r
left join REQUESTS_OCOM ro on r.REQUESTID=ro.REQUESTID
left join LOCATIONS l on r.REQUESTID=l.REQUESTID
left join PATIENTS p on p.PATID=r.PATID
where r.ACCESSNUMBER='$ACCESSNUMBER'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
$notes = '';
if(isset($row[0])) { $notes .= $row[0]."<br/>"; }
$notes .= $row[1];
*/
$sql = "select ro.COMMENTTEXT from REQUESTS r
left join REQUESTS_OCOM ro on r.REQUESTID=ro.REQUESTID
where r.ACCESSNUMBER='$ACCESSNUMBER'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
$notes = isset($row[0]) ? $row[0] : '';
return $notes;
}
function getStatus($conn, $ACCESSNUMBER) {
/*
$sql = "select
case
when exists ( select 1 from GDC_CMOD.dbo.TDL_ORDER t left join SP_REQUESTS r on r.HOSTORDERNUMBER=t.ODR_CNOLAB collate Latin1_general_CS_AS
WHERE r.SP_ACCESSNUMBER='$ACCESSNUMBER' and t.ODR_ISPENDING=1 ) then 'PENDING'
when exists (
select 1 from TESTS t
left join REQUESTS r on r.REQUESTID=t.REQUESTID
where r.ACCESSNUMBER='$ACCESSNUMBER' and
( t.RESTYPE=0 OR t.RESSTATUS=0 OR Left(t.RESVALUE,7)='Pending' )
and t.NOTPRINTABLE is null
) then 'PENDING'
else 'FINAL'
end";
*/
$sql = "select STATS from GDC_CMOD.dbo.V_DASHBOARD where SP_ACCESSNUMBER='$ACCESSNUMBER'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
if(isset($row[0])) {
$status = $row[0];
if($status == 'Comp') { $status = 'FINAL'; }
else { $status = 'PENDING'; }
} else { $status = ''; }
return $status;
}
function getCollData($conn,$ACCESSNUMBER) {
$collData = "";
$sql = "select distinct format(COLLECTIONDATE,'dd-MM-yyyy'), format(COLLECTIONDATE,'HH:mm'), x = stuff(
(select ', ' + dst.SHORTTEXT from GDC_CMOD.dbo.TUBES t1
left join glendb.dbo.DICT_SAMPLES_TYPES dst on t1.TUBENUMBER=dst.SAMPCODE
where t1.ACCESSNUMBER=t.ACCESSNUMBER
and format(t1.COLLECTIONDATE,'dd-MM-yyyy HH:mm')=format(t.COLLECTIONDATE,'dd-MM-yyyy HH:mm')
for xml path('')),
1,1, '')
from GDC_CMOD.dbo.TUBES t where t.ACCESSNUMBER='$ACCESSNUMBER' and STATUS=1";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$date1 = '';
while ( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC) ) {
if($date1 == $row[0]) { $collData .= $row[1].$row[2].'. '; }
else { $collData .= $row[0].' '.$row[1].$row[2].'. '; }
$date1 = $row[0];
}
return $collData;
}
function getRecvData($conn,$ACCESSNUMBER) {
$recvData = "";
$sql = "select DS.SHORTTEXT, format(S.LABRECEPTIONDATE,'dd-MM-yyyy'), format(S.LABRECEPTIONDATE,'HH:mm') from SAMPLES S
left join DICT_SAMPLES_TYPES DS on DS.SAMPCODE=LEFT(S.SAMPLENUMBER,3)
left join SP_TUBES ST on ST.TUBENB=right(S.FULLSAMPLENUM,13)
where S.FULLSAMPLENUM like '%$ACCESSNUMBER' and ST.TUBESTATUS=4
order by S.LABRECEPTIONDATE";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$date1 = '';
while ( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC) ) {
$x = $row[0];
$date = $row[1];
$time = $row[2];
if( $date1 == $date ) {
if($time1==$time) { $recvData .= $x.'. '; }
else { $recvData .= $time.' '.$x.'. '; }
}
else { $recvData .= $date.' '.$time.' '.$x.'. '; }
$date1 = $date;
$time1 = $time;
}
return $recvData;
}
function getValBy($conn,$ACCESSNUMBER) {
$sql = "SELECT top 1 a.INITUSER, max(STEPDATE) as STEPDATE
FROM glendb.dbo.AUDIT_TRAIL a WHERE (a.LIS_SESSION='VAL' or (a.LIS_SESSION='ERM' and a.VALIDATION=5))
and a.ATR_ACCESSNUMBER='$ACCESSNUMBER'
GROUP BY a.INITUSER, a.STEPDATE
order by a.STEPDATE desc";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
$valBy = isset($row[0]) ? $row[0] : '';
if( $valBy == '' || $valBy =='LIS' ) { $valBy = "AHT"; }
return $valBy;
}
function getVal1($conn,$ACCESSNUMBER) {
$sql = "SELECT top 1 a.INITUSER, max(STEPDATE) as STEPDATE
FROM glendb.dbo.AUDIT_TRAIL a WHERE (a.LIS_SESSION='VAL' or (a.LIS_SESSION='ERM' and a.VALIDATION=5))
and a.ATR_ACCESSNUMBER='$ACCESSNUMBER'
GROUP BY a.INITUSER, a.STEPDATE
order by a.STEPDATE desc";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
$valBy = isset($row[0]) ? $row[0] : '';
$valDate = isset($row[1]) ? $row[1] : '';
if( $valBy == '' || $valBy =='LIS' ) { $valBy = "SYSTEM"; }
$val = [ 'valBy'=>$valBy, 'valDate'=>$valDate ];
return $val;
}
function getNoSample($conn,$ACCESSNUMBER) {
$sql = "select DST.SHORTTEXT from SP_TUBES ST
LEFT JOIN DICT_SAMPLES_TYPES DST ON DST.SAMPCODE=ST.TUBETYPE
where ST.SP_ACCESSNUMBER='$ACCESSNUMBER' AND ST.TUBESTATUS<>4";
/*
$sql = "select DS.SHORTTEXT from SP_TUBES T
left join DICT_SAMPLES_TYPES DS on T.SAMPLETYPE=DS.SAMPCODE
where T.SP_ACCESSNUMBER='$ACCESSNUMBER'
and T.SAMPLETYPE not in (
select substring(S.SAMPLENUMBER,0,4) from SAMPLES S
left join REQUESTS R on R.REQUESTID=S.REQUESTID
where R.ACCESSNUMBER=T.SP_ACCESSNUMBER
) AND T.SAMPLETYPE <> '900'";
*/
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$noSample = '';
while ($row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC)) {
$sample = $row[0];
$noSample .= "<tr> <td>$sample</td> <td colspan='6'>No Sample</td> </tr>\r";
}
return $noSample;
}
function getResultDebug($conn, $ACCESSNUMBER, $eng) {
include("_inc.php");
$sql = "SELECT DC.FULLTEXT, DT.TESTCODE, T.VALIDATIONSTATUS,
RESULT = CASE
WHEN T.RESTYPE=0 THEN 'Pending'
WHEN T.RESTYPE=4 AND T.RESVALUE='' AND T.RESSTATUS=1 THEN '.' -- null -> .
WHEN T.RESTYPE IN (7,15,4) THEN T.RESVALUE
WHEN T.RESTYPE=9 THEN +'< '+T.RESVALUE
WHEN T.RESTYPE=10 THEN +'> '+T.RESVALUE
WHEN T.RESVALUE IS NULL THEN
CASE
WHEN T.CODEDRESULTID IS NULL AND DT.TESTTYPE IN (4,5) THEN null
WHEN T.CODEDRESULTID IS NULL THEN TC.COMMENTTEXT
WHEN T.CODEDRESULTID IS NOT NULL AND T.RESTYPE=6 AND SUBSTRING(DX.FULLTEXT,1,3) NOT LIKE '%#%' THEN DX.FULLTEXT
END
ELSE T.RESVALUE
END,
T.MINIMUM, T.MAXIMUM,
DT.FULLTEXT,
DT.RESPRECISION,DT.RESPRECISION2, DT.OPERAND, DT.SOFTCONVERSION, DT.UNITS, DT.UNITS2, T.RESTYPE, VI.FULLTEXT,
case
when TC.COMMENTTEXT is null then DX2.FULLTEXT
else TC.COMMENTTEXT
end, T.RERUN
FROM TESTS T
JOIN DICT_TESTS DT ON DT.TESTID=T.TESTID
LEFT JOIN DICT_TEXTS DX ON DX.TEXTID=T.CODEDRESULTID
LEFT JOIN TESTS_COMMENTS TC ON TC.REQTESTID=T.REQTESTID
LEFT JOIN DICT_TEXTS DX2 ON DX2.TEXTID=TC.COMMENTCODEDID
LEFT JOIN REQUESTS R ON R.REQUESTID=T.REQUESTID
LEFT JOIN DICT_CHAPTERS DC ON DC.CHAPID=T.CHAPID
LEFT JOIN GDC_CMOD.dbo.V_INTER2 VI ON VI.ATR_ACCESSNUMBER=R.ACCESSNUMBER AND DT.TESTCODE=VI.ATR_TESTCODE
WHERE R.ACCESSNUMBER='$ACCESSNUMBER' AND T.NOTPRINTABLE IS NULL AND DT.TESTCODE<>'STATS'
ORDER BY T.TESTORDER";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$CHAP = "";
$i = 0;
$page = 1;
$line = 0;
$lpp = 34; // line per page
$done[1]= "";
$nline = 0;
$RERUN=1;
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC)) {
$CHAPTER = $row[0];
$TESTCODE = $row[1];
$VALIDATIONSTATUS = $row[2];
$R1 = $row[3];
if($R1=='****') {$R1='-';}
$L1 = $row[4];
$H1 = $row[5];
$FULLTEXT = $row[6];
$PRECISION1 = $row[7];
$PRECISION2 = $row[8];
$OPERAND = $row[9];// 3* 4/
$SOFTCONVERSION =$row[10];
$U1 = $row[11];
$U2 = $row[12];
$RESTYPE = $row[13];
$I = $row[14];
$RESCOM = $row[15];
// Get ITEXT or ETEXT
if($eng==1) {
$ICHAPTER = substr($CHAPTER, strpos($CHAPTER,'#E')+2, strrpos($CHAPTER,'#E')-strpos($CHAPTER,'#E')-2 );
if($ICHAPTER != $CHAP) {
$raw[$i] = " <tr><td colspan='7'><pre>$ICHAPTER</pre></td> </tr>\r\n";
$nline += 1;
}
$CHAP = $ICHAPTER;
$ITEXT = substr($FULLTEXT, strpos($FULLTEXT,'#E')+2, strrpos($FULLTEXT,'#E')-strpos($FULLTEXT,'#E')-2 );
} else {
$ICHAPTER = substr($CHAPTER,2, strrpos($CHAPTER,'#I')-2 );
if($ICHAPTER != $CHAP) {
$raw[$i] = " <tr><td colspan='7'><pre>$ICHAPTER</pre></td> </tr>\r\n";
$nline += 1;
}
$CHAP = $ICHAPTER;
$ITEXT = substr($FULLTEXT,2, strrpos($FULLTEXT,'#I')-2 );
}
// GRP | ELE
if($TESTCODE=='PCRN') { $raw[$i] .= " <tr> <td></td> <td colspan='6'><br/><pre>$ITEXT</pre></td></tr>"; $done[$page] .= $raw[$i]; }
elseif(!is_numeric($RESTYPE)) {
// ch
if( array_key_exists( $TESTCODE, $_chinese) ) { $ITEXT = rtrim($ITEXT)." <span class='textC'>".$_chinese[$TESTCODE].'</span>'; }
if($ITEXT!='') {
$ITEXT = " <tr> <td colspan='7'><pre>$ITEXT</pre></td> </tr>\r\n";
$nline += 1;
$raw[$i] .= $ITEXT;
}
$RERUN = $row[16];
} else {
//flagging
if( substr($R1,0,2)=='< ' && is_numeric(substr($R1,2,strlen($R1))) ) { $r1 = substr($R1,2,strlen($R1)); $r1-=1;}
elseif( substr($R1,0,2)=='> ' && is_numeric(substr($R1,2,strlen($R1))) ) { $r1 = substr($R1,2,strlen($R1)); $r1+=1;}
else {$r1 = $R1;}
if($r1 < $L1 && is_numeric($r1) && is_numeric($L1)) {$F = "*L";}
elseif($r1 > $H1 && is_numeric($r1) && is_numeric($H1)) {$F = "*H";}
else {$F="";}
//echo "$R1<br/>";
//get R2 L2 H2
if($RESTYPE == 0) { $R2=""; $L1=""; $H1=""; $L2=""; $H2=""; }
else {
if( in_array($RESTYPE,[7,15,4]) && $OPERAND == 3 ) {
if(is_numeric($R1)) { $R2 = NUMBER_FORMAT($R1 * $SOFTCONVERSION, $PRECISION2,'.',''); }
else {$R2 = 0;}
if($L1 != 0) { $L2 = NUMBER_FORMAT($L1 * $SOFTCONVERSION, $PRECISION2); }
else {$L2 = 0;}
if($H1 != 0) { $H2 = NUMBER_FORMAT($H1 * $SOFTCONVERSION, $PRECISION2); }
else {$H2 = 0;}
} elseif( in_array($RESTYPE,[7,15,4]) && $OPERAND == 4 ) {
IF(is_numeric($R1)) { $R2 = NUMBER_FORMAT($R1 / $SOFTCONVERSION, $PRECISION2); }
ELSE {$R2 = 0;}
IF($L1 != 0) { $L2 = NUMBER_FORMAT($L1 / $SOFTCONVERSION, $PRECISION2); }
ELSE {$L2 = 0;}
IF($H1 != 0) { $H2 = NUMBER_FORMAT($H1 / $SOFTCONVERSION, $PRECISION2); }
ELSE {$H2 = 0;}
} else { $R2=$R1; $L2=$L1; $H2=$H1; }
}
//precision1
if(is_numeric($R1) && is_numeric($PRECISION1)) { $R1 = NUMBER_FORMAT($R1,$PRECISION1,'.',''); }
// split in half - multi line
// text | result
$TEXT = explode("\r\n",$ITEXT);
$test = array();
$res = array();
foreach($TEXT as $text) {
$test[]= substr($text,0,33);
$res[]= substr($text,33,strlen($text));
}
$space = ( strlen($test[0])-strlen(ltrim($test[0])) ) * 7;
$test = rtrim(implode("\r\n",$test));
$res = implode("\r\n",$res);
// italic
if( in_array( $TESTCODE, $_italic) ) { $test ="<i>$test</i>"; }
// ch
if( array_key_exists( $TESTCODE, $_chinese) ) { $test.=" <span class='textC'>".$_chinese[$TESTCODE].'</span>'; }
//line count
$tline = count( explode(PHP_EOL, $test) );
$rline = count( explode(PHP_EOL, $res) );
$r1line = count( explode(PHP_EOL, $R1) );
if($rline < $r1line) { $rline = $r1line; }
if ($test == ' Note') {
$ITEXT = " <tr> <td style='padding-left:".$space."px'><br/>$test</td> <td colspan='6'><br/><pre>$res </pre></td> </tr>\r\n";
} elseif ( strlen($RESCOM) < 2 ) {
$ITEXT = " <tr> <td style='padding-left:".$space."px'>$test</td> <td colspan='6'><pre>$res </pre></td> </tr>\r\n";
} else {
$rline += count( explode(PHP_EOL, $RESCOM) );
$res = rtrim($res);
$ITEXT = " <tr> <td style='padding-left:".$space."px'>$test</td> <td colspan='6'><pre>$res \r\n$RESCOM</pre></td> </tr>\r\n ";
}
if($tline > $rline) { $nline += $tline; } else { $nline += $rline; }
/*
## replace {R1 {L1 {H1 {R2 {L2 {H2 {I ##
GET STRING POS
DELETE ALL STRING
{R1,{R2,{I,{L1,{H1,{L2,{H2 // ORDER
GET NEW STRING LENGTH
*/
// Get all string pos
$posR1 = strpos($ITEXT, "{R1");
$posR12 = strrpos($ITEXT, "{R1");
$posR2 = strpos($ITEXT, "{R2");
$posR22 = strrpos($ITEXT, "{R2");
$posI1 = strpos($ITEXT, "{I");
$posI2 = strrpos($ITEXT, "{I");
$posL1 = strpos($ITEXT, "{L1");
$posH1 = strpos($ITEXT, "{H1");
$posL2 = strpos($ITEXT, "{L2");
$posH2 = strpos($ITEXT, "{H2");
$posU1 = strpos($ITEXT, "{U1");
$posU2 = strpos($ITEXT, "{U2");
#echo "<pre>$ITEXT</pre>\r\n";
// Delete all string
$ITEXT = str_replace( "{R1", " ", $ITEXT );
$ITEXT = str_replace( "{R2", " ", $ITEXT );
$ITEXT = str_replace( "{I", " ", $ITEXT );
$ITEXT = str_replace( "{L1", " ", $ITEXT );
$ITEXT = str_replace( "{H1", " ", $ITEXT );
$ITEXT = str_replace( "{L2", " ", $ITEXT );
$ITEXT = str_replace( "{H2", " ", $ITEXT );
$ITEXT = str_replace( "{U1", " ", $ITEXT );
$ITEXT = str_replace( "{U2", " ", $ITEXT );
// REPLACE
if(in_array($RESTYPE, [4,6,7,9,10,15])) {
$ITEXT = f_repl($ITEXT,$R1.' '.$F,$posR1);
if($posR1 != $posR12) { $ITEXT = f_repl($ITEXT,$R1.' '.$F,$posR12); }
$ITEXT = f_repl($ITEXT,$L1,$posL1);
$ITEXT = f_repl($ITEXT,$H1,$posH1);
if(isset($R2)) {
$ITEXT = f_repl($ITEXT,$R2.' '.$F,$posR2);
if($posR2 != $posR22) { $ITEXT = f_repl($ITEXT,$R2.' '.$F,$posR22); }
}
if(isset($L2)) { $ITEXT = f_repl($ITEXT,$L2,$posL2); }
if(isset($H2)) { $ITEXT = f_repl($ITEXT,$H2,$posH2); }
$ITEXT = f_repl($ITEXT,$I,$posI1);
$ITEXT = f_repl($ITEXT,$I,$posI2);
$ITEXT = f_repl($ITEXT,$U1,$posU1);
$ITEXT = f_repl($ITEXT,$U2,$posU2);
} elseif(in_array($RESTYPE,[0,5])) {
if(strlen($RESCOM) < 2) {
$ITEXT = substr($ITEXT, 0, $posR1); $ITEXT .= $R1."</pre></td> </tr>";
} else {
$ITEXT = substr($ITEXT, 0, $posR1); $ITEXT .= "$R1 \r\n$RESCOM</pre></td> </tr>";
}
}
// bold flag
//$ITEXT = str_replace('*L', '<b>*L</b>', $ITEXT);
//$ITEXT = str_replace('*H', '<b>*H</b>', $ITEXT);
$raw[$i] .= $ITEXT;
$line += $nline;
if($TESTCODE != 'COVGG') {
if($line > $lpp) {$page++; $done[$page] = ""; $line = $nline; }
} else {
if($line > $lpp-14) {$page++; $done[$page] = ""; $line = $nline; }
}
if($line > $lpp) {$page++; $done[$page] = ""; $line = $nline; }
$done[$page] .= $raw[$i];
$i++;
$raw[$i] = "";
$nline = 0;
}
}
return $done;
}
?>

View File

@ -1,23 +0,0 @@
<?php
$_chinese = array(
"HBSAG" => "B型肝炎抗原", "GGT" => "丙种谷氨酰转肽酶", "NEUT" => "中性粒细胞", "HBSAT" => "乙肝表面抗体", "AHBS" => "乙肝表面抗体", "AHBST" => "乙肝表面抗体效价", "LDH" => "乳酸脱氢酶",
"LDL" => "<br/>低密度脂蛋白", "PROLA" => "促乳素", "TPHCG" => "促绒毛膜性激素测验", "PSA" => "前列腺特异性抗原", "MONO" => "单核细胞", "HSV1G" => "单纯疱疹病毒抗体1IgG",
"HSV1M" => "单纯疱疹病毒抗体1IgM", "HSV2G" => "单纯疱疹病毒抗体2IgG", "HSV2M" => "单纯疱疹病毒抗体2IgM", "CRPQN" => "反应蛋白质量", "2SWTH" => "咽喉", "2DIPT" => "咽喉",
"BASO" => "嗜性粒血球数", "EOS" => "嗜酸性粒血球", "EOSC" => "嗜酸性粒血球", "PBF" => "<br/>外周血沈淀率", "UA" => "尿酸", "CMVG" => "巨细胞病毒IgG", "CMVM" => "巨细胞病毒IgM",
"MCHC" => "平均含血红素浓度", "MCH" => "平均含血红素量", "ACAG" => "异常冠状动脉IgG", "ACAM" => "异常冠状动脉IgM", "GDS" => "当时", "VDRL" => "性病研究实验试验",
"CHOL" => "总胆固醇", "UBIL" => "总胆红素", "TP" => "总蛋白质(量)", "EBVEA" => "抗EB病毒定量免疫A", "EBVVA" => "抗EB病毒滴度免疫A", "SALMG" => "抗沙门菌IgG",
"SALMM" => "抗沙门菌IgM", "DENGG" => "抗登革热IgG", "DENGR" => "抗登革热IgG/IgM快速", "DENGM" => "抗登革热IgM", "ICTTB" => "抗结核菌抗体线测试",
"ASTO" => "抗链球菌", "AMUBA" => "抗阿米巴", "TPHA" => "梅毒螺旋体血凝集测定", "PAPS" => "涂片", "LYM" => "淋巴细胞", "1GO" => "淋病", "FPSA" => "游离前列腺特异性抗原",
"GLOB" => "球蛋白", "TG" => "甘油三脂", "GROW" => "生长荷尔蒙", "PTH" => "甲状旁腺激素", "TPO" => "甲状腺过氧化物酶抗体", "AFP" => "甲胎蛋白", "CA125" => "癌抗体125",
"CA153" => "癌抗体15-3", "CA199" => "癌抗体19-9", "CA724" => "癌抗体72-4", "CEA" => "癌胚抗原", "1NEIS" => "白喉(咽)", "2DIPN" => "白喉(鼻)", "WBC" => "白细胞",
"FWBC" => "白细胞", "ULEUX" => "白细胞数目", "ALB" => "白蛋白", "CORPG" => "皮质醇", "CORSR" => "皮质醇", "DBIL" => "直接", "TESTO" => "睾酮", "ALP" => "<br/>碱性磷酸",
"NSE" => "神经原特异性烯醇化酶", "GLUP" => "空腹", "HBA1C" => "空腹与餐后血糖水平", "2SPER" => "精虫", "SPERM" => "精虫", "RBC" => "红细胞", "FRBC" => "红细胞",
"UERY" => "红细胞数目", "LED" => "红细胞沈降率", "MCV" => "红血球平均体积", "PCV" => "红血球积压", "PASMS" => "组织学 病理", "CYSMS" => "细胞学", "CKMB" => "细胞角蛋白",
"CREA" => "肌酸酐,肌酸内酰胺酸", "BTGN" => "肾石化验", "BATU" => "胆石化验", "CHE" => "胆碱酯酶", "INSL" => "胰岛素", "CYSTC" => "胱硫醚", "APN" => "脂联素",
"LIPO" => "脂蛋白", "2PUS" => "", "DHEAS" => "脱氢表雄酮硫酸酯", "UGLU" => "葡萄糖", "UPROT" => "蛋白", "GOLRH" => "血型", "PLT" => "血小板", "BUN" => "血尿素氮",
"TBIL" => "血清谷丙转氨酶", "SGPT" => "血清谷丙转氨酶", "SGOT" => "血清谷草转氨酶", "HB" => "血红素", "CHLAA" => "衣原体素", "CHLAG" => "衣原体素IgG", "CHLAM" => "衣原体素IgM",
"HSCRP" => "赵敏反应蛋白", "APOA1" => "载脂蛋白", "APOB" => "载脂蛋白", "APOR" => "载脂蛋白比率", "SDLDL" => "载脂蛋白比率", "ALDO" => "醛固酮", "DIFF" => "鉴别",
"ESTRI" => "雌三醇", "FESTR" => "雌三醇", "RUBG" => "风疹IgG", "RUBM" => "风疹IgM", "GLU2P" => "餐后两个小时", "HDL" => "高密度脂蛋白");
$_italic = array("UTRI","ITALIC","PLSFC", "PLSOV", "PLSML", "PLSVI");
?>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 222 KiB

View File

@ -1,2 +0,0 @@
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}main{display:block}h1{font-size:2em;margin:.67em 0}hr{box-sizing:content-box;height:0;overflow:visible}pre{font-family:monospace,monospace;font-size:1em}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,input{overflow:visible}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:1px dotted ButtonText}fieldset{padding:.35em .75em .625em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}progress{vertical-align:baseline}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}details{display:block}summary{display:list-item}template{display:none}[hidden]{display:none}

View File

@ -1 +0,0 @@
{"version":3,"sources":["normalize.css"],"names":[],"mappings":"AAqEA,SA6GA,IACA,IAIE,eAAgB,SA8FlB,OAnCA,GAoCA,MACE,SAAqB,QAhRvB,KACE,YAAa,WACb,qBAAiC,KACjC,yBAA6C,KAO/C,KACE,OAAQ,EAcD,YAKH,MAPN,QACA,MACA,QAEA,OACA,OACA,OACA,KAEA,IACA,QACA,QACE,QAAoC,MAOtC,MACA,OACA,SACA,MACE,QAAS,aAOX,sBACE,QAAS,KACT,OAAQ,EAgBA,UAAV,SAEE,QAAS,KAWX,EACE,iBAAkB,YAClB,6BAAyC,QAQ3C,SACA,QACE,cAAe,EAWjB,YACE,cAAe,KACf,gBAA4B,UAC5B,gBAAoC,UAAU,OAOhD,EACA,OAUE,YAAa,OAOf,IACE,WAAY,OAQd,GACE,UAAW,IACX,OAAQ,MAAO,EAOjB,KACE,iBAAkB,KAClB,MAAO,KAOT,MACE,UAAW,IAQb,IACA,IACE,UAAW,IACX,YAAa,EACb,SAAU,SAIZ,IACE,OAAQ,OAGV,IACE,IAAK,MAUP,IACE,aAAc,KAOhB,eACE,SAAU,OAWZ,KACA,IACA,IACA,KACE,YAAa,UAAW,UACxB,UAAsB,IAOxB,OACE,OAAQ,IAAI,KAQd,GACE,WAAY,YACZ,OAAmB,EAYrB,OACA,MACA,OACA,SACE,KAAM,QACN,OAAmB,EAOrB,SACE,YAAa,IAQf,OACA,OASA,OACA,OACE,eAA2B,KAY7B,cAFsB,cADtB,OACA,mBAGE,mBAAoB,OAQtB,gCACA,+BACA,gCAHA,yBAIE,aAAc,KACd,QAAS,EAQX,6BACA,4BACA,6BAHA,sBAIE,QAAoB,WAAP,OAAJ,IAOX,SACE,OAAQ,IAAI,MAAM,OAClB,OAAQ,EAAE,IACV,QAAS,MAAO,OAAQ,MAU1B,OACE,WAAY,WACZ,MAAkB,QAClB,QAA4B,MAC5B,UAAsC,KACtC,QAA4C,EAC5C,YAAwD,OAO1D,SACE,SAAU,KAQZ,gBACA,aACE,WAAY,WACZ,QAAoB,EAOtB,yCACA,yCACE,OAAQ,KAQV,cACE,mBAAoB,UACpB,eAA2B,KAO7B,4CACA,yCACE,mBAAoB,KAOtB,4BACE,MAAO,QACP,QAAS,IAQX,6BACE,mBAAoB,OACpB,KAAiB"}

View File

@ -1,34 +0,0 @@
/*html,pre,th,table { font-family:'Courier New', Courier, monospace; font-size:7.8pt; margin:0;}*/
html,pre,th,table { font-family:'Lucida Console', Monaco, monospace; font-size:7.7pt; margin:0;}
#page { background: white; display: block; margin: 0 auto; page-break-after:always; width: 210mm; height: 295mm; }
#dinfo { float:left; width:200mm;
background-size: 100% auto; background-repeat: no-repeat;
margin-left:0.5cm;
}
#dresult { float:left; margin: 0.2cm 0.8cm 0 1.5cm; height: 17.5cm; }
#footer { float:left; margin:0cm 2cm 0 1cm; height:1.5cm; }
table {border-collapse:collapse;}
td {vertical-align:top;}
th,td { line-height:1.3;}
.result tr:nth-child(even), th { background: #DDD !important; }
.info { border:solid 1px black; margin:-1cm 0 0 8.5cm; width:11cm;}
.flag { float:right; top:0; font-weight:bold; }
.result { table-layout:fixed; border:solid 1px black; width:100%; }
.textC { font-size:7pt; }
.footer {width : 17cm; }
.footer td {vertical-align:bottom;}
td.right { text-align: right; }
#notes { margin: 5mm 0 0 10mm; }
.img { width:200mm; margin-left:0.5cm }
.img-footer { margin-bottom:7.5mm }
pre.small {font-size:6pt;}
@media print {
@page { margin:0; size:210mm 297mm; }
}

View File

@ -1,33 +0,0 @@
/*html,pre,th,table { font-family:'Courier New', Courier, monospace; font-size:7.8pt; margin:0;}*/
html,pre,th,table { font-family:'Lucida Console', Monaco, monospace; font-size:7.7pt; margin:0;}
#page { background: white; display: block; margin: 0 auto; page-break-after:always; width: 210mm; height: 295mm; }
#dinfo { float:left; width:200mm;
background-size: 100% auto; background-repeat: no-repeat;
margin-left:0.5cm;
}
#dresult { float:left; margin: 0.2cm 0.8cm 0 1.5cm; height: 16cm; }
#footer { float:left; margin:0cm 0cm 0.5cm 1cm; }
table {border-collapse:collapse;}
td {vertical-align:top;}
th,td { line-height:1.3;}
.result tr:nth-child(even), th { background: #DDD !important; }
.info { border:solid 1px black; margin:-1cm 0 0 8.5cm; width:11cm;}
.flag { float:right; top:0; font-weight:bold; }
.result { table-layout:fixed; border:solid 1px black; width:100%; }
.textC { font-size:7pt; }
.footer {width : 18.5cm; }
.footer td {vertical-align:bottom;}
td.right { text-align: right; }
#notes { margin: 5mm 0 0 10mm; }
.img { width:210mm; }
pre.small {font-size:6pt;}
@media print {
@page { margin:0; size:210mm 297mm; }
}

View File

@ -1,29 +0,0 @@
/*html,pre,th,table { font-family:'Courier New', Courier, monospace; font-size:7.8pt; margin:0;}*/
html,pre,th,table { font-family:'Lucida Console', Monaco, monospace; font-size:7.5pt; margin:0;}
body { -webkit-print-color-adjust:exact; }
#page { z-index:1; background: white; display: block; margin: 0; page-break-after:always;
/*width: 210mm; height: 297mm;*/
width: 210mm; height: 297mm;
}
#dinfo { float:right; margin:4cm 0.8cm 0 0; }
#dresult { float:left; margin: 0.2cm 0.8cm 0 1.5cm; height: 16.5cm; }
#footer { float:left; margin:0cm 2cm 0 1cm; height:3cm; }
table {border-collapse:collapse;}
td {vertical-align:top;}
th,td { line-height:1.3;}
.result tr:nth-child(even), th { background: #f2f2f2; }
.info { border:solid 1px black; width:11cm; }
.flag { float:right; top:0; font-weight:bold; }
.result { table-layout:fixed; border:solid 1px black; width:100%; }
.textC { font-size:7pt; }
.footer {width : 17cm; }
.footer td {vertical-align:bottom;}
td.right { text-align: right; }
#notes { margin: 5mm 0 0 10mm; }
.footer-img { visibility:hidden; }
pre.small {font-size:6pt;}

View File

@ -1,29 +0,0 @@
/*html,pre,th,table { font-family:'Courier New', Courier, monospace; font-size:7.8pt; margin:0;}*/
html,pre,th,table { font-family:'Lucida Console', Monaco, monospace; font-size:7.5pt; margin:0;}
body { -webkit-print-color-adjust:exact; }
#page { z-index:1; background: white; display: block; margin: 0; page-break-after:always;
/*width: 210mm; height: 297mm;*/
width: 210mm; height: 297mm;
}
#dinfo { float:right; margin:4cm 0.8cm 0 0; }
#dresult { float:left; margin: 0.2cm 0.8cm 0 1.5cm; height: 14cm; }
#footer { float:left; margin:0cm 2cm 0 1cm; }
table {border-collapse:collapse;}
td {vertical-align:top;}
th,td { line-height:1.3;}
.result tr:nth-child(even), th { background: #f2f2f2; }
.info { border:solid 1px black; width:11cm; }
.flag { float:right; top:0; font-weight:bold; }
.result { table-layout:fixed; border:solid 1px black; width:100%; }
.textC { font-size:7pt; }
.footer {width : 17cm; height:4cm; }
.footer td {vertical-align:bottom;}
td.right { text-align: right; }
#notes { margin: 5mm 0 0 10mm; }
.footer-img { visibility:hidden; }
pre.small {font-size:6pt;}

View File

@ -1,10 +0,0 @@
<?php
$serverName = "glenlis";
$db = "glendb";
$connectionInfo = array( "Database"=>$db, "UID"=>"sa", "PWD"=>"Summittso4516728");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( !$conn ) {
echo "Connection 1 could not be established.<br />";
die( print_r( sqlsrv_errors(), true));
}
?>

View File

@ -1,10 +0,0 @@
<?php
$serverName = "localhost";
$db = "glendb";
$connectionInfo = array( "Database"=>$db, "UID"=>"sa", "PWD"=>"master");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( !$conn ) {
echo "Connection 1 could not be established.<br />";
die( print_r( sqlsrv_errors(), true));
}
?>

View File

@ -1,151 +0,0 @@
<?php
if(isset($_GET['preview'])) { $preview = $_GET['preview']; } else { $preview=0; }
if(isset($_GET['eng'])) { $eng = $_GET['eng']; $lang='eng'; } else { $eng = 0; $lang = 'ind'; }
if(isset($_GET['acc'])) {
$ACCESSNUMBER = $_GET['acc'];
} else {
$file = $argv[1];
$x = explode('\\',$file);
$x = $x[1];
$x = explode('_',$x);
$ACCESSNUMBER = $x[0];
$lang = $x[1];
if($lang=='eng') {$eng=1;}
}
include("config.php");
include("_function.php");
$raw = "<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />";
$pdf = $raw + "<link rel='stylesheet' href='http://glenlis/spooler_db/normalize.min.css' />
<link rel='stylesheet' href='http://glenlis/spooler_db/pdf.css' />";
$raw.= "<link rel='stylesheet' href='/spooler_db/normalize.min.css' /> <link rel='stylesheet' href='/spooler_db/style.css' />"; }
$raw .= "</head>
<body style='-webkit-print-color-adjust:exact;'>";
$pdf .= "</head>
<body style='-webkit-print-color-adjust:exact;'>";
$HOSTNUMBER = getHost($conn, $ACCESSNUMBER);
$result = getResult($conn, $ACCESSNUMBER,$eng);
$info = getData2($conn,$ACCESSNUMBER);
$notes = getNotes($conn, $ACCESSNUMBER);
$collData = getCollData($conn, $ACCESSNUMBER);
$recvData = getRecvData($conn, $ACCESSNUMBER);
$noSample = getNoSample($conn,$ACCESSNUMBER);
if( $noSample == '' ) {
$status = getStatus($conn, $ACCESSNUMBER);
} else {
$status = "PENDING";
}
$valBy = getValBy($conn, $ACCESSNUMBER);
if(!isset($_GET['date'])) { $date = date('d-m-Y H:i'); }
else { $date = $_GET['date']; }
$npage = count($result);
$i=1;
foreach($result as $page) {
$raw .= "<div id='page'>
<div id=pagetop style='height:0.01cm'> </div>";
$pdf .= "<div id='page'>
<div id=pagetop style='height:0.01cm'> </div>
<img src='http://glenlis/spooler_db/gleneagleshdr.png' class='img'/>";
if($preview==1) { $raw.= "<div style='font-size:30px'>preview only do not print</div>" ; }
$raw .= "<div id='dinfo'>
$info
</div>
<div id='dresult'>
<table class='result'>
<colgroup>
<col style='width:26%;'></col>
<col style='width:10%;'></col>
<col style='width:15%;'></col>
<col style='width:12%;'></col>
<col style='width:10%;'></col>
<col style='width:15%;'></col>
<col style='width:12%;'></col>
</colgroup>
<tr> <th rowspan='2' style='border-right:solid 1px black; border-bottom:solid 1px black;'>TEST</th>
<th colspan='3' style='border-right:solid 1px black;'>CONVENTIONAL</th> <th colspan='3'>INTERNATIONAL</th> </tr>
<tr style='border-bottom:solid 1px black;'> <th>RESULT</th> <th>REF. RANGES</th> <th style='border-right:solid 1px black;'>UNIT</th> <th>RESULT</th> <th>REF. RANGES</th> <th>UNIT</th> </tr>
$page
";
$pdf .= "<div id='dinfo'>
$info
</div>
<div id='dresult'>
<table class='result'>
<colgroup>
<col style='width:26%;'></col>
<col style='width:10%;'></col>
<col style='width:15%;'></col>
<col style='width:12%;'></col>
<col style='width:10%;'></col>
<col style='width:15%;'></col>
<col style='width:12%;'></col>
</colgroup>
<tr> <th rowspan='2' style='border-right:solid 1px black; border-bottom:solid 1px black;'>TEST</th>
<th colspan='3' style='border-right:solid 1px black;'>CONVENTIONAL</th> <th colspan='3'>INTERNATIONAL</th> </tr>
<tr style='border-bottom:solid 1px black;'> <th>RESULT</th> <th>REF. RANGES</th> <th style='border-right:solid 1px black;'>UNIT</th> <th>RESULT</th> <th>REF. RANGES</th> <th>UNIT</th> </tr>
$page
";
// lastpage show note
if($i != $npage) {
$raw.="</table>";
$pdf.="</table>";
} else {
$raw .= "$noSample</table>
<table> <tr><td>Note :</td> <td><pre>$notes</pre></td></tr>
</table>";
$pdf .= "$noSample</table>
<table> <tr><td>Note :</td> <td><pre>$notes</pre></td></tr>
</table>";
}
$raw .= "</div>";
$raw .= "<div id='footer'>
<table class='footer'>
<tr> <td>";
if($i == $npage) { $raw .= "Status : $status"; }
$raw .= "<pre class='small'>Collected on $collData
Received on $recvData</pre>
Page $i/$npage Printed By : $valBy $date </td>";
if($pdf!=1) {
$raw .="
<td class='right'><pre>
(__________________)
Authorised Signature
</pre></td>";
} else {
$raw.="<td class='right'><pre><b>&rdquo;This result is valid without signature.&rdquo;</b></pre></td>";
}
$raw .="
</tr>
</table>
</div>
";
if($pdf==1) { $raw .="<img src='http://glenlis/spooler_db/gleneaglesftr.png' class='img'/>"; }
$raw .= "</div>";
$i+=1;
}
$raw .="</body>";
echo $raw;
if($pdf == 1) {
$file = fopen("process_pdf/$HOSTNUMBER.html","w");
fwrite($file, $raw);
fclose($file);
}
if(isset($_GET['print'])) {
$file = fopen("process_oru/$ACCESSNUMBER.oru","w+");
$date = date('Y-m-d H:i');
fwrite($file, "$ACCESSNUMBER\r\n$HOSTNUMBER\r\n$date\r\n$status\r\n$lang");
fclose($file);
}
?>

View File

@ -1,103 +0,0 @@
<?php
$ACCESSNUMBER = $_GET['acc'];
if(isset($_GET['pdf'])) { $pdf = $_GET['pdf']; } else { $pdf=0; }
if(isset($_GET['preview'])) { $preview = $_GET['preview']; } else { $preview=0; }
if(isset($_GET['eng'])) { $eng = $_GET['eng']; } else { $eng = 0;}
include("config.php");
include("_function.php");
$raw = "<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />";
if($pdf==0) { $raw.= "<link rel='stylesheet' href='/spooler_db/normalize.min.css' /> <link rel='stylesheet' href='/spooler_db/style.css' />"; }
else {
$raw .= "<link rel='stylesheet' href='http://glenlis/spooler_db/normalize.min.css' />
<link rel='stylesheet' href='http://glenlis/spooler_db/pdf.css' />";
}
$raw .= "</head>
<body>";
$HOSTNUMBER = getHost($conn, $ACCESSNUMBER);
$result = getResultDebug($conn, $ACCESSNUMBER,$eng);
$info = getData2($conn,$ACCESSNUMBER);
$notes = getNotes($conn, $ACCESSNUMBER);
$collData = getCollData($conn, $ACCESSNUMBER);
$recvData = getRecvData($conn, $ACCESSNUMBER);
$noSample = getNoSample($conn,$ACCESSNUMBER);
if( $noSample == '' ) {
$status = getStatus($conn, $ACCESSNUMBER);
} else {
$status = "PENDING";
}
$valBy = getValBy($conn, $ACCESSNUMBER);
$date = date('d-m-Y H:i');
$npage = count($result);
$i=1;
foreach($result as $page) {
$raw .= "<div id='page'>
<div id=pagetop style='height:0.01cm'> </div>";
if($preview==1) { $raw.= "<div style='font-size:30px'>preview only do not print</div>" ; }
if($pdf==1) { $raw .= "<img src='http://glenlis/spooler_db/gleneagleshdr.png' class='img'/>"; }
$raw .= "<div id='dinfo'>
$info
</div>
<div id='dresult'>
<table class='result'>
<colgroup>
<col style='width:26%;'></col>
<col style='width:10%;'></col>
<col style='width:15%;'></col>
<col style='width:12%;'></col>
<col style='width:10%;'></col>
<col style='width:15%;'></col>
<col style='width:12%;'></col>
</colgroup>
<tr> <th rowspan='2' style='border-right:solid 1px black; border-bottom:solid 1px black;'>TEST</th>
<th colspan='3' style='border-right:solid 1px black;'>CONVENTIONAL</th> <th colspan='3'>INTERNATIONAL</th> </tr>
<tr style='border-bottom:solid 1px black;'> <th>RESULT</th> <th>REF. RANGES</th> <th style='border-right:solid 1px black;'>UNIT</th> <th>RESULT</th> <th>REF. RANGES</th> <th>UNIT</th> </tr>
$page
";
// lastpage show note
if($i != $npage) {
$raw.="</table>";
} else {
$raw .= "$noSample</table>
<table> <tr><td>Note :</td> <td><pre>$notes</pre></td></tr>
</table>";
}
$raw .= "</div>";
$raw .= "<div id='footer'>
<table class='footer'>
<tr> <td>";
if($i == $npage) { $raw .= "Status : $status"; }
$raw .= "<pre class='small'>Collected on $collData
Received on $recvData</pre>
Page $i/$npage Printed By : $valBy $date </td>";
if($pdf!=1) {
$raw .="
<td class='right'><pre>
(__________________)
Authorised Signature
</pre></td>";
} else {
$raw.="<td class='right'><pre><b>&rdquo;This result is valid without signature.&rdquo;</b></pre></td>";
}
$raw .="
</tr>
</table>
</div>
";
//echo "<img src='gleneaglesftr.png' class='footer-img'/>";
if($pdf==1) { $raw .="<img src='http://glenlis/spooler_db/gleneaglesftr.png' class='img'/>"; }
$raw .= "</div>";
$i+=1;
}
$raw .="</body>";
echo $raw;
?>

View File

@ -1,241 +0,0 @@
function getResultDebug($conn, $ACCESSNUMBER, $eng) {
include("_inc.php");
$sql = "SELECT DC.FULLTEXT, DT.TESTCODE, T.VALIDATIONSTATUS,
RESULT = CASE
WHEN T.RESTYPE=0 THEN 'Pending'
WHEN T.RESTYPE=4 AND T.RESVALUE='' AND T.RESSTATUS=1 THEN '.' -- null -> .
WHEN T.RESTYPE IN (7,15,4) THEN T.RESVALUE
WHEN T.RESTYPE=9 THEN +'< '+T.RESVALUE
WHEN T.RESTYPE=10 THEN +'> '+T.RESVALUE
WHEN T.RESVALUE IS NULL THEN
CASE
WHEN T.CODEDRESULTID IS NULL AND DT.TESTTYPE IN (4,5) THEN null
WHEN T.CODEDRESULTID IS NULL THEN TC.COMMENTTEXT
WHEN T.CODEDRESULTID IS NOT NULL AND T.RESTYPE=6 AND SUBSTRING(DX.FULLTEXT,1,3) NOT LIKE '%#%' THEN DX.FULLTEXT
END
ELSE T.RESVALUE
END,
T.MINIMUM, T.MAXIMUM,
DT.FULLTEXT,
DT.RESPRECISION,DT.RESPRECISION2, DT.OPERAND, DT.SOFTCONVERSION, DT.UNITS, DT.UNITS2, T.RESTYPE, VI.FULLTEXT,
case
when TC.COMMENTTEXT is null then DX2.FULLTEXT
else TC.COMMENTTEXT
end, T.RERUN
FROM TESTS T
JOIN DICT_TESTS DT ON DT.TESTID=T.TESTID
LEFT JOIN DICT_TEXTS DX ON DX.TEXTID=T.CODEDRESULTID
LEFT JOIN TESTS_COMMENTS TC ON TC.REQTESTID=T.REQTESTID
LEFT JOIN DICT_TEXTS DX2 ON DX2.TEXTID=TC.COMMENTCODEDID
LEFT JOIN REQUESTS R ON R.REQUESTID=T.REQUESTID
LEFT JOIN DICT_CHAPTERS DC ON DC.CHAPID=T.CHAPID
LEFT JOIN GDC_CMOD.dbo.V_INTER2 VI ON VI.ATR_ACCESSNUMBER=R.ACCESSNUMBER AND DT.TESTCODE=VI.ATR_TESTCODE
WHERE R.ACCESSNUMBER='$ACCESSNUMBER' AND T.NOTPRINTABLE IS NULL AND DT.TESTCODE<>'STATS'
ORDER BY T.TESTORDER";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$CHAP = "";
$i = 0;
$page = 1;
$line = 0;
$lpp = 34; // line per page
$done[1]= "";
$nline = 0;
$RERUN=1;
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC)) {
$CHAPTER = $row[0];
$TESTCODE = $row[1];
$VALIDATIONSTATUS = $row[2];
$R1 = $row[3];
if($R1=='****') {$R1='-';}
$L1 = $row[4];
$H1 = $row[5];
$FULLTEXT = $row[6];
$PRECISION1 = $row[7];
$PRECISION2 = $row[8];
$OPERAND = $row[9];// 3* 4/
$SOFTCONVERSION =$row[10];
$U1 = $row[11];
$U2 = $row[12];
$RESTYPE = $row[13];
$I = $row[14];
$RESCOM = $row[15];
// Get ITEXT or ETEXT
if($eng==1) {
$ICHAPTER = substr($CHAPTER, strpos($CHAPTER,'#E')+2, strrpos($CHAPTER,'#E')-strpos($CHAPTER,'#E')-2 );
if($ICHAPTER != $CHAP) {
$raw[$i] = " <tr><td colspan='7'><pre>$ICHAPTER</pre></td> </tr>\r\n";
$nline += 1;
}
$CHAP = $ICHAPTER;
$ITEXT = substr($FULLTEXT, strpos($FULLTEXT,'#E')+2, strrpos($FULLTEXT,'#E')-strpos($FULLTEXT,'#E')-2 );
} else {
$ICHAPTER = substr($CHAPTER,2, strrpos($CHAPTER,'#I')-2 );
if($ICHAPTER != $CHAP) {
$raw[$i] = " <tr><td colspan='7'><pre>$ICHAPTER</pre></td> </tr>\r\n";
$nline += 1;
}
$CHAP = $ICHAPTER;
$ITEXT = substr($FULLTEXT,2, strrpos($FULLTEXT,'#I')-2 );
}
// GRP | ELE
if($TESTCODE=='PCRN') { $raw[$i] .= " <tr> <td></td> <td colspan='6'><br/><pre>$ITEXT</pre></td></tr>"; $done[$page] .= $raw[$i]; }
elseif(!is_numeric($RESTYPE)) {
// ch
if( array_key_exists( $TESTCODE, $_chinese) ) { $ITEXT = rtrim($ITEXT)." <span class='textC'>".$_chinese[$TESTCODE].'</span>'; }
if($ITEXT!='') {
$ITEXT = " <tr> <td colspan='7'><pre>$ITEXT</pre></td> </tr>\r\n";
$nline += 1;
$raw[$i] .= $ITEXT;
}
$RERUN = $row[16];
} else {
//flagging
if( substr($R1,0,2)=='< ' && is_numeric(substr($R1,2,strlen($R1))) ) { $r1 = substr($R1,2,strlen($R1)); $r1-=1;}
elseif( substr($R1,0,2)=='> ' && is_numeric(substr($R1,2,strlen($R1))) ) { $r1 = substr($R1,2,strlen($R1)); $r1+=1;}
else {$r1 = $R1;}
if($r1 < $L1 && is_numeric($r1) && is_numeric($L1)) {$F = "*L";}
elseif($r1 > $H1 && is_numeric($r1) && is_numeric($H1)) {$F = "*H";}
else {$F="";}
//echo "$R1<br/>";
//get R2 L2 H2
if($RESTYPE == 0) { $R2=""; $L1=""; $H1=""; $L2=""; $H2=""; }
else {
if( in_array($RESTYPE,[7,15,4]) && $OPERAND == 3 ) {
if(is_numeric($R1)) { $R2 = NUMBER_FORMAT($R1 * $SOFTCONVERSION, $PRECISION2,'.',''); }
else {$R2 = 0;}
if($L1 != 0) { $L2 = NUMBER_FORMAT($L1 * $SOFTCONVERSION, $PRECISION2); }
else {$L2 = 0;}
if($H1 != 0) { $H2 = NUMBER_FORMAT($H1 * $SOFTCONVERSION, $PRECISION2); }
else {$H2 = 0;}
} elseif( in_array($RESTYPE,[7,15,4]) && $OPERAND == 4 ) {
IF(is_numeric($R1)) { $R2 = NUMBER_FORMAT($R1 / $SOFTCONVERSION, $PRECISION2); }
ELSE {$R2 = 0;}
IF($L1 != 0) { $L2 = NUMBER_FORMAT($L1 / $SOFTCONVERSION, $PRECISION2); }
ELSE {$L2 = 0;}
IF($H1 != 0) { $H2 = NUMBER_FORMAT($H1 / $SOFTCONVERSION, $PRECISION2); }
ELSE {$H2 = 0;}
} else { $R2=$R1; $L2=$L1; $H2=$H1; }
}
//precision1
if(is_numeric($R1) && is_numeric($PRECISION1)) { $R1 = NUMBER_FORMAT($R1,$PRECISION1,'.',''); }
// split in half - multi line
// text | result
$TEXT = explode("\r\n",$ITEXT);
$test = array();
$res = array();
foreach($TEXT as $text) {
$test[]= substr($text,0,33);
$res[]= substr($text,33,strlen($text));
}
$space = ( strlen($test[0])-strlen(ltrim($test[0])) ) * 7;
$test = rtrim(implode("\r\n",$test));
$res = implode("\r\n",$res);
// italic
if( in_array( $TESTCODE, $_italic) ) { $test ="<i>$test</i>"; }
// ch
if( array_key_exists( $TESTCODE, $_chinese) ) { $test.=" <span class='textC'>".$_chinese[$TESTCODE].'</span>'; }
//line count
$tline = count( explode(PHP_EOL, $test) );
$rline = count( explode(PHP_EOL, $res) );
$r1line = count( explode(PHP_EOL, $R1) );
if($rline < $r1line) { $rline = $r1line; }
if ($test == ' Note') {
$ITEXT = " <tr> <td style='padding-left:".$space."px'><br/>$test</td> <td colspan='6'><br/><pre>$res </pre></td> </tr>\r\n";
} elseif ( strlen($RESCOM) < 2 ) {
$ITEXT = " <tr> <td style='padding-left:".$space."px'>$test</td> <td colspan='6'><pre>$res </pre></td> </tr>\r\n";
} else {
$rline += count( explode(PHP_EOL, $RESCOM) );
$res = rtrim($res);
$ITEXT = " <tr> <td style='padding-left:".$space."px'>$test</td> <td colspan='6'><pre>$res \r\n$RESCOM</pre></td> </tr>\r\n ";
}
if($tline > $rline) { $nline += $tline; } else { $nline += $rline; }
/*
## replace {R1 {L1 {H1 {R2 {L2 {H2 {I ##
GET STRING POS
DELETE ALL STRING
{R1,{R2,{I,{L1,{H1,{L2,{H2 // ORDER
GET NEW STRING LENGTH
*/
// Get all string pos
$posR1 = strpos($ITEXT, "{R1");
$posR12 = strrpos($ITEXT, "{R1");
$posR2 = strpos($ITEXT, "{R2");
$posR22 = strrpos($ITEXT, "{R2");
$posI1 = strpos($ITEXT, "{I");
$posI2 = strrpos($ITEXT, "{I");
$posL1 = strpos($ITEXT, "{L1");
$posH1 = strpos($ITEXT, "{H1");
$posL2 = strpos($ITEXT, "{L2");
$posH2 = strpos($ITEXT, "{H2");
$posU1 = strpos($ITEXT, "{U1");
$posU2 = strpos($ITEXT, "{U2");
#echo "<pre>$ITEXT</pre>\r\n";
// Delete all string
$ITEXT = str_replace( "{R1", " ", $ITEXT );
$ITEXT = str_replace( "{R2", " ", $ITEXT );
$ITEXT = str_replace( "{I", " ", $ITEXT );
$ITEXT = str_replace( "{L1", " ", $ITEXT );
$ITEXT = str_replace( "{H1", " ", $ITEXT );
$ITEXT = str_replace( "{L2", " ", $ITEXT );
$ITEXT = str_replace( "{H2", " ", $ITEXT );
$ITEXT = str_replace( "{U1", " ", $ITEXT );
$ITEXT = str_replace( "{U2", " ", $ITEXT );
// REPLACE
if(in_array($RESTYPE, [4,6,7,9,10,15])) {
$ITEXT = f_repl($ITEXT,$R1.' '.$F,$posR1);
if($posR1 != $posR12) { $ITEXT = f_repl($ITEXT,$R1.' '.$F,$posR12); }
$ITEXT = f_repl($ITEXT,$L1,$posL1);
$ITEXT = f_repl($ITEXT,$H1,$posH1);
if(isset($R2)) {
$ITEXT = f_repl($ITEXT,$R2.' '.$F,$posR2);
if($posR2 != $posR22) { $ITEXT = f_repl($ITEXT,$R2.' '.$F,$posR22); }
}
if(isset($L2)) { $ITEXT = f_repl($ITEXT,$L2,$posL2); }
if(isset($H2)) { $ITEXT = f_repl($ITEXT,$H2,$posH2); }
if($I == 'Negative') {
$I1 = "Negatif";
$I2 = "Negative";
$ITEXT = f_repl($ITEXT,$I1,$posI1);
$ITEXT = f_repl($ITEXT,$I2,$posI2);
} else {
$ITEXT = f_repl($ITEXT,$I,$posI1);
$ITEXT = f_repl($ITEXT,$I,$posI2);
}
$ITEXT = f_repl($ITEXT,$U1,$posU1);
$ITEXT = f_repl($ITEXT,$U2,$posU2);
} elseif(in_array($RESTYPE,[0,5])) {
if(strlen($RESCOM) < 2) {
$ITEXT = substr($ITEXT, 0, $posR1); $ITEXT .= $R1."</pre></td> </tr>";
} else {
$ITEXT = substr($ITEXT, 0, $posR1); $ITEXT .= "$R1 \r\n$RESCOM</pre></td> </tr>";
}
}
// bold flag
//$ITEXT = str_replace('*L', '<b>*L</b>', $ITEXT);
//$ITEXT = str_replace('*H', '<b>*H</b>', $ITEXT);
$raw[$i] .= $ITEXT;
$line += $nline;
if($TESTCODE != 'COVGG') {
if($line > $lpp) {$page++; $done[$page] = ""; $line = $nline; }
} else {
if($line > $lpp-14) {$page++; $done[$page] = ""; $line = $nline; }
}
if($line > $lpp) {$page++; $done[$page] = ""; $line = $nline; }
$done[$page] .= $raw[$i];
$i++;
$raw[$i] = "";
$nline = 0;
}
}
return $done;
}

View File

@ -1,21 +0,0 @@
<?php
include("config.php");
$d1 = '2024-09-14'; $d2 = '2024-09-14';
$sql = "select SP_ACCESSNUMBER, HOSTORDERNUMBER, STATS from GDC_CMOD.dbo.V_DASHBOARD where
COLLECTIONDATE between '2024-09-14 00:00' and '2024-09-14 23:59'
and ODR_DDATE between '2024-09-14 00:00' and '2024-09-14 23:59'
and STATS='Comp'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC) ) {
$ACCESSNUMBER = $row['SP_ACCESSNUMBER'];
$HOSTNUMBER = $row['HOSTORDERNUMBER'];
$status = $row['STATS'];
//oru
$file = fopen("process_oru/$ACCESSNUMBER.oru","w+");
$date = date('Y-m-d H:i');
fwrite($file, "$ACCESSNUMBER\r\n$HOSTNUMBER\r\n$date\r\n$status\r\n-");
fclose($file);
}
?>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 222 KiB

View File

@ -1,124 +0,0 @@
<?php
if(isset($_GET['acc'])) {
$ACCESSNUMBER = $_GET['acc'];
$pdf = 0;
if(isset($_GET['pdf'])) { $pdf = $_GET['pdf']; }
} else {
$file = $argv[1] ;
$filename = explode('\\',$file);
$filename = $filename[1];
$ACCESSNUMBER = $filename;
$pdf = 1;
}
if(isset($_GET['eng'])) { $eng = 1; } else { $eng = 0;}
include("config.php");
include("_function.php");
$raw = "<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />";
if($pdf==0) { $raw.= "<link rel='stylesheet' href='/spooler_db/normalize.min.css' /> <link rel='stylesheet' href='/spooler_db/style.css' />"; }
else { $raw .= "<link rel='stylesheet' href='../normalize.min.css' /> <link rel='stylesheet' href='../pdf.css' />"; }
$raw .= "</head>
<body style='-webkit-print-color-adjust: exact;'>";
$HOSTNUMBER = getHost($conn, $ACCESSNUMBER);
$result = getResult($conn, $ACCESSNUMBER,$eng);
$info = getData2($conn,$ACCESSNUMBER);
$notes = getNotes($conn, $ACCESSNUMBER);
$collData = getCollData($conn, $ACCESSNUMBER);
$recvData = getRecvData($conn, $ACCESSNUMBER);
$noSample = getNoSample($conn,$ACCESSNUMBER);
if( $noSample == '' ) {
$status = getStatus($conn, $ACCESSNUMBER);
} else {
$status = "PENDING";
}
$valBy = getValBy($conn, $ACCESSNUMBER);
$date = date('d-m-Y H:i');
$npage = count($result);
$i=1;
foreach($result as $page) {
$raw .= "<div id='page'>
<div id=pagetop style='height:0.01cm'> </div>";
if($pdf==1) { $raw .= "<img src='../gleneagleshdr.png' class='img'/>"; }
$raw .= "<div id='dinfo'>
$info
</div>
<div id='dresult'>
<table class='result'>
<colgroup>
<col style='width:26%;'></col>
<col style='width:10%;'></col>
<col style='width:15%;'></col>
<col style='width:12%;'></col>
<col style='width:10%;'></col>
<col style='width:15%;'></col>
<col style='width:12%;'></col>
</colgroup>
<tr> <th rowspan='2' style='border-right:solid 1px black; border-bottom:solid 1px black;'>TEST</th>
<th colspan='3' style='border-right:solid 1px black;'>CONVENTIONAL</th> <th colspan='3'>INTERNATIONAL</th> </tr>
<tr style='border-bottom:solid 1px black;'> <th>RESULT</th> <th>REF. RANGES</th> <th style='border-right:solid 1px black;'>UNIT</th> <th>RESULT</th> <th>REF. RANGES</th> <th>UNIT</th> </tr>
$page
";
// lastpage show note
if($i != $npage) {
$raw.="</table>";
} else {
$raw .= "$noSample</table>
<table> <tr><td>Note :</td> <td><pre>$notes</pre></td></tr>
</table>";
}
$raw .= "</div>";
$raw .= "<div id='footer'>
<table class='footer'>
<tr> <td>";
if($i == $npage) { $raw .= "Status : $status"; }
$raw .= "<pre class='small'>Collected on $collData
Received on $recvData</pre>
Page $i/$npage Printed By : $valBy $date </td>";
if($pdf!=1) {
$raw .="
<td class='right'><pre>
(__________________)
Authorised Signature
</pre></td>";
} else {
$raw.="<td class='right'><pre><b>&rdquo;This result is valid without signature.&rdquo;</b></pre></td>";
}
$raw .="
</tr>
</table>
</div>
";
//echo "<img src='gleneaglesftr.png' class='footer-img'/>";
if($pdf==1) { $raw .="<img src='../gleneaglesftr.png' class='img'/>"; }
$raw .= "</div>";
$i+=1;
}
$raw .="</body>";
//echo $raw;
if($pdf == 0) { echo $raw; }
else {
if(!isset($_GET['dl'])) {
$file = fopen("process_pdf/$HOSTNUMBER.html","w");
fwrite($file, $raw);
fclose($file);
$Ym = date('Ym');
$now = date("YmdHms");
$dirname = "archive/".$Ym."/";
// $dirname = dirname($dirname);
if (!is_dir($dirname)) { mkdir($dirname, 0755, true); }
$file = fopen($dirname.$HOSTNUMBER."_".$now.".html","w+");
fwrite($file, $raw);
fclose($file);
} else { echo $raw; }
}
?>

View File

@ -1,214 +0,0 @@
<?php
if(isset($_GET['preview'])) { $preview = $_GET['preview']; } else { $preview=0; }
if(isset($_GET['eng'])) { $eng = $_GET['eng']; $lang='eng'; } else { $eng = 0; $lang = 'ind'; }
if(isset($_GET['acc'])) { $ACCESSNUMBER = $_GET['acc']; }
include("config.php");
include("_function.php");
$HOSTNUMBER = getHost($conn, $ACCESSNUMBER);
$result = getResult($conn, $ACCESSNUMBER,$eng);
$info = getData2($conn,$ACCESSNUMBER);
$notes = getNotes($conn, $ACCESSNUMBER);
$others = getOthers($conn,$ACCESSNUMBER, $eng);
$collData = getCollData($conn, $ACCESSNUMBER);
$recvData = getRecvData($conn, $ACCESSNUMBER);
$noSample = getNoSample($conn,$ACCESSNUMBER);
if( $noSample == '' ) {
$status = getStatus($conn, $ACCESSNUMBER);
} else {
$status = "PENDING";
}
//if($ACCESSNUMBER != '3121849766') {$status = "FINAL";}
if($preview == 0) {
$sql = "INSERT INTO GDC_CMOD.dbo.AUDIT_REQUESTS(ACCESSNUMBER, STEPDATE, STEPTYPE, STEPSTATUS)
VALUES('$ACCESSNUMBER', GETDATE(), 'PRINT', '$status')";
$stmt = sqlsrv_query($conn,$sql);
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
}
$valBy = getValBy($conn, $ACCESSNUMBER);
if(!isset($_GET['date'])) { $date = date('d-m-Y H:i'); }
else { $date = $_GET['date']; }
$npage = count($result);
$i=1;
$raw ='';
$pdf ='';
$tmp = "<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<link rel='stylesheet' href='assets/normalize.min.css' />";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$raw .= "\r\n<link rel='stylesheet' href='assets/style.css' />";
$pdf .= "\r\n<link rel='stylesheet' href='assets/pdf.css' />";
$tmp = "</head>
<body style='-webkit-print-color-adjust:exact;'>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
if($eng==1) { $othertitle = "Non Laboratory Test"; }
else { $othertitle = "Pemeriksaan Non Laboratorium"; }
$countpage = substr_count($result[$npage],"\r");
$countothers = substr_count("$others","\r");
$countline = $countpage + $countothers;
$pageadd = 0;
if($countline > 37) {
$npage += 1;
$pageadd = 1;
}
foreach($result as $page) {
$tmp .= "<div id='page'>
<div id='pagetop' style='height:0.01cm'> </div>";
if($preview==1) { $tmp.= "<div style='font-size:30px'>preview only do not print</div>" ; }
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .= "<img src='assets/gleneagleshdr.png' class='img'/>";
$tmp .= "<div id='dinfo'>
$info
</div>
<div id='dresult'>
<table class='result'>
<colgroup>
<col style='width:26%;'></col>
<col style='width:10%;'></col>
<col style='width:15%;'></col>
<col style='width:12%;'></col>
<col style='width:10%;'></col>
<col style='width:15%;'></col>
<col style='width:12%;'></col>
</colgroup>
<tr> <th rowspan='2' style='border-right:solid 1px black; border-bottom:solid 1px black;'>TEST</th>
<th colspan='3' style='border-right:solid 1px black;'>CONVENTIONAL</th> <th colspan='3'>INTERNATIONAL</th> </tr>
<tr style='border-bottom:solid 1px black;'> <th>RESULT</th> <th>REF. RANGES</th> <th style='border-right:solid 1px black;'>UNIT</th> <th>RESULT</th> <th>REF. RANGES</th> <th>UNIT</th> </tr>
$page
";
// lastpage show nosample, others and note
if($pageadd !=1) {
if( $i != $npage ) {
$tmp .="</table>";
} else {
$tmp .= "$noSample </table>";
$tmp .= "<table> <tr><td>Note :</td> <td><pre>$notes</pre></td></tr>
</table> <br/>\r\n";
if($others != '' && $countline < 38) {
$tmp .= "<table><tr><td><b>$othertitle :</b><br/>\r\n";
$tmp .= "$others</td></tr></table>";
$others = '';
}
}
} else { // page tambahan = 1
if( $i != $npage-1 ) {
$tmp .="</table>";
} else {
$tmp .= "$noSample </table>";
$tmp .= "<table> <tr><td>Note :</td> <td><pre>$notes</pre></td></tr>
</table> <br/>\r\n";
}
}
$tmp .= "</div>";
$tmp .= "<div id='footer'>
<table class='footer'>
<tr> <td>";
if($i == $npage) { $tmp .= "Status : $status"; }
$tmp .= "<pre class='small'>Collected on $collData\r\nReceived on $recvData</pre>
Page $i/$npage Printed By : $valBy $date </td>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$tmp .="
<td class='right'><pre>
(__________________)
Authorised Signature
</pre></td>";
$raw .= $tmp; $tmp = '';
$pdf .= "<td class='right'><pre><b>&rdquo;This result is valid without signature.&rdquo;</b></pre></td>";
$tmp .="
</tr>
</table>
</div>
";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .="<img src='assets/gleneaglesftr.png' class='img img-footer'/>";
$tmp .= "</div>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$i+=1;
}
if($others != '') {
$tmp .= "
<div id='page'>
<div id='pagetop' style='height:0.01cm'> </div>";
if($preview==1) { $tmp.= "<div style='font-size:30px'>preview only do not print</div>" ; }
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .= "<img src='assets/gleneagleshdr.png' class='img'/>";
$tmp .= "<div id='dinfo'>
$info
</div>
<div id='dresult'>
<table class='others' style='width:15cm'>
<tr><td><b>$othertitle : </b><br/>\r\n
$others</td></tr></table>
</div>
";
$tmp .= "<div id='footer'>
<table class='footer'>
<tr> <td>";
if($i == $npage) { $tmp .= "Status : $status"; }
$tmp .= "<pre class='small'>Collected on $collData\r\nReceived on $recvData</pre>
Page $i/$npage Printed By : $valBy $date </td>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$tmp .="
<td class='right'><pre>
(__________________)
Authorised Signature
</pre></td>";
$raw .= $tmp; $tmp = '';
$pdf .= "<td class='right'><pre><b>&rdquo;This result is valid without signature.&rdquo;</b></pre></td>";
$tmp .="
</tr>
</table>
</div>
";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .="<br/><img src='assets/gleneaglesftr.png' class='img img-footer'/>";
$tmp .= "</div>";
}
$tmp .="</body>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
echo $raw;
if($preview != 1) {
//pdf
$file = fopen("process_pdf/$HOSTNUMBER.html","w+");
fwrite($file, $pdf);
fclose($file);
//archive
/*
$date = date('YmdHi');
*/
$folder = date('Ym');
$date = date('YmdHi');
//$file = fopen("archive/$date"."_$HOSTNUMBER.html","w+");
$filename = "archive/$folder/$date"."_$HOSTNUMBER.html";
$dirname = dirname($filename);
if (!is_dir($dirname)) { mkdir($dirname, 0777, true); }
$file = fopen("archive/$folder/$date"."_$HOSTNUMBER.html","w+");
fwrite($file, $pdf);
fclose($file);
//oru
$file = fopen("process_oru/$ACCESSNUMBER.oru","w+");
$date = date('Y-m-d H:i');
fwrite($file, "$ACCESSNUMBER\r\n$HOSTNUMBER\r\n$date\r\n$status");
fclose($file);
}
?>

View File

@ -1,229 +0,0 @@
<?php
if(isset($_GET['preview'])) { $preview = $_GET['preview']; } else { $preview=0; }
if(isset($_GET['eng'])) { $eng = $_GET['eng']; $lang='eng'; } else { $eng = 0; $lang = 'ind'; }
if(isset($_GET['acc'])) { $ACCESSNUMBER = $_GET['acc']; }
include("config.php");
include("_function.php");
function cutData($text) {
//$text .= strlen($text);
if( strlen($text) > 95 ) {
$split_text = explode(" ", $text);
$cut_length = 11;
$split_text_cut1 = array_slice($split_text, 0, $cut_length);
$split_text_cut2 = array_slice($split_text, $cut_length, count($split_text));
$text1 = implode(" ", $split_text_cut1);
$text2 = implode(" ", $split_text_cut2);
$text = $text1."\r\n".$text2;
}
return($text);
}
$HOSTNUMBER = getHost($conn, $ACCESSNUMBER);
$result = getResult($conn, $ACCESSNUMBER,$eng);
$info = getData2($conn,$ACCESSNUMBER);
$notes = getNotes($conn, $ACCESSNUMBER);
$others = getOthers($conn,$ACCESSNUMBER, $eng);
$collData = getCollData($conn, $ACCESSNUMBER);
$recvData = getRecvData($conn, $ACCESSNUMBER);
$collData = cutData($collData);
$recvData = cutData($recvData);
$noSample = getNoSample($conn,$ACCESSNUMBER);
if( $noSample == '' ) {
$status = getStatus($conn, $ACCESSNUMBER);
} else {
$status = "PENDING";
}
//if($ACCESSNUMBER != '3121849766') {$status = "FINAL";}
if($preview == 0) {
$sql = "INSERT INTO GDC_CMOD.dbo.AUDIT_REQUESTS(ACCESSNUMBER, STEPDATE, STEPTYPE, STEPSTATUS)
VALUES('$ACCESSNUMBER', GETDATE(), 'PRINT', '$status')";
$stmt = sqlsrv_query($conn,$sql);
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
}
$valBy = getValBy($conn, $ACCESSNUMBER);
if(!isset($_GET['date'])) { $date = date('d-m-Y H:i'); }
else { $date = $_GET['date']; }
$npage = count($result);
$i=1;
$raw ='';
$pdf ='';
$tmp = "<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<link rel='stylesheet' href='assets/normalize.min.css' />";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$raw .= "\r\n<link rel='stylesheet' href='assets/style.css' />";
$pdf .= "\r\n<link rel='stylesheet' href='assets/pdf.css' />";
$tmp = "</head>
<body style='-webkit-print-color-adjust:exact;'>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
if($eng==1) { $othertitle = "Non Laboratory Test"; }
else { $othertitle = "Pemeriksaan Non Laboratorium"; }
$countpage = substr_count($result[$npage],"\r");
$countothers = substr_count("$others","\r");
$countline = $countpage + $countothers;
$pageadd = 0;
if($countline > 39) {
$npage += 1;
$pageadd = 1;
}
foreach($result as $page) {
$tmp .= "<div id='page'>
<div id='pagetop' style='height:0.01cm'> </div>";
if($preview==1) { $tmp.= "<div style='font-size:30px'>preview only do not print</div>" ; }
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .= "<img src='assets/gleneagleshdr.png' class='img'/>";
$tmp .= "<div id='dinfo'>
$info
</div>
<div id='dresult'>
<table class='result'>
<colgroup>
<col style='width:26%;'></col>
<col style='width:10%;'></col>
<col style='width:15%;'></col>
<col style='width:12%;'></col>
<col style='width:10%;'></col>
<col style='width:15%;'></col>
<col style='width:12%;'></col>
</colgroup>
<tr> <th rowspan='2' style='border-right:solid 1px black; border-bottom:solid 1px black;'>TEST</th>
<th colspan='3' style='border-right:solid 1px black;'>CONVENTIONAL</th> <th colspan='3'>INTERNATIONAL</th> </tr>
<tr style='border-bottom:solid 1px black;'> <th>RESULT</th> <th>REF. RANGES</th> <th style='border-right:solid 1px black;'>UNIT</th> <th>RESULT</th> <th>REF. RANGES</th> <th>UNIT</th> </tr>
$page
";
// lastpage show nosample, others and note
if($pageadd !=1) {
if( $i != $npage ) {
$tmp .="</table>";
} else {
$tmp .= "$noSample </table>";
$tmp .= "<table> <tr><td>Note :</td> <td><pre>$notes</pre></td></tr>
</table> <br/>\r\n";
if($others != '' && $countline < 38) {
$tmp .= "<table><tr><td><b>$othertitle :</b><br/>\r\n";
$tmp .= "$others</td></tr></table>";
$others = '';
}
}
} else { // page tambahan = 1
if( $i != $npage-1 ) {
$tmp .="</table>";
} else {
$tmp .= "$noSample </table>";
$tmp .= "<table> <tr><td>Note :</td> <td><pre>$notes</pre></td></tr>
</table> <br/>\r\n";
}
}
$tmp .= "</div>";
$tmp .= "<div id='footer'>
<table class='footer'>
<tr> <td>";
if($i == $npage) { $tmp .= "Status : $status"; }
$tmp .= "<pre class='small'>Collected on $collData\r\nReceived on $recvData</pre>
Page $i/$npage Printed By : $valBy $date </td>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$tmp .="
<td class='right'><pre>
(__________________)
Authorised Signature
</pre></td>";
$raw .= $tmp; $tmp = '';
$pdf .= "<td class='right'><pre><b>&rdquo;This result is valid without signature.&rdquo;</b></pre></td>";
$tmp .="
</tr>
</table>
</div>
";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .="<img src='assets/gleneaglesftr.png' class='img img-footer'/>";
$tmp .= "</div>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$i+=1;
}
if($others != '') {
$tmp .= "
<div id='page'>
<div id='pagetop' style='height:0.01cm'> </div>";
if($preview==1) { $tmp.= "<div style='font-size:30px'>preview only do not print</div>" ; }
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .= "<img src='assets/gleneagleshdr.png' class='img'/>";
$tmp .= "<div id='dinfo'>
$info
</div>
<div id='dresult'>
<table class='others' style='width:15cm'>
<tr><td><b>$othertitle : </b><br/>\r\n
$others</td></tr></table>
</div>
";
$tmp .= "<div id='footer'>
<table class='footer'>
<tr> <td>";
if($i == $npage) { $tmp .= "Status : $status"; }
$tmp .= "<pre class='small'>Collected on $collData\r\nReceived on $recvData</pre>
Page $i/$npage Printed By : $valBy $date </td>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$tmp .="
<td class='right'><pre>
(__________________)
Authorised Signature
</pre></td>";
$raw .= $tmp; $tmp = '';
$pdf .= "<td class='right'><pre><b>&rdquo;This result is valid without signature.&rdquo;</b></pre></td>";
$tmp .="
</tr>
</table>
</div>
";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .="<br/><img src='assets/gleneaglesftr.png' class='img img-footer'/>";
$tmp .= "</div>";
}
$tmp .="</body>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
echo $raw;
if($preview != 1) {
//pdf
$file = fopen("process_pdf/$HOSTNUMBER.html","w+");
fwrite($file, $pdf);
fclose($file);
//archive
/*
$date = date('YmdHi');
*/
$folder = date('Ym');
$date = date('YmdHi');
//$file = fopen("archive/$date"."_$HOSTNUMBER.html","w+");
$filename = "archive/$folder/$date"."_$HOSTNUMBER.html";
$dirname = dirname($filename);
if (!is_dir($dirname)) { mkdir($dirname, 0777, true); }
$file = fopen("archive/$folder/$date"."_$HOSTNUMBER.html","w+");
fwrite($file, $pdf);
fclose($file);
//oru
$file = fopen("process_oru/$ACCESSNUMBER.oru","w+");
$date = date('Y-m-d H:i');
fwrite($file, "$ACCESSNUMBER\r\n$HOSTNUMBER\r\n$date\r\n$status\r\n-");
fclose($file);
}
?>

View File

@ -1,214 +0,0 @@
<?php
if(isset($_GET['preview'])) { $preview = $_GET['preview']; } else { $preview=0; }
if(isset($_GET['eng'])) { $eng = $_GET['eng']; $lang='eng'; } else { $eng = 0; $lang = 'ind'; }
if(isset($_GET['acc'])) { $ACCESSNUMBER = $_GET['acc']; }
include("config.php");
include("_function.php");
$HOSTNUMBER = getHost($conn, $ACCESSNUMBER);
$result = getResult($conn, $ACCESSNUMBER,$eng);
$info = getData2($conn,$ACCESSNUMBER);
$notes = getNotes($conn, $ACCESSNUMBER);
$others = getOthers($conn,$ACCESSNUMBER, $eng);
$collData = getCollData($conn, $ACCESSNUMBER);
$recvData = getRecvData($conn, $ACCESSNUMBER);
$noSample = getNoSample($conn,$ACCESSNUMBER);
if( $noSample == '' ) {
$status = getStatus($conn, $ACCESSNUMBER);
} else {
$status = "PENDING";
}
if($preview == 0) {
$sql = "INSERT INTO GDC_CMOD.dbo.AUDIT_REQUESTS(ACCESSNUMBER, STEPDATE, STEPTYPE, STEPSTATUS)
VALUES('$ACCESSNUMBER', GETDATE(), 'PRINT', '$status')";
$stmt = sqlsrv_query($conn,$sql);
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
}
$valBy = getValBy($conn, $ACCESSNUMBER);
if(!isset($_GET['date'])) { $date = date('d-m-Y H:i'); }
else { $date = $_GET['date']; }
$npage = count($result);
$i=1;
$raw ='';
$pdf ='';
$tmp = "<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<link rel='stylesheet' href='assets/normalize.min.css' />";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$raw .= "\r\n<link rel='stylesheet' href='assets/style.css' />";
$pdf .= "\r\n<link rel='stylesheet' href='assets/pdf.css' />";
$tmp = "</head>
<body style='-webkit-print-color-adjust:exact;'>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
if($eng==1) { $othertitle = "Non Laboratory Test"; }
else { $othertitle = "Pemeriksaan Non Laboratorium"; }
$countpage = substr_count($result[$npage],"\r");
$countothers = substr_count("$others","\r");
$countline = $countpage + $countothers;
$pageadd = 0;
if($countline > 36) {
$npage += 1;
$pageadd = 1;
}
foreach($result as $page) {
$tmp .= "<div id='page'>
<div id='pagetop' style='height:0.01cm'> </div>";
if($preview==1) { $tmp.= "<div style='font-size:30px'>preview only do not print</div>" ; }
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .= "<img src='assets/gleneagleshdr.png' class='img'/>";
$tmp .= "<div id='dinfo'>
$info
</div>
<div id='dresult'>
<table class='result'>
<colgroup>
<col style='width:26%;'></col>
<col style='width:10%;'></col>
<col style='width:15%;'></col>
<col style='width:12%;'></col>
<col style='width:10%;'></col>
<col style='width:15%;'></col>
<col style='width:12%;'></col>
</colgroup>
<tr> <th rowspan='2' style='border-right:solid 1px black; border-bottom:solid 1px black;'>TEST</th>
<th colspan='3' style='border-right:solid 1px black;'>CONVENTIONAL</th> <th colspan='3'>INTERNATIONAL</th> </tr>
<tr style='border-bottom:solid 1px black;'> <th>RESULT</th> <th>REF. RANGES</th> <th style='border-right:solid 1px black;'>UNIT</th> <th>RESULT</th> <th>REF. RANGES</th> <th>UNIT</th> </tr>
$page
";
// lastpage show nosample, others and note
if($pageadd !=1) {
if( $i != $npage ) {
$tmp .="</table>";
} else {
$tmp .= "$noSample </table>";
$tmp .= "<table> <tr><td>Note :</td> <td><pre>$notes</pre></td></tr>
</table> <br/>\r\n";
if($others != '' && $countline < 38) {
$tmp .= "<table><tr><td><b>$othertitle :</b><br/>\r\n";
$tmp .= "$others</td></tr></table>";
$others = '';
}
}
} else { // page tambahan = 1
if( $i != $npage-1 ) {
$tmp .="</table>";
} else {
$tmp .= "$noSample </table>";
$tmp .= "<table> <tr><td>Note :</td> <td><pre>$notes</pre></td></tr>
</table> <br/>\r\n";
}
}
$tmp .= "</div>";
$tmp .= "<div id='footer'>
<table class='footer'>
<tr> <td>";
if($i == $npage) { $tmp .= "Status : $status"; }
$tmp .= "<pre class='small'>Collected on $collData\r\nReceived on $recvData</pre>
Page $i/$npage Printed By : $valBy $date </td>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$tmp .="
<td class='right'><pre>
(__________________)
Authorised Signature
</pre></td>";
$raw .= $tmp; $tmp = '';
$pdf .= "<td class='right'><pre><b>&rdquo;This result is valid without signature.&rdquo;</b></pre></td>";
$tmp .="
</tr>
</table>
</div>
";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .="<img src='assets/gleneaglesftr.png' class='img img-footer'/>";
$tmp .= "</div>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$i+=1;
}
if($others != '') {
$tmp .= "
<div id='page'>
<div id='pagetop' style='height:0.01cm'> </div>";
if($preview==1) { $tmp.= "<div style='font-size:30px'>preview only do not print</div>" ; }
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .= "<img src='assets/gleneagleshdr.png' class='img'/>";
$tmp .= "<div id='dinfo'>
$info
</div>
<div id='dresult'>
<table class='others' style='width:15cm'>
<tr><td><b>$othertitle : </b><br/>\r\n
$others</td></tr></table>
</div>
";
$tmp .= "<div id='footer'>
<table class='footer'>
<tr> <td>";
if($i == $npage) { $tmp .= "Status : $status"; }
$tmp .= "<pre class='small'>Collected on $collData\r\nReceived on $recvData</pre>
Page $i/$npage Printed By : $valBy $date </td>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$tmp .="
<td class='right'><pre>
(__________________)
Authorised Signature
</pre></td>";
$raw .= $tmp; $tmp = '';
$pdf .= "<td class='right'><pre><b>&rdquo;This result is valid without signature.&rdquo;</b></pre></td>";
$tmp .="
</tr>
</table>
</div>
";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .="<br/><img src='assets/gleneaglesftr.png' class='img img-footer'/>";
$tmp .= "</div>";
}
$tmp .="</body>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
echo $raw;
if($preview != 1) {
//pdf
$file = fopen("process_pdf/$HOSTNUMBER.html","w+");
fwrite($file, $pdf);
fclose($file);
//archive
/*
$date = date('YmdHi');
*/
$folder = date('Ym');
$date = date('YmdHi');
//$file = fopen("archive/$date"."_$HOSTNUMBER.html","w+");
$filename = "archive/$folder/$date"."_$HOSTNUMBER.html";
$dirname = dirname($filename);
if (!is_dir($dirname)) { mkdir($dirname, 0777, true); }
$file = fopen("archive/$folder/$date"."_$HOSTNUMBER.html","w+");
fwrite($file, $pdf);
fclose($file);
//oru
$file = fopen("process_oru/$ACCESSNUMBER.oru","w+");
$date = date('Y-m-d H:i');
fwrite($file, "$ACCESSNUMBER\r\n$HOSTNUMBER\r\n$date\r\n$status");
fclose($file);
}
?>

View File

@ -1,214 +0,0 @@
<?php
if(isset($_GET['preview'])) { $preview = $_GET['preview']; } else { $preview=0; }
if(isset($_GET['eng'])) { $eng = $_GET['eng']; $lang='eng'; } else { $eng = 0; $lang = 'ind'; }
if(isset($_GET['acc'])) { $ACCESSNUMBER = $_GET['acc']; }
include("config.php");
include("_function_zaka.php");
$HOSTNUMBER = getHost($conn, $ACCESSNUMBER);
$result = getResult($conn, $ACCESSNUMBER,$eng);
$info = getData2($conn,$ACCESSNUMBER);
$notes = getNotes($conn, $ACCESSNUMBER);
$others = getOthers($conn,$ACCESSNUMBER, $eng);
$collData = getCollData($conn, $ACCESSNUMBER);
$recvData = getRecvData($conn, $ACCESSNUMBER);
$noSample = getNoSample($conn,$ACCESSNUMBER);
if( $noSample == '' ) {
$status = getStatus($conn, $ACCESSNUMBER);
} else {
$status = "PENDING";
}
//if($ACCESSNUMBER != '3121849766') {$status = "FINAL";}
if($preview == 0) {
$sql = "INSERT INTO GDC_CMOD.dbo.AUDIT_REQUESTS(ACCESSNUMBER, STEPDATE, STEPTYPE, STEPSTATUS)
VALUES('$ACCESSNUMBER', GETDATE(), 'PRINT', '$status')";
$stmt = sqlsrv_query($conn,$sql);
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
}
$valBy = getValBy($conn, $ACCESSNUMBER);
if(!isset($_GET['date'])) { $date = date('d-m-Y H:i'); }
else { $date = $_GET['date']; }
$npage = count($result);
$i=1;
$raw ='';
$pdf ='';
$tmp = "<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<link rel='stylesheet' href='assets/normalize.min.css' />";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$raw .= "\r\n<link rel='stylesheet' href='assets/style.css' />";
$pdf .= "\r\n<link rel='stylesheet' href='assets/pdf.css' />";
$tmp = "</head>
<body style='-webkit-print-color-adjust:exact;'>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
if($eng==1) { $othertitle = "Non Laboratory Test"; }
else { $othertitle = "Pemeriksaan Non Laboratorium"; }
$countpage = substr_count($result[$npage],"\r");
$countothers = substr_count("$others","\r");
$countline = $countpage + $countothers;
$pageadd = 0;
if($countline > 37) {
$npage += 1;
$pageadd = 1;
}
foreach($result as $page) {
$tmp .= "<div id='page'>
<div id='pagetop' style='height:0.01cm'> </div>";
if($preview==1) { $tmp.= "<div style='font-size:30px'>preview only do not print</div>" ; }
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .= "<img src='assets/gleneagleshdr.png' class='img'/>";
$tmp .= "<div id='dinfo'>
$info
</div>
<div id='dresult'>
<table class='result'>
<colgroup>
<col style='width:26%;'></col>
<col style='width:10%;'></col>
<col style='width:15%;'></col>
<col style='width:12%;'></col>
<col style='width:10%;'></col>
<col style='width:15%;'></col>
<col style='width:12%;'></col>
</colgroup>
<tr> <th rowspan='2' style='border-right:solid 1px black; border-bottom:solid 1px black;'>TEST</th>
<th colspan='3' style='border-right:solid 1px black;'>CONVENTIONAL</th> <th colspan='3'>INTERNATIONAL</th> </tr>
<tr style='border-bottom:solid 1px black;'> <th>RESULT</th> <th>REF. RANGES</th> <th style='border-right:solid 1px black;'>UNIT</th> <th>RESULT</th> <th>REF. RANGES</th> <th>UNIT</th> </tr>
$page
";
// lastpage show nosample, others and note
if($pageadd !=1) {
if( $i != $npage ) {
$tmp .="</table>";
} else {
$tmp .= "$noSample </table>";
$tmp .= "<table> <tr><td>Note :</td> <td><pre>$notes</pre></td></tr>
</table> <br/>\r\n";
if($others != '' && $countline < 38) {
$tmp .= "<table><tr><td><b>$othertitle :</b><br/>\r\n";
$tmp .= "$others</td></tr></table>";
$others = '';
}
}
} else { // page tambahan = 1
if( $i != $npage-1 ) {
$tmp .="</table>";
} else {
$tmp .= "$noSample </table>";
$tmp .= "<table> <tr><td>Note :</td> <td><pre>$notes</pre></td></tr>
</table> <br/>\r\n";
}
}
$tmp .= "</div>";
$tmp .= "<div id='footer'>
<table class='footer'>
<tr> <td>";
if($i == $npage) { $tmp .= "Status : $status"; }
$tmp .= "<pre class='small'>Collected on $collData\r\nReceived on $recvData</pre>
Page $i/$npage Printed By : $valBy $date </td>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$tmp .="
<td class='right'><pre>
(__________________)
Authorised Signature
</pre></td>";
$raw .= $tmp; $tmp = '';
$pdf .= "<td class='right'><pre><b>&rdquo;This result is valid without signature.&rdquo;</b></pre></td>";
$tmp .="
</tr>
</table>
</div>
";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .="<img src='assets/gleneaglesftr.png' class='img img-footer'/>";
$tmp .= "</div>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$i+=1;
}
if($others != '') {
$tmp .= "
<div id='page'>
<div id='pagetop' style='height:0.01cm'> </div>";
if($preview==1) { $tmp.= "<div style='font-size:30px'>preview only do not print</div>" ; }
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .= "<img src='assets/gleneagleshdr.png' class='img'/>";
$tmp .= "<div id='dinfo'>
$info
</div>
<div id='dresult'>
<table class='others' style='width:15cm'>
<tr><td><b>$othertitle : </b><br/>\r\n
$others</td></tr></table>
</div>
";
$tmp .= "<div id='footer'>
<table class='footer'>
<tr> <td>";
if($i == $npage) { $tmp .= "Status : $status"; }
$tmp .= "<pre class='small'>Collected on $collData\r\nReceived on $recvData</pre>
Page $i/$npage Printed By : $valBy $date </td>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$tmp .="
<td class='right'><pre>
(__________________)
Authorised Signature
</pre></td>";
$raw .= $tmp; $tmp = '';
$pdf .= "<td class='right'><pre><b>&rdquo;This result is valid without signature.&rdquo;</b></pre></td>";
$tmp .="
</tr>
</table>
</div>
";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .="<br/><img src='assets/gleneaglesftr.png' class='img img-footer'/>";
$tmp .= "</div>";
}
$tmp .="</body>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
echo $raw;
if($preview != 1) {
//pdf
$file = fopen("process_pdf/$HOSTNUMBER.html","w+");
fwrite($file, $pdf);
fclose($file);
//archive
/*
$date = date('YmdHi');
*/
$folder = date('Ym');
$date = date('YmdHi');
//$file = fopen("archive/$date"."_$HOSTNUMBER.html","w+");
$filename = "archive/$folder/$date"."_$HOSTNUMBER.html";
$dirname = dirname($filename);
if (!is_dir($dirname)) { mkdir($dirname, 0777, true); }
$file = fopen("archive/$folder/$date"."_$HOSTNUMBER.html","w+");
fwrite($file, $pdf);
fclose($file);
//oru
$file = fopen("process_oru/$ACCESSNUMBER.oru","w+");
$date = date('Y-m-d H:i');
fwrite($file, "$ACCESSNUMBER\r\n$HOSTNUMBER\r\n$date\r\n$status");
fclose($file);
}
?>

View File

@ -1,208 +0,0 @@
<?php
if(isset($_GET['preview'])) { $preview = $_GET['preview']; } else { $preview=0; }
if(isset($_GET['eng'])) { $eng = $_GET['eng']; $lang='eng'; } else { $eng = 0; $lang = 'ind'; }
if(isset($_GET['acc'])) { $ACCESSNUMBER = $_GET['acc']; }
include("config.php");
include("_function_dev.php");
function cutData($text) {
//$text .= strlen($text);
if( strlen($text) > 95 ) {
$split_text = explode(" ", $text);
$cut_length = 11;
$split_text_cut1 = array_slice($split_text, 0, $cut_length);
$split_text_cut2 = array_slice($split_text, $cut_length, count($split_text));
$text1 = implode(" ", $split_text_cut1);
$text2 = implode(" ", $split_text_cut2);
$text = $text1."\r\n".$text2;
}
return($text);
}
$HOSTNUMBER = getHost($conn, $ACCESSNUMBER);
$result = getResult($conn, $ACCESSNUMBER,$eng);
$info = getData2($conn,$ACCESSNUMBER);
$notes = getNotes($conn, $ACCESSNUMBER);
$others = getOthers($conn,$ACCESSNUMBER, $eng);
$collData = getCollData($conn, $ACCESSNUMBER);
$recvData = getRecvData($conn, $ACCESSNUMBER);
$collData = cutData($collData);
$recvData = cutData($recvData);
$noSample = getNoSample($conn,$ACCESSNUMBER);
if( $noSample == '' ) {
$status = getStatus($conn, $ACCESSNUMBER);
} else {
$status = "PENDING";
}
$valBy = getValBy($conn, $ACCESSNUMBER);
if(!isset($_GET['date'])) { $date = date('d-m-Y H:i'); }
else { $date = $_GET['date']; }
$npage = count($result);
$i=1;
$raw ='';
$pdf ='';
$tmp = "<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<link rel='stylesheet' href='assets/normalize.min.css' />";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$raw .= "\r\n<link rel='stylesheet' href='assets/style.css' />";
$pdf .= "\r\n<link rel='stylesheet' href='assets/pdf.css' />";
$tmp = "</head>
<body style='-webkit-print-color-adjust:exact;'>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
if($eng==1) { $othertitle = "Non Laboratory Test"; }
else { $othertitle = "Pemeriksaan Non Laboratorium"; }
$countpage = substr_count($result[$npage],"\r");
$countothers = substr_count("$others","\r");
$countline = $countpage + $countothers;
$pageadd = 0;
if($countline > 36) {
$npage += 1;
$pageadd = 1;
}
foreach($result as $page) {
$tmp .= "<div id='page'>
<div id='pagetop' style='height:0.01cm'> </div>";
if($preview==1) { $tmp.= "<div style='font-size:30px'>preview only do not print</div>" ; }
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .= "<img src='assets/gleneagleshdr.png' class='img'/>";
$tmp .= "<div id='dinfo'>
$info
</div>
<div id='dresult'>
<table class='result'>
<colgroup>
<col style='width:26%;'></col>
<col style='width:10%;'></col>
<col style='width:15%;'></col>
<col style='width:12%;'></col>
<col style='width:10%;'></col>
<col style='width:15%;'></col>
<col style='width:12%;'></col>
</colgroup>
<tr> <th rowspan='2' style='border-right:solid 1px black; border-bottom:solid 1px black;'>TEST</th>
<th colspan='3' style='border-right:solid 1px black;'>CONVENTIONAL</th> <th colspan='3'>INTERNATIONAL</th> </tr>
<tr style='border-bottom:solid 1px black;'> <th>RESULT</th> <th>REF. RANGES</th> <th style='border-right:solid 1px black;'>UNIT</th> <th>RESULT</th> <th>REF. RANGES</th> <th>UNIT</th> </tr>
$page
";
// lastpage show nosample, others and note
if($pageadd !=1) {
if( $i != $npage ) {
$tmp .="</table>";
} else {
$tmp .= "$noSample </table>";
$tmp .= "<table> <tr><td>Note :</td> <td><pre>$notes</pre></td></tr>
</table> <br/>\r\n";
if($others != '' && $countline < 38) {
$tmp .= "<table><tr><td><b>$othertitle :</b><br/>\r\n";
$tmp .= "$others</td></tr></table>";
$others = '';
}
}
} else { // page tambahan = 1
if( $i != $npage-1 ) {
$tmp .="</table>";
} else {
$tmp .= "$noSample </table>";
$tmp .= "<table> <tr><td>Note :</td> <td><pre>$notes</pre></td></tr>
</table> <br/>\r\n";
}
}
$tmp .= "</div>";
$tmp .= "<div id='footer'>
<table class='footer'>
<tr> <td>";
if($i == $npage) { $tmp .= "Status : $status"; }
$tmp .= "<pre class='small'>Collected on $collData\r\nReceived on $recvData</pre>
Page $i/$npage Printed By : $valBy $date </td>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$tmp .= "<td class='right'><pre><b>&rdquo;This result is valid without signature.&rdquo;</b></pre></td>";
$tmp .="
</tr>
</table>
</div>
";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .="<img src='assets/gleneaglesftr.png' class='img img-footer'/>";
$tmp .= "</div>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$i+=1;
}
if($others != '') {
$tmp .= "
<div id='page'>
<div id='pagetop' style='height:0.01cm'> </div>";
if($preview==1) { $tmp.= "<div style='font-size:30px'>preview only do not print</div>" ; }
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .= "<img src='assets/gleneagleshdr.png' class='img'/>";
$tmp .= "<div id='dinfo'>
$info
</div>
<div id='dresult'>
<table class='others' style='width:15cm'>
<tr><td><b>$othertitle : </b><br/>\r\n
$others</td></tr></table>
</div>
";
$tmp .= "<div id='footer'>
<table class='footer'>
<tr> <td>";
if($i == $npage) { $tmp .= "Status : $status"; }
$tmp .= "<pre class='small'>Collected on $collData\r\nReceived on $recvData</pre>
Page $i/$npage Printed By : $valBy $date </td>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$tmp .= "<td class='right'><pre><b>&rdquo;This result is valid without signature.&rdquo;</b></pre></td>";
$tmp .="
</tr>
</table>
</div>
";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .="<br/><img src='assets/gleneaglesftr.png' class='img img-footer'/>";
$tmp .= "</div>";
}
$tmp .="</body>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
echo $raw;
/*
if($preview != 1) {
$sql = "INSERT INTO GDC_CMOD.dbo.AUDIT_REQUESTS(ACCESSNUMBER, STEPDATE, STEPTYPE, STEPSTATUS)
VALUES('$ACCESSNUMBER', GETDATE(), 'PRINT', '$status')";
$stmt = sqlsrv_query($conn,$sql);
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
//pdf
$file = fopen("process_pdf/$HOSTNUMBER.html","w+");
fwrite($file, $pdf);
fclose($file);
//archive
$folder = date('Ym');
$date = date('YmdHi');
//$file = fopen("archive/$date"."_$HOSTNUMBER.html","w+");
$filename = "archive/$folder/$date"."_$HOSTNUMBER.html";
$dirname = dirname($filename);
if (!is_dir($dirname)) { mkdir($dirname, 0777, true); }
$file = fopen("archive/$folder/$date"."_$HOSTNUMBER.html","w+");
fwrite($file, $pdf);
fclose($file);
//oru
$file = fopen("process_oru/$ACCESSNUMBER.oru","w+");
$date = date('Y-m-d H:i');
fwrite($file, "$ACCESSNUMBER\r\n$HOSTNUMBER\r\n$date\r\n$status\r\n-");
fclose($file);
}
*/
?>

View File

@ -1,217 +0,0 @@
<?php
namespace chillerlan\QRCodeExamples;
use chillerlan\QRCode\{QRCode, QROptions};
if(isset($_GET['preview'])) { $preview = $_GET['preview']; } else { $preview=0; }
if(isset($_GET['eng'])) { $eng = $_GET['eng']; $lang='eng'; } else { $eng = 0; $lang = 'ind'; }
if(isset($_GET['acc'])) { $ACCESSNUMBER = $_GET['acc']; }
require_once("qrcode/vendor/autoload.php");
include("config.php");
include("_function.php");
$HOSTNUMBER = getHost($conn, $ACCESSNUMBER);
$result = getResult($conn, $ACCESSNUMBER,$eng);
$others = getOthers($conn, $ACCESSNUMBER, $eng);
$info = getData2($conn,$ACCESSNUMBER);
$notes = getNotes($conn, $ACCESSNUMBER);
$collData = getCollData($conn, $ACCESSNUMBER);
$recvData = getRecvData($conn, $ACCESSNUMBER);
$noSample = getNoSample($conn,$ACCESSNUMBER);
if( $noSample == '' ) {
$status = getStatus($conn, $ACCESSNUMBER);
} else {
$status = "PENDING";
}
if($preview == 0) {
$sql = "INSERT INTO GDC_CMOD.dbo.AUDIT_REQUESTS(ACCESSNUMBER, STEPDATE, STEPTYPE, STEPSTATUS)
VALUES('$ACCESSNUMBER', GETDATE(), 'PRINT', '$status')";
$stmt = sqlsrv_query($conn,$sql);
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
}
$valBy = getValBy($conn, $ACCESSNUMBER);
$qrcode = getQrcode($HOSTNUMBER);
if(!isset($_GET['date'])) { $date = date('d-m-Y H:i'); }
else { $date = $_GET['date']; }
$npage = count($result);
$i=1;
$raw ='';
$pdf ='';
$tmp = "<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<link rel='stylesheet' href='assets/normalize.min.css' />";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$raw .= "\r\n<link rel='stylesheet' href='assets/style_qr.css' />";
$pdf .= "\r\n<link rel='stylesheet' href='assets/pdf_qr.css' />";
$tmp = "</head>
<body style='-webkit-print-color-adjust:exact;'>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
if($eng==1) { $othertitle = "Non Laboratory Test"; }
else { $othertitle = "Pemeriksaan Non Laboratorium"; }
$countpage = substr_count($result[$npage],"\r");
$countothers = substr_count("$others","\r");
$countline = $countpage + $countothers;
$pageadd = 0;
if($countline > 39) {
$npage = $npage+1;
$pageadd = 1;
}
foreach($result as $page) {
$tmp .= "<div id='page'>
<div id=pagetop style='height:0.01cm'> </div>";
if($preview==1) { $tmp.= "<div style='font-size:30px'>preview only do not print</div>" ; }
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .= "<img src='assets/gleneagleshdr.png' class='img'/>";
$tmp .= "<div id='dinfo'>
$info
</div>
<div id='dresult'>
<table class='result'>
<colgroup>
<col style='width:26%;'></col>
<col style='width:10%;'></col>
<col style='width:15%;'></col>
<col style='width:12%;'></col>
<col style='width:10%;'></col>
<col style='width:15%;'></col>
<col style='width:12%;'></col>
</colgroup>
<tr> <th rowspan='2' style='border-right:solid 1px black; border-bottom:solid 1px black;'>TEST</th>
<th colspan='3' style='border-right:solid 1px black;'>CONVENTIONAL</th> <th colspan='3'>INTERNATIONAL</th> </tr>
<tr style='border-bottom:solid 1px black;'> <th>RESULT</th> <th>REF. RANGES</th> <th style='border-right:solid 1px black;'>UNIT</th> <th>RESULT</th> <th>REF. RANGES</th> <th>UNIT</th> </tr>
$page
";
// lastpage show note
// lastpage show nosample, others and note
if($pageadd !=1) {
if( $i != $npage ) {
$tmp .="</table>";
} else {
$tmp .= "$noSample </table>";
$tmp .= "<table> <tr><td>Note :</td> <td><pre>$notes</pre></td></tr>
</table> <br/>\r\n";
if($others != '' && $countline < 39) {
$tmp .= "<table><tr><td><b>$othertitle :</b><br/>\r\n";
$tmp .= "$others</td></tr></table>";
$others = '';
}
}
} else { // page tambahan = 1
if( $i != $npage-1 ) {
$tmp .="</table>";
} else {
$tmp .= "$noSample </table>";
$tmp .= "<table> <tr><td>Note :</td> <td><pre>$notes</pre></td></tr>
</table> <br/>\r\n";
}
}
$tmp .= "</div>";
$tmp .= "<div id='footer'>
<table class='footer'>
<tr> <td><a href='http://$qrcode'><img src='".(new QRCode)->render($qrcode)."' alt='QR Code' style='width:3cm' /></a></td>
<td valign='middle'>";
if($i == $npage) { $tmp .= "Status : $status<br/>"; }
$tmp .= "<span class='small'>Collected on $collData<br/>Received on $recvData</span><br/>
Page $i/$npage Printed By : $valBy $date </td>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$tmp .="
<td class='right'><pre>
(__________________)
Authorised Signature
</pre></td>";
$raw .= $tmp; $tmp = '';
$pdf .= "<td class='right'><pre><b>&rdquo;This result is valid without signature.&rdquo;</b></pre></td>";
$tmp .="
</tr>
</table>
</div>
";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .="<img src='assets/gleneaglesftr.png' class='img'/>";
$tmp .= "</div>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$i+=1;
}
if($others != '') {
$tmp .= "
<div id='page'>
<div id='pagetop' style='height:0.01cm'> </div>";
if($preview==1) { $tmp.= "<div style='font-size:30px'>preview only do not print</div>" ; }
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .= "<img src='assets/gleneagleshdr.png' class='img'/>";
$tmp .= "<div id='dinfo'>
$info
</div>
<div id='dresult'>
<table>
<tr><td><b>$othertitle :</b><br/>\r\n
$others</td></tr></table>
</div>
";
$tmp .= "<div id='footer'>
<table class='footer'>
<tr> <td>";
if($i == $npage) { $tmp .= "Status : $status"; }
$tmp .= "<pre class='small'>Collected on $collData\r\nReceived on $recvData</pre>
Page $i/$npage Printed By : $valBy $date </td>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$tmp .="
<td class='right'><pre>
(__________________)
Authorised Signature
</pre></td>";
$raw .= $tmp; $tmp = '';
$pdf .= "<td class='right'><pre><b>&rdquo;This result is valid without signature.&rdquo;</b></pre></td>";
$tmp .="
</tr>
</table>
</div>
";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .="<img src='assets/gleneaglesftr.png' class='img'/>";
$tmp .= "</div>";
}
$tmp .="</body>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
echo $raw;
if($preview != 1) {
//pdf
$file = fopen("process_pdf/$HOSTNUMBER.html","w+");
fwrite($file, $pdf);
fclose($file);
//archive
$folder = date('Ym');
$date = date('YmdHi');
//$file = fopen("archive/$date"."_$HOSTNUMBER.html","w+");
$filename = "archive/$folder/$date"."_$HOSTNUMBER.html";
$dirname = dirname($filename);
if (!is_dir($dirname)) { mkdir($dirname, 0777, true); }
$file = fopen("archive/$folder/$date"."_$HOSTNUMBER.html","w+");
fwrite($file, $pdf);
fclose($file);
//oru
$file = fopen("process_oru/$ACCESSNUMBER.oru","w+");
$date = date('Y-m-d H:i');
fwrite($file, "$ACCESSNUMBER\r\n$HOSTNUMBER\r\n$date\r\n$status\r\ncovid");
fclose($file);
}
?>

View File

@ -1,2 +0,0 @@
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}main{display:block}h1{font-size:2em;margin:.67em 0}hr{box-sizing:content-box;height:0;overflow:visible}pre{font-family:monospace,monospace;font-size:1em}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,input{overflow:visible}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:1px dotted ButtonText}fieldset{padding:.35em .75em .625em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}progress{vertical-align:baseline}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}details{display:block}summary{display:list-item}template{display:none}[hidden]{display:none}

View File

@ -1 +0,0 @@
{"version":3,"sources":["normalize.css"],"names":[],"mappings":"AAqEA,SA6GA,IACA,IAIE,eAAgB,SA8FlB,OAnCA,GAoCA,MACE,SAAqB,QAhRvB,KACE,YAAa,WACb,qBAAiC,KACjC,yBAA6C,KAO/C,KACE,OAAQ,EAcD,YAKH,MAPN,QACA,MACA,QAEA,OACA,OACA,OACA,KAEA,IACA,QACA,QACE,QAAoC,MAOtC,MACA,OACA,SACA,MACE,QAAS,aAOX,sBACE,QAAS,KACT,OAAQ,EAgBA,UAAV,SAEE,QAAS,KAWX,EACE,iBAAkB,YAClB,6BAAyC,QAQ3C,SACA,QACE,cAAe,EAWjB,YACE,cAAe,KACf,gBAA4B,UAC5B,gBAAoC,UAAU,OAOhD,EACA,OAUE,YAAa,OAOf,IACE,WAAY,OAQd,GACE,UAAW,IACX,OAAQ,MAAO,EAOjB,KACE,iBAAkB,KAClB,MAAO,KAOT,MACE,UAAW,IAQb,IACA,IACE,UAAW,IACX,YAAa,EACb,SAAU,SAIZ,IACE,OAAQ,OAGV,IACE,IAAK,MAUP,IACE,aAAc,KAOhB,eACE,SAAU,OAWZ,KACA,IACA,IACA,KACE,YAAa,UAAW,UACxB,UAAsB,IAOxB,OACE,OAAQ,IAAI,KAQd,GACE,WAAY,YACZ,OAAmB,EAYrB,OACA,MACA,OACA,SACE,KAAM,QACN,OAAmB,EAOrB,SACE,YAAa,IAQf,OACA,OASA,OACA,OACE,eAA2B,KAY7B,cAFsB,cADtB,OACA,mBAGE,mBAAoB,OAQtB,gCACA,+BACA,gCAHA,yBAIE,aAAc,KACd,QAAS,EAQX,6BACA,4BACA,6BAHA,sBAIE,QAAoB,WAAP,OAAJ,IAOX,SACE,OAAQ,IAAI,MAAM,OAClB,OAAQ,EAAE,IACV,QAAS,MAAO,OAAQ,MAU1B,OACE,WAAY,WACZ,MAAkB,QAClB,QAA4B,MAC5B,UAAsC,KACtC,QAA4C,EAC5C,YAAwD,OAO1D,SACE,SAAU,KAQZ,gBACA,aACE,WAAY,WACZ,QAAoB,EAOtB,yCACA,yCACE,OAAQ,KAQV,cACE,mBAAoB,UACpB,eAA2B,KAO7B,4CACA,yCACE,mBAAoB,KAOtB,4BACE,MAAO,QACP,QAAS,IAQX,6BACE,mBAAoB,OACpB,KAAiB"}

View File

@ -1,96 +0,0 @@
<?php
function nullAph($string) {
if($string=='') { $string='null'; }
else {$string= "'$string'";}
return $string;
}
$ACCESSNUMBER=$_GET['acc'];
include('config.php');
$connFB = odbc_connect('GLENEAGLES','','');
$sql = "select * from GDC_CMOD.dbo.v_lab_result where ACCESSNUMBER='$ACCESSNUMBER'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
while ($row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC)) {
$CIDBILLING = $row['CIDBILLING'];
$CIDBILLINGDT = $row['CIDBILLINGDT'];
$CIDPRODUCT = $row['CIDPRODUCT'];
$ODR_CNOLAB = $row['ODR_CNOLAB'];
$RSLT_NCOMPARISON = $row['RSLT_NCOMPARISON'];
$NSEX = $row['NSEX'];
$UOM_ID = $row['UOM_ID'];
$RSLT_VALUEN = $row['RSLT_VALUEN'];
$RSLT_VALUET = $row['RSLT_VALUET'];
//$RSLT_VALUEB = $row['RSLT_VALUEB'];
$RSLT_VALUEB = 'null';
$RSLT_NORMAL = $row['RSLT_NORMAL'];
$RSLT_COMMENT = $row['RSLT_COMMENT'];
$INTER_UOM_ID = $row['INTER_UOM_ID'];
$RSLT_INTERVALUEN = $row['RSLT_INTERVALUEN'];
$RSLT_INTERVALUET = $row['RSLT_INTERVALUET'];
//$RSLT_INTERVALUEB = $row['RSLT_INTERVALUEB'];
$RSLT_INTERVALUEB = 'null';
$RSLT_INTERNORMAL = $row['RSLT_INTERNORMAL'];
$RSLT_INTERCOMMENT = $row['RSLT_INTERCOMMENT'];
$RSLT_NORMALTEXT = $row['FTEXT'];
$MACH_ID = $row['MACH_ID'];
$RSLT_CREATEDBY = $row['RSLT_CREATEDBY'];
$RSLT_NCONVERSION = $row['RSLT_NCONVERSION'];
$CIDBILLING = nullAph($CIDBILLING);
$CIDBILLINGDT = nullAph($CIDBILLINGDT);
$CIDPRODUCT = nullAph($CIDPRODUCT);
//$ODR_CNOLAB = nullAph($ODR_CNOLAB);
$RSLT_NCOMPARISON = nullAph($RSLT_NCOMPARISON);
$NSEX = nullAph($NSEX);
$UOM_ID = nullAph($UOM_ID);
$RSLT_VALUEN = nullAph($RSLT_VALUEN);
$RSLT_VALUET = nullAph($RSLT_VALUET);
$RSLT_NORMAL = nullAph($RSLT_NORMAL);
$RSLT_COMMENT = nullAph($RSLT_COMMENT);
$INTER_UOM_ID = nullAph($INTER_UOM_ID);
$RSLT_INTERVALUEN = nullAph($RSLT_INTERVALUEN);
$RSLT_INTERVALUET = nullAph($RSLT_INTERVALUET);
$RSLT_INTERNORMAL = nullAph($RSLT_INTERNORMAL);
$RSLT_INTERCOMMENT = nullAph($RSLT_INTERCOMMENT);
$RSLT_NORMALTEXT = nullAph($RSLT_NORMALTEXT);
$MACH_ID = nullAph($MACH_ID);
$RSLT_CREATEDBY = nullAph($RSLT_CREATEDBY);
$RSLT_NCONVERSION = nullAph($RSLT_NCONVERSION);
//var sqlFB = "EXECUTE procedure TDL_FILL_LABRESULT ( "+CIDBILLING+", "+CIDBILLINGDT+", "+CIDPRODUCT+", "+RSLT_NCOMPARISON+", "+NSEX+", "+UOM_ID+",
// "+RSLT_VALUEN+", "+RSLT_VALUET+", "+RSLT_VALUEB+", "+RSLT_NORMAL+", "+RSLT_COMMENT+", "+INTER_UOM_ID+", "+RSLT_INTERVALUEN+",
// "+RSLT_INTERVALUET+", "+RSLT_INTERVALUEB+", "+RSLT_INTERNORMAL+", "+RSLT_INTERCOMMENT+","+RSLT_NORMALTEXT+", "+MACH_ID+",
// "+RSLT_CREATEDBY+", "+RSLT_NCONVERSION+")";
if($CIDBILLINGDT !='') {
//echo "<pre>"; print_r($row); echo"</pre>";
$sqlFB = "EXECUTE procedure TDL_FILL_LABRESULT ( $CIDBILLING, $CIDBILLINGDT, $CIDPRODUCT, $RSLT_NCOMPARISON, $NSEX, $UOM_ID,
$RSLT_VALUEN, $RSLT_VALUET, $RSLT_VALUEB, $RSLT_NORMAL, $RSLT_COMMENT, $INTER_UOM_ID, $RSLT_INTERVALUEN,
$RSLT_INTERVALUET, $RSLT_INTERVALUEB, $RSLT_INTERNORMAL, $RSLT_INTERCOMMENT,$RSLT_NORMALTEXT, $MACH_ID, $RSLT_CREATEDBY,
$RSLT_NCONVERSION)";
//echo $sqlFB."<br/>";
//$resultsc = odbc_exec($connFB, $sqlFB) or die("$sqlFB<br/> ".odbc_errormsg());
}
}
// update tdl_order status
$resdt = date('Y-m-d H:i');
$sql = "select status = case
when exists (
select 1 from glendb.dbo.TESTS t
left join glendb.dbo.REQUESTS r on r.REQUESTID=t.REQUESTID
where r.ACCESSNUMBER='$ACCESSNUMBER' and
( t.RESTYPE=0 OR t.RESSTATUS=0 OR Left(t.RESVALUE,7)='Pending' )
and t.NOTPRINTABLE is null
) then 'PENDING'
else 'FINAL'
end";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
if($row[0]!='PENDING') {
$status=1;
$sqlFB = "UPDATE TDL_ORDER SET ODR_NRESULT='$status', ODR_DTRESULT='$resdt' WHERE ODR_CNOLAB='$ODR_CNOLAB'";
//echo $sqlFB."<br/>";
$resultsc = odbc_exec($connFB, $sqlFB) or die(odbc_errormsg());
}
odbc_close($connFB);
?>

View File

@ -1,376 +0,0 @@
{
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"@types/node": {
"version": "14.14.21",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.21.tgz",
"integrity": "sha512-cHYfKsnwllYhjOzuC5q1VpguABBeecUp24yFluHpn/BQaVxB1CuQ1FSRZCzrPxrkIfWISXV2LbeoBthLWg0+0A=="
},
"anymatch": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz",
"integrity": "sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg==",
"requires": {
"normalize-path": "^3.0.0",
"picomatch": "^2.0.4"
}
},
"balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
},
"binary-extensions": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.0.0.tgz",
"integrity": "sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow=="
},
"brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
}
},
"braces": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
"requires": {
"fill-range": "^7.0.1"
}
},
"chokidar": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.3.0.tgz",
"integrity": "sha512-dGmKLDdT3Gdl7fBUe8XK+gAtGmzy5Fn0XkkWQuYxGIgWVPPse2CxFA5mtrlD0TOHaHjEUqkWNyP1XdHoJES/4A==",
"requires": {
"anymatch": "~3.1.1",
"braces": "~3.0.2",
"fsevents": "~2.1.1",
"glob-parent": "~5.1.0",
"is-binary-path": "~2.1.0",
"is-glob": "~4.0.1",
"normalize-path": "~3.0.0",
"readdirp": "~3.2.0"
}
},
"chrome-launcher": {
"version": "0.13.2",
"resolved": "https://registry.npmjs.org/chrome-launcher/-/chrome-launcher-0.13.2.tgz",
"integrity": "sha512-zWD9RVVKd8Nx2xKGY4G08lb3nCD+2hmICxovvRE9QjBKQzHFvCYqGlsw15b4zUxLKq3wXEwVbR/yLtMbfk7JbQ==",
"requires": {
"@types/node": "*",
"escape-string-regexp": "^1.0.5",
"is-wsl": "^2.2.0",
"lighthouse-logger": "^1.0.0",
"mkdirp": "^0.5.3",
"rimraf": "^3.0.2"
},
"dependencies": {
"glob": {
"version": "7.1.6",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
"integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==",
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.0.4",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
}
},
"minimist": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
},
"mkdirp": {
"version": "0.5.5",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
"integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==",
"requires": {
"minimist": "^1.2.5"
}
},
"rimraf": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz",
"integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==",
"requires": {
"glob": "^7.1.3"
}
}
}
},
"chrome-remote-interface": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/chrome-remote-interface/-/chrome-remote-interface-0.28.2.tgz",
"integrity": "sha512-F7mjof7rWvRNsJqhVXuiFU/HWySCxTA9tzpLxUJxVfdLkljwFJ1aMp08AnwXRmmP7r12/doTDOMwaNhFCJsacw==",
"requires": {
"commander": "2.11.x",
"ws": "^7.2.0"
}
},
"commander": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz",
"integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ=="
},
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
},
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"requires": {
"ms": "2.0.0"
}
},
"escape-string-regexp": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ="
},
"fill-range": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
"requires": {
"to-regex-range": "^5.0.1"
}
},
"fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
},
"fsevents": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.3.tgz",
"integrity": "sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ==",
"optional": true
},
"glob": {
"version": "6.0.4",
"resolved": "https://registry.npmjs.org/glob/-/glob-6.0.4.tgz",
"integrity": "sha1-DwiGD2oVUSey+t1PnOJLGqtuTSI=",
"requires": {
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "2 || 3",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
}
},
"glob-parent": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.0.tgz",
"integrity": "sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw==",
"requires": {
"is-glob": "^4.0.1"
}
},
"html-pdf-chrome": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/html-pdf-chrome/-/html-pdf-chrome-0.6.1.tgz",
"integrity": "sha512-WAdk9K1ZJpvZ0D1JfCML+rjPD5RhjsqXaLafoRtyboqxfv7z7NKy06VMEgGDsM7lbO1k2E3aUimUd+jPbLzGGw==",
"requires": {
"chrome-launcher": "0.13.2",
"chrome-remote-interface": "^0.28.0"
}
},
"inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
"requires": {
"once": "^1.3.0",
"wrappy": "1"
}
},
"inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
},
"is-binary-path": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz",
"integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==",
"requires": {
"binary-extensions": "^2.0.0"
}
},
"is-docker": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.1.1.tgz",
"integrity": "sha512-ZOoqiXfEwtGknTiuDEy8pN2CfE3TxMHprvNer1mXiqwkOT77Rw3YVrUQ52EqAOU3QAWDQ+bQdx7HJzrv7LS2Hw=="
},
"is-extglob": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
"integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI="
},
"is-glob": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz",
"integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==",
"requires": {
"is-extglob": "^2.1.1"
}
},
"is-number": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng=="
},
"is-wsl": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
"integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==",
"requires": {
"is-docker": "^2.0.0"
}
},
"lighthouse-logger": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/lighthouse-logger/-/lighthouse-logger-1.2.0.tgz",
"integrity": "sha512-wzUvdIeJZhRsG6gpZfmSCfysaxNEr43i+QT+Hie94wvHDKFLi4n7C2GqZ4sTC+PH5b5iktmXJvU87rWvhP3lHw==",
"requires": {
"debug": "^2.6.8",
"marky": "^1.2.0"
}
},
"marky": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/marky/-/marky-1.2.1.tgz",
"integrity": "sha512-md9k+Gxa3qLH6sUKpeC2CNkJK/Ld+bEz5X96nYwloqphQE0CKCVEKco/6jxEZixinqNdz5RFi/KaCyfbMDMAXQ=="
},
"minimatch": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"requires": {
"brace-expansion": "^1.1.7"
}
},
"minimist": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
},
"mkdirp": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"requires": {
"minimist": "0.0.8"
}
},
"moment": {
"version": "2.29.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
"integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ=="
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
"mv": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/mv/-/mv-2.1.1.tgz",
"integrity": "sha1-rmzg1vbV4KT32JN5jQPB6pVZtqI=",
"requires": {
"mkdirp": "~0.5.1",
"ncp": "~2.0.0",
"rimraf": "~2.4.0"
}
},
"ncp": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ncp/-/ncp-2.0.0.tgz",
"integrity": "sha1-GVoh1sRuNh0vsSgbo4uR6d9727M="
},
"node-cmd": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/node-cmd/-/node-cmd-3.0.0.tgz",
"integrity": "sha1-OP/3CkqqT2WdID61eGJzcBjiT28="
},
"node-run-cmd": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/node-run-cmd/-/node-run-cmd-1.0.1.tgz",
"integrity": "sha1-F1XBJiS9/5INj0UkLWZC4hSj1AA="
},
"normalize-path": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
"integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA=="
},
"once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"requires": {
"wrappy": "1"
}
},
"path-is-absolute": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
},
"pdf-to-printer": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/pdf-to-printer/-/pdf-to-printer-1.1.0.tgz",
"integrity": "sha512-+4v71/7HI1eL8I7orib8YiAiTC45qEL5WAQSKwL2YhmIXvNv+jiOkROtuO6MhFq9mfoUCCQd+ZrjC6bKUFGmxg=="
},
"picomatch": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.1.1.tgz",
"integrity": "sha512-OYMyqkKzK7blWO/+XZYP6w8hH0LDvkBvdvKukti+7kqYFCiEAk+gI3DWnryapc0Dau05ugGTy0foQ6mqn4AHYA=="
},
"readdirp": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.2.0.tgz",
"integrity": "sha512-crk4Qu3pmXwgxdSgGhgA/eXiJAPQiX4GMOZZMXnqKxHX7TaoL+3gQVo/WeuAiogr07DpnfjIMpXXa+PAIvwPGQ==",
"requires": {
"picomatch": "^2.0.4"
}
},
"rimraf": {
"version": "2.4.5",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.4.5.tgz",
"integrity": "sha1-7nEM5dk6j9uFb7Xqj/Di11k0sto=",
"requires": {
"glob": "^6.0.1"
}
},
"to-regex-range": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
"requires": {
"is-number": "^7.0.0"
}
},
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
},
"ws": {
"version": "7.4.2",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.4.2.tgz",
"integrity": "sha512-T4tewALS3+qsrpGI/8dqNMLIVdq/g/85U98HPMa6F0m6xTbvhXU6RCQLqPH3+SlomNV/LdY6RXEbBpMH6EOJnA=="
}
}
}

View File

@ -1,34 +0,0 @@
/*html,pre,th,table { font-family:'Courier New', Courier, monospace; font-size:7.8pt; margin:0;}*/
html,pre,th,table { font-family:'Lucida Console', Monaco, monospace; font-size:7.7pt; margin:0;}
#page { background: white; display: block; margin: 0 auto; page-break-after:always; width: 210mm; height: 295mm; }
#dinfo { float:left; width:200mm;
background-size: 100% auto; background-repeat: no-repeat;
margin-left:0.5cm;
}
#dresult { float:left; margin: 0.2cm 0.8cm 0 1.5cm; height: 18cm; }
#footer { float:left; margin:0cm 2cm 0 1cm; height:1.5cm; }
table {border-collapse:collapse;}
td {vertical-align:top;}
th,td { line-height:1.3;}
.result tr:nth-child(even), th { background: #DDD !important; }
.info { border:solid 1px black; margin:-1cm 0 0 8.5cm; width:11cm;}
.flag { float:right; top:0; font-weight:bold; }
.result { table-layout:fixed; border:solid 1px black; width:100%; }
.textC { font-size:7pt; }
.footer {width : 17cm; }
.footer td {vertical-align:bottom;}
td.right { text-align: right; }
#notes { margin: 5mm 0 0 10mm; }
.img { width:200mm; margin-left:0.5cm }
.img-footer { margin-bottom:7.5mm }
pre.small {font-size:6pt;}
@media print {
@page { margin:0; size:210mm 297mm; }
}

View File

@ -1,116 +0,0 @@
<?php
if(isset($_GET['acc'])) {
$ACCESSNUMBER = $_GET['acc'];
$pdf = 0;
if(isset($_GET['pdf'])) { $pdf = $_GET['pdf']; }
} else {
$file = $argv[1] ;
$filename = explode('\\',$file);
$filename = $filename[1];
$ACCESSNUMBER = $filename;
$pdf = 1;
}
if(isset($_GET['eng'])) { $eng = 1; } else { $eng = 0;}
include("config.php");
include("_function.php");
$raw = "<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />";
if($pdf==0) { $raw.= "<link rel='stylesheet' href='/spooler_db/normalize.min.css' /> <link rel='stylesheet' href='/spooler_db/style.css' />"; }
else { $raw .= "<link rel='stylesheet' href='../normalize.min.css' /> <link rel='stylesheet' href='../pdf.css' />"; }
$raw .= "</head>
<body>";
$HOSTNUMBER = getHost($conn, $ACCESSNUMBER);
$result = getResult($conn, $ACCESSNUMBER,$eng);
$info = getData2($conn,$ACCESSNUMBER);
$notes = getNotes($conn, $ACCESSNUMBER);
$collData = getCollData($conn, $ACCESSNUMBER);
$recvData = getRecvData($conn, $ACCESSNUMBER);
$noSample = getNoSample($conn,$ACCESSNUMBER);
if( $noSample == '' ) {
$status = getStatus($conn, $ACCESSNUMBER);
} else {
$status = "PENDING";
}
$valBy = getValBy($conn, $ACCESSNUMBER);
$date = date('d-m-Y H:i');
$npage = count($result);
$i=1;
foreach($result as $page) {
$raw .= "<div id='page'>
<div id=pagetop style='height:0.01cm'> </div>";
if($pdf==1) { $raw .= "<img src='../gleneagleshdr.png' class='img'/>"; }
$raw .= "<div id='dinfo'>
$info
</div>
<div id='dresult'>
<table class='result'>
<colgroup>
<col style='width:26%;'></col>
<col style='width:10%;'></col>
<col style='width:15%;'></col>
<col style='width:12%;'></col>
<col style='width:10%;'></col>
<col style='width:15%;'></col>
<col style='width:12%;'></col>
</colgroup>
<tr> <th rowspan='2' style='border-right:solid 1px black; border-bottom:solid 1px black;'>TEST</th>
<th colspan='3' style='border-right:solid 1px black;'>CONVENTIONAL</th> <th colspan='3'>INTERNATIONAL</th> </tr>
<tr style='border-bottom:solid 1px black;'> <th>RESULT</th> <th>REF. RANGES</th> <th style='border-right:solid 1px black;'>UNIT</th> <th>RESULT</th> <th>REF. RANGES</th> <th>UNIT</th> </tr>
$page
";
// lastpage show note
if($i != $npage) {
$raw.="</table>";
} else {
$raw .= "$noSample</table>
<table> <tr><td>Note :</td> <td><pre>$notes</pre></td></tr>
</table>";
}
$raw .= "</div>";
$raw .= "<div id='footer'>
<table class='footer'>
<tr> <td>";
if($i == $npage) { $raw .= "Status : $status"; }
$raw .= "<pre class='small'>Collected on $collData
Received on $recvData</pre>
Page $i/$npage Printed By : $valBy $date </td>";
if($pdf!=1) {
$raw .="
<td class='right'><pre>
(__________________)
Authorised Signature
</pre></td>";
} else {
$raw.="<td class='right'><pre><b>&rdquo;This result is valid without signature.&rdquo;</b></pre></td>";
}
$raw .="
</tr>
</table>
</div>
";
//echo "<img src='gleneaglesftr.png' class='footer-img'/>";
if($pdf==1) { $raw .="<img src='../gleneaglesftr.png' class='img'/>"; }
$raw .= "</div>";
$i+=1;
}
$raw .="</body>";
//echo $raw;
if($pdf == 0) { echo $raw; }
else {
if(!isset($_GET['dl'])) {
$file = fopen("process_pdf/$HOSTNUMBER.html","w");
fwrite($file, $raw);
fclose($file);
} else { echo $raw; }
}
?>

View File

@ -1,33 +0,0 @@
/*html,pre,th,table { font-family:'Courier New', Courier, monospace; font-size:7.8pt; margin:0;}*/
html,pre,th,table { font-family:'Lucida Console', Monaco, monospace; font-size:7.7pt; margin:0;}
#page { background: white; display: block; margin: 0 auto; page-break-after:always; width: 210mm; height: 295mm; }
#dinfo { float:left; width:200mm;
background-size: 100% auto; background-repeat: no-repeat;
margin-left:0.5cm;
}
#dresult { float:left; margin: 0.2cm 0.8cm 0 1.5cm; height: 16cm; }
#footer { float:left; margin:0cm 0cm 0.5cm 1cm; }
table {border-collapse:collapse;}
td {vertical-align:top;}
th,td { line-height:1.3;}
.result tr:nth-child(even), th { background: #DDD !important; }
.info { border:solid 1px black; margin:-1cm 0 0 8.5cm; width:11cm;}
.flag { float:right; top:0; font-weight:bold; }
.result { table-layout:fixed; border:solid 1px black; width:100%; }
.textC { font-size:7pt; }
.footer {width : 18.5cm; }
.footer td {vertical-align:bottom;}
td.right { text-align: right; }
#notes { margin: 5mm 0 0 10mm; }
.img { width:210mm; }
pre.small {font-size:6pt;}
@media print {
@page { margin:0; size:210mm 297mm; }
}

View File

@ -1 +0,0 @@
node spooler_pdf.js

View File

@ -1,137 +0,0 @@
<?php
function getHost($conn,$ACCESSNUMBER) {
$sql = "select EXTERNALORDERNUMBER from REQUESTS where ACCESSNUMBER='$ACCESSNUMBER'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
$HOSTNUMBER = $row[0];
return $HOSTNUMBER;
}
include("config.php");
//include("_function.php");
$ACCESSNUMBER = $_GET['acc'];
$HOSTNUMBER = getHost($conn, $ACCESSNUMBER);
echo "$HOSTNUMBER";
/*
$result = getResult($conn, $ACCESSNUMBER,$eng);
$info = getData2($conn,$ACCESSNUMBER);
$notes = getNotes($conn, $ACCESSNUMBER);
$collData = getCollData($conn, $ACCESSNUMBER);
$recvData = getRecvData($conn, $ACCESSNUMBER);
$noSample = getNoSample($conn,$ACCESSNUMBER);
if( $noSample == '' ) {
$status = getStatus($conn, $ACCESSNUMBER);
} else {
$status = "PENDING";
}
$valBy = getValBy($conn, $ACCESSNUMBER);
if(!isset($_GET['date'])) { $date = date('d-m-Y H:i'); }
else { $date = $_GET['date']; }
$npage = count($result);
$i=1;
$raw ='';
$pdf ='';
$tmp = "<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<link rel='stylesheet' href='normalize.min.css' />";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$raw .= "\r\n<link rel='stylesheet' href='style.css' />";
$pdf .= "\r\n<link rel='stylesheet' href='pdf.css' />";
$tmp = "</head>
<body style='-webkit-print-color-adjust:exact;'>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
foreach($result as $page) {
$tmp .= "<div id='page'>
<div id='pagetop' style='height:0.01cm'> </div>";
if($preview==1) { $tmp.= "<div style='font-size:30px'>preview only do not print</div>" ; }
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .= "<img src='http://glenlis/spooler_db/gleneagleshdr.png' class='img'/>";
$tmp .= "<div id='dinfo'>
$info
</div>
<div id='dresult'>
<table class='result'>
<colgroup>
<col style='width:26%;'></col>
<col style='width:10%;'></col>
<col style='width:15%;'></col>
<col style='width:12%;'></col>
<col style='width:10%;'></col>
<col style='width:15%;'></col>
<col style='width:12%;'></col>
</colgroup>
<tr> <th rowspan='2' style='border-right:solid 1px black; border-bottom:solid 1px black;'>TEST</th>
<th colspan='3' style='border-right:solid 1px black;'>CONVENTIONAL</th> <th colspan='3'>INTERNATIONAL</th> </tr>
<tr style='border-bottom:solid 1px black;'> <th>RESULT</th> <th>REF. RANGES</th> <th style='border-right:solid 1px black;'>UNIT</th> <th>RESULT</th> <th>REF. RANGES</th> <th>UNIT</th> </tr>
$page
";
// lastpage show note
if($i != $npage) {
$tmp .="</table>";
} else {
$tmp .= "$noSample</table>
<table> <tr><td>Note :</td> <td><pre>$notes</pre></td></tr>
</table>";
}
$tmp .= "</div>";
$tmp .= "<div id='footer'>
<table class='footer'>
<tr> <td>";
if($i == $npage) { $tmp .= "Status : $status"; }
$tmp .= "<pre class='small'>Collected on $collData\r\nReceived on $recvData</pre>
Page $i/$npage Printed By : $valBy $date </td>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$tmp .="
<td class='right'><pre>
(__________________)
Authorised Signature
</pre></td>";
$raw .= $tmp; $tmp = '';
$pdf .= "<td class='right'><pre><b>&rdquo;This result is valid without signature.&rdquo;</b></pre></td>";
$tmp .="
</tr>
</table>
</div>
";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .="<img src='http://glenlis/spooler_db/gleneaglesftr.png' class='img'/>";
$tmp .= "</div>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$i+=1;
}
$tmp .="</body>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
echo $raw;
if($preview != 1) {
//pdf
$file = fopen("process_pdf/$HOSTNUMBER.html","w+");
fwrite($file, $pdf);
fclose($file);
//archive
$folder = date('Ym');
$date = date('YmdHi');
//$file = fopen("archive/$date"."_$HOSTNUMBER.html","w+");
$filename = "archive/$folder/$date"."_$HOSTNUMBER.html";
$dirname = dirname($filename);
if (!is_dir($dirname)) { mkdir($dirname, 0777, true); }
$file = fopen("archive/$folder/$date"."_$HOSTNUMBER.html","w+");
fwrite($file, $pdf);
fclose($file);
//oru
$file = fopen("process_oru/$ACCESSNUMBER.oru","w+");
$date = date('Y-m-d H:i');
fwrite($file, "$ACCESSNUMBER\r\n$HOSTNUMBER\r\n$date\r\n$status");
fclose($file);
}
*/
?>

Binary file not shown.

View File

@ -1,38 +0,0 @@
const chokidar = require('chokidar');
const paths = require('path');
const mv = require('mv');
const fs = require('fs');
const moment = require('moment');
const nrc = require('node-run-cmd');
const htmlPdf = require('html-pdf-chrome');
const options = {
port: 42020,
printOptions:{
marginBottom: 0,
marginLeft: 0,
marginTop: 0,
marginRight: 0
}
};
var now = moment().format('YYYYMMDDHHmmss');
chokidar.watch('process_pdf/' , { ignoreInitial: false, awaitWriteFinish: true, depth:0 }).on('add', (path) => {
if(paths.extname(path)=='') {
console.log('raw file processed '+path);
nrc.run('php main2.php '+path).then( function(){
mv(path, "done_pdf/"+paths.basename(path) , function (err) {
if (err) throw err;
});
});
}
else if(paths.extname(path)=='.html') {
url = "file://C:/inetpub/wwwroot/spooler_db/process_pdf/"+paths.basename(path);
console.log('generating pdf '+url);
htmlPdf.create(url, options).then((pdf) => pdf.toFile("C:\\inetpub\\wwwroot\\spooler_db\\process_pdf\\"+paths.basename(path,'.html')+".pdf")).then( function(err) {
mv(path, "done_pdf/"+paths.basename(path) , function (err) {
if (err) throw err;
})
});
}
});

View File

@ -1,29 +0,0 @@
/*html,pre,th,table { font-family:'Courier New', Courier, monospace; font-size:7.8pt; margin:0;}*/
html,pre,th,table { font-family:'Lucida Console', Monaco, monospace; font-size:7.5pt; margin:0;}
body { -webkit-print-color-adjust:exact; }
#page { z-index:1; background: white; display: block; margin: 0; page-break-after:always;
/*width: 210mm; height: 297mm;*/
width: 210mm; height: 297mm;
}
#dinfo { float:right; margin:4cm 0.8cm 0 0; }
#dresult { float:left; margin: 0.2cm 0.8cm 0 1.5cm; height: 17cm; }
#footer { float:left; margin:0cm 2cm 0 1cm; height:3cm; }
table {border-collapse:collapse;}
td {vertical-align:top;}
th,td { line-height:1.3;}
.result tr:nth-child(even), th { background: #DDD; }
.info { border:solid 1px black; width:11cm; }
.flag { float:right; top:0; font-weight:bold; }
.result { table-layout:fixed; border:solid 1px black; width:100%; }
.textC { font-size:7pt; }
.footer {width : 17cm; }
.footer td {vertical-align:bottom;}
td.right { text-align: right; }
#notes { margin: 5mm 0 0 10mm; }
.footer-img { visibility:hidden; }
pre.small {font-size:6pt;}

View File

@ -1,29 +0,0 @@
/*html,pre,th,table { font-family:'Courier New', Courier, monospace; font-size:7.8pt; margin:0;}*/
html,pre,th,table { font-family:'Lucida Console', Monaco, monospace; font-size:7.5pt; margin:0;}
body { -webkit-print-color-adjust:exact; }
#page { z-index:1; background: white; display: block; margin: 0; page-break-after:always;
/*width: 210mm; height: 297mm;*/
width: 210mm; height: 297mm;
}
#dinfo { float:right; margin:4cm 0.8cm 0 0; }
#dresult { float:left; margin: 0.2cm 0.8cm 0 1.5cm; height: 14cm; }
#footer { float:left; margin:0cm 2cm 0 1cm; }
table {border-collapse:collapse;}
td {vertical-align:top;}
th,td { line-height:1.3;}
.result tr:nth-child(even), th { background: #DDD; }
.info { border:solid 1px black; width:11cm; }
.flag { float:right; top:0; font-weight:bold; }
.result { table-layout:fixed; border:solid 1px black; width:100%; }
.textC { font-size:7pt; }
.footer {width : 17cm; height:4cm; }
.footer td {vertical-align:bottom;}
td.right { text-align: right; }
#notes { margin: 5mm 0 0 10mm; }
.footer-img { visibility:hidden; }
pre.small {font-size:6pt;}

View File

@ -1,29 +0,0 @@
const paths = require('path');
const mv = require('mv');
const fs = require('fs');
const htmlPdf = require('html-pdf-chrome');
const options = {
port: 42020,
printOptions:{
marginBottom: 0,
marginLeft: 0,
marginTop: 0,
marginRight: 0
}
};
file = process.argv[2];
filename = file.substring(42,file.length-4);
//C:/node/node.exe C:/inetpub/wwwroot/spooler_db/test.js C:/inetpub/wwwroot/spooler_db/process_pdf/01221200963.html
//url = "file://C:/inetpub/wwwroot/spooler_db/process_pdf/"+paths.basename(path);
//url = "file://C:/inetpub/wwwroot/spooler_db/"+file;
url = "file://"+file;
htmlPdf.create(url, options).then((pdf) => pdf.toFile("C:\\inetpub\\wwwroot\\spooler_db\\process_pdf\\"+filename+"pdf"));
//htmlPdf.create(url, options).then((pdf) => pdf.toFile("C:\\inetpub\\wwwroot\\spooler_db\\test_done\\"+filename+".pdf")).then( function(err) {
/*
mv(file, "test_done/"+filename , function (err) {
if (err) throw err;
})
*/
//});

View File

@ -1,8 +0,0 @@
<?php
include("config.php");
include("_function.php");
$ACCESSNUMBER = "5100321678";
//$ACCESSNUMBER = "5100121359";
$result = getResult($conn, $ACCESSNUMBER,0);$npage = count($result);
echo "$npage<br/><pre>";
print_r($result);

View File

@ -1,205 +0,0 @@
<?php
if(isset($_GET['eng'])) { $eng = $_GET['eng']; $lang='eng'; } else { $eng = 0; $lang = 'ind'; }
if(isset($_GET['reqnum'])) { $ACCESSNUMBER = $_GET['reqnum']; }
include("config.php");
include("_function.php");
$HOSTNUMBER = getHost($conn, $ACCESSNUMBER);
$result = getResult($conn, $ACCESSNUMBER,$eng);
$info = getData2($conn,$ACCESSNUMBER);
$notes = getNotes($conn, $ACCESSNUMBER);
$others = getOthers($conn,$ACCESSNUMBER, $eng);
$collData = getCollData($conn, $ACCESSNUMBER);
$recvData = getRecvData($conn, $ACCESSNUMBER);
$noSample = getNoSample($conn,$ACCESSNUMBER);
if( $noSample == '' ) {
$status = getStatus($conn, $ACCESSNUMBER);
} else {
$status = "PENDING";
}
$userid = $_GET['userid'];
$val1 = getVal1($conn, $ACCESSNUMBER);
$valBy = $val1['valBy'];
$valDate = date_format($val1['valDate'], 'd-m-Y H:i');
if(!isset($_GET['date'])) { $date = date('d-m-Y H:i'); }
else { $date = $_GET['date']; }
$npage = count($result);
$i=1;
$raw ='';
$pdf ='';
$tmp = "<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<link rel='stylesheet' href='assets/normalize.min.css' />";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$raw .= "\r\n<link rel='stylesheet' href='assets/style.css' />";
$pdf .= "\r\n<link rel='stylesheet' href='assets/pdf.css' />";
$tmp = "</head>
<body style='-webkit-print-color-adjust:exact;'>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
if($eng==1) { $othertitle = "Non Laboratory Test"; }
else { $othertitle = "Pemeriksaan Non Laboratorium"; }
$countpage = substr_count($result[$npage],"\r");
$countothers = substr_count("$others","\r");
$countline = $countpage + $countothers;
$pageadd = 0;
if($countline > 37) {
$npage += 1;
$pageadd = 1;
}
foreach($result as $page) {
$tmp .= "<div id='page'>
<div id='pagetop' style='height:0.01cm'> </div>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .= "<img src='assets/gleneagleshdr.png' class='img'/>";
$tmp .= "<div id='dinfo'>
$info
</div>
<div id='dresult'>
<table class='result'>
<colgroup>
<col style='width:26%;'></col>
<col style='width:10%;'></col>
<col style='width:15%;'></col>
<col style='width:12%;'></col>
<col style='width:10%;'></col>
<col style='width:15%;'></col>
<col style='width:12%;'></col>
</colgroup>
<tr> <th rowspan='2' style='border-right:solid 1px black; border-bottom:solid 1px black;'>TEST</th>
<th colspan='3' style='border-right:solid 1px black;'>CONVENTIONAL</th> <th colspan='3'>INTERNATIONAL</th> </tr>
<tr style='border-bottom:solid 1px black;'> <th>RESULT</th> <th>REF. RANGES</th> <th style='border-right:solid 1px black;'>UNIT</th> <th>RESULT</th> <th>REF. RANGES</th> <th>UNIT</th> </tr>
$page
";
// lastpage show nosample, others and note
if($pageadd !=1) {
if( $i != $npage ) {
$tmp .="</table>";
} else {
$tmp .= "$noSample </table>";
$tmp .= "<table> <tr><td>Note :</td> <td><pre>$notes</pre></td></tr>
</table> <br/>\r\n";
if($others != '' && $countline < 38) {
$tmp .= "<table><tr><td><b>$othertitle :</b><br/>\r\n";
$tmp .= "$others</td></tr></table>";
$others = '';
}
}
} else { // page tambahan = 1
if( $i != $npage-1 ) {
$tmp .="</table>";
} else {
$tmp .= "$noSample </table>";
$tmp .= "<table> <tr><td>Note :</td> <td><pre>$notes</pre></td></tr>
</table> <br/>\r\n";
}
}
$tmp .= "</div>";
$tmp .= "<div id='footer'>
<table class='footer'>
<tr> <td>";
if($i == $npage) { $tmp .= "Status : $status"; }
$tmp .= "<pre class='small'>Collected on $collData\r\nReceived on $recvData</pre>
Page $i/$npage Val1 : $valBy $valDate | Val2 : $userid $date</td>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$tmp .="
<td class='right'><pre>
(__________________)
Authorised Signature
</pre></td>";
$raw .= $tmp; $tmp = '';
$pdf .= "<td class='right'><pre><b>&rdquo;This result is valid without signature.&rdquo;</b></pre></td>";
$tmp .="
</tr>
</table>
</div>
";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .="<img src='assets/gleneaglesftr.png' class='img img-footer'/>";
$tmp .= "</div>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$i+=1;
}
if($others != '') {
$tmp .= "
<div id='page'>
<div id='pagetop' style='height:0.01cm'> </div>";
if($preview==1) { $tmp.= "<div style='font-size:30px'>preview only do not print</div>" ; }
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .= "<img src='assets/gleneagleshdr.png' class='img'/>";
$tmp .= "<div id='dinfo'>
$info
</div>
<div id='dresult'>
<table class='others' style='width:15cm'>
<tr><td><b>$othertitle : </b><br/>\r\n
$others</td></tr></table>
</div>
";
$tmp .= "<div id='footer'>
<table class='footer'>
<tr> <td>";
if($i == $npage) { $tmp .= "Status : $status"; }
$tmp .= "<pre class='small'>Collected on $collData\r\nReceived on $recvData \r\n".
"Page $i/$npage Val1 : $valBy $valDate | Val2 : $userid $date</pre> </td>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$tmp .="
<td class='right'><pre>
(__________________)
Authorised Signature
</pre></td>";
$raw .= $tmp; $tmp = '';
$pdf .= "<td class='right'><pre><b>&rdquo;This result is valid without signature.&rdquo;</b></pre></td>";
$tmp .="
</tr>
</table>
</div>
";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .="<br/><img src='assets/gleneaglesftr.png' class='img img-footer'/>";
$tmp .= "</div>";
}
$tmp .="</body>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
echo $pdf;
if(isset($_POST['print'])) {
//pdf
$file = fopen("C:/inetpub/wwwroot/spooler_db/val2/$HOSTNUMBER.html","w+");
fwrite($file, $pdf);
fclose($file);
/*
$folder = date('Ym');
$date = date('YmdHi');
//$file = fopen("archive/$date"."_$HOSTNUMBER.html","w+");
$filename = "archive/$folder/$date"."_$HOSTNUMBER.html";
$dirname = dirname($filename);
if (!is_dir($dirname)) { mkdir($dirname, 0777, true); }
$file = fopen("archive/$folder/$date"."_$HOSTNUMBER.html","w+");
fwrite($file, $pdf);
fclose($file);
//oru
$file = fopen("process_oru/$ACCESSNUMBER.oru","w+");
$date = date('Y-m-d H:i');
fwrite($file, "$ACCESSNUMBER\r\n$HOSTNUMBER\r\n$date\r\n$status");
fclose($file);
*/
}
?>

View File

@ -1,193 +0,0 @@
<?php
namespace chillerlan\QRCodeExamples;
use chillerlan\QRCode\{QRCode, QROptions};
if(isset($_GET['eng'])) { $eng = $_GET['eng']; $lang='eng'; } else { $eng = 0; $lang = 'ind'; }
if(isset($_GET['acc'])) { $ACCESSNUMBER = $_GET['acc']; }
require_once("qrcode/vendor/autoload.php");
include("config.php");
include("_function.php");
$HOSTNUMBER = getHost($conn, $ACCESSNUMBER);
$result = getResult($conn, $ACCESSNUMBER,$eng);
$others = getOthers($conn, $ACCESSNUMBER, $eng);
$info = getData2($conn,$ACCESSNUMBER);
$notes = getNotes($conn, $ACCESSNUMBER);
$collData = getCollData($conn, $ACCESSNUMBER);
$recvData = getRecvData($conn, $ACCESSNUMBER);
$noSample = getNoSample($conn,$ACCESSNUMBER);
if( $noSample == '' ) {
$status = getStatus($conn, $ACCESSNUMBER);
} else {
$status = "PENDING";
}
if($preview == 0) {
$sql = "INSERT INTO GDC_CMOD.dbo.AUDIT_REQUESTS(ACCESSNUMBER, STEPDATE, STEPTYPE, STEPSTATUS)
VALUES('$ACCESSNUMBER', GETDATE(), 'PRINT', '$status')";
$stmt = sqlsrv_query($conn,$sql);
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
}
$valBy = getValBy($conn, $ACCESSNUMBER);
$qrcode = getQrcode($HOSTNUMBER);
if(!isset($_GET['date'])) { $date = date('d-m-Y H:i'); }
else { $date = $_GET['date']; }
$npage = count($result);
$i=1;
$raw ='';
$pdf ='';
$tmp = "<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<link rel='stylesheet' href='assets/normalize.min.css' />";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$raw .= "\r\n<link rel='stylesheet' href='assets/style_qr.css' />";
$pdf .= "\r\n<link rel='stylesheet' href='assets/pdf_qr.css' />";
$tmp = "</head>
<body style='-webkit-print-color-adjust:exact;'>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
if($eng==1) { $othertitle = "Non Laboratory Test"; }
else { $othertitle = "Pemeriksaan Non Laboratorium"; }
$countpage = substr_count($result[$npage],"\r");
$countothers = substr_count("$others","\r");
$countline = $countpage + $countothers;
$pageadd = 0;
if($countline > 39) {
$npage = $npage+1;
$pageadd = 1;
}
foreach($result as $page) {
$tmp .= "<div id='page'>
<div id=pagetop style='height:0.01cm'> </div>";
if($preview==1) { $tmp.= "<div style='font-size:30px'>preview only do not print</div>" ; }
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .= "<img src='assets/gleneagleshdr.png' class='img'/>";
$tmp .= "<div id='dinfo'>
$info
</div>
<div id='dresult'>
<table class='result'>
<colgroup>
<col style='width:26%;'></col>
<col style='width:10%;'></col>
<col style='width:15%;'></col>
<col style='width:12%;'></col>
<col style='width:10%;'></col>
<col style='width:15%;'></col>
<col style='width:12%;'></col>
</colgroup>
<tr> <th rowspan='2' style='border-right:solid 1px black; border-bottom:solid 1px black;'>TEST</th>
<th colspan='3' style='border-right:solid 1px black;'>CONVENTIONAL</th> <th colspan='3'>INTERNATIONAL</th> </tr>
<tr style='border-bottom:solid 1px black;'> <th>RESULT</th> <th>REF. RANGES</th> <th style='border-right:solid 1px black;'>UNIT</th> <th>RESULT</th> <th>REF. RANGES</th> <th>UNIT</th> </tr>
$page
";
// lastpage show note
// lastpage show nosample, others and note
if($pageadd !=1) {
if( $i != $npage ) {
$tmp .="</table>";
} else {
$tmp .= "$noSample </table>";
$tmp .= "<table> <tr><td>Note :</td> <td><pre>$notes</pre></td></tr>
</table> <br/>\r\n";
if($others != '' && $countline < 39) {
$tmp .= "<table><tr><td><b>$othertitle :</b><br/>\r\n";
$tmp .= "$others</td></tr></table>";
$others = '';
}
}
} else { // page tambahan = 1
if( $i != $npage-1 ) {
$tmp .="</table>";
} else {
$tmp .= "$noSample </table>";
$tmp .= "<table> <tr><td>Note :</td> <td><pre>$notes</pre></td></tr>
</table> <br/>\r\n";
}
}
$tmp .= "</div>";
$tmp .= "<div id='footer'>
<table class='footer'>
<tr> <td><a href='http://$qrcode'><img src='".(new QRCode)->render($qrcode)."' alt='QR Code' style='width:3cm' /></a></td>
<td valign='middle'>";
if($i == $npage) { $tmp .= "Status : $status<br/>"; }
$tmp .= "<span class='small'>Collected on $collData<br/>Received on $recvData</span><br/>
Page $i/$npage Printed By : $valBy $date </td>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$tmp .="
<td class='right'><pre>
(__________________)
Authorised Signature
</pre></td>";
$raw .= $tmp; $tmp = '';
$pdf .= "<td class='right'><pre><b>&rdquo;This result is valid without signature.&rdquo;</b></pre></td>";
$tmp .="
</tr>
</table>
</div>
";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .="<img src='assets/gleneaglesftr.png' class='img'/>";
$tmp .= "</div>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$i+=1;
}
if($others != '') {
$tmp .= "
<div id='page'>
<div id='pagetop' style='height:0.01cm'> </div>";
if($preview==1) { $tmp.= "<div style='font-size:30px'>preview only do not print</div>" ; }
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .= "<img src='assets/gleneagleshdr.png' class='img'/>";
$tmp .= "<div id='dinfo'>
$info
</div>
<div id='dresult'>
<table>
<tr><td><b>$othertitle :</b><br/>\r\n
$others</td></tr></table>
</div>
";
$tmp .= "<div id='footer'>
<table class='footer'>
<tr> <td>";
if($i == $npage) { $tmp .= "Status : $status"; }
$tmp .= "<pre class='small'>Collected on $collData\r\nReceived on $recvData</pre>
Page $i/$npage Printed By : $valBy $date </td>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$tmp .="
<td class='right'><pre>
(__________________)
Authorised Signature
</pre></td>";
$raw .= $tmp; $tmp = '';
$pdf .= "<td class='right'><pre><b>&rdquo;This result is valid without signature.&rdquo;</b></pre></td>";
$tmp .="
</tr>
</table>
</div>
";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
$pdf .="<img src='assets/gleneaglesftr.png' class='img'/>";
$tmp .= "</div>";
}
$tmp .="</body>";
$raw .= $tmp; $pdf .= $tmp; $tmp = '';
echo $pdf;
?>