View source: R/openfda_parser.R
| parseOpenFDA | R Documentation |
Reads openFDA's bulk download files for Drugs@FDA (drug/drugsfda)
and the NDC directory (drug/ndc) and returns a dvobject with
one table per record level, field names as in the files.
parseOpenFDA(
drugsfda_path = NULL,
ndc_path = NULL,
release = NULL,
release_date = NULL,
retrieved_at = NULL
)
drugsfda_path |
Character or NULL. Path to the Drugs@FDA download (zip or JSON). |
ndc_path |
Character or NULL. Path to the NDC directory download (zip or JSON). |
release |
Character or NULL. Release label, e.g. |
release_date |
Date, |
retrieved_at |
Date, |
Each download is one JSON object, {meta, results}, usually zipped
(drug-drugsfda-0001-of-0001.json.zip,
drug-ndc-0001-of-0001.json.zip). Zips are read directly, without
extracting them to disk; an unzipped .json file works too. The
parser checks the number of records against meta.results.total.
Drugs@FDA lists FDA application products (NDA, ANDA, BLA); the NDC
directory lists products registered for sale, including products sold
under an OTC monograph without an application. Every application, product,
submission and listing is kept as the files have it, including tentative
approvals (submission_status "TA"); the parser does no status
grouping and no matching across sources.
YYYYMMDD dates become dates. NDC packaging dates are written two ways
(20220525 and 04-DEC-09) and are kept as text, as written.
finished and sample are logical. Every other field stays text.
The openfda block of each record is kept as (key, field, value)
rows; it is openFDA's annotation, and it can belong to another drug (for
example ANDA202111).
release_date defaults to the files' meta.last_updated (the
export date) when every file given has the same one.
Parsing the full Drugs@FDA and NDC files takes about a minute and needs roughly 300 MB of memory.
openFDA data are released under CC0 1.0. openFDA asks for credit, which is
recorded in the object's metadata (see get_source_metadata),
and states: "Do not rely on openFDA to make decisions regarding medical
care."
A dvobject with tibbles. From Drugs@FDA:
drugsfda_application (key application_number),
drugsfda_product (key application and product_number),
drugsfda_active_ingredient, drugsfda_submission (key
application, submission_type and submission_number),
drugsfda_submission_property_type,
drugsfda_application_doc and drugsfda_openfda. From the
NDC directory: ndc_product (key product_id),
ndc_active_ingredient, ndc_route, ndc_pharm_class,
ndc_packaging and ndc_openfda. Only the tables of the
files given are built.
Other parsers:
cett_nodes_options(),
drug_node_options(),
parseDrugBank(),
parseHGNC(),
parseHPO(),
parseHealthCanadaDPD(),
parseOnSIDES(),
parseTWOSIDES(),
references_node_options()
openfda_dir <- system.file("extdata", "openfda", package = "dbparser")
openfda <- parseOpenFDA(
drugsfda_path = file.path(openfda_dir,
"drug-drugsfda-0001-of-0001.json.zip"),
ndc_path = file.path(openfda_dir, "drug-ndc-0001-of-0001.json.zip"),
release = "2026-10")
openfda$drugsfda_product[, c("application_number", "brand_name",
"marketing_status")]
get_source_metadata(openfda)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.