I’m not very good with ruby so I’m very thankful for all the help offered 🙂
I have 2 models Clinic and Patient
clinics has three fields which I cache aggregates when a Patient is created
max_patients,
max_female_patients,
max_male_patients
I’m trying to wrap my brain around how to write a validation to check the following rules when adding a new Patient:
cannot have more than 37 total patients for 1 clinic,
15 female patients and 22 male patients is the standard,
however if a substitution needs to be made I can
swap out 3 male patients for 1 female,
or swap out 1 female patient for 1 male
The other nuisance is that patients are added 3 at time (on one form) and each patient can select a different clinic day.
I hope that makes sense.. I’ve been thinking about this for hours and I have a bad feeling I’m approaching this the wrong way.
Thanks for any help in advance
I wouldn’t create database columns for these attributes, I would
use a child-inheritable class variable through cattr_accessor
(class extension defined in ActiveSupport).
I’m not sure what you mean by:
I don’t think you’ve given enough info, or it’s not clear in my mind anyway.
For example, when does a substitution need to be made? Are the appointments recurrent, or a one-off (since it’s a clinic… I assumed one-off). Anyway, hope this helps.
-Luke