Interface LogicDataSource

public interface LogicDataSource

Provides data to the logic service engine. Each data source is responsible for exposing a set of keys to the logic service and delivering results to the logic service engine upon request. Requests to the data source reference the evaluation context, a patient cohort, and criteria.

Keys (and their subsequent results) work best if they are well documented and maximize the re-use of data. For example, consider a data source that has access to a historical listing of pharmacy visits for patients. For each visit to the name of the pharmacy, the date of the visit and the number of prescriptions filled at that visit are known. You might want to make a key for each attribute, e.g. A consumer of the logic service could then use
 Context.getLogicService().eval(myPatient, "@pharmacy");
to get a list of the names of pharamacies visited by the patient. However, this limits the ways we can use the result. On the other hand, consider defining the key: Now a consumer of the logic service can use the same result in several different ways:
 Result result = Context.getLogicService().eval(myPatient, "@pharmacy visit.visit");
 Result lastVisit = result.latest();
 Date dateOfVisit = result.getResultDate();
 String pharmacy = result.toString();
 int numberOfPrescriptions = result.toNumber();
One way to approach the design of a new data service is to avoid thinking of the individual attributes, but rather think about turning the data into the fewest number of observations (a key for each) filled with as much data as possible. Remember that you can overload values within results; however, such overloading should aim to be as intuitive as possible and well documented. New logic data sources should be documented on the OpenMRS wiki, including a description of the keys available from the data source as well as the characteristics of the result returned for each key.

Field Summary
static java.lang.String NAME
          The name by which this data source should be registered when it is loaded.
Method Summary
 int getDefaultTTL()
 java.util.Collection<java.lang.String> getKeys()
 boolean hasKey(java.lang.String key)
 java.util.Map<java.lang.Integer,Result> read(LogicContext context, Cohort patients, LogicCriteria criteria)
          Extracts data from the data source.

Field Detail


static final java.lang.String NAME
The name by which this data source should be registered when it is loaded. Implementations should override this like public static final String NAME = "person";

See Also:
Constant Field Values
Method Detail


java.util.Map<java.lang.Integer,Result> read(LogicContext context,
                                             Cohort patients,
                                             LogicCriteria criteria)
                                             throws LogicException
Extracts data from the data source. Actually, this function only checks for cached data and forwards all non-cached requests to its subclass(es).

context - the current logic context
patients - Cohort of Patient(s) for whom to perform the queries
criteria - LogicCriteria identifying which data is to be extracted
Map of results for each patient, grouped by requested data element


java.util.Collection<java.lang.String> getKeys()


boolean hasKey(java.lang.String key)


int getDefaultTTL()


Generated Apr 27 2012 10:06 PM. NOTE - these libraries are in active development and subject to change