OpenClinica / enketo-oc

OpenClinica's fork of the Enketo web forms monorepo
Apache License 2.0
0 stars 1 forks source link

OC Only: Async Query widget #202

Open enketo-issue-mover opened 6 years ago

enketo-issue-mover commented 6 years ago

From @MartijnR on June 29, 2018 19:55

Somewhat related to #1052

Objective:

The "widget"

Have a 'widget' with a button that upon click makes an (asynchronous) request to an OC endpoint. Possible block complete form UI during request.

  1. The url could be a jr:// url that can be found in the Manifest.
  2. Enketo could pass an xpath-query parameter to the API request
  3. Enketo could pass a result-type to the API request with as possible values string and instance
  4. We don't mix and match asynchronous and synchronous functions in XPath.

simple string, that populates oc1:

type name appearance bind::oc:api-query calculation
text oc1 oc-api-query oc-api(jr://file/abc.xml, /path/to[name=${one}]/node, 'string' )
calculate two ${oc1} + 3

node fragment (readonly text = note because it doesn't store a value in this node):

type name appearance bind::oc:api-query calculation
note oc1 oc-api-query oc-api(jr://file/abc.xml, /path/to[name=${one}]/item, 'instance' )
calculate two instance("abc")/path/to/node

An empty <instance id="abc" oc:writeable="true" /> would have to be added to the XForm as well for the last example.

Upon failed retrieval:

Upon successful retrieval:

If the result is of type string, the simplest flavor of this widget would simply populate that question (i.e. that text question with an oc-api-query appearance) with the returned value. This seems fairly straightforward.

If the result is of type instance, it could populate/add/refresh (?) an instance in the form. (NOTE: requires creating support for writable instances, and triggering re-evaluation of logic when such an instance gets re-freshed). There could be other questions that use that instance, e.g. calculations or selects that will get updated. Not sure yet about the XForm and XLSForm syntax possibilities here.

Copied from original issue: kobotoolbox/enketo-express#1076

enketo-issue-mover commented 6 years ago

From @MartijnR on July 4, 2018 22:2

for simple string version, Martijn to implement:

This would take him about 3-4 days (mocking the API).

OC to implement:

enketo-issue-mover commented 6 years ago

From @MartijnR on July 4, 2018 22:8

What we actually need to use for the instance population is XForms Event and Actions.

for the complex instance-populating version, Martijn to implement:

This would take him about 5-6 additional days.

OC to implement:

enketo-issue-mover commented 6 years ago

From @MartijnR on July 6, 2018 19:36

Does the first parameter of oc-api make sense? Enketo doesn't actually need to retrieve this file. OC needs to be able to find it. Maybe this should just be the OC API endpoint that Enketo should send the request to?

Needs more thought.

enketo-issue-mover commented 6 years ago

From @pbowen-oc on July 27, 2018 19:58

@kkrumlian - We need to provide input to go ahead with this.