forked from openemr/openemr
-
Notifications
You must be signed in to change notification settings - Fork 4
/
labs_ajax.php
127 lines (114 loc) · 4.16 KB
/
labs_ajax.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
/**
* labs_ajax.php
*
* @package OpenEMR
* @link http://www.open-emr.org
* @author Jerry Padgett <sjpadgett@gmail.com>
* @copyright Copyright (c) 2021 Jerry Padgett <sjpadgett@gmail.com>
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/
require_once(__DIR__ . "/../../../interface/globals.php");
use Mpdf\Mpdf;
use OpenEMR\Common\Csrf\CsrfUtils;
use OpenEMR\Core\Header;
if (!CsrfUtils::verifyCsrfToken($_GET["csrf_token_form"])) {
CsrfUtils::csrfNotVerified();
}
function orderDate($order)
{
$sql = "SELECT DATE_FORMAT(date_ordered, '%m/%d/%Y') AS date_ordered FROM procedure_order WHERE procedure_order_id = ? ";
return sqlQuery($sql, [$order]);
}
$action = $_GET['action'];
if ($action === 'code_detail') {
$code = strtoupper($_GET['code']);
$dos = array();
$query = "SELECT detail.name, ord.procedure_code AS code, detail.name AS title, detail.description, detail.notes FROM procedure_type det ";
$query .= "LEFT JOIN procedure_type ord ON ord.procedure_type_id = detail.parent ";
$query .= "WHERE ord.activity = 1 AND detail.procedure_type = 'det' AND ord.procedure_code = ? ";
$query .= "ORDER BY detail.seq ";
$result = sqlStatement($query, [$code]);
echo "<html><head>";
Header::setupHeader();
echo "</head><body style='overflow-x: hidden;'>";
echo "<div class='row'>\n";
echo "<div class='col-10 col-sm-offset-1'><h4>" . xlt('Test Code Information') . "</h4>\n";
$none = true;
while ($data = sqlFetchArray($result)) {
if (empty($data['notes'])) {
continue;
}
$none = false;
echo "<div><b><h5 style='margin-bottom:0'>" . text($data['name']) . "</h5></b>\n";
echo "<span class='col-12'>" . nl2br(text($data['notes'])) . "</span>\n";
echo "</div>\n";
}
if ($none) {
echo "<h4 style='margin-bottom:0'>" . xlt("Details Not Available") . "</h4>\n";
echo "<div class='pr-5'>\n";
echo xlt("Contact your Lab representative.") . "\n";
echo xlt("Additional information may be available");
echo "</div>\n";
}
echo "</div></div></body></html>";
}
if ($action === 'print_labels') {
$client = $_GET['acctid'];
$pid = $_GET['pid'];
$order = $_GET['order'];
$specimen = array();
$specimens = explode(";", $_GET['specimen']);
$patient = strtoupper($_GET['patient']);
$order_date = orderDate($order);
$dob = $_GET['dob'];
$count = 1;
if ($_GET['count']) {
$count = (int)$_GET['count'];
}
$pdf = new mPDF(array(
'tempDir' => $GLOBALS['MPDF_WRITE_DIR'],
'mode' => 'utf-8',
'format' => [45, 19],
'default_font_size' => '9',
'default_font' => 'courier',
'margin_left' => '0',
'margin_right' => '0',
'margin_top' => '1mm',
'margin_bottom' => '0',
'margin_header' => '0',
'margin_footer' => '0'
));
$pdf->text_input_as_HTML = true;
while ($count > 0) {
foreach ($specimens as $t) {
if (empty($t)) {
continue;
}
if ($t === 'none') {
$ord = $order;
} else {
$ord = $order . '-' . $t;
}
$pdf->AddPage();
$barcode = '<div style="text-align: center;vertical-align: bottom;">';
$pdf->SetFont('', 'B', 8);
$pdf->writeCell(0, 3, $patient, 0, 1, 'C');
$pdf->SetFont('', '', 7);
$pdf->writeCell(0, 3, 'CLIENT#: ' . $client . '-WDL', 0, 1, 'C');
$pdf->writeCell(0, 3, 'DOS: ' . $order_date['date_ordered'], 0, 1, 'C');
$pdf->writeCell(0, 3, 'DOB: ' . $dob, 0, 1, 'C');
$code_info = $client . '-' . $ord;
$barcode .= '<barcode size=".6" pr=".4" code="' . attr($code_info) . '" type="C39" /></div>';
$pdf->writeHTML($barcode);
}
$count--;
}
$label_file = $patient . "-" . $client . "_" . $order . "_LABEL.pdf";
// send to display where user decides to print etc...
try {
$pdf->Output($label_file, 'I');
} catch (\Exception $e) {
echo $e->getMessage();
}
}