Spaces:
Sleeping
Sleeping
# genesis/regulation.py | |
""" | |
Regulatory Insights for GENESIS-AI | |
Fetches approvals, clinical trial phases, and safety alerts from FDA and EMA. | |
""" | |
import requests | |
FDA_DRUG_API = "https://api.fda.gov/drug/drugsfda.json" | |
EMA_MEDICINE_API = "https://www.ema.europa.eu/api/medicines" | |
def fetch_fda_drug_info(drug_name): | |
"""Search FDA database for a drug.""" | |
try: | |
r = requests.get(FDA_DRUG_API, params={"search": f"products.brand_name:{drug_name}", "limit": 5}) | |
r.raise_for_status() | |
return r.json().get("results", []) | |
except Exception as e: | |
return {"error": str(e)} | |
def fetch_ema_medicine_info(medicine_name): | |
"""Search EMA database for a medicine.""" | |
try: | |
r = requests.get(f"{EMA_MEDICINE_API}?searchQuery={medicine_name}") | |
r.raise_for_status() | |
return r.json() | |
except Exception as e: | |
return {"error": str(e)} | |
def get_regulatory_data(term): | |
"""Fetch both FDA and EMA data.""" | |
return { | |
"fda": fetch_fda_drug_info(term), | |
"ema": fetch_ema_medicine_info(term) | |
} | |