Open Addison-Weatherhead opened 1 month ago
Under the hood, load_dictionary
always also loads the base dictionary that comes with ricu
. This happens at the end of the subroutine read_dictionary
by calling config_path
, which itself calls user_config_path
and default_config_path
. The former can be set via the environment variable RICU_CONFIG_PATH
.
The error comes from the fact that the .json in the documentation is copied out of the base dictionary. When you supply your own .json, ricu
loads both your .json and the base dictionary and tries to combine the concepts within them. Importantly, only the "sources"
part of the concept can be updated, all other entries (e.g., unit
, min
, max
) are expected to stay the same.
So, nothing is wrong with your .json but you tried to perform an update that isn't currently allowed. You can try two fixes that should work:
{
"glu2": {
"unit": "mg/dL",
"min": 0,
"max": 1000,
"description": "glucose",
"category": "chemistry",
"sources": {
"other_database": [
{
"ids": [50809, 50931],
"table": "labevents",
"sub_var": "itemid"
}
]
}
}
}
{
"glu": {
"sources": {
"mimic_demo": [
{
"ids": [999],
"table": "labevents",
"sub_var": "itemid"
}
]
}
}
}
Calling load_dictionary on the json file provided in the documentation (https://cran.r-project.org/web/packages/ricu/ricu.pdf) (page 34/35), yields this error:
What exactly is wrong with the concept-dict.json:
{ "glu": { "unit": "mg/dL", "min": 0, "max": 1000, "description": "glucose", "category": "chemistry", "sources": { "mimic_demo": [ { "ids": [50809, 50931], "table": "labevents", "sub_var": "itemid" } ] } } }
I'm using R 4.2.2, and ricu 0.6.0 (below is the entry for ricu from my renv.lock):
"ricu": { "Package": "ricu", "Version": "0.6.0", "Source": "GitHub", "RemoteType": "github", "RemoteHost": "api.github.com", "RemoteRepo": "ricu-package", "RemoteUsername": "prockenschaub", "RemoteRef": "monkeypatch0.6.0", "RemoteSha": "0969a52747c71ae9f47051d640caa5df2d5169a0", "Requirements": [ "R", "assertthat", "backports", "cli", "curl", "data.table", "fansi", "fst", "jsonlite", "methods", "openssl", "prt", "readr", "rlang", "stats", "tibble", "utils", "vctrs" ], "Hash": "2681cdea2f2f3446691071ea30f745b5" },