← Back to team overview

dhis2-devs team mailing list archive

Re: Fwd: If-then in indicator formula?

 

Oh I see, now I understand your use case. Unfortunately, that is not
possible at the moment. The indicator formula can not go down to the level
of specifying dataElement.option.

But, you can achieve what you wanted using custom form and creating your
"mini-aggregation" function.

If you see section 6.2.4
<https://www.dhis2.org/doc/snapshot/en/user/html/ch06s02.html#d5e1345> in
our documentation, there are multiple events that you can interact with.
You can start with *dhis2.de.event.dataValuesLoaded* - this notifies you
when all values in a form are loaded. At this point you can call a
javacript function - a function that you need to create - that scans
through the form and count the "Yes"s, "Partial"s and "No"s.

You can also call to this same function whenever there is a value change -
*dhis2.de.event.dataValueSaved* is your friend for this.

In the form, each input field has an id of format
*DATASET_UID-DATAELEMENT_UID-val*. This implies you need to know the IDs of
your data set and data elements.

---
Thank you,
Abyot.

On Wed, Feb 18, 2015 at 8:37 AM, <larinj@xxxxxxxxxxxx> wrote:

>  Hi Abyot,
>
>
>
> Let me explain it a little more…
>
>
>
> In my dataset, I have 10 criteria which can be answered by “Yes”,
> “Partial”, or “No”.  These are defined as an option set.
>
>
>
> What I need is to be able to count how many among the 10 criteria were
> “Yes”, etc.  And to show this summary, hopefully, within the same form,
> like what an indicator does now.
>
>
>
> I hope this clarifies my problem.
>
>
>
> Regards,
>
> -joven
>
>
>
>
>
>
>
> *From:* Abyot Gizaw [mailto:abyota@xxxxxxxxx]
> *Sent:* 18 February 2015 15:32
> *To:* Knut Staring
> *Cc:* LARIN, Joven (WPRO); DHIS 2 developers
> *Subject:* Re: [Dhis2-devs] Fwd: If-then in indicator formula?
>
>
>
> Hi,
>
>
>
> Forgive me if I fail to see something here.
>
>
>
> But I see two things: if-then in Indicators and counting the "Yes",
> "Partial", and "No"s
>
>
>
> If the intention is on the counting, that for me is a simple aggregation
> which the DHIS2 supports. Using options, category and combination of DHIS2
> - it is also possible to use the aggregated result in indicators.
>
>
>
>
> ---
>
> Thank you,
>
> Abyot.
>
>
>
> On Wed, Feb 18, 2015 at 6:45 AM, Knut Staring <knutst@xxxxxxxxx> wrote:
>
> Hello Joven,
>
>
>
> Please allow me to forward your question to our developer list.
>
>
>
> Unfortunately, I don't think the current indicator implementation supports
> such conditional expressions, though I've seen this question come up before
> and the need for it is certainly there. Maybe this is something that could
> be added in the near future, or others may have suggestions on how to work
> around this limitation.
>
>
>
> You could use the Web API to get the raw data into an HTML report and then
> process them in the client, using Javascript. Alternatively, you could also
> extract the data, process it using an external script (e.g. Python, R) and
> inject the result back into DHIS2 (again preferably using the WebAPI).
>
>
>
> Knut
>
>
>
> ---------- Forwarded message ----------
> From: <larinj@xxxxxxxxxxxx>
> Date: Wed, Feb 18, 2015 at 9:18 AM
> Subject: If-then in indicator formula?
> To: knutst@xxxxxxxxx
>
>   Hi Knut!
>
>
>
> I hope you’re doing well.  Wherever you are. J
>
>
>
> I was wondering if it’s currently possible to do an if-then in the
> indicator formula?  I need to be able to count the “Yes”, “Partial” and
> “No”-s (from an option set) in one of the datasets that I have.
>
>
>
> Thanks in advance.
>
>
>
> Regards,
>
> -joven
>
>
>
> *Joven Larin*
> Informatics Assistant
> Health Intelligence and Innovation
> Division of Health Sector Development
>
> World Health Organization | Regional Office for the Western Pacific |
> Manila, Philippines
> Tel: +63 2 5289967 | E-mail: larinj@xxxxxxxxxxxx | Web:
> http://www.wpro.who.int
>
>
>
>
>
>
>  ------------------------------
>
> This message was scanned for viruses with Trend Micro ScanMail, GFI
> MailSecurity and GFI MailEssentials by the World Health Organization
> Regional Office for the Western Pacific. However, the recipient is advised
> to scan this e-mail and any attached files for viruses.
>
> Disclaimer:
>
> This e-mail, together with any attachments, is intended for the named
> recipients only and is confidential. It may also be privileged or otherwise
> protected by law.
>
> If you have received it in error, please notify the sender immediately by
> reply e-mail and delete it and any attachments from your system. You may
> not copy or disclose its contents to anyone.
>
>
>
>
>
> --
>
> Knut Staring
>
> Dept. of Informatics, University of Oslo
>
> Norway: +4791880522
>
> Skype: knutstar
>
> http://dhis2.org
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dhis2-devs
> Post to     : dhis2-devs@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dhis2-devs
> More help   : https://help.launchpad.net/ListHelp
>
>
>
>
>
>
>
>  ------------------------------
>
> This message was scanned for viruses with Trend Micro ScanMail, GFI
> MailSecurity and GFI MailEssentials by the World Health Organization
> Regional Office for the Western Pacific. However, the recipient is advised
> to scan this e-mail and any attached files for viruses.
>
> Disclaimer:
>
> This e-mail, together with any attachments, is intended for the named
> recipients only and is confidential. It may also be privileged or otherwise
> protected by law.
>
> If you have received it in error, please notify the sender immediately by
> reply e-mail and delete it and any attachments from your system. You may
> not copy or disclose its contents to anyone.
>  <#14b9b9f53ff245bc_>
>

JPEG image


Follow ups

References