Adding scripts to templates

ClaimMaster lets you insert Javascript code sections into templates, giving you full control of claim language transformations. Currently, Javascript code can be added to claim cloning, Abstract, and Summary generation templates.




Below are the rules for inserting the Javascript code into templates.

  1. The code section needs be to enclosed in the <script> and </script> tags.  Only one code section is allowed per template, other code sections will be ignored.  You can insert the code section anywhere in the template and it will be evaluated first, with its resulting output being plugged back into the rest of the template before other replacement fields in the template are replaced with data.  Therefore, the output of the Javascript code can include other replacement fields, such as [DEVICENAME], [FUNCTION], etc.  Since the code is evaluated prior to other fields being replaced, they will also be replaced when the template is fully evaluated.


  1. The Javascript function that will be internally called by ClaimMaster is named transform_claim() - its name and parameters should not be changed in the code section.  transform_claim() must return a string, which is the result of the claim transformation.


  1. transform_claim() is currently passed 3 inputs:
    1. unchangedlims - an array of unchanged claim limitations
    2. changedlims - an array of limitations that have been conjugated/adjusted by the NLP engine
    3. fullclaimtext - a string containing the entire text of the claim

Using these inputs, you can perform essentially any transformation on the resulting text.  For example, you can use regular expressions and other Javascript operations to conditionally insert limitations based on the language that appears in the preamble, etc.  See sample templates shipped with ClaimMaster for example scripts or contact support for assistance.  We do recommend that you run your code through Javascript syntax validator, such as Esprima, to ensure the the code doesn't have any issues and can be evaluated.


  1. Below is the general format for inserting the code into a template:


---------- SOME TEMPLATE LANGUAGE GOES HERE ----------

<script>

function transform_claim (unchangedlims, changedlims, fullclaimtext) {

   

   var output = '';  

   DO SOME OPERATIONS ON THE CLAIM LIMITATIONS HERE

   return output;

}

</script>

---------- TEMPLATE CAN CONTINUE HERE----------


5.  You can also test your code directly from the template editor.  To do so, click on the Test button shown for any templates that allow insertion of code sections.



This will bring up ClaimMaster's code/template evaluator window, which will allow you to test the template against an arbitrary text input.  Once you are satisfied with the code, you can just copy & paste it back into the template.


The following functions are available in the template evaluator:



    1. In this text field you can type or copy & paste the claim you'd like to test your template on.
    2. Pressing this button will copy the text from the current selection in the open Word document into the field #1. 
    3. This text field contains the test template.  It can include both a code section and other replacement fields, such as [LIMS_CHANGED], [DEVICENAME], etc.
    4. These options specify whether the template is a claim cloning template or another type of template (e.g., for generating Specification, Abstract, etc.).
    5. This field shows the result of applying the claim template to the claim language shown in field #1.  If there are any Javascript parsing errors in your script, you'll see a message about Javascript syntax and a button with a link to the Javascript syntax checking website will become visible.
    6. Click this button to evaluate the template against the claim language in field #1.  The result will be shown in the field #5, above.