🔍 Code Extractor

function get_lims_sampletestresultdetails_by_id

Maturity: 39

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

File:
/tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
Lines:
187 - 194
Complexity:
simple

Purpose

This function queries a Neo4j database to fetch a specific LIMS (Laboratory Information Management System) sample test result details record. It's designed for retrieving detailed test result information for a particular sample using its ID. The function returns the first matching node or None if no match is found, making it useful for data retrieval operations in laboratory data management systems.

Source Code

def get_lims_sampletestresultdetails_by_id(id):
    """Get a LIMS_SampleTestResultDetails node by its ID"""
    query = """
    MATCH (n:LIMS_SampleTestResultDetails {id: $id})
    RETURN n
    """
    result = run_query(query, {"id": id})
    return result[0] if result else None

Parameters

Name Type Default Kind
id - - positional_or_keyword

Parameter Details

id: The unique identifier of the LIMS_SampleTestResultDetails node to retrieve. Expected to be a string or integer value that matches the 'id' property of nodes in the Neo4j database. This should correspond to a valid sample test result details record identifier.

Return Value

Returns a dictionary-like object representing the LIMS_SampleTestResultDetails node if found, containing all properties of the matched node. Returns None if no node with the specified ID exists. The exact structure depends on the properties stored in the Neo4j node, but typically includes test result details such as measurements, timestamps, and related metadata.

Dependencies

  • neo4j

Required Imports

from neo4j import GraphDatabase

Usage Example

from neo4j import GraphDatabase

# Assuming run_query function is defined
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['n'] for record in result]
    driver.close()

# Use the function
result_details = get_lims_sampletestresultdetails_by_id('SAMPLE_001')
if result_details:
    print(f'Found test result: {result_details}')
else:
    print('No test result found with that ID')

Best Practices

  • Ensure the 'run_query' helper function is properly implemented with error handling and connection management
  • Validate the 'id' parameter before passing it to prevent injection attacks or invalid queries
  • Consider adding error handling for database connection failures
  • The function assumes 'run_query' returns a list; ensure this contract is maintained
  • Consider adding type hints for better code documentation (e.g., def get_lims_sampletestresultdetails_by_id(id: str) -> Optional[Dict])
  • Close Neo4j driver connections properly to avoid resource leaks
  • Consider caching frequently accessed nodes to reduce database load

Similar Components

AI-powered semantic similarity - components with related functionality:

  • function get_lims_sampletestresults_by_id 93.3% similar

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

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_lims_sampletestresultdetails_by_uid 90.4% similar

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

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_all_lims_sampletestresultdetails 87.4% similar

    Queries a Neo4j graph database to retrieve LIMS_SampleTestResultDetails nodes with a configurable limit on the number of results returned.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_lims_samples_by_id 86.0% similar

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

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_lims_sampletestresults_by_uid 85.3% 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