offdataai
Healthcare & Life Sciences · data model template

Pharmacy Management data model

Normalized (3NF) pharmacy-management model. The prescription order is separated from its individual fills/dispenses, drug products are keyed by NDC and RxNorm, claims follow the NCPDP Telecommunication adjudication shape, and cost-share is broken out into copay components. Controlled-substance flags (DEA schedule) and interaction/recall knowledge bases support dispensing safety. PHI is classified phi and masked.

Operational pharmacy-management data for retail, mail-order, and specialty dispensing: patients, prescribers, drug products (NDC/RxNorm), prescriptions, fills/dispenses, inventory lots, suppliers, insurance plans, NCPDP insurance claims, patient copays, drug-drug interactions, and FDA recalls. Patient and prescriber PHI is classified and masked for HIPAA. It is a normalized (3NF) relational model that mirrors the source system, suited to operational databases and to landing source data faithfully.

3NFHealthcare & Life SciencesHIPAADEAHITECH
13
tables
165
columns
17
relationships
12
PII columns

Opening the template creates a project with the ERD, platform-native DDL, a dbt project and documentation already generated (recommended platform: PostgreSQL). Edit it in plain English or on the canvas, then ship it to any supported warehouse.

Subject areas

partiesdrug_catalogdispensingbilling

Design decisions

  • Prescription order separated from fills

    A prescription authorizes a quantity with refills; each dispense is a distinct fill with its own NDC, quantity, and pricing. Modeling fills as children of the prescription preserves the true dispensing grain and supports adherence (days-supply) analytics.

  • NDC and RxNorm coding for drug products

    Drugs are keyed by the 11-digit National Drug Code and cross-walked to RxNorm so substitutions, formulary lookups, and interaction checks are interoperable.

  • NCPDP claim adjudication structure

    Pharmacy claims are adjudicated in real time via the NCPDP Telecommunication Standard (BIN/PCN routing, B1/B2 transactions, reject codes); modeling claims and copays accordingly matches the real reimbursement flow.

  • PHI and controlled-substance controls for HIPAA/DEA

    Patient/prescriber identifiers and cardholder IDs are classified phi and masked, and DEA numbers/schedules are restricted and fully masked, supporting HIPAA and DEA controlled-substance recordkeeping.

Tables in the Pharmacy Management model

Every table with its grain, columns, types and keys. PK marks a primary key, BK a business key and PII a column classified as personal data, which gets a masking strategy by default.

Tables (13)

pharmacy

Grain: one row per pharmacy location

ColumnTypeKeys
pharmacy_keybigintPK
pharmacy_idvarcharBK
ncpdp_idvarchar
npivarchar
namevarchar
pharmacy_typevarchar
dea_numbervarchar
phonevarchar
address_line1varchar
cityvarchar
statevarchar
postal_codevarchar
is_activeboolean

patient

Grain: one row per patient

All PHI masked for HIPAA.

ColumnTypeKeys
patient_keybigintPK
patient_idvarcharBK
ssnvarcharPII
first_namevarcharPII
last_namevarcharPII
date_of_birthdatePII
gendervarchar
emailvarcharPII
phonevarcharPII
address_line1varcharPII
cityvarchar
statevarchar
postal_codevarchar
preferred_languagevarchar
is_activeboolean

prescriber

Grain: one row per prescribing clinician

ColumnTypeKeys
prescriber_keybigintPK
prescriber_idvarcharBK
npivarchar
dea_numbervarchar
first_namevarcharPII
last_namevarcharPII
specialtyvarchar
license_numbervarchar
license_statevarchar
phonevarcharPII
is_activeboolean

supplier

Grain: one row per drug wholesaler / supplier

ColumnTypeKeys
supplier_keybigintPK
supplier_idvarcharBK
namevarchar
dea_numbervarchar
account_numbervarchar
contact_namevarcharPII
phonevarchar
emailvarchar
address_line1varchar
cityvarchar
statevarchar
postal_codevarchar
is_activeboolean

drug

Grain: one row per drug product (NDC)

ColumnTypeKeys
drug_keybigintPK
ndcvarcharBK
rxnorm_codevarchar
brand_namevarchar
generic_namevarchar
drug_classvarchar
dosage_formvarchar
strengthvarchar
strength_unitvarchar
routevarchar
dea_schedulevarchar
is_controlledboolean
manufacturervarchar
awpdecimal
is_activeboolean

insurance_plan

Grain: one row per pharmacy benefit plan (BIN/PCN)

ColumnTypeKeys
insurance_plan_keybigintPK
plan_idvarcharBK
payer_namevarchar
binvarchar
pcnvarchar
group_numbervarchar
plan_typevarchar
formulary_idvarchar
is_activeboolean

prescription

Grain: one row per prescription (the order)

The prescription order; individual dispenses are fills.

ColumnTypeKeys
prescription_keybigintPK
patient_keybigint
prescriber_keybigint
drug_keybigint
pharmacy_keybigint
rx_numbervarcharBK
written_datedate
sigvarchar
quantity_writtendecimal
days_supplysmallint
refills_authorizedsmallint
refills_remainingsmallint
daw_codevarchar
is_controlledboolean
originvarchar
statusvarchar
expiration_datedate

fill

Grain: one row per dispensed fill of a prescription

Dispense events; one prescription has many fills.

ColumnTypeKeys
fill_keybigintPK
prescription_keybigint
pharmacy_keybigint
drug_keybigint
fill_numbersmallint
quantity_dispenseddecimal
days_supplysmallint
fill_datedate
sold_datedate
lot_numbervarchar
ingredient_costdecimal
dispensing_feedecimal
total_pricedecimal
pharmacist_initialsvarchar
statusvarchar

inventory

Grain: one row per drug lot held in pharmacy stock

ColumnTypeKeys
inventory_keybigintPK
pharmacy_keybigint
drug_keybigint
supplier_keybigint
lot_numbervarcharBK
quantity_on_handdecimal
reorder_pointdecimal
unit_costdecimal
expiration_datedate
received_datedate
storage_locationvarchar
statusvarchar

insurance_claim

Grain: one row per adjudicated pharmacy claim (NCPDP)

NCPDP Telecommunication claim adjudication.

ColumnTypeKeys
insurance_claim_keybigintPK
fill_keybigint
insurance_plan_keybigint
patient_keybigint
claim_idvarcharBK
rx_reference_numbervarchar
transaction_codevarchar
cardholder_idvarcharPII
ingredient_cost_submitteddecimal
dispensing_fee_submitteddecimal
gross_amount_duedecimal
amount_paiddecimal
patient_pay_amountdecimal
adjudication_statusvarchar
reject_codevarchar
submitted_datetimetimestamp
adjudicated_datetimetimestamp

copay

Grain: one row per patient cost-share component on a claim

ColumnTypeKeys
copay_keybigintPK
insurance_claim_keybigint
patient_keybigint
cost_share_typevarchar
amountdecimal
deductible_applieddecimal
coinsurance_amountdecimal
benefit_stagevarchar
payment_methodvarchar
collectedboolean
collected_datedate

drug_interaction

Grain: one row per known drug-drug interaction pair

Interaction knowledge base referenced at dispensing.

ColumnTypeKeys
drug_interaction_keybigintPK
drug_keybigint
interacting_drug_keybigint
severityvarchar
mechanismvarchar
clinical_effectvarchar
managementvarchar
documentation_levelvarchar
reference_sourcevarchar

drug_recall

Grain: one row per FDA drug recall affecting a lot

ColumnTypeKeys
drug_recall_keybigintPK
drug_keybigint
recall_numbervarcharBK
affected_lot_numbervarchar
classificationvarchar
reasonvarchar
statusvarchar
recall_initiation_datedate

Relationships

Each relationship is a foreign key on the first table referencing the second.

  • prescription.patient_key → patient (many-to-one)
  • prescription.prescriber_key → prescriber (many-to-one)
  • prescription.drug_key → drug (many-to-one)
  • prescription.pharmacy_key → pharmacy (many-to-one)
  • fill.prescription_key → prescription (many-to-one)
  • fill.pharmacy_key → pharmacy (many-to-one)
  • fill.drug_key → drug (many-to-one)
  • inventory.pharmacy_key → pharmacy (many-to-one)
  • inventory.drug_key → drug (many-to-one)
  • inventory.supplier_key → supplier (many-to-one)
  • insurance_claim.fill_key → fill (many-to-one)
  • insurance_claim.insurance_plan_key → insurance_plan (many-to-one)
  • insurance_claim.patient_key → patient (many-to-one)
  • copay.insurance_claim_key → insurance_claim (many-to-one)
  • copay.patient_key → patient (many-to-one)
  • drug_interaction.drug_key → drug (many-to-one)
  • drug_recall.drug_key → drug (many-to-one)

Related templates

All templates →
Start for $1

From requirements to AI-ready context, in one platform.

Describe your business in a conversation, start from a template or connect your own database. Your first model is ready in minutes.

Get startedBook a demo

Plans from $1/month · cancel any time