Skip to content

Document Templates

Every document (a Visit Report, a Prescription or a Laboratory Report) is printed with one of your organization’s document templates. This screen lists them and, if you are allowed to manage them, lets you add, change, switch on and off, and delete them. Your own templates are part of the Professional and Enterprise plans: without them, the screen is not in the sidebar, and opening it says that your plan doesn’t include it. Documents are still made from the standard templates on every plan.

Each template prints one kind of document and has a scope:

Scope Used for
Location Documents for visits at that location.
Country Documents for visits at a location in that country (two-letter code, e.g. MX).
Default Everything else.

When a document is generated, the platform picks the most specific active template for its kind: the location’s, then the country’s, then the default. A template has a location or a country, not both.

Only one template can be active per kind and scope. Switching a template on switches off the one that was active for the same kind and scope, so a document always has a template to be printed with. For the same reason, the active default for a kind cannot be switched off: to replace it, switch on another default. New organizations start with an active default for each kind.

Each template is also written for one language (Locale: English, Spanish or Mexican Spanish). Statuses, dates and numbers in the document follow it; the template’s own fixed text is up to whoever wrote it.

Each row shows the template’s name, its kind, its scope, its locale and when it was last changed, with an Active switch. From a row’s menu:

  • View Template shows its markup.
  • Edit Template changes its name, locale or markup. Its kind and scope stay as they are: Copy it to make one for another kind or scope.
  • Delete Template removes it for good. The active default for a kind cannot be deleted; switch on another default first.

Templates are written in Typst. The document’s data is available to the template as data; the Document Template Reference lists everything it holds.

When you create a template, or change its markup or language, it is tried out against sample data before it is saved (a rename alone is saved straight away): once with everything filled in, once with every list empty and every optional field (such as the clinician or the aftercare) missing, and once as seen by someone who may see none of the sections. If it would fail on a real document — for example by reading a field that may be empty, or the first entry of a list that may have none, without checking — it is not saved and the errors are shown under the editor, each naming the sample it failed on. A template can be up to 256 KiB, and trying it out has a time and memory limit: a template that takes too long or uses too much memory is not saved either. If templates cannot be tried out at the moment, saving fails without changing anything; try again a little later.

New templates start inactive, so you can prepare one without changing what gets printed. Switch it on when it is ready.

Seeing this screen and the templates’ markup needs permission to view document templates. Creating, editing, switching on and off, and deleting need permission to manage them; without it the screen is read-only. The Administrator role of an organization created since this screen arrived has both; in an older organization, add them on the Roles screen to the roles that should have them. Location names are shown to those who may view locations; others see the location’s ID.