Thanks @ball for the link at Re: [OpenMRS Talk] HTML Form Entry - Velocity Functions - Passing the current encounter date or visit date
However I have found that I cannot pass existing variables to a Velocity Expression, any suggestions on how I can do something like <lookup complexExpression="$fn.latestObs(90315,$visit.startDatetime).valueCoded.name"/>
or <lookup complexExpression="$fn.latestObs(90315,$encounter.encounterDatetime).valueCoded.name"/>
The output is $fn.latestObs(90315,$visit.startDatetime).valueCoded.name
which shows that the velocity expression is not processed.
Any ideas on what I may be missing here?