How to map same name entities between domains in DDD?

I am working on the migration of a project from desktop to web. I am using VueJS 3 (composition API). Since this project has lots of modules, I thought about using DDD on the frontend for organization and so far, things are going great, but I am facing a situation where I don't know exactly what to do. Just to give some idea of my architecture so far: I'll usually have in the domain two objects for one entity: one as a "work object" and the other as the validated entity. The "work object" is a representation for forms, such a form for creating a new user, where I can have the UserWO, which might be composed of other entities (also suffixed with WO); and I'll have the validated object User, which is created when I receive some object back from the backend (lising or 200 status after a creation). My problem is the following: I have a domain for "patients", where I create, edit, and do other operations with it, and I also have patients in another domain "surgery" (which is a very simplified version of the patient - just the data this domain requires). Because I am dealing with the frontend, this domain patients is used within a modal, a huge one, which is its own module, since I can, not only select a patient, but before passing the selected patient down, I can do any operation I want with this patient. Whenever I access the module for surgery, I open the patients modal (a domain) and select the patient I want to work with and then I'd have to pass down this selected patient to the module (surgery), but I don't know how to pass a Patient from domain patient to another Patient in the domain surgery. My best guess for this would be a mapper from one domain's entity to an entity in another domain, but I don't know where I'd place this mapper. I don't if I made myself clear, but if you guys can help, I'll appreciate it.

Mar 21, 2025 - 20:15
 0
How to map same name entities between domains in DDD?

I am working on the migration of a project from desktop to web. I am using VueJS 3 (composition API). Since this project has lots of modules, I thought about using DDD on the frontend for organization and so far, things are going great, but I am facing a situation where I don't know exactly what to do.

Just to give some idea of my architecture so far: I'll usually have in the domain two objects for one entity: one as a "work object" and the other as the validated entity. The "work object" is a representation for forms, such a form for creating a new user, where I can have the UserWO, which might be composed of other entities (also suffixed with WO); and I'll have the validated object User, which is created when I receive some object back from the backend (lising or 200 status after a creation).

My problem is the following: I have a domain for "patients", where I create, edit, and do other operations with it, and I also have patients in another domain "surgery" (which is a very simplified version of the patient - just the data this domain requires). Because I am dealing with the frontend, this domain patients is used within a modal, a huge one, which is its own module, since I can, not only select a patient, but before passing the selected patient down, I can do any operation I want with this patient. Whenever I access the module for surgery, I open the patients modal (a domain) and select the patient I want to work with and then I'd have to pass down this selected patient to the module (surgery), but I don't know how to pass a Patient from domain patient to another Patient in the domain surgery.

My best guess for this would be a mapper from one domain's entity to an entity in another domain, but I don't know where I'd place this mapper.

I don't if I made myself clear, but if you guys can help, I'll appreciate it.