Downloads and compiles the simple (non-composite) coded-field reference
tables from the IMR NMD Reference API into a single long-format lookup. These are the
Biotic columns flagged as codes of type KeyType (e.g. sex,
maturationstage, missiontype, nation) whose meaning is otherwise
only resolvable against the API. The result is written to the DuckDB database as the
codeindex table by compileDatabase, so agents and the Shiny app can
decode these fields offline with a join instead of a per-code network call.
Usage
prepareReferenceCodes(tables = NULL, lang = c("en", "no"))Arguments
- tables
Character vector of reference-table names to pull. Defaults to the coded
KeyTypecolumns that actually occur inmission/stnall/indall. Note that a few Biotic columns map to a differently named reference dataset (e.g. thegearcolumn resolves against theequipmenttable — handled separately byprepareGearListand therefore not included here).- lang
Language for
shortname/description:"en"(default) or"no".
Value
A data.table with columns reftable, code,
shortname, and description, stacked across all successfully read tables.
Details
Reads each table from .../reference/v2/dataset/{table} (the same endpoint
family used by prepareGearList) and keeps only the code -> meaning
mapping. Editor-identity columns from the registry (updatedBy, insertedBy,
timestamps, ...By fields) are dropped on purpose so no staff usernames land in the
database. Tables that fail to download (e.g. off the IMR network) are skipped with a
warning rather than aborting the build. Composite reference tables that are keyed by taxa
and/or sex (specialstage, eggstage, moultingstage,
spawningfrequency) are intentionally not handled here — they need a
taxa/sex-aware lookup and are left to the API.