# Accession Kit Lots

The Clarity LIMS NGS Extensions Package includes the *AccessionReagentKitLots* script, which automates the accessioning of reagent lots based on container names. This section provides details on the script and its parameters, and LIMS configuration requirements.

## Script Overview

Designed for use in automated workflows, the *AccessionReagentKitLots* creates a new reagent lot, matching the Reagent Kit Name specified in the command line to a reagent kit configured in the LIMS.

The script populates the lot details according to the following logic (see [Script Parameters](#script-parameters) section for details):

* Lot Name = Lot name (specified by *lotName* parameter)
* Lot Number = Container name (specified by *from* parameter)
* Expires = now + expiry days (specified by *expiryDays* parameter)
* Status of Reagent Lot toggle switch is set to Active

Before accessioning the reagent lot, the script verifies that:

* The *expiryDays* parameter value is greater than 0, and is a whole number
* The reagent lot does not already exist in the LIMS - lots are not reusable.

The script checks whether there is an existing reagent lot in the LIMS that matches the combination of lot name + lot number provided. If so, validation fails. (Kit name is not checked during this validation process.)

If a unique combination of lot name + lot number is provided, the LIMS creates the new lot—even if there are already lots in the LIMS matching either the name or the number.

Note that it is therefore possible to create both of these lots:

* Lot 'ABC' with number '123'
* Lot 'ABD' with number '123'

## Script Parameters

| **Parameter**                                               | **Description**                                                                                                                                                                                                                                                                                                   |
| ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p>-u {username}<br>-username {username}</p>                | (Required) LIMS login username                                                                                                                                                                                                                                                                                    |
| <p>-p {password}<br>-password {password}</p>                | (Required) LIMS login password                                                                                                                                                                                                                                                                                    |
| <p>-i {stepURI:v2}<br>-stepURI {stepURI:v2}</p>             | (Required) LIMS step URI                                                                                                                                                                                                                                                                                          |
| <p>-log {logFileLIMSID}<br>-logFileName {logFileLIMSID}</p> | (Required) LIMS ID of the log file placeholder                                                                                                                                                                                                                                                                    |
| -from \<outputContainer / inputContainer>                   | <p>(Required) Must be either 'outputContainer' or 'inputContainer'.<br>This dictates where the 'Container Name' value is copied from. This is used to create the lot number.<br>Only supports output containers on steps that output samples. See <a href="#rules-and-constraints">Rules and Constraints</a>.</p> |
| -reagentKit \<Reagent Kit Name>                             | (Required) Reagent Kit name on which the generated lot is based.                                                                                                                                                                                                                                                  |
| -lotName \<Reagent Lot Name>                                | (Required) Reagent Lot name to assign to the lot                                                                                                                                                                                                                                                                  |
| -expiryDays <#>                                             | (Required) Number of days the lot's expiry date will be set to. Must be greater than zero (script checks for this).                                                                                                                                                                                               |
| <p>-t \<true/false><br>-testMode \<true/false></p>          | (Optional) Runs script in test mode. Script is triggered manually via button on Record Details screen. Defaults to false.                                                                                                                                                                                         |

## Command Line Example

<details>

<summary>Example</summary>

{% code overflow="wrap" %}

```markup
bash -c "/opt/gls/clarity/bin/java -jar /opt/gls/clarity/extensions/ngs-common/v5/EPP/ngs-extensions.jar -i {stepURI:v2:http}
-u {username} -p {password} script:accessionReagentKitLots -log {compoundOutputFileLuid0} -from 'outputContainer'
-reagentKit '' -lotName '' -expiryDays <#>"
```

{% endcode %}

</details>

## Configuration

The following sections describe the configuration intended to support the *AccessionReagentKitLots* script.

**Master Step Custom Fields**

Configure master step custom fields (step UDFs in v4.x) for reagent kit name and lot name, and display them in the Step Details area of the Record Details screen. When running the step, the user fills in these values and they are supplied to the *reagentKit* and *lotName* parameters in the script. In this scenario, configure the automation command line as follows:

{% code overflow="wrap" %}

```markup
script:accessionReagentKitLots -log {compoundOutputFileLuid0} -from 'outputContainer'
-reagentKit '' -lotName '' -expiryDays <#>"
```

{% endcode %}

**Automation trigger**

The script is intended to be automatically triggered at the end of a step. However, you may include the -t option to run the script in test mode and trigger the script via button on the Record Details screen.

## Rules and Constraints

* Reagent Kit Name specified in the command line must match a reagent kit configured in the LIMS.
* *expiryDays* parameter value must meet the following criteria:
  * Must be a whole number greater than 0.
  * Must be a numeric value (i.e., '1' not 'one').
* When specifying the *from* parameter, note that the script only supports the value 'outputContainer' if the step outputs are samples. Step output measurement records with placement are not supported.
* Accessioning reagent lots with this script sets each reagent lot status to Active until the expiry date is reached. You cannot use the script to add reagent lots with status set to Pending.
* The step should only be run with a single container matching the *from* definition.
* If *from* is defined as the output container, the step can have multiple input containers but all samples must be placed in the same output/destination container. This is because the script only looks up a single container name. If there are multiple output containers in the step, the script will not fail; however, it will choose a container arbitrarily, which could result in unexpected behavior/results.
