...
Code Block | ||
---|---|---|
| ||
import java.util.Map; import org.openmrs.Patient; import org.openmrs.logic.*; import org.openmrs.logic.rule.*; import org.openmrs.logic.result.*; public class GENERATED-NAME extends AbstractRule { public Result eval(LogicContext context, Integer patientId, Map<String, Object> parameters) throws LogicException { // YOUR-CONTENT-INSERTED-HERE } } |
...
Code Block | ||
---|---|---|
| ||
/* * In order to add as little overhead as possible, allowing rules to be runrun * relatively efficiently on very large * cohorts, the rule framework does notnot * automatically provide us with a Patient object, but just a patientId. * This line fetches that Patient object. (It actually fetches all patients patients* in the cohort the rule is being evaluated * on.) */ def patient = context.getPatient(patientId) /* * We want this rule to work correctly if you evaluate it as-of some other other* date. So we fetch the index date from * the LogicContext. "context.indexDate" * is groovy shorthand for "context.getIndexDate()" */ def age = patient.getAge(context.indexDate) /* * We need to wrap our returned value in a logic Result. */ return new Result(age) |
...
Code Block | ||
---|---|---|
| ||
package org.openmrs.module.logic.rule;
import java.util.Map;
import org.openmrs.Patient;
import org.openmrs.logic.*;
import org.openmrs.logic.rule.*;
import org.openmrs.logic.result.*;
public class CompiledRule3 extends AbstractRule {
public Result eval(LogicContext context, Integer patientId,
Map<String, Object> parameters) {
return new Result("I would recommend Groovy instead");
}
}
|