Written by

Lead Technical Analyst at Missouri Health Connection
Question Scott Beeson · Jan 21, 2016

Not sure why I'm getting this error

Here is the function I'm writing:

/// Returns the participant code based on MSH-4
ClassMethod getParticipant(iSendingFacility As %String) As %String [ Final ]
{
   set = $PIECE(iSendingFacility,"^",1)
   set = $PIECE(iSendingFacility,"^",2)
   set sc1 = Lookup("ParticipantCodeMap",a)
   if sc1 = "" {
      set sc1 = Lookup("ParticipantCodeMap",b)
   }
   q sc1
}

For some reason when I try to run it I get the following error:

 set sc1 = Lookup("ParticipantCodeMap",a)
 ^
<UNDEFINED> 

I tried adding the the default parameter in case it's not finding it but it didn't help.  What am I missing?

Comments

Scott Beeson · Jan 21, 2016

I must be using the Lookup command wrong.

PHR>Lookup("ParticipantCodeMap","1083601330")
LOOKUP("ParticipantCodeMap","1083601330")
^
<SYNTAX>
0
Scott Beeson · Jan 21, 2016

I figured it out, I needed to use ..Lookup(), of course.

0
Dmitry Maslennikov · Jan 21, 2016

I guess that you writing an function for rule.  And your class where you do it extends  Ens.Util.FunctionSet  where Lookup is located. Lookup is a method and you should call it as a method, now it is as variable.

 
/// Returns the participant code based on MSH-4
ClassMethod getParticipant(iSendingFacility As %String) As %String [ Final ]
{
   set = $PIECE(iSendingFacility,"^",1)
   set = $PIECE(iSendingFacility,"^",2)
   set sc1 = ..Lookup("ParticipantCodeMap",a)
   if sc1 = "" {
      set sc1 = ..Lookup("ParticipantCodeMap",b)
   }
   sc1
}
 

And if you want to call it by terminal, it should be so:

 write ##class(Ens.Util.FunctionSet).Lookup("ParticipantCodeMap","1083601330")
0
Evgeny Shvarov  Oct 20, 2018 to Dmitry Maslennikov

Converted this to an answer

0