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 various 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?

...

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


                i) 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 PluginInitializer implements InitializingBean {
	
	private LabelTmplTokenRegistrar specimenPrintLabelTokensRegistrarlabelTokensRegistrar;
	
	public void setSpecimenPrintLabelTokensRegistrarsetLabelTokensRegistrar(LabelTmplTokenRegistrar specimenPrintLabelTokensRegistrarlabelTokensRegistrar) {
		this.specimenPrintLabelTokensRegistrarlabelTokensRegistrar = specimenPrintLabelTokensRegistrarlabelTokensRegistrar;
	}

	@Override
	public void afterPropertiesSet() throws Exception {
		specimenPrintLabelTokensRegistrarlabelTokensRegistrar.register(new SpecimenCollectionContainerPrintToken());	// Here replace SpecimenCollectionContainerPrintToken() with your class.

	}
}

 

      3. After adding this plugin initializer class you also need to define this bean in the spring context file located at PLUGIN_HOME/src/main/resources/pluginContext.xml. Following example describes how to define this bean:

Code Block
<bean id="pluginInitializer" class="com.krishagni.openspecimen.plugin.init.PluginInitializer">
  <property name="specimenPrintLabelTokensRegistrarlabelTokensRegistrar" ref="specimenPrintLabelTokensRegistrar"/>
</bean>


In above bean specimenPrintLabelTokensRegistrar is to register specimen print label token. Replace registrar bean name according to your label token type by referring below list

Label TypeRegistrar Bean
PPID Label Token
ppidTokensRegistrar
Specimen Label Token
specimenTokenRegistrar
Visit Label Token
visitTokenRegistrar