Web API : Get Indicator Value

Dear Julhas,

Thank you very much. I actually needed orgUnitId to call web-api. Iused the following code to get it done. Seems to work on data entry screen.

var ouselect = $(‘.selected’).attr(‘href’);
var orgid = ouselect.match(/“([^”]+)"/)[1];

image

···

On Mon, Nov 16, 2015 at 3:39 PM, Julhas Sujan julhaspustcse@gmail.com wrote:

Hi Pamod,

Please paste the following code in your dataentry screen and check the result from console. It will show the selected organization unit and period:

If you need more information please let me know.

Thanks

Julhas

On Mon, Nov 16, 2015 at 3:10 PM, Pamod Amarakoon pamodm@gmail.com wrote:

Hi Julhas,

I managed to get most of the stuff figured out to get the above functionality done. Just need a quick help if you are not busy. How to capture the selected org unit ID from DOM at data entry screen. I could capture org unit name from input box but id doesn’t contain organisationUnit ID.

Thank you

On Sun, Nov 15, 2015 at 7:50 PM, Pamod Amarakoon pamodm@gmail.com wrote:

Sure. Thanx Julhas.


Regards,
Pamod Amarakoon

Confidentiality Notice: the information contained in this email and any attachments may be legally privileged and confidential. If you are not an intended recipient, you are hereby notified that any dissemination, distribution, or copying of this e-mail is strictly prohibited. If you have received this e-mail in error, please notify the sender and permanently delete the e-mail and any attachments immediately. You should not retain, copy or use this e-mail or any attachments for any purpose, nor disclose all or any part of the contents to any other person.

On Sun, Nov 15, 2015 at 7:15 PM, Julhas Sujan julhaspustcse@gmail.com wrote:

Hi,

Thank you very much. I got your point. It is possible but u need to call internal API from DHIS2 data entry screen and api will give you the last day mid night total.

You need to use JavaScript to auto save this extracted data. I am too much busy with my recent project. You may organize this following things:

  1. Create dataset and data elements and make elements group
  1. Assign organization Unit and
  1. Design Data entry Screen

Develop the mentioned points in your development server and send me this credentials. I will develop this api in your development when i will free.

Thanks

Julhas


Regards,
Pamod Amarakoon

Confidentiality Notice: the information contained in this email and any attachments may be legally privileged and confidential. If you are not an intended recipient, you are hereby notified that any dissemination, distribution, or copying of this e-mail is strictly prohibited. If you have received this e-mail in error, please notify the sender and permanently delete the e-mail and any attachments immediately. You should not retain, copy or use this e-mail or any attachments for any purpose, nor disclose all or any part of the contents to any other person.

On Sun, Nov 15, 2015 at 7:36 PM, Pamod Amarakoon pamodm@gmail.com wrote:

Hi Julhas,

There is a data set which records number and category of in ward patients in a hospital. for example following are few data elements in the data set.

  1. mid night total
  1. new admissions
  1. transfer out
  1. transfer in
  1. deaths
  1. discharges
  1. total in ward

therefore, today’s mid night total would be yesterday’s total in ward patients. therefore, rather than manually entering mid night total, it would avoid typing errors if we can retrieve that from yesterday’s data set.

the web api query u work could be used to obtain the value. i was just wondering of 2 things.

  1. whether relative periods like last_month, yesterday are not supported
  1. whether filtering could be used to obtain the specific dataElement value.
    eg: https://play.dhis2.org/demo/api/dataValueSets?dataSet=BfMAe6Itzgt&period=201506&orgUnit=DiszpKrYNg8&filter=dataElement:eq:s46m5MS0hxu

but above does not work

Thanx a lot.

On Sun, Nov 15, 2015 at 3:35 PM, Julhas Sujan julhaspustcse@gmail.com wrote:

Hi Pamod,

Sure, I will check. Can you please give me the detail business logic that you want to do. I need more conceptualization on your problem/api issue.

Thanks

Julhas


Regards,
Pamod Amarakoon

Confidentiality Notice: the information contained in this email and any attachments may be legally privileged and confidential. If you are not an intended recipient, you are hereby notified that any dissemination, distribution, or copying of this e-mail is strictly prohibited. If you have received this e-mail in error, please notify the sender and permanently delete the e-mail and any attachments immediately. You should not retain, copy or use this e-mail or any attachments for any purpose, nor disclose all or any part of the contents to any other person.

On Sun, Nov 15, 2015 at 3:39 PM, Pamod Amarakoon pamodm@gmail.com wrote:

Hi Julhas,

Hope you are doing great. I was too busy with eHealth Asia 2015 conference, I virtually couldn’t work on the problem I mentioned before. I tried to check the api request u mentioned today.

https://play.dhis2.org/demo/api/dataValueSets?dataSet=BfMAe6Itzgt&period=201506&orgUnit=DiszpKrYNg8

it’s working fine on demo server. just being curious whether the relative period LAST_MONTH could be used for this requirement in web-api. When i tried replacing it with 201506 it says “at least one valid period or start/end date must be specified”.

have u tried using relavtive periods in api, if so is there a different syntax to be used when calling for periods.

Thanks

On Tue, Sep 22, 2015 at 11:00 PM, Julhas Sujan julhaspustcse@gmail.com wrote:

{
console.log(json);
});

Here, json is an array. Your previous month data is containing there. Just you have to extract from it.


Regards,
Pamod Amarakoon

Confidentiality Notice: the information contained in this email and any attachments may be legally privileged and confidential. If you are not an intended recipient, you are hereby notified that any dissemination, distribution, or copying of this e-mail is strictly prohibited. If you have received this e-mail in error, please notify the sender and permanently delete the e-mail and any attachments immediately. You should not retain, copy or use this e-mail or any attachments for any purpose, nor disclose all or any part of the contents to any other person.

On Tue, Sep 22, 2015 at 11:27 PM, Julhas Sujan julhaspustcse@gmail.com wrote:

You have to set logic based on your requirements. You may use for loop for jquery or javascript.

Hope you can do. :slight_smile:

On Tue, Sep 22, 2015 at 11:24 PM, Pamod Amarakoon pamodm@gmail.com wrote:

Thanx Julhas, I’m currently outside at my clinic, will test it once I reach home. But if we are to get the particular date dynamically is there any provision on web api for relative date such as PREVIOUS DAY or YESTERDAY etc.

On Tue, Sep 22, 2015 at 10:45 PM, Julhas Sujan julhaspustcse@gmail.com wrote:

Hi Pamod,

Please check and try from your data entry screen:

dhis2.util.on( ‘dhis2.de.event.formReady’, function( event, ds ) {
jQuery( “#formLoad” ).html( “Form loaded successfully: " + ds );
jQuery.get(”…/api/dataValueSets?dataSet=“+ds+”&period=201506&orgUnit=DiszpKrYNg8",function(json)
{
console.log(json);
});
} );

I have tested it.

Thanks

Julhas


Regards,
Pamod Amarakoon

Confidentiality Notice: the information contained in this email and any attachments may be legally privileged and confidential. If you are not an intended recipient, you are hereby notified that any dissemination, distribution, or copying of this e-mail is strictly prohibited. If you have received this e-mail in error, please notify the sender and permanently delete the e-mail and any attachments immediately. You should not retain, copy or use this e-mail or any attachments for any purpose, nor disclose all or any part of the contents to any other person.

http://ehealthasia.org

On Tue, Sep 22, 2015 at 10:58 PM, Pamod Amarakoon pamodm@gmail.com wrote:

Thank you Julhas. I too have been quite busy recently with a Health Informatics Conference we are organizing. I’ll add you on skype and buzz you, if there’s any update or need clarification.

Thanx again

On Mon, Sep 21, 2015 at 4:13 PM, Julhas Sujan julhaspustcse@gmail.com wrote:

Thanks. I understood your problem. Yes it is possible to get previous day data in the data entry screen using web-api. Now i am too much busy. I will knock you soon. It will better for us in skype discussion.

You may add me in skype: julhas08

Julhas


Regards,
Pamod Amarakoon

Confidentiality Notice: the information contained in this email and any attachments may be legally privileged and confidential. If you are not an intended recipient, you are hereby notified that any dissemination, distribution, or copying of this e-mail is strictly prohibited. If you have received this e-mail in error, please notify the sender and permanently delete the e-mail and any attachments immediately. You should not retain, copy or use this e-mail or any attachments for any purpose, nor disclose all or any part of the contents to any other person.

http://ehealthasia.org

On Mon, Sep 21, 2015 at 2:59 PM, Pamod Amarakoon pamodm@gmail.com wrote:

Dear Julhas,

Thank you for the prompt reply and sorry for my late response coz I had some issue with my laptop and had to format it.

the exact requirement is to obtain the mid night total of previous day of each ward to the starting total of a form of present day. The form is as below.

​POT value should be replaced by value of midnight total of previous day. Since mid night total is an indicator, i was thinking to use web-api to pull that data from previous day.

I couldn’t check on ur solution yet, but do you think there is an alternate way of achieving this.

Thanks a lot.

On Sun, Sep 20, 2015 at 4:08 PM, Julhas Sujan julhaspustcse@gmail.com wrote:

Hi Pamod,

Can you share me about your instance? Actually, the indicators.json is for all of your indicators regarding this dataset. You may get the analytic’s data as my mentioned array as:

https://apps.dhis2.org/demo/api/analytics?dimension=dx:FnYCr2EAzWS;eTDtyyaSA7f&dimension=pe:THIS_YEAR&filter=ou:ImspTQPwCqd

where,dx:FnYCr2EAzWS=dataset
pe:THIS_YEAR=Period
ou:ImspTQPwCqd=Organization Unit

Authentication: admin / district

Please try again by this api.

And I have given you my previous email as my working dataset.

Thanks

Julhas


Regards,
Pamod Amarakoon

Confidentiality Notice: the information contained in this email and any attachments may be legally privileged and confidential. If you are not an intended recipient, you are hereby notified that any dissemination, distribution, or copying of this e-mail is strictly prohibited. If you have received this e-mail in error, please notify the sender and permanently delete the e-mail and any attachments immediately. You should not retain, copy or use this e-mail or any attachments for any purpose, nor disclose all or any part of the contents to any other person.

http://ehealthasia.org

On Sun, Sep 20, 2015 at 4:19 PM, Pamod Amarakoon pamodm@gmail.com wrote:

Dear Julhas,

The solution you suggested doesn’t seem to work on my instance. Output of indicators.json is the same output I get for the query u mentioned without getting filtered by orgUnit or period.

The particular example you mentioned, is it on a dataSet in demo site.

Thank you

On Sun, Sep 20, 2015 at 2:57 PM, Julhas Sujan julhaspustcse@gmail.com wrote:

Hi Pamod,

Please check the following link as for indicators data:
…/api/indicators.json?dataSet=XT5UDcXpXst&period=201506&orgUnit=ddTZZY0GhLW

For value format as an array:
$resultData1= Array
(
‘resultData’ => Array
(
‘headers’ => Array
(
‘0’ => Array
(
‘name’ => ‘dx’,
‘column’ => ‘Data’,
‘type’ => ‘java.lang.String’
),

                '1' => Array
                    (
                        'name' => 'pe',
                        'column' => 'Period',
                        'type' => 'java.lang.String'
                    ),

                '2' => Array
                    (
                        'name' => 'ou',
                        'column' => 'Organisation unit',
                        'type' => 'java.lang.String'
                    ),

                '3' => Array
                    (
                        'name' => 'value',
                        'column' => 'Value',
                        'type' => 'java.lang.Double'
                    ),

            ),

        'metaData' => Array
            (
               'names' => Array
                    (
                        'pe' => 'Period',
                        'yAfJFLuVkEa' => 'Argariya CC, Gazipur Sadar',
                        'ou' => 'Organisation unit',
                        'dx' => 'Data',
                        'JQt3QsxwLp5' => 'Zinc_ClosingBalance',
                        '201506' => 'August 2015'
                    )

            ),

        'rows' => Array
            (
                '0' => Array
                    (
                        '0' => 'JQt3QsxwLp5',//indicator id
                        '1' => 201508,
                        '2' => 'yAfJFLuVkEa',// organization unit

‘3’ => 1360.0// Indicator value

)

            )

    )

);

$indicatorId=$data[‘resultData’][‘rows’][0][0];
$orgUnitServer=$data[‘resultData’][‘rows’][0][2];
$indicatorValue=$data[‘resultData’][‘rows’][0][3];// Indicator Values

Hope it will be helpful for you.

Best Regards

Julhas Sujan

Management Science for Health(MSH)

Dhaka, Bangladesh

Skype: julhas08

Web: www.julhas.info


Regards,
Pamod Amarakoon

Confidentiality Notice: the information contained in this email and any attachments may be legally privileged and confidential. If you are not an intended recipient, you are hereby notified that any dissemination, distribution, or copying of this e-mail is strictly prohibited. If you have received this e-mail in error, please notify the sender and permanently delete the e-mail and any attachments immediately. You should not retain, copy or use this e-mail or any attachments for any purpose, nor disclose all or any part of the contents to any other person.

http://ehealthasia.org

On Sun, Sep 20, 2015 at 1:22 PM, Pamod Amarakoon pamodm@gmail.com wrote:

Dear All,

  1. what is the format to get a value of an aggregated indicator of a particular data set using web - API. Is it stored in database or calculated in real time
  1. is the relative period available for Previous Day (yesterday).


Regards,
Pamod Amarakoon

Confidentiality Notice: the information contained in this email and any attachments may be legally privileged and confidential. If you are not an intended recipient, you are hereby notified that any dissemination, distribution, or copying of this e-mail is strictly prohibited. If you have received this e-mail in error, please notify the sender and permanently delete the e-mail and any attachments immediately. You should not retain, copy or use this e-mail or any attachments for any purpose, nor disclose all or any part of the contents to any other person.

http://ehealthasia.org

Thank you


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

Regards,
Pamod Amarakoon

Confidentiality Notice: the information contained in this email and any attachments may be legally privileged and confidential. If you are not an intended recipient, you are hereby notified that any dissemination, distribution, or copying of this e-mail is strictly prohibited. If you have received this e-mail in error, please notify the sender and permanently delete the e-mail and any attachments immediately. You should not retain, copy or use this e-mail or any attachments for any purpose, nor disclose all or any part of the contents to any other person.