Using NOTIN and Lookup in the method
Any syntax help, i want to check different msg types and then reach out to the value in that particular segment. Here is example, i want to get SSNNumber from a method. Trying to use NOTIN, and Lookup
Class Training.RulesFunctionSet Extends Ens.Rule.FunctionSet
{
ClassMethod getEmiratesId(pHL7 As EnsLib.HL7.Message) As %String
{
SET msgType = pHL7.GetValueAt("MSH:MessageType.TriggerEvent")
IF msgType NotIn "A39,A40,O01,O11,O09,R01" {
return pHL7.GetValueAt("PID:SSNNumberPatient")}
IF msgType In "A39,A40" {
return pHL7.GetValueAt("PIDgrp(1).PID:SSNNumberPatient")}
IF msgType In Lookup("AllowsMsgTypes",HL7.{MSH:SendingFacility.NamespaceID},,) {
return pHL7.GetValueAt("PIDgrpgrp(1).PIDgrp.PID:SSNNumberPatient")}
}
}
Comments
You can use the contains operator "["
IF ",A39,A40,O01,O11,O09,R01,"'[(","_msgType_",") {
return pHL7.GetValueAt("PID:SSNNumberPatient")}
Thanks @Adrian Zeeman
How about Not Contains syntax and Lookup syntax
I'm not sure about the lookup syntax, I haven't used it.
The code that I sent is not contains. It has an apostrophe in front of the open square bracket. If you want to check if it's contained in the list it will just be a open square bracket
"NotIn" is not part of InterSystems ObjectScript. Also not "in" . This is SQL slang
Alternative to the proposal of @Adrian Zeeman you may try this construct:
if '($LF($LFS("A39,A40,O01,O11,O09,R01"),msgType) { . . . Hi Ahmad,
In the class Ens.Util.FunctionSet exists the methods In and NotIn, that's work if comma-delimited string.
To check if a value is not in a LookupTable test if the returns of method Lookup is empty.