Update app.py
Browse files
app.py
CHANGED
@@ -21,7 +21,7 @@ API_ENDPOINTS = {
|
|
21 |
"pubchem": "https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/{}/JSON",
|
22 |
"pubmed": "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi",
|
23 |
"who_drugs": "https://health-products.canada.ca/api/drug/product",
|
24 |
-
"ema_reports": "https://www.ema.europa.eu/api/search/medicines",
|
25 |
"fda_drug_approval": "https://api.fda.gov/drug/label.json?search=openfda.brand_name:{}",
|
26 |
"faers_adverse_events": "https://api.fda.gov/drug/event.json?search=patient.drug.medicinalproduct:{}",
|
27 |
"pharmgkb": "https://api.pharmgkb.org/v1/data/variant/{}/clinicalAnnotations",
|
@@ -109,14 +109,13 @@ def _get_clinical_trials(query: str, email:Optional[str] = CLINICALTRIALS_EMAIL)
|
|
109 |
if query.upper().startswith("NCT") and query[3:].isdigit(): # Check if it's an NCT number
|
110 |
params = {
|
111 |
"id": query,
|
112 |
-
"fmt": "json"
|
113 |
-
"email": email
|
114 |
}
|
115 |
else:
|
116 |
params = {
|
117 |
"query.term": query,
|
118 |
"fmt": "json",
|
119 |
-
|
120 |
}
|
121 |
return _query_api(API_ENDPOINTS["clinical_trials"], params)
|
122 |
|
@@ -145,7 +144,9 @@ def _get_bioportal_data(ontology: str, term: str) -> Optional[Dict]:
|
|
145 |
if not BIOPORTAL_API_KEY:
|
146 |
st.error("BioPortal API key not found. Please set the BIOPORTAL_API_KEY environment variable.")
|
147 |
return None
|
148 |
-
|
|
|
|
|
149 |
headers = {
|
150 |
"Authorization": f"apikey token={BIOPORTAL_API_KEY}"
|
151 |
}
|
@@ -337,7 +338,7 @@ with tabs[3]:
|
|
337 |
with st.spinner("Compiling global regulatory status..."):
|
338 |
# Multi-regional checks
|
339 |
fda = _get_fda_approval(drug_name)
|
340 |
-
|
341 |
who = _query_api(API_ENDPOINTS["who_drugs"], {"name": drug_name})
|
342 |
|
343 |
st.subheader("Regulatory Status")
|
@@ -347,13 +348,14 @@ with tabs[3]:
|
|
347 |
st.write(fda['openfda']['brand_name'][0] if fda and 'openfda' in fda and 'brand_name' in fda['openfda'] else "Not approved")
|
348 |
with col2:
|
349 |
st.markdown("**EMA Status**")
|
350 |
-
st.write(ema['results'][0]['currentStatus'] if ema and 'results' in ema and ema['results'] else "Not approved")
|
|
|
351 |
with col3:
|
352 |
st.markdown("**WHO Essential Medicine**")
|
353 |
st.write("Yes" if who else "No")
|
354 |
|
355 |
# Save the information to a PDF report
|
356 |
-
regulatory_content = f"### Regulatory Report\n\nFDA Status: {fda['openfda']['brand_name'][0] if fda and 'openfda' in fda and 'brand_name' in fda['openfda'] else 'Not Approved'}\n\nEMA Status: {
|
357 |
report_file = _save_pdf_report(regulatory_content, f"{drug_name}_regulatory_report.pdf")
|
358 |
if report_file:
|
359 |
with open(report_file, "rb") as file:
|
|
|
21 |
"pubchem": "https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/{}/JSON",
|
22 |
"pubmed": "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi",
|
23 |
"who_drugs": "https://health-products.canada.ca/api/drug/product",
|
24 |
+
#"ema_reports": "https://www.ema.europa.eu/api/search/medicines", #Removed due to 403
|
25 |
"fda_drug_approval": "https://api.fda.gov/drug/label.json?search=openfda.brand_name:{}",
|
26 |
"faers_adverse_events": "https://api.fda.gov/drug/event.json?search=patient.drug.medicinalproduct:{}",
|
27 |
"pharmgkb": "https://api.pharmgkb.org/v1/data/variant/{}/clinicalAnnotations",
|
|
|
109 |
if query.upper().startswith("NCT") and query[3:].isdigit(): # Check if it's an NCT number
|
110 |
params = {
|
111 |
"id": query,
|
112 |
+
"fmt": "json"
|
|
|
113 |
}
|
114 |
else:
|
115 |
params = {
|
116 |
"query.term": query,
|
117 |
"fmt": "json",
|
118 |
+
"email": email
|
119 |
}
|
120 |
return _query_api(API_ENDPOINTS["clinical_trials"], params)
|
121 |
|
|
|
144 |
if not BIOPORTAL_API_KEY:
|
145 |
st.error("BioPortal API key not found. Please set the BIOPORTAL_API_KEY environment variable.")
|
146 |
return None
|
147 |
+
if not term:
|
148 |
+
st.error("Please provide a search term")
|
149 |
+
return None
|
150 |
headers = {
|
151 |
"Authorization": f"apikey token={BIOPORTAL_API_KEY}"
|
152 |
}
|
|
|
338 |
with st.spinner("Compiling global regulatory status..."):
|
339 |
# Multi-regional checks
|
340 |
fda = _get_fda_approval(drug_name)
|
341 |
+
# ema = _query_api(API_ENDPOINTS["ema_reports"], {"search": drug_name}) #Removed EMA due to 403 error
|
342 |
who = _query_api(API_ENDPOINTS["who_drugs"], {"name": drug_name})
|
343 |
|
344 |
st.subheader("Regulatory Status")
|
|
|
348 |
st.write(fda['openfda']['brand_name'][0] if fda and 'openfda' in fda and 'brand_name' in fda['openfda'] else "Not approved")
|
349 |
with col2:
|
350 |
st.markdown("**EMA Status**")
|
351 |
+
#st.write(ema['results'][0]['currentStatus'] if ema and 'results' in ema and ema['results'] else "Not approved") #Removed EMA due to 403 error
|
352 |
+
st.write("Not Available")
|
353 |
with col3:
|
354 |
st.markdown("**WHO Essential Medicine**")
|
355 |
st.write("Yes" if who else "No")
|
356 |
|
357 |
# Save the information to a PDF report
|
358 |
+
regulatory_content = f"### Regulatory Report\n\nFDA Status: {fda['openfda']['brand_name'][0] if fda and 'openfda' in fda and 'brand_name' in fda['openfda'] else 'Not Approved'}\n\nEMA Status: {'Not Available'}\n\nWHO Essential Medicine: {'Yes' if who else 'No'}"
|
359 |
report_file = _save_pdf_report(regulatory_content, f"{drug_name}_regulatory_report.pdf")
|
360 |
if report_file:
|
361 |
with open(report_file, "rb") as file:
|