LEXRXC2 ;ISL/KER - Re-Index 757.01 AMC/AWRD ;08/17/2011
;;2.0;LEXICON UTILITY;**81**;Sep 23, 1996;Build 10
;
; Global Variables
; ^LEX( SACC 1.3
; ^LEX(757.01, SACC 1.3
; ^LEX(757.04, SACC 1.3
; ^LEX(757.05, SACC 1.3
;
; External References
; ^DIK ICR 10013
; IX1^DIK ICR 10013
; $$FMDIFF^XLFDT ICR 10103
; $$NOW^XLFDT ICR 10103
; $$UP^XLFSTR ICR 10104
;
; Local Variables NEWed or KILLed Elsewhere
; LEXNAM Task name NEWed/KILLed by LEXRXXT
; LEXTEST Test variable NEWed/KILLed by Developer
; ZTQUEUED Task flag NEWed/KILLed by Taskman
;
Q
; NOTES:
;
; The AMC cross-references is used to create the AWRD
; cross-reference, hence the AMC cross-reference must
; be repaired/re-indexed before AWRD.
;
; The AWRD cross-references is used to create the ASL
; cross-reference, hence the AWRD cross-reference must
; be repaired/re-indexed before ASL.
;
; Re-indexing file 757.01 will Kill off all Linked Words
; from the Replacement Word file #757.05, hence after
; repairing/re-indexing file 757.01 you should immediatley
; re-index file 757.05.
;
EN ; Main Entry Point
R75701 ; Repair file 757.01
D RAMC,RAWRD Q
RAMC ; Index ^LEX(757.01,"AMC",MC,IEN)
N DA,DIK,LEXBEG,LEXDIF,LEXELP,LEXEND,LEXERR,LEXFI,LEXIDX,LEXIDXT,LEXIEN,LEXMC,LEXNDS,LEXOK,LEXSTR
S LEXFI="757.01"
N LEXTC S LEXTC=$$UPD^LEXRXXT3($G(LEXNAM),,"Repairing File #757.01 ""AMC""") Q:LEXTC=1
S LEXBEG=$$NOW^XLFDT,(LEXNDS,LEXERR)=0,LEXSTR="",LEXFI=757.01,LEXIDX="AMC",LEXIDXT="^LEX(757.01,""AMC"",MC,IEN)"
F S LEXSTR=$O(^LEX(LEXFI,LEXIDX,LEXSTR)) Q:'$L(LEXSTR) D
. N LEXIEN S LEXIEN=0 F S LEXIEN=$O(^LEX(LEXFI,LEXIDX,LEXSTR,LEXIEN)) Q:+LEXIEN'>0 D
. . S LEXNDS=LEXNDS+1
. . I '$D(^LEX(LEXFI,LEXIEN,0)) D Q
. . . S LEXERR=LEXERR+1 K:'$D(LEXTEST) ^LEX(LEXFI,LEXIDX,LEXSTR,LEXIEN)
. . . I '$D(ZTQUEUED) W !,?8,LEXFI,?19,LEXIDX,?30,LEXSTR,?58," ",LEXIEN
. . N LEXOK,LEXMC S LEXMC=+($P($G(^LEX(LEXFI,LEXIEN,1)),"^",1))
. . S LEXOK=0 S:LEXMC=LEXSTR LEXOK=1 I 'LEXOK D
. . . S LEXERR=LEXERR+1 K:'$D(LEXTEST) ^LEX(LEXFI,LEXIDX,LEXSTR,LEXIEN) S:+LEXMC>0 ^LEX(LEXFI,LEXIDX,+LEXMC,LEXIEN)=""
. . . I '$D(ZTQUEUED) W !,?8,LEXFI,?19,LEXIDX,?30,LEXSTR,?58," ",LEXIEN
S LEXIEN=0 F S LEXIEN=$O(^LEX(LEXFI,LEXIEN)) Q:+LEXIEN'>0 D
. N DA,DIK,X S DA=LEXIEN,X=+($G(^LEX(LEXFI,DA,1))) Q:'$L(X)
. I '$D(^LEX(LEXFI,LEXIDX,X,DA)) D
. . S LEXERR=LEXERR+1 I '$D(ZTQUEUED) W !,?8,LEXFI,?19,LEXIDX,?30,"Missing",?58," ",DA
. S:$L(X) ^LEX(LEXFI,LEXIDX,X,DA)=""
. S ^LEX(LEXFI,LEXIDX,X,DA)=""
S LEXERR=$S(+LEXERR>0:LEXERR,1:"") I '$D(ZTQUEUED) W !,$J(LEXERR,5),?8,LEXFI,?19,LEXIDX,?30,LEXIDXT
S LEXEND=$$NOW^XLFDT,LEXELP=$$FMDIFF^XLFDT(LEXEND,LEXBEG,3)
S:$E(LEXELP,1)=" "&($E(LEXELP,3)=":") LEXELP=$TR(LEXELP," ","0")
D REP^LEXRXXS(LEXFI,LEXFI,LEXIDX,LEXNDS,LEXERR,LEXIDXT,LEXELP)
Q
RAWRD ; Index ^LEX(757.01,"AWRD",WORD,MC,EXP)
N DA,DIK,LEXBEG,LEXDIF,LEXE,LEXELP,LEXEND,LEXERR,LEXEXCL,LEXEXP,LEXFI,LEXHI,LEXI,LEXIDX,LEXIDXT,LEXL,LEXLO,LEXM
N LEXMCE,LEXNDS,LEXS,LEXS1,LEXS2,LEXS3,LEXS4,LEXSTR,LEXT,LEXTC,LEXTK,LEXTKN,LEXTNG,LEXW,LEXWDS,X
S LEXFI="757.01"
N LEXTC S LEXTC=$$UPD^LEXRXXT3($G(LEXNAM),,"Repairing File #757.01 ""AWRD""") Q:LEXTC=1
S LEXBEG=$$NOW^XLFDT,(LEXNDS,LEXERR)=0,LEXFI=757.01,LEXIDX="AWRD",LEXIDXT="^LEX(757.01,""AWRD"",WORD,MC,EXP)"
S LEXTKN="" F S LEXTKN=$O(^LEX(LEXFI,LEXIDX,LEXTKN)) Q:'$L(LEXTKN) D
. S LEXEXCL=0 I $O(^LEX(757.04,"B",LEXTKN,0))>0 D
. . S LEXEXCL=$P($G(^LEX(757.04,+($O(^LEX(757.04,"B",LEXTKN,0))),0)),"^",2),LEXEXCL=$S(LEXEXCL="B":1,LEXEXCL="I":1,1:0)
. S LEXS1="" F S LEXS1=$O(^LEX(LEXFI,LEXIDX,LEXTKN,LEXS1)) Q:'$L(LEXS1) D
. . S LEXS2="" F S LEXS2=$O(^LEX(LEXFI,LEXIDX,LEXTKN,LEXS1,LEXS2)) Q:'$L(LEXS2) D
. . . ; Supplemental ^LEX(757.01,"AWRD",WORD,IEN,MC,SUP)
. . . ; Duplicates
. . . N LEXLO,LEXHI F D Q:+($G(LEXHI))'>+($G(LEXLO))
. . . . N DA,DIK S LEXLO=$O(^LEX(LEXFI,LEXIDX,LEXTKN,LEXS1,LEXS2,"")),LEXHI=$O(^LEX(LEXFI,LEXIDX,LEXTKN,LEXS1,LEXS2," "),-1) Q:(+LEXLO+LEXHI)'>0
. . . . I LEXLO>0,LEXHI>0,LEXHI>LEXLO S DA(1)=LEXS1,DA=LEXHI S DIK="^LEX(757.01,"_DA(1)_",5," D:$D(@(DIK_DA_",0)")) ^DIK
. . . I $D(^LEX(LEXFI,LEXIDX,LEXTKN,LEXS1,LEXS2))=10!($D(^LEX(LEXFI,LEXIDX,LEXTKN,LEXS1,LEXS2))=11) D
. . . . N LEXS3 S LEXS3="" F S LEXS3=$O(^LEX(LEXFI,LEXIDX,LEXTKN,LEXS1,LEXS2,LEXS3)) Q:'$L(LEXS3) D
. . . . . N LEXEXP,LEXMCE,LEXSTR S LEXNDS=+($G(LEXNDS))+1
. . . . . S LEXEXP=LEXS1,LEXMCE=+($$MCE^LEXRXXM(LEXEXP))
. . . . . S LEXSTR=$P($G(^LEX(LEXFI,+LEXEXP,5,+LEXS3,0)),"^",1)
. . . . . ; Redundant
. . . . . I $D(^LEX(LEXFI,LEXIDX,LEXTKN,LEXS1,LEXS2))=11 D
. . . . . . S LEXERR=+($G(LEXERR))+1 I '$D(ZTQUEUED) W !,"1",?8,LEXFI,?19,LEXIDX,?30,LEXTKN,?58," ",LEXS1,"/",LEXS2,"/",LEXS3
. . . . . . I '$D(LEXTEST) D
. . . . . . . N DA,DIK,LEXI,LEXIDX,LEXT,LEXWDS
. . . . . . . S LEXT=$P($G(^LEX(757.01,+LEXEXP,0)),"^",1),LEXI=0 D WORDS^LEXRXXP(LEXT,.LEXWDS) S LEXIDX="AWRD"
. . . . . . . Q:'$D(LEXWDS(LEXTKN)) S DA(1)=LEXEXP,DA=LEXS3,DIK="^LEX(757.01,"_DA(1)_",5," I $D(@(DIK_DA_",0)")) D
. . . . . . . . D ^DIK K ^LEX(LEXFI,LEXIDX,LEXTKN,LEXS1,LEXS2,LEXS3)
. . . . . ; Verify
. . . . . N LEXS D SUP^LEXRXXP(LEXEXP,.LEXS) I '$D(LEXS("S",LEXTKN,LEXS1,LEXS2,LEXS3)) D
. . . . . . Q:+LEXS3'>0 S LEXERR=+($G(LEXERR))+1 I '$D(ZTQUEUED) W !,"2",?8,LEXFI,?19,LEXIDX,?30,LEXTKN,?58," ",LEXS1,"/",LEXS2,"/",LEXS3
. . . . . . I '$D(LEXTEST) K ^LEX(LEXFI,LEXIDX,LEXTKN,LEXS1,LEXS2,LEXS3)
. . . ; Linked ^LEX(757.01,"AWRD",WORD,IEN,"LINKED")
. . . I $D(^LEX(LEXFI,LEXIDX,LEXTKN,LEXS1,LEXS2))=1,LEXS2="LINKED" D Q
. . . . N LEXEXP,LEXL S LEXEXP=LEXS1,LEXNDS=+($G(LEXNDS))+1 D LINK^LEXRXXP(LEXEXP,.LEXL)
. . . . Q:$D(LEXL("R",LEXTKN,+LEXEXP,"LINKED"))!($D(LEXL("L",LEXTKN,+LEXEXP,"LINKED")))
. . . . I '$D(LEXL("R",LEXTKN,+LEXEXP,"LINKED"))&($D(LEXL("L",LEXTKN,+LEXEXP,"LINKED"))) D
. . . . . S LEXERR=+($G(LEXERR))+1 I '$D(ZTQUEUED) W !,"3",?8,LEXFI,?19,LEXIDX,?30,LEXTKN,?58," ",LEXS1,"/",LEXS2
. . . . . I '$D(LEXTEST) K ^LEX(LEXFI,LEXIDX,LEXTKN,LEXS1,LEXS2)
. . . ; Words ^LEX(757.01,"AWRD",WORD,MC,IEN)
. . . I $D(^LEX(LEXFI,LEXIDX,LEXTKN,LEXS1,LEXS2))=1,+LEXS2>0,$D(^LEX(757.01,+LEXS2,0)) D Q
. . . . N LEXW,LEXIDX D AWRD^LEXRXXP(+LEXS2,.LEXW,1) S LEXIDX="AWRD" S LEXNDS=+($G(LEXNDS))+1
. . . . I '$D(LEXW("W",LEXTKN,LEXS1,LEXS2)) D Q
. . . . . S LEXERR=+($G(LEXERR))+1 I '$D(ZTQUEUED) W !,"4",?8,LEXFI,?19,LEXIDX,?30,LEXTKN,?58," ",LEXS2
. . . . . I '$D(LEXTEST) K ^LEX(LEXFI,LEXIDX,LEXTKN,LEXS1,LEXS2)
S LEXEXP=0 F S LEXEXP=$O(^LEX(LEXFI,LEXEXP)) Q:+LEXEXP'>0 D
. N DA,DIK,LEXS,LEXS1,LEXS1,LEXS3,LEXS4,X S DA=$G(LEXEXP),X=$P($G(^LEX(LEXFI,DA,0)),"^",1) Q:'$L(X)
. I $L(X),$D(^LEX(LEXFI,+($G(DA)),0)),$D(^LEX(LEXFI,+($G(DA)),1)) D
. . N LEXW,LEXTK,LEXM,LEXE S ^LEX(LEXFI,"B",$$UP^XLFSTR($E(X,1,63)),DA)=""
. . D AWRD^LEXRXXP(+DA,.LEXW,1) S LEXTK="" F S LEXTK=$O(LEXW("W",LEXTK)) Q:'$L(LEXTK) D
. . . S LEXM=0 F S LEXM=$O(LEXW("W",LEXTK,LEXM)) Q:+LEXM'>0 D
. . . . S LEXE=0 F S LEXE=$O(LEXW("W",LEXTK,LEXM,LEXE)) Q:+LEXE'>0 D
. . . . . Q:$D(^LEX(757.01,"AWRD",LEXTK,LEXM))
. . . . . S LEXERR=+($G(LEXERR))+1 I '$D(ZTQUEUED) W !,"5",?8,LEXFI,?19,LEXIDX,?30,"Missing ",$E(LEXTK,1,18),?58," ",LEXM,"/",LEXE
. . . . . S ^LEX(757.01,"AWRD",LEXTK,LEXM,LEXE)=""
. K LEXS D SUP^LEXRXXP(LEXEXP,.LEXS)
. S LEXS1="" F S LEXS1=$O(LEXS("S",LEXS1)) Q:'$L(LEXS1) S LEXS2="" F S LEXS2=$O(LEXS("S",LEXS1,LEXS2)) Q:'$L(LEXS2) D
. . S LEXS3="" F S LEXS3=$O(LEXS("S",LEXS1,LEXS2,LEXS3)) Q:'$L(LEXS3) S LEXS4="" F S LEXS4=$O(LEXS("S",LEXS1,LEXS2,LEXS3,LEXS4)) Q:'$L(LEXS4) D
. . . I '$D(^LEX(757.01,"AWRD",LEXS1,LEXS2,LEXS3,LEXS4)) D
. . . . S LEXERR=+($G(LEXERR))+1 I '$D(ZTQUEUED) W !,"6",?8,LEXFI,?19,LEXIDX,?30,"Missing ",$E(LEXS1,1,18),?58," ",LEXS2,"/",LEXS3,"/",LEXS4
. . . . S ^LEX(757.01,"AWRD",LEXS1,LEXS2,LEXS3,LEXS4)=""
. K LEXS D LINK^LEXRXXP(LEXEXP,.LEXS)
. S LEXS1="" F S LEXS1=$O(LEXS("L",LEXS1)) Q:'$L(LEXS1) S LEXS2="" F S LEXS2=$O(LEXS("L",LEXS1,LEXS2)) Q:'$L(LEXS2) D
. . S LEXS3="" F S LEXS3=$O(LEXS("L",LEXS1,LEXS2,LEXS3)) Q:'$L(LEXS3) D
. . . I '$D(^LEX(757.01,"AWRD",LEXS1,LEXS2,LEXS3)) D
. . . . S LEXERR=+($G(LEXERR))+1 I '$D(ZTQUEUED) W !,"7",?8,LEXFI,?19,LEXIDX,?30,"Missing ",$E(LEXS1,1,18),?58," ",LEXS2,"/",LEXS3
. . . . S ^LEX(757.01,"AWRD",LEXS1,LEXS2,LEXS3)=""
. S LEXS1="" F S LEXS1=$O(LEXS("R",LEXS1)) Q:'$L(LEXS1) S LEXS2="" F S LEXS2=$O(LEXS("R",LEXS1,LEXS2)) Q:'$L(LEXS2) D
. . S LEXS3="" F S LEXS3=$O(LEXS("R",LEXS1,LEXS2,LEXS3)) Q:'$L(LEXS3) D
. . . I '$D(^LEX(757.01,"AWRD",LEXS1,LEXS2)) D
. . . . Q:$D(^LEX(757.04,"ACTION",LEXS1,"B"))!($D(^LEX(757.04,"ACTION",LEXS1,"I")))
. . . . S LEXERR=+($G(LEXERR))+1 I '$D(ZTQUEUED) W !,"8",?8,LEXFI,?19,LEXIDX,?30,"Missing ",$E(LEXS1,1,18),?58," ",LEXS2,"/",LEXS3
. . . . S ^LEX(757.01,"AWRD",LEXS1,LEXS2,LEXS3)=""
. K LEXS S LEXS=0 F S LEXS=$O(^LEX(LEXFI,LEXEXP,5,LEXS)) Q:+LEXS'>0 D
. . N DA,DIK S DA(1)=LEXEXP,DA=LEXS,DIK="^LEX(757.01,"_DA(1)_",5," D IX1^DIK
S LEXEXP=0 F S LEXEXP=$O(^LEX(757.05,LEXEXP)) Q:+LEXEXP'>0 D
. N DA,DIK S DA=LEXEXP,DIK="^LEX(757.05," D IX1^DIK
S LEXERR=$S(+LEXERR>0:LEXERR,1:"") I '$D(ZTQUEUED) W !,$J(LEXERR,5),?8,LEXFI,?19,LEXIDX,?30,LEXIDXT
S LEXEND=$$NOW^XLFDT,LEXELP=$$FMDIFF^XLFDT(LEXEND,LEXBEG,3)
S:$E(LEXELP,1)=" "&($E(LEXELP,3)=":") LEXELP=$TR(LEXELP," ","0")
D REP^LEXRXXS(LEXFI,LEXFI,LEXIDX,LEXNDS,LEXERR,LEXIDXT,LEXELP)
Q
;
; Miscellaneous
CLR ; Clear
K LEXNAM,LEXTEST,ZTQUEUED
Q
LEXRXC2 ;ISL/KER - Re-Index 757.01 AMC/AWRD ;08/17/2011
+1 ;;2.0;LEXICON UTILITY;**81**;Sep 23, 1996;Build 10
+2 ;
+3 ; Global Variables
+4 ; ^LEX( SACC 1.3
+5 ; ^LEX(757.01, SACC 1.3
+6 ; ^LEX(757.04, SACC 1.3
+7 ; ^LEX(757.05, SACC 1.3
+8 ;
+9 ; External References
+10 ; ^DIK ICR 10013
+11 ; IX1^DIK ICR 10013
+12 ; $$FMDIFF^XLFDT ICR 10103
+13 ; $$NOW^XLFDT ICR 10103
+14 ; $$UP^XLFSTR ICR 10104
+15 ;
+16 ; Local Variables NEWed or KILLed Elsewhere
+17 ; LEXNAM Task name NEWed/KILLed by LEXRXXT
+18 ; LEXTEST Test variable NEWed/KILLed by Developer
+19 ; ZTQUEUED Task flag NEWed/KILLed by Taskman
+20 ;
+21 QUIT
+22 ; NOTES:
+23 ;
+24 ; The AMC cross-references is used to create the AWRD
+25 ; cross-reference, hence the AMC cross-reference must
+26 ; be repaired/re-indexed before AWRD.
+27 ;
+28 ; The AWRD cross-references is used to create the ASL
+29 ; cross-reference, hence the AWRD cross-reference must
+30 ; be repaired/re-indexed before ASL.
+31 ;
+32 ; Re-indexing file 757.01 will Kill off all Linked Words
+33 ; from the Replacement Word file #757.05, hence after
+34 ; repairing/re-indexing file 757.01 you should immediatley
+35 ; re-index file 757.05.
+36 ;
EN ; Main Entry Point
R75701 ; Repair file 757.01
+1 DO RAMC
DO RAWRD
QUIT
RAMC ; Index ^LEX(757.01,"AMC",MC,IEN)
+1 NEW DA,DIK,LEXBEG,LEXDIF,LEXELP,LEXEND,LEXERR,LEXFI,LEXIDX,LEXIDXT,LEXIEN,LEXMC,LEXNDS,LEXOK,LEXSTR
+2 SET LEXFI="757.01"
+3 NEW LEXTC
SET LEXTC=$$UPD^LEXRXXT3($GET(LEXNAM),,"Repairing File #757.01 ""AMC""")
IF LEXTC=1
QUIT
+4 SET LEXBEG=$$NOW^XLFDT
SET (LEXNDS,LEXERR)=0
SET LEXSTR=""
SET LEXFI=757.01
SET LEXIDX="AMC"
SET LEXIDXT="^LEX(757.01,""AMC"",MC,IEN)"
+5 FOR
SET LEXSTR=$ORDER(^LEX(LEXFI,LEXIDX,LEXSTR))
IF '$LENGTH(LEXSTR)
QUIT
Begin DoDot:1
+6 NEW LEXIEN
SET LEXIEN=0
FOR
SET LEXIEN=$ORDER(^LEX(LEXFI,LEXIDX,LEXSTR,LEXIEN))
IF +LEXIEN'>0
QUIT
Begin DoDot:2
+7 SET LEXNDS=LEXNDS+1
+8 IF '$DATA(^LEX(LEXFI,LEXIEN,0))
Begin DoDot:3
+9 SET LEXERR=LEXERR+1
IF '$DATA(LEXTEST)
KILL ^LEX(LEXFI,LEXIDX,LEXSTR,LEXIEN)
+10 IF '$DATA(ZTQUEUED)
WRITE !,?8,LEXFI,?19,LEXIDX,?30,LEXSTR,?58," ",LEXIEN
End DoDot:3
QUIT
+11 NEW LEXOK,LEXMC
SET LEXMC=+($PIECE($GET(^LEX(LEXFI,LEXIEN,1)),"^",1))
+12 SET LEXOK=0
IF LEXMC=LEXSTR
SET LEXOK=1
IF 'LEXOK
Begin DoDot:3
+13 SET LEXERR=LEXERR+1
IF '$DATA(LEXTEST)
KILL ^LEX(LEXFI,LEXIDX,LEXSTR,LEXIEN)
IF +LEXMC>0
SET ^LEX(LEXFI,LEXIDX,+LEXMC,LEXIEN)=""
+14 IF '$DATA(ZTQUEUED)
WRITE !,?8,LEXFI,?19,LEXIDX,?30,LEXSTR,?58," ",LEXIEN
End DoDot:3
End DoDot:2
End DoDot:1
+15 SET LEXIEN=0
FOR
SET LEXIEN=$ORDER(^LEX(LEXFI,LEXIEN))
IF +LEXIEN'>0
QUIT
Begin DoDot:1
+16 NEW DA,DIK,X
SET DA=LEXIEN
SET X=+($GET(^LEX(LEXFI,DA,1)))
IF '$LENGTH(X)
QUIT
+17 IF '$DATA(^LEX(LEXFI,LEXIDX,X,DA))
Begin DoDot:2
+18 SET LEXERR=LEXERR+1
IF '$DATA(ZTQUEUED)
WRITE !,?8,LEXFI,?19,LEXIDX,?30,"Missing",?58," ",DA
End DoDot:2
+19 IF $LENGTH(X)
SET ^LEX(LEXFI,LEXIDX,X,DA)=""
+20 SET ^LEX(LEXFI,LEXIDX,X,DA)=""
End DoDot:1
+21 SET LEXERR=$SELECT(+LEXERR>0:LEXERR,1:"")
IF '$DATA(ZTQUEUED)
WRITE !,$JUSTIFY(LEXERR,5),?8,LEXFI,?19,LEXIDX,?30,LEXIDXT
+22 SET LEXEND=$$NOW^XLFDT
SET LEXELP=$$FMDIFF^XLFDT(LEXEND,LEXBEG,3)
+23 IF $EXTRACT(LEXELP,1)=" "&($EXTRACT(LEXELP,3)="
SET LEXELP=$TRANSLATE(LEXELP," ","0")
+24 DO REP^LEXRXXS(LEXFI,LEXFI,LEXIDX,LEXNDS,LEXERR,LEXIDXT,LEXELP)
+25 QUIT
RAWRD ; Index ^LEX(757.01,"AWRD",WORD,MC,EXP)
+1 NEW DA,DIK,LEXBEG,LEXDIF,LEXE,LEXELP,LEXEND,LEXERR,LEXEXCL,LEXEXP,LEXFI,LEXHI,LEXI,LEXIDX,LEXIDXT,LEXL,LEXLO,LEXM
+2 NEW LEXMCE,LEXNDS,LEXS,LEXS1,LEXS2,LEXS3,LEXS4,LEXSTR,LEXT,LEXTC,LEXTK,LEXTKN,LEXTNG,LEXW,LEXWDS,X
+3 SET LEXFI="757.01"
+4 NEW LEXTC
SET LEXTC=$$UPD^LEXRXXT3($GET(LEXNAM),,"Repairing File #757.01 ""AWRD""")
IF LEXTC=1
QUIT
+5 SET LEXBEG=$$NOW^XLFDT
SET (LEXNDS,LEXERR)=0
SET LEXFI=757.01
SET LEXIDX="AWRD"
SET LEXIDXT="^LEX(757.01,""AWRD"",WORD,MC,EXP)"
+6 SET LEXTKN=""
FOR
SET LEXTKN=$ORDER(^LEX(LEXFI,LEXIDX,LEXTKN))
IF '$LENGTH(LEXTKN)
QUIT
Begin DoDot:1
+7 SET LEXEXCL=0
IF $ORDER(^LEX(757.04,"B",LEXTKN,0))>0
Begin DoDot:2
+8 SET LEXEXCL=$PIECE($GET(^LEX(757.04,+($ORDER(^LEX(757.04,"B",LEXTKN,0))),0)),"^",2)
SET LEXEXCL=$SELECT(LEXEXCL="B":1,LEXEXCL="I":1,1:0)
End DoDot:2
+9 SET LEXS1=""
FOR
SET LEXS1=$ORDER(^LEX(LEXFI,LEXIDX,LEXTKN,LEXS1))
IF '$LENGTH(LEXS1)
QUIT
Begin DoDot:2
+10 SET LEXS2=""
FOR
SET LEXS2=$ORDER(^LEX(LEXFI,LEXIDX,LEXTKN,LEXS1,LEXS2))
IF '$LENGTH(LEXS2)
QUIT
Begin DoDot:3
+11 ; Supplemental ^LEX(757.01,"AWRD",WORD,IEN,MC,SUP)
+12 ; Duplicates
+13 NEW LEXLO,LEXHI
FOR
Begin DoDot:4
+14 NEW DA,DIK
SET LEXLO=$ORDER(^LEX(LEXFI,LEXIDX,LEXTKN,LEXS1,LEXS2,""))
SET LEXHI=$ORDER(^LEX(LEXFI,LEXIDX,LEXTKN,LEXS1,LEXS2," "),-1)
IF (+LEXLO+LEXHI)'>0
QUIT
+15 IF LEXLO>0
IF LEXHI>0
IF LEXHI>LEXLO
SET DA(1)=LEXS1
SET DA=LEXHI
SET DIK="^LEX(757.01,"_DA(1)_",5,"
IF $DATA(@(DIK_DA_",0)"))
DO ^DIK
End DoDot:4
IF +($GET(LEXHI))'>+($GET(LEXLO))
QUIT
+16 IF $DATA(^LEX(LEXFI,LEXIDX,LEXTKN,LEXS1,LEXS2))=10!($DATA(^LEX(LEXFI,LEXIDX,LEXTKN,LEXS1,LEXS2))=11)
Begin DoDot:4
+17 NEW LEXS3
SET LEXS3=""
FOR
SET LEXS3=$ORDER(^LEX(LEXFI,LEXIDX,LEXTKN,LEXS1,LEXS2,LEXS3))
IF '$LENGTH(LEXS3)
QUIT
Begin DoDot:5
+18 NEW LEXEXP,LEXMCE,LEXSTR
SET LEXNDS=+($GET(LEXNDS))+1
+19 SET LEXEXP=LEXS1
SET LEXMCE=+($$MCE^LEXRXXM(LEXEXP))
+20 SET LEXSTR=$PIECE($GET(^LEX(LEXFI,+LEXEXP,5,+LEXS3,0)),"^",1)
+21 ; Redundant
+22 IF $DATA(^LEX(LEXFI,LEXIDX,LEXTKN,LEXS1,LEXS2))=11
Begin DoDot:6
+23 SET LEXERR=+($GET(LEXERR))+1
IF '$DATA(ZTQUEUED)
WRITE !,"1",?8,LEXFI,?19,LEXIDX,?30,LEXTKN,?58," ",LEXS1,"/",LEXS2,"/",LEXS3
+24 IF '$DATA(LEXTEST)
Begin DoDot:7
+25 NEW DA,DIK,LEXI,LEXIDX,LEXT,LEXWDS
+26 SET LEXT=$PIECE($GET(^LEX(757.01,+LEXEXP,0)),"^",1)
SET LEXI=0
DO WORDS^LEXRXXP(LEXT,.LEXWDS)
SET LEXIDX="AWRD"
+27 IF '$DATA(LEXWDS(LEXTKN))
QUIT
SET DA(1)=LEXEXP
SET DA=LEXS3
SET DIK="^LEX(757.01,"_DA(1)_",5,"
IF $DATA(@(DIK_DA_",0)"))
Begin DoDot:8
+28 DO ^DIK
KILL ^LEX(LEXFI,LEXIDX,LEXTKN,LEXS1,LEXS2,LEXS3)
End DoDot:8
End DoDot:7
End DoDot:6
+29 ; Verify
+30 NEW LEXS
DO SUP^LEXRXXP(LEXEXP,.LEXS)
IF '$DATA(LEXS("S",LEXTKN,LEXS1,LEXS2,LEXS3))
Begin DoDot:6
+31 IF +LEXS3'>0
QUIT
SET LEXERR=+($GET(LEXERR))+1
IF '$DATA(ZTQUEUED)
WRITE !,"2",?8,LEXFI,?19,LEXIDX,?30,LEXTKN,?58," ",LEXS1,"/",LEXS2,"/",LEXS3
+32 IF '$DATA(LEXTEST)
KILL ^LEX(LEXFI,LEXIDX,LEXTKN,LEXS1,LEXS2,LEXS3)
End DoDot:6
End DoDot:5
End DoDot:4
+33 ; Linked ^LEX(757.01,"AWRD",WORD,IEN,"LINKED")
+34 IF $DATA(^LEX(LEXFI,LEXIDX,LEXTKN,LEXS1,LEXS2))=1
IF LEXS2="LINKED"
Begin DoDot:4
+35 NEW LEXEXP,LEXL
SET LEXEXP=LEXS1
SET LEXNDS=+($GET(LEXNDS))+1
DO LINK^LEXRXXP(LEXEXP,.LEXL)
+36 IF $DATA(LEXL("R",LEXTKN,+LEXEXP,"LINKED"))!($DATA(LEXL("L",LEXTKN,+LEXEXP,"LINKED")))
QUIT
+37 IF '$DATA(LEXL("R",LEXTKN,+LEXEXP,"LINKED"))&($DATA(LEXL("L",LEXTKN,+LEXEXP,"LINKED")))
Begin DoDot:5
+38 SET LEXERR=+($GET(LEXERR))+1
IF '$DATA(ZTQUEUED)
WRITE !,"3",?8,LEXFI,?19,LEXIDX,?30,LEXTKN,?58," ",LEXS1,"/",LEXS2
+39 IF '$DATA(LEXTEST)
KILL ^LEX(LEXFI,LEXIDX,LEXTKN,LEXS1,LEXS2)
End DoDot:5
End DoDot:4
QUIT
+40 ; Words ^LEX(757.01,"AWRD",WORD,MC,IEN)
+41 IF $DATA(^LEX(LEXFI,LEXIDX,LEXTKN,LEXS1,LEXS2))=1
IF +LEXS2>0
IF $DATA(^LEX(757.01,+LEXS2,0))
Begin DoDot:4
+42 NEW LEXW,LEXIDX
DO AWRD^LEXRXXP(+LEXS2,.LEXW,1)
SET LEXIDX="AWRD"
SET LEXNDS=+($GET(LEXNDS))+1
+43 IF '$DATA(LEXW("W",LEXTKN,LEXS1,LEXS2))
Begin DoDot:5
+44 SET LEXERR=+($GET(LEXERR))+1
IF '$DATA(ZTQUEUED)
WRITE !,"4",?8,LEXFI,?19,LEXIDX,?30,LEXTKN,?58," ",LEXS2
+45 IF '$DATA(LEXTEST)
KILL ^LEX(LEXFI,LEXIDX,LEXTKN,LEXS1,LEXS2)
End DoDot:5
QUIT
End DoDot:4
QUIT
End DoDot:3
End DoDot:2
End DoDot:1
+46 SET LEXEXP=0
FOR
SET LEXEXP=$ORDER(^LEX(LEXFI,LEXEXP))
IF +LEXEXP'>0
QUIT
Begin DoDot:1
+47 NEW DA,DIK,LEXS,LEXS1,LEXS1,LEXS3,LEXS4,X
SET DA=$GET(LEXEXP)
SET X=$PIECE($GET(^LEX(LEXFI,DA,0)),"^",1)
IF '$LENGTH(X)
QUIT
+48 IF $LENGTH(X)
IF $DATA(^LEX(LEXFI,+($GET(DA)),0))
IF $DATA(^LEX(LEXFI,+($GET(DA)),1))
Begin DoDot:2
+49 NEW LEXW,LEXTK,LEXM,LEXE
SET ^LEX(LEXFI,"B",$$UP^XLFSTR($EXTRACT(X,1,63)),DA)=""
+50 DO AWRD^LEXRXXP(+DA,.LEXW,1)
SET LEXTK=""
FOR
SET LEXTK=$ORDER(LEXW("W",LEXTK))
IF '$LENGTH(LEXTK)
QUIT
Begin DoDot:3
+51 SET LEXM=0
FOR
SET LEXM=$ORDER(LEXW("W",LEXTK,LEXM))
IF +LEXM'>0
QUIT
Begin DoDot:4
+52 SET LEXE=0
FOR
SET LEXE=$ORDER(LEXW("W",LEXTK,LEXM,LEXE))
IF +LEXE'>0
QUIT
Begin DoDot:5
+53 IF $DATA(^LEX(757.01,"AWRD",LEXTK,LEXM))
QUIT
+54 SET LEXERR=+($GET(LEXERR))+1
IF '$DATA(ZTQUEUED)
WRITE !,"5",?8,LEXFI,?19,LEXIDX,?30,"Missing ",$EXTRACT(LEXTK,1,18),?58," ",LEXM,"/",LEXE
+55 SET ^LEX(757.01,"AWRD",LEXTK,LEXM,LEXE)=""
End DoDot:5
End DoDot:4
End DoDot:3
End DoDot:2
+56 KILL LEXS
DO SUP^LEXRXXP(LEXEXP,.LEXS)
+57 SET LEXS1=""
FOR
SET LEXS1=$ORDER(LEXS("S",LEXS1))
IF '$LENGTH(LEXS1)
QUIT
SET LEXS2=""
FOR
SET LEXS2=$ORDER(LEXS("S",LEXS1,LEXS2))
IF '$LENGTH(LEXS2)
QUIT
Begin DoDot:2
+58 SET LEXS3=""
FOR
SET LEXS3=$ORDER(LEXS("S",LEXS1,LEXS2,LEXS3))
IF '$LENGTH(LEXS3)
QUIT
SET LEXS4=""
FOR
SET LEXS4=$ORDER(LEXS("S",LEXS1,LEXS2,LEXS3,LEXS4))
IF '$LENGTH(LEXS4)
QUIT
Begin DoDot:3
+59 IF '$DATA(^LEX(757.01,"AWRD",LEXS1,LEXS2,LEXS3,LEXS4))
Begin DoDot:4
+60 SET LEXERR=+($GET(LEXERR))+1
IF '$DATA(ZTQUEUED)
WRITE !,"6",?8,LEXFI,?19,LEXIDX,?30,"Missing ",$EXTRACT(LEXS1,1,18),?58," ",LEXS2,"/",LEXS3,"/",LEXS4
+61 SET ^LEX(757.01,"AWRD",LEXS1,LEXS2,LEXS3,LEXS4)=""
End DoDot:4
End DoDot:3
End DoDot:2
+62 KILL LEXS
DO LINK^LEXRXXP(LEXEXP,.LEXS)
+63 SET LEXS1=""
FOR
SET LEXS1=$ORDER(LEXS("L",LEXS1))
IF '$LENGTH(LEXS1)
QUIT
SET LEXS2=""
FOR
SET LEXS2=$ORDER(LEXS("L",LEXS1,LEXS2))
IF '$LENGTH(LEXS2)
QUIT
Begin DoDot:2
+64 SET LEXS3=""
FOR
SET LEXS3=$ORDER(LEXS("L",LEXS1,LEXS2,LEXS3))
IF '$LENGTH(LEXS3)
QUIT
Begin DoDot:3
+65 IF '$DATA(^LEX(757.01,"AWRD",LEXS1,LEXS2,LEXS3))
Begin DoDot:4
+66 SET LEXERR=+($GET(LEXERR))+1
IF '$DATA(ZTQUEUED)
WRITE !,"7",?8,LEXFI,?19,LEXIDX,?30,"Missing ",$EXTRACT(LEXS1,1,18),?58," ",LEXS2,"/",LEXS3
+67 SET ^LEX(757.01,"AWRD",LEXS1,LEXS2,LEXS3)=""
End DoDot:4
End DoDot:3
End DoDot:2
+68 SET LEXS1=""
FOR
SET LEXS1=$ORDER(LEXS("R",LEXS1))
IF '$LENGTH(LEXS1)
QUIT
SET LEXS2=""
FOR
SET LEXS2=$ORDER(LEXS("R",LEXS1,LEXS2))
IF '$LENGTH(LEXS2)
QUIT
Begin DoDot:2
+69 SET LEXS3=""
FOR
SET LEXS3=$ORDER(LEXS("R",LEXS1,LEXS2,LEXS3))
IF '$LENGTH(LEXS3)
QUIT
Begin DoDot:3
+70 IF '$DATA(^LEX(757.01,"AWRD",LEXS1,LEXS2))
Begin DoDot:4
+71 IF $DATA(^LEX(757.04,"ACTION",LEXS1,"B"))!($DATA(^LEX(757.04,"ACTION",LEXS1,"I")))
QUIT
+72 SET LEXERR=+($GET(LEXERR))+1
IF '$DATA(ZTQUEUED)
WRITE !,"8",?8,LEXFI,?19,LEXIDX,?30,"Missing ",$EXTRACT(LEXS1,1,18),?58," ",LEXS2,"/",LEXS3
+73 SET ^LEX(757.01,"AWRD",LEXS1,LEXS2,LEXS3)=""
End DoDot:4
End DoDot:3
End DoDot:2
+74 KILL LEXS
SET LEXS=0
FOR
SET LEXS=$ORDER(^LEX(LEXFI,LEXEXP,5,LEXS))
IF +LEXS'>0
QUIT
Begin DoDot:2
+75 NEW DA,DIK
SET DA(1)=LEXEXP
SET DA=LEXS
SET DIK="^LEX(757.01,"_DA(1)_",5,"
DO IX1^DIK
End DoDot:2
End DoDot:1
+76 SET LEXEXP=0
FOR
SET LEXEXP=$ORDER(^LEX(757.05,LEXEXP))
IF +LEXEXP'>0
QUIT
Begin DoDot:1
+77 NEW DA,DIK
SET DA=LEXEXP
SET DIK="^LEX(757.05,"
DO IX1^DIK
End DoDot:1
+78 SET LEXERR=$SELECT(+LEXERR>0:LEXERR,1:"")
IF '$DATA(ZTQUEUED)
WRITE !,$JUSTIFY(LEXERR,5),?8,LEXFI,?19,LEXIDX,?30,LEXIDXT
+79 SET LEXEND=$$NOW^XLFDT
SET LEXELP=$$FMDIFF^XLFDT(LEXEND,LEXBEG,3)
+80 IF $EXTRACT(LEXELP,1)=" "&($EXTRACT(LEXELP,3)="
SET LEXELP=$TRANSLATE(LEXELP," ","0")
+81 DO REP^LEXRXXS(LEXFI,LEXFI,LEXIDX,LEXNDS,LEXERR,LEXIDXT,LEXELP)
+82 QUIT
+83 ;
+84 ; Miscellaneous
CLR ; Clear
+1 KILL LEXNAM,LEXTEST,ZTQUEUED
+2 QUIT