Portal credential enhancements
[openemr.git] / interface / patient_file / barcode_label.php
blob80c3b93cbd0abfd7b7d9b3ab4063dbfd684beee4
1 <?php
2 /**
3 * interface/patient_file/barcode_label.php Displaying a PDF file of Labels for printing.
5 * Program for displaying Barcode Label
6 * via the popups on the left nav screen
8 * this is from the barcode-coder and FPDF website I used the examples and code snippets
9 * listed on the sites to create this program
12 * @package OpenEMR
13 * @link http://www.open-emr.org
14 * @author Terry Hill <terry@lillysystems.com>
15 * @copyright Copyright (c) 2014 Terry Hill <terry@lillysystems.com>
16 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
20 require_once("../globals.php");
22 //Get the data to place on labels
24 $patdata = sqlQuery("SELECT " .
25 "p.fname, p.mname, p.lname, p.pubpid, p.DOB, " .
26 "p.street, p.city, p.state, p.postal_code, p.pid " .
27 "FROM patient_data AS p " .
28 "WHERE p.pid = ? LIMIT 1", array($pid));
32 $today = date('m/d/Y');
33 $dob = substr($patdata['DOB'], 5, 2) ."/". Substr($patdata['DOB'], 8, 2) ."/". Substr($patdata['DOB'], 0, 4);
37 // -------------------------------------------------- //
38 // BARCODE DATA AND TYPE
39 // -------------------------------------------------- //
41 $code = $patdata['pubpid']; // what is wanted as the barcode
42 $bartype = $GLOBALS['barcode_label_type'] ; // Get barcode type
44 switch ($bartype) {
45 case '1':
46 $type = 'std25';
47 break;
48 case '2':
49 $type = 'int25';
50 break;
51 case '3':
52 $type = 'ean8';
53 break;
54 case '4':
55 $type = 'ean13';
56 break;
57 case '5':
58 $type = 'upc';
59 break;
60 case '6':
61 $type = 'code11';
62 break;
63 case '7':
64 $type = 'code39';
65 break;
66 case '8':
67 $type = 'code93';
68 break;
69 case '9':
70 $type = 'code128';
71 break;
72 case '10':
73 $type = 'codabar';
74 break;
75 case '11':
76 $type = 'msi';
77 break;
78 case '12':
79 $type = 'datamatrix';
80 break;
83 // -------------------------------------------------- //
84 // PROPERTIES
85 // -------------------------------------------------- //
86 $fontSize = 28;
87 $angle = 90; // rotation in degrees
88 $black = '000000'; // color in hexa
90 if ($GLOBALS['barcode_label_type'] == '12') { // datamatrix
91 $marge = 0; // between barcode and hri in pixel
92 $x = 35; // barcode center
93 $y = 120; // barcode center
94 $height = 40; // barcode height in 1D ; module size in 2D
95 $width = 4; // barcode height in 1D ; not use in 2D
96 } else {
97 $marge = 5; // between barcode and hri in pixel
98 $x = 30; // barcode center
99 $y = 120; // barcode center
100 $height = 40; // barcode height in 1D ; module size in 2D
101 $width = 1; // barcode height in 1D ; not use in 2D
104 // -------------------------------------------------- //
105 // ALLOCATE FPDF RESSOURCE
106 // -------------------------------------------------- //
108 $pdf = new eFPDF('P', 'mm', array(102,252)); // set the orentation, unit of measure and size of the page
109 $pdf->AddPage();
111 // -------------------------------------------------- //
112 // BARCODE
113 // -------------------------------------------------- //
115 $data = Barcode::fpdf($pdf, $black, $x, $y, $angle, $type, array('code'=>$code), $width, $height);
116 $pdf->SetFont('Arial', 'B', $fontSize);
117 $pdf->SetTextColor(0, 0, 0);
118 $len = $pdf->GetStringWidth($data['hri']);
119 Barcode::rotate(-$len / 2, ($data['height'] / 2) + $fontSize + $marge, $angle, $xt, $yt);
121 // -------------------------------------------------- //
122 // OUTPUT
123 // -------------------------------------------------- //
125 $pdf->TextWithRotation($x + $xt, $y + $yt, $data['hri'], $angle);
126 $pdf->Output();