Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Node positional calculation not working dynamically #455

Closed
pbowen-oc opened this issue Feb 24, 2021 · 7 comments
Closed

Node positional calculation not working dynamically #455

pbowen-oc opened this issue Feb 24, 2021 · 7 comments
Assignees
Milestone

Comments

@pbowen-oc
Copy link

The attached form attempts to read in from the clinicaldata instance using three different methods:

  1. Using node position: [1]
  2. Using node position: [position()=${rownum}] where ${rownum} = 1 (from a calculate item = position(..))
  3. Using node position: [number(${rownum})] where ${rownum} = 1 (from a calculate item = position(..))

Only the first method reads in the value successfully. The other options read in null. All three were expected to work.

Method #2 was in use on the original source form prior to deploying 2.5.6.oc-5 and working successfully then. Since that time, it reads no data.

XForm: NodePositionCalc.xml.txt

Clinicaldata instance: NodePositionCalc.clinicaldata.xml.txt

Screenshot 2021-02-24 001514

@pbowen-oc pbowen-oc added this to the Next milestone Feb 24, 2021
@MartijnR
Copy link

MartijnR commented Feb 24, 2021

http://localhost:8005/?xform=NodePositionCalc.xml

  • create a minimal test form

@MartijnR
Copy link

MartijnR commented Feb 24, 2021

I believe the two none-working formulas are evaluating correctly because current() is missing in the predicate (same as #398 (comment)). That would be a pyxform issue then. Will confirm.

  • run original form in enketo-express-oc with correction of predicate to current()/../rownum to confirm that the XForm is wrong - confirmed
  • test similar xlsform in latest pyxform - did not do after discovering open bug report
  • file bug report in pyxform if necessary

@MartijnR
Copy link

MartijnR commented Feb 24, 2021

Pyxform issue already posted: XLSForm/pyxform#490 (and it looks like I was aware that OpenClinica needed this fix)

@MartijnR
Copy link

MartijnR commented Feb 24, 2021

Method #2 was in use on the original source form prior to deploying 2.5.6.oc-5 and working successfully then. Since that time, it reads no data.

Definitely no recent change in this very elementary XPath evaluation in Enketo. XPath expressions are clearly incorrect. However, in the past pyxform would have generated an absolute path for ${rownum}, which though this was also incorrect, may have caused this to be evaluated as desired.

To bypass the pyxform bug, remove the ${node} references and replace by beautiful pure XPath

current replace with
[position()=${rownum}] [position()=current()/../rownum]
number(${rownum}) number(current()/../rownum)

@pbowen-oc
Copy link
Author

@MartijnR - Thanks. Am I correct in assuming that we will need to take this approach for now for any item references used in the instance expression? Is this syntax going to vary if the item being referenced is in a different group than the item that has this instance expression?

@pbowen-oc
Copy link
Author

I have created a new Pyxform issue (XLSForm/pyxform#531) since the previous fix was incomplete and did not handle expressions that contained spaces.

@pbowen-oc
Copy link
Author

This is all set.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants