ORWDXM1 ; SLC/KCM - Order Dialogs, Menus;04-Jun-2010 14:12;PLS
;;3.0;ORDER ENTRY/RESULTS REPORTING;**10,85,131,132,141,178,185,187,1002,1004,215,243,1010**;Dec 17, 1997;Build 47
;Modified - IHS/MSC/PLS - 5/14/2010 - Line BLDQRSP+25
; 6/04/2010 Line BLDQRSP+136
BLDQRSP(LST,ORIT,FLDS,ISIMO,ENCLOC) ; Build responses for an order
; LST=QuickLevel^ResponseID(ORIT;$H)^Dialog^Type^FormID^DGrp
; LST(n)=verify text or reject text
; ORIT= ptr to 101.41 for quick order, 100 for copy
; 1 2 3 4 5 6 7 8 11-20
; FLDS=DFN^LOC^ORNP^INPT^SEX^AGE^EVENT^SC%^^^Key Variables...
; ORIT=+ORIT: ptr to 101.41, $E(ORIT)=C: copy $E(ORIT)=X: change
; !! SHOULD CHECK for PRE-CPRS ORDERS (treat as text?)
K ^TMP("ORWDXMQ",$J)
N ORWMODE ; 0:Dialog,Quick 1:copy order 2:change order
N TEMPCAT ; patient category from DPT file
N ISXFER ; Transfer order?
N ORIMO ;If IMO(inpatient medication on outpatient)
N TEMPORIT
N ADMLOC,PATLOC,ORDLOC,LEVEL,DELAY,SCHLOC,SCHTYP
S PATLOC=$P(FLDS,U,2)
S ORDLOC=$S(ORIT["C":+$P($G(^OR(100,+$P(ORIT,"C",2),0)),U,10),1:0)
S ORIMO=$G(ISIMO)
S ORWMODE=0,ISXFER=""
S:$E(ORIT)="C" ORWMODE=1 S:$E(ORIT)="T" ORWMODE=1,ISXFER=";T" ;treat xfer as copy for now
S:$E(ORIT)="X" ORWMODE=2
S:$E(ORIT)="P" ORWMODE=3 ; IHS/CIA/DKM - Added to support med processing function
S TEMPORIT=ORIT
I ORWMODE S ORIT=$E(ORIT,2,999)
S LST(0)=""
; IHS/CIA/DKM - Modified next 2 lines
;D CHKDSBL^ORWDXM3(.LST,ORIT,ORWMODE) Q:+LST(0)=8 ;disable
;D CHKVACT^ORWDXM3(.LST,ORIT,ORWMODE,$P(FLDS,U,3)) Q:+LST(0)=8 ;action
D:ORWMODE'=3 CHKDSBL^ORWDXM3(.LST,ORIT,ORWMODE) Q:+LST(0)=8 ;disable
D:ORWMODE'=3 CHKVACT^ORWDXM3(.LST,ORIT,ORWMODE,$P(FLDS,U,3)) Q:+LST(0)=8 ;action
I ORWMODE=1 D CHKCOPY^ORWDXM3(.LST,ORIT,FLDS) Q:+LST(0)=8 ;no copy
I ORWMODE=2 D BLD4CHG^ORWDXM3(.LST,ORIT,FLDS) Q ;change
I 'ORWMODE,($P(^ORD(101.41,+ORIT,0),U,4)="D"),'($O(^DIC(9.4,"C","OR",0))[$P(^ORD(101.41,+ORIT,0),U,7)) S LST(0)="0^0^"_$$DLGINFO^ORWDXM3(ORIT,ORWMODE_ISXFER) Q
;radilogy vars
N ORIMTYPE
;blood bank vars
N ORCOMP,ORTAS
;lab vars
N LRFZX,LRFSAMP,LRFSPEC,LRFDATE,LRFURG,LRFSCH
N ORTIME,ORCOLLCT,ORMAX,ORTEST,ORIMTIME,ORSMAX,ORSTMS,ORSCH
;pharmacy vars
N PSJNOPC,ORMORE,ORINPT,ORXNP,ORSCHED,ORQTY,ORNOUNS,ORXNP,OREFILLS
N ORCOMPLX,ORQTY,ORCOPAY,ORDRUG,ORWPSPIK,ORWPSWRG,ORSD,ORDSUP,ORWP94
;dietetics vars
N ORPARAM,ORNPO,ORTIME,ORMEAL,ORTRAY,ORDATE
;consults vars
N GMRCNOPD,GMRCNOAT,GMRCREAF
; setup general env
N ORTYPE,ORVP,ORL,ORNP,ORSEX,ORAGE,ORWARD,OREVENT,ORDIV,ORSC,KEYVAR
N ORDG,ORDIALOG,ORCAT,FIRST,ORQUIT,X,ORTRAIL,ORLEAD,RSPREF,AUTOACK
N OREVNTYP
S ORWP94=$O(^ORD(101.41,"AB","PS MEDS",0))>0
S ORVP=$P(FLDS,U,1)_";DPT(",ORNP=+$P(FLDS,U,3),ORSC=$P(FLDS,U,8)
S ORL=$P(FLDS,U,2)_";SC(",ORL(2)=ORL
S ORSEX=$P(FLDS,U,5),ORAGE=$P(FLDS,U,6),ORTYPE="Q",FIRST=1
I $P(FLDS,U,4),$G(^SC(+ORL,42)) S ORWARD=+^SC(+ORL,42)
I $L($P(FLDS,U,7)) D
. S OREVENT=$P(FLDS,U,7)
. S OREVNTYP=$P(OREVENT,";",2)
. S OREVENT("TS")=$P(OREVENT,";",3)
. S OREVENT("EFFECTIVE")=$P(OREVENT,";",4)
. S OREVENT=+$P(OREVENT,";",1)
I 'ORWMODE D
. D SETKEYV^ORWDXM3($P(FLDS,U,11,20)) ; from menu path
. S KEYVAR=$$KEYVAR^ORWDXM3(ORIT) ; from entry action
. D SETKEYV^ORWDXM3(KEYVAR)
K ^TMP("ORWORD",$J)
; init return record based on auto-accept
I ORWMODE S LST(0)="2^"_ORIT ;verify on copy
E S LST(0)=+$P($G(^ORD(101.41,ORIT,5)),U,8)_U_ORIT
S TEMPCAT=$S($L($P($G(^DPT(+ORVP,.1)),U)):"I",1:"O")
I TEMPCAT="I",+$P(FLDS,U,4)=1,$E(TEMPORIT)="C",$P($G(^ORD(100.98,$P($G(^OR(100,+ORIT,0)),U,11),0)),U)="OUTPATIENT MEDICATIONS" S TEMPCAT="O"
I $L($G(OREVNTYP)) D
. S ORCAT=$S(OREVNTYP="A":"I",OREVNTYP="T":"I",OREVNTYP="O":TEMPCAT,OREVNTYP="M":TEMPCAT,OREVNTYP="C":TEMPCAT,1:"O") I $G(OREVENT) D
.. N X S X=$$EVT^OREVNTX(OREVENT),X=$P($G(^ORD(100.5,+X,0)),U,7)
.. I OREVNTYP="T",X,X<4 S ORCAT="O" ;To pass=outpt
.. I OREVNTYP="D",X=41 S ORCAT="I" ;From ASIH=inpt
E S ORCAT=TEMPCAT
D SETUP^ORWDXM4 Q:+LST(0)=8
S X="OR GTX START DATE"_$S($G(ORWP94):"/TIME",1:"")
I ORWMODE,(ORDG=+$O(^ORD(100.98,"B","O RX",0))) D ;remove old values
. K ORDIALOG($$PTR^ORCD(X),1)
. I ORWMODE=2,$$DRAFT^ORWDX2(ORIT) Q ;keep comments
. K:ISXFER'["T" ORDIALOG($$PTR^ORCD("OR GTX WORD PROCESSING 1"),1)
D SETUPS^ORWDXM4 ;moved to save space, expects X
Q:+LST(0)=8
I $G(ORQUIT) S LST(0)="0^0^"_$$DLGINFO^ORWDXM3(ORIT,ORWMODE_ISXFER)_"^"_$G(KEYVAR) Q
N SEQ,DA,XCODE,MUSTASK,PROMPT,INST,KEY,IVFID
S IVFID=$O(^ORD(101.41,"B","PSJI OR PAT FLUID OE",0))
S AUTOACK=$S($D(ORWPSWRG):0,1:1)
S SEQ=0 F S SEQ=$O(^ORD(101.41,+ORDIALOG,10,"B",SEQ)) Q:'SEQ D
. S DA=0 F S DA=$O(^ORD(101.41,+ORDIALOG,10,"B",SEQ,DA)) Q:'DA D
. . ; skip if this is a child prompt
. . I $P(^ORD(101.41,+ORDIALOG,10,DA,0),U,11) Q
. . ; set default for prompt, see if needs to be interactive
. . S PROMPT=$P(^ORD(101.41,+ORDIALOG,10,DA,0),U,2)
. . D SETITEM(DA,PROMPT,1,.MUSTASK)
. . I MUSTASK S AUTOACK=0 Q
. . ; iterate through the child items if parent and edit only
. . Q:'$D(^ORD(101.41,+ORDIALOG,10,"DAD",PROMPT))
. . N CSEQ,CDA,CPROMPT,INST,ORQUIT
. . S CSEQ=0 F S CSEQ=$O(^ORD(101.41,+ORDIALOG,10,"DAD",PROMPT,CSEQ)) Q:'CSEQ D Q:$G(ORQUIT)
. . . S CDA=$O(^ORD(101.41,+ORDIALOG,10,"DAD",PROMPT,CSEQ,0))
. . . S CPROMPT=$P(^ORD(101.41,+ORDIALOG,10,CDA,0),U,2)
. . . ; if req & no instances then need interaction
. . . I $P(^ORD(101.41,+ORDIALOG,10,CDA,0),U,6),ORDIALOG'=IVFID,'$O(ORDIALOG(CPROMPT,0)) S AUTOACK=0
. . . S INST=0 F S INST=$O(ORDIALOG(CPROMPT,INST)) Q:'INST D
. . . . N ORASK D VBASK^ORWDXM4(INST) ; set ORASK for VBECS
. . . . ; set default for each child prompt, if necessary
. . . . D SETITEM(CDA,CPROMPT,INST,.MUSTASK)
. . . . ; if no val & child prmpt required then need interaction
. . . . I MUSTASK,$P(^ORD(101.41,+ORDIALOG,10,CDA,0),U,6) S AUTOACK=0
N IVDLG
S IVDLG=$O(^ORD(101.41,"AB","PSJI OR PAT FLUID OE",0))
I $$ISMED(ORIT),(ORDIALOG'=IVDLG),(ORCAT="I") D
. F P="PATIENT INSTRUCTIONS","START DATE/TIME","DAYS SUPPLY","QUANTITY","REFILLS","ROUTING","SERVICE CONNECTED" K ORDIALOG($$PTR(P),1)
S KEY=$S(ORWMODE:"C",1:"")_ORIT_"-"_$P($H,",",2),SEQ=0
I $$ISINPMED(ORIT) D
.S LEVEL=$P(LST(0),U),DELAY=$S($P($G(OREVENT),";")>0:1,1:0)
.I LEVEL=2!(ISIMO) D ADMTIME^ORWDXM2(ORDLOC,PATLOC,ENCLOC,DELAY,ISIMO)
I ($$ISMED(ORIT)),'($$VALQO^ORWDXM3(ORIT)) S AUTOACK=0
S PROMPT=0 F S PROMPT=$O(ORDIALOG(PROMPT)) Q:'PROMPT D
. I '$D(^ORD(101.41,ORDIALOG,10,"D",PROMPT)) K ORDIALOG(PROMPT) Q
. S INST=0 F S INST=$O(ORDIALOG(PROMPT,INST)) Q:'INST D
. . S SEQ=SEQ+1,^TMP("ORWDXMQ",$J,KEY,SEQ,0)=U_PROMPT_U_INST
. . ; save word processing value
. . I $E(ORDIALOG(PROMPT,0))="W",$L(ORDIALOG(PROMPT,INST)) D
. . . M ^TMP("ORWDXMQ",$J,KEY,SEQ,2)=@ORDIALOG(PROMPT,INST)
. . ; save other value types
. . E S ^TMP("ORWDXMQ",$J,KEY,SEQ,1)=ORDIALOG(PROMPT,INST)
I AUTOACK D
. I ORWMODE S AUTOACK=2
. I 'ORWMODE,($P(^ORD(101.41,ORIT,0),U,8)!'LST(0)) S AUTOACK=2
;I ($$ISMED(ORIT)),'($$VALQO^ORWDXM3(ORIT)) S AUTOACK=0
I ORIMO,ORWMODE S AUTOACK=2
; added to accept Herbal/OTC/NonVA Med quick orders
I ORWMODE'=3,$L($G(^ORD(101.41,+ORIT,0))),($P(^ORD(100.98,$P(^ORD(101.41,+ORIT,0),U,5),0),U,3)="NV RX"),($P($G(^ORD(101.41,+ORIT,5)),U,8)) S AUTOACK=1
;I $G(^OR(100,+ORIT,0)),$P($G(^ORD(101.41,+$P(^OR(100,+ORIT,0),U,5),0)),U,8),$D(ORDIALOG("B","HERBAL/OTC/NON VA MEDICATION")) S AUTOACK=1
I AUTOACK=2,$$ISMED(ORIT),(ORDIALOG=IVDLG),$$VERORD^ORWDXM3=0 S AUTOACK=0
I AUTOACK=2 D VERTXT^ORWDXM2
S LST(0)=AUTOACK_U_KEY_U_$$DLGINFO^ORWDXM3(ORIT,ORWMODE_ISXFER)_"^"_$G(KEYVAR)
I $P(LST(0),U,4)="D" S $P(LST(0),U,4)="Q"
I ORWMODE=1 S $P(LST(0),U,4)="C"
K ^TMP("ORWORD",$J)
K ^TMP("PSJINS",$J),^TMP("PSJMR",$J),^TMP("PSJNOUN",$J)
Q
SETITEM(DA,PROMPT,INST,MUSTASK) ; set default value & return if must prompt
N EDITONLY,Y,VALIV,XCODE
S MUSTASK=0,EDITONLY=0,VALIV=0
I $D(^TMP("ORWDHTM",$J,ORDIALOG,PROMPT)) D
. I $E(ORDIALOG(PROMPT,0))="W" D
. . S ^TMP("ORWORD",$J,PROMPT,INST,1,0)=^TMP("ORWDHTM",$J,ORDIALOG,PROMPT)
. . S ORDIALOG(PROMPT,INST)="^TMP(""ORWORD"","_$J_","_PROMPT_","_INST_")"
. E S ORDIALOG(PROMPT,INST)=^TMP("ORWDHTM",$J,ORDIALOG,PROMPT)
I $D(^TMP("ORWDHTM",$J,ORIT,PROMPT)) D
. S ORDIALOG(PROMPT,INST)=^TMP("ORWDHTM",$J,ORIT,PROMPT)
. ; NEED TO CLEAN UP ^TMP("ORWDHTM") after process order set!!!
;
; skip if a value already exists for this prompt and not WP
Q:$D(ORDIALOG(PROMPT,INST))&($E(ORDIALOG(PROMPT,0))'="W")
; execute default action if no value in QO, checking EDITONLY afterwards
I '$D(ORDIALOG(PROMPT,INST)) D
. ;
. ;Intermittent IV orders do not require a solution or an infusion rate
. I PROMPT=$$PTR("INFUSION RATE"),$$GETIVTYP^ORWDXM3="I" S VALIV=1 Q
. I PROMPT=$$PTR("ORDERABLE ITEM"),$$GETIVTYP^ORWDXM3="I" S VALIV=1 Q
. I $E(ORDIALOG(PROMPT,0))="W",$D(^ORD(101.41,+ORDIALOG,10,DA,8))>9 D
. . M ^TMP("ORWORD",$J,PROMPT,INST)=^ORD(101.41,+ORDIALOG,10,DA,8)
. . S ORDIALOG(PROMPT,INST)="^TMP(""ORWORD"","_$J_","_PROMPT_","_INST_")"
. E D
. . S XCODE=$$SUBCODE($G(^ORD(101.41,+ORDIALOG,10,DA,7)))
. . I $L(XCODE) X XCODE S:$D(Y) ORDIALOG(PROMPT,INST)=Y
Q:VALIV=1
Q:$G(EDITONLY)
I 'ORWMODE,$P($G(^ORD(101.41,+ORDIALOG,10,DA,0)),U,8) Q
I ORWMODE,($P($G(^ORD(101.41,+ORDIALOG,10,DA,0)),U,9)'["W"),'$P($G(^ORD(101.41,+ORDIALOG,10,DA,0)),U,6)!$D(ORDIALOG(PROMPT,INST)) Q
I 'ORWMODE,LST(0),$D(ORDIALOG(PROMPT,INST)),($E(ORDIALOG(PROMPT,0))="W") Q
I 'ORWMODE,LST(0),'$P($G(^ORD(101.41,+ORDIALOG,10,DA,0)),U,6) Q
S XCODE=$$SUBCODE($G(^ORD(101.41,+ORDIALOG,10,DA,3)))
I $L(XCODE) X XCODE Q:'$T
S MUSTASK=1
Q
SUBCODE(X) ; substitute code
I X["$$REQDCOMM^ORCDLR" Q "I $$LRRQCM^ORWDXM2"
I X["$$ASKSAMP^ORCDLR" Q "I $$LRASMP^ORWDXM2"
I X["$$SCHEDULD^ORCDRA1" Q "I $$SCHEDULD^ORWDXM2"
I X["(^PSX(550,""C"")" Q "S Y=$E($$DEFPICK^ORWDPS32) K:'$L(Y) Y"
I X["I $$ASKURG^ORCDVBEC" Q "I 1"
I X["K:$G(ORASK)" Q "I $G(ORASK)"
Q X
PTR(NAME) ; -- Returns pointer to OR GTX NAME
Q +$O(^ORD(101.41,"AB",$E("OR GTX "_NAME,1,63),0))
;
ISINPMED(IFN) ;
N PKG,RESULT,Y
I 'ORWMODE S PKG=$P($G(^ORD(101.41,IFN,0)),U,7)
E S PKG=$P($G(^OR(100,+IFN,0)),U,14)
S Y=$$GET1^DIQ(9.4,+PKG_",",1)
S RESULT=$S($E(Y,1,3)="PSJ":1,1:0)
Q RESULT
;
ISMED(IFN) ; return 1 if pharmacy order dlg used
N PKG
I 'ORWMODE S PKG=$P($G(^ORD(101.41,IFN,0)),U,7)
E S PKG=$P($G(^OR(100,+IFN,0)),U,14)
Q $$NMSP^ORCD(PKG)="PS"
SITEVAL() ;return 1 if site does want the reason for study to carry through from past orders of this ordering session
I $$GET^XPAR("ALL","OR RA RFS CARRY ON")=0 Q 0
Q 1
SVRPC(RET,X) ;RPC FOR SITEVAL
S RET=$$SITEVAL
Q
ORWDXM1 ; SLC/KCM - Order Dialogs, Menus;04-Jun-2010 14:12;PLS
+1 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**10,85,131,132,141,178,185,187,1002,1004,215,243,1010**;Dec 17, 1997;Build 47
+2 ;Modified - IHS/MSC/PLS - 5/14/2010 - Line BLDQRSP+25
+3 ; 6/04/2010 Line BLDQRSP+136
BLDQRSP(LST,ORIT,FLDS,ISIMO,ENCLOC) ; Build responses for an order
+1 ; LST=QuickLevel^ResponseID(ORIT;$H)^Dialog^Type^FormID^DGrp
+2 ; LST(n)=verify text or reject text
+3 ; ORIT= ptr to 101.41 for quick order, 100 for copy
+4 ; 1 2 3 4 5 6 7 8 11-20
+5 ; FLDS=DFN^LOC^ORNP^INPT^SEX^AGE^EVENT^SC%^^^Key Variables...
+6 ; ORIT=+ORIT: ptr to 101.41, $E(ORIT)=C: copy $E(ORIT)=X: change
+7 ; !! SHOULD CHECK for PRE-CPRS ORDERS (treat as text?)
+8 KILL ^TMP("ORWDXMQ",$JOB)
+9 ; 0:Dialog,Quick 1:copy order 2:change order
NEW ORWMODE
+10 ; patient category from DPT file
NEW TEMPCAT
+11 ; Transfer order?
NEW ISXFER
+12 ;If IMO(inpatient medication on outpatient)
NEW ORIMO
+13 NEW TEMPORIT
+14 NEW ADMLOC,PATLOC,ORDLOC,LEVEL,DELAY,SCHLOC,SCHTYP
+15 SET PATLOC=$PIECE(FLDS,U,2)
+16 SET ORDLOC=$SELECT(ORIT["C":+$PIECE($GET(^OR(100,+$PIECE(ORIT,"C",2),0)),U,10),1:0)
+17 SET ORIMO=$GET(ISIMO)
+18 SET ORWMODE=0
SET ISXFER=""
+19 ;treat xfer as copy for now
IF $EXTRACT(ORIT)="C"
SET ORWMODE=1
IF $EXTRACT(ORIT)="T"
SET ORWMODE=1
SET ISXFER=";T"
+20 IF $EXTRACT(ORIT)="X"
SET ORWMODE=2
+21 ; IHS/CIA/DKM - Added to support med processing function
IF $EXTRACT(ORIT)="P"
SET ORWMODE=3
+22 SET TEMPORIT=ORIT
+23 IF ORWMODE
SET ORIT=$EXTRACT(ORIT,2,999)
+24 SET LST(0)=""
+25 ; IHS/CIA/DKM - Modified next 2 lines
+26 ;D CHKDSBL^ORWDXM3(.LST,ORIT,ORWMODE) Q:+LST(0)=8 ;disable
+27 ;D CHKVACT^ORWDXM3(.LST,ORIT,ORWMODE,$P(FLDS,U,3)) Q:+LST(0)=8 ;action
+28 ;disable
IF ORWMODE'=3
DO CHKDSBL^ORWDXM3(.LST,ORIT,ORWMODE)
IF +LST(0)=8
QUIT
+29 ;action
IF ORWMODE'=3
DO CHKVACT^ORWDXM3(.LST,ORIT,ORWMODE,$PIECE(FLDS,U,3))
IF +LST(0)=8
QUIT
+30 ;no copy
IF ORWMODE=1
DO CHKCOPY^ORWDXM3(.LST,ORIT,FLDS)
IF +LST(0)=8
QUIT
+31 ;change
IF ORWMODE=2
DO BLD4CHG^ORWDXM3(.LST,ORIT,FLDS)
QUIT
+32 IF 'ORWMODE
IF ($PIECE(^ORD(101.41,+ORIT,0),U,4)="D")
IF '($ORDER(^DIC(9.4,"C","OR",0))[$PIECE(^ORD(101.41,+ORIT,0),U,7))
SET LST(0)="0^0^"_$$DLGINFO^ORWDXM3(ORIT,ORWMODE_ISXFER)
QUIT
+33 ;radilogy vars
+34 NEW ORIMTYPE
+35 ;blood bank vars
+36 NEW ORCOMP,ORTAS
+37 ;lab vars
+38 NEW LRFZX,LRFSAMP,LRFSPEC,LRFDATE,LRFURG,LRFSCH
+39 NEW ORTIME,ORCOLLCT,ORMAX,ORTEST,ORIMTIME,ORSMAX,ORSTMS,ORSCH
+40 ;pharmacy vars
+41 NEW PSJNOPC,ORMORE,ORINPT,ORXNP,ORSCHED,ORQTY,ORNOUNS,ORXNP,OREFILLS
+42 NEW ORCOMPLX,ORQTY,ORCOPAY,ORDRUG,ORWPSPIK,ORWPSWRG,ORSD,ORDSUP,ORWP94
+43 ;dietetics vars
+44 NEW ORPARAM,ORNPO,ORTIME,ORMEAL,ORTRAY,ORDATE
+45 ;consults vars
+46 NEW GMRCNOPD,GMRCNOAT,GMRCREAF
+47 ; setup general env
+48 NEW ORTYPE,ORVP,ORL,ORNP,ORSEX,ORAGE,ORWARD,OREVENT,ORDIV,ORSC,KEYVAR
+49 NEW ORDG,ORDIALOG,ORCAT,FIRST,ORQUIT,X,ORTRAIL,ORLEAD,RSPREF,AUTOACK
+50 NEW OREVNTYP
+51 SET ORWP94=$ORDER(^ORD(101.41,"AB","PS MEDS",0))>0
+52 SET ORVP=$PIECE(FLDS,U,1)_";DPT("
SET ORNP=+$PIECE(FLDS,U,3)
SET ORSC=$PIECE(FLDS,U,8)
+53 SET ORL=$PIECE(FLDS,U,2)_";SC("
SET ORL(2)=ORL
+54 SET ORSEX=$PIECE(FLDS,U,5)
SET ORAGE=$PIECE(FLDS,U,6)
SET ORTYPE="Q"
SET FIRST=1
+55 IF $PIECE(FLDS,U,4)
IF $GET(^SC(+ORL,42))
SET ORWARD=+^SC(+ORL,42)
+56 IF $LENGTH($PIECE(FLDS,U,7))
Begin DoDot:1
+57 SET OREVENT=$PIECE(FLDS,U,7)
+58 SET OREVNTYP=$PIECE(OREVENT,";",2)
+59 SET OREVENT("TS")=$PIECE(OREVENT,";",3)
+60 SET OREVENT("EFFECTIVE")=$PIECE(OREVENT,";",4)
+61 SET OREVENT=+$PIECE(OREVENT,";",1)
End DoDot:1
+62 IF 'ORWMODE
Begin DoDot:1
+63 ; from menu path
DO SETKEYV^ORWDXM3($PIECE(FLDS,U,11,20))
+64 ; from entry action
SET KEYVAR=$$KEYVAR^ORWDXM3(ORIT)
+65 DO SETKEYV^ORWDXM3(KEYVAR)
End DoDot:1
+66 KILL ^TMP("ORWORD",$JOB)
+67 ; init return record based on auto-accept
+68 ;verify on copy
IF ORWMODE
SET LST(0)="2^"_ORIT
+69 IF '$TEST
SET LST(0)=+$PIECE($GET(^ORD(101.41,ORIT,5)),U,8)_U_ORIT
+70 SET TEMPCAT=$SELECT($LENGTH($PIECE($GET(^DPT(+ORVP,.1)),U)):"I",1:"O")
+71 IF TEMPCAT="I"
IF +$PIECE(FLDS,U,4)=1
IF $EXTRACT(TEMPORIT)="C"
IF $PIECE($GET(^ORD(100.98,$PIECE($GET(^OR(100,+ORIT,0)),U,11),0)),U)="OUTPATIENT MEDICATIONS"
SET TEMPCAT="O"
+72 IF $LENGTH($GET(OREVNTYP))
Begin DoDot:1
+73 SET ORCAT=$SELECT(OREVNTYP="A":"I",OREVNTYP="T":"I",OREVNTYP="O":TEMPCAT,OREVNTYP="M":TEMPCAT,OREVNTYP="C":TEMPCAT,1:"O")
IF $GET(OREVENT)
Begin DoDot:2
+74 NEW X
SET X=$$EVT^OREVNTX(OREVENT)
SET X=$PIECE($GET(^ORD(100.5,+X,0)),U,7)
+75 ;To pass=outpt
IF OREVNTYP="T"
IF X
IF X<4
SET ORCAT="O"
+76 ;From ASIH=inpt
IF OREVNTYP="D"
IF X=41
SET ORCAT="I"
End DoDot:2
End DoDot:1
+77 IF '$TEST
SET ORCAT=TEMPCAT
+78 DO SETUP^ORWDXM4
IF +LST(0)=8
QUIT
+79 SET X="OR GTX START DATE"_$SELECT($GET(ORWP94):"/TIME",1:"")
+80 ;remove old values
IF ORWMODE
IF (ORDG=+$ORDER(^ORD(100.98,"B","O RX",0)))
Begin DoDot:1
+81 KILL ORDIALOG($$PTR^ORCD(X),1)
+82 ;keep comments
IF ORWMODE=2
IF $$DRAFT^ORWDX2(ORIT)
QUIT
+83 IF ISXFER'["T"
KILL ORDIALOG($$PTR^ORCD("OR GTX WORD PROCESSING 1"),1)
End DoDot:1
+84 ;moved to save space, expects X
DO SETUPS^ORWDXM4
+85 IF +LST(0)=8
QUIT
+86 IF $GET(ORQUIT)
SET LST(0)="0^0^"_$$DLGINFO^ORWDXM3(ORIT,ORWMODE_ISXFER)_"^"_$GET(KEYVAR)
QUIT
+87 NEW SEQ,DA,XCODE,MUSTASK,PROMPT,INST,KEY,IVFID
+88 SET IVFID=$ORDER(^ORD(101.41,"B","PSJI OR PAT FLUID OE",0))
+89 SET AUTOACK=$SELECT($DATA(ORWPSWRG):0,1:1)
+90 SET SEQ=0
FOR
SET SEQ=$ORDER(^ORD(101.41,+ORDIALOG,10,"B",SEQ))
IF 'SEQ
QUIT
Begin DoDot:1
+91 SET DA=0
FOR
SET DA=$ORDER(^ORD(101.41,+ORDIALOG,10,"B",SEQ,DA))
IF 'DA
QUIT
Begin DoDot:2
+92 ; skip if this is a child prompt
+93 IF $PIECE(^ORD(101.41,+ORDIALOG,10,DA,0),U,11)
QUIT
+94 ; set default for prompt, see if needs to be interactive
+95 SET PROMPT=$PIECE(^ORD(101.41,+ORDIALOG,10,DA,0),U,2)
+96 DO SETITEM(DA,PROMPT,1,.MUSTASK)
+97 IF MUSTASK
SET AUTOACK=0
QUIT
+98 ; iterate through the child items if parent and edit only
+99 IF '$DATA(^ORD(101.41,+ORDIALOG,10,"DAD",PROMPT))
QUIT
+100 NEW CSEQ,CDA,CPROMPT,INST,ORQUIT
+101 SET CSEQ=0
FOR
SET CSEQ=$ORDER(^ORD(101.41,+ORDIALOG,10,"DAD",PROMPT,CSEQ))
IF 'CSEQ
QUIT
Begin DoDot:3
+102 SET CDA=$ORDER(^ORD(101.41,+ORDIALOG,10,"DAD",PROMPT,CSEQ,0))
+103 SET CPROMPT=$PIECE(^ORD(101.41,+ORDIALOG,10,CDA,0),U,2)
+104 ; if req & no instances then need interaction
+105 IF $PIECE(^ORD(101.41,+ORDIALOG,10,CDA,0),U,6)
IF ORDIALOG'=IVFID
IF '$ORDER(ORDIALOG(CPROMPT,0))
SET AUTOACK=0
+106 SET INST=0
FOR
SET INST=$ORDER(ORDIALOG(CPROMPT,INST))
IF 'INST
QUIT
Begin DoDot:4
+107 ; set ORASK for VBECS
NEW ORASK
DO VBASK^ORWDXM4(INST)
+108 ; set default for each child prompt, if necessary
+109 DO SETITEM(CDA,CPROMPT,INST,.MUSTASK)
+110 ; if no val & child prmpt required then need interaction
+111 IF MUSTASK
IF $PIECE(^ORD(101.41,+ORDIALOG,10,CDA,0),U,6)
SET AUTOACK=0
End DoDot:4
End DoDot:3
IF $GET(ORQUIT)
QUIT
End DoDot:2
End DoDot:1
+112 NEW IVDLG
+113 SET IVDLG=$ORDER(^ORD(101.41,"AB","PSJI OR PAT FLUID OE",0))
+114 IF $$ISMED(ORIT)
IF (ORDIALOG'=IVDLG)
IF (ORCAT="I")
Begin DoDot:1
+115 FOR P="PATIENT INSTRUCTIONS","START DATE/TIME","DAYS SUPPLY","QUANTITY","REFILLS","ROUTING","SERVICE CONNECTED"
KILL ORDIALOG($$PTR(P),1)
End DoDot:1
+116 SET KEY=$SELECT(ORWMODE:"C",1:"")_ORIT_"-"_$PIECE($HOROLOG,",",2)
SET SEQ=0
+117 IF $$ISINPMED(ORIT)
Begin DoDot:1
+118 SET LEVEL=$PIECE(LST(0),U)
SET DELAY=$SELECT($PIECE($GET(OREVENT),";")>0:1,1:0)
+119 IF LEVEL=2!(ISIMO)
DO ADMTIME^ORWDXM2(ORDLOC,PATLOC,ENCLOC,DELAY,ISIMO)
End DoDot:1
+120 IF ($$ISMED(ORIT))
IF '($$VALQO^ORWDXM3(ORIT))
SET AUTOACK=0
+121 SET PROMPT=0
FOR
SET PROMPT=$ORDER(ORDIALOG(PROMPT))
IF 'PROMPT
QUIT
Begin DoDot:1
+122 IF '$DATA(^ORD(101.41,ORDIALOG,10,"D",PROMPT))
KILL ORDIALOG(PROMPT)
QUIT
+123 SET INST=0
FOR
SET INST=$ORDER(ORDIALOG(PROMPT,INST))
IF 'INST
QUIT
Begin DoDot:2
+124 SET SEQ=SEQ+1
SET ^TMP("ORWDXMQ",$JOB,KEY,SEQ,0)=U_PROMPT_U_INST
+125 ; save word processing value
+126 IF $EXTRACT(ORDIALOG(PROMPT,0))="W"
IF $LENGTH(ORDIALOG(PROMPT,INST))
Begin DoDot:3
+127 MERGE ^TMP("ORWDXMQ",$JOB,KEY,SEQ,2)=@ORDIALOG(PROMPT,INST)
End DoDot:3
+128 ; save other value types
+129 IF '$TEST
SET ^TMP("ORWDXMQ",$JOB,KEY,SEQ,1)=ORDIALOG(PROMPT,INST)
End DoDot:2
End DoDot:1
+130 IF AUTOACK
Begin DoDot:1
+131 IF ORWMODE
SET AUTOACK=2
+132 IF 'ORWMODE
IF ($PIECE(^ORD(101.41,ORIT,0),U,8)!'LST(0))
SET AUTOACK=2
End DoDot:1
+133 ;I ($$ISMED(ORIT)),'($$VALQO^ORWDXM3(ORIT)) S AUTOACK=0
+134 IF ORIMO
IF ORWMODE
SET AUTOACK=2
+135 ; added to accept Herbal/OTC/NonVA Med quick orders
+136 IF ORWMODE'=3
IF $LENGTH($GET(^ORD(101.41,+ORIT,0)))
IF ($PIECE(^ORD(100.98,$PIECE(^ORD(101.41,+ORIT,0),U,5),0),U,3)="NV RX")
IF ($PIECE($GET(^ORD(101.41,+ORIT,5)),U,8))
SET AUTOACK=1
+137 ;I $G(^OR(100,+ORIT,0)),$P($G(^ORD(101.41,+$P(^OR(100,+ORIT,0),U,5),0)),U,8),$D(ORDIALOG("B","HERBAL/OTC/NON VA MEDICATION")) S AUTOACK=1
+138 IF AUTOACK=2
IF $$ISMED(ORIT)
IF (ORDIALOG=IVDLG)
IF $$VERORD^ORWDXM3=0
SET AUTOACK=0
+139 IF AUTOACK=2
DO VERTXT^ORWDXM2
+140 SET LST(0)=AUTOACK_U_KEY_U_$$DLGINFO^ORWDXM3(ORIT,ORWMODE_ISXFER)_"^"_$GET(KEYVAR)
+141 IF $PIECE(LST(0),U,4)="D"
SET $PIECE(LST(0),U,4)="Q"
+142 IF ORWMODE=1
SET $PIECE(LST(0),U,4)="C"
+143 KILL ^TMP("ORWORD",$JOB)
+144 KILL ^TMP("PSJINS",$JOB),^TMP("PSJMR",$JOB),^TMP("PSJNOUN",$JOB)
+145 QUIT
SETITEM(DA,PROMPT,INST,MUSTASK) ; set default value & return if must prompt
+1 NEW EDITONLY,Y,VALIV,XCODE
+2 SET MUSTASK=0
SET EDITONLY=0
SET VALIV=0
+3 IF $DATA(^TMP("ORWDHTM",$JOB,ORDIALOG,PROMPT))
Begin DoDot:1
+4 IF $EXTRACT(ORDIALOG(PROMPT,0))="W"
Begin DoDot:2
+5 SET ^TMP("ORWORD",$JOB,PROMPT,INST,1,0)=^TMP("ORWDHTM",$JOB,ORDIALOG,PROMPT)
+6 SET ORDIALOG(PROMPT,INST)="^TMP(""ORWORD"","_$JOB_","_PROMPT_","_INST_")"
End DoDot:2
+7 IF '$TEST
SET ORDIALOG(PROMPT,INST)=^TMP("ORWDHTM",$JOB,ORDIALOG,PROMPT)
End DoDot:1
+8 IF $DATA(^TMP("ORWDHTM",$JOB,ORIT,PROMPT))
Begin DoDot:1
+9 SET ORDIALOG(PROMPT,INST)=^TMP("ORWDHTM",$JOB,ORIT,PROMPT)
+10 ; NEED TO CLEAN UP ^TMP("ORWDHTM") after process order set!!!
End DoDot:1
+11 ;
+12 ; skip if a value already exists for this prompt and not WP
+13 IF $DATA(ORDIALOG(PROMPT,INST))&($EXTRACT(ORDIALOG(PROMPT,0))'="W")
QUIT
+14 ; execute default action if no value in QO, checking EDITONLY afterwards
+15 IF '$DATA(ORDIALOG(PROMPT,INST))
Begin DoDot:1
+16 ;
+17 ;Intermittent IV orders do not require a solution or an infusion rate
+18 IF PROMPT=$$PTR("INFUSION RATE")
IF $$GETIVTYP^ORWDXM3="I"
SET VALIV=1
QUIT
+19 IF PROMPT=$$PTR("ORDERABLE ITEM")
IF $$GETIVTYP^ORWDXM3="I"
SET VALIV=1
QUIT
+20 IF $EXTRACT(ORDIALOG(PROMPT,0))="W"
IF $DATA(^ORD(101.41,+ORDIALOG,10,DA,8))>9
Begin DoDot:2
+21 MERGE ^TMP("ORWORD",$JOB,PROMPT,INST)=^ORD(101.41,+ORDIALOG,10,DA,8)
+22 SET ORDIALOG(PROMPT,INST)="^TMP(""ORWORD"","_$JOB_","_PROMPT_","_INST_")"
End DoDot:2
+23 IF '$TEST
Begin DoDot:2
+24 SET XCODE=$$SUBCODE($GET(^ORD(101.41,+ORDIALOG,10,DA,7)))
+25 IF $LENGTH(XCODE)
XECUTE XCODE
IF $DATA(Y)
SET ORDIALOG(PROMPT,INST)=Y
End DoDot:2
End DoDot:1
+26 IF VALIV=1
QUIT
+27 IF $GET(EDITONLY)
QUIT
+28 IF 'ORWMODE
IF $PIECE($GET(^ORD(101.41,+ORDIALOG,10,DA,0)),U,8)
QUIT
+29 IF ORWMODE
IF ($PIECE($GET(^ORD(101.41,+ORDIALOG,10,DA,0)),U,9)'["W")
IF '$PIECE($GET(^ORD(101.41,+ORDIALOG,10,DA,0)),U,6)!$DATA(ORDIALOG(PROMPT,INST))
QUIT
+30 IF 'ORWMODE
IF LST(0)
IF $DATA(ORDIALOG(PROMPT,INST))
IF ($EXTRACT(ORDIALOG(PROMPT,0))="W")
QUIT
+31 IF 'ORWMODE
IF LST(0)
IF '$PIECE($GET(^ORD(101.41,+ORDIALOG,10,DA,0)),U,6)
QUIT
+32 SET XCODE=$$SUBCODE($GET(^ORD(101.41,+ORDIALOG,10,DA,3)))
+33 IF $LENGTH(XCODE)
XECUTE XCODE
IF '$TEST
QUIT
+34 SET MUSTASK=1
+35 QUIT
SUBCODE(X) ; substitute code
+1 IF X["$$REQDCOMM^ORCDLR"
QUIT "I $$LRRQCM^ORWDXM2"
+2 IF X["$$ASKSAMP^ORCDLR"
QUIT "I $$LRASMP^ORWDXM2"
+3 IF X["$$SCHEDULD^ORCDRA1"
QUIT "I $$SCHEDULD^ORWDXM2"
+4 IF X["(^PSX(550,""C"")"
QUIT "S Y=$E($$DEFPICK^ORWDPS32) K:'$L(Y) Y"
+5 IF X["I $$ASKURG^ORCDVBEC"
QUIT "I 1"
+6 IF X["K:$G(ORASK)"
QUIT "I $G(ORASK)"
+7 QUIT X
PTR(NAME) ; -- Returns pointer to OR GTX NAME
+1 QUIT +$ORDER(^ORD(101.41,"AB",$EXTRACT("OR GTX "_NAME,1,63),0))
+2 ;
ISINPMED(IFN) ;
+1 NEW PKG,RESULT,Y
+2 IF 'ORWMODE
SET PKG=$PIECE($GET(^ORD(101.41,IFN,0)),U,7)
+3 IF '$TEST
SET PKG=$PIECE($GET(^OR(100,+IFN,0)),U,14)
+4 SET Y=$$GET1^DIQ(9.4,+PKG_",",1)
+5 SET RESULT=$SELECT($EXTRACT(Y,1,3)="PSJ":1,1:0)
+6 QUIT RESULT
+7 ;
ISMED(IFN) ; return 1 if pharmacy order dlg used
+1 NEW PKG
+2 IF 'ORWMODE
SET PKG=$PIECE($GET(^ORD(101.41,IFN,0)),U,7)
+3 IF '$TEST
SET PKG=$PIECE($GET(^OR(100,+IFN,0)),U,14)
+4 QUIT $$NMSP^ORCD(PKG)="PS"
SITEVAL() ;return 1 if site does want the reason for study to carry through from past orders of this ordering session
+1 IF $$GET^XPAR("ALL","OR RA RFS CARRY ON")=0
QUIT 0
+2 QUIT 1
SVRPC(RET,X) ;RPC FOR SITEVAL
+1 SET RET=$$SITEVAL
+2 QUIT