ORY2112 ;SLC/RJS,CLA - OCX PACKAGE RULE TRANSPORT ROUTINE (Delete after Install of OR*3*211) ;APR 5,2005 at 08:07
;;3.0;ORDER ENTRY/RESULTS REPORTING;**211**;Dec 17,1997
;; ;;ORDER CHECK EXPERT version 1.01 released OCT 29,1998
;
S ;
; Record Utilities
Q
;
ADDREC(OCXCREF) ;
;
N QUIT,OCXDD,OCXDA,OCXGREF,OCXNAME
S OCXDD=$O(@OCXCREF@("")) Q:'OCXDD 0
S OCXNAME=$G(@OCXCREF@(OCXDD,.01,"E"))
;
W " record missing..."
I (OCXFLAG["D") Q 0
;
S OCXDA=0 D CREATE(OCXCREF,OCXDD,.OCXDA,0)
S:$L(OCXNAME) ^TMP("OCXRULE",$J,"A",+OCXDD,OCXNAME)=""
;
Q 0
;
CREATE(OCXCREF,OCXDD,OCXDA,OCXLVL) ;
;
N OCXFLD,OCXGREF,OCXKEY
;
I $L(OCXDA),'(OCXDA=+OCXDA) W !!,"Unresolved subscript." Q
;
S OCXKEY=@OCXCREF@(OCXDD,.01,"E")
S OCXGREF=$$GETREF(+OCXDD,.OCXDA,OCXLVL) Q:'$L(OCXGREF)
I 'OCXDA D
.S OCXDA=$O(^TMP("OCXRULE",$J,"B",+OCXDD,OCXKEY,0)) Q:OCXDA
.S OCXDA=$O(@(OCXGREF_""" "")"),-1)+1
.F OCXDA=OCXDA:1 Q:'$D(@(OCXGREF_OCXDA_",0)"))
.I $D(@(OCXGREF_OCXDA_",0)")) S OCXDA=0
;
I 'OCXDA W !!,"Error adding record..." Q
;
I '$D(@(OCXGREF_"0)")) S @(OCXGREF_"0)")=U_$$FILEHDR^OCXSENDD(+OCXDD)_U_U
;
S OCXFLD=0 F S OCXFLD=$O(@OCXCREF@(OCXDD,OCXFLD)) Q:'OCXFLD Q:(OCXFLD[":") I '$$EXFLD^ORY2111(+OCXDD,OCXFLD) D
.I $L($G(@OCXCREF@(OCXDD,OCXFLD,"E"))) D DIE(OCXDD,OCXGREF,OCXFLD,@OCXCREF@(OCXDD,OCXFLD,"E"),.OCXDA,OCXLVL)
.I $O(@OCXCREF@(OCXDD,OCXFLD,0)) D WORD(OCXDD,OCXGREF,OCXFLD,.OCXDA,OCXCREF)
;
D PUSH(.OCXDA)
S OCXFLD="" F S OCXFLD=$O(@OCXCREF@(OCXDD,OCXFLD)) Q:'$L(OCXFLD) I (OCXFLD[":") D
.S OCXDA=$P(OCXFLD,":",2) W ! D CREATE($$APPEND(OCXCREF,OCXDD),OCXFLD,.OCXDA,OCXLVL+1)
D POP(.OCXDA)
Q
;
LOADWORD(RREF,OCXDD,OCXFLD,OCXSUB) ;
;
N QUIT,DDPATH,INDEX,OCXDA,OCXGREF
S DDPATH=$P($P($$APPEND(RREF,OCXDD),"(",2),")",1)
F INDEX=1:1:$L(DDPATH,",") S OCXDA($L(DDPATH,",")-INDEX)=+$P($P(DDPATH,",",INDEX),":",2)
S OCXDA=$G(OCXDA(0)) K OCXDA(0)
Q:(OCXFLAG["D") 0
I (OCXFLAG["A") S QUIT=$$READ("Y"," Do you want to reload the local '"_$$FIELD^OCXSENDD(+OCXDD,+OCXFLD,"LABEL")_"' field ?","YES") Q:'QUIT (QUIT[U)
S OCXGREF=$$GETREF(+OCXDD,.OCXDA,$L(DDPATH,",")-1) Q:'$L(OCXGREF)
D WORD(OCXDD,OCXGREF,OCXFLD,.OCXDA,RREF)
Q 0
;
GETREF(OCXDD,OCXDA,OCXLVL) ;
;
Q:'OCXDD ""
;
N OCXIENS,OCXERR,OCXX
S OCXIENS=$$IENS^DILF(.OCXDA),OCXERR=""
S OCXX=$$ROOT^DILFD(OCXDD,OCXIENS,0,OCXERR)
Q OCXX
;
WORD(DD,GREF,FLD,DA,RREF) ;
;
N SUB,GLROOT,LINE
S SUB=$P($$FIELD^OCXSENDD(+DD,FLD,"GLOBAL SUBSCRIPT LOCATION"),";",1) S:'(SUB=+SUB) SUB=""""_SUB_""""
S GLROOT=GREF_DA_","_SUB_")" K @GLROOT
S LINE=0 F S LINE=$O(@RREF@(DD,FLD,LINE)) Q:'LINE D
.S @GLROOT@($O(@GLROOT@(""),-1)+1,0)=@RREF@(DD,FLD,LINE)
S LINE=$O(@GLROOT@(""),-1),@GLROOT@(0)=U_U_LINE_U_LINE_U_$$DATE("T")_U
;
Q
;
DATE(X) N %DT,Y S %DT="" D ^%DT Q +Y
;
DIE(OCXDD,OCXDIC,OCXFLD,OCXVAL,OCXDA,OCXLVL) ;
;
N DIC,DIE,X,Y,DR,DA,OCXDVAL,OCXPTR,OCXGREF,D0,OCXSCR
S (D0,DA)=OCXDA,(DIC,DIE)=OCXDIC,DR=""
S:OCXLVL D0=OCXDA(1),DR="S DA(1)="_(+D0)_",D0="_(+D0)_";"
S:OCXVAL="?" OCXVAL="? " S DR=DR_OCXFLD_"///^S X=OCXVAL"
I '(OCXVAL="@") W !,?(OCXLVL*5),$$FIELD^OCXSENDD(+OCXDD,OCXFLD,"LABEL"),": ",OCXVAL
;
I '(OCXVAL="@") D
.N OCXIEN,SHORT
.S OCXPTR=+$P($$FIELD^OCXSENDD(+OCXDD,OCXFLD,"SPECIFIER"),"P",2)
.Q:'OCXPTR
.S OCXGREF="^"_$$FIELD^OCXSENDD(+OCXDD,OCXFLD,"POINTER")
.I '($E(OCXGREF,1,4)="^OCX"),'(OCXGREF="^ORD(100.9,"),'(OCXGREF="^ORD(100.8,") Q
.Q:$$DIC(OCXGREF,OCXVAL,0)
.S OCXIEN=$$DIC(OCXGREF,OCXVAL,1)
.S ^TMP("OCXRULE",$J,"B",OCXPTR,OCXVAL,OCXIEN)=""
;
S OCXSCR=1
D ^DIE
;
; I $D(Y) -> DIE FILER ERROR
I $D(Y) W " ^DIE filer data error..." S OCXDIER=$G(OCXDIER)+1
I '$D(Y) W " ...Correct data Filed"
;
Q
;
DIC(DIC,X,OCXADD) N OCXSCR S DIC(0)="",OCXSCR=1 S:OCXADD DIC(0)="L" D ^DIC Q:(+Y>0) +Y Q 0
;
PUSH(OCXDA) ;
N OCXSUB S OCXSUB="" F S OCXSUB=$O(OCXDA(OCXSUB),-1) Q:'OCXSUB S OCXDA(OCXSUB+1)=OCXDA(OCXSUB)
S OCXDA(1)=OCXDA,OCXDA=0
Q
;
POP(OCXDA) ;
N OCXSUB S OCXSUB="" F S OCXSUB=$O(OCXDA(OCXSUB)) Q:'OCXSUB S OCXDA(OCXSUB)=$G(OCXDA(OCXSUB+1))
S OCXDA=OCXDA(1) K OCXDA($O(OCXDA(""),-1))
Q
;
APPEND(ARRAY,OCXSUB) ;
S:'(OCXSUB=+OCXSUB) OCXSUB=""""_OCXSUB_""""
Q:'(ARRAY["(") ARRAY_"("_OCXSUB_")"
Q $E(ARRAY,1,$L(ARRAY)-1)_","_OCXSUB_")"
;
READ(OCXZ0,OCXZA,OCXZB,OCXZL) ;
N OCXLINE,DIR,DTOUT,DUOUT,DIRUT,DIROUT
Q:'$L($G(OCXZ0)) U
S DIR(0)=OCXZ0
S:$L($G(OCXZA)) DIR("A")=OCXZA
S:$L($G(OCXZB)) DIR("B")=OCXZB
F OCXLINE=1:1:($G(OCXZL)-1) W !
D ^DIR
I $D(DTOUT)!$D(DUOUT)!$D(DIRUT)!$D(DIROUT) Q U
Q Y
;
PAUSE() W " Press Enter " R X:DTIME W ! Q (X[U)
;
ORY2112 ;SLC/RJS,CLA - OCX PACKAGE RULE TRANSPORT ROUTINE (Delete after Install of OR*3*211) ;APR 5,2005 at 08:07
+1 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**211**;Dec 17,1997
+2 ;; ;;ORDER CHECK EXPERT version 1.01 released OCT 29,1998
+3 ;
S ;
+1 ; Record Utilities
+2 QUIT
+3 ;
ADDREC(OCXCREF) ;
+1 ;
+2 NEW QUIT,OCXDD,OCXDA,OCXGREF,OCXNAME
+3 SET OCXDD=$ORDER(@OCXCREF@(""))
IF 'OCXDD
QUIT 0
+4 SET OCXNAME=$GET(@OCXCREF@(OCXDD,.01,"E"))
+5 ;
+6 WRITE " record missing..."
+7 IF (OCXFLAG["D")
QUIT 0
+8 ;
+9 SET OCXDA=0
DO CREATE(OCXCREF,OCXDD,.OCXDA,0)
+10 IF $LENGTH(OCXNAME)
SET ^TMP("OCXRULE",$JOB,"A",+OCXDD,OCXNAME)=""
+11 ;
+12 QUIT 0
+13 ;
CREATE(OCXCREF,OCXDD,OCXDA,OCXLVL) ;
+1 ;
+2 NEW OCXFLD,OCXGREF,OCXKEY
+3 ;
+4 IF $LENGTH(OCXDA)
IF '(OCXDA=+OCXDA)
WRITE !!,"Unresolved subscript."
QUIT
+5 ;
+6 SET OCXKEY=@OCXCREF@(OCXDD,.01,"E")
+7 SET OCXGREF=$$GETREF(+OCXDD,.OCXDA,OCXLVL)
IF '$LENGTH(OCXGREF)
QUIT
+8 IF 'OCXDA
Begin DoDot:1
+9 SET OCXDA=$ORDER(^TMP("OCXRULE",$JOB,"B",+OCXDD,OCXKEY,0))
IF OCXDA
QUIT
+10 SET OCXDA=$ORDER(@(OCXGREF_""" "")"),-1)+1
+11 FOR OCXDA=OCXDA:1
IF '$DATA(@(OCXGREF_OCXDA_",0)"))
QUIT
+12 IF $DATA(@(OCXGREF_OCXDA_",0)"))
SET OCXDA=0
End DoDot:1
+13 ;
+14 IF 'OCXDA
WRITE !!,"Error adding record..."
QUIT
+15 ;
+16 IF '$DATA(@(OCXGREF_"0)"))
SET @(OCXGREF_"0)")=U_$$FILEHDR^OCXSENDD(+OCXDD)_U_U
+17 ;
+18 SET OCXFLD=0
FOR
SET OCXFLD=$ORDER(@OCXCREF@(OCXDD,OCXFLD))
IF 'OCXFLD
QUIT
IF (OCXFLD["
QUIT
IF '$$EXFLD^ORY2111(+OCXDD,OCXFLD)
Begin DoDot:1
+19 IF $LENGTH($GET(@OCXCREF@(OCXDD,OCXFLD,"E")))
DO DIE(OCXDD,OCXGREF,OCXFLD,@OCXCREF@(OCXDD,OCXFLD,"E"),.OCXDA,OCXLVL)
+20 IF $ORDER(@OCXCREF@(OCXDD,OCXFLD,0))
DO WORD(OCXDD,OCXGREF,OCXFLD,.OCXDA,OCXCREF)
End DoDot:1
+21 ;
+22 DO PUSH(.OCXDA)
+23 SET OCXFLD=""
FOR
SET OCXFLD=$ORDER(@OCXCREF@(OCXDD,OCXFLD))
IF '$LENGTH(OCXFLD)
QUIT
IF (OCXFLD[":")
Begin DoDot:1
+24 SET OCXDA=$PIECE(OCXFLD,":",2)
WRITE !
DO CREATE($$APPEND(OCXCREF,OCXDD),OCXFLD,.OCXDA,OCXLVL+1)
End DoDot:1
+25 DO POP(.OCXDA)
+26 QUIT
+27 ;
LOADWORD(RREF,OCXDD,OCXFLD,OCXSUB) ;
+1 ;
+2 NEW QUIT,DDPATH,INDEX,OCXDA,OCXGREF
+3 SET DDPATH=$PIECE($PIECE($$APPEND(RREF,OCXDD),"(",2),")",1)
+4 FOR INDEX=1:1:$LENGTH(DDPATH,",")
SET OCXDA($LENGTH(DDPATH,",")-INDEX)=+$PIECE($PIECE(DDPATH,",",INDEX),":",2)
+5 SET OCXDA=$GET(OCXDA(0))
KILL OCXDA(0)
+6 IF (OCXFLAG["D")
QUIT 0
+7 IF (OCXFLAG["A")
SET QUIT=$$READ("Y"," Do you want to reload the local '"_$$FIELD^OCXSENDD(+OCXDD,+OCXFLD,"LABEL")_"' field ?","YES")
IF 'QUIT
QUIT (QUIT[U)
+8 SET OCXGREF=$$GETREF(+OCXDD,.OCXDA,$LENGTH(DDPATH,",")-1)
IF '$LENGTH(OCXGREF)
QUIT
+9 DO WORD(OCXDD,OCXGREF,OCXFLD,.OCXDA,RREF)
+10 QUIT 0
+11 ;
GETREF(OCXDD,OCXDA,OCXLVL) ;
+1 ;
+2 IF 'OCXDD
QUIT ""
+3 ;
+4 NEW OCXIENS,OCXERR,OCXX
+5 SET OCXIENS=$$IENS^DILF(.OCXDA)
SET OCXERR=""
+6 SET OCXX=$$ROOT^DILFD(OCXDD,OCXIENS,0,OCXERR)
+7 QUIT OCXX
+8 ;
WORD(DD,GREF,FLD,DA,RREF) ;
+1 ;
+2 NEW SUB,GLROOT,LINE
+3 SET SUB=$PIECE($$FIELD^OCXSENDD(+DD,FLD,"GLOBAL SUBSCRIPT LOCATION"),";",1)
IF '(SUB=+SUB)
SET SUB=""""_SUB_""""
+4 SET GLROOT=GREF_DA_","_SUB_")"
KILL @GLROOT
+5 SET LINE=0
FOR
SET LINE=$ORDER(@RREF@(DD,FLD,LINE))
IF 'LINE
QUIT
Begin DoDot:1
+6 SET @GLROOT@($ORDER(@GLROOT@(""),-1)+1,0)=@RREF@(DD,FLD,LINE)
End DoDot:1
+7 SET LINE=$ORDER(@GLROOT@(""),-1)
SET @GLROOT@(0)=U_U_LINE_U_LINE_U_$$DATE("T")_U
+8 ;
+9 QUIT
+10 ;
DATE(X) NEW %DT,Y
SET %DT=""
DO ^%DT
QUIT +Y
+1 ;
DIE(OCXDD,OCXDIC,OCXFLD,OCXVAL,OCXDA,OCXLVL) ;
+1 ;
+2 NEW DIC,DIE,X,Y,DR,DA,OCXDVAL,OCXPTR,OCXGREF,D0,OCXSCR
+3 SET (D0,DA)=OCXDA
SET (DIC,DIE)=OCXDIC
SET DR=""
+4 IF OCXLVL
SET D0=OCXDA(1)
SET DR="S DA(1)="_(+D0)_",D0="_(+D0)_";"
+5 IF OCXVAL="?"
SET OCXVAL="? "
SET DR=DR_OCXFLD_"///^S X=OCXVAL"
+6 IF '(OCXVAL="@")
WRITE !,?(OCXLVL*5),$$FIELD^OCXSENDD(+OCXDD,OCXFLD,"LABEL"),": ",OCXVAL
+7 ;
+8 IF '(OCXVAL="@")
Begin DoDot:1
+9 NEW OCXIEN,SHORT
+10 SET OCXPTR=+$PIECE($$FIELD^OCXSENDD(+OCXDD,OCXFLD,"SPECIFIER"),"P",2)
+11 IF 'OCXPTR
QUIT
+12 SET OCXGREF="^"_$$FIELD^OCXSENDD(+OCXDD,OCXFLD,"POINTER")
+13 IF '($EXTRACT(OCXGREF,1,4)="^OCX")
IF '(OCXGREF="^ORD(100.9,")
IF '(OCXGREF="^ORD(100.8,")
QUIT
+14 IF $$DIC(OCXGREF,OCXVAL,0)
QUIT
+15 SET OCXIEN=$$DIC(OCXGREF,OCXVAL,1)
+16 SET ^TMP("OCXRULE",$JOB,"B",OCXPTR,OCXVAL,OCXIEN)=""
End DoDot:1
+17 ;
+18 SET OCXSCR=1
+19 DO ^DIE
+20 ;
+21 ; I $D(Y) -> DIE FILER ERROR
+22 IF $DATA(Y)
WRITE " ^DIE filer data error..."
SET OCXDIER=$GET(OCXDIER)+1
+23 IF '$DATA(Y)
WRITE " ...Correct data Filed"
+24 ;
+25 QUIT
+26 ;
DIC(DIC,X,OCXADD) NEW OCXSCR
SET DIC(0)=""
SET OCXSCR=1
IF OCXADD
SET DIC(0)="L"
DO ^DIC
IF (+Y>0)
QUIT +Y
QUIT 0
+1 ;
PUSH(OCXDA) ;
+1 NEW OCXSUB
SET OCXSUB=""
FOR
SET OCXSUB=$ORDER(OCXDA(OCXSUB),-1)
IF 'OCXSUB
QUIT
SET OCXDA(OCXSUB+1)=OCXDA(OCXSUB)
+2 SET OCXDA(1)=OCXDA
SET OCXDA=0
+3 QUIT
+4 ;
POP(OCXDA) ;
+1 NEW OCXSUB
SET OCXSUB=""
FOR
SET OCXSUB=$ORDER(OCXDA(OCXSUB))
IF 'OCXSUB
QUIT
SET OCXDA(OCXSUB)=$GET(OCXDA(OCXSUB+1))
+2 SET OCXDA=OCXDA(1)
KILL OCXDA($ORDER(OCXDA(""),-1))
+3 QUIT
+4 ;
APPEND(ARRAY,OCXSUB) ;
+1 IF '(OCXSUB=+OCXSUB)
SET OCXSUB=""""_OCXSUB_""""
+2 IF '(ARRAY["(")
QUIT ARRAY_"("_OCXSUB_")"
+3 QUIT $EXTRACT(ARRAY,1,$LENGTH(ARRAY)-1)_","_OCXSUB_")"
+4 ;
READ(OCXZ0,OCXZA,OCXZB,OCXZL) ;
+1 NEW OCXLINE,DIR,DTOUT,DUOUT,DIRUT,DIROUT
+2 IF '$LENGTH($GET(OCXZ0))
QUIT U
+3 SET DIR(0)=OCXZ0
+4 IF $LENGTH($GET(OCXZA))
SET DIR("A")=OCXZA
+5 IF $LENGTH($GET(OCXZB))
SET DIR("B")=OCXZB
+6 FOR OCXLINE=1:1:($GET(OCXZL)-1)
WRITE !
+7 DO ^DIR
+8 IF $DATA(DTOUT)!$DATA(DUOUT)!$DATA(DIRUT)!$DATA(DIROUT)
QUIT U
+9 QUIT Y
+10 ;
PAUSE() WRITE " Press Enter "
READ X:DTIME
WRITE !
QUIT (X[U)
+1 ;