🔍 Code Extractor

function get_all_lims_sampletestresults

Maturity: 42

Retrieves LIMS_SampleTestResults nodes from a Neo4j graph database with a configurable limit on the number of results returned.

File:
/tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
Lines:
217 - 224
Complexity:
simple

Purpose

This function queries a Neo4j database to fetch all nodes labeled as LIMS_SampleTestResults. It's designed for Laboratory Information Management System (LIMS) data retrieval, allowing users to extract sample test result records from the graph database. The function uses Cypher query language and delegates execution to a run_query helper function. Note: There's a discrepancy between the docstring (which mentions limit of 25) and the actual default parameter (100).

Source Code

def get_all_lims_sampletestresults(limit=100):
    """Return LIMS_SampleTestResults nodes (limited to 25)"""
    query = """
    MATCH (n:LIMS_SampleTestResults)
    RETURN n
    LIMIT $limit
    """
    return run_query(query, {"limit": limit})

Parameters

Name Type Default Kind
limit - 100 positional_or_keyword

Parameter Details

limit: Integer value that controls the maximum number of LIMS_SampleTestResults nodes to return from the database query. Default is 100. Can be adjusted to retrieve fewer or more records depending on performance and data requirements. Must be a positive integer.

Return Value

Returns the result of run_query() function execution, which typically contains a list or collection of Neo4j node objects representing LIMS_SampleTestResults records. The exact return type depends on the implementation of run_query(), but commonly returns a list of dictionaries or Neo4j Record objects containing node properties. Returns up to 'limit' number of nodes.

Dependencies

  • neo4j

Required Imports

from neo4j import GraphDatabase

Usage Example

# Assuming run_query is defined and Neo4j connection is configured
# Example run_query implementation:
from neo4j import GraphDatabase

driver = GraphDatabase.driver('bolt://localhost:7687', auth=('neo4j', 'password'))

def run_query(query, params):
    with driver.session() as session:
        result = session.run(query, params)
        return [record['n'] for record in result]

# Using the function
results = get_all_lims_sampletestresults(limit=50)
print(f'Retrieved {len(results)} sample test results')

# Get default 100 results
all_results = get_all_lims_sampletestresults()

# Process results
for node in results:
    print(node)

Best Practices

  • The docstring incorrectly states 'limited to 25' but the default parameter is 100 - this should be corrected for consistency
  • Ensure the run_query() function properly handles database connections and exceptions
  • Consider adding error handling for database connection failures
  • The limit parameter should be validated to ensure it's a positive integer
  • For large datasets, consider implementing pagination instead of relying solely on LIMIT
  • Close Neo4j driver connections properly when done to avoid resource leaks
  • Consider adding type hints for better code documentation (e.g., def get_all_lims_sampletestresults(limit: int = 100) -> list:)
  • The function name could be more concise (e.g., get_lims_test_results) while maintaining clarity

Similar Components

AI-powered semantic similarity - components with related functionality:

  • function get_all_lims_sampletestresultdetails 93.7% similar

    Queries a Neo4j graph database to retrieve LIMS_SampleTestResultDetails nodes with a configurable limit on the number of results returned.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_all_lims_tests 91.7% similar

    Queries a Neo4j graph database to retrieve LIMS_Tests nodes with a configurable limit on the number of results returned.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_all_lims_samples 91.5% similar

    Queries a Neo4j graph database to retrieve LIMS_Samples nodes with a configurable limit on the number of results returned.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_all_lims_sampletypetests 89.7% similar

    Queries a Neo4j graph database to retrieve LIMS_SampleTypeTests nodes with a configurable limit on the number of results returned.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_all_lims_testparameters 88.4% similar

    Retrieves LIMS_Testparameters nodes from a Neo4j graph database with a configurable limit on the number of results returned.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
← Back to Browse