Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register

Ticket #924 (closed task: fixed)

Opened 2 years ago

Last modified 1 year ago

Populate the rule token cache with concept names

Reported by: jmiranda Assigned to: mseaton
Priority: major Milestone:
Component: Logic Service Keywords:
Cc: Introductory Ticket: 0
Code Review Status:

Description (Last modified by jmiranda)

This is currently done by type, which is probably not a good long term solution. All distinct concept_id's from obs should be added to the cache and then if a string cannot be found in the cache it should be checked to see if it is a concept and if it is load it into the cache. We will have to keep an eye on how much memory this cache takes up. If it gets too big, we might have to purge it periodically.

Right now, token that have been registered and their associated tags created in the Logic Service are only kept in memory, meaning they're lost when the web application is restarted. The time necessary to re-register all tokens is prohibitive. Therefore, we need a mechanism within the logic service to persist these data.

Change History

07/18/08 16:27:15 changed by jmiranda

Comment from Burke: The obs data source rules bootstrapping (pre-loading of question/test concepts as reference rules pointing to the obs data source) could definitely be improved. The goal of the logic service was to provide the machinery to register rules and not to be doing the bootstrapping for obs or any other data source. The bootstrapping was thrown in as a temporary hack to get things started. Ideally, the automatic registering of any rules (whether for the obs data source or any other) could eventually be done elsewhere -- e.g., as part of the OpenMRS initialization process.

07/18/08 16:28:54 changed by jmiranda

... (continued from comment above)

"select distinct concept_id from obs" should provide a better starting point for auto-registering reference rules for the obs data source.

Eventually, I'd like to have the caching handled by a library (like Ehcache) rather than trying to re-invent the wheel.

11/07/08 21:32:58 changed by jmiranda

  • intro_ticket changed.
  • description changed.

11/07/08 21:34:53 changed by jmiranda

  • owner changed from tmdugan to mseaton.

So what we've come up with is a logic_token_definition table that keeps a reference to a token and it's serialized rule. We will use XStream to serialize the rules to XML and save them in this new table.

TODO

  • Add Logic DAO to persist and remove rules from the database
  • Add ability in RuleFactory to manage the rules in the system
  • Persist rules and load them at startup
  • Register default rules (goes through concepts)
  • Add ability to register only certain concept classes and locales
  • Register all keys from all data sources (%%patient.gender)
  • Register rules like AgeRule and HIVPositiveRule written in Java - these need to be injected into the RuleFactory via spring

11/13/08 15:27:39 changed by mseaton

  • status changed from new to assigned.

Persistence of Rules is covered by ticket #969. This issue is only meant to cover automatic rule / token registration, and separation of this into OpenMRS startup and out of the LogicService itself.

11/13/08 15:50:04 changed by mseaton

  • status changed from assigned to closed.
  • resolution set to fixed.

I have added the following changes to Logic to support this:

  • Moved startup logic from RuleFactory to Context.startup to initialize default tokens.
  • Changed logic that controls which tokens are registered by default as follows:
    • Rule classes are added directly: HIVPositiveRule, AgeRule
    • Reference rules added as follows, if not already registered:
      • All keys in PersonDataSource
      • All keys in ObsDataSource based on the following global properties:
        • logic.autoRegisteredTokens.conceptClassNames
          • csv of class names will register all concepts in these classes.
        • logic.autoRegisteredTokens.conceptIds
          • csv of concept ids will register all listed concepts
        • logic.defaultConceptNameLocale
          • determines the locale to use when registering above concepts
          • registers the concept name in this locale, or will use Locale.US if not specified
  • Added new TokenRegistry class to ensure tokens are accessed and queried in a standard way
  • Modified LogicService and RuleFactory classes to utilize the TokenRegistry

11/13/08 15:57:23 changed by mseaton

Actually #969 looks like it is for persisting TokenTags, not Tokens, so this ticket will also handle persistence of tokens, per original specifications. The following has been completed to solve this:

  • Created a new class: TokenDefinition, with new table logic_token_definition to represent persisted Tokens. Each TokenDefinition contains a String token and a serialized Rule string.
  • Added a new RuleSerializer class to abstract the logic involved with serializing and deserializing a Rule to a String to be persisted in a TokenDefinition.
  • Modified RuleFactory and LogicService to provide methods for persisting Rules to the database as they are registered in the TokenRegistry. Added a mechanism for loading previously saved Rules upon startup and not recreating these rules if already registered.