Ok, this got a bit more cumbersome than originally thought. I’m posting an updated barcode_label.php file here which may fix your exact use-case. I added the patient’s name and date of birth which is properly formatted. On this week’s Saturday Developer call we discussed the use-case for the Barcode Label. This functionality was originally developed to simply print a bunch of barcodes for physical paper. I would content there should always be the patient name here, but for now we don’t want to bring these changes into the codebase.
But, if you swap out the existing barcode_label.php file contents with this, you’ll end up with something that could be sued as a viable wristband identifier.
Here is a screenshot of the final product
<?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://www.open-emr.org
* @author Terry Hill <terry@lillysystems.com>
* @copyright Copyright (c) 2014 Terry Hill <terry@lillysystems.com>
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/
require_once("../globals.php");
require_once("{$srcdir}/formatting.inc.php");
ini_set('display_errors', 'on');
error_reporting(E_ALL);
//Get the data to place on labels
$sql = "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";
$patdata = sqlQuery($sql, [$pid]);
$today = date('m/d/Y');
$dob = oeFormatShortDate($patdata['DOB']);
// -------------------------------------------------- //
// 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);
$hri_string = "PUBPID {$data['hri']}";
$patName = $patdata['fname'];
$patName .= (strlen($patdata['mname']) > 0) ? " {$patdata['mname']}" : "";
$patName .= " {$patdata['lname']}";
$pt_name_string = $patName;
$dob_string = "DOB {$dob}";
$hri_len = $pdf->GetStringWidth($hri_string);
$dob_len = $pdf->GetStringWidth($dob_string);
$len = ($hri_len > $dob_len) ? $hri_len : $dob_len;
Barcode::rotate(-$len / 2, ($data['height'] / 2) + $fontSize + $marge, $angle, $xt, $yt);
// -------------------------------------------------- //
// OUTPUT
// -------------------------------------------------- //
$pdf->TextWithRotation($x + $xt - 20, $y + $yt, $pt_name_string, $angle);
$pdf->TextWithRotation($x + $xt - 8, $y + $yt, $hri_string, $angle);
$pdf->TextWithRotation($x + $xt + 4, $y + $yt, $dob_string, $angle);
$pdf->Output();