Velocity Lookup fn.getConcept() Short Name

3 views
Skip to first unread message

Craig A.

unread,
Nov 17, 2014, 4:48:11 AM11/17/14
to implem...@openmrs.org
Hi Everyone,

I'm creating an emergency contact form using the SimpleUi in HTML Form Entry Module. I'm able to call the name of a concept using the velocity Lookup Expression <lookup expression="fn.getConcept('').name"/>. The Fully Specified Name is "Emergency Contact Relationship" with short name "Relationship"  On the form, this all sits within a section titled "Emergency Contact," so the most appropriate term to display in the form <legend> is on the form is "Relationship."Is it possible to get the short name of a concept?

I tried:

fn.getConcept('').shortname
fn.getConcept('').shortName 
fn.getConcept('').short 

Thank you!
Craig

Burke Mamlin

unread,
Nov 17, 2014, 10:02:30 AM11/17/14
to implem...@openmrs.org
Looking at the API docs at http://api.openmrs.org, it appears that you need to specify the locale.[1]

Try something like:

fn.getConcept(...).getShortNameForLocale('en')

Actually, you should use the context's locale, but I'm at a conference on my phone and I'm not sure of the right way to get it in Velocity.  Probably something like Context.locale or fn.getContext().locale.

Cheers,

--
OpenMRS Implementers: http://om.rs/implist
Post: implem...@openmrs.org | Unsubscribe: implementers...@openmrs.org
Manage your OpenMRS subscriptions at http://om.rs/id
 
Register today for our Maputo 2015 Implementers Meeting: http://om.rs/moz15

Craig A.

unread,
Nov 25, 2014, 12:12:10 AM11/25/14
to implem...@openmrs.org
Hi Burke,

Thank you for your help with this. I reviewed the code, but didn't have the knowledge to make it work. Instead, I was able to use a different approach. I added a synonym in the concept and made it the "preferred name" in the dictionary. Now, referencing the name with <lookup expression="fn.getConcept('').name"/> gives me the "preferred name" synonym which is exactly what I need. Again, thank you for your help with this!

Sincerely,
Craig
Reply all
Reply to author
Forward
0 new messages