Domain Driven Design and Event Sourcing with RIM
description
Transcript of Domain Driven Design and Event Sourcing with RIM
![Page 1: Domain Driven Design and Event Sourcing with RIM](https://reader035.fdocuments.in/reader035/viewer/2022062519/56815238550346895dc07d56/html5/thumbnails/1.jpg)
Domain Driven Design and Event Sourcing with RIM
![Page 2: Domain Driven Design and Event Sourcing with RIM](https://reader035.fdocuments.in/reader035/viewer/2022062519/56815238550346895dc07d56/html5/thumbnails/2.jpg)
Introduction
2
RIMResistance is Futile, you Will be Assimilated!
![Page 3: Domain Driven Design and Event Sourcing with RIM](https://reader035.fdocuments.in/reader035/viewer/2022062519/56815238550346895dc07d56/html5/thumbnails/3.jpg)
DDD and Event Sourcing
3
• 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…
![Page 4: Domain Driven Design and Event Sourcing with RIM](https://reader035.fdocuments.in/reader035/viewer/2022062519/56815238550346895dc07d56/html5/thumbnails/4.jpg)
DDD and Event Sourcing
4
• Agenda– Google will find heaps of stuff on this– Will focus on the RIM stuff– Great resources for DDD/ES
• http://msdn.microsoft.com/en-us/library/jj554200.aspx• Implementing Doman-Driven Design
– Vaughn Vernon
• Domain Driven Design (the Blue Book)– Eric Evans
![Page 5: Domain Driven Design and Event Sourcing with RIM](https://reader035.fdocuments.in/reader035/viewer/2022062519/56815238550346895dc07d56/html5/thumbnails/5.jpg)
DDD and Event Sourcing
5
• Domain Driven Design– Object Oriented Model – Business needs & language captured – HL7 v3 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
![Page 6: Domain Driven Design and Event Sourcing with RIM](https://reader035.fdocuments.in/reader035/viewer/2022062519/56815238550346895dc07d56/html5/thumbnails/6.jpg)
Domain ModelBlueprint for all Aggregates
6
HL7 V3 RIM
![Page 7: Domain Driven Design and Event Sourcing with RIM](https://reader035.fdocuments.in/reader035/viewer/2022062519/56815238550346895dc07d56/html5/thumbnails/7.jpg)
7
Vocabulary
Supporting DomainsExternal Services
Bou
nd
ed
Con
texts
Bou
nd
ed
Con
texts
![Page 8: Domain Driven Design and Event Sourcing with RIM](https://reader035.fdocuments.in/reader035/viewer/2022062519/56815238550346895dc07d56/html5/thumbnails/8.jpg)
8
Supporting DomainsExternal Services
Other systems or Big Ball of Mud…
Anti Corruption LayerAnti Corruption Layer
Business Process and Rules Engines
Point: This layer keeps RIM pure!
![Page 9: Domain Driven Design and Event Sourcing with RIM](https://reader035.fdocuments.in/reader035/viewer/2022062519/56815238550346895dc07d56/html5/thumbnails/9.jpg)
DDD and Event Sourcing
9
• 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
![Page 10: Domain Driven Design and Event Sourcing with RIM](https://reader035.fdocuments.in/reader035/viewer/2022062519/56815238550346895dc07d56/html5/thumbnails/10.jpg)
Patient Dashboard ExampleUse Case
10
• Schedule a patient visit – Find Patient (Query Model)– View Calendar (Query Model)– Patient assigned time slot (Command)– CreateAppointmentCommand(data)
executes• Scheduling aggregate is created from data• The created aggregate is appended• Publishes event to update Query Model
![Page 11: Domain Driven Design and Event Sourcing with RIM](https://reader035.fdocuments.in/reader035/viewer/2022062519/56815238550346895dc07d56/html5/thumbnails/11.jpg)
11
Scheduling AggregateExample
![Page 12: Domain Driven Design and Event Sourcing with RIM](https://reader035.fdocuments.in/reader035/viewer/2022062519/56815238550346895dc07d56/html5/thumbnails/12.jpg)
12
Scheduling AggregateCMET (PAT) is the Root
![Page 13: Domain Driven Design and Event Sourcing with RIM](https://reader035.fdocuments.in/reader035/viewer/2022062519/56815238550346895dc07d56/html5/thumbnails/13.jpg)
13
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
![Page 14: Domain Driven Design and Event Sourcing with RIM](https://reader035.fdocuments.in/reader035/viewer/2022062519/56815238550346895dc07d56/html5/thumbnails/14.jpg)
14
Scheduling Aggregate
• Considerations continued…– Serialized, XML, JSON, etc…– Relational Database (SQL)– Cache based systems– File systems– NoSQL
• Natural for event stores• Easier to query Aggregates if needed• Aggregates loaded for logic on command
![Page 15: Domain Driven Design and Event Sourcing with RIM](https://reader035.fdocuments.in/reader035/viewer/2022062519/56815238550346895dc07d56/html5/thumbnails/15.jpg)
15
Scheduling AggregateAppended
ID Name Version Data
1 Schedule
1.2
2 Schedule
1.2
3 Schedule
1.2
CreateAppointmentCommand(data)
Event Store
![Page 16: Domain Driven Design and Event Sourcing with RIM](https://reader035.fdocuments.in/reader035/viewer/2022062519/56815238550346895dc07d56/html5/thumbnails/16.jpg)
16
Scheduling AggregatePublishes Events
AppointmentCreatedEvent(data) {
MRN First Last DOB Phone Start End Note
UpdateDatabaseView()
}
Query model
![Page 17: Domain Driven Design and Event Sourcing with RIM](https://reader035.fdocuments.in/reader035/viewer/2022062519/56815238550346895dc07d56/html5/thumbnails/17.jpg)
17
Scheduling AggregatePublishes Events
AppointmentCreatedEvent() {
CreateAdmissionMessage()
}
HL7 2.xMSH|^~\&|ADT1|MCM|LABADT|MCM|198808181126|SECURITY|ADT^A01|MSG00001-|P|2.3EVN|A01|198808181123PID|||PATID1234^5^M11||JONES^WILLIAM^A^III||19610615|M-||C|1200 N ELMSTREET^^GREENSBORO^NC^27401-1020|GL|(91-9)379-1212|(919)271-3434||S||PATID12345001^2^M10|123456789|9-87654^NC
![Page 18: Domain Driven Design and Event Sourcing with RIM](https://reader035.fdocuments.in/reader035/viewer/2022062519/56815238550346895dc07d56/html5/thumbnails/18.jpg)
Scheduling AggregatePublishes Events
AppointmentCreatedEvent() {
UpdateDataMart()
}
![Page 19: Domain Driven Design and Event Sourcing with RIM](https://reader035.fdocuments.in/reader035/viewer/2022062519/56815238550346895dc07d56/html5/thumbnails/19.jpg)
Patient Dashboard ExampleTwo Separate Models
(CQRS)
19
• 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)
![Page 20: Domain Driven Design and Event Sourcing with RIM](https://reader035.fdocuments.in/reader035/viewer/2022062519/56815238550346895dc07d56/html5/thumbnails/20.jpg)
Simple Component DesignCQRS
20
WebDashboard
WebDashboard
View ModelView ModelAggregate Services
Aggregate Services
App Services
App Services
Publishes to
Commands
Query
EventsEvents SQLSQL