Populating data from Excel to DHIS2 Data Entry Web Form with Internet Explorer

Hi!

I’m trying to populate data from Excel to DHIS2 Data Entry Web Form using VBA code in Excel with Internet Explorer, the data goes to form but not persisted to database. Anyone already try to do that?

The VBA code, tested to fill form in the demo instance:

'Before run this Macro make sure to login into dhis2-demo using Internet Explorer

Sub FillInternetForm()

Dim IE As Object

Set IE = CreateObject(“InternetExplorer.Application”)

IE.Navigate “https://play.dhis2.org/demo/dhis-web-dataentry/index.action

IE.Visible = True

While IE.busy

DoEvents 'wait until IE is done loading page.

Wend

'You have 30 seconds to choose Orgunit, form and period

'Eg. Sierra Leone, Emergency Response, Result

Application.Wait Now + TimeValue(“00:00:30”)

'Populating Data to two first fields

IE.document.getElementById(“KFnFpbqDqji-bRowv6yZOF2-val”).Focus

IE.document.getElementById(“KFnFpbqDqji-bRowv6yZOF2-val”).Value = “20”

Application.Wait Now + TimeValue(“00:00:02”)

IE.document.getElementById(“zFFb3bar4Ct-bRowv6yZOF2-val”).Focus

IE.document.getElementById(“zFFb3bar4Ct-bRowv6yZOF2-val”).Value = “30”

End Sub

The result:

The Data goes to the field but not persisted, the field don’t change color.

I appreciate your help if you can provide.

Thank you

Damasceno Lopes, MSc

Health Information System Officer

Friends in Global Health, Mozambique

+258844626770 | +258829502145

FGH

image

image

···

Hi there

To make sure that the data values are saved, you need to trigger the “change” event on each field.

https://github.com/dhis2/dhis2-core/blob/master/dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js#L538

···

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Thu, Oct 26, 2017 at 9:18 PM, Damasceno Lopes damascenolopess@gmail.com wrote:

Hi!

I’m trying to populate data from Excel to DHIS2 Data Entry Web Form using VBA code in Excel with Internet Explorer, the data goes to form but not persisted to database. Anyone already try to do that?

The VBA code, tested to fill form in the demo instance:

'Before run this Macro make sure to login into dhis2-demo using Internet Explorer

Sub FillInternetForm()

Dim IE As Object

Set IE = CreateObject(“InternetExplorer.Application”)

IE.Navigate “https://play.dhis2.org/demo/dhis-web-dataentry/index.action

IE.Visible = True

While IE.busy

DoEvents 'wait until IE is done loading page.

Wend

'You have 30 seconds to choose Orgunit, form and period

'Eg. Sierra Leone, Emergency Response, Result

Application.Wait Now + TimeValue(“00:00:30”)

'Populating Data to two first fields

IE.document.getElementById(“KFnFpbqDqji-bRowv6yZOF2-val”).Focus

IE.document.getElementById(“KFnFpbqDqji-bRowv6yZOF2-val”).Value = “20”

Application.Wait Now + TimeValue(“00:00:02”)

IE.document.getElementById(“zFFb3bar4Ct-bRowv6yZOF2-val”).Focus

IE.document.getElementById(“zFFb3bar4Ct-bRowv6yZOF2-val”).Value = “30”

End Sub

The result:

The Data goes to the field but not persisted, the field don’t change color.

I appreciate your help if you can provide.

Thank you

Damasceno Lopes, MSc

Health Information System Officer

Friends in Global Health, Mozambique

+258844626770 | +258829502145

FGH


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

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

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

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

You may also want to consider just making the HTTP request, instead of working with the form itself

https://support.microsoft.com/en-us/help/301102/how-to-make-a-get-request-by-using-visual-basic–net-or-visual-basic-2

The DHIS2 dataValue API is documented in here in “Section 1.19.7. Sending, reading and deleting individual data values”

Regards,

Jason

···

On Thu, Oct 26, 2017 at 4:18 PM, Damasceno Lopes damascenolopess@gmail.com wrote:

Hi!

I’m trying to populate data from Excel to DHIS2 Data Entry Web Form using VBA code in Excel with Internet Explorer, the data goes to form but not persisted to database. Anyone already try to do that?

The VBA code, tested to fill form in the demo instance:

'Before run this Macro make sure to login into dhis2-demo using Internet Explorer

Sub FillInternetForm()

Dim IE As Object

Set IE = CreateObject(“InternetExplorer.Application”)

IE.Navigate “https://play.dhis2.org/demo/dhis-web-dataentry/index.action

IE.Visible = True

While IE.busy

DoEvents 'wait until IE is done loading page.

Wend

'You have 30 seconds to choose Orgunit, form and period

'Eg. Sierra Leone, Emergency Response, Result

Application.Wait Now + TimeValue(“00:00:30”)

'Populating Data to two first fields

IE.document.getElementById(“KFnFpbqDqji-bRowv6yZOF2-val”).Focus

IE.document.getElementById(“KFnFpbqDqji-bRowv6yZOF2-val”).Value = “20”

Application.Wait Now + TimeValue(“00:00:02”)

IE.document.getElementById(“zFFb3bar4Ct-bRowv6yZOF2-val”).Focus

IE.document.getElementById(“zFFb3bar4Ct-bRowv6yZOF2-val”).Value = “30”

End Sub

The result:

The Data goes to the field but not persisted, the field don’t change color.

I appreciate your help if you can provide.

Thank you

Damasceno Lopes, MSc

Health Information System Officer

Friends in Global Health, Mozambique

+258844626770 | +258829502145

FGH


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

Jason P. Pickering
email: jason.p.pickering@gmail.com
tel:+46764147049

Given the widespread knowledge of VBA coupled with the huge trove of legacy data in Excel and the continued use of Excel for offline data collection, it could be nice to add an appendix to the documentation with code snippets to import data directly from Excel to the API, in addition to the R documentation (munging?).

Perhaps it is something you could be interesting in developing and sharing, Damasceno?

Cheers,

Knut

···

On Thu, Oct 26, 2017 at 4:55 PM, Jason Pickering jason.p.pickering@gmail.com wrote:

You may also want to consider just making the HTTP request, instead of working with the form itself

https://support.microsoft.com/en-us/help/301102/how-to-make-a-get-request-by-using-visual-basic–net-or-visual-basic-2

The DHIS2 dataValue API is documented in here in “Section 1.19.7. Sending, reading and deleting individual data values”

Regards,

Jason


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

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

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

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

On Thu, Oct 26, 2017 at 4:18 PM, Damasceno Lopes damascenolopess@gmail.com wrote:

Hi!

I’m trying to populate data from Excel to DHIS2 Data Entry Web Form using VBA code in Excel with Internet Explorer, the data goes to form but not persisted to database. Anyone already try to do that?

The VBA code, tested to fill form in the demo instance:

'Before run this Macro make sure to login into dhis2-demo using Internet Explorer

Sub FillInternetForm()

Dim IE As Object

Set IE = CreateObject(“InternetExplorer.Application”)

IE.Navigate “https://play.dhis2.org/demo/dhis-web-dataentry/index.action

IE.Visible = True

While IE.busy

DoEvents 'wait until IE is done loading page.

Wend

'You have 30 seconds to choose Orgunit, form and period

'Eg. Sierra Leone, Emergency Response, Result

Application.Wait Now + TimeValue(“00:00:30”)

'Populating Data to two first fields

IE.document.getElementById(“KFnFpbqDqji-bRowv6yZOF2-val”).Focus

IE.document.getElementById(“KFnFpbqDqji-bRowv6yZOF2-val”).Value = “20”

Application.Wait Now + TimeValue(“00:00:02”)

IE.document.getElementById(“zFFb3bar4Ct-bRowv6yZOF2-val”).Focus

IE.document.getElementById(“zFFb3bar4Ct-bRowv6yZOF2-val”).Value = “30”

End Sub

The result:

The Data goes to the field but not persisted, the field don’t change color.

I appreciate your help if you can provide.

Thank you

Damasceno Lopes, MSc

Health Information System Officer

Friends in Global Health, Mozambique

+258844626770 | +258829502145

FGH


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

Jason P. Pickering
email: jason.p.pickering@gmail.com
tel:+46764147049

Knut Staring

Dept. of Informatics, University of Oslo

Norway: +4791880522

Skype: knutstar

http://dhis2.org

Thanks Morten,

After hit the change event on the fields the data values are now saved/persisted.

Damasceno Lopes, MSc

Health Information System Officer

Friends in Global Health, Mozambique

+258844626770 | +258829502145

FGH-Mozambique

···

2017-10-26 16:41 GMT+02:00 Morten Olav Hansen morten@dhis2.org:

Hi there

To make sure that the data values are saved, you need to trigger the “change” event on each field.

https://github.com/dhis2/dhis2-core/blob/master/dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js#L538

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Thu, Oct 26, 2017 at 9:18 PM, Damasceno Lopes damascenolopess@gmail.com wrote:

Hi!

I’m trying to populate data from Excel to DHIS2 Data Entry Web Form using VBA code in Excel with Internet Explorer, the data goes to form but not persisted to database. Anyone already try to do that?

The VBA code, tested to fill form in the demo instance:

'Before run this Macro make sure to login into dhis2-demo using Internet Explorer

Sub FillInternetForm()

Dim IE As Object

Set IE = CreateObject(“InternetExplorer.Application”)

IE.Navigate “https://play.dhis2.org/demo/dhis-web-dataentry/index.action

IE.Visible = True

While IE.busy

DoEvents 'wait until IE is done loading page.

Wend

'You have 30 seconds to choose Orgunit, form and period

'Eg. Sierra Leone, Emergency Response, Result

Application.Wait Now + TimeValue(“00:00:30”)

'Populating Data to two first fields

IE.document.getElementById(“KFnFpbqDqji-bRowv6yZOF2-val”).Focus

IE.document.getElementById(“KFnFpbqDqji-bRowv6yZOF2-val”).Value = “20”

Application.Wait Now + TimeValue(“00:00:02”)

IE.document.getElementById(“zFFb3bar4Ct-bRowv6yZOF2-val”).Focus

IE.document.getElementById(“zFFb3bar4Ct-bRowv6yZOF2-val”).Value = “30”

End Sub

The result:

The Data goes to the field but not persisted, the field don’t change color.

I appreciate your help if you can provide.

Thank you

Damasceno Lopes, MSc

Health Information System Officer

Friends in Global Health, Mozambique

+258844626770 | +258829502145

FGH


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

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

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

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

Hi Knut,

I'm not using HTTP request to post the data to DHIS2, Im just filling DHIS2
Web Data Entry Form Automatically with MS Excel data. We choose this Option
to fill Large Forms so the mappings will secure no error on data entering.

Check a sample on the video attached.

Thanks

···

2017-10-26 17:12 GMT+02:00 Knut Staring <knutst@gmail.com>:

Given the widespread knowledge of VBA coupled with the huge trove of
legacy data in Excel and the continued use of Excel for offline data
collection, it could be nice to add an appendix to the documentation with
code snippets to import data directly from Excel to the API, in addition to
the R documentation (munging?).

Perhaps it is something you could be interesting in developing and
sharing, Damasceno?

Cheers,
Knut

On Thu, Oct 26, 2017 at 4:55 PM, Jason Pickering < > jason.p.pickering@gmail.com> wrote:

You may also want to consider just making the HTTP request, instead of
working with the form itself

https://support.microsoft.com/en-us/help/301102/how-to-make-
a-get-request-by-using-visual-basic--net-or-visual-basic-2

The DHIS2 dataValue API is documented in here
<Home - DHIS2 Documentation;
in "Section 1.19.7. Sending, reading and deleting individual data values"

Regards,
Jason

On Thu, Oct 26, 2017 at 4:18 PM, Damasceno Lopes < >> damascenolopess@gmail.com> wrote:

Hi!

I’m trying to populate data from Excel to DHIS2 Data Entry Web Form
using VBA code in Excel with Internet Explorer, the data goes to form but
not persisted to database. Anyone already try to do that?

The VBA code, tested to fill form in the demo instance:

'Before run this Macro make sure to login into dhis2-demo using Internet
Explorer

Sub FillInternetForm()

Dim IE As Object

Set IE = CreateObject("InternetExplorer.Application")

IE.Navigate "https://play.dhis2.org/demo/dhis-web-dataentry/index.action
"

IE.Visible = True

While IE.busy

DoEvents 'wait until IE is done loading page.

Wend

'You have 30 seconds to choose Orgunit, form and period

'Eg. Sierra Leone, Emergency Response, Result

Application.Wait Now + TimeValue("00:00:30")

'Populating Data to two first fields

IE.document.getElementById("KFnFpbqDqji-bRowv6yZOF2-val").Focus

IE.document.getElementById("KFnFpbqDqji-bRowv6yZOF2-val").Value = "20"

Application.Wait Now + TimeValue("00:00:02")

IE.document.getElementById("zFFb3bar4Ct-bRowv6yZOF2-val").Focus

IE.document.getElementById("zFFb3bar4Ct-bRowv6yZOF2-val").Value = "30"

End Sub

The result:

The Data goes to the field but not persisted, the field don’t change
color.

I appreciate your help if you can provide.

Thank you

*Damasceno Lopes, MSc*

*Health Information System Officer*

Friends in Global Health, Mozambique

*+258844626770 <+258%2084%20462%206770>* | *+258829502145
<damasceno.lopes@fgh.org.mz>*

[image: FGH]

_______________________________________________
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

--
Jason P. Pickering
email: jason.p.pickering@gmail.com
tel:+46764147049 <+46%2076%20414%2070%2049>

_______________________________________________
Mailing list: https://launchpad.net/~dhis2-users
Post to : dhis2-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-users
More help : https://help.launchpad.net/ListHelp

--
Knut Staring
Dept. of Informatics, University of Oslo
Norway: +4791880522 <+47%20918%2080%20522>
Skype: knutstar
http://dhis2.org

But this job of manually selecting org/units and also working with browser loading DHIS2 is time consuming and not efficient. Better way is to work with apis. Just post data and you are done. It would work more than 100000 times faster.

Regards,

Sultan Ahamar.

···

On Thu, Oct 26, 2017 at 9:31 PM, Damasceno Lopes damascenolopess@gmail.com wrote:

Thanks Morten,

After hit the change event on the fields the data values are now saved/persisted.

Damasceno Lopes, MSc

Health Information System Officer

Friends in Global Health, Mozambique

+258844626770 | +258829502145

FGH-Mozambique


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

2017-10-26 16:41 GMT+02:00 Morten Olav Hansen morten@dhis2.org:

Hi there

To make sure that the data values are saved, you need to trigger the “change” event on each field.

https://github.com/dhis2/dhis2-core/blob/master/dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js#L538

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Thu, Oct 26, 2017 at 9:18 PM, Damasceno Lopes damascenolopess@gmail.com wrote:

Hi!

I’m trying to populate data from Excel to DHIS2 Data Entry Web Form using VBA code in Excel with Internet Explorer, the data goes to form but not persisted to database. Anyone already try to do that?

The VBA code, tested to fill form in the demo instance:

'Before run this Macro make sure to login into dhis2-demo using Internet Explorer

Sub FillInternetForm()

Dim IE As Object

Set IE = CreateObject(“InternetExplorer.Application”)

IE.Navigate “https://play.dhis2.org/demo/dhis-web-dataentry/index.action

IE.Visible = True

While IE.busy

DoEvents 'wait until IE is done loading page.

Wend

'You have 30 seconds to choose Orgunit, form and period

'Eg. Sierra Leone, Emergency Response, Result

Application.Wait Now + TimeValue(“00:00:30”)

'Populating Data to two first fields

IE.document.getElementById(“KFnFpbqDqji-bRowv6yZOF2-val”).Focus

IE.document.getElementById(“KFnFpbqDqji-bRowv6yZOF2-val”).Value = “20”

Application.Wait Now + TimeValue(“00:00:02”)

IE.document.getElementById(“zFFb3bar4Ct-bRowv6yZOF2-val”).Focus

IE.document.getElementById(“zFFb3bar4Ct-bRowv6yZOF2-val”).Value = “30”

End Sub

The result:

The Data goes to the field but not persisted, the field don’t change color.

I appreciate your help if you can provide.

Thank you

Damasceno Lopes, MSc

Health Information System Officer

Friends in Global Health, Mozambique

+258844626770 | +258829502145

FGH


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

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

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

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