@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(String token,
Rule rule)
Registers a new rule with the logic service.
|
void |
addRule(String token,
String[] tags,
Rule rule)
Registers a new rule with the logic service, associating the tags with the given token
|
void |
addTokenTag(String token,
String tag)
Adds a tag to the given token.
|
Map<LogicCriteria,Map<Integer,Result>> |
eval(Cohort who,
List<LogicCriteria> criterias)
Evaluates a collection of queries for a set of patients
|
Map<Integer,Result> |
eval(Cohort who,
LogicCriteria criteria)
Evaluates a query over a list of patients
|
Map<Integer,Result> |
eval(Cohort who,
LogicCriteria criteria,
Map<String,Object> parameters)
Evaluates a query over a list of patients
|
Map<Integer,Result> |
eval(Cohort who,
String expression)
Evaluates a query over a list of patients
|
Map<Integer,Result> |
eval(Cohort who,
String expression,
Map<String,Object> parameters)
Evaluates a query over a list of patients
|
Result |
eval(Integer patientId,
LogicCriteria criteria)
Evaluates a query for a given patient
|
Result |
eval(Integer patientId,
LogicCriteria criteria,
Map<String,Object> parameters)
Evaluates a query for a given patient
|
Map<LogicCriteria,Result> |
eval(Integer patientId,
Map<String,Object> parameters,
LogicCriteria... criteria)
Evaluates multiple
LogicCriteria for a single patient. |
Map<String,Result> |
eval(Integer patientId,
Map<String,Object> parameters,
String... expressions)
Evaluates multiple logic expressions for a single patient.
|
Result |
eval(Integer patientId,
String expression)
Evaluates a rule for a given patient, given the token for the rule.
|
Result |
eval(Integer patientId,
String expression,
Map<String,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,
Map<String,Object> parameters)
Deprecated.
|
Result |
eval(Patient who,
String expression)
Deprecated.
|
Result |
eval(Patient who,
String expression,
Map<String,Object> parameters)
Deprecated.
|
Set<String> |
findTags(String partialTag)
Deprecated.
use
getTags(String) |
Set<String> |
findToken(String token)
Deprecated.
|
List<String> |
getAllTokens()
Fetch all known (registered) tokens
|
Result.Datatype |
getDefaultDatatype(String token)
Fetches the default datatype this token will return when fed to an eval() call.
|
LogicDataSource |
getLogicDataSource(String name)
Get a logic data source by name
|
Map<String,LogicDataSource> |
getLogicDataSources()
Get all registered logic data sources
|
Set<RuleParameterInfo> |
getParameterList(String token)
Fetches the parameters expected by a given rule
|
Rule |
getRule(String token)
Gets the rule registered under a given token
|
List<String> |
getTags(String partialTag)
Performs a partial match search for token tags among all known tokens.
|
Collection<String> |
getTagsByToken(String token)
Deprecated.
|
Set<String> |
getTokens()
Deprecated.
use
getAllTokens() |
List<String> |
getTokens(String partialToken)
Fetch all known (registered) tokens matching a given string
|
Set<String> |
getTokensByTag(String tag)
Deprecated.
|
List<String> |
getTokensWithTag(String tag)
Gets all tokens associated with this tag.
|
Set<String> |
getTokenTags(String token)
Gets all tags associated with this token.
|
LogicCriteria |
parse(String criteria)
Parse a criteria String to create a new LogicCriteria.
|
LogicCriteria |
parseString(String inStr)
Deprecated.
use
parse(String) |
void |
registerLogicDataSource(String name,
LogicDataSource logicDataSource)
Deprecated.
data sources are now auto-registered via Spring (since Logic module version 0.5)
|
void |
removeLogicDataSource(String name)
Deprecated.
data sources are now auto-registered via Spring (since Logic module version 0.5)
|
void |
removeRule(String token)
Removes a rule from the logic service
|
void |
removeTokenTag(String token,
String tag)
Removes a token's previously assigned tag.
|
void |
setLogicDataSources(Map<String,LogicDataSource> logicDataSources)
Deprecated.
data sources are now auto-registered via Spring (since Logic module version 0.5)
|
void |
updateRule(String token,
Rule rule)
Update a rule that has previously been registered
|
@Deprecated Set<String> getTokens()
getAllTokens()
List<String> getAllTokens()
@Deprecated Set<String> findToken(String token)
getTokens(String)
token
- full or partial token nameList<String> getTokens(String partialToken)
token
- full or partial token namevoid addRule(String token, Rule rule) throws LogicException
token
- the lookup key ("token") for this rulerule
- new rule to be registeredLogicException
Rule
void addRule(String token, 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 registeredLogicException
Rule getRule(String token) throws LogicException
token
- lookup key ("token") under which the rule is registeredLogicException
- if no rule by that name is foundvoid updateRule(String token, Rule rule) throws LogicException
token
- lookup key ("token") for the rule to be updatedrule
- new version of rule (replaces existing rule)LogicException
void removeRule(String token) throws LogicException
token
- lookup key ("token") under which rule to be removed is registeredLogicException
Result eval(Integer patientId, String expression) throws LogicException
patientId
- patient for whom the rule is to be calculatedexpression
- expression to be parsed and evaluatedLogicException
#parse(String)}
Result eval(Integer patientId, String expression, Map<String,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(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 patientLogicException
Result eval(Integer patientId, LogicCriteria criteria, Map<String,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 queryLogicException
Map<String,Result> eval(Integer patientId, Map<String,Object> parameters, 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)}
Map<LogicCriteria,Result> eval(Integer patientId, Map<String,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, 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, String expression, Map<String,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, Map<String,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 queryLogicException
Map<Integer,Result> eval(Cohort who, 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)}
Map<Integer,Result> eval(Cohort who, String expression, Map<String,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)}
Map<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 patientLogicException
Map<Integer,Result> eval(Cohort who, LogicCriteria criteria, Map<String,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 ruleLogicException
Map<LogicCriteria,Map<Integer,Result>> eval(Cohort who, List<LogicCriteria> criterias) throws LogicException
who
- patients for whom the queries are to be runcriterias
- parallel list of criteria to be evaluated on each patientLogicException
void addTokenTag(String token, String tag)
token
- tag
- void removeTokenTag(String token, String tag)
token
- tag
- @Deprecated Collection<String> getTagsByToken(String token)
getTokenTags(String)
token
- token to look up bySet<String> getTokenTags(String token)
token
- token to look up by@Deprecated Set<String> getTokensByTag(String tag)
getTokensWithTag(String)
tag
- tag to look up byList<String> getTokensWithTag(String tag)
tag
- tag to look up by@Deprecated Set<String> findTags(String partialTag)
getTags(String)
partialTag
- partial match stringList<String> getTags(String partialTag)
partialTag
- partial match stringResult.Datatype getDefaultDatatype(String token)
token
- token to look the datatype up forSet<RuleParameterInfo> getParameterList(String token)
@Deprecated void registerLogicDataSource(String name, LogicDataSource logicDataSource) throws LogicException
name
- name for the data sourcelogicDataSource
- the data sourceLogicException
Map<String,LogicDataSource> getLogicDataSources()
@Deprecated void setLogicDataSources(Map<String,LogicDataSource> logicDataSources) throws LogicException
logicDataSources
- LogicException
LogicDataSource getLogicDataSource(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(String name)
name
- name of the logic data source to be unregistered@Deprecated LogicCriteria parseString(String inStr)
parse(String)
logicService.parseString("LAST 'CD4 COUNT' < 200");
inStr
- LogicCriteria expression in a plain String object.LogicCriteria parse(String criteria)
logicService.parseString("LAST 'CD4 COUNT' < 200");
criteria
- LogicCriteria expression in a plain String object.Copyright © 2018 OpenMRS LLC.. All Rights Reserved.