🔍 Code Extractor

function get_lims_sampletypeproperties_by_uid

Maturity: 39

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

File:
/tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
Lines:
274 - 281
Complexity:
simple

Purpose

This function queries a Neo4j database to fetch a specific LIMS_SampleTypeProperties node using its UID. It's designed for Laboratory Information Management System (LIMS) applications where sample type properties need to be retrieved by their unique identifier. The function returns the first matching node or None if no match is found.

Source Code

def get_lims_sampletypeproperties_by_uid(uid):
    """Get a LIMS_SampleTypeProperties node by its UID"""
    query = """
    MATCH (n:LIMS_SampleTypeProperties {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_SampleTypeProperties 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, existing UID in the database.

Return Value

Returns a dictionary-like object representing the LIMS_SampleTypeProperties node if found, containing all properties of the node. Returns None if no node with the specified UID exists. The exact structure depends on the properties stored in the Neo4j node, but will include at least the UID property.

Dependencies

  • neo4j

Required Imports

from neo4j import GraphDatabase

Usage Example

# Assuming run_query function is defined and Neo4j is configured
# Example run_query implementation:
# def run_query(query, params):
#     driver = GraphDatabase.driver(uri, auth=(user, password))
#     with driver.session() as session:
#         result = session.run(query, params)
#         return [record['n'] for record in result]

from neo4j import GraphDatabase

# Retrieve a sample type properties node by UID
uid = "sample-type-123"
sample_properties = get_lims_sampletypeproperties_by_uid(uid)

if sample_properties:
    print(f"Found sample properties: {sample_properties}")
else:
    print(f"No sample properties found for UID: {uid}")

Best Practices

  • Ensure the run_query function is properly implemented with error handling and connection management
  • Validate the uid parameter before passing it to avoid injection attacks or invalid queries
  • Handle the None return value appropriately in calling code to avoid NoneType errors
  • Consider adding error handling for database connection failures
  • Use connection pooling for better performance in production environments
  • Consider adding logging for debugging and monitoring database queries
  • Ensure proper Neo4j driver cleanup and session management in the run_query implementation

Similar Components

AI-powered semantic similarity - components with related functionality:

  • function get_lims_sampletypes_by_uid 93.0% 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_sampletypeproperties_by_id 90.5% similar

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

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_lims_sampletypetests_by_uid 89.5% similar

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

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