function get_parameter_medicationtypeproperties_with_references_medicationtypes_parameter_medicationtypes
Retrieves Parameter_MedicationTypes nodes from a Neo4j graph database that are connected to a specific Parameter_MedicationTypeProperties node via a REFERENCES_MEDICATIONTYPES relationship.
/tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
1641 - 1648
simple
Purpose
This function queries a Neo4j graph database to find medication type nodes that are referenced by a medication type properties node. It's useful for traversing relationships in a medical data graph to understand which medication types are associated with specific medication type properties. The function supports pagination through a limit parameter to control the number of results returned.
Source Code
def get_parameter_medicationtypeproperties_with_references_medicationtypes_parameter_medicationtypes(source_id, limit=100):
"""Get Parameter_MedicationTypes nodes connected to a Parameter_MedicationTypeProperties via REFERENCES_MEDICATIONTYPES"""
query = """
MATCH (source:Parameter_MedicationTypeProperties {id: $source_id})-[r:REFERENCES_MEDICATIONTYPES]->(target:Parameter_MedicationTypes)
RETURN target
LIMIT $limit
"""
return run_query(query, {"source_id": source_id, "limit": limit})
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
source_id |
- | - | positional_or_keyword |
limit |
- | 100 | positional_or_keyword |
Parameter Details
source_id: The unique identifier (id property) of the Parameter_MedicationTypeProperties node from which to start the traversal. This should be a string or value that matches the 'id' property of a node in the database.
limit: Maximum number of Parameter_MedicationTypes nodes to return. Defaults to 100. This parameter helps control query performance and result set size. Must be a positive integer.
Return Value
Returns the result of run_query() function, which typically returns a list of Neo4j records containing the target Parameter_MedicationTypes nodes. Each record represents a node that has a REFERENCES_MEDICATIONTYPES relationship from the source Parameter_MedicationTypeProperties node. The exact return type depends on the run_query() implementation, but it likely returns a list of dictionaries or Neo4j Record objects containing node properties.
Dependencies
neo4j
Required Imports
from neo4j import GraphDatabase
Usage Example
# Assuming run_query() is already defined and Neo4j connection is configured
from neo4j import GraphDatabase
# Define or import the run_query function (example implementation)
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['target'] for record in result]
driver.close()
# Use the function to get medication types
source_property_id = 'med_prop_123'
medication_types = get_parameter_medicationtypeproperties_with_references_medicationtypes_parameter_medicationtypes(source_property_id, limit=50)
# Process the results
for med_type in medication_types:
print(f"Medication Type: {med_type}")
Best Practices
- Ensure the source_id parameter matches an existing Parameter_MedicationTypeProperties node in the database to avoid empty results
- Use appropriate limit values to balance between performance and completeness of results
- The run_query() function should handle database connection management, error handling, and proper resource cleanup
- Consider adding error handling for cases where the source node doesn't exist or has no relationships
- Validate that the Neo4j database connection is established before calling this function
- For large result sets, consider implementing pagination by calling the function multiple times with different offsets
- Ensure proper indexing on the 'id' property of Parameter_MedicationTypeProperties nodes for optimal query performance
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function get_parameter_medicationtypeproperties_by_id 88.1% similar
-
function get_all_parameter_medicationtypeproperties 87.1% similar
-
function get_parameter_medicationtypes_by_id 85.1% similar
-
function get_all_parameter_medicationtypes 85.1% similar
-
function get_parameter_medicationtypeproperties_by_uid 81.0% similar