XForm calculate not working

0 views
Skip to first unread message

Joaquín Blaya

unread,
Jun 7, 2012, 4:34:03 PM6/7/12
to implem...@openmrs.org
Hi,
I've created a form, with a coded concept where one of the possible answers is the concept 6157^Si respuesta^99DCT. Then I've placed a numeric concept that has in the calculate field the following value 

(function () {if(/form/obs/tuvo_menarca/value=='6157^Si respuesta^99DCT' )  { value = 1; }} ) ()

However in the Preview tab and when I fill out the form, the value isn't calculate. 

I've tried using /obs/tuvo_menarca/value, using double instead of single quotes around the 6157^Si respuesta^99DCT, but it hasn't worked. What am I doing wrong?

Also, I know there's a simpler way of doing this calculation, but this is just an initial one for something more complex which will require if and else ifs.

Thanks,

Joaquín
___________________________________________________________________
Gerente de Desarrollo, eHealth Systems
Research Fellow, Escuela de Medicina de Harvard
Moderador, GHDOnline.org

Daniel Kayiwa

unread,
Jun 8, 2012, 3:13:37 AM6/8/12
to implem...@openmrs.org
Hi Joaquin,

Can you change: value = 1; to return 1;





--
The greatest want of the world is the want of men—men who will not be bought or sold, men who in their inmost souls are true and honest, men who do not fear to call sin by its right name, men whose conscience is as true to duty as the needle to the pole, men who will stand for the right though the heavens fall. 

Joaquín Blaya

unread,
Jun 8, 2012, 2:44:20 PM6/8/12
to implem...@openmrs.org
Hi Daniel,
It didn't work.  I tried also with one = or == for checking the value and it also didn't work. 

(function () {if(/form/obs/diu_edad_y_tabaquismo/value==1 )  { return 1; }} ) ()


Joaquín
___________________________________________________________________
Gerente de Desarrollo, eHealth Systems
Research Fellow, Escuela de Medicina de Harvard
Moderador, GHDOnline.org


Daniel Kayiwa

unread,
Jun 9, 2012, 2:24:19 PM6/9/12
to implem...@openmrs.org

Hi Joaquin,

Can you send me the form?
If we keep uppermost in our minds the unkind and unjust acts of others, we shall find it impossible to love them as Christ has loved us; but if our thoughts dwell upon the wondrous love and pity of Christ for us, the same spirit will flow out to others.

Joaquín Blaya

unread,
Jun 9, 2012, 3:21:15 PM6/9/12
to implem...@openmrs.org
Sure, here it is.


Joaquín
___________________________________________________________________
Gerente de Desarrollo, eHealth Systems
Research Fellow, Escuela de Medicina de Harvard
Moderador, GHDOnline.org


Prueba-de-calcular.xml

Daniel Kayiwa

unread,
Jun 11, 2012, 3:32:41 AM6/11/12
to implem...@openmrs.org

Thanks Joaquin for reporting this.
I noted that:

There is a bug which requires you to have spaces on both sides of the equal signs. For instance, use: ...value == 6101 instead of ...value==6101

So just put at least one space at the beginning and end of the equal signs and try again.

Joaquín Blaya

unread,
Jun 11, 2012, 9:37:55 AM6/11/12
to implem...@openmrs.org
Great, that worked!

Thanks Daniel,


Joaquín
___________________________________________________________________
Gerente de Desarrollo, eHealth Systems
Research Fellow, Escuela de Medicina de Harvard
Moderador, GHDOnline.org


Reply all
Reply to author
Forward
0 new messages