Product EngineeringFeaturesRemote Printer (lh-print)

Overview

High-level overview of the lh-print utility: purpose, architecture, and core concepts.

👤 Aditya Naresh📅 Updated: Apr 20, 2026📁 Remote Printer

Overview

lh-print (LiveHealth Barcode Printer) is a Python-based utility designed to bridge the gap between modern web-based laboratory management systems and physical label printers. It enables seamless printing of patient and sample barcodes directly from a browser by translating web data into printer-specific commands (PRN).

Remote Printer

The lh-print utility acts as a local protocol handler. When a user clicks a "Print" button in the LiveHealth web application, the browser triggers a custom URI scheme (lhprint://). The local lh-print application intercepts this trigger, parses the patient data, hydrates a predefined PRN template, and sends the raw commands directly to the shared thermal printer.

In engineering terms: this utility solves the "last-mile" connectivity issue for legacy hardware. Since web browsers cannot directly communicate with local COM/LPT ports or specific UNC paths for raw PRN delivery due to security sandboxing, lh-print serves as the trusted local agent that executes these low-level OS operations.

TicketTitleNotes
EN-9789Barcode Printer UtilitySupport for Multiple Printers in PRN Application (Shipping + Barcode Labels)
EN-10033Remote Print IntegrationSupport for same sample id multiple tests printing in PRN2 mode

Prerequisites

RequirementWhy it mattersWhere it is enforced
Windows OSThe protocol handler registration and UNC path moving logic are Windows-specificlhprint/config.py, lhprint/utils.py
Shared PrinterThe application "moves" PRN files to a UNC path (\\machine\printer)lhprint/prn_printer.py
Registry EntryThe lhprint:// protocol must be registered in the Windows Registry to be triggered by browserslh-print.reg (Generated by config.py)
Directory AccessApplication must have write access to C:\livehealth\LHBarcodePrinterlhprint/__init__.py
Config Fileconfig.json must specify the correct printer share name and templatelhprint/barcode_printer.py

What Is It For

Frontend perspective

  • Seamless UX: Print barcodes without downloading files or opening search/print dialogs.
  • Bulk Support: Trigger multiple barcode prints for a single order in one click.
  • Dynamic Feedback: Leverage local logging to troubleshoot printer connectivity issues.

Backend/Local perspective

  • Protocol Interception: Register and handle lhprint:// URI schemes.
  • Data Parsing: Extract patient names, IDs, and test details from encoded URI strings.
  • Template Hydration: Dynamically inject patient data into EPL, ZPL, EZPL, etc. templates.
  • Physical Execution: Send raw commands to thermal printers via OS-level move commands to UNC paths.

Key Features

  • Multi-Dialect Support: Default templates provided for EPL, ZPL, EZPL, TSPL, and ESCP.
  • Custom URI Scheme: Uses lhprint:// to allow cross-browser compatibility.
  • Zero-Dependency Core: Designed to run as a standalone executable (via PyInstaller).
  • Flexible Configuration: config.json allows fine-grained control over field splitting and character limits.
  • Bulk Print Modes: Supports single barcode, bulk (delimited by $), and API-based fetch modes.
  • Auto-Initialization: Automatically creates directories, registry files, and default templates on first run.

On this page