Filter Processes by Date and Type

Workflows, chemistry, hardware, and software are continually changing in the lab. As a result, you can determine which samples were processed after a specific change happened.

Using the processes (list) resource you can construct a query that filters the list using both process type and date modified.

Prerequisites

Before you follow the example, make sure you have the following items:

  • Samples that have been added to the system.

  • Multiple processes of the Cookbook Example type that have been run on different dates.

  • A compatible version of API (v2 r21 or later).

Code Example

In Clarity LIMS, when you search for a specific step type, the search results list shows all steps of that type that have been run, along with detailed information about each one. This information includes the protocol that includes the step, the number of samples in the step, the step LIMS ID, and the date the step was run.

The following screenshot shows the search results for the step type Denature and Anneal RNA (TruSight Tumor 170 v1.0).

The list shows the date run for each step, but not the last modified date. This is because a step can be modified after it was run, without changing the date on which it was run.

To find the steps that meet the two criteria (step type and date modified), you must to do the following steps:

  1. Request a list of all steps (processes), filtered on process type and date modified.

  2. Once you have the list of processes, you can use a script to print the LIMS ID for each process.

Step 1. List processes of a specific type that were modified after a specified date

To request a list of all processes of a specific type that were modified after a specified date, use a GET method that uses both the ?type and ?last-modified filter on the processes resource:

// Retrieve a date and format it to a string
c = Calendar.getInstance()
c.add(Calendar.WEEK_OF_YEAR, -1)
df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")
time = df.format(c.getTime())
time = URLEncoder.encode(time, "UTF-8")

 
// Retrieve the processes that were last-modified in the given date range
processesURI = "http://${hostname}/api/v2/processes?type=Denature%20and%20Anneal%20RNA%20%28TruSight%20Tumor%20170%20v1.0%29&last-modified=" + time
processes = GLSRestApiUtils.httpGET(processesURI, username, password)

The GET call returns a list of the first 500 processes that match the filter specified. If more than 500 processes match the filter, only the first 500 are available from the first page.

In the XML returned, each process is an element in the list. Each element contains the URI for the individual process resource, which includes the LIMS ID for the process.

The URI for the list of all processes is http://yourIPaddress/api/processes. In the example code, the list was filtered by appending the following:

?type=Denature%20and%20Anneal%20RNA%20%28TruSight%20Tumor%20170%20v1.0%29&last-modified= + time

This filters the list to show only processes that are of the Cookbook Example type and were modified after the specified date.

The date must be specified in ISO 8601, including the time. In the example, this is accomplished using an instance of a Calendar object and a SimpleDateFormat object, and encoding the date using UTF-8. The date specified is one week prior to the time the code is executed.

All of the REST list resources are paged. Only the first 500 items are returned when you query for a list of items, such as http://youripaddress/api/v2/artifacts.

If you cannot filter the list, you must iterate through the pages of a list resource to find the items that you are looking for. The URI for the next page of resources is always the last element on the page of a list resource.

After requesting an individual process XML resource, you have access to a large collection of data that lets you modify or view each process. Within the process XML, you can also access the artifacts that were inputs or outputs of the process.

After running the script on the command line, output is be generated showing the LIMS ID for each process in the list.

Last updated