fixes for prior commit - moved Documents menu item to Procedures->Lab documents
[openemr.git] / interface / patient_file / barcode_label.php
blob628a0a80b9a4ab8d642bed9e48b24e4bbfe13ad0
1 <?php
2 /**
3 * interface/patient_file/barcode_label.php Displaying a PDF file of Labels for printing.
4 *
5 * Program for displaying Barcode Label
6 * via the popups on the left nav screen
7 *
8 * Copyright (C) 2014 Terry Hill <terry@lillysystems.com>
9 *
10 * LICENSE: This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 3
13 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
21 * @package OpenEMR
22 * @author Terry Hill <terry@lillysystems.com>
23 * @link http://www.open-emr.org
25 * this is from the barcode-coder and FPDF website I used the examples and code snippets listed on the sites
26 * to create this program
30 $fake_register_globals=false;
31 $sanitize_all_escapes=true;
34 require_once("../globals.php");
35 require_once("$srcdir/classes/PDF_Label.php");
36 require_once("$srcdir/formatting.inc.php");
37 require_once("$srcdir/classes/php-barcode.php");
39 //Get the data to place on labels
41 $patdata = sqlQuery("SELECT " .
42 "p.fname, p.mname, p.lname, p.pubpid, p.DOB, " .
43 "p.street, p.city, p.state, p.postal_code, p.pid " .
44 "FROM patient_data AS p " .
45 "WHERE p.pid = ? LIMIT 1", array($pid));
49 $today = date('m/d/Y');
50 $dob = substr($patdata['DOB'],5,2) ."/". Substr($patdata['DOB'],8,2) ."/". Substr($patdata['DOB'],0,4);
54 // -------------------------------------------------- //
55 // BARCODE DATA AND TYPE
56 // -------------------------------------------------- //
58 $code = $patdata['pubpid']; // what is wanted as the barcode
59 $bartype = $GLOBALS['barcode_label_type'] ; // Get barcode type
61 switch($bartype){
62 case '1':
63 $type = 'std25';
64 break;
65 case '2':
66 $type = 'int25';
67 break;
68 case '3':
69 $type = 'ean8';
70 break;
71 case '4':
72 $type = 'ean13';
73 break;
74 case '5':
75 $type = 'upc';
76 break;
77 case '6':
78 $type = 'code11';
79 break;
80 case '7':
81 $type = 'code39';
82 break;
83 case '8':
84 $type = 'code93';
85 break;
86 case '9':
87 $type = 'code128';
88 break;
89 case '10':
90 $type = 'codabar';
91 break;
92 case '11':
93 $type = 'msi';
94 break;
95 case '12':
96 $type = 'datamatrix';
97 break;
100 // -------------------------------------------------- //
101 // PROPERTIES
102 // -------------------------------------------------- //
103 $fontSize = 28;
104 $angle = 90; // rotation in degrees
105 $black = '000000'; // color in hexa
107 if ($GLOBALS['barcode_label_type'] == '12') { // datamatrix
108 $marge = 0; // between barcode and hri in pixel
109 $x = 35; // barcode center
110 $y = 120; // barcode center
111 $height = 40; // barcode height in 1D ; module size in 2D
112 $width = 4; // barcode height in 1D ; not use in 2D
114 ELSE
116 $marge = 5; // between barcode and hri in pixel
117 $x = 30; // barcode center
118 $y = 120; // barcode center
119 $height = 40; // barcode height in 1D ; module size in 2D
120 $width = 1; // barcode height in 1D ; not use in 2D
123 // -------------------------------------------------- //
124 // ALLOCATE FPDF RESSOURCE
125 // -------------------------------------------------- //
127 $pdf = new eFPDF('P', 'mm',array(102,252)); // set the orentation, unit of measure and size of the page
128 $pdf->AddPage();
130 // -------------------------------------------------- //
131 // BARCODE
132 // -------------------------------------------------- //
134 $data = Barcode::fpdf($pdf, $black, $x, $y, $angle, $type, array('code'=>$code), $width, $height);
135 $pdf->SetFont('Arial','B',$fontSize);
136 $pdf->SetTextColor(0, 0, 0);
137 $len = $pdf->GetStringWidth($data['hri']);
138 Barcode::rotate(-$len / 2, ($data['height'] / 2) + $fontSize + $marge, $angle, $xt, $yt);
140 // -------------------------------------------------- //
141 // OUTPUT
142 // -------------------------------------------------- //
144 $pdf->TextWithRotation($x + $xt, $y + $yt, $data['hri'], $angle);
145 $pdf->Output();