7 * @link http://www.open-emr.org
8 * @author Jerry Padgett <sjpadgett@gmail.com>
9 * @copyright Copyright (c) 2021 Jerry Padgett <sjpadgett@gmail.com>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 require_once(__DIR__
. "/../../../interface/globals.php");
16 use OpenEMR\Common\Csrf\CsrfUtils
;
17 use OpenEMR\Core\Header
;
19 if (!CsrfUtils
::verifyCsrfToken($_GET["csrf_token_form"])) {
20 CsrfUtils
::csrfNotVerified();
23 function orderDate($order)
25 $sql = "SELECT DATE_FORMAT(date_ordered, '%m/%d/%Y') AS date_ordered FROM procedure_order WHERE procedure_order_id = ? ";
26 return sqlQuery($sql, [$order]);
29 $action = $_GET['action'];
31 if ($action === 'code_detail') {
32 $code = strtoupper($_GET['code']);
35 $query = "SELECT detail.name, ord.procedure_code AS code, detail.name AS title, detail.description, detail.notes FROM procedure_type det ";
36 $query .= "LEFT JOIN procedure_type ord ON ord.procedure_type_id = detail.parent ";
37 $query .= "WHERE ord.activity = 1 AND detail.procedure_type = 'det' AND ord.procedure_code = ? ";
38 $query .= "ORDER BY detail.seq ";
39 $result = sqlStatement($query, [$code]);
41 Header
::setupHeader();
42 echo "</head><body style='overflow-x: hidden;'>";
43 echo "<div class='row'>\n";
44 echo "<div class='col-10 col-sm-offset-1'><h4>" . xlt('Test Code Information') . "</h4>\n";
46 while ($data = sqlFetchArray($result)) {
47 if (empty($data['notes'])) {
51 echo "<div><b><h5 style='margin-bottom:0'>" . text($data['name']) . "</h5></b>\n";
52 echo "<span class='col-12'>" . nl2br(text($data['notes'])) . "</span>\n";
56 echo "<h4 style='margin-bottom:0'>" . xlt("Details Not Available") . "</h4>\n";
57 echo "<div class='pr-5'>\n";
58 echo xlt("Contact your Lab representative.") . "\n";
59 echo xlt("Additional information may be available");
62 echo "</div></div></body></html>";
65 if ($action === 'print_labels') {
66 $client = $_GET['acctid'];
68 $order = $_GET['order'];
70 $specimens = explode(";", $_GET['specimen']);
71 $patient = strtoupper($_GET['patient']);
72 $order_date = orderDate($order);
76 $count = (int)$_GET['count'];
79 $pdf = new mPDF(array(
80 'tempDir' => $GLOBALS['MPDF_WRITE_DIR'],
83 'default_font_size' => '9',
84 'default_font' => 'courier',
86 'margin_right' => '0',
87 'margin_top' => '1mm',
88 'margin_bottom' => '0',
89 'margin_header' => '0',
90 'margin_footer' => '0'
92 $pdf->text_input_as_HTML
= true;
95 foreach ($specimens as $t) {
102 $ord = $order . '-' . $t;
106 $barcode = '<div style="text-align: center;vertical-align: bottom;">';
107 $pdf->SetFont('', 'B', 8);
108 $pdf->writeCell(0, 3, $patient, 0, 1, 'C');
109 $pdf->SetFont('', '', 7);
110 $pdf->writeCell(0, 3, 'CLIENT#: ' . $client . '-WDL', 0, 1, 'C');
111 $pdf->writeCell(0, 3, 'DOS: ' . $order_date['date_ordered'], 0, 1, 'C');
112 $pdf->writeCell(0, 3, 'DOB: ' . $dob, 0, 1, 'C');
113 $code_info = $client . '-' . $ord;
114 $barcode .= '<barcode size=".6" pr=".4" code="' . attr($code_info) . '" type="C39" /></div>';
115 $pdf->writeHTML($barcode);
120 $label_file = $patient . "-" . $client . "_" . $order . "_LABEL.pdf";
121 // send to display where user decides to print etc...
123 $pdf->Output($label_file, 'I');
124 } catch (\Exception
$e) {
125 echo $e->getMessage();