🔍 Code Extractor

function get_all_lims_sampletestresultdetails

Maturity: 40

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

File:
/tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
Lines:
178 - 185
Complexity:
simple

Purpose

This function is designed to fetch Laboratory Information Management System (LIMS) sample test result details from a Neo4j graph database. It executes a Cypher query to match all nodes labeled as LIMS_SampleTestResultDetails and returns them with a limit on the result set size. This is useful for retrieving test result metadata, exploring the database structure, or performing batch operations on sample test results. The function relies on an external run_query function to execute the Cypher query against the Neo4j database.

Source Code

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

Parameters

Name Type Default Kind
limit - 100 positional_or_keyword

Parameter Details

limit: An integer that specifies the maximum number of LIMS_SampleTestResultDetails nodes to return from the query. Default value is 100. Note: The docstring incorrectly states the limit is 25, but the actual default is 100. This parameter helps prevent overwhelming the system with large result sets and allows for pagination-style data retrieval.

Return Value

Returns the result of the run_query function execution, which typically contains a list or collection of Neo4j node objects representing LIMS_SampleTestResultDetails. The exact return type depends on the implementation of run_query, but it likely returns a list of dictionaries or Neo4j Record objects containing the node properties. The number of results will not exceed the specified limit parameter.

Dependencies

  • neo4j

Required Imports

from neo4j import GraphDatabase

Usage Example

from neo4j import GraphDatabase

# Assuming run_query is defined elsewhere
def run_query(query, params):
    driver = GraphDatabase.driver('bolt://localhost:7687', auth=('neo4j', 'password'))
    with driver.session() as session:
        result = session.run(query, params)
        return [record['n'] for record in result]
    driver.close()

# Get default 100 results
results = get_all_lims_sampletestresultdetails()
print(f'Retrieved {len(results)} sample test result details')

# Get only 10 results
limited_results = get_all_lims_sampletestresultdetails(limit=10)
for node in limited_results:
    print(node)

Best Practices

  • The docstring incorrectly states the limit is 25 when the default is actually 100 - this should be corrected for consistency
  • Always specify an appropriate limit value based on your use case to avoid memory issues with large datasets
  • Ensure the run_query function properly handles database connections and closes them to prevent connection leaks
  • Consider adding error handling for cases where the database is unavailable or the query fails
  • The function depends on run_query being defined elsewhere - ensure this dependency is available before calling
  • For production use, consider adding pagination support (offset parameter) to retrieve large datasets in chunks
  • Add return type annotations for better code documentation and IDE support

Similar Components

AI-powered semantic similarity - components with related functionality:

  • function get_all_lims_sampletestresults 93.7% similar

    Retrieves LIMS_SampleTestResults 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
  • function get_all_lims_samples 88.6% 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_tests 88.1% 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_lims_sampletestresultdetails_by_id 87.4% similar

    Retrieves a single LIMS_SampleTestResultDetails node from a Neo4j graph database by its unique identifier.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_all_lims_testparameters 86.1% 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