Print Tokens
Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com

Print Tokens

Introduction

Print tokens define which data fields should be included in the label. Each print rule can have its own set of tokens, giving users flexibility to customize labels based on their needs.

Example:
If a print rule includes tokens like Specimen Label and Visit Name, the generated label CSV will include these two values for each specimen.

This allows users to extract only the relevant information from OpenSpecimen for each type of label.

Types of Label Tokens

Label tokens are of two types

  1. Basic Tokens

  2. Advance tokens

Basic Tokens

Each type of print rule has a predefined set of basic tokens. These are available in a dropdown when configuring print rules.

e.g., Print tokens for specimen print rules

image-20250617-073013.png

e.g., Print tokens for container print rules

image-20250617-073128.png

 

Advance tokens

Advanced tokens allow you to include any data field from OpenSpecimen, including custom fields, in your labels.

Key Features:

  • No longer limited to predefined dropdown options

  • Define tokens using the new eval(...) syntax

Syntax:

eval(displayLabel, expr)

  • displayLabel: The name you want to show on the label (e.g., "Diagnosis")

  • expr: The OpenSpecimen expression to extract the value (e.g., #specimen.visit.clinicalDiagnoses[0].props['abbreviation'])

This gives you greater flexibility to build labels that match your site's specific needs.

Examples of basic and advanced tokens for each type of print rule are available on the following pages:

  1. Specimen Print Rules

  2. Distribution Print Rules

  3. Container Print Rules

  4. Visit Print Rules

Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com