OCXOED01 ;SLC/RJS,CLA - Rule Editor (Rule Display) ;10/29/98 12:37
;;3.0;ORDER ENTRY/RESULTS REPORTING;**32**;Dec 17,1997
;; ;;ORDER CHECK EXPERT version 1.01 released OCT 29,1998
;
S ;
Q
EN(OCXR0) ;
;
N OCXACT,OCXRD
F K OCXRD,OCXACT S (OCXRD,OCXACT)="" D GETDATA(OCXR0,.OCXRD),DISP(OCXR0,.OCXRD,.OCXACT) Q:$$EN^OCXOED02(OCXR0,.OCXRD,.OCXACT)
;
Q
;
DISP(OCXR0,OCXRD,OCXACT) ;
;
N OCXTHLN,OCXTNLN,OCXTRLN,OCXTULN,OCXTNLN,OCXPREV,OCXNDX
;
S OCXTNLN=$C(27,91,48,109),OCXTRLN=$C(27,91,55,109),OCXTULN=$C(27,91,52,109),OCXTHLN=$C(27,91,49,109)
;
W @IOF,OCXTNLN
W !,$$CENTER($$FIELD("Rule Edit Screen"),80),!
W " ",$$OPT^OCXOEDT("Edit Rule","EDRULE","02",.OCXACT,OCXR0,"ER")
W " ",$$FIELD("Rule:")," ",$$DATA($G(OCXRD("RUL",OCXR0,.01,"E")),30)
W " ",$$FIELD("Status:")," ",$$DATA($G(OCXRD("RUL",OCXR0,.02,"E")),10)
;
W !!,$$SEP("Event/Element Definitions"),!
S OCXR1=0 F S OCXR1=$O(OCXRD("RUL",OCXR0,"ELE",OCXR1)) Q:'OCXR1 D
.N OCORD,OCXTYP,OCXNDX,OCXSYM,OCXTRAN,OCXR2,OCXNAM
.S OCXSYM=$G(OCXRD("RUL",OCXR0,"ELE",OCXR1,.01,"E"))
.S OCXTYP=$G(OCXRD("RUL",OCXR0,"ELE",OCXR1,.02,"I")) Q:OCXTYP
.S OCXTRAN=$G(OCXRD("RUL",OCXR0,"ELE",OCXR1,1,"E")),OCXNDX=$O(OCXRD("ORD",999),-1)\1+1
.S OCXRD("ORD",OCXNDX,0)=OCXR1,OCXRD("ORD",OCXNDX,1)=OCXSYM,OCXRD("ORD",OCXNDX,2)=OCXTRAN
;
S OCXR1=0 F S OCXR1=$O(OCXRD("RUL",OCXR0,"ELE",OCXR1)) Q:'OCXR1 D
.S OCXSYM=$G(OCXRD("RUL",OCXR0,"ELE",OCXR1,.01,"E"))
.S OCXTYP=$G(OCXRD("RUL",OCXR0,"ELE",OCXR1,.02,"I")) Q:'OCXTYP
.S OCXTRAN=$G(OCXRD("RUL",OCXR0,"ELE",OCXR1,2,"E"))
.S OCXR2=$O(OCXRD("ORD",0)) F S OCXPREV=OCXR2,OCXR2=$O(OCXRD("ORD",OCXR2)) Q:'OCXPREV D
..S OCXNAM=$G(OCXRD("ORD",OCXPREV,1)) I $L(OCXNAM),(OCXTRAN[OCXNAM) S OCXNDX=$$BTW(OCXPREV,OCXR2)
.S OCXRD("ORD",OCXNDX,0)=OCXR1,OCXRD("ORD",OCXNDX,1)=OCXSYM,OCXRD("ORD",OCXNDX,2)=OCXTRAN
;
S OCXNDX=0 F S OCXNDX=$O(OCXRD("ORD",OCXNDX)) Q:'OCXNDX D
.N OCXTYP,OCXR1
.S OCXR1=+$G(OCXRD("ORD",OCXNDX,0)) Q:'OCXR1
.W !
.W " ",$$OPT^OCXOEDT("T"_OCXR1,"EDRELE","02",.OCXACT,OCXR0_","_OCXR1)," "
.S OCXTYP=$G(OCXRD("RUL",OCXR0,"ELE",OCXR1,.02,"I"))
.I OCXTYP W $$FIELD("*")
.I 'OCXTYP W " "
.W $G(OCXRD("RUL",OCXR0,"ELE",OCXR1,.01,"E"))
.I $L($G(OCXRD("RUL",OCXR0,"ELE",OCXR1,1,"SRC",2,"E"))) W $$FIELD(" From: "),$$DATA($G(OCXRD("RUL",OCXR0,"ELE",OCXR1,1,"SRC",2,"E")),(90-$X))
.;
W !
W !," ",$$OPT^OCXOEDT("Add Element","EOPT","02",.OCXACT,"""ADD"","_OCXR0,"AE")
W " ",$$OPT^OCXOEDT("Delete Element","EOPT","02",.OCXACT,"""DEL"","_OCXR0,"DE")
;
W !!,$$SEP("Relation Descriptions"),!
S OCXR1=0 F S OCXR1=$O(OCXRD("RUL",OCXR0,"REL",OCXR1)) Q:'OCXR1 D
.W !
.W " ",$$OPT^OCXOEDT("R"_OCXR1,"EDRREL","02",.OCXACT,OCXR0_","_OCXR1)
.W " ",$$DATA($J(OCXR1,2)_". ",5)
.N OCXWORD,OCXEXP
.S OCXEXP=$G(OCXRD("RUL",OCXR0,"REL",OCXR1,1,"E"))
.S OCXSC1=$G(OCXRD("RUL",OCXR0,"REL",OCXR1,7,"E"))
.F OCXWORD=1:1:$L(OCXEXP," ") W:($X>70) !," " W $P(OCXEXP," ",OCXWORD)," "
.I $L(OCXSC1) W $$FIELD(" ("_OCXSC1_")")
W !
W !," ",$$OPT^OCXOEDT("Add Relation","ROPT","02",.OCXACT,"""ADD"","_OCXR0,"AR")
W " ",$$OPT^OCXOEDT("Delete Relation","ROPT","02",.OCXACT,"""DEL"","_OCXR0,"DR")
;
Q
;
XLATE(X) ;
N N S N=$E(X,$L(X))
Q (+X)_" "_$S((N="S"):"Seconds",(N="M"):"Minutes",(N="H"):"Hours",(N="D"):"Days",1:"???")
;
BTW(X,Y) S:'Y Y=999 Q (Y-((Y-X)/2))
;
;
CENTER(X,M) ;
N SP S SP="",$P(SP," ",80)=" " Q $E(SP,1,((M\2)-($L(X)\2)))_X
;
SEP(OCXHDR) ;
;
N SPACES S SPACES="",$P(SPACES," ",80-$L(OCXHDR))=" " Q OCXTNLN_OCXTHLN_OCXTULN_$G(OCXHDR)_SPACES_OCXTNLN
;
FIELD(OCXHDR) ;
;
Q OCXTHLN_$G(OCXHDR)_OCXTNLN
;
DATA(OCXVAL,OCXLEN) ;
;
N SPACES S SPACES="",$P(SPACES," ",OCXLEN+5)=" ",OCXVAL=$G(OCXVAL)
I ($L(OCXVAL)>OCXLEN) Q $E(OCXVAL,1,OCXLEN-3)_"..."
Q $E((OCXVAL_SPACES),1,OCXLEN)
;
GETDATA(OCXD0,OCXD) ;
;
N OCXDIQ,OCXX
S OCXDIQ="" D DIQ("^OCXS(860.2,",OCXD0,"IEN",.OCXDIQ)
M OCXD("RUL")=OCXDIQ(860.2) K OCXDIQ S OCXDIQ=""
S OCXX=0 F S OCXX=$O(^OCXS(860.2,OCXD0,"C",OCXX)) Q:'OCXX W "." D
.D GETMULT(OCXD0,OCXX,"C","ELE",860.21,.OCXD)
.D GETELEM(OCXD0,OCXX,"C","ELE",860.21,.OCXD)
S OCXX=0 F S OCXX=$O(^OCXS(860.2,OCXD0,"R",OCXX)) Q:'OCXX W "." D
.D GETMULT(OCXD0,OCXX,"R","REL",860.22,.OCXD)
Q
;
GETMULT(OCXD0,OCXD1,OCXSUB,OCXSLOT,OCXSUBD,OCXD) ;
;
N OCXDIQ
S OCXDIQ="" D DIQ("^OCXS(860.2,"_OCXD0_","""_OCXSUB_""",",OCXD1,"IEN",.OCXDIQ)
M OCXD("RUL",OCXD0,OCXSLOT)=OCXDIQ(OCXSUBD) K OCXDIQ S OCXDIQ=""
Q
;
GETELEM(OCXD0,OCXD1,OCXSUB,OCXSLOT,OCXSUBD,OCXD) ;
;
N OCXDIQ,OCXELE
S OCXELE=$G(OCXD("RUL",OCXD0,"ELE",OCXD1,1,"I")) Q:'OCXELE
S OCXDIQ="" D DIQ("^OCXS(860.3,",OCXELE,"IEN",.OCXDIQ)
M OCXD("RUL",OCXD0,"ELE",OCXD1,1,"SRC")=OCXDIQ(860.3,OCXELE) K OCXDIQ S OCXDIQ=""
Q
;
DIC(OCXDIC,OCXDIC0,OCXDICA,OCXX,OCXDICS,OCXDR) ;
;
N DIC,X,Y
S DIC=$G(OCXDIC) Q:'$L(DIC) -1
S DIC(0)=$G(OCXDIC0) S:$L($G(OCXX)) X=OCXX
S:$L($G(OCXDICS)) DIC("S")=OCXDICS
S:$L($G(OCXDICA)) DIC("A")=OCXDICA
S:$L($G(OCXDR)) DIC("DR")=OCXDR
D ^DIC Q:(Y<1) 0 Q Y
;
DIQ(DIC,DA,OCXDIQ0,OCXARY) ;
N DR,DIQ S DR=".01:99999",DIQ="OCXARY(",DIQ(0)=$G(OCXDIQ0) D EN^DIQ1
Q
;
OCXOED01 ;SLC/RJS,CLA - Rule Editor (Rule Display) ;10/29/98 12:37
+1 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**32**;Dec 17,1997
+2 ;; ;;ORDER CHECK EXPERT version 1.01 released OCT 29,1998
+3 ;
S ;
+1 QUIT
EN(OCXR0) ;
+1 ;
+2 NEW OCXACT,OCXRD
+3 FOR
KILL OCXRD,OCXACT
SET (OCXRD,OCXACT)=""
DO GETDATA(OCXR0,.OCXRD)
DO DISP(OCXR0,.OCXRD,.OCXACT)
IF $$EN^OCXOED02(OCXR0,.OCXRD,.OCXACT)
QUIT
+4 ;
+5 QUIT
+6 ;
DISP(OCXR0,OCXRD,OCXACT) ;
+1 ;
+2 NEW OCXTHLN,OCXTNLN,OCXTRLN,OCXTULN,OCXTNLN,OCXPREV,OCXNDX
+3 ;
+4 SET OCXTNLN=$CHAR(27,91,48,109)
SET OCXTRLN=$CHAR(27,91,55,109)
SET OCXTULN=$CHAR(27,91,52,109)
SET OCXTHLN=$CHAR(27,91,49,109)
+5 ;
+6 WRITE @IOF,OCXTNLN
+7 WRITE !,$$CENTER($$FIELD("Rule Edit Screen"),80),!
+8 WRITE " ",$$OPT^OCXOEDT("Edit Rule","EDRULE","02",.OCXACT,OCXR0,"ER")
+9 WRITE " ",$$FIELD("Rule:")," ",$$DATA($GET(OCXRD("RUL",OCXR0,.01,"E")),30)
+10 WRITE " ",$$FIELD("Status:")," ",$$DATA($GET(OCXRD("RUL",OCXR0,.02,"E")),10)
+11 ;
+12 WRITE !!,$$SEP("Event/Element Definitions"),!
+13 SET OCXR1=0
FOR
SET OCXR1=$ORDER(OCXRD("RUL",OCXR0,"ELE",OCXR1))
IF 'OCXR1
QUIT
Begin DoDot:1
+14 NEW OCORD,OCXTYP,OCXNDX,OCXSYM,OCXTRAN,OCXR2,OCXNAM
+15 SET OCXSYM=$GET(OCXRD("RUL",OCXR0,"ELE",OCXR1,.01,"E"))
+16 SET OCXTYP=$GET(OCXRD("RUL",OCXR0,"ELE",OCXR1,.02,"I"))
IF OCXTYP
QUIT
+17 SET OCXTRAN=$GET(OCXRD("RUL",OCXR0,"ELE",OCXR1,1,"E"))
SET OCXNDX=$ORDER(OCXRD("ORD",999),-1)\1+1
+18 SET OCXRD("ORD",OCXNDX,0)=OCXR1
SET OCXRD("ORD",OCXNDX,1)=OCXSYM
SET OCXRD("ORD",OCXNDX,2)=OCXTRAN
End DoDot:1
+19 ;
+20 SET OCXR1=0
FOR
SET OCXR1=$ORDER(OCXRD("RUL",OCXR0,"ELE",OCXR1))
IF 'OCXR1
QUIT
Begin DoDot:1
+21 SET OCXSYM=$GET(OCXRD("RUL",OCXR0,"ELE",OCXR1,.01,"E"))
+22 SET OCXTYP=$GET(OCXRD("RUL",OCXR0,"ELE",OCXR1,.02,"I"))
IF 'OCXTYP
QUIT
+23 SET OCXTRAN=$GET(OCXRD("RUL",OCXR0,"ELE",OCXR1,2,"E"))
+24 SET OCXR2=$ORDER(OCXRD("ORD",0))
FOR
SET OCXPREV=OCXR2
SET OCXR2=$ORDER(OCXRD("ORD",OCXR2))
IF 'OCXPREV
QUIT
Begin DoDot:2
+25 SET OCXNAM=$GET(OCXRD("ORD",OCXPREV,1))
IF $LENGTH(OCXNAM)
IF (OCXTRAN[OCXNAM)
SET OCXNDX=$$BTW(OCXPREV,OCXR2)
End DoDot:2
+26 SET OCXRD("ORD",OCXNDX,0)=OCXR1
SET OCXRD("ORD",OCXNDX,1)=OCXSYM
SET OCXRD("ORD",OCXNDX,2)=OCXTRAN
End DoDot:1
+27 ;
+28 SET OCXNDX=0
FOR
SET OCXNDX=$ORDER(OCXRD("ORD",OCXNDX))
IF 'OCXNDX
QUIT
Begin DoDot:1
+29 NEW OCXTYP,OCXR1
+30 SET OCXR1=+$GET(OCXRD("ORD",OCXNDX,0))
IF 'OCXR1
QUIT
+31 WRITE !
+32 WRITE " ",$$OPT^OCXOEDT("T"_OCXR1,"EDRELE","02",.OCXACT,OCXR0_","_OCXR1)," "
+33 SET OCXTYP=$GET(OCXRD("RUL",OCXR0,"ELE",OCXR1,.02,"I"))
+34 IF OCXTYP
WRITE $$FIELD("*")
+35 IF 'OCXTYP
WRITE " "
+36 WRITE $GET(OCXRD("RUL",OCXR0,"ELE",OCXR1,.01,"E"))
+37 IF $LENGTH($GET(OCXRD("RUL",OCXR0,"ELE",OCXR1,1,"SRC",2,"E")))
WRITE $$FIELD(" From: "),$$DATA($GET(OCXRD("RUL",OCXR0,"ELE",OCXR1,1,"SRC",2,"E")),(90-$X))
+38 ;
End DoDot:1
+39 WRITE !
+40 WRITE !," ",$$OPT^OCXOEDT("Add Element","EOPT","02",.OCXACT,"""ADD"","_OCXR0,"AE")
+41 WRITE " ",$$OPT^OCXOEDT("Delete Element","EOPT","02",.OCXACT,"""DEL"","_OCXR0,"DE")
+42 ;
+43 WRITE !!,$$SEP("Relation Descriptions"),!
+44 SET OCXR1=0
FOR
SET OCXR1=$ORDER(OCXRD("RUL",OCXR0,"REL",OCXR1))
IF 'OCXR1
QUIT
Begin DoDot:1
+45 WRITE !
+46 WRITE " ",$$OPT^OCXOEDT("R"_OCXR1,"EDRREL","02",.OCXACT,OCXR0_","_OCXR1)
+47 WRITE " ",$$DATA($JUSTIFY(OCXR1,2)_". ",5)
+48 NEW OCXWORD,OCXEXP
+49 SET OCXEXP=$GET(OCXRD("RUL",OCXR0,"REL",OCXR1,1,"E"))
+50 SET OCXSC1=$GET(OCXRD("RUL",OCXR0,"REL",OCXR1,7,"E"))
+51 FOR OCXWORD=1:1:$LENGTH(OCXEXP," ")
IF ($X>70)
WRITE !," "
WRITE $PIECE(OCXEXP," ",OCXWORD)," "
+52 IF $LENGTH(OCXSC1)
WRITE $$FIELD(" ("_OCXSC1_")")
End DoDot:1
+53 WRITE !
+54 WRITE !," ",$$OPT^OCXOEDT("Add Relation","ROPT","02",.OCXACT,"""ADD"","_OCXR0,"AR")
+55 WRITE " ",$$OPT^OCXOEDT("Delete Relation","ROPT","02",.OCXACT,"""DEL"","_OCXR0,"DR")
+56 ;
+57 QUIT
+58 ;
XLATE(X) ;
+1 NEW N
SET N=$EXTRACT(X,$LENGTH(X))
+2 QUIT (+X)_" "_$SELECT((N="S"):"Seconds",(N="M"):"Minutes",(N="H"):"Hours",(N="D"):"Days",1:"???")
+3 ;
BTW(X,Y) IF 'Y
SET Y=999
QUIT (Y-((Y-X)/2))
+1 ;
+2 ;
CENTER(X,M) ;
+1 NEW SP
SET SP=""
SET $PIECE(SP," ",80)=" "
QUIT $EXTRACT(SP,1,((M\2)-($LENGTH(X)\2)))_X
+2 ;
SEP(OCXHDR) ;
+1 ;
+2 NEW SPACES
SET SPACES=""
SET $PIECE(SPACES," ",80-$LENGTH(OCXHDR))=" "
QUIT OCXTNLN_OCXTHLN_OCXTULN_$GET(OCXHDR)_SPACES_OCXTNLN
+3 ;
FIELD(OCXHDR) ;
+1 ;
+2 QUIT OCXTHLN_$GET(OCXHDR)_OCXTNLN
+3 ;
DATA(OCXVAL,OCXLEN) ;
+1 ;
+2 NEW SPACES
SET SPACES=""
SET $PIECE(SPACES," ",OCXLEN+5)=" "
SET OCXVAL=$GET(OCXVAL)
+3 IF ($LENGTH(OCXVAL)>OCXLEN)
QUIT $EXTRACT(OCXVAL,1,OCXLEN-3)_"..."
+4 QUIT $EXTRACT((OCXVAL_SPACES),1,OCXLEN)
+5 ;
GETDATA(OCXD0,OCXD) ;
+1 ;
+2 NEW OCXDIQ,OCXX
+3 SET OCXDIQ=""
DO DIQ("^OCXS(860.2,",OCXD0,"IEN",.OCXDIQ)
+4 MERGE OCXD("RUL")=OCXDIQ(860.2)
KILL OCXDIQ
SET OCXDIQ=""
+5 SET OCXX=0
FOR
SET OCXX=$ORDER(^OCXS(860.2,OCXD0,"C",OCXX))
IF 'OCXX
QUIT
WRITE "."
Begin DoDot:1
+6 DO GETMULT(OCXD0,OCXX,"C","ELE",860.21,.OCXD)
+7 DO GETELEM(OCXD0,OCXX,"C","ELE",860.21,.OCXD)
End DoDot:1
+8 SET OCXX=0
FOR
SET OCXX=$ORDER(^OCXS(860.2,OCXD0,"R",OCXX))
IF 'OCXX
QUIT
WRITE "."
Begin DoDot:1
+9 DO GETMULT(OCXD0,OCXX,"R","REL",860.22,.OCXD)
End DoDot:1
+10 QUIT
+11 ;
GETMULT(OCXD0,OCXD1,OCXSUB,OCXSLOT,OCXSUBD,OCXD) ;
+1 ;
+2 NEW OCXDIQ
+3 SET OCXDIQ=""
DO DIQ("^OCXS(860.2,"_OCXD0_","""_OCXSUB_""",",OCXD1,"IEN",.OCXDIQ)
+4 MERGE OCXD("RUL",OCXD0,OCXSLOT)=OCXDIQ(OCXSUBD)
KILL OCXDIQ
SET OCXDIQ=""
+5 QUIT
+6 ;
GETELEM(OCXD0,OCXD1,OCXSUB,OCXSLOT,OCXSUBD,OCXD) ;
+1 ;
+2 NEW OCXDIQ,OCXELE
+3 SET OCXELE=$GET(OCXD("RUL",OCXD0,"ELE",OCXD1,1,"I"))
IF 'OCXELE
QUIT
+4 SET OCXDIQ=""
DO DIQ("^OCXS(860.3,",OCXELE,"IEN",.OCXDIQ)
+5 MERGE OCXD("RUL",OCXD0,"ELE",OCXD1,1,"SRC")=OCXDIQ(860.3,OCXELE)
KILL OCXDIQ
SET OCXDIQ=""
+6 QUIT
+7 ;
DIC(OCXDIC,OCXDIC0,OCXDICA,OCXX,OCXDICS,OCXDR) ;
+1 ;
+2 NEW DIC,X,Y
+3 SET DIC=$GET(OCXDIC)
IF '$LENGTH(DIC)
QUIT -1
+4 SET DIC(0)=$GET(OCXDIC0)
IF $LENGTH($GET(OCXX))
SET X=OCXX
+5 IF $LENGTH($GET(OCXDICS))
SET DIC("S")=OCXDICS
+6 IF $LENGTH($GET(OCXDICA))
SET DIC("A")=OCXDICA
+7 IF $LENGTH($GET(OCXDR))
SET DIC("DR")=OCXDR
+8 DO ^DIC
IF (Y<1)
QUIT 0
QUIT Y
+9 ;
DIQ(DIC,DA,OCXDIQ0,OCXARY) ;
+1 NEW DR,DIQ
SET DR=".01:99999"
SET DIQ="OCXARY("
SET DIQ(0)=$GET(OCXDIQ0)
DO EN^DIQ1
+2 QUIT
+3 ;