function get_lims_sampletestresultdetails_by_uid
Retrieves a LIMS_SampleTestResultDetails node from a Neo4j graph database by its unique identifier (UID).
/tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
196 - 203
simple
Purpose
This function queries a Neo4j database to fetch a specific LIMS_SampleTestResultDetails node using its UID. It's designed for Laboratory Information Management System (LIMS) data retrieval, specifically for accessing detailed test result information for samples. The function returns the first matching node or None if no match is found.
Source Code
def get_lims_sampletestresultdetails_by_uid(uid):
"""Get a LIMS_SampleTestResultDetails node by its UID"""
query = """
MATCH (n:LIMS_SampleTestResultDetails {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_SampleTestResultDetails 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 to return results.
Return Value
Returns a dictionary-like object representing the LIMS_SampleTestResultDetails 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 typically includes test result details, sample information, and metadata.
Dependencies
neo4j
Required Imports
from neo4j import GraphDatabase
Usage Example
# Assuming run_query function is defined and Neo4j is configured
# Example run_query implementation:
from neo4j import GraphDatabase
driver = GraphDatabase.driver('bolt://localhost:7687', auth=('neo4j', 'password'))
def run_query(query, params):
with driver.session() as session:
result = session.run(query, params)
return [record['n'] for record in result]
# Use the function
uid = 'sample-test-result-12345'
result = get_lims_sampletestresultdetails_by_uid(uid)
if result:
print(f"Found test result: {result}")
else:
print(f"No test result 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 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 and monitoring database queries
- For production use, implement connection pooling and retry logic in the run_query function
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function get_lims_sampletestresults_by_uid 95.5% similar
-
function get_lims_sampletestresultdetails_by_id 90.4% similar
-
function get_lims_samples_by_uid 89.1% similar
-
function get_lims_sampletypetests_by_uid 88.4% similar
-
function get_lims_testparameters_by_uid 87.1% similar