biocontext_kb.core.openfda#

Functions#

count_drugs_by_field(field[, search_filter, limit])

Count unique values in a field across FDA-approved drugs. Useful for statistical analysis.

get_available_pharmacologic_classes([class_type, limit])

Get available pharmacologic classes from FDA database. Call this first to see available options.

get_drug_by_application_number(application_number)

Get detailed information about an FDA-approved drug by application number. Format: NDA/ANDA/BLA followed by 6 digits.

get_drug_label_info([brand_name, generic_name, ndc])

Get comprehensive drug labeling information from FDA. Includes active ingredients, dosage forms, administration routes.

get_drug_statistics()

Get general statistics about the FDA Drugs@FDA database. Includes top sponsors, dosage forms, routes, marketing status.

get_generic_equivalents(brand_name)

Find generic equivalents for a brand name drug. Searches ANDA entries with matching active ingredients.

search_drugs_by_therapeutic_class(therapeutic_class[, ...])

Search for drugs by therapeutic or pharmacologic class. Use get_available_pharmacologic_classes() first for exact terms.

search_drugs_fda([brand_name, generic_name, ...])

Search FDA Drugs@FDA database for approved drug products. Supports multiple search criteria.

Package Contents#

biocontext_kb.core.openfda.count_drugs_by_field(field, search_filter=None, limit=100)#

Count unique values in a field across FDA-approved drugs. Useful for statistical analysis.

Returns:

Results array with term and count for each unique value or error message.

Return type:

dict

Parameters:
  • field (Annotated[str, Field(description="Field to count (e.g., 'sponsor_name', 'products.dosage_form', 'products.route', 'openfda.pharm_class_epc')")])

  • search_filter (Annotated[Optional[str], Field(description='Optional search filter to apply before counting')])

  • limit (Annotated[int, Field(description='Maximum number of count results to return', ge=1, le=1000)])

biocontext_kb.core.openfda.get_available_pharmacologic_classes(class_type='epc', limit=100)#

Get available pharmacologic classes from FDA database. Call this first to see available options.

Returns:

Class type, field, available_classes array with term/count, total_found or error message.

Return type:

dict

Parameters:
  • class_type (Annotated[str, Field(description="Class type: 'epc' (Established Pharmacologic Class), 'moa' (Mechanism of Action), 'pe' (Physiologic Effect), or 'cs' (Chemical Structure)")])

  • limit (Annotated[int, Field(description='Number of unique classes to return', ge=1, le=1000)])

biocontext_kb.core.openfda.get_drug_by_application_number(application_number)#

Get detailed information about an FDA-approved drug by application number. Format: NDA/ANDA/BLA followed by 6 digits.

Returns:

FDA drug results with application details, products, sponsor information or error message.

Return type:

dict

Parameters:

application_number (Annotated[str, Field(description="FDA application number (e.g., 'NDA021436', 'ANDA123456', 'BLA761234')")])

biocontext_kb.core.openfda.get_drug_label_info(brand_name=None, generic_name=None, ndc=None)#

Get comprehensive drug labeling information from FDA. Includes active ingredients, dosage forms, administration routes.

Returns:

Drug label results with indications, warnings, dosage, active ingredients or error message.

Return type:

dict

Parameters:
  • brand_name (Annotated[Optional[str], Field(description='Brand name of the drug')])

  • generic_name (Annotated[Optional[str], Field(description='Generic name of the drug')])

  • ndc (Annotated[Optional[str], Field(description='National Drug Code (NDC)')])

biocontext_kb.core.openfda.get_drug_statistics()#

Get general statistics about the FDA Drugs@FDA database. Includes top sponsors, dosage forms, routes, marketing status.

Returns:

Top sponsors, dosage_forms, administration_routes, marketing_statuses with counts or error message.

Return type:

dict

biocontext_kb.core.openfda.get_generic_equivalents(brand_name)#

Find generic equivalents for a brand name drug. Searches ANDA entries with matching active ingredients.

Returns:

Brand drug info, generic_equivalents array, total_generics_found count or error message.

Return type:

dict

Parameters:

brand_name (Annotated[str, Field(description='Brand name drug to find generics for')])

biocontext_kb.core.openfda.search_drugs_by_therapeutic_class(therapeutic_class, class_type='epc', limit=25)#

Search for drugs by therapeutic or pharmacologic class. Use get_available_pharmacologic_classes() first for exact terms.

Returns:

FDA drug results array with application info, products, sponsor names or error message.

Return type:

dict

Parameters:
  • therapeutic_class (Annotated[str, Field(description='Exact therapeutic/pharmacologic class term from FDA (use get_available_pharmacologic_classes first)')])

  • class_type (Annotated[str, Field(description="Class type: 'epc' (Established Pharmacologic Class), 'moa' (Mechanism of Action), 'pe' (Physiologic Effect), or 'cs' (Chemical Structure)")])

  • limit (Annotated[int, Field(description='Number of results to return', ge=1, le=1000)])

biocontext_kb.core.openfda.search_drugs_fda(brand_name=None, generic_name=None, active_ingredient=None, sponsor_name=None, application_number=None, marketing_status=None, dosage_form=None, route=None, search_type='or', sort_by=None, limit=25, skip=0)#

Search FDA Drugs@FDA database for approved drug products. Supports multiple search criteria.

Returns:

Results array with drug products including application numbers, sponsors, products array or error message.

Return type:

dict

Parameters:
  • brand_name (Annotated[Optional[str], Field(description="Brand or trade name (e.g., 'Tylenol')")])

  • generic_name (Annotated[Optional[str], Field(description="Generic name (e.g., 'acetaminophen')")])

  • active_ingredient (Annotated[Optional[str], Field(description='Active ingredient name')])

  • sponsor_name (Annotated[Optional[str], Field(description='Company/sponsor name')])

  • application_number (Annotated[Optional[str], Field(description='FDA application number (NDA, ANDA, or BLA)')])

  • marketing_status (Annotated[Optional[str], Field(description="Marketing status: 'Prescription', 'Over-the-counter', 'Discontinued', or 'None (Tentative Approval)'")])

  • dosage_form (Annotated[Optional[str], Field(description="Dosage form (e.g., 'TABLET', 'INJECTION', 'CAPSULE')")])

  • route (Annotated[Optional[str], Field(description="Route of administration (e.g., 'ORAL', 'INJECTION', 'TOPICAL')")])

  • search_type (Annotated[str, Field(description="'and' for all terms must match, 'or' for any term matches")])

  • sort_by (Annotated[Optional[str], Field(description="Field to sort by (e.g., 'sponsor_name', 'application_number')")])

  • limit (Annotated[int, Field(description='Number of results to return', ge=1, le=1000)])

  • skip (Annotated[int, Field(description='Number of results to skip for pagination', ge=0, le=25000)])