🔍 Code Extractor

function get_lims_parameters_by_uid

Maturity: 39

Retrieves a LIMS_Parameters node from a Neo4j graph database by searching for a specific UID (unique identifier).

File:
/tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
Lines:
79 - 86
Complexity:
simple

Purpose

This function queries a Neo4j database to fetch a single LIMS_Parameters node that matches the provided UID. It's designed for Laboratory Information Management System (LIMS) data retrieval, allowing users to access parameter configurations or settings stored in the graph database. The function returns the first matching node or None if no match is found.

Source Code

def get_lims_parameters_by_uid(uid):
    """Get a LIMS_Parameters node by its UID"""
    query = """
    MATCH (n:LIMS_Parameters {UID: $uid})
    RETURN n
    """
    result = run_query(query, {"uid": uid})
    return result[0] if result else None

Parameters

Name Type Default Kind
uid - - positional_or_keyword

Parameter Details

uid: The unique identifier (UID) of the LIMS_Parameters node to retrieve. Expected to be a string or value that matches the UID property stored in the Neo4j database. This should be a valid identifier that exists in the database's LIMS_Parameters nodes.

Return Value

Returns a dictionary-like object representing the LIMS_Parameters node if found, containing all properties of the matched node. Returns None if no node with the specified UID exists. The exact structure depends on the properties stored in the LIMS_Parameters node in the database.

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, parameters):
    with driver.session() as session:
        result = session.run(query, parameters)
        return [record['n'] for record in result]

# Using get_lims_parameters_by_uid
uid_to_search = 'LIMS-12345'
parameters = get_lims_parameters_by_uid(uid_to_search)

if parameters:
    print(f'Found parameters: {parameters}')
else:
    print(f'No parameters found for UID: {uid_to_search}')

Best Practices

  • Ensure the run_query function is properly implemented with error handling and connection management
  • Validate the uid parameter before passing it to prevent injection attacks or invalid queries
  • Consider adding error handling for database connection failures or query execution errors
  • The function assumes run_query returns a list; ensure this contract is maintained
  • Close Neo4j driver connections properly when the application terminates
  • Consider adding logging for debugging database queries
  • Verify that the UID exists before attempting retrieval to avoid unnecessary database queries

Similar Components

AI-powered semantic similarity - components with related functionality:

  • function get_lims_testparameters_by_uid 94.5% similar

    Retrieves a LIMS_Testparameters node from a Neo4j graph database by matching its unique identifier (UID).

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

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

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_lims_requests_by_uid 88.0% similar

    Retrieves a single LIMS_Requests node from a Neo4j graph database by matching its unique identifier (UID).

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_lims_samples_by_uid 86.6% similar

    Retrieves a single LIMS_Samples node from a Neo4j graph database by matching its unique identifier (UID).

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_lims_pathogens_by_uid 86.5% similar

    Retrieves a single LIMS_Pathogens node from a Neo4j graph database by matching its unique identifier (UID).

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