I wanted to know if it is possible to do a search on a table created from odk-x survey form using multiple parameters e.g the 3 names.
Problem I want to solve.Registration at the clinic poses many challenges.Clients may pose as new clients and so a search on the 3 names and a mothers first name may help
Any help on this is greatly appreciated
There are multiple ways to solve this, but what I find easiest is to use the âODK-X Tablesâ app to display the search screen (i.e. the text entry fields and a search button) and then use javascript to do the lookup in the database based on SQL. That way you have full control of the SQL query (if you want to experiment I recommend that you copy the sqlite.db file from the device (/sdcard/opendatakit/data/webDb) to your computer and uses something like DB Browser to test/build your SQLâŚ
So basically there are three steps;
use javascript to construct the SQL based on user input
Define the successFn and failureFn. In the successFn you can iterate through the results produced by the SQL like this;
var successFn = function( result ) {
var persons = []; // this array will hold the persons found by the sql query
for (var row = 0; row < result.getCount(); row++) {
var id = result.getData(row,"_id");
var temperatura = result.getData(row,"temperatura");
var febre = result.getData(row,"febre");
var p = {
id,
temperatura,
febre,
}
persons.push(p); // This adds the "person" to the array
}
populateList(persons);
return;
}
Finally you can the display the persons and hook it up so that when you click a person, you open a new form instance for that personâŚ
We have solved a similar problem, so you can have a look at the complete (unpolished) solution for a âCentroâ (i.e. Clinic) page out here:
Let us know how that works out - I will be happy to help if you get stuck somewhere
Many many thanks @Emil
Let me try this and keep you posted
Attached is the form am working on.Please check it and see how best to offer other insights
Once again Thanks CBS_Case_Report.xlsx (28.2 KB)
Hi Duncan,
Does that mean that you got your search page working in ODK-X Tables and the results displayed correctly? And then, once you click on one of the results, and tries to open a new form in ODK-X Survey with some parameters passed on from javascript ODK-X Survey crashes? If so, I think that can sometimes happen if you include some parameters in the json-object you pass on to ODK-X Survey that Survey does not expect⌠Have you checked that all the variables that you pass along exist in the formâs model?
E.g. both variable_01 and variable_02 must be âknownâ by the form in Survey and of the correct type (i.e. be mentioned on the model sheet of the excel workbook)