Healthcare software gets hard to change when one model of the patient or the visit has to serve every team. A scheduler's appointment, a clinician's encounter and a biller's claim line all describe the same afternoon, but each carries different rules, and forcing them into one table ties every change to every other.
This post explains how domain-driven design helps: splitting a product into bounded contexts such as patient identity, scheduling, orders and billing, building a shared language with clinicians and billing staff, and deciding how those contexts talk to each other and to EHRs.
What is domain-driven design in healthcare?
Untangling a health product that has grown around one big model?
Our fractional CTO service helps product teams set domain boundaries before the next rebuild.
Domain-driven design in healthcare is a way of structuring software around the work of care: registration, scheduling, ordering, documentation and billing, each modeled in its own bounded context using words clinicians and staff recognize. Agnotic Technologies uses it so each part of a health product can change without breaking the others.
It is a design approach, not a framework or a library you install.
Why does one shared model break down?
One shared model breaks down because the same word means different things to different teams. To a scheduler an appointment is a slot with a provider and a room; to a clinician the visit is an encounter with problems, notes and orders; to a biller it is a set of charges waiting for codes.
When all three live in one table, a field added for billing appears on the scheduling screen, a status added for clinicians breaks a claim rule, and nobody can say which meaning a column holds. The fix is not a bigger model but several smaller ones with clear edges.
Which bounded contexts does a healthcare product need?
Most healthcare products need a handful of contexts that follow how the organization already divides its work. Each one owns its data and rules and shares only what the others need.
- Patient identity: registration, demographics, identifiers from each source system and duplicate resolution.
- Scheduling: providers, locations, templates, slots, appointments, arrivals and cancellations.
- Orders and results: what was ordered, by whom, where it was sent and what came back.
- Clinical documentation: encounters, notes, problems and medication lists as the clinician sees them.
- Billing: charges, codes, claims, payer rules and remittances.
A small product may hold two contexts in one module at first. What matters is knowing where the line would fall, so the code does not quietly grow across it.
How do contexts talk to each other?
Contexts talk through published events and narrow APIs, never by reading each other's tables. When scheduling records that a patient has arrived, it publishes a check-in event and documentation opens an encounter; when the clinician signs that encounter, billing starts charges and orders sends any new orders to the lab.
A context map records each of these relationships: which context publishes, which listens, and which one translates when the words differ.
How do you build a shared language with clinicians?
You build it by sitting with the people who do the work, writing down the words they use and the rules behind them, and then using exactly those words in code, screens and tests. The glossary belongs to a context: an order in the lab context is not the same thing as an order in the pharmacy context.
- Workshops: walk through real scenarios, such as a patient who arrives late, with front desk staff, nurses and billers.
- Glossary: one entry per term per context, with an example and the rule it carries.
- Names in code: classes, events and API fields use glossary terms, not database shorthand.
- Review: clinicians read event names and screen labels and flag any word that sounds wrong.
Where do FHIR and HL7 fit in a domain model?
HL7 FHIR and HL7 v2 belong at the edge of the system, as the published language used with EHRs and partners, rather than as the internal model of every context. Each context translates between its own terms and the standard at its boundary.
HL7 FHIR is a standard published by HL7 International for exchanging health data through RESTful APIs built on defined resources such as Patient, Observation and MedicationRequest.
Exchange resources carry optional elements and extensions one product rarely needs inside. A translation layer for each EHR connection maps incoming messages into the context's own terms and stops one vendor's quirks from spreading through the code.
Billing as its own context
Billing stays separate by receiving facts from other contexts, such as a signed encounter or a resulted test, and turning them into charges and claims under its own rules.
HIPAA adopts ASC X12 standards for electronic transactions, including health care claims (837), payment and remittance advice (835), eligibility inquiries (270/271) and prior authorization requests (278).
Those transaction formats should stay inside the billing context. When a payer changes a rule, only billing changes, and scheduling and documentation never need to know what a claim segment is.
How do bounded contexts help with privacy?
Bounded contexts help because each one can hold only the data its job needs, which makes access rules easier to write down and to check.
The HIPAA Privacy Rule's minimum necessary standard requires covered entities to limit uses and disclosures of protected health information to the minimum needed for the purpose.
Billing may need diagnosis codes but not the full note, and scheduling needs a name and a phone number but no results. Design each event to carry identifiers and the few fields its listeners use, never a copy of the whole chart.
Aggregates and rules inside a context
Inside a context, group the data that must change together into an aggregate with a single entry point, and keep the business rules there rather than in screens. An appointment aggregate, for example, checks that the slot is free, that the visit type suits the provider and that a cancellation follows clinic policy.
Keeping rules in one place means a mobile app, a front desk screen and an EHR feed all follow the same policy. Rules copied into each screen drift apart as the product grows.
What goes wrong when teams adopt domain-driven design?
Most failures come from keeping the vocabulary of the method while skipping the boundaries. These patterns recur.
- Contexts by layer: teams split into API, database and interface groups instead of by business capability.
- One giant patient: every context adds fields to a shared patient object until the old single model returns.
- Shared tables: two contexts write to the same table as a temporary shortcut, and the boundary disappears.
- Developer vocabulary: names such as status code two that no clinician can review.
- Services too early: each context deployed on its own before the team can operate that many.
A worked example: splitting a growing outpatient product
A specialty clinic product began as one application in which the appointment record also held notes, orders and charges. Every billing change meant retesting scheduling, and clinicians complained that screen labels used billing terms.
The team ran workshops with front desk staff, nurses and the billing lead, wrote a glossary and drew a context map. They moved billing behind events for signed encounters first, then separated orders and results, keeping one deployable application with clear modules.
After the split, payer rule changes touched only the billing module, and a nurse reviewed screen labels before each release.
Should each bounded context be a microservice?
Not at first. A bounded context is a boundary in the model, and it can live as a module inside one application until the team has a reason, such as a separate release rhythm or different scaling needs, to deploy it alone.
Enforce the boundary in code with separate packages, no database access across modules and build checks that fail when one module imports another's internals. Moving a context into its own service later then becomes a deployment change rather than a redesign.
Ownership of contexts and terms
Each context needs one owning team, and each glossary term needs one person who can say what it means.
- Product owner: the context map and decisions about moving a boundary.
- Clinical and billing leads: glossary terms and the rules behind them.
- Context teams: their model, data, events and API contracts.
- Integration team: translation layers for each EHR, lab, payer or partner.
- Privacy and security: which data each context and each event may carry.
How do you test a domain model?
Test it with scenarios written in the shared language, such as a patient cancelling inside the late cancellation window, that clinicians and staff can read and confirm.
- Scenario tests: one per rule, named in glossary terms and run against the aggregate.
- Contract tests: each published event and API checked against what its listeners expect.
- Boundary tests: the build fails if one module reads another's tables or internal classes.
- Translation tests: sample HL7 v2 and FHIR messages mapped into each context and back out.
What are domain-driven design in healthcare best practices?
Start from the work, not the database: run workshops with clinicians and staff, keep a glossary for each context, maintain a context map, and let contexts talk only through events and narrow APIs.
Keep standards such as FHIR and X12 at the edges, give each context only the data it needs, enforce boundaries in code before splitting services, and revisit the map whenever the organization takes on a new kind of work.
How Agnotic can help
Agnotic builds healthcare products around clear bounded contexts: running domain workshops with clinical and billing staff, drawing the context map, designing events and APIs, and building the translation layers to EHRs, labs and clearinghouses.
Build your next health product around clear domains with Agnotic
Our custom healthcare software team designs and builds products with boundaries that hold as they grow.
Related reading on Agnotic
Architecture, APIs, standards and domain testing.


