LEXXFI4 ;ISL/KER - File Info - Record Counts (2) ;04/21/2014
;;2.0;LEXICON UTILITY;**32,80**;Sep 23, 1996;Build 1
;
; Global Variables
; ^TMP("LEXCNT") SACC 2.3.2.5.1
;
; External References
; $$FMDIFF^XLFDT ICR 10103
;
Q
DSP ; Display Results
N LEXFP,LEXCT,LEXFI,LEXGTOT,LEXHSF,LEXJOB,LEXMD,LEXX,LEXLVL,LEXML
N LEXNCFI,LEXNFI,LEXNPAR,LEXOPAR,LEXO,LEXPAR,LEXTAB,LEXTXT
S (LEXCT,LEXGTOT,LEXML)=0,LEXOPAR=""
S LEXJOB=$J S:+($G(LEXMD))>0 LEXJOB=+($G(LEXMD))
K:$D(LEXMD) LEXMD S LEXFP="" S LEXFP=""
F S LEXFP=$O(^TMP("LEXCNT",LEXJOB,"ORDER",LEXFP)) Q:LEXFP="" D
. S LEXO=""
. F S LEXO=$O(^TMP("LEXCNT",LEXJOB,"ORDER",LEXFP,LEXO)) Q:LEXO="" D
. . N LEXFI,LEXPAR,LEXLVL,LEXTAB,LEXTXT,LEXHSF,LEXX
. . S LEXTAB="",LEXHSF=0
. . S LEXPAR=$G(^TMP("LEXCNT",LEXJOB,"ORDER",LEXFP,LEXO))
. . S LEXFI=+($P(LEXPAR,"^",2)),LEXLVL=+($P(LEXPAR,"^",3))
. . S LEXPAR=+($P(LEXPAR,"^",1)) Q:LEXPAR=0
. . S LEXNFI=$O(^TMP("LEXCNT",LEXJOB,LEXPAR,LEXPAR))
. . S:LEXNFI>0&(LEXNFI'=LEXPAR) LEXHSF=1
. . S LEXX=$G(^TMP("LEXCNT",LEXJOB,LEXPAR,LEXFI)),LEXCT=LEXCT+1
. . S LEXNPAR=$O(^TMP("LEXCNT",LEXJOB,"ORDER",LEXFP,LEXO))
. . S LEXNPAR=$P(LEXNPAR,";",1)
. . S LEXNCFI=$O(^TMP("LEXCNT",LEXJOB,"ORDER",LEXFP))
. . I '$L(LEXNPAR),$L(LEXNCFI) S LEXML=1
. . I LEXCT=1 D TTL,HDR
. . I +LEXFI>0 D TSF
. . I +LEXFI'>0,+($G(LEXHSF))>0 D GTSF
D GT,CK
Q
TSF ; Total for a Single File/Sub-File
N LEXNM,LEXTAB,LEXTOT,LEXTXT,LEXTYP
S LEXX=$G(LEXX),LEXTOT=+LEXX,LEXNM=$P(LEXX,"^",2)
S LEXTYP=$P(LEXX,"^",3),LEXTAB=""
Q:+LEXTOT'>0 Q:'$L(LEXNM) Q:'$L(LEXTYP)
S $P(LEXTAB," ",(+($G(LEXLVL))*2))=""
S LEXTXT=" "_LEXTAB_LEXNM_" ("_LEXTYP_")"
S LEXTXT=LEXTXT_$J("",(60-$L(LEXTXT)))_$J(LEXTOT,9)
S LEXGTOT=+($G(LEXGTOT))+LEXTOT D TL^LEXXFI8(LEXTXT)
Q
GTSF ; Grand Total for a Single File
N LEXLVL,LEXNM,LEXTAB,LEXTOT,LEXTXT,LEXTYP,LEXX
S LEXX=$G(^TMP("LEXCNT",LEXJOB,LEXPAR,LEXPAR)),LEXLVL=+($$ML)+2
S LEXNM=$P(LEXX,"^",2),LEXTYP=$P(LEXX,"^",3) Q:'$L(LEXNM) Q:'$L(LEXTYP)
S LEXTAB="",LEXX=$G(^TMP("LEXCNT",LEXJOB,LEXPAR,0))
S LEXTOT=+LEXX,$P(LEXTAB," ",(LEXLVL*2))=""
S LEXTXT=" "_LEXTAB_" - Total Records for "_LEXTYP
S LEXTXT=LEXTXT_$J("",(60-$L(LEXTXT)))_$J(LEXTOT,9)
D TL^LEXXFI8(LEXTXT)
Q
GT ; Grand Totals for Multiple Files
N LEXCT,LEXFI,LEXTXT S LEXCT=0,LEXFI="" I +($G(LEXGTOT))>0,+($G(LEXML))>0 D
. D BL^LEXXFI8 S LEXTXT=" GRAND TOTAL (ALL FILES) "
. S LEXTXT=LEXTXT_$J("",(50-$L(LEXTXT)))_$J(LEXGTOT,19) D TL^LEXXFI8(LEXTXT)
Q
TTL ; Record Count Title
D:+($G(LEXMUL))>0 TT^LEXXFI8("","Record Counts")
D:+($G(LEXMUL))'>0 TT^LEXXFI8($G(LEXFI),"Record Count")
D BL^LEXXFI8
Q
HDR ; Record Count Header
N LEXTXT S LEXTXT=" Name (File Number)"
S LEXTXT=LEXTXT_$J("",(60-$L(LEXTXT)))_$J("Entries",9) D TL^LEXXFI8(LEXTXT)
S LEXTXT=" -------------------------------------------------"
S LEXTXT=LEXTXT_$J("",(60-$L(LEXTXT)))_$J("-------",9) D TL^LEXXFI8(LEXTXT)
Q
CK ; Records Checked
N LEXF,LEXS,LEXFT,LEXST,LEXJ S LEXJ=$S(+($G(LEXJOB))>0:+($G(LEXJOB)),1:$J)
S LEXF=+($G(^TMP("LEXCNT",LEXJ,"CNT")))
S LEXFT=$S(LEXF=1:"1 File",LEXF>1:(LEXF_" Files"),1:"")
S LEXS=+($G(^TMP("LEXCNT",LEXJ,"SUB")))
S LEXST=$S(LEXS=1:"1 Sub-File",LEXS>1:(LEXS_" Sub-Files"),1:"")
I (LEXF+LEXS)>1 D
. S LEXTXT=" " S:$L(LEXFT) LEXTXT=LEXTXT_LEXFT
. S:$L(LEXFT)&($L(LEXST)) LEXTXT=LEXTXT_" and "_LEXST
. S:'$L(LEXFT)&($L(LEXST)) LEXTXT=LEXTXT_LEXST
. I $L(LEXFT)!($L(LEXST)) S LEXTXT=LEXTXT_" Checked" D
. . D BL^LEXXFI8,TL^LEXXFI8(LEXTXT)
Q
ML(X) ; Maximum Level
N LEXJ S LEXJ=$S(+($G(LEXJOB))>0:+($G(LEXJOB)),1:$J)
S X=+($G(^TMP("LEXCNT",LEXJ,"LVL"))) S:+X'>0 X=1
Q X
NF(X) ; Number of Files
N LEXJ S LEXJ=$S(+($G(LEXJOB))>0:+($G(LEXJOB)),1:$J)
S X=+($G(^TMP("LEXCNT",LEXJ,"CNT")))
Q X
NS(X) ; Number of Sub-Files
N LEXJ S LEXJ=$S(+($G(LEXJOB))>0:+($G(LEXJOB)),1:$J)
S X=+($G(^TMP("LEXCNT",LEXJ,"SUB")))
Q X
ST ; Show TMP Array
N NN,NC S NN="^TMP(""LEXCNT"")",NC="^TMP(""LEXCNT"","
F S NN=$Q(@NN) Q:NN=""!(NN'[NC) D
. W !,NN,"=",@NN
Q
EP(X,Y) ; Elapsed Time (Begin, End)
N LEXTIM,LEXBEG,LEXEND
S LEXBEG=$G(X),LEXEND=$G(Y) Q:+LEXBEG'>0 "" Q:+LEXEND'>0 ""
S LEXTIM=$$FMDIFF^XLFDT(LEXEND,LEXBEG,2) Q:+LEXTIM'>0 "00:00:00"
S LEXTIM=$$TIM(LEXTIM)
Q LEXTIM
TIM(X) ; Format Time Elapsed
N LEXD,LEXH,LEXM,LEXS,LEXT,LEXV S X=+($G(X)) Q:X'>0 "00:00:00"
S LEXD=X\86400 S LEXV=LEXD*86400 S:+LEXV>0&(LEXV<X) X=X-LEXV
S LEXH=X\3600 S LEXV=LEXH*3600 S:+LEXV>0&(LEXV<X) X=X-LEXV
S:$L(LEXH)<2 LEXH="0"_LEXH S:$L(LEXH)<2 LEXH="0"_LEXH
S LEXM=X\60 S LEXV=LEXM*60 S:+LEXV>0&(LEXV<X) X=X-LEXV
S:$L(LEXM)<2 LEXM="0"_LEXM S:$L(LEXM)<2 LEXM="0"_LEXM
S LEXS=X S:$L(LEXS)<2 LEXS="0"_LEXS S:$L(LEXS)<2 LEXS="0"_LEXS
S LEXT="" S:+LEXD>0 LEXT=+LEXD_" day"_$S(+LEXD>1:"s",1:"")_" "
S LEXT=LEXT_LEXH_":"_LEXM_":"_LEXS,X=LEXT
Q X
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HLEXXFI4 4943 printed Nov 22, 2024@17:20:12 Page 2
LEXXFI4 ;ISL/KER - File Info - Record Counts (2) ;04/21/2014
+1 ;;2.0;LEXICON UTILITY;**32,80**;Sep 23, 1996;Build 1
+2 ;
+3 ; Global Variables
+4 ; ^TMP("LEXCNT") SACC 2.3.2.5.1
+5 ;
+6 ; External References
+7 ; $$FMDIFF^XLFDT ICR 10103
+8 ;
+9 QUIT
DSP ; Display Results
+1 NEW LEXFP,LEXCT,LEXFI,LEXGTOT,LEXHSF,LEXJOB,LEXMD,LEXX,LEXLVL,LEXML
+2 NEW LEXNCFI,LEXNFI,LEXNPAR,LEXOPAR,LEXO,LEXPAR,LEXTAB,LEXTXT
+3 SET (LEXCT,LEXGTOT,LEXML)=0
SET LEXOPAR=""
+4 SET LEXJOB=$JOB
if +($GET(LEXMD))>0
SET LEXJOB=+($GET(LEXMD))
+5 if $DATA(LEXMD)
KILL LEXMD
SET LEXFP=""
SET LEXFP=""
+6 FOR
SET LEXFP=$ORDER(^TMP("LEXCNT",LEXJOB,"ORDER",LEXFP))
if LEXFP=""
QUIT
Begin DoDot:1
+7 SET LEXO=""
+8 FOR
SET LEXO=$ORDER(^TMP("LEXCNT",LEXJOB,"ORDER",LEXFP,LEXO))
if LEXO=""
QUIT
Begin DoDot:2
+9 NEW LEXFI,LEXPAR,LEXLVL,LEXTAB,LEXTXT,LEXHSF,LEXX
+10 SET LEXTAB=""
SET LEXHSF=0
+11 SET LEXPAR=$GET(^TMP("LEXCNT",LEXJOB,"ORDER",LEXFP,LEXO))
+12 SET LEXFI=+($PIECE(LEXPAR,"^",2))
SET LEXLVL=+($PIECE(LEXPAR,"^",3))
+13 SET LEXPAR=+($PIECE(LEXPAR,"^",1))
if LEXPAR=0
QUIT
+14 SET LEXNFI=$ORDER(^TMP("LEXCNT",LEXJOB,LEXPAR,LEXPAR))
+15 if LEXNFI>0&(LEXNFI'=LEXPAR)
SET LEXHSF=1
+16 SET LEXX=$GET(^TMP("LEXCNT",LEXJOB,LEXPAR,LEXFI))
SET LEXCT=LEXCT+1
+17 SET LEXNPAR=$ORDER(^TMP("LEXCNT",LEXJOB,"ORDER",LEXFP,LEXO))
+18 SET LEXNPAR=$PIECE(LEXNPAR,";",1)
+19 SET LEXNCFI=$ORDER(^TMP("LEXCNT",LEXJOB,"ORDER",LEXFP))
+20 IF '$LENGTH(LEXNPAR)
IF $LENGTH(LEXNCFI)
SET LEXML=1
+21 IF LEXCT=1
DO TTL
DO HDR
+22 IF +LEXFI>0
DO TSF
+23 IF +LEXFI'>0
IF +($GET(LEXHSF))>0
DO GTSF
End DoDot:2
End DoDot:1
+24 DO GT
DO CK
+25 QUIT
TSF ; Total for a Single File/Sub-File
+1 NEW LEXNM,LEXTAB,LEXTOT,LEXTXT,LEXTYP
+2 SET LEXX=$GET(LEXX)
SET LEXTOT=+LEXX
SET LEXNM=$PIECE(LEXX,"^",2)
+3 SET LEXTYP=$PIECE(LEXX,"^",3)
SET LEXTAB=""
+4 if +LEXTOT'>0
QUIT
if '$LENGTH(LEXNM)
QUIT
if '$LENGTH(LEXTYP)
QUIT
+5 SET $PIECE(LEXTAB," ",(+($GET(LEXLVL))*2))=""
+6 SET LEXTXT=" "_LEXTAB_LEXNM_" ("_LEXTYP_")"
+7 SET LEXTXT=LEXTXT_$JUSTIFY("",(60-$LENGTH(LEXTXT)))_$JUSTIFY(LEXTOT,9)
+8 SET LEXGTOT=+($GET(LEXGTOT))+LEXTOT
DO TL^LEXXFI8(LEXTXT)
+9 QUIT
GTSF ; Grand Total for a Single File
+1 NEW LEXLVL,LEXNM,LEXTAB,LEXTOT,LEXTXT,LEXTYP,LEXX
+2 SET LEXX=$GET(^TMP("LEXCNT",LEXJOB,LEXPAR,LEXPAR))
SET LEXLVL=+($$ML)+2
+3 SET LEXNM=$PIECE(LEXX,"^",2)
SET LEXTYP=$PIECE(LEXX,"^",3)
if '$LENGTH(LEXNM)
QUIT
if '$LENGTH(LEXTYP)
QUIT
+4 SET LEXTAB=""
SET LEXX=$GET(^TMP("LEXCNT",LEXJOB,LEXPAR,0))
+5 SET LEXTOT=+LEXX
SET $PIECE(LEXTAB," ",(LEXLVL*2))=""
+6 SET LEXTXT=" "_LEXTAB_" - Total Records for "_LEXTYP
+7 SET LEXTXT=LEXTXT_$JUSTIFY("",(60-$LENGTH(LEXTXT)))_$JUSTIFY(LEXTOT,9)
+8 DO TL^LEXXFI8(LEXTXT)
+9 QUIT
GT ; Grand Totals for Multiple Files
+1 NEW LEXCT,LEXFI,LEXTXT
SET LEXCT=0
SET LEXFI=""
IF +($GET(LEXGTOT))>0
IF +($GET(LEXML))>0
Begin DoDot:1
+2 DO BL^LEXXFI8
SET LEXTXT=" GRAND TOTAL (ALL FILES) "
+3 SET LEXTXT=LEXTXT_$JUSTIFY("",(50-$LENGTH(LEXTXT)))_$JUSTIFY(LEXGTOT,19)
DO TL^LEXXFI8(LEXTXT)
End DoDot:1
+4 QUIT
TTL ; Record Count Title
+1 if +($GET(LEXMUL))>0
DO TT^LEXXFI8("","Record Counts")
+2 if +($GET(LEXMUL))'>0
DO TT^LEXXFI8($GET(LEXFI),"Record Count")
+3 DO BL^LEXXFI8
+4 QUIT
HDR ; Record Count Header
+1 NEW LEXTXT
SET LEXTXT=" Name (File Number)"
+2 SET LEXTXT=LEXTXT_$JUSTIFY("",(60-$LENGTH(LEXTXT)))_$JUSTIFY("Entries",9)
DO TL^LEXXFI8(LEXTXT)
+3 SET LEXTXT=" -------------------------------------------------"
+4 SET LEXTXT=LEXTXT_$JUSTIFY("",(60-$LENGTH(LEXTXT)))_$JUSTIFY("-------",9)
DO TL^LEXXFI8(LEXTXT)
+5 QUIT
CK ; Records Checked
+1 NEW LEXF,LEXS,LEXFT,LEXST,LEXJ
SET LEXJ=$SELECT(+($GET(LEXJOB))>0:+($GET(LEXJOB)),1:$JOB)
+2 SET LEXF=+($GET(^TMP("LEXCNT",LEXJ,"CNT")))
+3 SET LEXFT=$SELECT(LEXF=1:"1 File",LEXF>1:(LEXF_" Files"),1:"")
+4 SET LEXS=+($GET(^TMP("LEXCNT",LEXJ,"SUB")))
+5 SET LEXST=$SELECT(LEXS=1:"1 Sub-File",LEXS>1:(LEXS_" Sub-Files"),1:"")
+6 IF (LEXF+LEXS)>1
Begin DoDot:1
+7 SET LEXTXT=" "
if $LENGTH(LEXFT)
SET LEXTXT=LEXTXT_LEXFT
+8 if $LENGTH(LEXFT)&($LENGTH(LEXST))
SET LEXTXT=LEXTXT_" and "_LEXST
+9 if '$LENGTH(LEXFT)&($LENGTH(LEXST))
SET LEXTXT=LEXTXT_LEXST
+10 IF $LENGTH(LEXFT)!($LENGTH(LEXST))
SET LEXTXT=LEXTXT_" Checked"
Begin DoDot:2
+11 DO BL^LEXXFI8
DO TL^LEXXFI8(LEXTXT)
End DoDot:2
End DoDot:1
+12 QUIT
ML(X) ; Maximum Level
+1 NEW LEXJ
SET LEXJ=$SELECT(+($GET(LEXJOB))>0:+($GET(LEXJOB)),1:$JOB)
+2 SET X=+($GET(^TMP("LEXCNT",LEXJ,"LVL")))
if +X'>0
SET X=1
+3 QUIT X
NF(X) ; Number of Files
+1 NEW LEXJ
SET LEXJ=$SELECT(+($GET(LEXJOB))>0:+($GET(LEXJOB)),1:$JOB)
+2 SET X=+($GET(^TMP("LEXCNT",LEXJ,"CNT")))
+3 QUIT X
NS(X) ; Number of Sub-Files
+1 NEW LEXJ
SET LEXJ=$SELECT(+($GET(LEXJOB))>0:+($GET(LEXJOB)),1:$JOB)
+2 SET X=+($GET(^TMP("LEXCNT",LEXJ,"SUB")))
+3 QUIT X
ST ; Show TMP Array
+1 NEW NN,NC
SET NN="^TMP(""LEXCNT"")"
SET NC="^TMP(""LEXCNT"","
+2 FOR
SET NN=$QUERY(@NN)
if NN=""!(NN'[NC)
QUIT
Begin DoDot:1
+3 WRITE !,NN,"=",@NN
End DoDot:1
+4 QUIT
EP(X,Y) ; Elapsed Time (Begin, End)
+1 NEW LEXTIM,LEXBEG,LEXEND
+2 SET LEXBEG=$GET(X)
SET LEXEND=$GET(Y)
if +LEXBEG'>0
QUIT ""
if +LEXEND'>0
QUIT ""
+3 SET LEXTIM=$$FMDIFF^XLFDT(LEXEND,LEXBEG,2)
if +LEXTIM'>0
QUIT "00:00:00"
+4 SET LEXTIM=$$TIM(LEXTIM)
+5 QUIT LEXTIM
TIM(X) ; Format Time Elapsed
+1 NEW LEXD,LEXH,LEXM,LEXS,LEXT,LEXV
SET X=+($GET(X))
if X'>0
QUIT "00:00:00"
+2 SET LEXD=X\86400
SET LEXV=LEXD*86400
if +LEXV>0&(LEXV<X)
SET X=X-LEXV
+3 SET LEXH=X\3600
SET LEXV=LEXH*3600
if +LEXV>0&(LEXV<X)
SET X=X-LEXV
+4 if $LENGTH(LEXH)<2
SET LEXH="0"_LEXH
if $LENGTH(LEXH)<2
SET LEXH="0"_LEXH
+5 SET LEXM=X\60
SET LEXV=LEXM*60
if +LEXV>0&(LEXV<X)
SET X=X-LEXV
+6 if $LENGTH(LEXM)<2
SET LEXM="0"_LEXM
if $LENGTH(LEXM)<2
SET LEXM="0"_LEXM
+7 SET LEXS=X
if $LENGTH(LEXS)<2
SET LEXS="0"_LEXS
if $LENGTH(LEXS)<2
SET LEXS="0"_LEXS
+8 SET LEXT=""
if +LEXD>0
SET LEXT=+LEXD_" day"_$SELECT(+LEXD>1:"s",1:"")_" "
+9 SET LEXT=LEXT_LEXH_":"_LEXM_":"_LEXS
SET X=LEXT
+10 QUIT X