Type: New Feature
Affects Version/s: None
Fix Version/s: Logic 0.5
When you evaluate a rule, the logic service fetches a Patient object to pass to Rule.eval(LogicContext, Patient, Map). This fetch is expensive for large cohorts--it's actually the most expensive step in evaluating simple rules. (It takes ~30 seconds for 20k patients on my laptop.)
However doing a data source read (perhaps through a ReferenceRule) does not give you access to that Patient. The method signature is read(LogicContext, Cohort, LogicCriteria).
A side-effect of this is that it is twice as slow to run the ReferenceRule "person.birthdate" (which goes to the data source, even though the framework has already loaded up patient objects) than it would be to write a birthdate rule in java which would just return the birthdate off the passed-in patient object.
There are two possible fixes:
- Don't pass a real Patient object to Rule.eval – instead pass it a "new Patient(pid)" and force the rule to do a data source read if it wants a full Patient object.
- Burke points out that this is bad and we should just change the method signature to take an Integer. I agree in theory, but I don't know how to change this in a backwards-compatible way. Maybe since few people are using logic, we can break backwards-compatibility this time.
- Change the method signature of LogicDataSource.read to take a Collection<Patient> instead of a Cohort.
I prefer the first option, and I'm okay breaking backwards-compatibility this time.