🔍 Code Extractor

function get_lims_requests_with_references_establishment_dbo_establishment

Maturity: 42

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

File:
/tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
Lines:
1225 - 1232
Complexity:
simple

Purpose

This function is designed to traverse a graph database to find establishment records referenced by a Laboratory Information Management System (LIMS) request. It's useful for tracking which establishments are associated with specific laboratory requests, enabling data lineage and relationship analysis in a LIMS context. The function supports pagination through a configurable limit parameter.

Source Code

def get_lims_requests_with_references_establishment_dbo_establishment(source_id, limit=100):
    """Get dbo_Establishment nodes connected to a LIMS_Requests via REFERENCES_ESTABLISHMENT"""
    query = """
    MATCH (source:LIMS_Requests {id: $source_id})-[r:REFERENCES_ESTABLISHMENT]->(target:dbo_Establishment)
    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 of the LIMS_Requests node to query from. This should be a string or value that matches the 'id' property of a LIMS_Requests node in the Neo4j database.

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

Return Value

Returns the result of the run_query function, which typically contains a list or collection of dbo_Establishment nodes that match the query criteria. 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 properties of the matched dbo_Establishment nodes. Returns an empty collection if no matching establishments are found.

Dependencies

  • neo4j

Required Imports

from neo4j import GraphDatabase

Usage Example

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

# Example run_query implementation (must be defined before use)
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()

# Get establishments referenced by LIMS request with ID 'REQ-12345'
establishments = get_lims_requests_with_references_establishment_dbo_establishment('REQ-12345', limit=50)

# Process the results
for establishment in establishments:
    print(f"Establishment: {establishment}")

Best Practices

  • Ensure the run_query function is properly implemented with error handling and connection management
  • Use appropriate limit values to avoid performance issues with large datasets
  • Validate that source_id exists before calling to avoid unnecessary database queries
  • Consider implementing connection pooling for the Neo4j driver if making multiple queries
  • Handle cases where no establishments are found (empty result set)
  • Ensure proper authentication and authorization for Neo4j database access
  • Consider adding error handling for database connection failures
  • The limit parameter should be validated to ensure it's a positive integer

Similar Components

AI-powered semantic similarity - components with related functionality:

  • function get_lims_samples_with_references_establishment_dbo_establishment 93.0% similar

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

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function create_references_establishment_relationship 85.3% similar

    Creates a REFERENCES_ESTABLISHMENT relationship in a Neo4j graph database between a LIMS_Requests node and a dbo_Establishment node, with optional properties on the relationship.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function create_references_establishment_relationship_v1 81.2% similar

    Creates a REFERENCES_ESTABLISHMENT relationship in a Neo4j graph database between a LIMS_Samples node and a dbo_Establishment node, with optional properties on the relationship.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_lims_samples_with_references_requests_lims_requests 79.0% 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_dbo_establishmentcycles_with_references_establishment_dbo_establishment 78.9% similar

    Queries a Neo4j graph database to retrieve dbo_Establishment nodes that are connected to a specific dbo_EstablishmentCycles node through a REFERENCES_ESTABLISHMENT relationship.

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