🔍 Code Extractor

function get_lims_sampletestresultdetails_with_references_samples_lims_samples

Maturity: 40

Queries a Neo4j graph database to retrieve LIMS_Samples nodes that are connected to a specific LIMS_SampleTestResultDetails node through a REFERENCES_SAMPLES relationship.

File:
/tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
Lines:
1257 - 1264
Complexity:
simple

Purpose

This function is designed to traverse a Laboratory Information Management System (LIMS) graph database to find sample records associated with specific test result details. It's useful for tracking which samples are referenced by particular test results, enabling data lineage and relationship analysis in laboratory data management systems.

Source Code

def get_lims_sampletestresultdetails_with_references_samples_lims_samples(source_id, limit=100):
    """Get LIMS_Samples nodes connected to a LIMS_SampleTestResultDetails via REFERENCES_SAMPLES"""
    query = """
    MATCH (source:LIMS_SampleTestResultDetails {id: $source_id})-[r:REFERENCES_SAMPLES]->(target:LIMS_Samples)
    RETURN target
    LIMIT $limit
    """
    return run_query(query, {"source_id": source_id, "limit": limit})

Parameters

Name Type Default Kind
source_id - - positional_or_keyword
limit - 100 positional_or_keyword

Parameter Details

source_id: The unique identifier (id property) of the LIMS_SampleTestResultDetails node from which to start the traversal. This should be a string or value that matches the 'id' property in the Neo4j database.

limit: Maximum number of LIMS_Samples nodes to return. Defaults to 100. This parameter controls query performance and prevents returning excessively large result sets. Must be a positive integer.

Return Value

Returns the result of run_query() function, which typically contains a list or collection of Neo4j records representing LIMS_Samples nodes. Each record contains the 'target' node with all its properties. The exact return type depends on the run_query() implementation, but commonly returns a list of dictionaries or Neo4j Record objects. Returns an empty collection if no matching samples are found or if the source_id doesn't exist.

Dependencies

  • neo4j

Required Imports

from neo4j import GraphDatabase

Usage Example

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

# Define run_query helper function (example implementation)
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['target'] for record in result]
    driver.close()

# Use the function to get samples for a specific test result
test_result_id = 'TEST_RESULT_12345'
samples = get_lims_sampletestresultdetails_with_references_samples_lims_samples(test_result_id, limit=50)

# Process the results
for sample in samples:
    print(f"Sample ID: {sample['id']}, Properties: {sample}")

Best Practices

  • Always validate that source_id exists before calling this function to avoid unnecessary database queries
  • Use appropriate limit values based on expected data volume to optimize query performance
  • Ensure proper error handling around the run_query() call to catch database connection issues
  • Consider implementing pagination for large result sets instead of increasing the limit parameter
  • Verify that the Neo4j database schema includes the expected node labels (LIMS_SampleTestResultDetails, LIMS_Samples) and relationship type (REFERENCES_SAMPLES)
  • Close database connections properly in the run_query() implementation to prevent resource leaks
  • Consider adding indexes on the 'id' property of LIMS_SampleTestResultDetails nodes for better query performance

Similar Components

AI-powered semantic similarity - components with related functionality:

  • function get_lims_sampletestresults_with_references_samples_lims_samples 97.2% similar

    Queries a Neo4j graph database to retrieve LIMS_Samples nodes that are connected to a specific LIMS_SampleTestResults node through a REFERENCES_SAMPLES relationship.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_lims_sampletestresults_with_references_testparameters_lims_testparameters 88.7% similar

    Queries a Neo4j graph database to retrieve LIMS_Testparameters nodes that are connected to a specific LIMS_SampleTestResults node through a REFERENCES_TESTPARAMETERS relationship.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_lims_samples_with_references_sampletypes_lims_sampletypes 87.9% similar

    Queries a Neo4j graph database to retrieve LIMS_SampleTypes nodes that are connected to a specific LIMS_Samples node through a REFERENCES_SAMPLETYPES relationship.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_lims_samples_with_references_requests_lims_requests 87.3% similar

    Queries a Neo4j graph database to retrieve LIMS_Requests nodes that are connected to a specific LIMS_Samples node via a REFERENCES_REQUESTS relationship.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_lims_sampletypetests_with_references_tests_lims_tests 86.1% similar

    Queries a Neo4j graph database to retrieve LIMS_Tests nodes that are connected to a specific LIMS_SampleTypeTests node through a REFERENCES_TESTS relationship.

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