forked from openemr/openemr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
barcode_label.php
126 lines (106 loc) · 3.75 KB
/
barcode_label.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
<?php
/**
* interface/patient_file/barcode_label.php Displaying a PDF file of Labels for printing.
*
* Program for displaying Barcode Label
* via the popups on the left nav screen
*
* this is from the barcode-coder and FPDF website I used the examples and code snippets
* listed on the sites to create this program
*
*
* @package OpenEMR
* @link http:https://www.open-emr.org
* @author Terry Hill <[email protected]>
* @copyright Copyright (c) 2014 Terry Hill <[email protected]>
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/
require_once("../globals.php");
//Get the data to place on labels
$patdata = sqlQuery("SELECT " .
"p.fname, p.mname, p.lname, p.pubpid, p.DOB, " .
"p.street, p.city, p.state, p.postal_code, p.pid " .
"FROM patient_data AS p " .
"WHERE p.pid = ? LIMIT 1", array($pid));
$today = date('m/d/Y');
$dob = substr($patdata['DOB'], 5, 2) . "/" . Substr($patdata['DOB'], 8, 2) . "/" . Substr($patdata['DOB'], 0, 4);
// -------------------------------------------------- //
// BARCODE DATA AND TYPE
// -------------------------------------------------- //
$code = $patdata['pubpid']; // what is wanted as the barcode
$bartype = $GLOBALS['barcode_label_type'] ; // Get barcode type
switch ($bartype) {
case '1':
$type = 'std25';
break;
case '2':
$type = 'int25';
break;
case '3':
$type = 'ean8';
break;
case '4':
$type = 'ean13';
break;
case '5':
$type = 'upc';
break;
case '6':
$type = 'code11';
break;
case '7':
$type = 'code39';
break;
case '8':
$type = 'code93';
break;
case '9':
$type = 'code128';
break;
case '10':
$type = 'codabar';
break;
case '11':
$type = 'msi';
break;
case '12':
$type = 'datamatrix';
break;
}
// -------------------------------------------------- //
// PROPERTIES
// -------------------------------------------------- //
$fontSize = 28;
$angle = 90; // rotation in degrees
$black = '000000'; // color in hexa
if ($GLOBALS['barcode_label_type'] == '12') { // datamatrix
$marge = 0; // between barcode and hri in pixel
$x = 35; // barcode center
$y = 120; // barcode center
$height = 40; // barcode height in 1D ; module size in 2D
$width = 4; // barcode height in 1D ; not use in 2D
} else {
$marge = 5; // between barcode and hri in pixel
$x = 30; // barcode center
$y = 120; // barcode center
$height = 40; // barcode height in 1D ; module size in 2D
$width = 1; // barcode height in 1D ; not use in 2D
}
// -------------------------------------------------- //
// ALLOCATE FPDF RESSOURCE
// -------------------------------------------------- //
$pdf = new eFPDF('P', 'mm', array(102,252)); // set the orentation, unit of measure and size of the page
$pdf->AddPage();
// -------------------------------------------------- //
// BARCODE
// -------------------------------------------------- //
$data = Barcode::fpdf($pdf, $black, $x, $y, $angle, $type, array('code' => $code), $width, $height);
$pdf->SetFont('Arial', 'B', $fontSize);
$pdf->SetTextColor(0, 0, 0);
$len = $pdf->GetStringWidth($data['hri']);
Barcode::rotate(-$len / 2, ($data['height'] / 2) + $fontSize + $marge, $angle, $xt, $yt);
// -------------------------------------------------- //
// OUTPUT
// -------------------------------------------------- //
$pdf->TextWithRotation($x + $xt, $y + $yt, $data['hri'], $angle);
$pdf->Output();