I'm writing a medical billing application and am using MVC (Spring) for the first time so I'm struggling to get an approach that feels right. Thoughts/comments would be appreciated.
My "domain" classes
- Doctor
- Patient
- Claim
- BusinessLogic
My controller classes
- ListPatients
- EditPatients
- FindPatients
- SubmitClaim
My repository classes
- IPatientDao
- IDoctorDao
- IClaimDao
My application is very "rule heavy". For example, doctors can't delete the patients of other doctors. Patients can't be deleted if they have been billed for something.
I think these rules should not be captured in Controllers, which feels dirty, especially if a rule needed to be utilised in several controllers. Similarly, I feel my DAO objects are for reading & writing only, not validation. As a consequence, I have made a BusinessLogic object which has the brains. So I can call something like:
businessLogic.deletePatient(patient,doctor); //returns true/false and sets a message
This does a check to see if the logged-in doctor has the right to delete a specific patient.
To me this seems the best way of keeping everything tidy.
Good or bad? What would be better?