Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register

root/openmrs/trunk/src/api/org/openmrs/logic/Rule.java

Revision 4358, 2.5 kB (checked in by bwolfe, 6 months ago)

Merging api-refactoring to trunk [3595]:[4355]

  • Property svn:eol-style set to CRLF
Line 
1 /**
2  * The contents of this file are subject to the OpenMRS Public License
3  * Version 1.0 (the "License"); you may not use this file except in
4  * compliance with the License. You may obtain a copy of the License at
5  * http://license.openmrs.org
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
9  * License for the specific language governing rights and limitations
10  * under the License.
11  *
12  * Copyright (C) OpenMRS, LLC.  All Rights Reserved.
13  */
14 package org.openmrs.logic;
15
16 import java.util.Map;
17 import java.util.Set;
18
19 import org.openmrs.Patient;
20 import org.openmrs.logic.result.Result;
21 import org.openmrs.logic.result.Result.Datatype;
22 import org.openmrs.logic.rule.RuleParameterInfo;
23
24 /**
25  *
26  * Base class for all logic rules.
27  *
28  */
29 public interface Rule {
30
31     /**
32      *
33      * Evaluate rule for a given patient and applying the given criteria.
34      *
35      * @param patient a patient for whom rule is to be calculated
36      * @return result of the rule for the given patient with given criteria
37      *         applied
38      * @throws LogicException TODO
39      */
40     public Result eval(LogicContext context, Patient patient,
41             Map<String, Object> parameters) throws LogicException;
42
43     /**
44      * Returns the list of arguments.
45      *
46      * @return list of arguments or null if no arguments
47      */
48     public Set<RuleParameterInfo> getParameterList();
49
50     /**
51      *
52      * Returns a list of dependencies (tokens for rules upon which this rule may
53      * depend).
54      *
55      * @return tokens for all rules that may be called by this rule
56      *
57      */
58     // TODO: it would be better to be able to query for dependency on both rules
59     // and/or data source keys
60     public String[] getDependencies();
61
62     /**
63      *
64      * Gets the time (in seconds) during which the Rule's results are considered
65      * to be valid. This is used to prevent the use of invalid (old) items from
66      * a cache
67      *
68      * @return duration (in seconds) the results are considered valid for this
69      *         rule
70      */
71     public int getTTL();
72
73     /**
74      *
75      * Gets the default datatype that the rule returns, when supplied with a
76      * given token. While results are loosely typed, this method allows rules to
77      * declare a default datatype to simplify user interfaces and defaults when
78      * working with rules.
79      *
80      * @return datatype
81      */
82     public Datatype getDefaultDatatype();
83
84 }
Note: See TracBrowser for help on using the browser.