UML Class Diagram – How to Model User Management Using UML Class Diagram?

asp.net-mvcclass-diagramdesign-patternsmvcuml

I have school project where me and my team have to build a health care system. It consists of different modules including :

A module for doctors : It allows a doctor to access the medical records of his patients, send indications to them, consult his agenda…

A module for patients : A patient can take an appointment with his doctor, signal an emergency or send indicators (glycaemia level, weight, blood pressure). There are three types of patients that must be taken care of by the system : Women with a risky pregnancy, Diabetics and people suffering from Alzheimer. The latter are assisted by people from their family or medical staff.

A module for transportation : To affect and dispatch an ambulance at the location where a patient signaled an emergency.


Upon trying to model the solution through an UML class diagram (which is actually a due document for the project), we came across three problems/dilemmas :

  1. How to model a patient ?

Our first thought was to create a User class from which inherit the other classes like this :

Class diagram - inheritance from User.

But then this wouldn't allow a patient to be pregnant and diabetic for example. Which is bothersome.

After searching on the internet, we found out about role-based access control, we didn't delve into it because we thought it was intended for account management and permissions, not business related stuff like a patient having different roles (diabetic and pregnant for example).

We finally agreed on creating a Pathology class and adding a list of pathologies for each patient. Does this violate any good design principle ? Is there a standard or better way to do this ?

Another similar problem appears with the assistant. Since he can be a member of the patient's family or the medical staff, we would have an him either falling in the Assistant class under User or in the MedicalAssistant class under MedicalStaff. But I think this is the same problem as for the patient's pathologies.


  1. How to model an assistant ?

Again with the assistant, he is here to assist a patient suffering from Alzheimer : he makes doctor appointments for him and is notified if he wanders off too far (we've included a wearable bracelet equipped with a GPS in the solution). This raised up the issue of redundancy since we have classes Assistant and Patient which implement the method MakeAppointment(Doctor, Date). This raised two possibilities :

Should this method be in the Doctor class instead ?

Should we have an IAppointement interface containing the method ?

I personally think the method should be moved to the Doctor class (maybe this is even a basic OOP thing).


  1. How to represent MVC ?

We're going to make a website and a mobile app supporting the system. We've thought about using ASP.NET to get a hand on it and get to know about the MVC design pattern. After a little bit of documentation (mainly from the "MVC In PHP series" from Tom Butler and "GUI Architectures from Martin Fowler (both on their websites), We've come to ask ourselves if the Controller and View layers should be represented in a class diagram like this :

Class diagram - some controllers.

We've found this post on stackoverflow that asks a similar question :

How to create UML class diagrams for MVC

It says that only the model (business related classes) should be represented. But is that a general rule ? Should the Controller and View classes be represented ? How would that translate into a sequence diagram ?

I'm sorry for the post being so long and the questions quite heterogeneous. Thanks in advance for any help, advice or remarks you might give us.

Best Answer

1. How to model a patient ?

Your design, with its Account, User, and the different derivates of users are already a good start.

The Patient could indeed be a special kind of User. However, the Patient is not a Diabetic, Alzheimer or Pregnant. He/she has a pathology like Diabetes or Alzheimer, or a state like Pregnant. He/she may even have several pathologies at the same time. Therefore I strongly recommend to go for an association of a Patient with one or more Pathologies. So use the principle of composition over inheritance.

As you came to this orientation by yourself, I can only confirm that you're one the good way.

How to model an Assistant ?

The assistant is proxy for a Patient, at least in the business sense. He doesn't make an appointment for himself: he makes an appointment on behalf of a patient. Other patients may make their appointments themselves.

So the method of making an appointment should be offered by the Doctor (or more precisely, by the doctor's schedule). But this doesn't oppose to also have a MakeAppointment() on the Assistant, that will forward the call to the relevant Doctor.

And by the way, a patient also has a schedule: you shouldn't in principle make 2 appointments at the same time for the same patient. This brings le to a further approach: you could very well see MakeAppointment as a "Transaction Script", that checks if schedule of doctor and of patient are free at a given time, then books the appointment on the doctor's schedule, then books it on the patient's schedule.

3. How to represent MVC ?

In fact it depends on the purpose of your UML diagram.

If it is a domain model, then it should only contain the domain objects (e.g. Patients, Doctors, Users) and no controllers or views, which would only make the model more difficult to understand.

However, if it is an implementation model, the you may show whatever class you need to build your software, including controllers and views.

More on role model

To come back on the role model, the issue discussed about Pathology exist in reality also for other roles. For instance, a Doctor could as well be a patient, if he breaks his leg.

So one user could have several roles. This would similarly call for a composition design: the User would bear the identity and each user could have several roles. You have then to think about which attributes are general and belong to the user, and which ones are specific to a role.

Related Topic