DICE2 ;SFISC/GFT-TRIGGER LOGIC ;09:41 AM 10 Jul 1999 [ 04/02/2003 8:25 AM ]
;;22.0;VA FileMan;**1001**;APR 1, 2003
;;22.0;VA FileMan;**6**;Mar 30, 1999
;Per VHA Directive 10-93-142, this routine should not be modified.
Q:$D(DTOUT) W !!!,"---",$P("SET^KILL",U,DIK)," LOGIC---" S DA="^DD("_DI_","_DL_",1,"_DQ_","_(DIK+3)
C K DICOMPX,DATE S:DOLD=DNEW DNEW="TRIGGERED "_DNEW S DNEW=$E(DNEW,1,30),DICOMPX(DNEW)="DIU",DICOMPX(DNEW,U)=DIN_U_DENEW,DCOND="SET" S:$P(^DD(DIN,DENEW,0),U,2)["D" DICOMPX(DNEW,"DATE")=1
W !!,"IN ANSWERING THE FOLLOWING QUESTION, '"_DNEW_"'",!?2,"CAN BE USED TO REFER TO THE EXISTING TRIGGERED FIELD VALUE.",!
S DICOMP="?",DICOMPX="",%=DIN S:DIK=1 DICOMPX(1,DI,DL)="DIV"
D OLD W "PLEASE ENTER AN EXPRESSION WHICH WILL BECOME THE VALUE OF THE",! S %F=DENEW D WR^DIDH
D GET Q:U[X I X="""@""" K X G DICE2^DIQQ
I X="@" S X="S X="""""
E D ^DICOMP G DICE2^DIQQ:'$D(X) F %=9.2:.1 Q:'$D(X(%)) S ^UTILITY("DICE",$J,DIK+3*10+%)=X(%)
K DICOMPX(DNEW) I X="S X=""""" S DE=X,DCOND="DELE" D DEL^DICE3 G Q:X=U,^DICE4:DENEW-.01 F X=0:1 G D01:'$D(J(X)) I J(X)=DIN W $C(7),!,"BUT THE TRIGGERING FIELD DEPENDS ON THE TRIGGERED FIELD!" S X=U G Q
S DE="S X=DIV "_X,%=$P(^DD(DIN,DENEW,0),U,2) I %["D",'Y["D" W $C(7),!,"WARNING -- THIS SHOULD PRODUCE A DATE VALUE, AND IT MAY NOT!"
S V=$P(%,"P",2) I V,DICOMPX-V!($P(DICOMPX,U,2)-.001) W !,$C(7),"WARNING -- THIS MUST BE '",$P(^DIC(+V,0),U)," NUMBER'!"
I Y["B" W $C(7),!,"WARNING--THIS TRUTH-VALUED EXPRESSION WILL PRODUCE ONLY VALUES OF '0' OR '1'"
I %'["D",Y["D" W $C(7),!,"WARNING -- THIS MAY PRODUCE A 'DATE', AND IT SHOULDN'T!"
D ^DICE3 G ^DICE4:X'=U
Q Q
;
OLD ;
I DIK=2 S X=$E("OLD "_DOLD,1,30),DICOMPX(X)="X",DICOMPX(X,U)=DI_U_DL W ?2,"NOTE: '"_X_"' CAN BE USED TO REFER TO THE VALUE OF THE",!?2,DOLD_" FIELD BEFORE ITS CHANGE OR DELETION.",! S:$P(^DD(DI,DL,0),U,2)["D" DICOMPX(X,"DATE")=1
Q
;
D01 S V=DREF,X=$L(V)-1 F %=X:-1 I "(,"[$E(V,%) S DHI=$E(V,%+1,X) I DHI'?1N1")" S V=$E(V,1,%),X=0 Q
DQ S X=$F(V,"""",X) I X>0 S V=$E(V,1,X-1)_""""_$E(V,X,999),X=X+2 G DQ
S X="I "_DHI_">0 N DIK S DIK(0)=DA,",V="DIK="""_V_""",",DHI="DA="_DHI_" D ^DIK",DTAG="S DA=DIK(0)"
F %=1:1:N S X=X_"DIK("_%_")=DA("_%_"),",DTAG=DTAG_",DA("_%_")=DIK("_%_")"
F %=1:1:A#100 S DHI="DA("_%_")=DIV("_(A#100-%)_"),"_DHI
S X=X_V_DHI,^UTILITY("DICE",$J,"DIK")="DELETE" G F^DICE4
;
GET ;
W !," WHENEVER THE '"_DOLD_"' FIELD IS "_$P("ENTERED OR CHANGED^CHANGED OR DELETED",U,DIK)
R ": ",X:DTIME S:'$T X=U S Y=X I X="" S Y="NO EFFECT",^UTILITY("DICE",$J,DIK)="Q" W " ",Y I DIK=2,^UTILITY("DICE",$J,1)="Q" W $C(7),"??" S X=U
S ^UTILITY("DICE",$J,$P("CREA^DELE",U,DIK)_"TE VALUE")=Y
DICE2 ;SFISC/GFT-TRIGGER LOGIC ;09:41 AM 10 Jul 1999 [ 04/02/2003 8:25 AM ]
+1 ;;22.0;VA FileMan;**1001**;APR 1, 2003
+2 ;;22.0;VA FileMan;**6**;Mar 30, 1999
+3 ;Per VHA Directive 10-93-142, this routine should not be modified.
+4 IF $DATA(DTOUT)
QUIT
WRITE !!!,"---",$PIECE("SET^KILL",U,DIK)," LOGIC---"
SET DA="^DD("_DI_","_DL_",1,"_DQ_","_(DIK+3)
C KILL DICOMPX,DATE
IF DOLD=DNEW
SET DNEW="TRIGGERED "_DNEW
SET DNEW=$EXTRACT(DNEW,1,30)
SET DICOMPX(DNEW)="DIU"
SET DICOMPX(DNEW,U)=DIN_U_DENEW
SET DCOND="SET"
IF $PIECE(^DD(DIN,DENEW,0),U,2)["D"
SET DICOMPX(DNEW,"DATE")=1
+1 WRITE !!,"IN ANSWERING THE FOLLOWING QUESTION, '"_DNEW_"'",!?2,"CAN BE USED TO REFER TO THE EXISTING TRIGGERED FIELD VALUE.",!
+2 SET DICOMP="?"
SET DICOMPX=""
SET %=DIN
IF DIK=1
SET DICOMPX(1,DI,DL)="DIV"
+3 DO OLD
WRITE "PLEASE ENTER AN EXPRESSION WHICH WILL BECOME THE VALUE OF THE",!
SET %F=DENEW
DO WR^DIDH
+4 DO GET
IF U[X
QUIT
IF X="""@"""
KILL X
GOTO DICE2^DIQQ
+5 IF X="@"
SET X="S X="""""
+6 IF '$TEST
DO ^DICOMP
IF '$DATA(X)
GOTO DICE2^DIQQ
FOR %=9.2:.1
IF '$DATA(X(%))
QUIT
SET ^UTILITY("DICE",$JOB,DIK+3*10+%)=X(%)
+7 KILL DICOMPX(DNEW)
IF X="S X="""""
SET DE=X
SET DCOND="DELE"
DO DEL^DICE3
IF X=U
GOTO Q
IF DENEW-.01
GOTO ^DICE4
FOR X=0:1
IF '$DATA(J(X))
GOTO D01
IF J(X)=DIN
WRITE $CHAR(7),!,"BUT THE TRIGGERING FIELD DEPENDS ON THE TRIGGERED FIELD!"
SET X=U
GOTO Q
+8 SET DE="S X=DIV "_X
SET %=$PIECE(^DD(DIN,DENEW,0),U,2)
IF %["D"
IF 'Y["D"
WRITE $CHAR(7),!,"WARNING -- THIS SHOULD PRODUCE A DATE VALUE, AND IT MAY NOT!"
+9 SET V=$PIECE(%,"P",2)
IF V
IF DICOMPX-V!($PIECE(DICOMPX,U,2)-.001)
WRITE !,$CHAR(7),"WARNING -- THIS MUST BE '",$PIECE(^DIC(+V,0),U)," NUMBER'!"
+10 IF Y["B"
WRITE $CHAR(7),!,"WARNING--THIS TRUTH-VALUED EXPRESSION WILL PRODUCE ONLY VALUES OF '0' OR '1'"
+11 IF %'["D"
IF Y["D"
WRITE $CHAR(7),!,"WARNING -- THIS MAY PRODUCE A 'DATE', AND IT SHOULDN'T!"
+12 DO ^DICE3
IF X'=U
GOTO ^DICE4
Q QUIT
+1 ;
OLD ;
+1 IF DIK=2
SET X=$EXTRACT("OLD "_DOLD,1,30)
SET DICOMPX(X)="X"
SET DICOMPX(X,U)=DI_U_DL
WRITE ?2,"NOTE: '"_X_"' CAN BE USED TO REFER TO THE VALUE OF THE",!?2,DOLD_" FIELD BEFORE ITS CHANGE OR DELETION.",!
IF $PIECE(^DD(DI,DL,0),U,2)["D"
SET DICOMPX(X,"DATE")=1
+2 QUIT
+3 ;
D01 SET V=DREF
SET X=$LENGTH(V)-1
FOR %=X:-1
IF "(,"[$EXTRACT(V,%)
SET DHI=$EXTRACT(V,%+1,X)
IF DHI'?1N1")"
SET V=$EXTRACT(V,1,%)
SET X=0
QUIT
DQ SET X=$FIND(V,"""",X)
IF X>0
SET V=$EXTRACT(V,1,X-1)_""""_$EXTRACT(V,X,999)
SET X=X+2
GOTO DQ
+1 SET X="I "_DHI_">0 N DIK S DIK(0)=DA,"
SET V="DIK="""_V_""","
SET DHI="DA="_DHI_" D ^DIK"
SET DTAG="S DA=DIK(0)"
+2 FOR %=1:1:N
SET X=X_"DIK("_%_")=DA("_%_"),"
SET DTAG=DTAG_",DA("_%_")=DIK("_%_")"
+3 FOR %=1:1:A#100
SET DHI="DA("_%_")=DIV("_(A#100-%)_"),"_DHI
+4 SET X=X_V_DHI
SET ^UTILITY("DICE",$JOB,"DIK")="DELETE"
GOTO F^DICE4
+5 ;
GET ;
+1 WRITE !," WHENEVER THE '"_DOLD_"' FIELD IS "_$PIECE("ENTERED OR CHANGED^CHANGED OR DELETED",U,DIK)
+2 READ ": ",X:DTIME
IF '$TEST
SET X=U
SET Y=X
IF X=""
SET Y="NO EFFECT"
SET ^UTILITY("DICE",$JOB,DIK)="Q"
WRITE " ",Y
IF DIK=2
IF ^UTILITY("DICE",$JOB,1)="Q"
WRITE $CHAR(7),"??"
SET X=U
+3 SET ^UTILITY("DICE",$JOB,$PIECE("CREA^DELE",U,DIK)_"TE VALUE")=Y