Power BI page: Medication Analysis ·
Data view: vw_prescription_analysis ·
Verified against data/databricks_output/exports/vw_prescription_analysis.csv
The Medication Analysis page explores inpatient pharmacy orders — drug frequency, administration routes, prescription duration, and drug-type classification across the MIMIC demo cohort.
Four headline metrics across the top of the page. Recomputed from the CSV export — exact match with the live dashboard (Power BI rounds 18,087 to 18K).
| Card | Value | Verified | DAX |
|---|---|---|---|
| Total Prescriptions | 18,087 | 18,087 | COUNTROWS(vw_prescription_analysis) |
| Patients Receiving Medication | 100 | 100 | DISTINCTCOUNT(patient_id) |
| Unique Drugs | 626 | 626 | DISTINCTCOUNT(drug_name) |
| Avg Prescription Duration | 2.71 days | 2.71 | AVERAGE(prescription_duration_days) |
Derived: 72.3 prescriptions per admission on average (18,087 ÷ 250 admissions with pharmacy records). All 100 patients received at least one medication. 25 admissions (of 275 total) have no linked prescription rows in this view.
Note: Power BI may display 598 unique drugs if built on a slightly earlier export; current CSV has 626 distinct drug_name values (579 MAIN · 46 BASE · 5 ADDITIVE-only names).
Four slicers on the left panel cross-filter all KPI cards and charts:
| Slicer | Values |
|---|---|
administration_route | IV · PO/NG · PO · SC · IV DRIP · IM · IH · TP · PR · ORAL · TD · IVPCA · IV BOLUS · DWELL · NU · NG · NEB · DIALYS · ED · SL · ID · and others (34 routes total) |
age_group | 18-34 · 35-49 · 50-64 · 65-79 · 80+ |
gender | F · M |
drug_type | MAIN · BASE · ADDITIVE |
| Drug | Prescriptions | Share |
|---|---|---|
| Insulin | 915 | 5.1% |
| 0.9% Sodium Chloride | 810 | 4.5% |
| Potassium Chloride | 610 | 3.4% |
| Sodium Chloride 0.9% Flush | 585 | 3.2% |
| Furosemide | 510 | 2.8% |
| 5% Dextrose | 492 | 2.7% |
| Bag | 454 | 2.5% |
| Magnesium Sulfate | 402 | 2.2% |
| Metoprolol Tartrate | 371 | 2.1% |
| Acetaminophen | 344 | 1.9% |
| Route | Prescriptions | Share |
|---|---|---|
| IV | 8,219 | 45.44% |
| PO/NG | 3,841 | 21.24% |
| PO | 2,191 | 12.11% |
| SC | 1,249 | 6.91% |
| IV DRIP | 1,026 | 5.67% |
| IM | 370 | 2.05% |
| IH | 194 | 1.07% |
| All other routes | 997 | 5.51% |
| Drug Type | Prescriptions | Share |
|---|---|---|
| MAIN | 14,391 | 79.6% |
| BASE | 3,677 | 20.3% |
| ADDITIVE | 19 | 0.1% |
Sorted by highest mean duration. Rare single-occurrence drugs can show very long averages tied to extended admissions.
| Drug | Avg Duration (days) |
|---|---|
| Clotrimazole | 23.29 |
| Aluminum Hydroxide Suspension | 23.25 |
| Sodium Fluoride 1.1% (Dental Gel) | 23.25 |
| Clonidine Patch 0.3 mg/24 hr | 18.33 |
| Psyllium Powder | 15.17 |
| Esomeprazole sodium | 14.96 |
| Caphosol | 14.17 |
| ruxolitinib | 13.54 |
| Collagenase Ointment | 12.17 |
| Hydrocortisone | 12.08 |
| Age Group | Prescriptions | Share |
|---|---|---|
| 50–64 | 7,440 | 41.1% |
| 65–79 | 5,265 | 29.1% |
| 80+ | 1,776 | 9.8% |
| 35–49 | 2,568 | 14.2% |
| 18–34 | 1,038 | 5.7% |
70.2% of prescriptions serve patients aged 50–79 — consistent with Dashboard 1 and 2 demographic patterns.
Male patients account for 10,493 prescriptions (58.0%) vs female 7,594 (42.0%), reflecting higher admission/utilization in the male cohort.
| Admission Type | Prescriptions | Share |
|---|---|---|
| EW EMER. | 7,291 | 40.3% |
| URGENT | 3,679 | 20.3% |
| OBSERVATION ADMIT | 3,581 | 19.8% |
| SURGICAL SAME DAY ADMISSION | 1,239 | 6.8% |
| DIRECT EMER. | 1,011 | 5.6% |
IV and IV DRIP routes (9,245 combined, 51.1%) align with the high volume of BASE fluids (saline, dextrose) and electrolyte replacements. SC route (1,249) maps primarily to insulin orders.
Four measures on this page. Full reference: powerbi/mimic_powerbi_dax_measures.md
Total Prescriptions = COUNTROWS(vw_prescription_analysis)
Patients Receiving Medication =
DISTINCTCOUNT(vw_prescription_analysis[patient_id])
Unique Drugs = DISTINCTCOUNT(vw_prescription_analysis[drug_name])
Avg Prescription Duration =
AVERAGE(vw_prescription_analysis[prescription_duration_days])
import pandas as pd
df = pd.read_csv("data/databricks_output/exports/vw_prescription_analysis.csv")
assert len(df) == 18087
assert df["patient_id"].nunique() == 100
assert df["drug_name"].nunique() == 626
assert round(df["prescription_duration_days"].mean(), 2) == 2.71
assert df["administration_route"].value_counts()["IV"] == 8219
Output: data/databricks_output/exports/prescription_analysis.json