DEV Community

Cover image for Designing a Scalable IPD Management System: How We Built It (and What We Learned)
Nzcares
Nzcares

Posted on

Designing a Scalable IPD Management System: How We Built It (and What We Learned)

Hospitals run on urgency. One minute everything’s calm, the next minute a critical patient arrives, and your system needs to handle it—now. When we started building an IPD (In-Patient Department) system for a hospital SaaS platform, we quickly realized: this isn’t your average web app.

You’re not just tracking admissions and bed numbers. You’re dealing with live vitals, emergency protocols, medication schedules, doctor rounds, insurance, inventory, and more—all flowing in parallel.

This post walks through how we approached building a scalable IPD module, the tech stack behind it, and the (many) lessons we learned along the way.

Step 1: Break the Monolith—Go Modular

We started by slicing the IPD into distinct services:

  • Admission/Discharge (ADT)
  • Bed Manager
  • EMR integration
  • Nursing interface
  • Billing
  • Lab/Pharmacy APIs

It’s tempting to just build one big service that “does it all,” but in practice, IPD needs different workflows for different teams. Nurses aren’t using the same dashboard as pharmacists. Admins need audit logs. Doctors want a minimal UI. So we separated concerns early on.

Everything communicates through REST and gRPC internally. Event queues (Kafka) help us track updates asynchronously—especially for things like medication updates or patient movement.

Step 2: Don’t Skip RBAC (Even If It’s Painful)

Hospitals are layered. Not everyone should see everything. A doctor needs to view a patient’s full chart. A front desk admin doesn’t. A lab tech shouldn’t modify discharge orders.

So we rolled out RBAC with granular scopes: vitals:read, medication:write, patient:assign_bed, etc.

We use a JWT-based system, where scopes are embedded in the token. At the service layer, everything gets checked.

We also log every access. Why? If something goes wrong—wrong medication, delayed discharge—you need a full audit trail.

Step 3: Real-Time Data Is Not Optional

Here’s where things get fun (and tricky).

Let’s say a patient’s oxygen level drops. You can’t wait for a backend cron job to run. We wired up MQTT to talk to wearable monitors, used Redis Pub/Sub to distribute updates, and Socket.IO to push alerts to the care team dashboard.

Here’s a rough sketch:

Medical Device → MQTT Broker → Redis Channel → Real-Time UI
Enter fullscreen mode Exit fullscreen mode

This setup isn’t just about alerts. It also keeps nurse dashboards synced with vitals, and flags when a patient might need escalation.

Step 4: Connecting the Dots—Labs, Pharmacy, and More

An IPD module doesn’t live in a vacuum. You need it to “talk” to:

  • Labs (LIMS)
  • Pharmacy stock systems
  • Insurance/TPA APIs
  • External wearables

We used FHIR as a translation layer, even though not everything on the backend uses it. Mapping reports to DiagnosticReport and medication orders to MedicationRequest helps when integrating with other systems down the road.

Pro tip: keep adapters loosely coupled. Every hospital has its own lab system and pharmacy quirks.

Step 5: Discharge Isn’t a Button. It’s a Flow.

One of the most common complaints from patients? "Why is discharge taking so long?"

Because it’s not one action. It’s five things:

  • Final rounds by doctor
  • Nurse notes updated
  • Final bills calculated
  • Medications verified
  • Reports handed over

We built a “discharge readiness” engine that checks all these steps and flags what’s pending. It’s saved hours of guesswork for the staff—and makes sure no step is missed.

We’re also experimenting with an AI-based predictor that estimates discharge time based on care progress and task completion. It’s not perfect yet, but it’s already showing promise.

Bonus: Logging, Auditing, and Compliance

This is healthcare. Mistakes are costly, and oversight is mandatory.

We added structured logs to nearly every action:

  • Who updated the vitals?
  • When was a patient transferred?
  • Who signed off on the medication?

It’s noisy at first, but absolutely essential for compliance (HIPAA, GDPR), and for debugging real-world issues.

Final Thoughts

Building an IPD management software is like building air traffic control for patient care. Everything is live, interconnected, and urgent. What surprised us most? It’s not just about tech. It’s about building trust into workflows—between people and systems.

If you’re building something similar, my advice: design like you’re in the ER. Think fast, think modular, and test like crazy.

We learned a lot building this for NZCares, and we’re still evolving the system every month. If you’re working on something similar (or better!), let’s connect—I’d love to hear what you’re solving.

Top comments (0)