[MEDITECH-L] NPR - Macro: Lengthy IF Statement

211 views
Skip to first unread message

Benoy, Marc - MGMC

unread,
Dec 4, 2007, 6:32:45 PM12/4/07
to medit...@mtusers.com
Hello all,

I am having an issue with a very long IF statement in a macro and I keep
on getting errors.

IF{/DATA["MED1]"_"."="."!(/DATA["MED2]"_"."="."!(/DATA["MED3]"_"."="."!.
.......

......... (DATA["MED26]"_"."=".") "Y"^/DATA["HMH"];"N"^/DATA["HMH"]}

I cannot keep on adding the 26 checks (checking if the medication
exists) on one line.

So initially I tried to break the line of code with a new line - but
this gives me an invalid termination error.
Then I tried Shift F6 but this amount of checks will exceed the 256
characters limit per line which leads to still broken line code
generating the same error.

Am I missing something or do I have to create many smaller IF statements
that lead to a final aggregate check?

Thanks,

Marc

Marc Benoy RN, MS, MBA
Manager of Clinical Informatics

CHW, AZ - East Valley Market
475 S. Dobson Road
Chandler, AZ 85224
(480)728.3068
Marc....@CHW.edu

Allen, Brian

unread,
Dec 5, 2007, 7:57:25 AM12/5/07
to Benoy, Marc - MGMC, medit...@mtusers.com
Your missing the second quote within the subscript of your /DATA and
some of your close parenthesis are missing too...

Should look something like... (couldn't fix/verify MED4 through
MED25)...

IF{/DATA["MED1"]_"."="."!(/DATA["MED2"]_"."=".")!(/DATA["MED3"]_"."="."!
.
.......

......... (DATA["MED26"]_"."=".") "Y"^/DATA["HMH"];"N"^/DATA["HMH"]}

Thanks,
Brian

Hello all,

Thanks,

Marc

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email and any files transmitted with it are confidential, and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error contact the Help Desk for Cape Cod Healthcare.

Help...@CapeCodHealth.org

Ganesh Seshadri

unread,
Dec 5, 2007, 8:34:11 AM12/5/07
to Benoy, Marc - MGMC, medit...@mtusers.com
firstly, i think you have a typo with the quote - /DATA["MEDn]" probably should be /DATA["MEDn"].
my first thought would be that if you have a long expression with of the same form, use a loop.
eg. instead of having variables /DATA["MED1"], ... /DATA["MED26"], make it an array /DATA[1] TO /DATA[26] so that you can test the value of the entire set in one loop.
eg. ""^/INDEX^/NULL.FLAG,
DO{@Add(1,/INDEX)'>26 IF{/DATA[/INDEX];1^/NULL.FLAG}},
after running this, if any element of /DATA[] is "", then /NULL.FLAG is set; if all elements of /DATA[] have some value, the null flag is not set.
other ways of checking for nill values are to & all the variables
ie, IF{/DATA[1]&/DATA[2]&/DATA[3] "ALL HAVE VALUE";"NILL PRESENT"}
or to use the form that you did: IF{/DATA[1]_.=.!(/DATA[2]_.=.) "NILL PRESENT";"NO NILLS"}

ganesh seshadri, indiana regional


-----Original Message-----
From: meditech-...@mtusers.com
[mailto:meditech-...@mtusers.com]On Behalf Of Benoy, Marc - MGMC
Sent: Tuesday, December 04, 2007 6:33 PM
To: medit...@mtusers.com
Subject: [MEDITECH-L] NPR - Macro: Lengthy IF Statement

Curtiss, John L

unread,
Dec 5, 2007, 9:19:11 AM12/5/07
to Curtiss, John L, Benoy, Marc - MGMC, medit...@mtusers.com
Oops, two extra }'s. Change the last line of the IF statmenet to
DATA["MED26]"_"."="." "Y";"N"}^/DATA["HMH"];"N"^/DATA["HMH"]

John Curtiss
Hutchinson Area Health Care
1095 Highway 15 South
Hutchinson, MN 55350

320-234-4967
320-234-5060 (fax)
jcur...@hahc-mn.org

-----Original Message-----
From: meditech-...@mtusers.com
[mailto:meditech-...@mtusers.com] On Behalf Of Curtiss, John L
Sent: Wednesday, December 05, 2007 8:11 AM
To: Benoy, Marc - MGMC; medit...@mtusers.com
Subject: Re: [MEDITECH-L] NPR - Macro: Lengthy IF Statement


Try something like this instead:
IF{/DATA["MED1]"_"."="." "Y";
/DATA["MED2]"_"."="." "Y";
/DATA["MED3]"_"."="." "Y";
.......
DATA["MED26]"_"."=".") "Y";"N"}^/DATA["HMH"];"N"^/DATA["HMH"]}

This way you don't need to worry about the length. If any statement
evaluates true then a "Y" is returned, if no statements evaluate true,
the "N" evaluates true because its not nil and the "N" is returned.

Or even better yet, put your med list in a group response and then write
an IF statement:

CS:

IF{&(G)GGL["YOURGROUPRESONSENAME]E[THEMEDBEINGEVALUATED]
"Y";"N"}^/DATA["HMH"];"N"^/DATA["HMH"]

(The above is all on line)

Magic:
IF{/GGL["YOURGROUPRESONSENAME]E[THEMEDBEINGEVALUATED]
"Y";"N"}^/DATA["HMH"];"N"^/DATA["HMH"]

If the med is in the group response its true, thus returns a "Y"
otherwise its false and returns a "N".

John Curtiss
Hutchinson Area Health Care
1095 Highway 15 South
Hutchinson, MN 55350

320-234-4967
320-234-5060 (fax)
jcur...@hahc-mn.org



-----Original Message-----
From: meditech-...@mtusers.com
[mailto:meditech-...@mtusers.com] On Behalf Of Benoy, Marc - MGMC
Sent: Tuesday, December 04, 2007 5:33 PM
To: medit...@mtusers.com
Subject: [MEDITECH-L] NPR - Macro: Lengthy IF Statement

Curtiss, John L

unread,
Dec 5, 2007, 9:10:51 AM12/5/07
to Benoy, Marc - MGMC, medit...@mtusers.com

CS:

Robert White

unread,
Dec 5, 2007, 9:38:41 AM12/5/07
to Marc - MGMC Benoy, medit...@mtusers.com
try a loop:

""^XX^OK,DO{XX+1^XX<27 IF{/DATA["MED"_XX] 1^OK,99^XX}},OK

>>> <meditech-...@mtusers.com> 12/05/07 9:10 AM >>>


Try something like this instead:
IF{/DATA["MED1]"_"."="." "Y";
/DATA["MED2]"_"."="." "Y";
/DATA["MED3]"_"."="." "Y";

.........

CS:


Hello all,

........... (DATA["MED26]"_"."=".") "Y"^/DATA["HMH"];"N"^/DATA["HMH"]}

I cannot keep on adding the 26 checks (checking if the medication
exists) on one line.

So initially I tried to break the line of code with a new line - but
this gives me an invalid termination error.
Then I tried Shift F6 but this amount of checks will exceed the 256
characters limit per line which leads to still broken line code
generating the same error.

Am I missing something or do I have to create many smaller IF statements
that lead to a final aggregate check?

Thanks,

Marc

Marc Benoy RN, MS, MBA
Manager of Clinical Informatics

CHW, AZ - East Valley Market
475 S. Dobson Road
Chandler, AZ 85224
(480)728.3068
Marc....@CHW.edu

Disclaimer: The information in this message is confidential. If you are not the intended recipient, do not disclose, copy, or distribute this message, and please immediately contact the sender.

Gord Dowling

unread,
Dec 5, 2007, 9:24:08 AM12/5/07
to Benoy, Marc - MGMC, medit...@mtusers.com
Hi Marc,
Some small errors in your example. Likely a cut and paste typo.

IF{/DATA["MED1]"_"."="."!(/DATA["MED2]"_"."="."!(/DATA["MED3]"_"."="."!.

^^ ERR ^^ ERR
^^ERR

You could do it this way

"N"^/DATA["HMH"],
IF{L(/DATA["MED1"])<1 " Y";/DATA["HMH"]}^/DATA["HMH"],
IF{L(/DATA["MED2"])<1 "Y";/DATA["HMH"]}^/DATA["HMH"],
IF{L(/DATA["MED3"])<1 "Y";/DATA["HMH"]}^/DATA["HMH"],
IF{L(/DATA["MED4"])<1 "Y";/DATA["HMH"]}^/DATA["HMH"],
IF{L(/DATA["MED5"])<1 "Y";/DATA["HMH"]}^/DATA["HMH"],
IF{L(/DATA["MED6"])<1 "Y";/DATA["HMH"]}^/DATA["HMH"],
IF{L(/DATA["MED7"])<1 "Y";/DATA["HMH"]}^/DATA["HMH"],
IF{L(/DATA["MED8"])<1 "Y";/DATA["HMH"]}^/DATA["HMH"],
IF{L(/DATA["MED9"])<1 "Y";/DATA["HMH"]}^/DATA["HMH"],
IF{L(/DATA["MED10"])<1 "Y";/DATA["HMH"]}^/DATA["HMH"],
IF{L(/DATA["MED11"])<1 "Y";/DATA["HMH"]}^/DATA["HMH"],
IF{L(/DATA["MED12"])<1 "Y";/DATA["HMH"]}^/DATA["HMH"],
IF{L(/DATA["MED13"])<1 "Y";/DATA["HMH"]}^/DATA["HMH"],
Ad nausem

Or
""^/CNT,"N"^/DATA["HMH"],
DO{1+/CNT^/CNT<27 IF{L(/DATA["MED"_/CNT])<1
"Y";/DATA["HMH"]}^/DATA["HMH"]},

Gord

Gordon Dowling
gord.d...@hpha.ca
Applications Analyst
Huron Perth Healthcare Alliance
Stratford, ON N5A 2Y6

(519)272-8210 ext2268

Jeanette Ahrens

unread,
Dec 5, 2007, 9:53:27 AM12/5/07
to medit...@mtusers.com
Hello,

I had hoped to copy a couple of standard reports for editing, but the
macros give a translation error. This may be too complicated for anyone
to explain in this forum (or too global due to high number of errors),
but if anyone knows what the error code means and what I should first
look at to address it I would appreciate your help.

Syntax - K[, $K[, F[, V[, O[, X[, $SEG, $DIR - not allowed! (I get
this error on two reports--sounds like nothing is allowed ;)

Thanks for your help,

Jeanette Ahrens, RN
MIS Clinical Support
DeSoto Memorial Hospital
Arcadia, FL

"The information contained in this message may be privileged and/or
confidential and protected from disclosure. If the reader of this
message is not the intended recipient, you are hereby notified that any
dissemination, distribution or copying of this document is strictly
prohibited. If you have received this communication in error, please
notify us immediately by replying to this message and deleting the
material from any computer."


Ganesh Seshadri

unread,
Dec 5, 2007, 10:26:53 AM12/5/07
to medit...@mtusers.com
meditech tends to use the kill command in many of its reports to set arrays to "". this is where I would start to see the initialized report is salvagable. you can generally rewrite the logic quite easily for these cases. eg. to kill an array called /DATA, use:
""^/SUBSCRIPT,
DO{>/DATA[/SUBSCRIPT]^/SUBSCRIPT ""^/DATA[/SUBSCRIPT]}

there are alternatives for opens and segs that you may be find in some of the reports posted on this list where the syntax checker is tricked into not recognizing statements as being these commands. in many cases, you can replace these using %Z.rw.fragment() generally at the expense of performance, but without having to game the syntax checker. for npr reports out of meditech data (rather than what you've created in your own segment), the chances are you dont need to use some of the restricted commands such as Free.

Lawrence, Mitchell

unread,
Dec 4, 2007, 6:56:55 PM12/4/07
to Lawrence, Mitchell, Benoy, Marc - MGMC, medit...@mtusers.com
Sorry, I forgot the looping operator (+). The code should be this when
checking for value:

"N"^FOUND,

"MED"^SUB,

DO{+/DATA[SUB]^SUB'>"MED26"&(FOUND="N") IF{/DATA[SUB] "Y"^FOUND}},

FOUND^/DATA["HMH"]

The code should be this when checking for NIL:

"N"^FOUND,

"MED"^SUB,

DO{+/DATA[SUB]^SUB'>"MED26"&(FOUND="N") IF{@Not(/DATA[SUB]) "Y"^FOUND}},

FOUND^/DATA["HMH"]

Thank you,

Mitch Lawrence

Lead Applications Analyst

Technical Support - NPR/Automation

CHRISTUS Information Management

*: Mitchell...@CHRISTUSHealth.org
<mailto:Mitchell...@CHRISTUSHealth.org>

Send a "thank you
<http://intranet.christushealth.org/spiritBuck/Default.asp> " to
someone!

________________________________

From: Lawrence, Mitchell
Sent: Tuesday, December 04, 2007 5:54 PM
To: 'Benoy, Marc - MGMC'; medit...@mtusers.com

Subject: RE: [MEDITECH-L] NPR - Macro: Lengthy IF Statement

Why not just do a DO loop instead?

"N"^FOUND,

"MED"^SUB,

DO{/DATA[SUB]^SUB'>"MED26"&(FOUND="N") IF{/DATA[SUB] "Y"^FOUND}},

FOUND^/DATA["HMH"]

This will loop through /DATA["MEDx"] where x = 1 through 26. If any of
them have a value, it will kick out of the loop on the first one it
finds and put a "Y" into /DATA["HMH"].

If you would rather have it check for empty /DATA["MEDx"], then do the
following (your question is contradictory. You are checking for NIL
(/DATA["MED1"]_"."=".") but say you are checking for a value):

DO{/DATA[SUB]^SUB'>"MED26"&(FOUND="N") IF{@Not(/DATA[SUB]) "Y"^FOUND}},

This will kick out of the loop on the first /DATA[SUB] that doesn't have
a value.

Thank you,

Mitch Lawrence

Lead Applications Analyst

Technical Support - NPR/Automation

CHRISTUS Information Management

(tm): Mitchell...@CHRISTUSHealth.org

Send a "thank you" to someone!

-----Original Message-----
From: meditech-...@mtusers.com
[mailto:meditech-...@mtusers.com] On Behalf Of Benoy, Marc - MGMC
Sent: Tuesday, December 04, 2007 5:33 PM
To: medit...@mtusers.com
Subject: [MEDITECH-L] NPR - Macro: Lengthy IF Statement

image001.jpg

Lawrence, Mitchell

unread,
Dec 4, 2007, 6:54:06 PM12/4/07
to Benoy, Marc - MGMC, medit...@mtusers.com

"N"^FOUND,

"MED"^SUB,

FOUND^/DATA["HMH"]

Thank you,

Mitch Lawrence

Lead Applications Analyst

Technical Support - NPR/Automation

CHRISTUS Information Management

(tm): Mitchell...@CHRISTUSHealth.org

Lawrence, Mitchell

unread,
Dec 4, 2007, 7:00:27 PM12/4/07
to Lawrence, Mitchell, Benoy, Marc - MGMC, medit...@mtusers.com
And actually, now that I think of it, /DATA["MEDx"] will not exist if it
doesn't have a value, therefore, the following code could be used
instead.

Checking for a value:

"N"^FOUND,

"MED"^SUB,

DO{/DATA[SUB]^SUB'>"MED26" "Y"^FOUND},

FOUND^/DATA["HMH"]

Checking for NIL:

"Y"^FOUND,

"MED"^SUB,

DO{/DATA[SUB]^SUB'>"MED26" "N"^FOUND},

image002.jpg
image003.jpg

Jeanette Ahrens

unread,
Dec 5, 2007, 11:38:41 AM12/5/07
to Ganesh Seshadri, medit...@mtusers.com
Hello Ganesh,

I looked at this and replaced several @KILL commands with your
example. There is at least one that is part of an IF statement, so not
sure how to go about this.

IF{'BCHG @Kill(/MV["D",RB]),@Kill(/MV["D",RB_"*"]),@Sub(1,LCNT)},
""^RB,1}

I am in way over my head here; this may be obvious to you NPR Gurus,
but to us mere mortals it is pretty overwhelming. This is from the
macro of a Meditech standard statement.

Thanks for your help,
Jeanette


>>> "Ganesh Seshadri" <gses...@indianarmc.org> 12/5/2007 10:26:53 AM

Robert White

unread,
Dec 5, 2007, 12:30:22 PM12/5/07
to Ganesh Seshadri, medit...@mtusers.com, meditech-...@mtusers.com
Try this:

IF{'BCHG ""^XX,
DO{>/MV["D",RB,XX]^XX ""^/MV["D",RB,XX]},
DO{>/MV["D",RB_"*",XX]^XX ""^/MV["D",RB_"*",XX]},
@Sub(1,LCNT)},
""^RB,1}

But there's probably going to be more problems with the sytax checker and the copied code. Copyin from the standard to a zcus is usually useful only for the most simple reports. Otherwise, you're better off starting from scratch.

>>> <meditech-...@mtusers.com> 12/05/07 11:38 AM >>>
Hello Ganesh,


Hello,

Thanks for your help,

Disclaimer: The information in this message is confidential. If you are not the intended recipient, do not disclose, copy, or distribute this message, and please immediately contact the sender.

Jeanette Ahrens

unread,
Dec 5, 2007, 2:09:26 PM12/5/07
to olesh...@gmail.com, Ganesh Seshadri, medit...@mtusers.com, Robert White
Thanks Guys. I'll try your suggestions and also consider that I may not
be able to initialize this report from the standard. I do appreciate
your taking the time to respond and give me your honest advice. In the
long run, you probably saved me a lot of time and grief. But, I'll try
these suggestions first ;) Just in case I get lucky.

>>> "Robert White" <Whi...@nehealth.com> 12/5/2007 12:30:22 PM >>>

Reply all
Reply to author
Forward
0 new messages