0

I am working on an system and am trying to utilize ddd with node.js. Here is the an example for the system, from a high-level:

database tables(mongoldb):    
user    
username: String    
firstName: String    
middleName: String    
lastName: String    

department
title: String    
members: [{    
    user: {type: this.mongoose.Schema.ObjectId, ref: 'user’},    
    permissions: String    
}]    

patient   
user: {type: this.mongoose.Schema.ObjectId, ref: 'user’},    
department: [{type: this.mongoose.Schema.ObjectId, ref: ‘department’}]    

lab: [{    
    patient: {type: this.mongoose.Schema.ObjectId, ref: ‘patient’}    
    doctor: {type: this.mongoose.Schema.ObjectId, ref: 'user’},    
    type: String,    
    results: {there is a lot going on here, }    
}]

medication: [{    
    patient: {type: this.mongoose.Schema.ObjectId, ref: ‘patient’}    
    doctor: {type: this.mongoose.Schema.ObjectId, ref: 'user’},    
    name: String,    
    dosage: Number,    
    etc.    
}]

The business logic states that only the patient or a doctor that is a member of one of the departments in the patients, department list can review his medical information. I initially thought it should be in a separate domain Service as it appears to span entities, but the downside is that would require other services to call a permission service and I thought services should not call other services. If I placed in the lab and medication entities then I am duplication code and violating dry. If I add to the departments domain Service then I am making a service call another service. From a ddd perspective, where does logic like this belong?

user1790300
  • 2,143
  • 10
  • 54
  • 123
  • Application services shouldn't call upon other application services because they are use case entry points, but there is no limit on how many domain services you can use. – plalx Sep 30 '16 at 03:35

1 Answers1

0

Where did you get the idea services should not call other services. Security usually is a separate service or whatever.

Jason Livesay
  • 6,317
  • 3
  • 25
  • 31