This article will cover what internal reports are, how to enable and configure them using the code editor, and how to run them.
In QBench there are two primary forms of reports: 1) for your laboratory's results which is generally intended for a customer (internal or external) to get their results for a given sample (commonly referred to as a Certificate of Analysis), and 2) reports on the data in your LIMS that are generally intended for management to review how the laboratory if performing, etc. This article will cover the latter use case with something called "Internal Reports" in QBench.
Internal reports are created similarly to other template-generated items in QBench, however, they additionally support the ability to easily print the report contents, and are not automatically generated to PDF.
Enable Internal Reports
To use, create, or edit internal reports you must first enable them by going to the Configuration > Application > General, and check the box labeled "Enable Internal Reports".
Note that you will need to first configure an internal report before they will be available in the user interface (we're working on having several internal reports available out-of-the-box soon :) ).
How to Run Internal Reports
To run an internal reports first make sure they are enabled and that at least one report exists and is active in your site. Then go to "Analytics" > "Internal Reports" > then select the report you'd like to run. The screenshot below shows how to run a report called "My Internal Report"
How to Configure an Internal Report
We will now go through the process of setting up a basic internal report that will show three metrics, for a selected time period (time period selection, among other criteria, is built into the Internal Report interface):
- Overall Turnaround Time
- Number of Samples Received
- Number of Samples Completed
Steps
- Create a new Internal Report by navigating to "Configuration" > "Application" > "Templates" > "Internal Reports", and click on the button to create a new Internal Report.
- Navigate to the "Filter Config" tab and add a new filter for Order, Date Created.
- This will be the date range we filter by to retrieve the data for our Internal Report
- Navigate to the "Design" tab and add this code into the Code Editor
<link href="//dpe4x5tiyshba.cloudfront.net/qbenchassets/qbc/assets/css/bootstrap-qbench-12pt.min.css" rel="stylesheet" type="text/css" />
{# get the data based on the filter params #}
{% set orders = QBOrderService().get_list(params.get('order')) %}
{# process data #}
{% set samples_received = [] %}
{% set samples_completed = [] %}
{% set test_tat = [] %}
{% for order in orders %}
{% for sample in order.samples %}
{% if sample.received %}
{% set _ = samples_received.append(sample) %}
{% endif %}
{% if sample.complete %}
{% set _ = samples_completed.append(sample) %}
{% endif %}
{% for test in sample.tests %}
{% if test.complete_date and order.date_received %}
{% set _ = test_tat.append((test.complete_date.date() - order.date_received.date()).days) %}
{% endif %}
{% endfor %}
{% endfor %}
{% endfor %}
{% set tat_ns = namespace(tat_summed=0) %}
{% for tat in test_tat %}
{% set tat_ns.tat_summed = tat_ns.tat_summed + tat %}
{% endfor %}
{% set average_tat = tat_ns.tat_summed / test_tat|length %}
<h2>Lab Samples Stats</h2>
<div>
<table class="table">
<thead>
<th>Average Turnaround Time</th>
<th>Number of Samples Received</th>
<th>Number of Samples Completed</th>
</thead>
<tbody>
<tr>
<td>{{ average_tat }} days</td>
<td>{{ samples_received|length }}</td>
<td>{{ samples_completed|length }}</td>
</tr>
</tbody>
</table>
</div>
{% macro generate_sample_row(sample) %}
<tr>
<td>{{ sample.get_display_id() }}</td>
<td>{{ sample.order.get_display_id() }}</td>
<td>{{ sample.tests|length }}</td>
</tr>
{% endmacro %}
<h2>Samples Received</h2>
<div>
<table class="table">
<thead>
<th>Sample ID</th>
<th>Order ID</th>
<th>Number of Tests</th>
</thead>
<tbody>
{% for sample in samples_received %}
{{ generate_sample_row(sample) }}
{% endfor %}
</tbody>
</table>
</div>
<h2>Samples Complete</h2>
<div>
<table class="table">
<thead>
<th>Sample ID</th>
<th>Order ID</th>
<th>Number of Tests</th>
</thead>
<tbody>
{% for sample in samples_completed %}
{{ generate_sample_row(sample) }}
{% endfor %}
</tbody>
</table>
</div>
* Some important notes about this template code
- "QBOrderService" is one of the many classes that are available to you when building an Internal Report. This class has two functions ("get()" and "get_list()") that can be used to retrieve data for your Report.
- A variable called "params" is passed into every Internal Report Template. This variable stores the filter selections that the user selects when generating an Internal Report.
- Save this as a new version and make the version active.
- Now, click on "Analytics" > "Internal Reports" > "Samples Report" in the nav bar to take you to the page to generate the report.
- You will be prompted to enter a date range for when some Orders were created.
- After you have chosen a date range, hit submit and your Internal Report will begin generating.
QB Service Classes
- QBOrderService
- QBSampleService
- QBTestService
- QBInvoiceService
- QBBatchService
- QBInventoryItemService
- QBInventoryStockService
- QBEquipmentService
- QBLogTypeService
- QBLogEntryService
Comments
0 comments
Article is closed for comments.