PDF template editor
Create, preview, publish and maintain the HTML templates behind invoices, receipts, statements and other PDFs, with the full template syntax and bill variables.
Every PDF LeapHealthOS produces, from invoices and receipts to prescriptions and consent forms, is built from an HTML template. The PDF Templates screen lets administrators write those templates, preview them and publish them. This page explains the screen, the template syntax and every variable available to bill documents.
You need some familiarity with HTML to write templates. If you only need to choose which template a document uses, see Invoices, receipts and statements.
Opening the screen
Open SettingsPlatform ConfigurationPDF Templates. The menu is visible only to administrators, and the screen works on desktop and laptop screens.
The list shows each template's Template Name (with its template code underneath), Version, Status (Published or Not Published) and an Actions menu with Edit template, Publish template (only for unpublished templates) and Delete template.
Template codes
The template code says which document a template is for. Your hospital can have one template per code.
Template Code option | Used for |
|---|---|
Bill Standard ( | Invoices |
Reciept Standard ( | Payment receipts (the option is spelled this way on screen) |
Statement Standard ( | Statements for fully paid bills |
Prescription Standard ( | Prescriptions |
Report Standard ( | Test reports |
Discharge Standard ( | Discharge summaries |
Other document | A code you choose, for documents such as consent forms. Use capital letters, digits and underscores, for example |
Because there is only one template per code, change an existing document's look by editing its template rather than creating a new one. The bill, receipt and statement codes used for billing are chosen on the Billing tab of System Settings.
Creating a template
Start a new template
AdministratorSettings > Platform Configuration > PDF Templates
Select Create Template.
Set up the template
Under Template Settings, enter the template name. Choose the Template Code; for Other document, type your own code. Choose Paper Size (A4) and Orientation (Portrait or Landscape). The code cannot be changed later.
Write the HTML
Type or paste your HTML into the HTML Editor. Each {{variable}} you use is listed under Variables.
Check the preview
The Live Preview shows the layout with variables left as placeholders. Variables whose names suggest an image (such as logo, signature, stamp or qr) show a grey placeholder box. The preview is approximate; the final PDF can differ slightly.
Save
Select Save.
Expected result: "Template created" appears. The template is listed as Not Published and is not used yet.
Publish
From the list, open the Actions menu and select Publish template, then confirm.
Expected result: "Template published successfully". The template shows Published and is used for new documents.
Editing a template
Select Edit template, make your changes and select Update. Each save increases the Version number.
- Editing a published template changes it immediately: every document created after you save uses the new version.
- A template cannot be unpublished from the screen.
Test after every change
After you save a billing template, create a test bill and check that the invoice (or receipt or statement) appears and looks right. If the document does not appear, ask your implementation team to check and restore the template.
Known gaps in the editor
- Documents are not created from a template saved in the editor if it contains a repeating section (
{{#each …}}) or a{{…}}value that is not listed on this page. The standard bill, receipt and statement templates contain repeating sections, so ask your implementation team to make changes to those templates. If documents stop appearing after you save a template, ask your implementation team to restore it. - Opening a template that is not yet published may show an empty editor.
- Delete template may not work. Published templates cannot be deleted. If you need a template removed, ask your implementation team.
Template syntax
Variables
Write {{variable_name}} where a value should appear, for example {{patient_name}}.
- Use letters, digits and underscores only, with no spaces inside the braces.
{{ patient_name }}is not filled in. - Values are inserted as plain text, so any HTML characters in a value are shown as typed.
Repeating sections
To print one row per item, wrap the row in an each block. Inside it, use the row's own fields. Read "Known gaps in the editor" above before you save a template that contains one.
<table> <tr><th>Item</th><th>Qty</th><th>Rate</th><th>GST</th><th>Amount</th></tr> {{#each line_items}} <tr> <td>{{item_name}}{{#if batch_number}}<br/>Batch {{batch_number}}, exp {{batch_expiry_formatted}}{{/if}}</td> <td>{{quantity}} {{unit}}</td> <td>{{unit_price_formatted}}</td> <td>{{tax_percent_formatted}} {{tax_mode}}</td> <td>{{line_total_formatted}}</td> </tr> {{/each}}</table>An {{#if field}} inside an each block shows its content only for rows where that field has a value.
Conditional sections
{{#if flag}} … {{/if}} shows the content only when the flag is true. If the flag is not one the document provides, the content is left out.
{{#if hospital_gstin}}<p>GSTIN: {{hospital_gstin}}</p>{{/if}}Header and footer
Content inside {{#header}} … {{/header}} and {{#footer}} … {{/footer}} is repeated at the top and bottom of every page, and space is reserved for it. Link images in the header or footer by their full web address.
The page has no side margins of its own, so add padding to your page content in your HTML styles.
Signature places
For documents that patients or staff sign, type [[sign here: Patient]] where the signature should go, using a name of your choice for each signer (for example [[sign here: Witness]]). A journey Sign step can then place each signature exactly there. The bracketed text is not printed. See Sign node.
Variables for bill documents
Amounts in the main variables are numbers with two decimals, without the rupee sign (for example 1062.00). Fields ending in _formatted include the rupee sign (for example ₹1062.00). Dates are shown as DD/MM/YYYY.
Available on invoices, receipts and statements
Variable | Value |
|---|---|
| The centre's address. |
| The centre's GSTIN. |
| The bill number. |
| The issue date. |
| Patient's name. |
| Patient's date of birth. |
| Patient's email. |
| Total before discounts and tax. |
| Total of line discounts. |
| The bill-wide discount. |
| Line and bill discounts together. |
| Total GST. |
| Overall GST as a percentage of the taxable amount. |
| Total excluding GST. |
| Bill total. |
Receipts only
Variable | Value |
|---|---|
| The receipt number. |
| Date of this payment. |
| Method used. |
| The payment's reference. |
| This payment. |
| All payments so far. |
| What is still owed. |
Statements only
Variable | Value |
|---|---|
| Total paid. |
| Balance (normally 0.00). |
| Number of payments. |
| Date the bill was fully paid. |
Repeating sections
Section | Available on | Row fields |
|---|---|---|
| All three |
|
| All three |
|
| Statements |
|
Flags for conditional sections
Flag | True when |
|---|---|
| The centre has a GSTIN. |
| At least one line carries GST. |
| Receipts only: a balance is still due after this payment. |
Prescription, report and discharge templates receive their own sets of values. Ask your implementation team for those lists before you change one of these templates.
Who can do what
Task | Permission |
|---|---|
View templates | Read permission on Settings |
Create, edit and delete templates | Configure permission on Settings |
Publish templates | Publish permission on Settings |
Related pages
Last updated on