Testing for presence of a segment

183 views
Skip to first unread message

Marc Lang

unread,
Sep 4, 2012, 4:31:03 AM9/4/12
to InterSystems: Ensemble in Healthcare

99% sure I've done this before and it worked...

In a source message the NK1 is repeating, and also optional.
In a DTL we need to work out if it exists of not.

I thought we could do something like:


<if condition='source.{NK1(*)}=0'>
<true>

</true>
<false>

</false>
</if>

However, when compiling this I get:

Saving DTL Diagram 'IMD.Transforms.TrakA01toIMDA01.DTL'...
Saved successfully.

Compilation started on 09/04/2012 09:27:15 with qualifiers 'cuk /checkuptodate=expandedonly'
Compiling document 'IMD.Transforms.TrakA01toIMDA01.DTL'
Compiling class IMD.Transforms.TrakA01toIMDA01
Compiling routine IMD.Transforms.TrakA01toIMDA01.1
IMD.Transforms.TrakA01toIMDA01.1.INT(15) ERROR #8: <NOLINE> : '$ZT="Trap",(tSC,tSCTrans)=1' : Offset:10 [zTransform+1^IMD.Transforms.TrakA01toIMDA01.1]
 TEXT: Set $ZT="Trap",(tSC,tSCTrans)=1 Do {
IMD.Transforms.TrakA01toIMDA01.1.INT(52) ERROR #1054: Invalid expression : '(source.GetValueAt("NK1("_(*)_")"))' : Offset:32 [zTransform+38^IMD.Transforms.TrakA01toIMDA01.1]
 TEXT: If (source.GetValueAt("NK1("_(*)_")")) {
IMD.Transforms.TrakA01toIMDA01.1.INT(54) ERROR #1053: Missing WHILE : '}' : Offset:2 [zTransform+40^IMD.Transforms.TrakA01toIMDA01.1]
 TEXT: } Else {
IMD.Transforms.TrakA01toIMDA01.1.INT(57) ERROR #1025: Expected end of line : '}' : Offset:2 [zTransform+43^IMD.Transforms.TrakA01toIMDA01.1]
 TEXT: } While 0
IMD.Transforms.TrakA01toIMDA01.1.INT(62) ERROR #1026: Invalid command : 'Exit }' : Offset:101 [Trap^IMD.Transforms.TrakA01toIMDA01.1]
 TEXT: Trap Set $ZT="", tSC=##class(Ens.Util.Error).EnsSystemError($zobjclass($this),"Transform") Goto Exit }
Detected 5 errors during compilation in 0.136s.


So looks like it doesn't like the asterisk?
I was sure I've had that working in the past.

Anthony Beukes

unread,
Sep 4, 2012, 4:46:24 AM9/4/12
to ensemble-in...@googlegroups.com

Try placing double quotes around the *:

<if condition='source.{NK1("*")}=0'>

--
You received this message because you are subscribed to the Google Groups "InterSystems: Ensemble in Healthcare Community" group.
To post to this group, send email to Ensemble-in...@googlegroups.com
To unsubscribe from this group, send email to Ensemble-in-Healt...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Ensemble-in-Healthcare?hl=en

Marc Lang

unread,
Sep 4, 2012, 7:16:10 AM9/4/12
to ensemble-in...@googlegroups.com
That worked, thanks!

Ted Peck

unread,
Sep 5, 2012, 2:04:06 PM9/5/12
to ensemble-in...@googlegroups.com, Marc Lang
I think it would also work with
<if condition='source.{NK1.*}=0'>

However these 2 forms can give different results for counts of group items. The form .* returns the count of all instances of the named item and their children, while the form (*) returns the count of all repetitions of the named item itself, which can be a different number.  For example using our popular sample message XYZ1.dat, I get these two results:

ENSDEMO>w h.GetValueAt("IN1grp(*)",,.sc)
3
ENSDEMO>w h.GetValueAt("IN1grp.*",,.sc)
6

That's because in this sample message each instance of IN1grp contains an IN1 and an IN2.

Ted

Marc Lang

unread,
Sep 10, 2012, 7:54:06 AM9/10/12
to InterSystems: Ensemble in Healthcare
This works good for repeating segments - but how to test if a single non-repeating segment exists?

the count always returns 0?

Peter Hunter

unread,
Sep 12, 2012, 6:42:39 PM9/12/12
to Ensemble-in...@googlegroups.com, InterSystems: Ensemble in Healthcare
Try this for non-repeating segments
<if condition='source.{PV1}&apos;=""'>
That worked, thanks!

To post to this group, send email to ...@googlegroups.com
To unsubscribe from this group, send email to Ensemble-in-Healthcare-unsub...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "InterSystems: Ensemble in Healthcare Community" group.
To post to this group, send email to Ensemble-in...@googlegroups.com
To unsubscribe from this group, send email to Ensemble-in-Healthcare-unsub...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "InterSystems: Ensemble in Healthcare Community" group.
To post to this group, send email to Ensemble-in...@googlegroups.com
To unsubscribe from this group, send email to Ensemble-in-Healthcare-unsub...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages