Conditional Text

Hi,

Sorry if this has been posted somewhere else, but my search only came up with posts from 2013.

Are the conditional text functions for male/female he/she?

I thought it might be something to do with the expr:if(openvpms:get(.,'sex')='MALE','M')

But I can't get it to work within a macro

ie:

concat('Please feed ', openvpms:get($patient,'name') ,' as much food as expr:if(openvpms:get(.,'sex')='MALE','he', 'she') wants ')

 

Thanks,

Greta

Comment viewing options

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

Re: Conditional Text

The expression openvpms:get(.,'sex') will probably not work as the period will generally not refer to a patient.

Replace it with: openvpms:get($patient,'sex')

Secondly, there are some single quotes and commas missing. It should be:

concat('Please feed ', openvpms:get($patient,'name') ,' as much food as ',
expr:if(openvpms:get($patient,'sex') = 'MALE','he', 'she'), ' wants ')

Thirdly, there are a couple of simplications:

  • openvpms:get($patient, 'name') can be changed to $patient.name
  • openvpms:get($patient,'sex') can be changed to $patient.sex.code

This gives the overall expression:

concat('Please feed ', $patient.name, ' as much food as ',
expr:if($patient.sex.code = 'MALE', 'he', 'she'), ' wants ')

Re: Conditional Text

Awesome! Thanks so much Tim.

Greta

Syndicate content