Barcode Print out

Hi,

Anyway to change the barcode label date format from yyyy/mm/dd to mm/dd/yyyy? I’ve already changed it in the Admin, global, locale settings to show mm/dd/yyyy still prints the label with yyyy/mm/dd.

I checked the barcode_label.php to see the date format in the code is: month/day/year. Not for sure where to make the change to fix the issue.

See code below:

$today = date('m/d/Y');
$dob   = substr($patdata['DOB'], 5, 2) . "/" . Substr($patdata['DOB'], 8, 2) . "/" . Substr($patdata['DOB'], 0, 4);

Thanks,
Samuel Eddinger

Interesting, looking at the code I don’t actually see where $dob is being used in the script. Was there another setting where you told the barcode to print the DOB?

Theoretically, in barcode_label.php you would make the following changes:

Add require_once("{$GLOBALS['srcdir']}/formatting.inc.php"); around line 20 to grab some formatting functions

Line 33 would become:

$dob = oeFormatShortDate($patdata['DOB'], true);

which should return the appropriately formatted date based on the global setting.

Caveat: This is untested, but should work.

Hi Robert,

I’ll make the changes to the php file and see if that fixes the DOB on the wristband.

Thanks,

Samuel Eddinger

image001.png

Hi Robert,

Made the changes to lines 20 and 33 with the new code, now the barcode label doesn’t come up at all now.

I’ll move the old file back to get the barcode level to come back up.

Thanks,

Samuel Eddinger

image001.png

Sorry I led you astray. I can do some investigation. What version are you running? And how exactly are you generating the barcode (what is your exact workflow as a user so I can replicate). Also, can you post any relevant log regarding the barcode.

Update:
I tested my code and it was working. However, by default the only text displayed below the barcode is the Human Readable Interpretation of the Barcode. I added the DOB to that as a proof of concept and it was in fact displaying the correctly formatted DOB.

NP, I really appreciate you trying to fix it. Version is 6.0.0.2. Generating the barcode, click patient (choose a patient name), once the Medical Record Dashboard comes up with the patients name, click on the ribbon “Popups”, and under “Popups” choose “Barcode Label” – it generates the barcode label in PDF format then we print that on a wristband.

Thanks,

Samuel Eddinger

image001.png

Have you made any customizations to the barcode_label.php file?

No, changes made.

Thanks,

Samuel Eddinger

image001.png

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();

I have a question with the print out barcode, not for sure if you can do it, but I thought that I would ask.

Right now the barcode contains (MRN:5 Patient: First, Last, and date of Birth) below the barcode. Wondering if I could keep the same information on the bottom of the barcode and just change the barcode to only read the patients name. Is this something that can be done?

Thanks,
Samuel Eddinger