Setting a text field to display conditionally based on age.

I have a text field in a jasperreport that I want to display if the animal is over 7.  

I created a variable (boolean) that was set to the expression

YEAR(TODAY())-YEAR($F{patient.entity.datefBirth})>7

I also tried

YEARS($F{patient.entity.datefBirth}, Today())>7

both still return false even when the patient is 15 on file.  

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: Setting a text field to display conditionally based on age.

​$P{dataSource}.getExpressionDataSource("reminder:getReminders(openvpms:get(.,'patient.entity'), date:add(date:today(),'-1d'),date:now())")

 

I additionally noted that if I tried to rpelace the date:now() function with $F{startTime} the function returned a jxpath error which is strange considering the getReminders function takes a java.util.Date as the param which is what that variable is


08 Aug. 2022 14:47:26,981 WARN AbstractDataSource,http-nio-8080-exec-24:130 - Ben - Failed to evaluate 'reminder:getReminders(openvpms:get(.,'patient.entit
y'), date:add(((java.util.Date)field_startTime.getValue()),'-1d'),date:add(((java.util.Date)field_startTime.getValue()),'1d'))' in report=Vaccination_Certif
icate_list.jrxml against object=act.patientDocumentForm:490424:f6cb7232-16d0-11ed-973b-0f13951c7fef. Current record object=act.patientDocumentForm:490424:f6
cb7232-16d0-11ed-973b-0f13951c7fef: Invalid XPath: 'reminder:getReminders(openvpms:get(.,\'patient.entity\'), date:add(((java.util.Date)field_startTime.getV
alue()),\'-1d\'),date:add(((java.util.Date)field_startTime.getValue()),\'1d\'))'. Syntax error after: 'reminder:g'
08 Aug. 2022 14:50:24,178 WARN AbstractDataSource,http-nio-8080-exec-41:130 - Ben - Failed to evaluate 'reminder:getReminders(openvpms:get(.,'patient.entit
y'), date:add(((java.util.Date)field_startTime.getValue()),'-1d'),date:now())' in report=Vaccination_Certificate_list.jrxml against object=act.patientDocume
ntForm:490424:f6cb7232-16d0-11ed-973b-0f13951c7fef. Current record object=act.patientDocumentForm:490424:f6cb7232-16d0-11ed-973b-0f13951c7fef: Invalid XPath
: 'reminder:getReminders(openvpms:get(.,\'patient.entity\'), date:add(((java.util.Date)field_startTime.getValue()),\'-1d\'),date:now())'. Syntax error after
: 'reminder:g'
Regards
 
Ben 
OpenVPMS Installer and Helper 
Ph: +61423044823 
Email: info[at]charltonit.com[dot]au

Re: Setting a text field to display conditionally based on age.

You have a typo in your field name. It should be:

$F{patient.entity.dateOfBirth}

The easiest way to diagnose these problems is to create a field for each part of the expression you are having trouble with i.e. create a field for each of:

  • $F{patient.entity.datefBirth}

  • YEAR(TODAY())

  • YEAR($F{patient.entity.datefBirth})

The first will display null indicating there is a problem with that field

Re: Setting a text field to display conditionally based on age.

Any ideas on the other issue with the reminder report data source and filtering it based on startTime as opposed to the current date

 

Regards
 
Ben 
OpenVPMS Installer and Helper 
Ph: +61423044823 
Email: info[at]charltonit.com[dot]au

Re: Setting a text field to display conditionally based on age.

Any ideas on the other issue with the reminder report data source and filtering it based on startTime as opposed to the current date

 

Regards
 
Ben 
OpenVPMS Installer and Helper 
Ph: +61423044823 
Email: info[at]charltonit.com[dot]au

Re: Setting a text field to display conditionally based on age.

Try:

​$P{dataSource}.getExpressionDataSource("reminder:getReminders(openvpms:get(.,'patient.entity'), date:add(date:today(),'-1d'),openvpms:get(.,'startTime'))")

or:

​$P{dataSource}.getExpressionDataSource("reminder:getReminders(openvpms:get(.,'patient.entity'), date:add(date:today(),'-1d'),$F.startTime")

The $F. and $P. prefixes allows JasperReport fields and parameters to be exposed to jxpath functions.

Syndicate content