Thanks, Stephane. I had thought of this already, but immediately dismissed it, because it would mean that I have to store the full patient database on the tablet, which is too much of a security risk when the tablet “disappears”.
For the simplified case I described (“patient exists”), a hash would be enough, but in the real application I need to retrieve the details of the patient as a feedback to the interviewer.
There are much more basic applications around (e.g. breezingforms in Joomla) that allow inserting JQuery Ajax into a field, but I am aware that this will not generalize well enough for the non-connected case.
Still thinking about some solution that would only transfer one patient’s data on request,
Just in case someone has another idea, here the full workflow:
Interviewer scans the patient’s barcode. No pull of data set
Barcode request patient’s details from server, and displays names, dob on all forms to give feedback to interviewer that she is adding additional data from the correct person.
Pulldata from an URL is not supported. I am not sure about this, because it is tempting to use it when you upload a media csv file, but let’s wait for someone knowing better.
So we must try to use the “manual copy csv-method” by using a sync tool. I used SMBSyn2 on Android, which works nicely.
On Android, form media are stored in subdirectories of /storage/emulated/0/odk/forms. When you have several versions of a form, there are multiple directories disambiguated by (2), (3).
Use SMBSync2 to synchronize all files in this folder with all non-empty subfolders with some Samba-Share - with other apps you can also synchronize with some network share, but the Sambo-solution was good enough for me. Make sure you have selected the advanced options, with “do not overwrite newer files”. You need this step to find out how the directory structure is.
Do the synchronization. Edit the CSV.imported-file (but read the full text first), or replace it by a new one. You need to make sure that you realy picked the latest version of the subdirectory, some clever script could do this automatically.
Create another task in SmbSync2 to COPY newer files to the device. Do the sync.
Test by entering new data into a form. Be surprised that things have not changed, old file still active.
Why? Kobo does not care about the CSV.imported file, because it looks up what is in the SQlite database, without checking that the CSV.imported had been changed.
So do the following:
Do not edit the CSV.imported file on your Samba share, but edit the SQLite database xxx.db with a standard tool - I use https://sqlitestudio.pl/. Then copy the file back to your device. This means that you can restrict the synchronization to *.db files only.
This procedure is a mess, and will not work reliably in practice. Correct me when I am wrong, but please provide an example.
After reading REST request to retrieve a value from an external source, I tried the same with ODK Collect 1…27.1 today: First, it does not create a file xx.csv.imported, but keeps the filename xx. Nice. In addition, it keeps a hash of the file in the database table externalMetadata, and updating the CSV file works; the app updates the database when the CSV file changes. Well done.
I hope this feature will carry over to the announce 1.27.1 of Kobo.
The location of the CSV file has change when you accepted the “Migration” request. It is now (don’t blame me when I mistyped the boa constrictor):
I don’t know if you ever found a better solution to this, but I “worked around” this by building a custom android application that receives and passes intents to Collect.
Now I’m looking for some kind of solution that will work with Enketo.