function get_all_parameter_medicationtypes
Retrieves Parameter_MedicationTypes nodes from a Neo4j graph database with a configurable limit on the number of results returned.
/tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
568 - 575
simple
Purpose
This function queries a Neo4j database to fetch all nodes labeled as 'Parameter_MedicationTypes'. It's designed to retrieve medication type parameters stored in the graph database, useful for applications that need to access medication classification or categorization data. The function provides a safety limit to prevent overwhelming queries, though there's a discrepancy between the docstring (25) and default parameter (100).
Source Code
def get_all_parameter_medicationtypes(limit=100):
"""Return Parameter_MedicationTypes nodes (limited to 25)"""
query = """
MATCH (n:Parameter_MedicationTypes)
RETURN n
LIMIT $limit
"""
return run_query(query, {"limit": limit})
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
limit |
- | 100 | positional_or_keyword |
Parameter Details
limit: Integer value that controls the maximum number of Parameter_MedicationTypes nodes to return from the database. Default is 100, though the docstring incorrectly states 25. This parameter helps prevent performance issues by limiting result set size. Expected values are positive integers, typically between 1 and several thousand depending on use case.
Return Value
Returns the result of run_query() function execution, which typically contains a list or collection of Neo4j node objects representing Parameter_MedicationTypes. The exact return type depends on the run_query() implementation, but commonly returns a list of dictionaries or Neo4j Record objects containing node properties. Returns up to 'limit' number of nodes. If no nodes exist or database is unreachable, behavior depends on run_query() error handling.
Dependencies
neo4j
Required Imports
from neo4j import GraphDatabase
Usage Example
# Assuming run_query is defined and Neo4j connection is configured
# Example 1: Get default 100 medication types
medication_types = get_all_parameter_medicationtypes()
for record in medication_types:
print(record['n'])
# Example 2: Get only 10 medication types
medication_types_limited = get_all_parameter_medicationtypes(limit=10)
# Example 3: Get all medication types (use large limit)
all_medication_types = get_all_parameter_medicationtypes(limit=10000)
Best Practices
- Note the discrepancy: docstring says 'limited to 25' but default parameter is 100 - update documentation or parameter for consistency
- Ensure run_query() function is properly defined with error handling before using this function
- Consider adding error handling for database connection failures
- Be mindful of the limit parameter when dealing with large datasets to avoid memory issues
- Consider adding pagination support for production use cases with large result sets
- Validate that Neo4j connection is established before calling this function
- Consider adding return type annotation for better code documentation
- The function depends on run_query() which should handle connection pooling and session management
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function get_all_parameter_medicationtypeproperties 92.0% similar
-
function get_parameter_medicationtypes_by_id 85.7% similar
-
function get_parameter_medicationtypeproperties_with_references_medicationtypes_parameter_medicationtypes 85.1% similar
-
function get_parameter_medicationtypes_by_uid 79.7% similar
-
function get_parameter_medicationtypeproperties_by_id 79.4% similar