cyclic root breaks dynamic data definitions?
If you make a task with a dynamic data definition cyclic then the enactment fails to start. In the following example we have a single task with a dynamic age data definition calculated from dob:
you@yourcomputer:~/Software/proformajs$ npm run repl
> @openclinical/proformajs@0.9.0 repl
> node src/repl.js
PROformajs Copyright (C) 2017 Openclinical CIC
This program comes with ABSOLUTELY NO WARRANTY;
This is free software, and you are welcome to
redistribute it under certain conditions;
This is a Javascript REPL with pre-loaded modules:
* Protocol
* Enactment
* moment
PROforma> let task = Protocol.inflate(`{"class":"Task","name":"test","cyclic":true,"dataDefinitions":[{"class":"Date","caption":"Date of birth","name":"dob"},{"class":"Integer","name":"age","valueCondition":"is_known('dob') ? now().diff(dob, 'years') : undefined"}]}`)
undefined
PROforma> task.validate()
[]
PROforma> let enactment = new Enactment({start: true, protocol: task})
Uncaught Error: Unable to getComponent 'test[0]:age' from 'test'
at Task.getComponent (file:///home/matt/Software/proformajs-jse/src/core.js:271:13)
at NumberDataDefinitionState._updateState (file:///home/matt/Software/proformajs-jse/src/evaluator.js:619:34)
at Enactment._cycle (file:///home/matt/Software/proformajs-jse/src/enactment.js:497:38)
at Enactment.start (file:///home/matt/Software/proformajs-jse/src/enactment.js:128:12)
at new Enactment (file:///home/matt/Software/proformajs-jse/src/enactment.js:119:40)
the expected behaviour is for the enactment to start and run the same protocol indefinately. If you set cyclic to false then it runs once successfully.
Edited by Matt South