lmb-fe/pages/echa.py
2026-03-13 23:54:16 +01:00

124 lines
3.3 KiB
Python

import streamlit as st
from functions import (
echa_request,
extract_acute_values,
extract_repeated_values,
extract_tox_info_values,
)
from functions_ui import download_pdf
st.set_page_config(
page_title="ECHA Toxicological Data Viewer",
page_icon="🧊",
layout="wide",
initial_sidebar_state="expanded",
)
st.info("Questa pagina mostra i dati ECHA in modo più dettagliato. È consigliato però utilizzare la pagina **Ingrediente** per avere informazioni più complete sull'ingrediente.")
if st.session_state.get("selected_cas") is None:
st.warning("Nessun CAS Number selezionato. Torna alla pagina principale per effettuare una ricerca.")
st.stop()
cas_number = st.session_state.selected_cas
DATA = echa_request(cas_number)
if "substance" not in DATA:
st.error(DATA)
st.stop()
# App
st.title("Toxicological Data Viewer")
# Substance info
substance = DATA["substance"]
dossier = DATA["dossier_info"]
st.subheader(f"{substance['rmlName']}")
with st.container(border=True):
col1, col2, col3, col4 = st.columns(4)
with col1:
st.caption("CAS Number")
st.write(substance["rmlCas"])
with col2:
st.caption("EC Number")
st.write(substance["rmlEc"])
with col3:
st.caption("Status")
st.write(dossier["registrationStatus"])
with col4:
st.caption("Last Updated")
st.write(dossier["lastUpdatedDate"])
# Tabs
tab1, tab2, tab3 = st.tabs(["Toxicological Information", "Acute Toxicity", "Repeated Dose Toxicity"])
with tab1:
st.subheader("Derived No Effect Levels (DNEL)")
tox_rows = extract_tox_info_values(DATA)
if tox_rows:
st.table(tox_rows)
else:
st.info("No DNEL values found.")
download_pdf(
casNo=substance["rmlCas"],
origin="echa_tox_info",
link=DATA["index"]["toxicological_information_link"],
)
with tab2:
st.subheader("Acute Toxicity Values")
acute_rows = extract_acute_values(DATA)
if acute_rows:
st.table(acute_rows)
else:
st.info("No acute toxicity values found.")
download_pdf(
casNo=substance["rmlCas"],
origin="echa_acute_tox",
link=DATA["index"]["acute_toxicity_link"],
)
with tab3:
st.subheader("Repeated Dose Toxicity Values")
repeated_rows = extract_repeated_values(DATA)
if repeated_rows:
st.table(repeated_rows)
else:
st.info("No repeated dose toxicity values found.")
download_pdf(
casNo=substance["rmlCas"],
origin="echa_repeated_tox",
link=DATA["index"]["repeated_dose_toxicity_link"],
)
# Key Information sections
st.divider()
st.subheader("Key Information")
acute_key_info = None
repeated_key_info = None
for section in DATA.get("acute_toxicity", {}).get("sections", []):
if section.get("label") == "Description of key information":
acute_key_info = section.get("KeyInformation")
break
for section in DATA.get("repeated_dose_toxicity", {}).get("sections", []):
if section.get("label") == "Description of key information":
repeated_key_info = section.get("KeyInformation")
break
if acute_key_info:
with st.expander("Acute Toxicity - Key Information"):
st.write(acute_key_info)
if repeated_key_info:
with st.expander("Repeated Dose Toxicity - Key Information"):
st.write(repeated_key_info)