File size: 1,072 Bytes
359d26a
8602110
 
 
 
 
359d26a
 
8602110
 
359d26a
8602110
 
359d26a
8602110
359d26a
8602110
 
 
359d26a
8602110
 
 
 
 
 
359d26a
8602110
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# 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)
    }