openfda_adverse_getter
Retrieve detailed FDA adverse event reports including patient demographics, drug details, adverse reactions, and outcomes using a specific report ID. Access critical biomedical data via BioMCP.
Instructions
Get detailed information for a specific FDA adverse event report.
Retrieves complete details including:
- Patient demographics and medical history
- All drugs involved and dosages
- Complete list of adverse reactions
- Event narrative and outcomes
- Reporter information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| api_key | No | Optional OpenFDA API key (overrides OPENFDA_API_KEY env var) | |
| report_id | Yes | Safety report ID |
Implementation Reference
- src/biomcp/individual_tools.py:1328-1354 (handler)MCP tool handler and registration for 'openfda_adverse_getter'. Defines input schema via Annotated Fields and delegates to core implementation.@mcp_app.tool() @track_performance("biomcp.openfda_adverse_getter") async def openfda_adverse_getter( report_id: Annotated[ str, Field(description="Safety report ID"), ], api_key: Annotated[ str | None, Field( description="Optional OpenFDA API key (overrides OPENFDA_API_KEY env var)" ), ] = None, ) -> str: """Get detailed information for a specific FDA adverse event report. Retrieves complete details including: - Patient demographics and medical history - All drugs involved and dosages - Complete list of adverse reactions - Event narrative and outcomes - Reporter information """ from biomcp.openfda import get_adverse_event return await get_adverse_event(report_id, api_key=api_key)
- Core helper function implementing the OpenFDA adverse event retrieval and formatting logic, called by the MCP handler.async def get_adverse_event(report_id: str, api_key: str | None = None) -> str: """ Get detailed information for a specific adverse event report. Args: report_id: Safety report ID api_key: Optional OpenFDA API key (overrides OPENFDA_API_KEY env var) Returns: Formatted string with detailed report information """ params = { "search": f'safetyreportid:"{report_id}"', "limit": 1, } response, error = await make_openfda_request( OPENFDA_DRUG_EVENTS_URL, params, "openfda_adverse_event_detail", api_key, ) if error: return f"⚠️ Error retrieving adverse event report: {error}" if not response or not response.get("results"): return f"Adverse event report '{report_id}' not found." result = response["results"][0] patient = result.get("patient", {}) # Build detailed output output = [f"## Adverse Event Report: {report_id}\n"] # Patient Information output.extend(_format_patient_info(patient)) # Drug Information if drugs := patient.get("drug", []): output.extend(format_drug_details(drugs)) # Reactions if reactions := patient.get("reaction", []): output.extend(format_reaction_details(reactions)) # Event Summary if summary := patient.get("summary", {}).get("narrativeincludeclinical"): output.append("### Event Narrative") output.append(clean_text(summary)) output.append("") # Report metadata output.extend(format_report_metadata(result)) output.append(f"\n{OPENFDA_DISCLAIMER}") return "\n".join(output)