Dot Matrix Printing for Inward Deposit and Payment Receipts - hmislk/hmis GitHub Wiki

Dot-Matrix Printing for Inward Deposit & Payment Receipts

Coop and other sites print inward deposit and payment receipts on 5ร—5 continuous stationery using an Epson LQ-310 impact printer. The normal browser print path rasterises the page to a bitmap, which prints mushy and unreadable on an impact head. This page explains the two print options added to fix that and how to set up the client machine.

Video

Video What it shows
Raw Text printing for inpatient payment and deposit receipts (about 3 min) Cashiers and administrators: turning on Raw Text in Settings, setting the line width, printing a payment receipt as a .prn file, the one-time printer setup panel, and reprinting the original or a duplicate

Choosing the paper type

The deposit, payment and reprint screens show the print buttons for the paper type chosen in Settings (the cog on the receipt preview; needs the Change Receipt Printing Paper Types privilege):

Paper type Set for Buttons shown Use with
POS / 5ร—5 / 5ร—5 Custom 3 / A4 the logged-in department Print Laser / inkjet / POS printers.
Dot-Matrix Paper (LQ-310) the logged-in department Print and Print (Dot-Matrix): a clean monospace receipt printed through the browser dialog LQ-310 with the ESC/P driver set to a native font (Track A below). Try this first.
Raw Text (Dot-Matrix) the logged-in department Print (Raw Text) only. The receipt downloads as a .prn file that the print agent sends straight to the printer. When Print (Dot-Matrix) is still not crisp enough (Track B below).

When a department uses Raw Text, it replaces the other paper types on that department's screens. The preview then shows an approximate picture of the dot-matrix print. The Raw Text (Dot-Matrix) card in Settings also sets that department's top margin, line width, pre-printed stationery and which patient rows to print.

A collapsed Raw text printer setup (one-time per PC) panel under the preview has the Download print agent (.zip) button and the short setup steps. Track B below has the full details.

Reprinting an original or a duplicate (Raw Text)

If the first print fails (printer jam, breakdown, paper out), open the bill again from Money icon โ†’ Payment Management โ†’ Inward Deposit โ†’ Deposit Search (or Payment Search) and click the bill to open its reprint screen. When the department uses the Raw Text paper type, the reprint screen previews both copies and has two Raw Text buttons:

Button Prints
Print Original (Raw Text) The receipt exactly as the first print โ€” no Duplicate marker. Use this when the original never reached the patient.
Print Duplicate (Raw Text) The receipt with **Duplicate** beside the heading. Use this for a second copy.

Deposit reprint toolbar

Payment reprint toolbar

Original reprints download as inward-reprint-original-<bill no>.prn and duplicates as inward-reprint-<bill no>.prn. Both match the agent's default inward-*.prn file pattern, so no agent change is needed.

The Back to Payments button on both reprint screens returns to the Payment Management page.

Track A โ€” Print (Dot-Matrix): printer & Chrome settings

  1. Install the printer with the Epson LQ-310 ESC/P2 driver (Windows "Add Printer" โ†’ Epson โ†’ LQ-310). Do not use a generic / text-only driver here.
  2. Printer Properties โ†’ Printing Preferences โ†’ Advanced:
    • Print Quality = Draft or LQ (Near Letter Quality) โ€” not "Photo" / "Best".
    • "Print Text as Graphics" = OFF (label varies: "Send TrueType as Bitmap = No", "Print Mode = Native", "Graphics = Draft").
    • Paper size = custom 5 in ร— 5 in (or your form's real length).
    • Paper source = Tractor / Continuous.
  3. In the Chrome print dialog for this printer:
    • Margins = None
    • Scale = 100 / Default
    • Headers and footers = OFF
    • Background graphics = OFF
    • Set it as the default destination and click Save.
  4. If the receipt prints over your pre-printed letterhead, set the ConfigOption Inward Dot Matrix Receipt Preprinted Stationery = true (per department) and tune Inward Dot Matrix Receipt Top Margin Lines (default 8) until the body clears the pre-printed logo.

Track B โ€” Print (Raw Text): client-machine setup

The .prn file must reach the LQ-310 as raw bytes. Pick one option.

Option 1 โ€” Manual (quick test, no automation)

  1. Share the printer (share name e.g. LQ310) or note its LPT port.
  2. After clicking Print (Raw Text), from a Command Prompt:
    copy /b "%USERPROFILE%\Downloads\inward-deposit-123.prn" \\localhost\LQ310
    
    (or ... \\.\LPT1). It prints immediately, crisp, with no driver rasterisation. Use this to confirm quality before setting up the agent.

Option 2 โ€” Watched-folder agent (recommended for daily use)

The agent sends raw bytes to the printer's local UNC share, so the printer must be shared on the cashier PC itself. No admin rights are needed anywhere in this procedure.

  1. Share the printer locally: Printer Properties โ†’ Sharing tab โ†’ tick "Share this printer". Any share name will do โ€” the agent looks it up from the printer name.
  2. On a deposit or payment receipt screen, open Raw text printer setup (one-time per PC) under the preview, click Download print agent (.zip) and unzip it to C:\hmis-print\.
  3. Copy print-agent-config.example.json to print-agent-config.json in that same folder and set:
    • WatchFolder โ€” where Chrome saves the .prn files, e.g. C:\hmis-print
    • PrinterPath โ€” the exact installed printer name from Settings > Printers & scanners (e.g. DEPOSIT), the one you just shared
    • FileGlob โ€” inward-*.prn
    • PollSeconds โ€” how often to check the folder, e.g. 2
  4. In Chrome โ†’ Settings โ†’ Downloads: set Location to C:\hmis-print\ and turn OFF "Ask where to save each file".
  5. Put a shortcut to start-agent-hidden.vbs in the current user's Startup folder, %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup, so the agent starts hidden at every logon. (This replaces the old Task Scheduler route, which many cashier PCs won't allow for a standard account.)
  6. Log off / on, or double-click the shortcut to start it immediately. Confirm agent.log โ€” written next to the script, not in the watch folder โ€” shows a watching ... -> <printer> (\\...\...) line.

Now Print (Raw Text) โ†’ file lands in C:\hmis-print\ โ†’ agent prints it โ†’ file is deleted. Fully hands-off.

How the agent handles failures

  • Each file is renamed to .processing before printing, so the same receipt can never be picked up and printed twice.
  • If the printer is unavailable, the job is retried a few times and then moved to a failed\ subfolder โ€” not retried forever on every poll.
  • If the agent is killed mid-job (reboot, logoff, crash), the leftover .processing file is moved to failed\ at the next startup. It is deliberately not reprinted, because the interrupted run may already have sent it to the spooler. Check whether it printed before re-dropping it into the watch folder.
  • Starting the agent twice over the same folder is blocked by a named mutex, so a manual start on top of the Startup one cannot double-print.

Troubleshooting

Symptom Fix
Control codes (โ†@, โ†x) printed literally on the page The transport is stripping / re-encoding 8-bit bytes. Set ConfigOption Inward Raw Text Receipt Emit ESC/P Codes = false for pure ASCII.
Nothing prints, no error Printer share name / LPT path wrong. Test with the Option 1 copy /b command first.
agent.log shows FATAL: no printer named '<name>' is installed PrinterPath in print-agent-config.json must match the printer's exact name in Settings > Printers & scanners.
agent.log shows FATAL: printer '<name>' is not shared The agent sends raw bytes via the printer's local UNC share. Printer Properties โ†’ Sharing โ†’ "Share this printer".
Agent starts and logs watching ... but nothing prints Check the failed\ subfolder of the watch folder โ€” undeliverable jobs are moved there rather than retried forever. agent.log names each one.
copy /b to a remote share fails with "Access is denied" The account lacks file-share permission on the print server's queue. Share the printer locally on the cashier PC instead and point PrinterPath at that local printer, so the agent uses \\<this-pc>\<sharename> and needs no permission on the remote server.
Prints half the receipt then ejects the whole form Form length in the driver โ‰  your stationery. Set the custom paper size to the real form length; the raw path emits one form-feed at the end.
Two copies of the receipt on screen The dot-matrix preview is meant to be hidden until you print. If it shows, the Inward Payment Bill Dot Matrix Paper config is on โ€” that is expected (it makes the monospace receipt the default preview).
Ends of lines missing at the right edge (Raw Text button) Lower Inward Raw Text Receipt Line Width (default 40) for that department โ€” e.g. 36 โ€” until every line fits on the paper.
Body still overlaps pre-printed header Increase Inward Dot Matrix Receipt Top Margin Lines (Dot-Matrix button) or Inward Raw Text Receipt Top Margin Lines (Raw Text button).

ConfigOption reference

Where to change them: dept-first options are set per department at Administration โ†’ Manage Institutions โ†’ Department Options. Select the department the cashier logs in to (e.g. Inward), select List Department Options, type Raw Text in the search box, then Edit. The rows appear after the first Print (Raw Text) from that department. global options are at Administration โ†’ Manage Institutions โ†’ Application Options. The Settings button on the deposit/payment page only switches the paper format.

Key Type Default Scope Effect
Inward Payment Bill Dot Matrix Paper bool false global/dept Makes the monospace receipt the default on-screen preview + plain Print target.
Inward Dot Matrix Receipt Preprinted Stationery bool false dept-first Suppress the app's text header; drop the body below pre-printed letterhead.
Inward Dot Matrix Receipt Top Margin Lines int 8 dept-first Blank leading lines when the above is true.
Print Barcode on Inward Dot Matrix Receipt bool false global/dept Include the (bitmap) barcode. Off for LQ.
Inward Raw Text Receipt Preprinted Stationery bool false dept-first Same as its Dot-Matrix twin, for the Raw Text file.
Inward Raw Text Receipt Top Margin Lines int 8 dept-first Blank leading lines in the Raw Text file.
Inward Raw Text Receipt Line Width int 40 dept-first Characters per line in the Raw Text file (24โ€“136). Lower it if the ends of lines are cut off at the right edge of the paper.
Inward Raw Text Receipt Emit ESC/P Codes bool true global/dept Wrap the file in ESC/P init + form-feed. Turn off if the transport mangles control bytes.
โš ๏ธ **GitHub.com Fallback** โš ๏ธ