🔍 Code Extractor

function get_lims_sampletypetests_by_uid

Maturity: 37

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

File:
/tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
Lines:
313 - 320
Complexity:
simple

Purpose

This function queries a Neo4j database to fetch a specific LIMS_SampleTypeTests node using its UID. It's designed for Laboratory Information Management System (LIMS) data retrieval, specifically for accessing sample type test configurations or records. The function returns the first matching node or None if no match is found.

Source Code

def get_lims_sampletypetests_by_uid(uid):
    """Get a LIMS_SampleTypeTests node by its UID"""
    query = """
    MATCH (n:LIMS_SampleTypeTests {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_SampleTypeTests node to retrieve. Expected to be a string or value that matches the UID property in the Neo4j database. This should be a valid, existing UID in the database.

Return Value

Returns a dictionary representing the LIMS_SampleTypeTests node if found, containing all properties of the node. Returns None if no node with the specified UID exists. The exact structure of the returned dictionary depends on the properties stored in the Neo4j node.

Dependencies

  • neo4j

Required Imports

from neo4j import GraphDatabase

Usage Example

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

# Example usage
uid_to_search = "12345-ABCDE"
result = get_lims_sampletypetests_by_uid(uid_to_search)

if result:
    print(f"Found node: {result}")
    # Access node properties
    # print(f"Node UID: {result['UID']}")
else:
    print(f"No LIMS_SampleTypeTests node found with 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
  • Handle the None return value appropriately in calling code to avoid NoneType errors
  • Consider adding logging for debugging database queries and results
  • Ensure proper Neo4j connection pooling and resource cleanup in the run_query implementation
  • The function assumes run_query returns a list; verify this assumption matches your implementation

Similar Components

AI-powered semantic similarity - components with related functionality:

  • function get_lims_sampletypes_by_uid 92.5% similar

    Retrieves a single LIMS_SampleTypes 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_tests_by_uid 92.1% similar

    Retrieves a single LIMS_Tests 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_sampletestresults_by_uid 91.7% similar

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

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_lims_sampletypetests_by_id 91.4% similar

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

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_lims_samples_by_uid 89.7% 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
← Back to Browse