ATSMNG ;TUCSON/DG;CREATE, MODIFY SEARCH TEMPLATES [ 10/25/91 1:47 PM ]
;;2.5;SEARCH TEMPLATE COMPARISON;;OCT 25, 1991
;
CREATE ; - EP - SELECT FILE FROM WHICH TO GENERATE SEARCH TEMPLATE
S ATSNOASK="" ;SETS FLAG SO THAT ADD DOESN`T ASK SEARCH TEMPLATE NAME
S DIC="^DIC(",DIC(0)="AEMQ",DIC("A")="Select File: " D ^DIC K DIC
I Y<0 D EOJ Q
E S ATSFLNUM=+Y
D NAME D:'$D(ATSTP) ADD D EOJ
Q
;
NAME ;CREATE SEARCH TEMPLATE
R !,"Enter Name Of New Search Template: ",X:300 S:'$T X="^"
I "^"[X S ATSTP="" Q
I $E(X)="?" G NAME
S DIC="^DIBT(",DIC(0)="EQL",DIC("DR")="[ATSCREATE]",DLAYGO=.401,DIADD=1 D ^DIC K DIC,DLAYGO,DR,DIE,DIADD
I Y<0 S ATSTP=""
E S ATSTMP=+Y
Q
;
ADD ; - EP - ADD ENTRY TO A SEARCH TEMPLATE
I '$D(ATSNOASK) S DIC="^DIBT(",DIC(0)="AEMQ",DIC("S")="I $P(^(0),""^"",5)=DUZ,($D(^(1))!('$D(^(2))))",DIC("A")="Select SEARCH TEMPLATE: " D ^DIC K DIC Q:Y<0 S ATSTMP=+Y
F ATSL=0:0 S DIC=$P(^DIBT(ATSTMP,0),"^",4),DIC(0)="AEMQ" D ^DIC K DIC Q:Y<0 W @$S($D(^DIBT(ATSTMP,1,+Y)):"!,*7,""Entry already in search template!"",!",1:"!,""Entered!"",!") S ^DIBT(ATSTMP,1,+Y)=""
D:'$D(ATSNOASK) EOJ
Q
;
DELETE ; - EP - DELETE ENTRY FROM A SEARCH TEMPLATE
S DIC="^DIBT(",DIC(0)="AEMQ",DIC("S")="I $P(^(0),""^"",5)=DUZ,($D(^(1))!('$D(^(2))))",DIC("A")="Select SEARCH TEMPLATE: " D ^DIC K DIC Q:Y<0 S ATSTMP=+Y
F ATSL=0:0 S DIC=$P(^DIBT(ATSTMP,0),"^",4),DIC(0)="AEMQ" D ^DIC K DIC Q:Y<0 W @$S('$D(^DIBT(ATSTMP,1,+Y)):"!,*7,""Entry does not exist in search template!"",!",1:"!,""Deleted!"",!") K ^DIBT(ATSTMP,1,+Y)
D EOJ
Q
;
EOJ ;
K ATSTMP,ATSNOASK,ATSTP,ATSFLNUM,ATSL
Q
;
ATSMNG ;TUCSON/DG;CREATE, MODIFY SEARCH TEMPLATES [ 10/25/91 1:47 PM ]
+1 ;;2.5;SEARCH TEMPLATE COMPARISON;;OCT 25, 1991
+2 ;
CREATE ; - EP - SELECT FILE FROM WHICH TO GENERATE SEARCH TEMPLATE
+1 ;SETS FLAG SO THAT ADD DOESN`T ASK SEARCH TEMPLATE NAME
SET ATSNOASK=""
+2 SET DIC="^DIC("
SET DIC(0)="AEMQ"
SET DIC("A")="Select File: "
DO ^DIC
KILL DIC
+3 IF Y<0
DO EOJ
QUIT
+4 IF '$TEST
SET ATSFLNUM=+Y
+5 DO NAME
IF '$DATA(ATSTP)
DO ADD
DO EOJ
+6 QUIT
+7 ;
NAME ;CREATE SEARCH TEMPLATE
+1 READ !,"Enter Name Of New Search Template: ",X:300
IF '$TEST
SET X="^"
+2 IF "^"[X
SET ATSTP=""
QUIT
+3 IF $EXTRACT(X)="?"
GOTO NAME
+4 SET DIC="^DIBT("
SET DIC(0)="EQL"
SET DIC("DR")="[ATSCREATE]"
SET DLAYGO=.401
SET DIADD=1
DO ^DIC
KILL DIC,DLAYGO,DR,DIE,DIADD
+5 IF Y<0
SET ATSTP=""
+6 IF '$TEST
SET ATSTMP=+Y
+7 QUIT
+8 ;
ADD ; - EP - ADD ENTRY TO A SEARCH TEMPLATE
+1 IF '$DATA(ATSNOASK)
SET DIC="^DIBT("
SET DIC(0)="AEMQ"
SET DIC("S")="I $P(^(0),""^"",5)=DUZ,($D(^(1))!('$D(^(2))))"
SET DIC("A")="Select SEARCH TEMPLATE: "
DO ^DIC
KILL DIC
IF Y<0
QUIT
SET ATSTMP=+Y
+2 FOR ATSL=0:0
SET DIC=$PIECE(^DIBT(ATSTMP,0),"^",4)
SET DIC(0)="AEMQ"
DO ^DIC
KILL DIC
IF Y<0
QUIT
WRITE @$SELECT($DATA(^DIBT(ATSTMP,1,+Y)):"!,*7,""Entry already in search template!"",!",1:"!,""Entered!"",!")
SET ^DIBT(ATSTMP,1,+Y)=""
+3 IF '$DATA(ATSNOASK)
DO EOJ
+4 QUIT
+5 ;
DELETE ; - EP - DELETE ENTRY FROM A SEARCH TEMPLATE
+1 SET DIC="^DIBT("
SET DIC(0)="AEMQ"
SET DIC("S")="I $P(^(0),""^"",5)=DUZ,($D(^(1))!('$D(^(2))))"
SET DIC("A")="Select SEARCH TEMPLATE: "
DO ^DIC
KILL DIC
IF Y<0
QUIT
SET ATSTMP=+Y
+2 FOR ATSL=0:0
SET DIC=$PIECE(^DIBT(ATSTMP,0),"^",4)
SET DIC(0)="AEMQ"
DO ^DIC
KILL DIC
IF Y<0
QUIT
WRITE @$SELECT('$DATA(^DIBT(ATSTMP,1,+Y)):"!,*7,""Entry does not exist in search template!"",!",1:"!,""Deleted!"",!")
KILL ^DIBT(ATSTMP,1,+Y)
+3 DO EOJ
+4 QUIT
+5 ;
EOJ ;
+1 KILL ATSTMP,ATSNOASK,ATSTP,ATSFLNUM,ATSL
+2 QUIT
+3 ;