LEXRX ;ISL/KER - Re-Index Lexicon ;04/21/2014
;;2.0;LEXICON UTILITY;**81,80**;Sep 23, 1996;Build 10
;
; Global Variables
; ^LEX( SACC 1.3
; ^LEXT( SACC 1.3
; ^TMP("LEXRX") SACC 2.3.2.5.1
; ^XTMP("LEXRXALL") SACC 2.3.2.5.2
; ^XTMP("LEXRXFIX") SACC 2.3.2.5.2
; ^XTMP("LEXRXMAJ") SACC 2.3.2.5.2
; ^XTMP("LEXRXONE") SACC 2.3.2.5.2
; ^XTMP("LEXRXSET") SACC 2.3.2.5.2
; ^XTMP("LEXRXSUP") SACC 2.3.2.5.2
;
; External References
; ^DIC ICR 10006
; ^DIR ICR 10026
;
;
; Global Variables
; ^LEX( SACC 1.3
; ^LEXT( SACC 1.3
;
; External References
; ^DIC ICR 10006
; ^DIR ICR 10026
;
; Callable Entry Points in this Routine
;
; EN^LEXRX Task the Repair/Re-Index of one or more Files
; CHECK^LEXRX Check if a Repair/Re-Index Task is Running
; MON^LEXRX Monitor Progress of a Running Task
;
EN ; Main Entry Point
N DIC,DIR,DIROUT,DIRUT,DTOUT,DUOUT,LEX,LEXAC,LEXAMSO,LEXENV
N LEXFI,LEXFN,LEXMON,LEXOK,LEXRUN,LEXSTA,LEXT,LEXTY,X,Y
K LEXMON S LEXENV=$$ENV^LEXRXXM Q:'LEXENV
W !," Repair/Re-Index Lexicon cross-references"
S LEXRUN=$$CHECK^LEXRXXM2 I +LEXRUN>0 D Q
. W " Try again later",!
N LEXAMSO,LEXFI,LEXOK S LEXOK=0,LEXAMSO=$$AMSO^LEXRXXA
I "^A^M^S^O^"'[("^"_LEXAMSO_"^") D Q
. W !!,?3,"Lexicon index Repair/Re-Index method not selected, aborting"
D:"^A^"[("^"_LEXAMSO_"^") ALL D:"^M^"[("^"_LEXAMSO_"^") MAJ
D:"^S^"[("^"_LEXAMSO_"^") SUP D:"^O^"[("^"_LEXAMSO_"^") ONE
Q
;
ALL ; All Files
N LEXOK,LEXTY,LEXAMSO K LEXFI S LEXOK=0,LEXAMSO="A"
W !!," ",$$BOLD^LEXRXXM,"Repair/Re-Index the Cross-References for all Lexicon Files",$$NORM^LEXRXXM,!
W !," The cross-references for the larger files will be repaired and the "
W !," smaller files will be re-indexed.",!
W !," Users may be on the system since the cross-references of the larger"
W !," files are not deleted and the re-indexing of the smaller files does"
W !," not involve the Lexicon look-up."
S LEXTY=3 S LEXOK=$$CO^LEXRXXA W ! I +LEXOK>0 K LEXFI D ALL^LEXRXXT
Q
MAJ ; Major Files
N LEXOK,LEXTY,LEXAMSO K LEXFI S LEXOK=0,LEXAMSO="M"
W !!," ",$$BOLD^LEXRXXM,"Repair the Cross-References for the Major Lexicon Files",$$NORM^LEXRXXM,!
W !," The cross-references of the larger files will be repaired by "
W !," verifying the individual subscripts in the cross-reference. Only"
W !," the entries that fail verification will be deleted.",!
W !," Users may be on the system since the cross-references are not"
W !," deleted."
S LEXTY=1 S LEXOK=$$CO^LEXRXXA W ! I +LEXOK>0 K LEXFI D MAJ^LEXRXXT
Q
SUP ; Supporting Files
N LEXOK,LEXTY,LEXAMSO K LEXFI S LEXOK=0,LEXAMSO="S"
W !!," ",$$BOLD^LEXRXXM,"Re-Index the Cross-References for the Supporting Lexicon Files",$$NORM^LEXRXXM,!
W !," The cross-references for the smaller files will be re-indexed.",!
W !," Users may be on the system since the cross-references of the smaller"
W !," files are not involve the Lexicon look-up."
S LEXTY=3 S LEXOK=$$CO^LEXRXXA W ! I +LEXOK>0 K LEXFI D SUP^LEXRXXT
Q
ONE ; One File
N LEXOK,LEXFI,LEXFN,LEXT,LEXTY,LEXAMSO S LEXAMSO="O",LEXFI=$$FI^LEXRXXA I '$L(LEXFI)!(LEXFI["^") W !!," Lexicon file not selected, aborting" Q
I +($$FV^LEXRXXM(($G(LEXFI))))'>0 W !!," Invalid file selected, aborting" Q
S LEXOK=0,LEXFN=$$FN^LEXRXXM(LEXFI) Q:'$L(LEXFN)
S LEXT=LEXFI,LEXT=LEXT_$J(" ",(8-$L(LEXT)))_LEXFN S LEXT=LEXFI_" ("_LEXFN_")" W !
I "^757^757.001^757.01^757.02^757.1^757.21^"[("^"_LEXFI_"^") D
. S LEXTY=1 W !," ",$$BOLD^LEXRXXM,"Repair Cross-References for file ",LEXT,$$NORM^LEXRXXM,! D
. . W !," The cross-references of file "_+LEXFI_" will be repaired by verifying"
. . W !," the individual subscripts in the cross-reference. Only the entries"
. . W !," that fail verification will be deleted. Users may be on the system"
. . W !," since the cross-references are not deleted."
I "^757^757.001^757.01^757.02^757.1^757.21^"'[("^"_LEXFI_"^") D
. S LEXTY=2 W !," ",$$BOLD^LEXRXXM,"Re-Index Cross-References for file ",LEXT,$$NORM^LEXRXXM,! D
. . W !," The cross-references of file "_+LEXFI_" will be re-indexed. Users may"
. . W !," be on the system since this file is not involved in the Lexicon "
. . W !," look-up."
S LEXOK=$$CO^LEXRXXA W ! I +LEXOK>0,$L($G(LEXFI)) D ONE^LEXRXXT
Q
;
CHECK ; Check if a Repair/Re-Index Task is Running
N LEXSTA K LEXMON S LEXSTA=$$CHECK^LEXRXXM2
I +($G(LEXSTA))'>0 W !!," Lexicon cross-reference repair is not running",!
Q
;
MON ; Monitor Progress of a Running Task
N LEXMON S LEXMON="" D MON^LEXRXXM2
Q
;
; Miscellaneous
FORCE ; Forced Repair/Re-Index
K ^TMP("LEXRX",$J),^XTMP("LEXRXALL"),^XTMP("LEXRXMAJ"),^XTMP("LEXRXSUP"),^XTMP("LEXRXONE"),^XTMP("LEXRXSET"),^XTMP("LEXRXFIX")
D CLR,EN
Q
CLR ; Clear
N LEXID K LEXFIX,LEXSET,LEXTEST
Q
LEXRX ;ISL/KER - Re-Index Lexicon ;04/21/2014
+1 ;;2.0;LEXICON UTILITY;**81,80**;Sep 23, 1996;Build 10
+2 ;
+3 ; Global Variables
+4 ; ^LEX( SACC 1.3
+5 ; ^LEXT( SACC 1.3
+6 ; ^TMP("LEXRX") SACC 2.3.2.5.1
+7 ; ^XTMP("LEXRXALL") SACC 2.3.2.5.2
+8 ; ^XTMP("LEXRXFIX") SACC 2.3.2.5.2
+9 ; ^XTMP("LEXRXMAJ") SACC 2.3.2.5.2
+10 ; ^XTMP("LEXRXONE") SACC 2.3.2.5.2
+11 ; ^XTMP("LEXRXSET") SACC 2.3.2.5.2
+12 ; ^XTMP("LEXRXSUP") SACC 2.3.2.5.2
+13 ;
+14 ; External References
+15 ; ^DIC ICR 10006
+16 ; ^DIR ICR 10026
+17 ;
+18 ;
+19 ; Global Variables
+20 ; ^LEX( SACC 1.3
+21 ; ^LEXT( SACC 1.3
+22 ;
+23 ; External References
+24 ; ^DIC ICR 10006
+25 ; ^DIR ICR 10026
+26 ;
+27 ; Callable Entry Points in this Routine
+28 ;
+29 ; EN^LEXRX Task the Repair/Re-Index of one or more Files
+30 ; CHECK^LEXRX Check if a Repair/Re-Index Task is Running
+31 ; MON^LEXRX Monitor Progress of a Running Task
+32 ;
EN ; Main Entry Point
+1 NEW DIC,DIR,DIROUT,DIRUT,DTOUT,DUOUT,LEX,LEXAC,LEXAMSO,LEXENV
+2 NEW LEXFI,LEXFN,LEXMON,LEXOK,LEXRUN,LEXSTA,LEXT,LEXTY,X,Y
+3 KILL LEXMON
SET LEXENV=$$ENV^LEXRXXM
IF 'LEXENV
QUIT
+4 WRITE !," Repair/Re-Index Lexicon cross-references"
+5 SET LEXRUN=$$CHECK^LEXRXXM2
IF +LEXRUN>0
Begin DoDot:1
+6 WRITE " Try again later",!
End DoDot:1
QUIT
+7 NEW LEXAMSO,LEXFI,LEXOK
SET LEXOK=0
SET LEXAMSO=$$AMSO^LEXRXXA
+8 IF "^A^M^S^O^"'[("^"_LEXAMSO_"^")
Begin DoDot:1
+9 WRITE !!,?3,"Lexicon index Repair/Re-Index method not selected, aborting"
End DoDot:1
QUIT
+10 IF "^A^"[("^"_LEXAMSO_"^")
DO ALL
IF "^M^"[("^"_LEXAMSO_"^")
DO MAJ
+11 IF "^S^"[("^"_LEXAMSO_"^")
DO SUP
IF "^O^"[("^"_LEXAMSO_"^")
DO ONE
+12 QUIT
+13 ;
ALL ; All Files
+1 NEW LEXOK,LEXTY,LEXAMSO
KILL LEXFI
SET LEXOK=0
SET LEXAMSO="A"
+2 WRITE !!," ",$$BOLD^LEXRXXM,"Repair/Re-Index the Cross-References for all Lexicon Files",$$NORM^LEXRXXM,!
+3 WRITE !," The cross-references for the larger files will be repaired and the "
+4 WRITE !," smaller files will be re-indexed.",!
+5 WRITE !," Users may be on the system since the cross-references of the larger"
+6 WRITE !," files are not deleted and the re-indexing of the smaller files does"
+7 WRITE !," not involve the Lexicon look-up."
+8 SET LEXTY=3
SET LEXOK=$$CO^LEXRXXA
WRITE !
IF +LEXOK>0
KILL LEXFI
DO ALL^LEXRXXT
+9 QUIT
MAJ ; Major Files
+1 NEW LEXOK,LEXTY,LEXAMSO
KILL LEXFI
SET LEXOK=0
SET LEXAMSO="M"
+2 WRITE !!," ",$$BOLD^LEXRXXM,"Repair the Cross-References for the Major Lexicon Files",$$NORM^LEXRXXM,!
+3 WRITE !," The cross-references of the larger files will be repaired by "
+4 WRITE !," verifying the individual subscripts in the cross-reference. Only"
+5 WRITE !," the entries that fail verification will be deleted.",!
+6 WRITE !," Users may be on the system since the cross-references are not"
+7 WRITE !," deleted."
+8 SET LEXTY=1
SET LEXOK=$$CO^LEXRXXA
WRITE !
IF +LEXOK>0
KILL LEXFI
DO MAJ^LEXRXXT
+9 QUIT
SUP ; Supporting Files
+1 NEW LEXOK,LEXTY,LEXAMSO
KILL LEXFI
SET LEXOK=0
SET LEXAMSO="S"
+2 WRITE !!," ",$$BOLD^LEXRXXM,"Re-Index the Cross-References for the Supporting Lexicon Files",$$NORM^LEXRXXM,!
+3 WRITE !," The cross-references for the smaller files will be re-indexed.",!
+4 WRITE !," Users may be on the system since the cross-references of the smaller"
+5 WRITE !," files are not involve the Lexicon look-up."
+6 SET LEXTY=3
SET LEXOK=$$CO^LEXRXXA
WRITE !
IF +LEXOK>0
KILL LEXFI
DO SUP^LEXRXXT
+7 QUIT
ONE ; One File
+1 NEW LEXOK,LEXFI,LEXFN,LEXT,LEXTY,LEXAMSO
SET LEXAMSO="O"
SET LEXFI=$$FI^LEXRXXA
IF '$LENGTH(LEXFI)!(LEXFI["^")
WRITE !!," Lexicon file not selected, aborting"
QUIT
+2 IF +($$FV^LEXRXXM(($GET(LEXFI))))'>0
WRITE !!," Invalid file selected, aborting"
QUIT
+3 SET LEXOK=0
SET LEXFN=$$FN^LEXRXXM(LEXFI)
IF '$LENGTH(LEXFN)
QUIT
+4 SET LEXT=LEXFI
SET LEXT=LEXT_$JUSTIFY(" ",(8-$LENGTH(LEXT)))_LEXFN
SET LEXT=LEXFI_" ("_LEXFN_")"
WRITE !
+5 IF "^757^757.001^757.01^757.02^757.1^757.21^"[("^"_LEXFI_"^")
Begin DoDot:1
+6 SET LEXTY=1
WRITE !," ",$$BOLD^LEXRXXM,"Repair Cross-References for file ",LEXT,$$NORM^LEXRXXM,!
Begin DoDot:2
+7 WRITE !," The cross-references of file "_+LEXFI_" will be repaired by verifying"
+8 WRITE !," the individual subscripts in the cross-reference. Only the entries"
+9 WRITE !," that fail verification will be deleted. Users may be on the system"
+10 WRITE !," since the cross-references are not deleted."
End DoDot:2
End DoDot:1
+11 IF "^757^757.001^757.01^757.02^757.1^757.21^"'[("^"_LEXFI_"^")
Begin DoDot:1
+12 SET LEXTY=2
WRITE !," ",$$BOLD^LEXRXXM,"Re-Index Cross-References for file ",LEXT,$$NORM^LEXRXXM,!
Begin DoDot:2
+13 WRITE !," The cross-references of file "_+LEXFI_" will be re-indexed. Users may"
+14 WRITE !," be on the system since this file is not involved in the Lexicon "
+15 WRITE !," look-up."
End DoDot:2
End DoDot:1
+16 SET LEXOK=$$CO^LEXRXXA
WRITE !
IF +LEXOK>0
IF $LENGTH($GET(LEXFI))
DO ONE^LEXRXXT
+17 QUIT
+18 ;
CHECK ; Check if a Repair/Re-Index Task is Running
+1 NEW LEXSTA
KILL LEXMON
SET LEXSTA=$$CHECK^LEXRXXM2
+2 IF +($GET(LEXSTA))'>0
WRITE !!," Lexicon cross-reference repair is not running",!
+3 QUIT
+4 ;
MON ; Monitor Progress of a Running Task
+1 NEW LEXMON
SET LEXMON=""
DO MON^LEXRXXM2
+2 QUIT
+3 ;
+4 ; Miscellaneous
FORCE ; Forced Repair/Re-Index
+1 KILL ^TMP("LEXRX",$JOB),^XTMP("LEXRXALL"),^XTMP("LEXRXMAJ"),^XTMP("LEXRXSUP"),^XTMP("LEXRXONE"),^XTMP("LEXRXSET"),^XTMP("LEXRXFIX")
+2 DO CLR
DO EN
+3 QUIT
CLR ; Clear
+1 NEW LEXID
KILL LEXFIX,LEXSET,LEXTEST
+2 QUIT