LEXRXB ;ISL/KER - Re-Index 757.001 B/AF ;05/23/2017
;;2.0;LEXICON UTILITY;**81,80,103**;Sep 23, 1996;Build 2
;
; Global Variables
; ^LEX(757.001) SACC 1.3
; ^LEX(757.02) SACC 1.3
; ^LEX(757.1) SACC 1.3
; ^TMP("LEXRX") SACC 2.3.2.5.1
;
; External References
; FILE^DID ICR 2052
; IX1^DIK ICR 10013
; IX2^DIK ICR 10013
; IXALL^DIK ICR 10013
; $$FMDIFF^XLFDT ICR 10103
; $$NOW^XLFDT ICR 10103
;
; Local Variables NEWed or KILLed Elsewhere
; LEXFIX Fix 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
R757001 ; Repair file 757.001
D RB,RAF,SET Q
RB ; Index ^LEX(757.001,"B",MC,IEN)
W:'$D(ZTQUEUED) ! N DA,DIK,LEXBEG,LEXDIF,LEXELP,LEXEND,LEXERR,LEXFI,LEXIDX,LEXIDXT,LEXIEN,LEXMC,LEXNDS,LEXOK,LEXSTR,X
S LEXFI="757.001"
N LEXTC S LEXTC=$$UPD^LEXRXXT3($G(LEXNAM),,"Repairing File #757.001 ""B""") Q:LEXTC=1
S LEXBEG=$$NOW^XLFDT,(LEXNDS,LEXERR)=0,LEXSTR="",LEXIDX="B",LEXIDXT="^LEX(757.001,""B"",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
. . Q:+LEXSTR>0&(LEXSTR=LEXIEN) N LEXOK,LEXMC S LEXMC=$P($G(^LEX(LEXFI,LEXIEN,0)),"^",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:$L(LEXMC) ^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=$P($G(^LEX(LEXFI,DA,0)),"^",1) Q:'$L(X)
. I '$D(^LEX(LEXFI,"B",X,DA)) D
. . S LEXERR=LEXERR+1 I '$D(ZTQUEUED) W !,?8,LEXFI,?19,LEXIDX,?30,"Missing",?58," ",DA
. S:$L(X) ^LEX(LEXFI,"B",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
RAF ; Index ^LEX(757.001,"AF",FREQ,IEN)
W:'$D(ZTQUEUED) ! N DA,DIK,LEXAF,LEXBEG,LEXDIF,LEXELP,LEXEND,LEXERR,LEXFI,LEXIDX,LEXIDXT,LEXFQ,LEXIEN,LEXNDS,LEXOF,LEXOK,LEXSTR,X
S LEXFI="757.001"
N LEXTC S LEXTC=$$UPD^LEXRXXT3($G(LEXNAM),,"Repairing File #757.001 ""AF""") Q:LEXTC=1
S LEXBEG=$$NOW^XLFDT,(LEXNDS,LEXERR)=0,LEXSTR="",LEXIDX="AF",LEXIDXT="^LEX(757.001,""AF"",FREQ,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,LEXFQ,LEXOF,LEXAF,LEXF S LEXFQ=+($P($G(^LEX(LEXFI,LEXIEN,0)),"^",3))
. . S LEXOF=+($P($G(^LEX(LEXFI,LEXIEN,0)),"^",2)) I LEXOF>LEXFQ D
. . . S LEXF=$$FREQ^LEXRXXM(LEXIEN) S:LEXF'>LEXFQ $P(^LEX(LEXFI,LEXIEN,0),"^",2)=LEXF,LEXOF=LEXF
. . . S:LEXF>LEXFQ $P(^LEX(LEXFI,LEXIEN,0),"^",2)=LEXF,$P(^LEX(LEXFI,LEXIEN,0),"^",3)=LEXF,(LEXOF,LEXFQ)=LEXF
. . S LEXAF=LEXFQ-LEXOF S:LEXAF>0 LEXAF=LEXAF*(-1)
. . S LEXOK=0 S:LEXAF=LEXSTR LEXOK=1 I 'LEXOK D
. . . S LEXERR=LEXERR+1 K:'$D(LEXTEST) ^LEX(LEXFI,LEXIDX,LEXSTR,LEXIEN) S:$L(LEXAF) ^LEX(LEXFI,LEXIDX,LEXAF,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,LEXF S DA=LEXIEN,X=+($P($G(^LEX(LEXFI,DA,0)),"^",3)),LEXF=-(X-(+($P(^LEX(LEXFI,DA,0),"^",2))))
. I '$D(^LEX(LEXFI,"AF",LEXF,DA)) D
. . S LEXERR=LEXERR+1 I '$D(ZTQUEUED) W !,?8,LEXFI,?19,LEXIDX,?30,"Missing",?58," ",DA
. S:$L(LEXF) ^LEX(LEXFI,"AF",LEXF,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
;
; Miscellaneous
SET ; Re-Index Concept Usage file 757.001 (Set logic only)
Q:'$D(LEXSET) N LEXTC,LEXPRE,LEXBEG,LEXEND,LEXELP,LEXNM,LEXFI,LEXRT
N LEXOUT,LEXMSG S LEXFI=757.001
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 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
S $P(^LEX(LEXFI,0),"^",3)=LEXP3,$P(^LEX(LEXFI,0),"^",4)=LEXP4
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
RESET ; Reset Frequencies in 757.001
N DA,DIK,LEXIEN,LEXFI,LEXCFQ,LEXCMC,LEXCND,LEXCOV,LEXCOF,LEXNFQ,LEXNND,LEXNOV
S LEXFI=757.001 S LEXIEN=0 F S LEXIEN=$O(^LEX(757.001,LEXIEN)) Q:+LEXIEN'>0 D
. S LEXCND=$G(^LEX(LEXFI,LEXIEN,0)),LEXCMC=+LEXCND,LEXCOV=$P(LEXCND,"^",2)
. S (LEXCFQ,LEXNFQ)=$P(LEXCND,"^",3),LEXNOV=$$FREQ(LEXIEN)
. S:LEXNOV>LEXNFQ LEXNFQ=LEXNOV S:LEXNOV'=LEXCOV LEXNFQ=LEXNOV
. Q:LEXCOV=LEXNOV&(LEXCFQ=LEXNFQ)
. S DA=+($G(LEXIEN)),DIK="^LEX("_LEXFI_"," D IX2^DIK
. S ^LEX(LEXFI,LEXIEN,0)=LEXCMC_"^"_LEXNOV_"^"_LEXNFQ D IX1^DIK
Q
FREQ(X) ; Get frequency based on codes and semantics
N LEXMC,LEXMCE,LEXND,LEXOF,LEXNF S LEXMC=+($G(X)),X=0 Q:'$D(^LEX(757,LEXMC,0)) X
S LEXMCE=$P($G(^LEX(757,+LEXMC,0)),"^",1)
S LEXOF=$P($G(^LEX(757.001,LEXMC,0)),"^",2)
N LEXSA,LEXSAB,LEXACT,LEXSMC,LEXNUR,LEXBEH,LEXI10,LEXPRO,LEXDIA
S (LEXSA,LEXNUR,LEXBEH,LEXPRO,LEXDIA,LEXI10,LEXSMC)=0 D SO,SM S X=0
S LEXNF="",X=0
; ICD-10-CM 6
S:+LEXI10=1&(+LEXDIA=1) (LEXNF,X)=6 Q:$L(LEXNF)&(LEXNF'=LEXOF)&(X>0) X
; ICD-10-PCS 5
S:+LEXI10=1&(+LEXDIA'=1) (LEXNF,X)=5 Q:$L(LEXNF)&(LEXNF'=LEXOF)&(X>0) X
; ICD-9 coded Diagnosis 4
S:LEXI10=0&(+LEXDIA=1)&(X=0) (LEXNF,X)=4 Q:$L(LEXNF)&(LEXNF'=LEXOF)&(X>0) X
; Behavior or non-ICD Diagnosis 3
S:'$L(LEXNF)&(+($G(LEXBEH))=1)&($G(LEXSMC)>0) (LEXNF,X)=3 Q:$L(LEXNF)&(LEXNF'=LEXOF)&(X>0) X
; Procedures 2
S:'$L(LEXNF)&(+($G(LEXPRO))=1) (LEXNF,X)=2 Q:$L(LEXNF)&(LEXNF'=LEXOF)&(X>0) X
; Nursing 1
S:'$L(LEXNF)&(+($G(LEXNUR))=1) (LEXNF,X)=1 Q:$L(LEXNF)&(LEXNF'=LEXOF)&(X>0) X
; Diseases 3
S:'$L(LEXNF)&(+($G(LEXSMC))>1) (LEXNF,X)=3 Q:$L(LEXNF)&(LEXNF'=LEXOF)&(X>0) X
; Non-Critical 0
S:'$L(LEXNF) (LEXNF,X)=0
Q X
SO ; Codes
N LEXSA S LEXSA=0 F S LEXSA=$O(^LEX(757.02,"AMC",LEXMC,LEXSA)) Q:+LEXSA=0 D SOC
Q
SOC ; Code Type
N LEXCOD,LEXEFF,LEXHIS,LEXND,LEXSAB
S LEXEFF=$O(^LEX(757.02,LEXSA,4,"B"," "),-1) Q:LEXEFF'?7N
S LEXHIS=$O(^LEX(757.02,LEXSA,4,"B",LEXEFF," "),-1) Q:+LEXHIS'>0
S LEXND=$G(^LEX(757.02,LEXSA,4,+LEXHIS,0)) Q:+($P(LEXND,"^",2))'>0
S LEXND=$G(^LEX(757.02,LEXSA,0)),LEXSAB=+($P(LEXND,U,3)),LEXCOD=$P(LEXND,U,2)
Q:LEXSAB=0
; ICD-10 CM/PCS
S:LEXSAB=30!(LEXSAB=31) LEXI10=1_"^"_LEXCOD
; Diagnosis ICD-9 and ICD-10
S:LEXSAB=1!(LEXSAB=30) LEXDIA=1_"^"_LEXCOD
; Procedures ICD-9, ICD-10, CPT and HCPCS
S:LEXSAB=2!(LEXSAB=31)!(LEXSAB=3)!(LEXSAB=4) LEXPRO=1_"^"_LEXCOD
; Behaviors DSM-III and DSM-IV
S:LEXSAB=5!(LEXSAB=6) LEXBEH=1_"^"_LEXCOD
; Nursing NANDA, NIC, NOC, HHC and Omaha
S:LEXSAB>10&(LEXSAB<16) LEXNUR=1_"^"_LEXCOD
Q
SM ; Semantics - BEH Behavior and DIS Disorders
N LEXBD,LEXCLA,LEXSM S LEXSMC=0,LEXMC=+($G(LEXMC)) Q:'$D(^LEX(757,LEXMC,0))
S (LEXBD,LEXSM)=0 F S LEXSM=$O(^LEX(757.1,"B",LEXMC,LEXSM)) Q:+LEXSM=0 D SMC
S LEXSMC=LEXBD
Q
SMC ; Semantic Class
S LEXCLA=+($P($G(^LEX(757.1,LEXSM,0)),U,2))
; Behavior
S:LEXCLA=3&(LEXBD'>0) LEXBD=1
; Disease
S:LEXCLA=6 LEXBD=2
Q
CLR ; Clear
K LEXFIX,LEXNAM,LEXSET,LEXTEST,ZTQUEUED,LEXQ
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HLEXRXB 9246 printed Nov 22, 2024@17:19:17 Page 2
LEXRXB ;ISL/KER - Re-Index 757.001 B/AF ;05/23/2017
+1 ;;2.0;LEXICON UTILITY;**81,80,103**;Sep 23, 1996;Build 2
+2 ;
+3 ; Global Variables
+4 ; ^LEX(757.001) SACC 1.3
+5 ; ^LEX(757.02) SACC 1.3
+6 ; ^LEX(757.1) SACC 1.3
+7 ; ^TMP("LEXRX") SACC 2.3.2.5.1
+8 ;
+9 ; External References
+10 ; FILE^DID ICR 2052
+11 ; IX1^DIK ICR 10013
+12 ; IX2^DIK ICR 10013
+13 ; IXALL^DIK ICR 10013
+14 ; $$FMDIFF^XLFDT ICR 10103
+15 ; $$NOW^XLFDT ICR 10103
+16 ;
+17 ; Local Variables NEWed or KILLed Elsewhere
+18 ; LEXFIX Fix Flag NEWed/KILLed by LEXRXXT
+19 ; LEXNAM Task name NEWed/KILLed by LEXRXXT
+20 ; LEXSET Re-Index flag NEWed/KILLed by LEXRXXT
+21 ; LEXQ Quiet flat NEWed/KILLed by LEXRXXT2
+22 ; LEXTEST Test variable NEWed/KILLed by Developer
+23 ; ZTQUEUED Task flag NEWed/KILLed by Taskman
+24 ;
+25 QUIT
EN ; Main Entry Point
R757001 ; Repair file 757.001
+1 DO RB
DO RAF
DO SET
QUIT
RB ; Index ^LEX(757.001,"B",MC,IEN)
+1 if '$DATA(ZTQUEUED)
WRITE !
NEW DA,DIK,LEXBEG,LEXDIF,LEXELP,LEXEND,LEXERR,LEXFI,LEXIDX,LEXIDXT,LEXIEN,LEXMC,LEXNDS,LEXOK,LEXSTR,X
+2 SET LEXFI="757.001"
+3 NEW LEXTC
SET LEXTC=$$UPD^LEXRXXT3($GET(LEXNAM),,"Repairing File #757.001 ""B""")
if LEXTC=1
QUIT
+4 SET LEXBEG=$$NOW^XLFDT
SET (LEXNDS,LEXERR)=0
SET LEXSTR=""
SET LEXIDX="B"
SET LEXIDXT="^LEX(757.001,""B"",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
IF '$DATA(^LEX(LEXFI,LEXIEN,0))
Begin DoDot:3
+8 SET LEXERR=LEXERR+1
if '$DATA(LEXTEST)
KILL ^LEX(LEXFI,LEXIDX,LEXSTR,LEXIEN)
+9 IF '$DATA(ZTQUEUED)
WRITE !,?8,LEXFI,?19,LEXIDX,?30,LEXSTR,?58," ",LEXIEN
End DoDot:3
QUIT
+10 if +LEXSTR>0&(LEXSTR=LEXIEN)
QUIT
NEW LEXOK,LEXMC
SET LEXMC=$PIECE($GET(^LEX(LEXFI,LEXIEN,0)),"^",1)
+11 SET LEXOK=0
if LEXMC=LEXSTR
SET LEXOK=1
IF 'LEXOK
Begin DoDot:3
+12 SET LEXERR=LEXERR+1
if '$DATA(LEXTEST)
KILL ^LEX(LEXFI,LEXIDX,LEXSTR,LEXIEN)
if $LENGTH(LEXMC)
SET ^LEX(LEXFI,LEXIDX,LEXMC,LEXIEN)=""
+13 IF '$DATA(ZTQUEUED)
WRITE !,?8,LEXFI,?19,LEXIDX,?30,LEXSTR,?58," ",LEXIEN
End DoDot:3
End DoDot:2
End DoDot:1
+14 SET LEXIEN=0
FOR
SET LEXIEN=$ORDER(^LEX(LEXFI,LEXIEN))
if +LEXIEN'>0
QUIT
Begin DoDot:1
+15 NEW DA,DIK,X
SET DA=LEXIEN
SET X=$PIECE($GET(^LEX(LEXFI,DA,0)),"^",1)
if '$LENGTH(X)
QUIT
+16 IF '$DATA(^LEX(LEXFI,"B",X,DA))
Begin DoDot:2
+17 SET LEXERR=LEXERR+1
IF '$DATA(ZTQUEUED)
WRITE !,?8,LEXFI,?19,LEXIDX,?30,"Missing",?58," ",DA
End DoDot:2
+18 if $LENGTH(X)
SET ^LEX(LEXFI,"B",X,DA)=""
End DoDot:1
+19 SET LEXERR=$SELECT(+LEXERR>0:LEXERR,1:"")
IF '$DATA(ZTQUEUED)
WRITE !,$JUSTIFY(LEXERR,5),?8,LEXFI,?19,LEXIDX,?30,LEXIDXT
+20 SET LEXEND=$$NOW^XLFDT
SET LEXELP=$$FMDIFF^XLFDT(LEXEND,LEXBEG,3)
+21 if $EXTRACT(LEXELP,1)=" "&($EXTRACT(LEXELP,3)="
SET LEXELP=$TRANSLATE(LEXELP," ","0")
+22 DO REP^LEXRXXS(LEXFI,LEXFI,LEXIDX,LEXNDS,LEXERR,LEXIDXT,LEXELP)
+23 QUIT
RAF ; Index ^LEX(757.001,"AF",FREQ,IEN)
+1 if '$DATA(ZTQUEUED)
WRITE !
NEW DA,DIK,LEXAF,LEXBEG,LEXDIF,LEXELP,LEXEND,LEXERR,LEXFI,LEXIDX,LEXIDXT,LEXFQ,LEXIEN,LEXNDS,LEXOF,LEXOK,LEXSTR,X
+2 SET LEXFI="757.001"
+3 NEW LEXTC
SET LEXTC=$$UPD^LEXRXXT3($GET(LEXNAM),,"Repairing File #757.001 ""AF""")
if LEXTC=1
QUIT
+4 SET LEXBEG=$$NOW^XLFDT
SET (LEXNDS,LEXERR)=0
SET LEXSTR=""
SET LEXIDX="AF"
SET LEXIDXT="^LEX(757.001,""AF"",FREQ,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,LEXFQ,LEXOF,LEXAF,LEXF
SET LEXFQ=+($PIECE($GET(^LEX(LEXFI,LEXIEN,0)),"^",3))
+12 SET LEXOF=+($PIECE($GET(^LEX(LEXFI,LEXIEN,0)),"^",2))
IF LEXOF>LEXFQ
Begin DoDot:3
+13 SET LEXF=$$FREQ^LEXRXXM(LEXIEN)
if LEXF'>LEXFQ
SET $PIECE(^LEX(LEXFI,LEXIEN,0),"^",2)=LEXF
SET LEXOF=LEXF
+14 if LEXF>LEXFQ
SET $PIECE(^LEX(LEXFI,LEXIEN,0),"^",2)=LEXF
SET $PIECE(^LEX(LEXFI,LEXIEN,0),"^",3)=LEXF
SET (LEXOF,LEXFQ)=LEXF
End DoDot:3
+15 SET LEXAF=LEXFQ-LEXOF
if LEXAF>0
SET LEXAF=LEXAF*(-1)
+16 SET LEXOK=0
if LEXAF=LEXSTR
SET LEXOK=1
IF 'LEXOK
Begin DoDot:3
+17 SET LEXERR=LEXERR+1
if '$DATA(LEXTEST)
KILL ^LEX(LEXFI,LEXIDX,LEXSTR,LEXIEN)
if $LENGTH(LEXAF)
SET ^LEX(LEXFI,LEXIDX,LEXAF,LEXIEN)=""
+18 IF '$DATA(ZTQUEUED)
WRITE !,?8,LEXFI,?19,LEXIDX,?30,LEXSTR,?58," ",LEXIEN
End DoDot:3
End DoDot:2
End DoDot:1
+19 SET LEXIEN=0
FOR
SET LEXIEN=$ORDER(^LEX(LEXFI,LEXIEN))
if +LEXIEN'>0
QUIT
Begin DoDot:1
+20 NEW DA,DIK,X,LEXF
SET DA=LEXIEN
SET X=+($PIECE($GET(^LEX(LEXFI,DA,0)),"^",3))
SET LEXF=-(X-(+($PIECE(^LEX(LEXFI,DA,0),"^",2))))
+21 IF '$DATA(^LEX(LEXFI,"AF",LEXF,DA))
Begin DoDot:2
+22 SET LEXERR=LEXERR+1
IF '$DATA(ZTQUEUED)
WRITE !,?8,LEXFI,?19,LEXIDX,?30,"Missing",?58," ",DA
End DoDot:2
+23 if $LENGTH(LEXF)
SET ^LEX(LEXFI,"AF",LEXF,DA)=""
End DoDot:1
+24 SET LEXERR=$SELECT(+LEXERR>0:LEXERR,1:"")
IF '$DATA(ZTQUEUED)
WRITE !,$JUSTIFY(LEXERR,5),?8,LEXFI,?19,LEXIDX,?30,LEXIDXT
+25 SET LEXEND=$$NOW^XLFDT
SET LEXELP=$$FMDIFF^XLFDT(LEXEND,LEXBEG,3)
+26 if $EXTRACT(LEXELP,1)=" "&($EXTRACT(LEXELP,3)="
SET LEXELP=$TRANSLATE(LEXELP," ","0")
+27 DO REP^LEXRXXS(LEXFI,LEXFI,LEXIDX,LEXNDS,LEXERR,LEXIDXT,LEXELP)
+28 QUIT
+29 ;
+30 ; Miscellaneous
SET ; Re-Index Concept Usage file 757.001 (Set logic only)
+1 if '$DATA(LEXSET)
QUIT
NEW LEXTC,LEXPRE,LEXBEG,LEXEND,LEXELP,LEXNM,LEXFI,LEXRT
+2 NEW LEXOUT,LEXMSG
SET LEXFI=757.001
+3 DO FILE^DID(LEXFI,"N","GLOBAL NAME","LEXOUT","LEXMSG")
+4 SET LEXRT=$GET(LEXOUT("GLOBAL NAME"))
if LEXRT'["^LEX"
QUIT
+5 SET LEXPRE=$GET(^TMP("LEXRX",$JOB,"T",1,"ELAP"))
+6 SET LEXBEG=$$NOW^XLFDT
SET LEXNM=$$FN^LEXRXXM(LEXFI)
+7 SET LEXTC=$$UPD^LEXRXXT3($GET(LEXNAM),,("Re-Indexing File #"_LEXFI))
+8 if LEXTC=1
QUIT
IF '$DATA(ZTQUEUED)
WRITE !,?8,"Re-Indexing",!
+9 NEW LEXIEN,LEXP3,LEXP4
SET (LEXP3,LEXP4,LEXIEN)=0
+10 FOR
SET LEXIEN=$ORDER(^LEX(LEXFI,LEXIEN))
if +LEXIEN'>0
QUIT
SET LEXP3=LEXIEN
SET LEXP4=LEXP4+1
+11 if LEXP3>0
SET $PIECE(^LEX(LEXFI,0),"^",3)=LEXP3
if LEXP4>0
SET $PIECE(^LEX(LEXFI,0),"^",4)=LEXP4
+12 IF +($GET(LEXP4))>0
Begin DoDot:1
+13 NEW ZTQUEUED,DIK
SET ZTQUEUED=$GET(ZTQUEUED)
SET DIK="^LEX("_LEXFI_","
DO IXALL^DIK
End DoDot:1
+14 SET $PIECE(^LEX(LEXFI,0),"^",3)=LEXP3
SET $PIECE(^LEX(LEXFI,0),"^",4)=LEXP4
+15 if $DATA(LEXQ)
QUIT
SET LEXEND=$$NOW^XLFDT
SET LEXELP=$$FMDIFF^XLFDT(LEXEND,LEXBEG,3)
+16 if $EXTRACT(LEXELP,1)=" "&($EXTRACT(LEXELP,3)="
SET LEXELP=$TRANSLATE(LEXELP," ","0")
+17 DO REP^LEXRXXS(LEXFI,LEXFI,"ALLIX",,,"Re-Index",LEXELP)
+18 SET LEXELP=$$ADDT^LEXRXXM(LEXELP,LEXPRE)
+19 SET ^TMP("LEXRX",$JOB,"T",1,"ELAP")=LEXELP
+20 QUIT
RESET ; Reset Frequencies in 757.001
+1 NEW DA,DIK,LEXIEN,LEXFI,LEXCFQ,LEXCMC,LEXCND,LEXCOV,LEXCOF,LEXNFQ,LEXNND,LEXNOV
+2 SET LEXFI=757.001
SET LEXIEN=0
FOR
SET LEXIEN=$ORDER(^LEX(757.001,LEXIEN))
if +LEXIEN'>0
QUIT
Begin DoDot:1
+3 SET LEXCND=$GET(^LEX(LEXFI,LEXIEN,0))
SET LEXCMC=+LEXCND
SET LEXCOV=$PIECE(LEXCND,"^",2)
+4 SET (LEXCFQ,LEXNFQ)=$PIECE(LEXCND,"^",3)
SET LEXNOV=$$FREQ(LEXIEN)
+5 if LEXNOV>LEXNFQ
SET LEXNFQ=LEXNOV
if LEXNOV'=LEXCOV
SET LEXNFQ=LEXNOV
+6 if LEXCOV=LEXNOV&(LEXCFQ=LEXNFQ)
QUIT
+7 SET DA=+($GET(LEXIEN))
SET DIK="^LEX("_LEXFI_","
DO IX2^DIK
+8 SET ^LEX(LEXFI,LEXIEN,0)=LEXCMC_"^"_LEXNOV_"^"_LEXNFQ
DO IX1^DIK
End DoDot:1
+9 QUIT
FREQ(X) ; Get frequency based on codes and semantics
+1 NEW LEXMC,LEXMCE,LEXND,LEXOF,LEXNF
SET LEXMC=+($GET(X))
SET X=0
if '$DATA(^LEX(757,LEXMC,0))
QUIT X
+2 SET LEXMCE=$PIECE($GET(^LEX(757,+LEXMC,0)),"^",1)
+3 SET LEXOF=$PIECE($GET(^LEX(757.001,LEXMC,0)),"^",2)
+4 NEW LEXSA,LEXSAB,LEXACT,LEXSMC,LEXNUR,LEXBEH,LEXI10,LEXPRO,LEXDIA
+5 SET (LEXSA,LEXNUR,LEXBEH,LEXPRO,LEXDIA,LEXI10,LEXSMC)=0
DO SO
DO SM
SET X=0
+6 SET LEXNF=""
SET X=0
+7 ; ICD-10-CM 6
+8 if +LEXI10=1&(+LEXDIA=1)
SET (LEXNF,X)=6
if $LENGTH(LEXNF)&(LEXNF'=LEXOF)&(X>0)
QUIT X
+9 ; ICD-10-PCS 5
+10 if +LEXI10=1&(+LEXDIA'=1)
SET (LEXNF,X)=5
if $LENGTH(LEXNF)&(LEXNF'=LEXOF)&(X>0)
QUIT X
+11 ; ICD-9 coded Diagnosis 4
+12 if LEXI10=0&(+LEXDIA=1)&(X=0)
SET (LEXNF,X)=4
if $LENGTH(LEXNF)&(LEXNF'=LEXOF)&(X>0)
QUIT X
+13 ; Behavior or non-ICD Diagnosis 3
+14 if '$LENGTH(LEXNF)&(+($GET(LEXBEH))=1)&($GET(LEXSMC)>0)
SET (LEXNF,X)=3
if $LENGTH(LEXNF)&(LEXNF'=LEXOF)&(X>0)
QUIT X
+15 ; Procedures 2
+16 if '$LENGTH(LEXNF)&(+($GET(LEXPRO))=1)
SET (LEXNF,X)=2
if $LENGTH(LEXNF)&(LEXNF'=LEXOF)&(X>0)
QUIT X
+17 ; Nursing 1
+18 if '$LENGTH(LEXNF)&(+($GET(LEXNUR))=1)
SET (LEXNF,X)=1
if $LENGTH(LEXNF)&(LEXNF'=LEXOF)&(X>0)
QUIT X
+19 ; Diseases 3
+20 if '$LENGTH(LEXNF)&(+($GET(LEXSMC))>1)
SET (LEXNF,X)=3
if $LENGTH(LEXNF)&(LEXNF'=LEXOF)&(X>0)
QUIT X
+21 ; Non-Critical 0
+22 if '$LENGTH(LEXNF)
SET (LEXNF,X)=0
+23 QUIT X
SO ; Codes
+1 NEW LEXSA
SET LEXSA=0
FOR
SET LEXSA=$ORDER(^LEX(757.02,"AMC",LEXMC,LEXSA))
if +LEXSA=0
QUIT
DO SOC
+2 QUIT
SOC ; Code Type
+1 NEW LEXCOD,LEXEFF,LEXHIS,LEXND,LEXSAB
+2 SET LEXEFF=$ORDER(^LEX(757.02,LEXSA,4,"B"," "),-1)
if LEXEFF'?7N
QUIT
+3 SET LEXHIS=$ORDER(^LEX(757.02,LEXSA,4,"B",LEXEFF," "),-1)
if +LEXHIS'>0
QUIT
+4 SET LEXND=$GET(^LEX(757.02,LEXSA,4,+LEXHIS,0))
if +($PIECE(LEXND,"^",2))'>0
QUIT
+5 SET LEXND=$GET(^LEX(757.02,LEXSA,0))
SET LEXSAB=+($PIECE(LEXND,U,3))
SET LEXCOD=$PIECE(LEXND,U,2)
+6 if LEXSAB=0
QUIT
+7 ; ICD-10 CM/PCS
+8 if LEXSAB=30!(LEXSAB=31)
SET LEXI10=1_"^"_LEXCOD
+9 ; Diagnosis ICD-9 and ICD-10
+10 if LEXSAB=1!(LEXSAB=30)
SET LEXDIA=1_"^"_LEXCOD
+11 ; Procedures ICD-9, ICD-10, CPT and HCPCS
+12 if LEXSAB=2!(LEXSAB=31)!(LEXSAB=3)!(LEXSAB=4)
SET LEXPRO=1_"^"_LEXCOD
+13 ; Behaviors DSM-III and DSM-IV
+14 if LEXSAB=5!(LEXSAB=6)
SET LEXBEH=1_"^"_LEXCOD
+15 ; Nursing NANDA, NIC, NOC, HHC and Omaha
+16 if LEXSAB>10&(LEXSAB<16)
SET LEXNUR=1_"^"_LEXCOD
+17 QUIT
SM ; Semantics - BEH Behavior and DIS Disorders
+1 NEW LEXBD,LEXCLA,LEXSM
SET LEXSMC=0
SET LEXMC=+($GET(LEXMC))
if '$DATA(^LEX(757,LEXMC,0))
QUIT
+2 SET (LEXBD,LEXSM)=0
FOR
SET LEXSM=$ORDER(^LEX(757.1,"B",LEXMC,LEXSM))
if +LEXSM=0
QUIT
DO SMC
+3 SET LEXSMC=LEXBD
+4 QUIT
SMC ; Semantic Class
+1 SET LEXCLA=+($PIECE($GET(^LEX(757.1,LEXSM,0)),U,2))
+2 ; Behavior
+3 if LEXCLA=3&(LEXBD'>0)
SET LEXBD=1
+4 ; Disease
+5 if LEXCLA=6
SET LEXBD=2
+6 QUIT
CLR ; Clear
+1 KILL LEXFIX,LEXNAM,LEXSET,LEXTEST,ZTQUEUED,LEXQ
+2 QUIT