Domain Driven Design and Event Sourcing with RIM

  • Slides: 20
Download presentation
Domain Driven Design and Event Sourcing with RIM

Domain Driven Design and Event Sourcing with RIM

Introduction RIMResistance is Futile, you Will be Assimilated! 1

Introduction RIMResistance is Futile, you Will be Assimilated! 1

DDD and Event Sourcing • Introduction – George de la Torre • Developer of

DDD and Event Sourcing • Introduction – George de la Torre • Developer of custom clinical apps • For a long time • Discovered RIM a long time ago… – Oleg Sitalo (silent partner) • Developer of custom clinical apps • For a long time together • Believes in RIM, at occasions… 2

DDD and Event Sourcing • Agenda – Google will find heaps of stuff on

DDD and Event Sourcing • Agenda – Google will find heaps of stuff on this – Will focus on the RIM stuff – Great resources for DDD/ES • http: //msdn. microsoft. com/enus/library/jj 554200. aspx • Implementing Doman-Driven Design – Vaughn Vernon • Domain Driven Design (the Blue Book) – Eric Evans 3

DDD and Event Sourcing • Domain Driven Design – Object Oriented Model – Business

DDD and Event Sourcing • Domain Driven Design – Object Oriented Model – Business needs & language captured – HL 7 v 3 RIM benefits • • • Design done! – the hardest part Standard – open & shared to all Deep insights into domain knowledge Integration of domains built in (No barriers!) Reuse logic across clinical domains 4

HL 7 V 3 RIM Domain Model Blueprint for all Aggregates 5

HL 7 V 3 RIM Domain Model Blueprint for all Aggregates 5

Vocabulary Supporting Domains External Services Bounded Contexts 6

Vocabulary Supporting Domains External Services Bounded Contexts 6

Supporting Domains External Services Anti Corruption Layer Other systems or Big Ball of Mud…

Supporting Domains External Services Anti Corruption Layer Other systems or Big Ball of Mud… Business Process and Rules Engines Point: This layer keeps RIM pure! 7

DDD and Event Sourcing • Event Sourcing – Only the Aggregate (D-MIM) is persisted

DDD and Event Sourcing • Event Sourcing – Only the Aggregate (D-MIM) is persisted – The command is saved (Behavior) – Aggregates publishes the events – Command Query Responsibility Segregation (CQRS) • Command (Transaction) Model • Query Model 8

Patient Dashboard Example Use Case • Schedule a patient visit – Find Patient (Query

Patient Dashboard Example Use Case • Schedule a patient visit – Find Patient (Query Model) – View Calendar (Query Model) – Patient assigned time slot (Command) – Create. Appointment. Command(data) executes • Scheduling aggregate is created from data • The created aggregate is appended • Publishes event to update Query Model 9

Scheduling Aggregate Example 10

Scheduling Aggregate Example 10

Scheduling Aggregate CMET (PAT) is the Root 11

Scheduling Aggregate CMET (PAT) is the Root 11

Scheduling Aggregate • Considerations – Entity is usually the Root – No cloning, only

Scheduling Aggregate • Considerations – Entity is usually the Root – No cloning, only class codes – Aggregates varies with the RIM set – Act may be the Root (Strategy) • • Reference others Aggregates (Observations) Act Mood partitioning PHI segregation requirement (Query model too) Performance 12

Scheduling Aggregate • Considerations continued… – Serialized, XML, JSON, etc… – Relational Database (SQL)

Scheduling Aggregate • Considerations continued… – Serialized, XML, JSON, etc… – Relational Database (SQL) – Cache based systems – File systems – No. SQL • Natural for event stores • Easier to query Aggregates if needed • Aggregates loaded for logic on command 13

Scheduling Aggregate Appended Create. Appointment. Command(data) Event Store ID Name Version 1 Schedule 1.

Scheduling Aggregate Appended Create. Appointment. Command(data) Event Store ID Name Version 1 Schedule 1. 2 2 Schedule 1. 2 3 Schedule 1. 2 Data 14

Scheduling Aggregate Publishes Events Appointment. Created. Event(data) { Update. Database. View() } Query model

Scheduling Aggregate Publishes Events Appointment. Created. Event(data) { Update. Database. View() } Query model MRN First Last DOB Phone Start End Note 15

Scheduling Aggregate Publishes Events Appointment. Created. Event() { Create. Admission. Message() } HL 7

Scheduling Aggregate Publishes Events Appointment. Created. Event() { Create. Admission. Message() } HL 7 2. x MSH|^~&|ADT 1|MCM|LABADT|MCM|198808181126|SECURITY|ADT^A 01|MSG 00001|P|2. 3 EVN|A 01|198808181123 PID|||PATID 1234^5^M 11||JONES^WILLIAM^A^III||19610615|M-||C|1200 N ELM STREET^^GREENSBORO^NC^27401 -1020|GL|(91 -9)379 -1212|(919)2713434||S||PATID 12345001^2^M 10|123456789|9 -87654^NC 16

Scheduling Aggregate Publishes Events Appointment. Created. Event() { Update. Data. Mart() }

Scheduling Aggregate Publishes Events Appointment. Created. Event() { Update. Data. Mart() }

Patient Dashboard Example Two Separate Models (CQRS) • Domain (Transaction) Model – Complex structure

Patient Dashboard Example Two Separate Models (CQRS) • Domain (Transaction) Model – Complex structure (RIM) – Aggregates are only created from RIM – Aggregates are appended (Write Only) • Query Model – Simplified model structure (SQL) – Multiple models created as needed – Model optimized for querying (Read Only) 18

Simple Component Design CQRS Web Dashboard Query Commands App Services Aggregate Services Events Publishes

Simple Component Design CQRS Web Dashboard Query Commands App Services Aggregate Services Events Publishes to View Model SQL 19