Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

raxtik-source-faers

CI codecov License: AGPL-3.0

Official FDA FAERS/AERS data source connector, signature resolver, and canonical extractor for raxtik-etl.


🏛 Overview

raxtik-source-faers is an independent plugin that implements the SourceAdapter protocol for raxtik-etl. It isolates all FDA-specific archive formats, legacy ASCII quirks, and historical schema evolution from the canonical data platform:

  • Fail-closed signature resolution: Accurately classifies releases into S1, S2, or S3 schemas.
  • Raw ASCII extract staging: Safely parses $-delimited text files, embedded line-breaks, and historical field aliases.
  • Reference codelists: Embedded clinical lookup tables for FDA CDER routes, dosage forms, and reporter roles.
  • Zero-core coupling: Registers via Python standard entry points without requiring any FAERS-specific logic inside raxtik-etl.

🔍 Historical Signatures Handled

Signature Date Range Primary Keys Distinguishing Features
S1 2004Q1 – 2012Q3 ISR, CASE Legacy AERS: FOLL_SEQ, GNDR_COD. Missing modern columns (PROD_AI, AUTH_NUM).
S2 2012Q4 – 2014Q2 PRIMARYID, CASEID Migration Era: Transitional columns (gndr_cod, lot_nbr, outc_code).
S3 2014Q3 – Present PRIMARYID, CASEID Modern FAERS/AEMS: SEX, PROD_AI, AUTH_NUM, LIT_REF, DRUG_REC_ACT.

Signature detection is fail-closed: any unrecognized or malformed archive raises an explicit ValueError rather than silently defaulting to modern schemas.


🏛️ Canonical Data Model & Schema Mapping

The raw FDA ASCII files (DEMO, DRUG, REAC, OUTC, INDI, THER, RPSR) are projected into the unified canonical star-schema:

Entity Relationships & Composite Keys

Table Entity / Domain Primary Key (Composite) Foreign Key Relationship Description
demo Case Submissions & Demographics primary_id (Root submission table) Patient age in decimal years, weight in kg, sex, country, receipt date.
drug Drug Products & Regimens (primary_id, drug_seq) primary_id → demo.primary_id Reported brand name, active substance, route, form, role code (PS, SS, C, I).
reac Adverse Reactions (primary_id, reported_reaction_term) primary_id → demo.primary_id MedDRA Preferred Terms (PT) describing adverse events.
outc Patient Outcomes (primary_id, outc_code) primary_id → demo.primary_id Clinical outcomes: Death (DE), Hospitalization (HO), Disability (DS), etc.
indi Therapy Indications (primary_id, indi_drug_seq, reported_indication_term) (primary_id, indi_drug_seq) → drug(primary_id, drug_seq) Medical conditions for which medications were prescribed.
ther Therapy Timelines (primary_id, dsg_drug_seq) (primary_id, dsg_drug_seq) → drug(primary_id, drug_seq) Therapy start date, end date, and duration in days.
rpsr Report Sources (primary_id, rpsr_code) primary_id → demo.primary_id Reporting channel: Health Professional (HP), Consumer (CSM), Study (SDY), etc.
cases Authoritative Deduplicated View case_id Derived from demo Precomputed deterministic resolution to latest report version per case_id.

📖 Visual Entity-Relationship Diagram:


📦 Installation

Install alongside raxtik-etl:

pip install raxtik-source-faers raxtik-etl

Once installed, raxtik-etl automatically discovers the FAERS connector and provides the specialized FAERS dataset client.


🚀 Usage

1. Direct Hugging Face Loading & Streaming

Query precompiled quarterly packages from 2004Q1 through 2026Q3:

from raxtik_etl import FAERS

# 1. Default (Fastest): Downloads once, caches locally, queries in milliseconds
with FAERS.from_hf("2024Q1") as faers:
    cases = faers.cases(limit=100)
    print(cases)

# 2. Zero-Disk Streaming: Streams directly over HTTPS without local downloads
with FAERS.from_hf("2024Q1", remote=True) as faers:
    cases = faers.cases(limit=100)
    print(cases)

2. Remote Querying via DuckDB (Zero Local Storage)

Query precompiled datasets on Hugging Face Hub over HTTPS without downloading full files to disk.

Option A: Remote DuckDB ATTACH (Single File URL, Full Schema & Views)

import duckdb

con = duckdb.connect()
# httpfs is DuckDB's native C++ extension (no pip install required)
con.execute("INSTALL httpfs; LOAD httpfs;")

# 1 single URL attaches all 7 tables and the precomputed cases view
db_url = "https://huggingface.co/datasets/raxtik-org/faers-safety-database/resolve/main/bronze/2024/faers_2024Q1.duckdb"
con.execute(f"ATTACH '{db_url}' AS faers (READ_ONLY);")

con.execute("""
    SELECT d.reported_drug_name, COUNT(*) AS report_count
    FROM faers.drug d
    JOIN faers.reac r ON d.primary_id = r.primary_id
    WHERE d.role_code = 'PS' AND r.reported_reaction_term = 'Myocardial infarction'
    GROUP BY d.reported_drug_name ORDER BY report_count DESC LIMIT 5;
""").show()

Note: Initial ATTACH takes ~10s to load catalog metadata over HTTP, after which subsequent queries execute directly.

Option B: Remote Parquet Scanning (Column Range Requests)

import duckdb

con = duckdb.connect()
con.execute("INSTALL httpfs; LOAD httpfs;")

con.execute("""
    SELECT d.reported_drug_name, COUNT(*) AS report_count
    FROM 'https://huggingface.co/datasets/raxtik-org/faers-safety-database/resolve/main/bronze/2024/faers_2024Q1.parquet/drug.parquet' d
    JOIN 'https://huggingface.co/datasets/raxtik-org/faers-safety-database/resolve/main/bronze/2024/faers_2024Q1.parquet/reac.parquet' r
      ON d.primary_id = r.primary_id
    WHERE d.role_code = 'PS' AND r.reported_reaction_term = 'Myocardial infarction'
    GROUP BY d.reported_drug_name ORDER BY report_count DESC LIMIT 5;
""").show()

3. Download Quarterly FDA Archives

from raxtik_source_faers import download_quarterly_archive

# Downloads and verifies official quarterly FDA archive zip
zip_path = download_quarterly_archive(year=2024, quarter=1, dest_dir="data/raw")
print(f"Downloaded to {zip_path}")

4. Extract into Canonical DuckDB via Adapter

import duckdb
from pathlib import Path
from raxtik_etl.sources.protocol import SourceArtifact
from raxtik_source_faers import FAERSAdapter

con = duckdb.connect("my_database.duckdb")
adapter = FAERSAdapter()

artifact = SourceArtifact(path=Path("data/raw/faers_ascii_2024q1.zip"), release="2024Q1")

result = adapter.extract_and_load(con, artifact)
print(f"Extracted {result.row_counts['demo']} reports under signature {result.signature_id}")

👥 Contributors

See CONTRIBUTORS.md for all project contributors.


📄 License

Licensed under the GNU Affero General Public License v3.0 (AGPL-3.0).

Metadata

Release files for raxtik-source-faers 0.1.0.dev1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for raxtik-source-faers 0.1.0.dev1
File Size Uploaded Provenance Actions
raxtik_source_faers-0.1.0.dev1.tar.gz 57.8 kB With provenance Details for raxtik_source_faers-0.1.0.dev1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for raxtik-source-faers 0.1.0.dev1
File Interpreter ABI Platform Actions
raxtik_source_faers-0.1.0.dev1-py3-none-any.whl Python 3 none any Details for raxtik_source_faers-0.1.0.dev1-py3-none-any.whl

Total release size: 113.2 kB

Release files / raxtik_source_faers-0.1.0.dev1.tar.gz

Download URL raxtik_source_faers-0.1.0.dev1.tar.gz
Size 57.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ae9b47e73747fb1dca07113801bfb952893bd4477d4e4248f0447299270961af
BLAKE2b-256 checksum
How to use checksums
73b12ac8303dd656d740d3b89a3fa42a2912abf697406c9fee52c8796d7c8b45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / raxtik_source_faers-0.1.0.dev1-py3-none-any.whl

Download URL raxtik_source_faers-0.1.0.dev1-py3-none-any.whl
Size 55.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5a4945c4df2c4444209acba367826bf0a1a055483c9b5a8430b5811d4f6e7ff7
BLAKE2b-256 checksum
How to use checksums
12105ff525050db412e11a29b1ccc43ad6e431e0ab15102c9ca3bd303f78a782
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Security for raxtik-source-faers 0.1.0.dev1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for raxtik_source_faers-0.1.0.dev1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page