LEXNDX1 ;ISL/KER - Set/kill indexes (Part 1) ;04/21/2014
;;2.0;LEXICON UTILITY;**80**;Sep 23, 1996;Build 10
;
; Global Variables
; ^LEX(757.011) N/A
; ^TMP("LEXSTOP") SACC 2.3.2.5.1
; ^TMP("LEXTKN") SACC 2.3.2.5.1
;
; External References
; $$UP^XLFSTR ICR 10103
; HOME^%ZIS ICR 10086
; ^%ZTLOAD ICR 10063
;
S ; Set Expression file (#757.01) word index node AWRD
Q:'$D(X)!('$D(DA)) Q:$D(DIC)#2=0
Q:'$D(@(DIC_DA_",0)")) Q:'$D(@(DIC_DA_",1)")) Q:+($P(@(DIC_DA_",1)"),U,1))=0
N LEXIDX,LEXJ,LEXI,LEXTYPE,LEXT S LEXTYPE=+X Q:LEXTYPE'>0
S LEXT=$P($G(^LEX(757.011,LEXTYPE,0)),"^",2) Q:+LEXT=0
S LEXTYPE=$P($G(^LEX(757.011,LEXTYPE,0)),"^",1) D:LEXTYPE["DELETED" U
S X=@(DIC_DA_",0)") S:X'="" ^LEX(757.01,"B",$$UP^XLFSTR($E(X,1,63)),DA)=""
S LEXEX=$P(^LEX(757,$P(^LEX(757.01,DA,1),U,1),0),U,1),LEXIDX=""
D PTX^LEXTOKN I $D(^TMP("LEXTKN",$J,0)),^TMP("LEXTKN",$J,0)>0 S LEXI="",LEXJ=0 D
. F S LEXJ=$O(^TMP("LEXTKN",$J,LEXJ)) Q:+LEXJ'>0 D
. . S LEXI=$O(^TMP("LEXTKN",$J,LEXJ,"")) Q:'$L(LEXI)
. . I '$D(^LEX(757.01,"AWRD",LEXI,LEXEX)) D
. . . S:'$D(^LEX(757.01,DA,4,"B",LEXI)) ^LEX(757.01,"AWRD",LEXI,LEXEX,DA)=""
D L K LEXIDX,LEXEX,LEXI,LEXTYPE,LEXT,LEXJ,^TMP("LEXTKN",$J,0),^TMP("LEXTKN",$J) Q
;
K ; Kill Expression file (#757.01) word index node AWRD
Q:'$D(X)!('$D(DA)) D U
Q:'$D(^LEX(757.01,DA,0)) Q:+($P(^LEX(757.01,DA,1),U,1))=0
N LEXTYPE,LEXT S LEXTYPE=+X Q:LEXTYPE'>0
S LEXT=$P($G(^LEX(757.011,LEXTYPE,0)),"^",2) Q:+LEXT=0
N LEXIDX,LEXJ,LEXI S X=^LEX(757.01,DA,0),LEXIDX=""
D PTX^LEXTOKN I $D(^TMP("LEXTKN",$J,0)),^TMP("LEXTKN",$J,0)>0 S LEXI="",LEXJ=0 D
. F S LEXJ=$O(^TMP("LEXTKN",$J,LEXJ)) Q:+LEXJ'>0 D
. . S LEXI=$O(^TMP("LEXTKN",$J,LEXJ,"")) Q:'$L(LEXI) K ^LEX(757.01,"AWRD",LEXI,DA)
K LEXIDX,LEXTYPE,LEXI,LEXJ,^TMP("LEXTKN",$J,0),^TMP("LEXTKN",$J) Q
L ; Link words
N DIC,LEXDEXP D KILL^LEXNDX2 S LEXDEXP=DA
; For Subsets
I $D(^LEX(757.21,"B",LEXDEXP)) D
. S DA=0 F S DA=$O(^LEX(757.21,"B",LEXDEXP,DA)) Q:+DA=0 D
. . N X S X=$P(^LEX(757.21,DA,0),U,2) Q:+X<1 D SS^LEXNDX2
; For Replacement Words
I $D(^LEX(757.05,"AEXP",LEXDEXP)) D
. S DA=0 F S DA=$O(^LEX(757.05,"AEXP",LEXDEXP,DA)) Q:+DA=0 D
. . N X,LEXMC S X=$P(^LEX(757.05,DA,0),U,1) Q:X=""
. . S LEXMC=$P($G(^LEX(757.01,LEXDEXP,1)),U,1) Q:+LEXMC'>0
. . S ^LEX(757.01,"AWRD",X,LEXDEXP,"LINKED")=""
S DA=LEXDEXP
Q
U ; Unlink words
N DIC,LEXDEXP D KILL^LEXNDX2 S LEXDEXP=DA
; For Subsets
I $D(^LEX(757.21,"B",LEXDEXP)) D
. S DA=0 F S DA=$O(^LEX(757.21,"B",LEXDEXP,DA)) Q:+DA=0 D
. . N X S X=$P(^LEX(757.21,DA,0),U,2) Q:+X<1 D SK^LEXNDX2
; For Replacement Words
I $D(^LEX(757.05,"AEXP",LEXDEXP)) D
. S DA=0 F S DA=$O(^LEX(757.05,"AEXP",LEXDEXP,DA)) Q:+DA=0 D
. . N X,LEXMC S X=$P(^LEX(757.05,DA,0),U,1) Q:X=""
. . S LEXMC=$P($G(^LEX(757.01,LEXDEXP,1)),U,1) Q:+LEXMC'>0
. . K ^LEX(757.01,"AWRD",X,LEXDEXP,"LINKED")
S DA=LEXDEXP
Q
REIDXMC ; Re-Index Expression file word index AWRD
S:$D(ZTQUEUED) ZTREQ="@"
N LEXIDX,LEXREIX,DA,X S DA=0,X="",(LEXREIX,LEXIDX)="" K ^TMP("LEXSTOP","REIDXMC")
F S DA=$O(^LEX(757.01,DA)) Q:+DA=0!($D(^TMP("LEXSTOP","REIDXMC"))) D
. S X=$P(^LEX(757.01,DA,1),U,2) D S
K ^TMP("LEXSTOP","REIDXMC"),LEXIDX,DA,X
Q
RMC ; Re-Index Expression file word index AWRD (Task Manager)
S ZTRTN="REIDXMC^LEXNDX1"
S ZTDESC="Re-Indexing Major Concept Words in ""AWRD"" index"
S ZTIO="",ZTDTH=$H D ^%ZTLOAD,HOME^%ZIS W:$D(ZTSK) !!,"Re-Indexing Major Concept Words in ""AWRD"" index" W:'$D(ZTSK) !!,"Task to re-index Major Concept not created"
K ZTDTH,ZTDESC,ZTIO,ZTRTN
Q
RALL ; Re-Index entire file (needs DIC)
S DIK=$G(DIC) Q:DIK="" Q:'$D(@(DIK_"0)"))
S ZTREQ="@",(ZTSAVE("ZTREQ"),ZTSAVE("DIK"))="",ZTRTN="IXALL^DIK"
S ZTDESC="Re-Indexing "_DIK
S ZTIO="",ZTDTH=$H D ^%ZTLOAD,HOME^%ZIS
K ZTDTH,ZTDESC,ZTIO,ZTRTN,ZTREQ,ZTSAVE
Q
LEXNDX1 ;ISL/KER - Set/kill indexes (Part 1) ;04/21/2014
+1 ;;2.0;LEXICON UTILITY;**80**;Sep 23, 1996;Build 10
+2 ;
+3 ; Global Variables
+4 ; ^LEX(757.011) N/A
+5 ; ^TMP("LEXSTOP") SACC 2.3.2.5.1
+6 ; ^TMP("LEXTKN") SACC 2.3.2.5.1
+7 ;
+8 ; External References
+9 ; $$UP^XLFSTR ICR 10103
+10 ; HOME^%ZIS ICR 10086
+11 ; ^%ZTLOAD ICR 10063
+12 ;
S ; Set Expression file (#757.01) word index node AWRD
+1 IF '$DATA(X)!('$DATA(DA))
QUIT
IF $DATA(DIC)#2=0
QUIT
+2 IF '$DATA(@(DIC_DA_",0)"))
QUIT
IF '$DATA(@(DIC_DA_",1)"))
QUIT
IF +($PIECE(@(DIC_DA_",1)"),U,1))=0
QUIT
+3 NEW LEXIDX,LEXJ,LEXI,LEXTYPE,LEXT
SET LEXTYPE=+X
IF LEXTYPE'>0
QUIT
+4 SET LEXT=$PIECE($GET(^LEX(757.011,LEXTYPE,0)),"^",2)
IF +LEXT=0
QUIT
+5 SET LEXTYPE=$PIECE($GET(^LEX(757.011,LEXTYPE,0)),"^",1)
IF LEXTYPE["DELETED"
DO U
+6 SET X=@(DIC_DA_",0)")
IF X'=""
SET ^LEX(757.01,"B",$$UP^XLFSTR($EXTRACT(X,1,63)),DA)=""
+7 SET LEXEX=$PIECE(^LEX(757,$PIECE(^LEX(757.01,DA,1),U,1),0),U,1)
SET LEXIDX=""
+8 DO PTX^LEXTOKN
IF $DATA(^TMP("LEXTKN",$JOB,0))
IF ^TMP("LEXTKN",$JOB,0)>0
SET LEXI=""
SET LEXJ=0
Begin DoDot:1
+9 FOR
SET LEXJ=$ORDER(^TMP("LEXTKN",$JOB,LEXJ))
IF +LEXJ'>0
QUIT
Begin DoDot:2
+10 SET LEXI=$ORDER(^TMP("LEXTKN",$JOB,LEXJ,""))
IF '$LENGTH(LEXI)
QUIT
+11 IF '$DATA(^LEX(757.01,"AWRD",LEXI,LEXEX))
Begin DoDot:3
+12 IF '$DATA(^LEX(757.01,DA,4,"B",LEXI))
SET ^LEX(757.01,"AWRD",LEXI,LEXEX,DA)=""
End DoDot:3
End DoDot:2
End DoDot:1
+13 DO L
KILL LEXIDX,LEXEX,LEXI,LEXTYPE,LEXT,LEXJ,^TMP("LEXTKN",$JOB,0),^TMP("LEXTKN",$JOB)
QUIT
+14 ;
K ; Kill Expression file (#757.01) word index node AWRD
+1 IF '$DATA(X)!('$DATA(DA))
QUIT
DO U
+2 IF '$DATA(^LEX(757.01,DA,0))
QUIT
IF +($PIECE(^LEX(757.01,DA,1),U,1))=0
QUIT
+3 NEW LEXTYPE,LEXT
SET LEXTYPE=+X
IF LEXTYPE'>0
QUIT
+4 SET LEXT=$PIECE($GET(^LEX(757.011,LEXTYPE,0)),"^",2)
IF +LEXT=0
QUIT
+5 NEW LEXIDX,LEXJ,LEXI
SET X=^LEX(757.01,DA,0)
SET LEXIDX=""
+6 DO PTX^LEXTOKN
IF $DATA(^TMP("LEXTKN",$JOB,0))
IF ^TMP("LEXTKN",$JOB,0)>0
SET LEXI=""
SET LEXJ=0
Begin DoDot:1
+7 FOR
SET LEXJ=$ORDER(^TMP("LEXTKN",$JOB,LEXJ))
IF +LEXJ'>0
QUIT
Begin DoDot:2
+8 SET LEXI=$ORDER(^TMP("LEXTKN",$JOB,LEXJ,""))
IF '$LENGTH(LEXI)
QUIT
KILL ^LEX(757.01,"AWRD",LEXI,DA)
End DoDot:2
End DoDot:1
+9 KILL LEXIDX,LEXTYPE,LEXI,LEXJ,^TMP("LEXTKN",$JOB,0),^TMP("LEXTKN",$JOB)
QUIT
L ; Link words
+1 NEW DIC,LEXDEXP
DO KILL^LEXNDX2
SET LEXDEXP=DA
+2 ; For Subsets
+3 IF $DATA(^LEX(757.21,"B",LEXDEXP))
Begin DoDot:1
+4 SET DA=0
FOR
SET DA=$ORDER(^LEX(757.21,"B",LEXDEXP,DA))
IF +DA=0
QUIT
Begin DoDot:2
+5 NEW X
SET X=$PIECE(^LEX(757.21,DA,0),U,2)
IF +X<1
QUIT
DO SS^LEXNDX2
End DoDot:2
End DoDot:1
+6 ; For Replacement Words
+7 IF $DATA(^LEX(757.05,"AEXP",LEXDEXP))
Begin DoDot:1
+8 SET DA=0
FOR
SET DA=$ORDER(^LEX(757.05,"AEXP",LEXDEXP,DA))
IF +DA=0
QUIT
Begin DoDot:2
+9 NEW X,LEXMC
SET X=$PIECE(^LEX(757.05,DA,0),U,1)
IF X=""
QUIT
+10 SET LEXMC=$PIECE($GET(^LEX(757.01,LEXDEXP,1)),U,1)
IF +LEXMC'>0
QUIT
+11 SET ^LEX(757.01,"AWRD",X,LEXDEXP,"LINKED")=""
End DoDot:2
End DoDot:1
+12 SET DA=LEXDEXP
+13 QUIT
U ; Unlink words
+1 NEW DIC,LEXDEXP
DO KILL^LEXNDX2
SET LEXDEXP=DA
+2 ; For Subsets
+3 IF $DATA(^LEX(757.21,"B",LEXDEXP))
Begin DoDot:1
+4 SET DA=0
FOR
SET DA=$ORDER(^LEX(757.21,"B",LEXDEXP,DA))
IF +DA=0
QUIT
Begin DoDot:2
+5 NEW X
SET X=$PIECE(^LEX(757.21,DA,0),U,2)
IF +X<1
QUIT
DO SK^LEXNDX2
End DoDot:2
End DoDot:1
+6 ; For Replacement Words
+7 IF $DATA(^LEX(757.05,"AEXP",LEXDEXP))
Begin DoDot:1
+8 SET DA=0
FOR
SET DA=$ORDER(^LEX(757.05,"AEXP",LEXDEXP,DA))
IF +DA=0
QUIT
Begin DoDot:2
+9 NEW X,LEXMC
SET X=$PIECE(^LEX(757.05,DA,0),U,1)
IF X=""
QUIT
+10 SET LEXMC=$PIECE($GET(^LEX(757.01,LEXDEXP,1)),U,1)
IF +LEXMC'>0
QUIT
+11 KILL ^LEX(757.01,"AWRD",X,LEXDEXP,"LINKED")
End DoDot:2
End DoDot:1
+12 SET DA=LEXDEXP
+13 QUIT
REIDXMC ; Re-Index Expression file word index AWRD
+1 IF $DATA(ZTQUEUED)
SET ZTREQ="@"
+2 NEW LEXIDX,LEXREIX,DA,X
SET DA=0
SET X=""
SET (LEXREIX,LEXIDX)=""
KILL ^TMP("LEXSTOP","REIDXMC")
+3 FOR
SET DA=$ORDER(^LEX(757.01,DA))
IF +DA=0!($DATA(^TMP("LEXSTOP","REIDXMC")))
QUIT
Begin DoDot:1
+4 SET X=$PIECE(^LEX(757.01,DA,1),U,2)
DO S
End DoDot:1
+5 KILL ^TMP("LEXSTOP","REIDXMC"),LEXIDX,DA,X
+6 QUIT
RMC ; Re-Index Expression file word index AWRD (Task Manager)
+1 SET ZTRTN="REIDXMC^LEXNDX1"
+2 SET ZTDESC="Re-Indexing Major Concept Words in ""AWRD"" index"
+3 SET ZTIO=""
SET ZTDTH=$HOROLOG
DO ^%ZTLOAD
DO HOME^%ZIS
IF $DATA(ZTSK)
WRITE !!,"Re-Indexing Major Concept Words in ""AWRD"" index"
IF '$DATA(ZTSK)
WRITE !!,"Task to re-index Major Concept not created"
+4 KILL ZTDTH,ZTDESC,ZTIO,ZTRTN
+5 QUIT
RALL ; Re-Index entire file (needs DIC)
+1 SET DIK=$GET(DIC)
IF DIK=""
QUIT
IF '$DATA(@(DIK_"0)"))
QUIT
+2 SET ZTREQ="@"
SET (ZTSAVE("ZTREQ"),ZTSAVE("DIK"))=""
SET ZTRTN="IXALL^DIK"
+3 SET ZTDESC="Re-Indexing "_DIK
+4 SET ZTIO=""
SET ZTDTH=$HOROLOG
DO ^%ZTLOAD
DO HOME^%ZIS
+5 KILL ZTDTH,ZTDESC,ZTIO,ZTRTN,ZTREQ,ZTSAVE
+6 QUIT