medic / cht-docs

Documentation site for the Community Health Tookit
https://docs.communityhealthtoolkit.org
14 stars 16 forks source link

Declarative configuration target schema is missing explanation of emitCustom #87

Open kennsippell opened 4 years ago

kennsippell commented 4 years ago

I don't know how to elegantly describe the "emitCustom" function in the declarative configuration docs for the target schema. The design of the declarative configuration system hides the "instance" from the configurer. There is no reason for the configuration author to understand the instance or its details.

In constrast, the emitCustom function is the only function that exposes or directly works with instances. It allows for the direct manipulation of that object and is quite useful (powerful), but it is an advanced feature and a real outlier for when it is required. It requires a deeper explanation of how the configuration system interfaces with the webapp and the schema used at that level.

I find it hard to document because it is a hurdle (and against the design pattern of the system) to all of a sudden introduce the concept of the emitted instances and the schema used there. Creating this issue to track reconsiling this.

rosteve commented 4 years ago

while doing targets configuration, can we use both contacts and reports in the appliesTo field? in order to achieve something like this:

appliesTo: 'contacts, reports'
appliesToType:['person', 'traveller_surveillance']
appliesIf: (c,r) => c.contact.has_symptoms === 'true' || Utils.getField(r,'has_symptoms') === 'true',

we need to count both person forms and traveller surveillance report forms and get an aggregate of both is they satisfy a certain condition.

MaxDiz commented 4 years ago

transferring to new cht-docs repo

kennsippell commented 1 year ago

Decent explanation now in this thread https://forum.communityhealthtoolkit.org/t/targets-emitcustom/2577/3