Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: LEXRXG

LEXRXG.m

Go to the documentation of this file.
LEXRXG ;ISL/KER - Re-Index 757.33 B/C/G ;05/23/2017
 ;;2.0;LEXICON UTILITY;**81,80,103**;Sep 23, 1996;Build 2
 ;               
 ; Global Variables
 ;    ^LEX(757.32)        SACC 1.3
 ;    ^LEX(757.33)        SACC 1.3
 ;    ^TMP("LEXRX",$J)    SACC 2.3.2.5.1
 ;               
 ; External References
 ;    FILE^DID            ICR   2052
 ;    IX1^DIK             ICR  10013
 ;    IX2^DIK             ICR  10013
 ;    IXALL^DIK           ICR  10013
 ;    $$DT^XLFDT          ICR  10103
 ;    $$FMADD^XLFDT       ICR  10103
 ;    $$FMDIFF^XLFDT      ICR  10103
 ;    $$FMTE^XLFDT        ICR  10103
 ;    $$NOW^XLFDT         ICR  10103
 ;               
 ; Local Variables NEWed or KILLed Elsewhere
 ;     LEXFIX     Fix Index flag  NEWed/KILLed by LEXRXXT
 ;     LEXNAM     Task name       NEWed/KILLed by LEXRXXT
 ;     LEXSET     Re-Index flag   NEWed/KILLed by LEXRXXT
 ;     LEXQ       Quiet flat      NEWed/KILLed by LEXRXXT2
 ;     LEXTEST    Test variable   NEWed/KILLed by Developer
 ;     ZTQUEUED   Task flag       NEWed/KILLed by Taskman
 ;               
 Q
EN ; Main Entry Point
R75733 ; Repair file 757.33
 D RB,RC,RG,R75733^LEXRXG2,R75733^LEXRXG3,SET
 Q
RB ;   Index    ^LEX(757.33,"B",MID,IEN) 
 N DA,DIK,LEXBEG,LEXDIF,LEXELP,LEXEND,LEXERR,LEXFI,LEXIDX,LEXIDXT,LEXIEN,LEXMC,LEXNDS,LEXOK,LEXSTR
 S LEXFI="757.33"
 N LEXTC S LEXTC=$$UPD^LEXRXXT3($G(LEXNAM),,"Repairing File #757.33 ""B""") Q:LEXTC=1
 S LEXBEG=$$NOW^XLFDT,(LEXNDS,LEXERR)=0,LEXSTR="",LEXFI=757.33,LEXIDX="B",LEXIDXT="^LEX(757.33,""B"",MID,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 N LEXOK,LEXID S LEXID=$P($G(^LEX(LEXFI,LEXIEN,0)),"^",1)
 . . S LEXOK=0 S:LEXID=LEXSTR LEXOK=1 I 'LEXOK D
 . . . S LEXERR=LEXERR+1 K:'$D(LEXTEST) ^LEX(LEXFI,LEXIDX,LEXSTR,LEXIEN)
 . . . S:$L(LEXID) ^LEX(LEXFI,LEXIDX,LEXID,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=$P($G(^LEX(LEXFI,DA,0)),"^",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 ",X,?58,"  ",DA
 . S:$L(X) ^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
 H 2 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
RC ;   Index    ^LEX(757.33,"C",DEF,SRC,ORD,TAR,IEN)
 N DA,DIK,LEXBEG,LEXDIF,LEXELP,LEXEND,LEXERR,LEXFI,LEXIDX,LEXIDXT,LEXIEN,LEXMC,LEXNDS,LEXOK,LEXDEF
 S LEXFI="757.33"
 N LEXTC S LEXTC=$$UPD^LEXRXXT3($G(LEXNAM),,"Repairing File #757.33 ""C""") Q:LEXTC=1
 S LEXBEG=$$NOW^XLFDT,(LEXNDS,LEXERR)=0,LEXDEF="",LEXFI=757.33,LEXIDX="C",LEXIDXT="^LEX(757.33,""C"",EXP,IEN)"
 F  S LEXDEF=$O(^LEX(LEXFI,LEXIDX,LEXDEF)) Q:'$L(LEXDEF)  D
 . N LEXSRC S LEXSRC="" F  S LEXSRC=$O(^LEX(LEXFI,LEXIDX,LEXDEF,LEXSRC)) Q:'$L(LEXSRC)  D
 . . N LEXORD S LEXORD="" F  S LEXORD=$O(^LEX(LEXFI,LEXIDX,LEXDEF,LEXSRC,LEXORD)) Q:'$L(LEXORD)  D
 . . . N LEXTAR S LEXTAR="" F  S LEXTAR=$O(^LEX(LEXFI,LEXIDX,LEXDEF,LEXSRC,LEXORD,LEXTAR)) Q:'$L(LEXTAR)  D
 . . . . N LEXIEN S LEXIEN="" F  S LEXIEN=$O(^LEX(LEXFI,LEXIDX,LEXDEF,LEXSRC,LEXORD,LEXTAR,LEXIEN)) Q:'$L(LEXIEN)  D
 . . . . . S LEXNDS=LEXNDS+1 N LEXN0,LEXN3,LEXD,LEXS,LEXO,LEXT S LEXN0=$G(^LEX(757.33,+LEXIEN,0)),LEXN3=$G(^LEX(757.33,+LEXIEN,3))
 . . . . . S LEXD=$P(LEXN0,"^",4),LEXS=$P(LEXN0,"^",2),LEXO=$P(LEXN3,"^",1),LEXT=$P(LEXN0,"^",3)
 . . . . . Q:'$L(LEXD)  Q:'$L(LEXS)  Q:'$L(LEXO)  Q:'$L(LEXT)
 . . . . . I LEXDEF'=LEXD!(LEXSRC'=LEXS)!(LEXORD'=LEXO)!(LEXTAR'=LEXT) D
 . . . . . . N DA S DA=LEXIEN S LEXERR=LEXERR+1
 . . . . . . K ^LEX(LEXFI,LEXIDX,LEXDEF,LEXSRC,LEXORD,LEXTAR,LEXIEN)
 . . . . . . S ^LEX(LEXFI,LEXIDX,LEXD,LEXS,LEXO,LEXT,DA)=""
 . . . . . . I '$D(ZTQUEUED) W !,?8,LEXFI,?19,LEXIDX,?30,"Invalid ",LEXSRC,"/",LEXTAR,?58,"  ",DA
 S LEXIEN=0 F  S LEXIEN=$O(^LEX(LEXFI,LEXIEN)) Q:+LEXIEN'>0  D
 . N DA,DIK,X,LEXN0,LEXN3,LEXD,LEXS,LEXO,LEXT S DA=LEXIEN,LEXN0=$G(^LEX(757.33,+LEXIEN,0)),LEXN3=$G(^LEX(757.33,+LEXIEN,3))
 . S LEXD=$P(LEXN0,"^",4),LEXS=$P(LEXN0,"^",2),LEXO=$P(LEXN3,"^",1),LEXT=$P(LEXN0,"^",3) Q:'$L(LEXD)  Q:'$L(LEXS)  Q:'$L(LEXO)  Q:'$L(LEXT)
 . I '$D(^LEX(LEXFI,LEXIDX,LEXD,LEXS,LEXO,LEXT,DA)) D
 . . S LEXERR=LEXERR+1 I '$D(ZTQUEUED) W !,?8,LEXFI,?19,LEXIDX,?30,"Missing ",LEXS,"/",LEXT,?58,"  ",DA
 . S ^LEX(LEXFI,LEXIDX,LEXD,LEXS,LEXO,LEXT,DA)=""
 S LEXERR=$S(+LEXERR>0:LEXERR,1:"") I '$D(ZTQUEUED) W !,$J(LEXERR,5),?8,LEXFI,?19,LEXIDX,?30,LEXIDXT
 H 2 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
RG ;   Index    ^LEX(757.33,"G",MAP,EFF,STA,IEN,HIS)
 N DA,DIK,LEXBEG,LEXDIF,LEXELP,LEXEND,LEXERR,LEXFI,LEXIDX,LEXIDXT,LEXIEN,LEXMC,LEXNDS,LEXOK,LEXDEF
 S LEXFI="757.33"
 N LEXTC S LEXTC=$$UPD^LEXRXXT3($G(LEXNAM),,"Repairing File #757.33 ""G""") Q:LEXTC=1
 S LEXBEG=$$NOW^XLFDT,(LEXNDS,LEXERR)=0,LEXDEF="",LEXFI=757.33,LEXIDX="G",LEXIDXT="^LEX(757.33,""G"",EXP,IEN)"
 F  S LEXDEF=$O(^LEX(LEXFI,LEXIDX,LEXDEF)) Q:'$L(LEXDEF)  D
 . N LEXEFF S LEXEFF="" F  S LEXEFF=$O(^LEX(LEXFI,LEXIDX,LEXDEF,LEXEFF)) Q:'$L(LEXEFF)  D
 . . N LEXSTA S LEXSTA="" F  S LEXSTA=$O(^LEX(LEXFI,LEXIDX,LEXDEF,LEXEFF,LEXSTA)) Q:'$L(LEXSTA)  D
 . . . N LEXIEN S LEXIEN=0 F  S LEXIEN=$O(^LEX(LEXFI,LEXIDX,LEXDEF,LEXEFF,LEXSTA,LEXIEN)) Q:+LEXIEN'>0  D
 . . . . N LEXHIS S LEXHIS=0 F  S LEXHIS=$O(^LEX(LEXFI,LEXIDX,LEXDEF,LEXEFF,LEXSTA,LEXIEN,LEXHIS)) Q:+LEXHIS'>0  D
 . . . . . S LEXNDS=LEXNDS+1 N LEXN0,LEXHN,LEXD,LEXE,LEXS
 . . . . . S LEXN0=$G(^LEX(757.33,+LEXIEN,0)),LEXNH=$G(^LEX(757.33,+LEXIEN,2,+LEXHIS,0))
 . . . . . S LEXD=$P(LEXN0,"^",1),LEXE=$P(LEXNH,"^",1),LEXS=$P(LEXNH,"^",2)
 . . . . . Q:'$L(LEXD)  Q:'$L(LEXE)  Q:'$L(LEXS)
 . . . . . I LEXDEF'=LEXD!(LEXEFF'=LEXE)!(LEXSTA'=LEXS) D
 . . . . . . N DA,LEXED,LEXSD S DA(1)=LEXIEN,DA=LEXHIS S LEXERR=LEXERR+1
 . . . . . . S LEXED=$TR($$FMTE^XLFDT(LEXEFF,"5DZ"),"@"," ")
 . . . . . . S LEXSD=$S(+LEXSTA>0:"Active",1:"Inactive")
 . . . . . . K ^LEX(757.33,"G",LEXDEF,LEXEFF,LEXSTA,DA(1))
 . . . . . . S ^LEX(757.33,"G",LEXD,LEXE,LEXS,DA(1))=""
 . . . . . . S ^LEX(757.33,"G",LEXD,LEXE,LEXS,DA(1),DA)=""
 . . . . . . I '$D(ZTQUEUED) W !,?8,LEXFI,?19,LEXIDX,?30,"Invalid ",LEXED," ",LEXSD,?58,"  ",DA(1),"/",DA
 S LEXIEN=0 F  S LEXIEN=$O(^LEX(LEXFI,LEXIEN)) Q:+LEXIEN'>0  D
 . N LEXHIS S LEXHIS=0 F  S LEXHIS=$O(^LEX(LEXFI,LEXIEN,2,LEXHIS)) Q:+LEXHIS'>0  D
 . . N DA,DIK,X,LEXN0,LEXHN,LEXD,LEXE,LEXS,LEXED,LEXSD
 . . S DA(1)=LEXIEN,DA=LEXHIS
 . . S LEXN0=$G(^LEX(757.33,+LEXIEN,0))
 . . S LEXNH=$G(^LEX(757.33,+LEXIEN,2,+LEXHIS,0))
 . . S LEXD=$P(LEXN0,"^",1),LEXE=$P(LEXNH,"^",1),LEXS=$P(LEXNH,"^",2) Q:'$L(LEXD)  Q:'$L(LEXE)  Q:'$L(LEXS)
 . . S LEXED=$TR($$FMTE^XLFDT(LEXE,"5DZ"),"@"," ")
 . . S LEXSD=$S(+LEXS>0:"Active",1:"Inactive")
 . . I $D(^LEX(LEXFI,LEXIDX,LEXD,LEXE,LEXS,DA(1)))<11 D
 . . . S LEXERR=LEXERR+1 I '$D(ZTQUEUED) W !,?8,LEXFI,?19,LEXIDX,?30,"Missing ",LEXED," ",LEXSD,?58,"  ",DA(1),"/",DA
 . . S ^LEX(LEXFI,LEXIDX,LEXD,LEXE,LEXS,DA(1))=""
 . . S ^LEX(LEXFI,LEXIDX,LEXD,LEXE,LEXS,DA(1),DA)=""
 S LEXERR=$S(+LEXERR>0:LEXERR,1:"") I '$D(ZTQUEUED) W !,$J(LEXERR,5),?8,LEXFI,?19,LEXIDX,?30,LEXIDXT
 H 2 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
SET ;   Re-Index Subset file 757.33 (Set logic only)
 Q:'$D(LEXSET)  N LEXTC,LEXPRE,LEXBEG,LEXEND,LEXELP,LEXNM,LEXFI,LEXRT
 N LEXOUT,LEXMSG S LEXFI=757.33
 D FILE^DID(LEXFI,"N","GLOBAL NAME","LEXOUT","LEXMSG")
 S LEXRT=$G(LEXOUT("GLOBAL NAME")) Q:LEXRT'["^LEX"
 S LEXPRE=$G(^TMP("LEXRX",$J,"T",1,"ELAP"))
 S LEXBEG=$$NOW^XLFDT,LEXNM=$$FN^LEXRXXM(LEXFI)
 S LEXTC=$$UPD^LEXRXXT3($G(LEXNAM),,("Re-Indexing File #"_LEXFI))
 Q:LEXTC=1  I '$D(ZTQUEUED) W !,?8,"Re-Indexing",!
 N LEXIEN,LEXP3,LEXP4 S (LEXP3,LEXP4,LEXIEN)=0
 F  S LEXIEN=$O(^LEX(LEXFI,LEXIEN)) Q:+LEXIEN'>0  D
 . D:$D(LEXFIX) FIX(LEXIEN) I $D(^LEX(LEXFI,+LEXIEN,0)) S LEXP3=LEXIEN,LEXP4=LEXP4+1
 S:LEXP3>0 $P(^LEX(LEXFI,0),"^",3)=LEXP3 S:LEXP4>0 $P(^LEX(LEXFI,0),"^",4)=LEXP4
 I +($G(LEXP4))>0 D
 . N ZTQUEUED,DIK S ZTQUEUED=$G(ZTQUEUED) S DIK="^LEX("_LEXFI_"," D IXALL^DIK
 Q:$D(LEXQ)  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,"ALLIX",,,"Re-Index",LEXELP)
 S LEXELP=$$ADDT^LEXRXXM(LEXELP,LEXPRE)
 S ^TMP("LEXRX",$J,"T",1,"ELAP")=LEXELP
 Q
FIX(X) ;   Fix Inactive Mappings 757.33
 N DA,DIK,LEXDEF,LEXEF,LEXEF1,LEXHIS,LEXMAP,LEXN0,LEXNC,LEXNE,LEXNEXT
 N LEXNH,LEXNS,LEXSCODE,LEXSEFF,LEXSIEN,LEXSNOM,LEXSRC,LEXSSAB,LEXSSTA
 N LEXSSYS,LEXST,LEXTCODE,LEXTD,LEXTEFF,LEXTIEN,LEXTNON,LEXTSAB
 N LEXTSTA,LEXTSYS S LEXTD=$$DT^XLFDT,DA=+($G(X)) Q:+DA'>0
 Q:'$D(^LEX(757.33,DA,0))  Q:'$D(^LEX(757.33,DA,2))
 S LEXN0=$G(^LEX(757.33,DA,0))
 S LEXEF=$O(^LEX(757.33,+DA,2,"B",(LEXTD+.001)),-1) Q:LEXEF'?7N
 S LEXEF1=$$FMADD^XLFDT(LEXEF,1) Q:LEXEF1'?7N  Q:LEXEF1'<LEXTD
 S LEXHIS=$O(^LEX(757.33,+DA,2,"B",+LEXEF," "),-1)
 S LEXNH=$G(^LEX(757.33,+DA,2,+LEXHIS,0)) S LEXST=$P(LEXNH,"^",2)
 Q:LEXST'>0  S LEXSCODE=$P(LEXN0,"^",2) S LEXTCODE=$P(LEXN0,"^",3)
 S LEXMAP=$P(LEXN0,"^",4) S LEXDEF=$G(^LEX(757.32,+LEXMAP,2))
 S LEXSSYS=$P(LEXDEF,"^",1),LEXTSYS=$P(LEXDEF,"^",2)
 S LEXSRC=$G(^LEX(757.03,LEXSSYS,0))
 S LEXSSAB=$E(LEXSRC,1,3),LEXSNOM=$P(LEXSRC,"^",2)
 S LEXSRC=$G(^LEX(757.03,LEXTSYS,0))
 S LEXTSAB=$E(LEXSRC,1,3),LEXTNON=$P(LEXSRC,"^",2)
 S LEXSSTA=$$STATCHK^LEXSRC2(LEXSCODE,LEXTD,,LEXSSAB)
 S LEXSIEN=$P(LEXSSTA,"^",2),LEXSEFF=$P(LEXSSTA,"^",3)
 S LEXTSTA=$$STATCHK^LEXSRC2(LEXTCODE,LEXTD,,LEXTSAB)
 S LEXTIEN=$P(LEXTSTA,"^",2),LEXTEFF=$P(LEXSSTA,"^",3)
 Q:+LEXSSTA>0&(+LEXTSTA>0)  S LEXNEXT=$O(^LEX(757.33,+DA,2," "),-1)+1
 S LEXNS=0,LEXNE=LEXEF1,LEXNC=$$NOW^XLFDT I $D(LEXFIX) D
 . N DIK S DIK="^LEX(757.33," D IX2^DIK
 . S ^LEX(757.33,+DA,2,0)="^757.333D^"_LEXNEXT_"^"_LEXNEXT
 . S ^LEX(757.33,+DA,2,+LEXNEXT,0)=LEXNE_"^"_LEXNS_"^"_LEXNC
 . W:'$D(ZTQUEUED) "."
 . S DIK="^LEX(757.33," D IX1^DIK
 Q
CLR ;   Clear
 K LEXFIX,LEXNAM,LEXSET,LEXTEST,ZTQUEUED,LEXQ
 Q