Bounded variant of CODES("all", ...) for callers that need to keep any
single call's work small (e.g. to stay under a network-layer request
timeout), rather than materialising the whole code type in one unbounded
scan. See DESCRIPTION_CHUNK() for the equivalent for a description
search - this is simpler, since there's no search predicate: each chunk is
just the rowid-bounded slice of the lookup table, read directly.
Usage
CODES_ALL_CHUNK(
type = getOption("codeminer.code_type"),
cursor = 0L,
batch_size = getOption("codeminer.chunk_batch_size", default = 200000L),
total_rows = NULL,
accumulated_so_far = 0L,
max_rows = getOption("codeminer.max_leaf_rows", default = 30000L),
lookup_version = getOption("codeminer.lookup_version", default = "latest"),
preferred_description_only = TRUE,
col_filters = "default"
)Arguments
- type
character. Type of clinical code system to be searched. Optional if input is a data frame with code_type column. Depends on what is available in the lookup tables. See
add_lookup_table()on how to add new lookup tables. This can also be configured through thecodeminer.code_typeoption.- cursor
Integer.
rowidto start this chunk's scan from.0for the first call.- batch_size
Integer. Number of
rowids to scan in this call. Defaults togetOption("codeminer.chunk_batch_size", default = 2000).- total_rows
Integer or
NULL. The underlying table's total row count. PassNULLon the first call (it will be resolved and returned); pass the previously-returned value on subsequent calls to skip re-resolving it.- accumulated_so_far
Integer. Total matched rows found by this leaf's previous chunks (before this one).
0for the first call. Used to checkmax_rowscumulatively across the whole chunked fetch, not just this one call.- max_rows
Integer. Ceiling on this leaf's cumulative matched rows across all chunks. Aborts with class
codeminer_max_leaf_rows_exceededif exceeded. Defaults togetOption("codeminer.max_leaf_rows", default = 30000).- lookup_version
character. Version of the lookup table to use. Default:
"latest". Can be configured through thecodeminer.lookup_versionoption.- preferred_description_only
Logical. If
TRUE, return only the preferred description for each code.- col_filters
Column filters to apply. See
CODES()for details.
Value
A list with result, next_cursor, total_rows, and exhausted
see
DESCRIPTION_CHUNK()for the shape.
See also
Other Clinical code lookups and mappings:
CODES(),
CODES_LIKE_CHUNK(),
DESCRIPTION_CHUNK(),
MAP(),
get_lookup_table(),
get_mapping_table(),
get_relationship_table(),
get_relationship_tree()
Examples
create_dummy_database()
#> ✔ Dummy database ready to use!
#> ℹ To reconnect to your previous database:
#> `Sys.setenv(CODEMINER_DB_PATH = "/tmp/Rtmp2UzWkJ/file1c0537109b58.duckdb")`
#> `codeminer_connect()`
chunk <- CODES_ALL_CHUNK(type = "ICD-10", batch_size = 100)
#> ℹ Using "UKB v4" as the latest lookup version for "ICD-10".
chunk$result
#> <codeminer_codelist>: 100 codes
#> Code type: "ICD-10"
#>
#> # A tibble: 100 × 3
#> code description code_type
#> <chr> <chr> <chr>
#> 1 A00 Cholera ICD-10
#> 2 A000 Cholera due to Vibrio cholerae 01, biovar cholerae ICD-10
#> 3 A001 Cholera due to Vibrio cholerae 01, biovar eltor ICD-10
#> 4 A009 Cholera, unspecified ICD-10
#> 5 A010 Typhoid fever ICD-10
#> 6 A02 Other salmonella infections ICD-10
#> 7 A020 Salmonella enteritis ICD-10
#> 8 A021 Salmonella sepsis ICD-10
#> 9 A022 Localized salmonella infections ICD-10
#> 10 A028 Other specified salmonella infections ICD-10
#> # ℹ 90 more rows
chunk$exhausted
#> [1] FALSE