Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Introduction

This document describes the steps to add customized tokens for label printingvarious purpose like Specimen Print token, Specimen label token, Visit Label Token, Container label token etc. This guide is intended for developers or technical IT staff. 

Prerequisites

One should have done the setup the plugin as per steps given at how to write a plugin for OpenSpecimen?

Steps

To customize the Print token implementation one needs to follow the below steps:

  1. Write a class to get label token. Below are examples for different type of label tokens.


Specimen label print token
Write a class that extends AbstractLabelTmplToken and implements LabelTmplToken. The following example describes how to implement LabelTmplToken:

 

Code Block
public class SpecimenCollectionContainerPrintToken extends AbstractLabelTmplToken implements LabelTmplToken {

	@Override
	public String getName() {
		return "specimen_collection_container";
	}

	@Override
	public String getReplacement(Object object) {
		Specimen specimen = (Specimen)object;
		while (specimen.getParentSpecimen() != null) {
			specimen = specimen.getParentSpecimen();
		}

		return specimen.getCollectionEvent().getContainer();
	}

}

 

     ii) For specimen label token extend AbstractSpecimenLabelToken. Refer attached example of PPID label token PpidLabelToken.java.

     iii) For visit label token extend AbstractVisitLabelToken class. Refer attached example of event label token EventLabelToken.java.

     iv) For participant ppid label token extend AbstractPpidToken class. Refer attached example of cp code label  token CpCodePpidToken.java.


     2. The next step will be to register this new token with the com.krishagni.catissueplus.core.common.domain.LabelTmplTokenRegistrar, to make OpenSpecimen aware of this new token. To register the new token, one needs to write a java class in the plugin like below:

...