Module: rules-emitter

This is a mocked version of cht-core's rules-engine's rules-emitter module https://github.com/medic/cht-core/blob/master/shared-libs/rules-engine/src/rules-emitter.js This mock provides (nearly?) identical functionally to the production emitter but avoids the bundled result code from cht-conf and avoids nools. The behaviour of the system may not be identical for all cases, but provides some useful experiences for test authors. https://github.com/medic/cht-conf-test-harness/pull/103
Source:

Methods

(inner) getEmissionsFor(contactDocs, reportDocs, taskDocs) → {Promise.<Object>|Array.<Object>|Array.<Object>}

Runs the partner's rules code for a set of documents and returns all emissions from nools
Parameters:
Name Type Description
contactDocs Array.<Object> A set of contact documents
reportDocs Array.<Object> All of the contacts' reports
taskDocs Array.<Object> All of the contacts' task documents (must be linked by requester to a contact)
Source:
Returns:
  • emissions The raw emissions from nools
    Type
    Promise.<Object>
  • emissions.tasks Array of task emissions
    Type
    Array.<Object>
  • emissions.targets Array of target emissions
    Type
    Array.<Object>

(inner) initialize(settings) → {Boolean}

Initializes the rules emitter
Parameters:
Name Type Description
settings Object Settings for the behavior of the rules emitter
Properties
Name Type Description
rules Object Rules code from settings doc
taskSchedules Array.<Object> Task schedules from settings doc
contact Object The logged in user's contact document
Source:
Returns:
Success
Type
Boolean