← Selected work
Applied ML platform · synthetic data only

Pharmacy Reconciliation & Prescription Renewal ML Platform

An end-to-end Applied ML system for leakage-safe prescription-renewal prediction, operational follow-up workflows, and containerized deployment using entirely synthetic pharmacy data.

  • Python
  • scikit-learn
  • MLflow
  • FastAPI
  • PostgreSQL
  • Docker
Data100% synthetic
Final modelLogistic Regression
DeliveryValidated locally · not deployed
01 / Overview

From reconciliation workflow to an operational ML platform.

The project began as a pharmacy billing-vs-ordering reconciliation workflow and evolved into an end-to-end Applied ML system for prescription-renewal prediction and operational follow-up.

Synthetic evidence boundaryEvery record, prediction, and reported model result in this project is synthetic.
02 / Problem

Two connected operational questions.

Reconciliation

Billed vs ordered quantities

Compare medication quantities to surface shortages, overages, and records that need operational review.

Renewal review

Zero-refill prescriptions

Identify prescriptions that may need renewal review as expected medication supply approaches exhaustion.

System role: prioritize operational follow-up for human review—not provide clinical guidance or automatically close cases.
03 / Applied ML methodology

Designed around time, leakage prevention, and a locked Test.

  1. 01

    Deterministic longitudinal synthetic data

  2. 02

    Point-in-time prediction design

  3. 03

    Leakage prevention

  4. 04

    Chronological Train / Validation / Test split

  5. 05

    16-feature final model input

  6. 06

    Train-only preprocessing

  7. 07

    Time-series cross-validation

  8. 08

    Logistic Regression / Random Forest / XGBoost / LightGBM comparison

  9. 09

    Locked final Logistic Regression before Test

  10. 10

    Threshold = 0.50

  11. 11

    Test consumed once

04 / Final synthetic evaluation

Recall-first results, without real-world claims.

63.83%Accuracy
63.06%Precision
90.83%Recall
74.44%F1
73.52%PR-AUC
67.10%ROC-AUC
Bar chart of final model metrics on the locked synthetic Test set
Locked Logistic Regression evaluation on synthetic Test observations.

Interpretation: high recall means the model caught most synthetic renewal cases, with the trade-off of additional false-positive review workload. This is not clinical or real-world performance.

05 / ML engineering

Built beyond the model artifact.

01

MLflow experiment tracking and locked model artifact

02

FastAPI single and batch inference

03

PostgreSQL prediction history

04

Follow-up case workflow

05

Activities and explicit case resolution

06

Alembic migrations

07

Docker and Docker Compose

08

Persistent PostgreSQL volume

09

Health and readiness endpoints

10

Request IDs and privacy-safe logs

11

139 automated tests

12

GitHub Actions CI

06 / Architecture

Validated locally, with the future path kept separate.

Local platform architecture with a separately labeled future AWS path
Current local architecture and future infrastructure are intentionally separated.
Validated local system
  1. 01
    Synthetic dataFixed-seed longitudinal histories
  2. 02
    Feature engineeringPoint-in-time features
  3. 03
    Leakage-safe temporal MLChronological validation
  4. 04
    Locked Logistic RegressionThreshold 0.50
  5. 05
    MLflowLocked model artifact
  6. 06
    FastAPISingle and batch inference
  7. 07
    PostgreSQLPredictions and follow-up cases
  8. 08
    Docker ComposeValidated local system
Future architecture — not deployed

AWS components shown in the diagram are planning only and are not represented as deployed technology.

07 / Key engineering decisions

Constraints made explicit.

01

Chronology first

Used chronological splitting instead of a random split to preserve the temporal prediction setting.

02

Locked before Test

Selected the model and 0.50 threshold before consuming Test, with no Test-based retuning.

03

Synthetic by design

All longitudinal pharmacy records and reported model results are deterministic and synthetic.

04

Prefer interpretable

Selected simpler Logistic Regression after comparison with more complex tree-based models.

05

Human resolution

Cases require explicit operational resolution rather than automatic closure from model output.

08 / Limitations

What this work does not claim.

Synthetic data only

The system has not been evaluated on real pharmacy data.

Not a clinical model

Predictions support a simulated operational review workflow, not clinical decisions.

Not production deployed

The validated system runs locally with Docker Compose.

AWS is planning only

The AWS path is future architecture and has not been deployed.

No real-world claim

The reported metrics do not represent real pharmacy performance.

Technical implementation

Explore the complete system.

The repository contains the synthetic-data pipeline, trained model workflow, API, migrations, tests, operational case handling, and Docker Compose setup.

View repository ↗