Changelog
Source:NEWS.md
microdatasus 3.0.0.9000
Development
- Updates Windows binary-installation instructions, including dependencies and R compatibility. Aligns the README, help and articles on connection failures, empty results, the limits of
stop_on_error, and the difference between local data, cached dictionaries and remote DBC discovery. - Publishes the development documentation on pushes to
dev, including the processing guide linked from the help pages. Cites the official DataSUS HTTPS transfer portal for the fixed municipal reference, retaining the original FTP address as provenance and documenting its access limitations and the bundled offline sources. Clarifies connection-failure handling and the separation between offline package checks and opt-in live tests. - Documents and adds regression coverage for discovering every published file part across all supported systems, including more than 26 parts, arbitrary suffix lengths, and different part sets for each state and period.
- Reconstructs the packaged municipal reference exactly from checksum-pinned official DataSUS TXT files, without changing its values. Ships the source members for offline rebuilding and reports an explicit snapshot version, source timestamp basis, archive checksum, and compatibility transformations. Documents that territorial enrichment uses a fixed reference, not boundaries selected from observation dates.
- Adds an offline, checksum-pinned corpus of eight official historical DBC excerpts with original DEF/CNV/DBF members and independently transcribed expected results. Checks four layout transitions, all label modes, mixed periods, values, types, category counts, and processing diagnostics.
- Makes CI coverage gates reject missing critical files, invalid percentages, and malformed coverage reports instead of silently ignoring missing entries.
- Fixes weekly live-test rotation to continue across year boundaries, so every registered SINAN system is selected even when a family has more than 53 members.
- Replaces the DBC-to-temporary-DBF path in
read_dbc()with a streaming native reader that parses decompressed records directly into R columns. Character data are converted explicitly to UTF-8 using DBF language-driver metadata plus per-field byte evidence (with a strictencodingoverride). Mixed and obfuscated identifier bytes are preserved losslessly with a warning.varsavoids allocating or parsing unselected fields, andfetch_datasus()uses this projection before reading whenever processing and row filtering do not require the full row. - Makes CP1252 decoding platform-independent by rejecting its five undefined byte values explicitly. Automatic decoding preserves those bytes losslessly, while an explicit CP1252 override continues to fail strictly on every OS.
- Hardens native DBC parsing with strict field-layout, record-marker, end-code, trailing-data, I/O, CRC32, embedded-NUL padding, numeric syntax and precision, and calendar-date checks. The reader recognizes the DBF language-driver variants found in official DataSUS files and detects a file changed between metadata and record reads. Malformed numeric and date cells in structurally valid official files become
NAwith diagnostics. Fixes undefined pointer arithmetic in the vendored blast sliding window found by UBSan, and adds deterministic mutation, truncation, full historical-system matrix, real-corpus, gctorture, sanitizer, and performance validation workflows. - Adds per-file
row_filterexecution before processing, deterministic schema sampling across historical layouts, and richer coercion/unknown-code counts. - Uses SHA-256 for new cache manifests while reading legacy MD5 manifests, supports resumable transfers and optional
microdatasus.mirrors, and brings CADGER/SIGTAB downloads into the persistent cache and provenance model. - Adds reproducibility lockfiles with request, source, dictionary, parser, and packaged-reference checksums through
datasus_lockfile()and verification helpers. - Makes packaged lookup-table provenance explicit with
datasus_reference_tables(), normalizes escaped UTF-8 values, and reports legacy reference use in processing diagnostics. - Classifies dictionary issues by origin, adds strict
fail_on_issuesaudits, rotating coverage of every registered subsystem, and live historical-layout transition checks. - Expands the package, function, README, FAQ, and article documentation for the direct DBC reader and the DEF/CNV/DBF parser, including encoding behavior, TabWin precedence, auditable fallbacks, stable processed types, and the boundary of the remaining
foreigndependency. - Speeds up
process_*()on large inputs by parsing repeated dates once, restricting Unicode unescaping to text that contains escapes, vectorizing fixed-width code padding and TabWinF-mode thresholds, and avoiding full-table row copies while scoring historical dictionary relations. - Documents automatic processing optimizations, persistent cache configuration, the scope of column projection, and the limits of synthetic benchmarks. Updates download examples and enables processing diagnostics where lockfiles need dictionary and reference-table provenance.
microdatasus 3.0.0
CRAN release: 2026-07-29
Downloads
Adds an optional persistent cache for DBC and TabWin ZIP files, with manifests, MD5 integrity checks, inspection through
datasus_cache_info(), and targeted cleanup throughclear_datasus_cache().Extends
fetch_datasus()with per-file processing and RDS output. Settingcollect = FALSEbounds memory use to roughly one source file and returns a provenance manifest; existing calls retain their combined-tibble behavior.Adds opt-in download provenance with source URL, size, checksum, timestamp, cache status, and local/output paths.
Reworks
fetch_datasus()around an internal registry of supported systems and manifests built from the files actually published by DataSUS. Each relevant FTP directory is listed only once per call, avoiding redundant connections and URLs for files that do not exist.Selects a single file for each system, period, state, and file part. Definitive/current data take precedence over preliminary data, and current data take precedence over historical copies. Results retain deterministic period, state, and file-part order.
Uses
curldirectly for directory listings and downloads, with per-operation timeouts and up to two retries for transient network failures. Downloads remain sequential, display transfer progress by default, and no longer modify the globaloptions("timeout").Downloads through temporary partial files, validates file size and DBC contents, and reliably removes temporary files. With
stop_on_error = FALSE, successfully read files are returned after a consolidated warning; withstop_on_error = TRUE, any failure aborts the operation.Applies
varsbefore accumulating results and combines files only once, reducing repeated copies. Whentrack_source = TRUE, thesourcecolumn is retained even whenvarsis supplied, and an existingsourcecolumn now produces a clear error.Strengthens validation of years, months, states, logical arguments,
vars, and fractionaltimeoutvalues. Monthly systems require months, annual systems ignore them with one warning, and"all"can no longer be combined with individual states.Replaces the former global 1996 lower-year restriction with historical limits specific to each information system. Existing public arguments, their order, and their defaults remain unchanged.
Adds
quietat the end of thefetch_datasus()signature. Transfer progress and status messages, including each file name, are displayed by default; setquiet = TRUEto hide them. Warnings and errors remain visible.Uses immediate
cliwarning alerts when month arguments or state selections are ignored, including whenquiet = TRUE.Standardizes download messages across microdata and auxiliary tables, with consistent status verbs, semantic
cliformatting, indexed file progress, and one diagnostic item per failed directory or file.Hardens
fetch_cadger()andfetch_sigtab()with shared timeout, retry, and temporary-file cleanup logic, and adds ZIP integrity and schema validation.
DBC support
- Removes the dependency on
read.dbcand reads DBC files with vendored C code adapted fromhealthbR. Thanks to Sidney Bissoli for the open-source code. - Adds
read_dbc()for local DBC files, with optional preservation of the column types inferred from DBF metadata. - Hardens
read_dbc()by rejecting directories and empty or unreadable input files before decompression, validating missing, unknown-size, and empty decompression output, and wrapping DBF read failures in contextual errors with stablemicrodatasus_dbc_errorsubclasses. - Expands local, CRAN-safe DBC tests for argument validation, type preservation, leading zeros, paths with spaces, repeat reads, temporary-file cleanup, and specific malformed header and compressed-stream errors.
Processing, documentation, and testing
Adds
datasus_variables()to inspect official DEF/CNV/DBF metadata andcompare_datasus_dictionary()to report added, removed, or changed fields and labels between dictionary versions.Supports the compact,
s, and long-descriptionNCNV dialects found in current official archives, legacy-encoded ZIP member names, codes wider than 32-bit integers, and audited two-column DBF description fallbacks.Adds
validate_datasus_schema()to join observed DBC fields, selected current/historical DEF declarations, and the types produced by the matching processor for all 93 downloadable families.Preserves very large CNV intervals as symbolic rules instead of expanding them in memory, reports missing, invalid, non-enumerable, and failed relations explicitly, and compares relation states and interval changes.
Adds
datasus_schema()for dictionary-derived field contracts andaudit_datasus_dictionaries()for all 104 current and historical TabWin definitions, while downloading each of the 14 physical archives only once.Persists parsed CNV/DBF relations by archive checksum and parser version, caches assembled variable tables in the R session, and serializes competing cache writes with atomic locks and uniquely named partial files.
Expands processing diagnostics with dictionary provenance, missing expected fields, unmapped input fields, and numeric/date coercion failures.
Gives every unified
process_*()function the samelabelspolicy ("factor","character", or"none") and optional diagnostics for unmapped codes, while appending all new arguments to preserve established calls.Expands coverage gates, processing benchmarks and scheduled live DataSUS smoke tests across SIM, SINASC, SIH, SIA, CNES, and SINAN; adds a monthly all-dictionary audit plus deterministic malformed-DBC, Valgrind, and UBSan safety workflows.
Replaces short SINAN acronym identifiers with readable canonical names, while retaining every previous value as a silent backward-compatible alias. The new
datasus_information_systems()lookup table lists all 93 supported file families and keeps names, DBC acronyms, periodicity, geography, and aliases synchronized with download and TabWin registries.Adds the unified
process_sinan()based on the officialTAB_SINANNET.zipandTAB_SINANONLINE.zipdefinitions and expandsfetch_datasus()from eight to all 58 SINAN families listed by the transfer portal. The seven former processors retain their original signatures as deprecated wrappers. Dates, encoded ages, municipality codes, labels, and identifiers now follow one tested type policy.Rebuilds
process_cnes()from the official DataSUS TabWin definitions. It now covers all thirteen downloadable CNES layouts, selects the historical or current service-classification definition row by row, shares the largeTAB_CNES.zipdownload for the R session, reads numeric increment metadata from DEF, and preserves identifiers and all existing arguments.Rebuilds
process_sia()from the official DataSUS TabWin definitions. It now covers all twelve downloadable SIA layouts, selects three historical PA definitions by record competence, shares archives in the session cache, and preserves all existing arguments while making their procedure, occupation, and team switches effective.Rebuilds
process_sih()from the official DataSUS TabWin definitions. The function now processesSIH-RD,SIH-RJ,SIH-SP, andSIH-ER, selects the three historical RD/RJ archives by record competence, caches shared downloads for the R session, and standardizes dates, quantities, values, labels, and identifiers while preserving its existing arguments.Standardizes patient age across processors without changing the source fields. SIH-RD/RJ and every applicable SIA layout now add integer
IDADEdias,IDADEmeses, orIDADEanoscolumns from the official TabWin unit conventions; SIM and SINAN use the same shared internal decoder.Speeds processing of large tables by applying row-specific historical dictionaries in one pass per field, factorizing only once, avoiding a second full-table UTF-8 normalization, and using direct numeric coercion when no special missing-value codes need preprocessing.
Adopts
dplyr::recode_values()becausedplyr::case_match()is deprecated.Expands and corrects the documentation for all public functions, including network behavior, actual return types, compatibility arguments, and links to the corresponding chapters of the book Sistemas de Informação em Saúde no Brasil.
Replaces skipped download tests with deterministic simulated listings and transfers. The suite now covers supported systems, historical, current, and preliminary files, multipart data, complete argument validation, retries, timeouts, empty listings and manifests, cleanup, corrupt and empty files, partial success,
vars,track_source, multiple states, and auxiliary-table schema validation. Localfile://fixtures exercisecurlwithout network access; live DataSUS smoke tests remain opt-in and are always skipped on CRAN.Runs the active GitHub Actions R CMD check workflow for pushes and pull requests involving the
devbranch as well asmainandmaster.Requires R 4.1.0 or later.
microdatasus 2.5.0
- Function
process_sinan_malaria, fix variable type when pre-processing the variableNU_IDADE_N(#132) - Function
process_sinasc, fix typo when pre-processing the variablePESO(#141). - Function
process_sia, fix typo when pre-processing the variablePA_MUNPCN(#137). - Function
process_cnesfor CNES-ST, fixMICR_REGandDISTRSANconversion. - Function
process_sih, fixNACIONALandHOMONIMOcodes, add moreFAEC_TPcodes (#131). - Remove
dtplyrpackage dependence.
microdatasus 2.4.2
- Fix error when processing data with
process_sinan_chikungunya().
microdatasus 2.4.1
- Fix typo in process functions that was changing variable names (
process_sim(),process_sinasc(),process_sinan_zika(),process_sinan_malaria(),process_sinan_leishmaniose_visceral(),process_sinan_leishmaniose_tegumentar(),process_sinan_dengue(),process_sinan_chikungunya(),process_sinan_chagas()).
microdatasus 2.4.0
- Update documentation on
fetch_datasus(). - Fetch SINAN-CHAGAS data.
- Process SINAN-CHAGAS data.
- Fetch SINAN-LEISHMANIOSE-VISCERAL and SINAN-LEISHMANIOSE-TEGUMENTAR data.
- Process SINAN-LEISHMANIOSE-VISCERAL and SINAN-LEISHMANIOSE-TEGUMENTAR data.
- Fetch SINAN-LEPTOSPIROSE data.
- Fix message when downloading data for all UFs.
microdatasus 2.3.4
- Fix error on tabNaturalidade, issue #123. Thanks @SophiaDamianoRovere and @hafermoraes for the suggestions.
- Fix FANTASIA names on CNES, issue #125.
microdatasus 2.3.1
CRAN release: 2024-06-18
- Import read.dbc package from CRAN.
- Remove CADGER data.
- General package adjustments for CRAN submission.
- Examples of process functions use data samples.
- Update package citation.
microdatasus 2.3.0
- All process functions uses dplyr verbs and dtplyr for fast processing.
- All process functions returns a tibble.
- Add
track_sourceargument tofetch_datasusfunction to create a variable calledsourcewith the file name that originated the row. - Updated CBO (CNES), CADGER (CNES), EQUIPE (SIA), SIGTAB (SIA) reference tables.
- Sample data for health information systems.
- Data files with XZ compression.
- Internal tests restructured.
- Progress bar removed from
process_simdue increased processing time.
microdatasus 2.2.7
- Enhance messages of
fetch_datasus. - Timeout the connection check when DataSUS FTP is down or not reachable.
- If there is no Internet or the DataSUS FTP is down or not reachable, the
fetch_datasuswill returnNULL. -
process_simshows a progress bar.
microdatasus 2.2.3
- As the package {read.dbc} is not available on CRAN, this patch uses the Github version.
- Issue #89 points out that files from SIM-EXT older than 2006 present 7-digits variable lengths for CODMUNRES and CODMUNOCOR. Those codes are now truncated to 6-digits standard by process_sim function.
- Related to #66, #84 and #86. Some files are very big to download, especially those from SIA and SIH. A timeout argument was added to the fetch_datasus with a default of 240 seconds.
- process_sinasc pull request #91 fixes issue #90, related to CODOCUPMAE variable
- Related to #79, now the function process_sia downloads an updated version from the SIGTAB table from DataSUS when nome_proced is TRUE.
microdatasus 2.2.1
- process_sinasc with new codes to process sex variable, avoiding missing results.
- process_cnes corrections to avoid NA introduction by coercion.
- process_sih corrects MUNIC_RES type
microdatasus 2.2.0
- fetch_datasus function uses read.dbc function with as.is set to TRUE for better performance.
- Minor bugs corrections.
microdatasus 2.1.0
- Bug correction that impacted download of all UFs from monthly data health systems.
microdatasus 1.4.4
- Updates SINAN functions for DataSUS changes in file structures, from per UF basis to all data (BR).
microdatasus 1.4.2
- Correct codmun handling for CNEST-ST data. Issue #38