@Transactional
public interface LogicService
 Patient myPatient = Context.getPatientService().getPatient(123);
 LogicService logicService = Context.getLogicService();
 Result result = logicService.eval(myPatient, "HIV POSITIVE");
 if (result.toBoolean()) {
        // patient is HIV positive
 }
 
 
 Results can be derived with specific criteria as well. For example, to fetch the maximum CD4
 count within the past six months:
 
 
   Result result = logicService.eval(myPatient, new LogicCriteria("CD4 COUNT")
     .within(Duration.months(6)).max();
 
 
 or within 6 months of 11-November-2006:
 
 
   Calendar calendar = Calendar.getInstance();
   calendar.set(2006, 11, 11);
   Date targetDate = calendar.getTime();
   Result result = logicService.eval(myPatient, new LogicCriteria("CD4 COUNT")
     .asOf(targetDate).within(Duration.months(6)).max();
 Rule, 
LogicCriteria, 
LogicDataSource| Modifier and Type | Method and Description | 
|---|---|
void | 
addRule(java.lang.String token,
       Rule rule)
Registers a new rule with the logic service. 
 | 
void | 
addRule(java.lang.String token,
       java.lang.String[] tags,
       Rule rule)
Registers a new rule with the logic service, associating the tags with the given token 
 | 
void | 
addTokenTag(java.lang.String token,
           java.lang.String tag)
Adds a tag to the given token. 
 | 
java.util.Map<LogicCriteria,java.util.Map<java.lang.Integer,Result>> | 
eval(Cohort who,
    java.util.List<LogicCriteria> criterias)
Evaluates a collection of queries for a set of patients 
 | 
java.util.Map<java.lang.Integer,Result> | 
eval(Cohort who,
    LogicCriteria criteria)
Evaluates a query over a list of patients 
 | 
java.util.Map<java.lang.Integer,Result> | 
eval(Cohort who,
    LogicCriteria criteria,
    java.util.Map<java.lang.String,java.lang.Object> parameters)
Evaluates a query over a list of patients 
 | 
java.util.Map<java.lang.Integer,Result> | 
eval(Cohort who,
    java.lang.String expression)
Evaluates a query over a list of patients 
 | 
java.util.Map<java.lang.Integer,Result> | 
eval(Cohort who,
    java.lang.String expression,
    java.util.Map<java.lang.String,java.lang.Object> parameters)
Evaluates a query over a list of patients 
 | 
Result | 
eval(java.lang.Integer patientId,
    LogicCriteria criteria)
Evaluates a query for a given patient 
 | 
Result | 
eval(java.lang.Integer patientId,
    LogicCriteria criteria,
    java.util.Map<java.lang.String,java.lang.Object> parameters)
Evaluates a query for a given patient 
 | 
java.util.Map<LogicCriteria,Result> | 
eval(java.lang.Integer patientId,
    java.util.Map<java.lang.String,java.lang.Object> parameters,
    LogicCriteria... criteria)
Evaluates multiple  
LogicCriteria for a single patient. | 
java.util.Map<java.lang.String,Result> | 
eval(java.lang.Integer patientId,
    java.util.Map<java.lang.String,java.lang.Object> parameters,
    java.lang.String... expressions)
Evaluates multiple logic expressions for a single patient. 
 | 
Result | 
eval(java.lang.Integer patientId,
    java.lang.String expression)
Evaluates a rule for a given patient, given the token for the rule. 
 | 
Result | 
eval(java.lang.Integer patientId,
    java.lang.String expression,
    java.util.Map<java.lang.String,java.lang.Object> parameters)
Evaluates a rule for a given patient, given a token and parameters for the rule. 
 | 
Result | 
eval(Patient who,
    LogicCriteria criteria)
Deprecated. 
 
 | 
Result | 
eval(Patient who,
    LogicCriteria criteria,
    java.util.Map<java.lang.String,java.lang.Object> parameters)
Deprecated. 
 
 | 
Result | 
eval(Patient who,
    java.lang.String expression)
Deprecated. 
 
 | 
Result | 
eval(Patient who,
    java.lang.String expression,
    java.util.Map<java.lang.String,java.lang.Object> parameters)
Deprecated. 
 
 | 
java.util.Set<java.lang.String> | 
findTags(java.lang.String partialTag)
Deprecated. 
 
use  
getTags(String) | 
java.util.Set<java.lang.String> | 
findToken(java.lang.String token)
Deprecated. 
 
 | 
java.util.List<java.lang.String> | 
getAllTokens()
Fetch all known (registered) tokens 
 | 
Result.Datatype | 
getDefaultDatatype(java.lang.String token)
Fetches the default datatype this token will return when fed to an eval() call. 
 | 
LogicDataSource | 
getLogicDataSource(java.lang.String name)
Get a logic data source by name 
 | 
java.util.Map<java.lang.String,LogicDataSource> | 
getLogicDataSources()
Get all registered logic data sources 
 | 
java.util.Set<RuleParameterInfo> | 
getParameterList(java.lang.String token)
Fetches the parameters expected by a given rule 
 | 
Rule | 
getRule(java.lang.String token)
Gets the rule registered under a given token 
 | 
java.util.List<java.lang.String> | 
getTags(java.lang.String partialTag)
Performs a partial match search for token tags among all known tokens. 
 | 
java.util.Collection<java.lang.String> | 
getTagsByToken(java.lang.String token)
Deprecated. 
 
 | 
java.util.Set<java.lang.String> | 
getTokens()
Deprecated. 
 
use  
getAllTokens() | 
java.util.List<java.lang.String> | 
getTokens(java.lang.String partialToken)
Fetch all known (registered) tokens matching a given string 
 | 
java.util.Set<java.lang.String> | 
getTokensByTag(java.lang.String tag)
Deprecated. 
 
 | 
java.util.List<java.lang.String> | 
getTokensWithTag(java.lang.String tag)
Gets all tokens associated with this tag. 
 | 
java.util.Set<java.lang.String> | 
getTokenTags(java.lang.String token)
Gets all tags associated with this token. 
 | 
LogicCriteria | 
parse(java.lang.String criteria)
Parse a criteria String to create a new LogicCriteria. 
 | 
LogicCriteria | 
parseString(java.lang.String inStr)
Deprecated. 
 
use  
parse(String) | 
void | 
registerLogicDataSource(java.lang.String name,
                       LogicDataSource logicDataSource)
Deprecated. 
 
data sources are now auto-registered via Spring (since Logic module version 0.5) 
 | 
void | 
removeLogicDataSource(java.lang.String name)
Deprecated. 
 
data sources are now auto-registered via Spring (since Logic module version 0.5) 
 | 
void | 
removeRule(java.lang.String token)
Removes a rule from the logic service 
 | 
void | 
removeTokenTag(java.lang.String token,
              java.lang.String tag)
Removes a token's previously assigned tag. 
 | 
void | 
setLogicDataSources(java.util.Map<java.lang.String,LogicDataSource> logicDataSources)
Deprecated. 
 
data sources are now auto-registered via Spring (since Logic module version 0.5) 
 | 
void | 
updateRule(java.lang.String token,
          Rule rule)
Update a rule that has previously been registered 
 | 
@Deprecated java.util.Set<java.lang.String> getTokens()
getAllTokens()java.util.List<java.lang.String> getAllTokens()
@Deprecated java.util.Set<java.lang.String> findToken(java.lang.String token)
getTokens(String)token - full or partial token namejava.util.List<java.lang.String> getTokens(java.lang.String partialToken)
token - full or partial token namevoid addRule(java.lang.String token,
             Rule rule)
      throws LogicException
token - the lookup key ("token") for this rulerule - new rule to be registeredLogicExceptionRulevoid addRule(java.lang.String token,
             java.lang.String[] tags,
             Rule rule)
      throws LogicException
token - the unique lookup key ("token") for this ruletags - words or phrases associated with this token (do not need to be unique)rule - new rule to be registeredLogicExceptionRule getRule(java.lang.String token) throws LogicException
token - lookup key ("token") under which the rule is registeredLogicException - if no rule by that name is foundvoid updateRule(java.lang.String token,
                Rule rule)
         throws LogicException
token - lookup key ("token") for the rule to be updatedrule - new version of rule (replaces existing rule)LogicExceptionvoid removeRule(java.lang.String token)
         throws LogicException
token - lookup key ("token") under which rule to be removed is registeredLogicExceptionResult eval(java.lang.Integer patientId, java.lang.String expression) throws LogicException
patientId - patient for whom the rule is to be calculatedexpression - expression to be parsed and evaluatedLogicException#parse(String)}Result eval(java.lang.Integer patientId, java.lang.String expression, java.util.Map<java.lang.String,java.lang.Object> parameters) throws LogicException
patientId - patient for whom the rule is to be calculatedexpression - expression to be parsed and evaluatedparameters - parameters to be passed to the ruleLogicException#parse(String)}Result eval(java.lang.Integer patientId, LogicCriteria criteria) throws LogicException
patientId - patient for whom the query is to be runcriteria - question to be answered (along with the token) for the given patientLogicExceptionResult eval(java.lang.Integer patientId, LogicCriteria criteria, java.util.Map<java.lang.String,java.lang.Object> parameters) throws LogicException
patientId - Patient for whom the query is to be runcriteria - Criteria question to be answered (along with the token) for the
            given patientparameters - Map of arguments to be passed to the ruleResult of queryLogicExceptionjava.util.Map<java.lang.String,Result> eval(java.lang.Integer patientId, java.util.Map<java.lang.String,java.lang.Object> parameters, java.lang.String... expressions) throws LogicException
LogicCriteria... version.)patientId - which patient to run the rules onparameters - global parameters to be passed to all rule evaluationsexpressions - expressions to be parsed and runLogicException#parse(String)}java.util.Map<LogicCriteria,Result> eval(java.lang.Integer patientId, java.util.Map<java.lang.String,java.lang.Object> parameters, LogicCriteria... criteria) throws LogicException
LogicCriteria for a single patient.
 (The criteria argument is an array and comes last because using a List would give this method
 the same type erasure as the String... version.)patientId - which patient to run the rules onparameters - global parameters to be passed to all rule evaluationscriteria - what criteria to runLogicException@Deprecated Result eval(Patient who, java.lang.String expression) throws LogicException
eval(Integer, String)who - patient for whom the rule is to be calculatedexpression - expression to be parsed and evaluatedLogicException#parse(String)}@Deprecated Result eval(Patient who, java.lang.String expression, java.util.Map<java.lang.String,java.lang.Object> parameters) throws LogicException
eval(Integer, String, Map)who - patient for whom the rule is to be calculatedexpression - expression to be parsed and evaluatedparameters - parameters to be passed to the ruleLogicException#parse(String)}@Deprecated Result eval(Patient who, LogicCriteria criteria) throws LogicException
eval(Integer, LogicCriteria)who - patient for whom the query is to be runcriteria - question to be answered (along with the token) for the given patientLogicException@Deprecated Result eval(Patient who, LogicCriteria criteria, java.util.Map<java.lang.String,java.lang.Object> parameters) throws LogicException
eval(Integer, LogicCriteria, Map)who - Patient for whom the query is to be runcriteria - Criteria question to be answered (along with the token) for the
            given patientparameters - Map of arguments to be passed to the ruleResult of queryLogicExceptionjava.util.Map<java.lang.Integer,Result> eval(Cohort who, java.lang.String expression) throws LogicException
who - patients for whom the query is to be runexpression - expression to be parsed and evaluated for each patientLogicException#parse(String)}java.util.Map<java.lang.Integer,Result> eval(Cohort who, java.lang.String expression, java.util.Map<java.lang.String,java.lang.Object> parameters) throws LogicException
who - patients for whom the query is to be runexpression - expression to be parsed and evaluated for each patientparameters - parameters to be passed to the ruleLogicException#parse(String)}java.util.Map<java.lang.Integer,Result> eval(Cohort who, LogicCriteria criteria) throws LogicException
who - patients for whom the query is to be runcriteria - question to be answered (along with the token) for each patientLogicExceptionjava.util.Map<java.lang.Integer,Result> eval(Cohort who, LogicCriteria criteria, java.util.Map<java.lang.String,java.lang.Object> parameters) throws LogicException
who - patients for whom the query is to runcriteria - question to be answered (along with the token) for each patientparameters - arguments to be passed to the ruleLogicExceptionjava.util.Map<LogicCriteria,java.util.Map<java.lang.Integer,Result>> eval(Cohort who, java.util.List<LogicCriteria> criterias) throws LogicException
who - patients for whom the queries are to be runcriterias - parallel list of criteria to be evaluated on each patientLogicExceptionvoid addTokenTag(java.lang.String token,
                 java.lang.String tag)
token - tag - void removeTokenTag(java.lang.String token,
                    java.lang.String tag)
token - tag - @Deprecated java.util.Collection<java.lang.String> getTagsByToken(java.lang.String token)
getTokenTags(String)token - token to look up byjava.util.Set<java.lang.String> getTokenTags(java.lang.String token)
token - token to look up by@Deprecated java.util.Set<java.lang.String> getTokensByTag(java.lang.String tag)
getTokensWithTag(String)tag - tag to look up byjava.util.List<java.lang.String> getTokensWithTag(java.lang.String tag)
tag - tag to look up by@Deprecated java.util.Set<java.lang.String> findTags(java.lang.String partialTag)
getTags(String)partialTag - partial match stringjava.util.List<java.lang.String> getTags(java.lang.String partialTag)
partialTag - partial match stringResult.Datatype getDefaultDatatype(java.lang.String token)
token - token to look the datatype up forjava.util.Set<RuleParameterInfo> getParameterList(java.lang.String token)
@Deprecated
void registerLogicDataSource(java.lang.String name,
                                         LogicDataSource logicDataSource)
                                  throws LogicException
name - name for the data sourcelogicDataSource - the data sourceLogicExceptionjava.util.Map<java.lang.String,LogicDataSource> getLogicDataSources()
@Deprecated void setLogicDataSources(java.util.Map<java.lang.String,LogicDataSource> logicDataSources) throws LogicException
logicDataSources - LogicExceptionLogicDataSource getLogicDataSource(java.lang.String name)
name - name of the desired logic data sourcenull if there is no data
         source registered under the given name (must be an exact match)@Deprecated void removeLogicDataSource(java.lang.String name)
name - name of the logic data source to be unregistered@Deprecated LogicCriteria parseString(java.lang.String inStr)
parse(String)logicService.parseString("LAST 'CD4 COUNT' < 200");inStr - LogicCriteria expression in a plain String object.LogicCriteria parse(java.lang.String criteria)
logicService.parseString("LAST 'CD4 COUNT' < 200");criteria - LogicCriteria expression in a plain String object.Copyright © 2018 OpenMRS Inc.. All Rights Reserved.