function get_parameter_medicationtypes_by_uid
Retrieves a single Parameter_MedicationTypes node from a Neo4j graph database by matching its unique identifier (UID).
/tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
586 - 593
simple
Purpose
This function queries a Neo4j database to fetch a specific Parameter_MedicationTypes node using its UID. It's designed for retrieving medication type parameter configurations or metadata stored in a graph database. The function returns the first matching node or None if no match is found, making it useful for lookup operations in healthcare or pharmaceutical applications that use graph databases to model medication parameters.
Source Code
def get_parameter_medicationtypes_by_uid(uid):
"""Get a Parameter_MedicationTypes node by its UID"""
query = """
MATCH (n:Parameter_MedicationTypes {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 Parameter_MedicationTypes 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 for a Parameter_MedicationTypes node.
Return Value
Returns the first Parameter_MedicationTypes node object that matches the provided UID if found, or None if no matching node exists. The returned node object contains all properties associated with that Parameter_MedicationTypes node in the database. The return type is either a dictionary-like node object or None.
Dependencies
neo4j
Required Imports
from neo4j import GraphDatabase
Usage Example
# Assuming run_query is defined and Neo4j connection is configured
from neo4j import GraphDatabase
# Example usage
uid_to_find = "med-type-123"
medication_type = get_parameter_medicationtypes_by_uid(uid_to_find)
if medication_type:
print(f"Found medication type: {medication_type}")
else:
print(f"No medication type found with UID: {uid_to_find}")
Best Practices
- Ensure the run_query function is properly defined and handles Neo4j connection management
- Validate the uid parameter before calling this function to avoid unnecessary database queries
- Handle the None return value appropriately in calling code to avoid NoneType errors
- Consider adding error handling for database connection failures
- Ensure proper indexing on the UID property in Neo4j for optimal query performance
- The function assumes run_query returns a list; verify this behavior matches your implementation
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function get_parameter_medicationtypeproperties_by_uid 93.8% similar
-
function get_parameter_medicationtypes_by_id 90.2% similar
-
function get_parameter_medicationtypeproperties_by_id 82.0% similar
-
function get_all_parameter_medicationtypes 79.7% similar
-
function get_parameter_medicationtypeproperties_with_references_medicationtypes_parameter_medicationtypes 79.3% similar