Hospital Admissions from SIH with healthbR
Source:vignettes/sih-hospital-admissions.Rmd
sih-hospital-admissions.RmdOverview
The SIH (Sistema de Informacoes Hospitalares) records all hospital admissions financed by the Brazilian public health system (SUS) through the Autorizacao de Internacao Hospitalar (AIH). It is managed by the Ministry of Health through DATASUS.
| Feature | Details |
|---|---|
| Coverage | Per state (UF), all 27 states |
| Years | 2008–2024 |
| Granularity | Monthly (one file per UF/month) |
| Unit | One row per hospital admission (AIH) |
| Format | .dbc files from DATASUS FTP |
Getting started
Module information
sih_info()Downloading data
Basic download
# All months of 2022 for Acre
admissions <- sih_data(year = 2022, uf = "AC")Key variables
| Variable | Description |
|---|---|
| DIAG_PRINC | Principal diagnosis (CID-10) |
| DT_INTER | Admission date |
| DT_SAIDA | Discharge date |
| SEXO | Sex (0=Unknown, 1=Male, 3=Female) |
| NASC | Date of birth |
| MORTE | Hospital death (0=No, 1=Yes) |
| MUNIC_RES | Municipality of residence (IBGE code) |
| MUNIC_MOV | Municipality of hospitalization |
| VAL_TOT | Total AIH value (R$) |
| DIAS_PERM | Length of stay (days) |
| PROC_REA | Procedure performed (SIGTAP code) |
| UTI_MES_TO | ICU days |
Note: Sex codes in SIH differ from SIM/SINASC (0=Unknown, 1=Male, 3=Female).
Data dictionary
sih_dictionary()
sih_dictionary("SEXO")
sih_dictionary("MORTE")Explore variables
sih_variables()
sih_variables(search = "diag")
sih_variables(search = "valor")Example: Hospitalization costs
admissions <- sih_data(year = 2022, uf = "SP", month = 1)
costs <- admissions |>
mutate(
chapter = substr(DIAG_PRINC, 1, 1),
cost = as.numeric(VAL_TOT)
) |>
group_by(chapter) |>
summarise(
admissions = n(),
total_cost = sum(cost, na.rm = TRUE),
mean_cost = mean(cost, na.rm = TRUE)
) |>
arrange(desc(total_cost))Cache and lazy evaluation
sih_cache_status()
sih_clear_cache()
# lazy query
lazy <- sih_data(year = 2022, uf = "SP", lazy = TRUE)
lazy |>
filter(MORTE == "1") |>
select(DIAG_PRINC, DT_INTER, SEXO, MUNIC_RES) |>
collect()Further reading
- SIH on DATASUS (
datasus.saude.gov.br) - SIGTAP procedure table (
wiki.saude.gov.br/sigtap) - SIA vignette for outpatient data