Well, that's no ordinary rabbit!

Things to remember:

DFT attributes are not evaluated if IFE is nil ("")

FCLx attributes are only evaluated for new, non nil responses

IFE attributes control whether the cursor stops at the query.
If IFE evaluates to nil the cursor will skip the query.
If IFE evaluates to any non-nil value the cursor will stop at the query.

Responses to queries are stored in the temp structure /[ANS%0,"QUERY"]|0 while the CDS is being edited.
Responses to multiple and E type queries have extra subscripts in the format /[ANS%0,"QUERY","M",x]|0 where x is the response line number.

Email sent from FCLx attributes is sent at the time the attribute is evaluated, not after the screen is filed.

The Basics

Write data to the screen without saving.
Note: R and S are the variables that stores the current cursor row and column.

P(R,S,DATA)^#

Save data as query response

DATA^/[ANS%0,"QUERY"]|0

Write data to screen and save

P(R,S,DATA^/[ANS%O,"QUERY"]|0)^#

Defaulting Responses


NOTE: DFT="RESPONSE" combined with IFE="" will not work since DFT attributes are not evaluated if IFE is nil.

Default a response and
allow user to change it.

DFT="RESPONSE"
or
IFE=P(R,S,"RESPONSE"^/[ANS%0,"QUERY"]|0)^#
or
REQ=P(R,S,"RESPONSE"^/[ANS%0,"QUERY"]|0)^#

Default a response and do
not allow the user to change it.

IFE=P(R,S,"RESPONSE"^/[ANS%0,"QUERY"]|0)^#,""

Conditionally default a future date
    tomorrow's date if SUN-THU
    Monday's date if FRI-SUN

DFT=IF{%Z.day.from.date(/.DAT)^DTE=6 %Z.date.add(/.DAT,3);
DFT=DTE=7 %Z.date.add(/.DAT,2)}

Default based on a previous response.
   QUERYC is current query
   QUERYP is previous query

DFT=IF{[ANS,"QUERYP"]|0="Y" "RESPONSE 1";"RESPONSE 2"}
or
IFE=P(R,S,IF{[ANS,"QUERYP"]|0="Y" "RESPONSE 1";
IFE="RESPONSE 2"}^/[ANS%0,"QUERYC"]|0)^#

Defaulting Responses In a Multiple Type Query

DFT attributes are not designed to handle multiple responses. Maybe in a future release there will be a DFTL attribute which defaults a list of responses. Until then you will need to do it the hard way - with lots of code. As in other attributes that default a response you need to store the responses in /[ANS%0... and also display them on screen. You do not want to display more responses than the lines that the multiple is set to display. If you have a long list of responses to default you can store them in a group response dictionary to save room in the attribute.

Defaulting a short list - 3 responses, query set to display 4 lines. The "1" at the end of line 1 and line 4 allows the user to add more responses.

IFE=IF{/[ANS%0,/S.LAST.QUERY,"M",1]|0 1;
IFE=P(R,S,"RESPONSE1"^/[ANS%0,"QUERY","M",1]|0)^#,
IFE=P(R+1,S,"RESPONSE3"^/[ANS%0,"QUERY","M",2]|0)^#,
IFE=P(R+2,S,"RESPONSE3"^/[ANS%0,"QUERY","M",3]|0)^#,1}


Defaulting a short list - 3 responses with query attribute set to display 2 lines. Note the 3rd response gets stored in /[ANS but is not written to the screen.

IFE=IF{/[ANS%0,/S.LAST.QUERY,"M",1]|0 1;
IFE=P(R,S,"RESPONSE1"^/[ANS%0,"QUERY","M",1]|0)^#,
IFE=P(R+1,S,"RESPONSE3"^/[ANS%0,"QUERY","M",2]|0)^#,
IFE="RESPONSE3"^/[ANS%0,"QUERY","M",3]|0,1} 


Defaulting a longer list stored in a group response dictionary called "MULT.RESP" in a multiple query. Here the object is to loop thru the group response dictionary elements and store the element names as a response using the element as the multiple subscript. The group response dictionary should be set up like this

Element     Element Name
1              RESPONSE1
2              RESPONSE2
3              RESPONSE3
etc           etc

The elements should start with 1 and not skip any numbers.

IFE=IF{/[ANS%0,"QUERY"^LQ,"M",1]|0 1;
IFE=\GGV[LQ]|20^QL,""^XX,
IFE=DO{+\GGL["MULT.RESP,"E",XX]^XX
IFE= \GGL["MULT.RESP,"E",XX]|0^YY,
IFE=IF{XX'>QL P(R+XX-1,S,YY^/[ANS%0,LQ,"M",XX]|0)^#;
IFE=YY^/[ANS%0,LQ,"M",XX]|0}},1} 

Defaulting canned text in a multiple query can also be done. You will need to vary the attribute based on the application where the canned text is stored but the format should be the same. Keep in mind that the canned text dictionaries vary in the line length. Both OE and NUR allow text lines greater than 75 characters and so may have lines longer than allowed in a query response. I have made use of several variables and referenced the physical data structure to save space. In the first line "QUERY" is stored in LQ and LQ is used from that point on. \GGV[LQ]|20 is the field in the MIS Query dictionary that holds the number of lines to display. These attributes just pull in the text. The tab stops are pulled in as plain text and will appear as [] in the query response. If you need the attribute to allow processing of the tab stops see my Pulling NUR Canned Text web page. Do not try to pull OE canned text into an NUR CDS or NUR canned text into an OE CDS.

The first version pulls the NUR canned text CANNED into an NUR CDS. &NCT is the physical structure of the NUR canned text dictionary.

IFE=IF{/[ANS%0,"QUERY"^LQ,"M",1]|0 1;
IFE=""^XX,
IFE=DO{+&NCT["CANNED,"T",XX]^XX &NCT["CANNED,"T",XX]^YY,
IFE=IF{XX'>\GGV[LQ]|20 P(R+XX-1,S,YY^/[ANS%0,LQ,"M",XX]|0)^#;
IFE=YY^/[ANS%0,LQ,"M",XX]|0}},1}

Similar code is used for pulling in OE canned text into an OE CDS. The canned text dictionary structure is &PCT instead of &NCT and there is an extra subscript for department. This attribute pulls in the canned text CANNED for department EKG into an OE CDS.

IFE=IF{/[ANS%0,"QUERY"^LQ,"M",1]|0 1;
IFE=""^XX,
IFE=DO{+&PCT["EKG","CANNED,"T",XX]^XX
IFE= &PCT["EKG","CANNED,"T",XX]^YY,
IFE=IF{XX'>\GGV[LQ]|20 P(R+XX-1,S,YY^/[ANS%0,LQ,"M",XX]|0)^#;
IFE=YY^/[ANS%0,LQ,"M",XX]|0}},1}

Requiring Responses

Require a response

REQ=1

Immediately require a response

REQI=1

Require if patient location is 1SO

REQ=@p.ADM.PAT.location="1SO"

Immediately require is patient location is 1SO

REQI=@p.ADM.PAT.location="1SO"

Require if weight is over 150 lbs

REQ=@p.OE.PAT.wt.in.lbs>150
or
REQ=@p.ADM.PAT.wt.in.lbs>150
or
REQ=@p.PHA.PAT.pha.wt.in.lbs>150

Immediately require if weight is over 150 lbs

REQI=@p.OE.PAT.wt.in.lbs>150
or
REQI=@p.ADM.PAT.wt.in.lbs>150
or
REQI=@p.PHA.PAT.pha.wt.in.lbs>150

Require if user ID starts with "NSG"

REQ=@.user$3="NSG"


Immediately require if user ID starts with "NSG"

REQI=@.user$3="NSG"


Require a response only MON-FRI

REQ=%Z.day.from.date(@.today)>1<7
or
REQ=%Z.day.from.date(@.today)'=1'=7


Immediately require a response only MON-FRI

REQI=%Z.day.from.date(@.today)>1<7
or
REQI=%Z.day.from.date(@.today)'=1'=7


Require a response if attending physician is DRXXX

REQ=@p.ADM.PAT.attend.doctor="DRXXX"


Immediately require a response if attending physician is DRXXX

REQI=@p.ADM.PAT.attend.doctor="DRXXX"


Require if a previous query ("QUERYP") is blank.

REQ=[ANS,"QUERYP"]|0_.=.
or
REQ=IF{[ANS,"QUERYP"]|0 "";1}
or
REQ='[ANS,"QUERYP"]|0


Immediately require a response if a previous query ("QUERYP") is blank

REQI=[ANS,"QUERYP"]|0_.=.
or
REQI=IF{[ANS,"QUERYP"]|0 "";1}
or
REQI='[ANS,"QUERYP"]|0


Require a response if a previous query ("QUERYP") has been answered.

REQ=[ANS,"QUERYP"]|0


Immediately require a response if a previous query ("QUERYP") has been answered.

REQI=[ANS,"QUERYP"]|0


Skipping Queries

Skip a query

IFE=""

Skip if patient's location is 1SO

IFE=IF{@ADM.PAT.location="1SO" "";1}

Skip if patient weight is over 150 lbs

IFE=IF{@OE.PAT.wt.in.lbs>150 "";1}

Skip if user ID starts with "SCH"

IFE=IF{@.user$3'="SCH" "";1}

Skip on Sat and Sun

IFE=IF{%Z.day.from.date(@.today)>1<7 1;""}
or
IFE=IF{%Z.day.from.date(@.today)'=1'=7 1;""}

Stop at a query based on response to query "ACCESS" in MIS User dictionary.

IFE=\GU[@.user]CD["ACCESS"]|0="Y"

Skip if previous query is blank -  previous query is "QUERYP"

IFE=[ANS,"QUERYP"]|0
or
IFE=IF{[ANS,"QUERYP]|0 1;""}

Skip if previous query is not blank - previous query is "QUERYP"

IFE=IF{[ANS,"QUERYP"]|0 "";1}

Displaying Messages

Display a message before user input

IFE=@W.return("This is the message"),1

Display a message if response is "Y"

FCL1=IF{@.response="Y" @W.return("This is the message")

Display a message if response is "Y"
and primary insurance is "MED"

FCL1=IF{@.response="Y"&(*AA[/["aa"]]IO[1]|0="MED")
FCL1= @W.return("Primary Ins is MED")}

Not allow a "Y" response if primary
insurance is "MED"

FCL1=@.response="Y"&(*AA[/["aa"]]IO[1]|0="MED")
FCL1A=@W.err("Primary Ins is MED")

Advanced Attribute
Sending an email from an attribute

Send an email to user "ADMXXX" from an OE procedure query if response is "Y"

Note: message is stored in /MSG
Message consists of patient name,
location, and OE procedure name

Note: email is sent when FCL is evaluated,not when order is filed.
Also see the Emailing MessagesPage

FCL1=IF{@.response="Y" @ADM.PAT.name^/MSG[1],
FCL1=@ADM.PAT.location^/MSG[2],
FCL1=@procedure.name^/MSG[3],
FCL1=%MIS.OA.MSG.auto("",Q(^/MSG,"ADMXXX")}

Advanced Attribute
Defaulting a response from a previous OE order

Default the most recent response to the same query for the same category and procedure. This is only for defaulting a previous OE order query response to the same query on a new OE order.

Requires a macro to be created

DFT=%OE.ORD.zcus.tjt.dft.M.prev.resp(/["aa"],"QUERY")

Macro code for this attribute

A^PT,
B^QRY,
""^SD^RESP,
DO{-?POE[PT,SD]^SD&'RESP ""^PO,
DO{-?POE[PT,SD,PO]^PO&'RESP @CHECK.CAT.PROC}},
RESP;

CHECK.CAT.PROC
IF{:PO[PO]|5'=/["pc"];
:PO[PO]|6'=/["pp"];
:PO[PO]R[QRY]|0^RESP}

Advanced Attribute
Displaying a multi line message in a pop-up window

Display a multi-line message before
user input.

Requires a macro to be created.

NOTE: limit of 240 chars / attribute

IFE=IF{DONE;
IFE="This is line 1 of the text you want to display."^M1,
IFE="This is line 1 of the text you want to display."^M2,
IFE="This is line 1 of the text you want to display."^M3,
IFE=%OE.ORD.zcus.tjt.dft.M.msg(M1,M2,M3,"",4),1^DONE1},1

Macro code for this attribute

;- A - first line of message
;- B - second line of message
;- C - third line of message
;- D - text color for NON-Gui displays
;- E - message box icon for GUI displays
; ---- 1=Err 2=Question 3=Warning 4=Info 5=Windows
A^MSG,
IF{/.GUI 19;
IF{D;8}}^CLR,
IF{C 2;B 1;0}+7^HT,
L(A)!(L(B))!(L(C))^WD,
WD+2_"C"^WDC,
WD+2_"L"^WDL,
IF{/.GUI @GUI.MESSAGE;
@NEW.WINDOW,
H(3),
#0,
@Window.close("")^#},
END;

NEW.WINDOW
@Window.centered(HT,WD+2,CLR)^#,
IF{E=1 I("!! ERROR !!":WDC)N^#;
E=2 I("?? QUESTION ??":WDC)N^#;
E=3 I("!! WARNING !!":WDC)N^#;
I("!! PLEASE NOTE !!":WDC)N^#},
I(D(4,0))N^#,
I("")N^#,
I(MSG:WDL)N^#,
IF{B I(B:WDL)N^#},
IF{C I(C:WDL)N^#},
I("")N^#,
I(D(4,0))N^#,
I("Press << ENTER>> to continue":WDC)^#

GUI.MESSAGE
".WO"^WO,
A^/WIN.MSG[1]^/[WO],
IF{B B^/WIN.MSG[2]},
IF{C C^/WIN.MSG[3]},
E^/WIN.ICON,
"Message for "_%Z.name.inversion(@MIS.USER.name[/.USR])^/WIN.TITLE,
%Z.w.macro(1,0)

Advanced Attribute
Stop at a query and require a response based on a previous multiple response

Stop at a query and require a response based on one of the reponses to a previous multiple query ("QUERYM") being "OTHER"

IFE=IF{""^XX^ZZ,DO{+/[ANS%0,"QUERYM","M",XX]^XX
IFE= IF{/[ANS%0,"QUERYM","M",XX]|0="OTHER" 1^ZZ}},ZZ;ZZ} REQ=IF{""^XX,DO{+/[ANS%0,"QUERYM","M",XX]^XX
REQ= IF{/[ANS%0,"QUERYM","M",XX]|0="OTHER" 1^ZZ}},ZZ;ZZ}

Conversion Attributes

 Lbs and Ozs to Kgs

Formula - LB*16+OZ/35.274
In the second method the cursor will stop at the query if both the Lbs and Ozs query are blank but skip it otherwise.

IFE=P(R,S,IF{[ANS,"LB_QRY"]|0^LB!([ANS,"OZ_QRY"]|0^OZ)
IFE= LB*16+OZ:5D/35.274:2D}^/[ANS%0,"KG_QRY"]|0)^#

or

IFE=IF{[ANS,"LB_QRY"]|0^LB!([ANS,"OZ_QRY"]|0^OZ)
IFE= P(R,S,LB*16+OZ:5D/35.274:2D^/[ANS%0,"KG_QRY"]|0)^#,
IFE="";1}

 Ft and In to Cm

Formula - FT*12+IN*2.54

IFE=P(R,S,IF{[ANS,"FT_QRY"]|0^FT!([ANS,"IN_QRY"]|0^IN)
IFE= FT*12+IN*2.54}^/[ANS%0,"CM_QRY"]|0)^#


Other Magic Pages

CDS Attributes Emailing Messages Emailing Scheduled Reports
@W. prompts String Manipulation NPR Viewer
Text Edit/View Attribute Meds in an NUR CDS NUI Desktop Icons
Field Attributes Lab results in a CDS Ultimate Message Box
Display Message Attributes Run NPR Report Attribute Multiple Query Checklist
NUR Canned Text in Query Mousetributes LAB TEST VIEW GROUP
OA Msg from PHA Rule FTP Standard Report HTML Pt Master Logs
PCI NPR Report


Don't see what you need?  Visit one of these other sites

Iatric Systems web site
Attributes
NPR tips
NPR reports
Magic and C/S Products
ITNurse.net
Hosted by Daniel Davis
Resources for the IT Nurse
Articles and Discussion Forum
Debbie Kelly web site
Attributes
Meditech tips
Nursing Informatics
Debbie Bate-Travis web site
Attributes
Links to other attribute sites
Links to Nursing Informatics sites
Magic NPR Report Writing
Blogged by John Sharpe
NPR Report Writing Tips

or email me your request (tomt at thomast357.com).