import pandas as pd
from pysus.online_data.SIH import SIH

def download_sih_to(uf="TO", years=range(2015, 2024)):

    dfs = []

    for year in years:
        print(f"Baixando {year}...")

        df = SIH().load().filter(
            UF=uf,
            ANO_CMPT=year
        )

        df = df.to_dataframe()

        dfs.append(df)

    full = pd.concat(dfs, ignore_index=True)

    full.to_parquet("data/sih_to.parquet")

    return full
