How can I pre-populate input fields from url parameters?

More
1 year 6 months ago #137380 by od
od created the topic: How can I pre-populate input fields from url parameters?
Hello all,
This is my first post here on the forum, so I hope someone can help me with this.

I have installed Limesurvey, and MYSQL on a Linux box, and it´s working like a charm.

Now came the need to integrate this with some clinical software. Basically the doctor need to fill in the form for each patient. Just one form per patient. So I will also need to kind of validation, don't think tokens will work here.

Did a few tests with test survey and database get populated fine with no issues. Can see all the answers, but I need to identify the doctors id number and the appointment episode.

And I don't want the doctors to input this by hand on each appointment so the only way I found was to get that information from the active session they have on the clinical software.

How can I pre-populate for example 3 input fields from URL parameters once they start the survey for the patient?
example:
num_id=6000
num_pr=1234
num_ep=12345678
http://ipadress/limesurvey/index.php/123456?lang=ptnum_id=6000+num_pr=1234+num_ep=12345678

How do I get this onto the database?
Hope someone could help me with this.

Thanks

Please Log in to join the conversation.

More
1 year 6 months ago #137381 by holch
holch replied the topic: How can I pre-populate input fields from url parameters?
You can pass some information on as url attributes. Have a look at the panel integration option, this should do the trick for you as well. You can create the 3 questions, and associate a variable with each of those. They will then be saved in the database together with this information and you can even show it within the survey by piping via EM.

Or you could use the LS API to write the information into a token table and work from there.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in to join the conversation.

More
1 year 6 months ago #137391 by DenisChenu
DenisChenu replied the topic: How can I pre-populate input fields from url parameters?
Hi,

manual.limesurvey.org/URL_fields#Prefill...using_GET_parameters

But here : i really think it's best to create a specific token for each doctors_id/appointment_episode

2 solution :
- API: Do it with the external tools : create token line or found it if exist : and show the url wxith token in the tool
- Plugin : usign beforeSurveyPage : test if parameters already exist in token : if yes : redirect to the good token, else create and redirect.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
1 year 6 months ago #137480 by od
od replied the topic: How can I pre-populate input fields from url parameters?
Hello all.

Thank you very much for your help.
I came across the following code on php that might work, I think...

Can you guys have a look and let me know you think?
If you think it will work where should I put it?

Thanks

<?php
$num_id = $_GET;
$num_pr = $_GET;
$num_ep = $_GET;
?>
<input id='num_id' type='number' value='<?php echo $num_id; ?>' >
<input id='num_pr' type='number' value='<?php echo $num_pr; ?>' >
<input id='num_ep' type='number' value='<?php echo $num_ep; ?>' >

Please Log in to join the conversation.

More
1 year 6 months ago #137482 by holch
holch replied the topic: How can I pre-populate input fields from url parameters?
What do you want to do with this PHP code? Where do you want to use this PHP code? How do you want this code to write into the database?

Or is this your base for writing a plugin? I just don't get it how this code should help to solve your problem.

Did you look at the options given to you?

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in to join the conversation.

More
1 year 6 months ago #137492 by DenisChenu
DenisChenu replied the topic: How can I pre-populate input fields from url parameters?
If you use GET parameters : no need to hack the code ....

I i provide a link : best is to read it .....

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
1 year 6 months ago #137501 by od
od replied the topic: How can I pre-populate input fields from url parameters?
That was a piece of code i got from internet. Anyway I'm not a developer so I will need help. I will give it a try. Thanks for your time.

Please Log in to join the conversation.

More
1 year 6 months ago #137505 by od
od replied the topic: How can I pre-populate input fields from url parameters?
I will read it. As I told holch i'm not a developer so I will need help from you guys.
Thanks for your time.

Please Log in to join the conversation.

More
1 year 6 months ago #137545 by od
od replied the topic: How can I pre-populate input fields from url parameters?
Hello holch.

I tried what you said and it worked but if I use only one parameter. I searched on the forum and came across this topic: www.limesurvey.org/forum/design-issues/9...-integration-fuction
For testing purposes I created a test survey and added the URL's parameter for each of the text field (image attach).
Changed the URL to http://ip/limesurvey/index.php/577256? (on the external clinical software)

Instead of each text box being filled with it's own parameter, what happen was that the three parameters are filled on the first text box. What I'm missing here?

Thanks for your time.
Attachments:

Please Log in to join the conversation.

More
1 year 6 months ago - 1 year 6 months ago #137561 by holch
holch replied the topic: How can I pre-populate input fields from url parameters?
Of course this happens, because you need to separate the parameters somehow. At the moment, everything after the "?" is considered to be only one parameter, because you did not tell Limesurvey otherwise.

I haven't tried this, but you need to do something more like this:

http://ip/limesurvey/index.php/577256?num_mec=9000?num_proc=33687?num_epi=16000406
or
http://ip/limesurvey/index.php/577256/num_mec/9000/num_proc/33687/num_epi/16000406

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds
Last Edit: 1 year 6 months ago by holch.

Please Log in to join the conversation.

More
1 year 6 months ago #137642 by od
od replied the topic: How can I pre-populate input fields from url parameters?
Tried with both.
Not working. Everything gets populated on the first text box.

The numbers 9000 ; 33687 and 16000406 aren't always the same. As those change depending who is active and accessing the survey. For example someone with user name 9000 is dealing with process 33687 and episode 16000406 but they could change. For example me with user number 6 I'm dealing with patient process 3398 and episode 29388383.

Ideias?
Attachments:

Please Log in to join the conversation.

More
1 year 6 months ago #137643 by DenisChenu
DenisChenu replied the topic: How can I pre-populate input fields from url parameters?

Hint: The extra GET parameters is filled only when survey start. Then, when you make your own test , it's better to add newtest parameters to Y like : ls.example.org/1234?QTEXT=prefilled&newtest=Y


Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
1 year 6 months ago #137645 by holch
holch replied the topic: How can I pre-populate input fields from url parameters?
It works like a charm for me.

I created 3 short text questions called "panel1", "panel2", "panel3".

Then I went into the panel integration in the administration and mapped the attributes "panel1", "panel2", "panel3" to the questions "panel1", "panel2", "panel3". See screenshot:



When I then call the URL http://localhost/ls250/index.php/599291/panel1/aaa/panel2/bbb/panel3/ccc

"aaa" is written into the question "panel1", "bbb" is written into "panel2" and "ccc" is written into "panel3".

Seeing what is saved into your first question you are clearly using the wrong format for the URL.

Here is how it looks like, when those questions are not hidden:


I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds
Attachments:

Please Log in to join the conversation.

More
1 year 6 months ago #137646 by holch
holch replied the topic: How can I pre-populate input fields from url parameters?
When I try again, it doesn't work, because of what Denis wrote. But when you use the code "newtest" and set it to "Y" it will work. I even switched the order of the attributes and it still works fine, e.g. with this URL:
http://localhost/ls250/index.php/599291/panel2/aaa/panel3/bbb/panel1/ccc/newtest/Y/

Now panel1 gets filled with "ccc", panel2 with aaa and panel3 with bbb.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in to join the conversation.

More
1 year 6 months ago #137653 by od
od replied the topic: How can I pre-populate input fields from url parameters?
It didn't work either and I migh have found out why.
I went to the integration panel for our clinical software and made a discovery. I don't want to be messing around on that because we don't have support.
The software is based on Java and what I have found was that they have the signs + and = as arguments and variables. I'm not a programmer (just starting now). Maybe changing the + for a / will work?

The exemple you gave will work but only and only if you have a static value of aaa bbb and ccc right? What if is dinamic?

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!