Leave a comment at the end of this page or email contact@krishagni.com
Specimen Print Rules
Neha Nimgire (Unlicensed)
Rohan Patwardhan
Prayuja Teli (Unlicensed)
- 1 Printing Specimen Labels
- 2 Print Rule Fields Specific to Specimen
- 3 Print Tokens
- 3.1 Basic Tokens
- 3.2 Advance Tokens
- 3.2.1 Examples of eval Tokens
- 3.2.1.1 Collection Protocol Level Tokens
- 3.2.1.2 Participant Level Token Examples
- 3.2.1.3 Visit Level Tokens
- 3.2.1.4 Specimen Level Token Examples
- 3.2.2 PV Properties Tokens
- 3.2.2.1 Syntax
- 3.2.2.2 Examples of PV Tokens
- 3.2.3 Examples of Advanced Functions Using eval Tokens
- 3.2.3.1 Conditional Token
- 3.2.3.2 Null Safe Operator
- 3.2.3.3 Pick Last Character
- 3.2.3.4 Concatenate multiple fields
- 3.2.3.5 Extract Substring Before Separator
- 3.2.3.6 Extract Substring After Separator
- 3.2.3.7 Conditional Print Based on Dynamic Values
- 3.2.1 Examples of eval Tokens
Printing Specimen Labels
You can configure specimen print rules to print physical specimen labels. OpenSpecimen provides all the necessary information associated with the specimens. You can define label tokens (basic and advanced) in the print rule. If the label is generated using this print rule, the defined tokens will be part of the output label file.
Click on Create → ‘Specimen’ from the print rules page.
Refer to the Print Rules page and Print Tokens for details, and click on the ‘Create’ button
Print Rule Fields Specific to Specimen
Field | Description | Example Values |
---|
Field | Description | Example Values |
---|---|---|
Collection Protocol | Short title of collection protocol(CP). The default value is *, meaning any CP. | Lung Cancer |
Visit Site | The collection site of visit. The default value is *, meaning any visit site. | Arkansas Hospital |
Lineage | All, Primary, Derived, and Aliquot |
|
Specimen Types | Can select multiple values from the list of types and/or class The default value is *, meaning any specimen type. | Example 1: All Fluid Example 2: Frozen Tissue |
Print Tokens
You can use the below tokens to include their corresponding value in printed labels.
Basic Tokens
These tokens are shipped with the default OpenSpecimen and are most commonly used. User can select multiple tokens as per requirements
Sr No | Level | Token Name | Description | Token | Example values |
---|
Sr No | Level | Token Name | Description | Token | Example values |
---|---|---|---|---|---|
1 | Collection Protocol | Collection Protocol | CP Short Title | specimen_cp_short | Lung Cancer |
2 | Participant | Participant Protocol Identifier | PPID-Unique protocol-specific participant ID | specimen_ppid | ETP-9933 |
3 | Participant | Master patient index | Participant unique ID | specimen_mpi | RTB18388 |
4 | Visit | Visit Name | Visit name | visit_name | ETP-9933-S-01 |
5 | Visit | Visit Date | The format of the date is as per locale in use. | visit_date | In US locale, 03-15-2016 Default: 15-03-2016 |
6 | Visit | Specimen Requirement Code | Specimen requirement code, which is set in the CP. | specimen_requirement_code | EDTA, SST, GTT, P1 |
7 | Specimen | Anatomic Site | Specimen anatomic site | specimen_anatomic_site | Abdomen, NOS |
8 | Specimen | Specimen Class | Specimen class value | specimen_class | Fluid, Molecular, Tissue, Cell |
9 | Specimen | Specimen Type | Type of specimen | specimen_type | Whole Blood, Serum, Cryopreserved Cells |
10 | Specimen | Created On | The date the specimen was created. The format of the date is as per locale in use. | specimen_created_on | In US locale, 03-15-2016 Default: 15-03-2016 |
11 | Specimen | Primary Specimen | Primary specimen label at any level of child specimen under it. Useful for printing derivative or aliquot labels. | specimen_primary_label | Consider below lineage of specimens:
|
12 | Specimen | Label | Specimen label | specimen_label | ETP-9933-S-01-P1 |
13 | Specimen | Barcode | Specimen barcode | specimen_barcode | 127182718 |
14 | Specimen | Lineage | Specimen lineage | specimen_lineage | New, Aliquot, Derivative |
15 | Specimen | Location | Specimen storage location. The format is the Container Name (Row x Column). | specimen_location | Rosy0105 (3 x 4) Rosy0105 is a container name. 3 is the row, and 4 is the column |
16 | Specimen | Pathological Status | Specimen pathological status. | specimen_pathology | Malignant, Metastatic |
17 | Specimen | Quantity | Specimen initial quantity | specimen_quantity | 2.5, 7000000 |
18 | Specimen | Concentration | Specimen concentration | specimen_concentration | 10 |
19 | Specimen | Specimen Collection Container | Collection container of specimen | specimen_collection_container | ACD Vacutainer |
Note: When you select one or more standard tokens and then switch to advanced mode, the system will automatically convert default tokens to match the format, and thus, it might look a bit different than what appears in the above table.
Advance Tokens
In addition to basic tokens, you may sometimes need to include additional data from the specimen, visit, or participant records linked to the specimen. These are often required for printing specific information on physical labels.
To support this, OpenSpecimen provides two modes for selecting tokens:
Eval tokens
PV Props
Examples of eval Tokens
Collection Protocol Level Tokens
Sr No. | Field | Example | Description |
---|
Sr No. | Field | Example | Description |
---|---|---|---|
1 | IRB ID | eval("IRB ID",#specimen.collectionProtocol.irbIdentifier) | Evaluates the collection protocol IRB ID |
2 | CP Code | eval("Code",#specimen.collectionProtocol.code) | Evaluates the collection protocol code |
3 | CP Principal Investigator's first name | eval("PI First Name",#specimen.collectionProtocol.principalInvestigator.firstName) | Gives the first name of the Principal Investigator of the CP |
4 | CP Principal Investigator's last name | eval("PI Last Name",#specimen.collectionProtocol.principalInvestigator.lastName) | Gives the Last name of the Principal Investigator of the CP |
5 | CP custom field | custom_field("Field Name",cp,field_name) | Prints CP custom fields |
Participant Level Token Examples
Sr No. | Field | Example | Description |
---|
Sr No. | Field | Example | Description |
---|---|---|---|
1 | External Subject ID | eval("External Subject Id", #specimen.registration.externalSubjectId) | Evaluates participant’s External Subject Id. |
2 | First Name | eval("First_Name",#specimen.registration.participant.firstName) | Evaluates participant’s First Name. |
3 | Last Name | eval("Last_Name",#specimen.registration.participant.lastName) | Evaluates participant’s Last Name. |
4 | Birth Date | eval("DOB",#specimen.registration.participant.birthDate) | Evaluates participant’s Date of Birth. |
5 | Participant custom field |
| Evaluates participant custom field height. |
6 | Participant Initials First letter of First, middle, and last name | eval("FN",#specimen.registration.participant.firstName?.trim()?.length() > 0 ? #specimen.registration.participant.firstName.charAt(0) : ""),eval("MN",#specimen.registration.participant.middleName?.trim()?.length() > 0 ? #specimen.registration.participant.middleName.charAt(0) : ""),eval("LN",#specimen.registration.participant.lastName?.trim()?.length() > 0 ? #specimen.registration.participant.lastName.charAt(0) : "") | Gives the first character from the first name, middle name, and last name in the output. |
7 | Identifier | eval("Identifier",#specimen.registration.id) | Evaluate the participant identifier |
Visit Level Tokens
Sr No. | Field | Example | Description |
---|
Sr No. | Field | Example | Description |
---|---|---|---|
1 | Visit Name | eval("Vist name",#specimen.visit.name) | Evaluates the visit name |
2 | Visit Date | eval("Vist date",#specimen.visit.visitDate) | Evaluates the visit date |
3 | Visit custom field |
| Prints value for visit custom field additional_diagnosis. |
4 | Event Code | eval("Event_Code",#specimen.visit.cpEvent?.code) | Evaluates the event code of the CP corresponding to the specimen’s visit. |
5 | Event Label | eval("Event_Label",#specimen.visit.cpEvent?.eventLabel) | Evaluates the collection protocol event label corresponding to the specimen’s visit. E.g., ‘Baseline,’ 'Follow-up' |
6 | Surgical Pathology Number | #specimen.visit.surgicalPathologyNumber | Prints Surgical Pathology number documented at Visit level |
Specimen Level Token Examples
Sr No | Field | Example | Description |
---|
Sr No | Field | Example | Description |
---|---|---|---|
1 | Label | eval(“Label”, #specimen.label) | Evaluates the specimen label |
2 | Identifier | eval(“Identifier”, #specimen.id) | Evaluates the specimen identifier |
3 | Created On | eval("Created On", #formatDate(#specimen.createdOn, "MMM, yyyy")) | Expression to extract month and year from the created on the field in the specified format |
4 | Container name and position | eval("Storage",#specimen.position) | Evaluates container name with position in linear or two dimensions(row & column) as per box settings |
5 | Anatomic Site | eval("site",#specimen.tissueSite.value) | Evaluates the anatomic site |
6 | Specimen type abbreviation | eval("type",#specimen.specimenType.props['abbreviation']) | Evaluates the specimen type abbreviation |
7 | Specimen custom field | eval("Ext.Lab.Num",#specimen.getExtension()?.getAttrValues()?.get("ST21")) From v10.2 onwards custom_field("Additive",specimen,additive) | Evaluates visit custom field ST21 From v10.2 onwards Prints value for specimen custom field additive. |
8 | SR name | eval("SR Name",#specimen.specimenRequirement?.name) | Evaluates the specimen-requirement name. |
9 | Available Quantity | eval("Available_Qty",#specimen.availableQuantity) | Evaluates the available quantity of the specimen |
10 | Quantity Unit | eval("type",#specimen.specimenClass.props['quantity_unit']) | Evaluates the quantity unit based on the specimen class. |
11 | Concentration Unit | eval("Conc unit",#specimen.specimenClass.props['concentration_unit']) | Evaluates the concentration unit based on the specimen class. |
12 | Laterality | eval("side",#specimen.tissueSide.value) | Evaluates the laterality |
13 | Received Date | eval("RD",#specimen.receivedEvent.time) | Evaluates the received date |
14 | Parent SR code | eval("Parent SR Code",#specimen.parentSpecimen.specimenRequirement?.code) | Evaluates the parent specimen requirement code. |
15 | Collection date of primary specimen at aliquot level | eval("CD",#formatDate(#specimen.primarySpecimen.collectionEvent.time,"MMM, yyyy")) | Evaluates collection date of primary specimen at child level |
16 | Custom date field (server timezone) | eval("Collection date", #formatDate(T(java.util.Date).from(T(java.time.Instant).ofEpochMilli(T(Long).parseLong(#specimen.getExtension()?.getAttrValues()?.get("collection_date")))), "MM/dd/yyyy HH:mm")) | Evaluates the custom date field 'Collection Date' If there is no value available for the date field, and if you try printing, it will throw an error. Please set it to default to the current date and time OR ensure there is always data entered for the field. |
17 | Custom date field (specific timezone) | eval("Collection date", T(java.time.format.DateTimeFormatter).ofPattern("MM/dd/yyyy HH:mm").withZone(T(java.time.ZoneId).of("Asia/Kolkata")).format(T(java.time.Instant).ofEpochMilli(T(Long).parseLong(#specimen.getExtension()?.getAttrValues()?.get("collection_date"))))) | Evaluates the custom date field 'Collection Date' If there is no value available for the date field, and if you try printing, it will throw an error. Please set it to default to the current date and time OR ensure there is always data entered for the field. |
18 | Ancestor Requirement Name | eval("Ancestor SR Name",#collFns.join(#specimen.getReqNames())) | Adds the ancestor requirement name on the child specimens as comma-seperated values. This includes primary specimens and intermediate parent. |
19 | Ancestor Requirement Code | eval("Ancestor SR Code",#collFns.join(#specimen.getReqCodes())) | Adds the ancestor requirement code on the child specimens as comma-seperated values. This includes primary specimens and intermediate parent. |
20 | Last character(s) of Specimen Label | eval("Last Char", #specimen.label.substring(#specimen.label.length - 1)) | Gives last character from specimen label in the output. You can replace -1 with any numbers E.g. -2 and it will give last 2 characters in the output |
21 | container position | eval("Storage Position",#specimen.position != null ? (#specimen.position.container.positionLabelingMode.name() == "TWO_D" ? (#specimen.position.posTwo + ", " + #specimen.position.posOne) : #specimen.position.container.positionLabelingMode.name() == "LINEAR" ? #specimen.position.getPosition() : "Not Applicable") : "Not Stored") | Gives container position i n4 scenarios - not stored, dimensionless, linear and 2 D layouts. |
22 | Additional Label | eval("Additional_Label",#specimen.additionalLabel) | Prints the value in the field ‘Additional Label’ from v10.x onwards |
25 | Concatenate multiple fields | eval("Participant identifier",#specimen.registration.getExtension()?.getAttrValues()?.get("UPN") + "_" + #specimen.registration.getExtension()?.getAttrValues()?.get("CPF-ID")) | It will concatenate values of registration custom fields ‘UPN’ and ‘CPF-ID’ in single column while generating print file |
26 | Parent Specimen Type | eval("Parent Type",#specimen.parentSpecimen.specimenType.value) | Generates the parent specimen type |
27 | Collection Event User | eval("CollectedUser",#specimen.primarySpecimen.collectionEvent.user.loginName) | Evaluates collection event user's 'login name' |
28 | Collection Event User | eval("CollectedUser",#specimen.primarySpecimen.collectionEvent.user.emailAddress) | Evaluates collection event user's 'Email Address' |
PV Properties Tokens
Syntax
Users can include the abbreviation and concept code of the PV fields defined in the dropdown manager in the print rules.
Syntax - pv_prop(caption, [object_type], field, prop, [is_custom_field])
Fields | Description | Values |
---|
Fields | Description | Values |
---|---|---|
caption | Field name to be displayed for the field |
|
object_type | Level of the field | visit for Visit, cpr for participant |
field | Field to be printed. Variable name in the form in case of custom fields |
|
prop | Property of the field to be printed | abbreviation or concept_code |
is_custom_field | To define whether the field is a custom field or not | true/false |
Examples of PV Tokens
Level | Field | Syntax | Description |
Specimen | Collection Collection (Abbreviation) | pv_prop("Collection Container", collectionEvent.container, abbreviation) | Prints the abbreviation 'E' for the collection container value 'EDTA Vacutainer' |
Specimen | Collection Collection (Concept Code) | pv_prop("Collection Container_code", collectionEvent.container, concept_code) | Prints the concept code 'EDTA' for the collection container value 'EDTA Vacutainer' |
Specimen | Collection Procedure (Abbreviation) | pv_prop("Collection Procedure", collectionEvent.procedure, abbreviation) | Prints the abbreviation 'V' for the collection procedure value 'Venipuncture' |
Specimen | Collection Procedure (Concept Code) | pv_prop("Collection Procedure_code", collectionEvent.procedure, concept_code) | Prints the concept code 'VEN' for the collection procedure value 'Venipuncture' |
Specimen | Received Quality (Abbreviation) | pv_prop("Received Quality",receivedEvent.quality,abbreviation) | Prints the abbreviation 'A' for the received quality value 'Acceptable' |
Specimen | Received Quality (Concept Code) | pv_prop("Received Quality_code",receivedEvent.quality,concept_code) | Prints the concept code 'ACC' for the received quality value 'Acceptable' |
Specimen | Custom field (Abbreviation) | pv_prop("Analysis Type", analysis_type, abbreviation, true) | Prints the abbreviation 'G' for the custom field analysis type for value 'Genomics' |
Specimen | Custom field (Concept Code) | pv_prop("Analysis Type_code", analysis_type, concept_code, true) | Prints the concept code 'GEN' for the custom field analysis type for value 'Genomics' |
Visit | Cohort (Abbreviation) | pv_prop("Visit Cohort", visit, cohort, abbreviation) | Prints the abbreviation 'CHS' for the visit field cohort for value 'Coronary Heart Study' |
Visit | Clinical Diagnosis Abbreviation | pv_prop("CD_Abbreviation",visit.clinicalDiagnoses[0],abbreviation) | Prints the abbreviation for the clinical diagnosis values |
Visit | All Clinical Diagnosis Abbreviation | eval("CD_Abbreviation",#collFns.join(#specimen.visit.clinicalDiagnoses.![props['abbreviation']])) | Prints all the abbreviation values in one field as comma separated |
Visit | Cohort (Concept Code) | pv_prop("Visit Cohort_code", visit, cohort, concept_code) | Prints the concept code 'COR' for the visit field cohort for value 'Coronary Heart Study' |
Visit | Custom Field (Abbreviation) | pv_prop("Geo Region", visit, geo_region, abbreviation, true) | Prints the abbreviation 'Ala' for the visit custom field Geo Region for value 'Alabama' |
Visit | Custom Field (Concept Code) | pv_prop("Geo Region_code", visit, geo_region,concept_code, true) | Prints the concept code 'ALA' for the visit custom field Geo Region for value 'Alabama' |
Participant | Custom Field (Abbreviation) | pv_prop("City Of Birth", cpr, city_of_birth, abbreviation, true) | Prints the abbreviation 'N' for the participant custom field City of Birth for value 'Nashik' |
Leave a comment at the end of this page or email contact@krishagni.com