public interface LogicDataSource
Context.getLogicService().eval(myPatient, "@pharmacy visit.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:
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.
Modifier and Type | Field and Description |
---|---|
static String |
NAME
The name by which this data source should be registered when it is loaded.
|
Modifier and Type | Method and Description |
---|---|
int |
getDefaultTTL() |
Collection<String> |
getKeys() |
boolean |
hasKey(String key) |
Map<Integer,Result> |
read(LogicContext context,
Cohort patients,
LogicCriteria criteria)
Extracts data from the data source.
|
static final String NAME
Map<Integer,Result> read(LogicContext context, Cohort patients, LogicCriteria criteria) throws LogicException
context
- the current logic contextpatients
- Cohort of Patient(s) for whom to perform the queriescriteria
- LogicCriteria
identifying which data is to be extractedMap
of results for each patient, grouped by requested data elementLogicException
Collection<String> getKeys()
boolean hasKey(String key)
int getDefaultTTL()
Copyright © 2024 OpenMRS Inc.. All rights reserved.