Versions Compared

Key

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

Table of Contents

Introduction

...

  1. Using REST APIs.
  2. Java Spring
  3. Angular JS

...

  1. Install prerequisite software which can be downloaded from http://demo.openspecimen.org/releases/

Prerequisites

...

...

View file
nameos-plugin.zip
height250

...

Prerequisites

Following table lists prerequisites and their supported versions.

...

Keyword

Comment

PLUGIN_HOME

Directory where plugin source code is kept. For example, F:\os-plugin.

JAVA_HOME

Directory where JDK is installed. For example, C:\JDK1.8

Following are high level steps:

  1. Install prerequisite software which can be downloaded from http://demo.openspecimen.org/releases/Prerequisites/
  2. Download the plugin skeleton os-plugin.zip  
    View file
    nameos-plugin.zip
    height250
  3. Unzip the downloaded file into a directory.

Plugin directory structure

  1. src/main/java: All the custom java classes should got under this directory
  2. src/main/resources 
    2.1. errors/messages.properties: All the messages and labels should go in this file
    2.2. pluginContext.xml: All the bean definition should go in this file.
  3. build.gradle: This file contains the complete build script for compiling and building the plugin

Steps to add custom Java classes

...

  1. Please add all your Java classes under PLUGIN_HOME/src/main/java/com/krishagni/openspecimen
  2. All the Spring configuration should be done in PLUGIN_HOME/src/main/resources/pluginContext.xml

...

  1. Create a new project by using the attached skelton
  2. Import this project into any IDE like eclipse
  3. Add new class
    3.1 Add custom token implementation class named SpecimenCollectionProcedurePrintToken.java in package com.krishagni.openspecimen.plugin.token, like below:

    Code Block
    package com.krishagni.openspecimen.plugin.token;
    
    import com.krishagni.catissueplus.core.biospecimen.domain.Specimen;
    import com.krishagni.catissueplus.core.common.domain.AbstractLabelTmplToken;
    import com.krishagni.catissueplus.core.common.domain.LabelTmplToken;
    
    
    public class SpecimenCollectionProcedurePrintToken extends AbstractLabelTmplToken implements LabelTmplToken {
    
    	@Override
    	public String getName() {
    		return "specimen_collection_procedure";
    	}
    
    	@Override
    	public String getReplacement(Object object) {
    		Specimen specimen = (Specimen)object;
    		while (specimen.getParentSpecimen() != null) {
    			specimen = specimen.getParentSpecimen();
    		}
    
    		return specimen.getCollectionEvent().getProcedure();
    	}
    }
    
    


    3.2. Add message key for the newly added label token. To add the message key need to update messages.properties file available at PLUGIN_HOME/src/main/resources/errors. Below is the sample: Register the token into OpenSpecimen with LabelTmplTokenRegistrar. Below is the code:

     

    Code Block
    print_specimen_collection_procedure=Collection Proceudre
     
    Note: OpenSpecimen will use this value in the cmd files as the label for collection procedure value.

    3.3. Now we need to register the above token into OpenSpecimen with LabelTmplTokenRegistrar. First create a package com.krishagni.openspecimen.plugin.init and write a class named PluginInitializer. This class will register the above token implementation with OpenSpecimen

     

     

    Code Block
    package com.krishagni.openspecimen.plugin.init;
    
    import org.springframework.beans.factory.InitializingBean;
    
    import com.krishagni.catissueplus.core.common.domain.LabelTmplTokenRegistrar;
    import com.krishagni.openspecimen.plugin.token.SpecimenCollectionProcedurePrintToken;
    
    
    public class PluginInitializer implements InitializingBean {
      
      private LabelTmplTokenRegistrar specimenPrintLabelTokensRegistrar;
       
      public void setSpecimenPrintLabelTokensRegistrar(LabelTmplTokenRegistrar specimenPrintLabelTokensRegistrar) {
          this.specimenPrintLabelTokensRegistrar = specimenPrintLabelTokensRegistrar;
      }
    
      @Override
      public void afterPropertiesSet() throws Exception {
          specimenPrintLabelTokensRegistrar.register(new SpecimenCollectionProcedurePrintToken());
      }
    }
     

    3.4. We have created a custom class for the token and written a plugin initializer which will register the new token with the LabelTmplTokenRegistrar. To make Spring aware to load this class we need to update the spring context. For this we need to add below in file PLUGIN_HOME/src/main/resources/pluginContext.xml

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


     

  4. Now we are done with the coding. Its time to deploy and test the plugin. Open the command prompt and traverse to PLUGIN_HOME. Run below commands:
    4.1. gradle clean This will cleaup the classes and any unneccessary files
    4.2. gradle build This will create the plugin archive file at PLUGIN_HOME/build/libs/
  5. Copy the os-plugin.jar and place it under plugin directory
  6. Start the tomcat
  7. Update the default_specimen_print_rules.csv and specify the newly added token specimen_collection_procedure and update the print rules file path from the settings
  8. Access the OpenSpecimen application, select a specimen and print it. The output will looks like below:

    Code Block
    Label Type=Std
    Printer=default
    Label=P0001-1
    Specimen Type=Plasma
    Collection Procedure=Surgical Resection
    Location=Virtual

     

    You can download the complete working example from here: 

    View file
    nameos-plugin-token.zip
    height250