DG488M ;ALB/GN - MONITOR/MAIL CLEANUP PATIENT RELATION & INCOME FILES;12/11/02 ; 2/4/03 12:56pm
;;5.3;REGISTRATION;**488,1015**;5-1-2001;Build 21
;
Q
;
MONITOR ; Monitor job while running
N IOINORM,IOINHI,IOUON,IOUOFF,IOBON,IOBOFF,IORVON,IORVOFF,IOHOME
N IOELEOL,NAMSPC,DGT12,DG12,DG12X,DGT21,DG21,DG21X,DGT22,DG22,DG22X
N STAT,DGLINE,DGBLNK,NOWTIM,%H,DTOUT,I,DGLEN,DGQUIT,TITLE,TLEN,X,REC
N NAMSPC,NOWTIME,PCT,TESTING,TASKID,MODE,BTIME,DGFIL,DGIEN,STIME,RUN
S:'$D(U) U="^"
S NAMSPC=$$NAMSPC^DG488
S DGQUIT=0
D SCRNSET
S TESTING=+$G(^XTMP(NAMSPC,0,"TESTING"))
S TASKID=$G(^XTMP(NAMSPC,0,"TASKID"))
;
F D Q:DGQUIT
. ;check lock status
. L +^XTMP(NAMSPC):3
. I '$T S RUN=1
. E S RUN=0
. L -^XTMP(NAMSPC)
. ;get last run info
. D GETLAST^DG488
. S:STAT="" STAT="NOT RUNNING"
. S NOWTIME=$$NOW^XLFDT
. I (RUN&(STAT'="RUNNING"))!('RUN&(STAT="RUNNING")) D
. . S STAT="ERRORED"
. D CLRSCR
. S $P(DGBLNK," ",81)=""
. S DGLINE=DGBLNK
. S TITLE=$P($G(^XTMP(NAMSPC,0),"^^DG488 JOB"),U,3)
. S TLEN=(80-$L(TITLE)\2)
. W $$FMTE^XLFDT($$NOW^XLFDT,"2P")
. S MODE=$S(TESTING:"TEST",1:"LIVE")
. W ?32,"** ",MODE," MODE **"
. W ?63,"Task ID: ",TASKID
. W !!
. ;title line
. W ?TLEN,IOINHI,IOUON,TITLE,IOUOFF,IOINORM,!
. ;begin next line
. S DGLINE=DGBLNK
. S DGLINE=$$FMTLINE(DGLINE,4,"Status")
. S DGLINE=$$FMTLINE(DGLINE,30,"Last ien")
. S DGLINE=$$FMTLINE(DGLINE,58,"Completed Time")
. W !!,IORVON,DGLINE,IORVOFF
. ;begin next line
. S DGLINE=DGBLNK
. S DGLINE=$$FMTLINE(DGLINE,4,STAT)
. S DGLINE=$$FMTLINE(DGLINE,26,DGFIL_"/"_DGIEN)
. S DGLINE=$$FMTLINE(DGLINE,58,$$FMTE^XLFDT(STIME,2))
. W !,DGLINE
. ;begin next line
. S DGLINE=DGBLNK
. S DGLINE=$$FMTLINE(DGLINE,5,"Tot 408.12 recs")
. S DGLINE=$$FMTLINE(DGLINE,30,"408.12 recs purged")
. S DGLINE=$$FMTLINE(DGLINE,55,"408.12 bad xrefs")
. W !!,IORVON,DGLINE,IORVOFF
. ;begin next line
. S DGLINE=DGBLNK
. S DGLINE=$$FMTLINE(DGLINE,7,$J($FN(DGT12,","),10))
. S DGLINE=$$FMTLINE(DGLINE,32,$J($FN(DG12,","),10))
. S DGLINE=$$FMTLINE(DGLINE,57,$J($FN(DG12X,","),10))
. W !,DGLINE
. ;begin next line
. S DGLINE=DGBLNK
. S DGLINE=$$FMTLINE(DGLINE,5,"Tot 408.21 recs")
. S DGLINE=$$FMTLINE(DGLINE,30,"408.21 recs purged")
. S DGLINE=$$FMTLINE(DGLINE,55,"408.21 bad xrefs")
. W !!,IORVON,DGLINE,IORVOFF
. ;begin next line
. S DGLINE=DGBLNK
. S DGLINE=$$FMTLINE(DGLINE,7,$J($FN(DGT21,","),10))
. S DGLINE=$$FMTLINE(DGLINE,32,$J($FN(DG21,","),10))
. S DGLINE=$$FMTLINE(DGLINE,57,$J($FN(DG21X,","),10))
. W !,DGLINE
. ;begin next line
. S DGLINE=DGBLNK
. S DGLINE=$$FMTLINE(DGLINE,5,"Tot 408.22 recs")
. S DGLINE=$$FMTLINE(DGLINE,30,"408.22 recs purged")
. S DGLINE=$$FMTLINE(DGLINE,55,"408.22 bad xrefs")
. W !!,IORVON,DGLINE,IORVOFF
. ;begin next line
. S DGLINE=DGBLNK
. S DGLINE=$$FMTLINE(DGLINE,7,$J($FN(DGT22,","),10))
. S DGLINE=$$FMTLINE(DGLINE,32,$J($FN(DG22,","),10))
. S DGLINE=$$FMTLINE(DGLINE,57,$J($FN(DG22X,","),10))
. W !,DGLINE
. ;begin next line
. S DGLINE=DGBLNK
. W !!!
. K DIR
. S DIR("T")=5
. W ?15,"screen refreshes automatically every "_DIR("T")_" seconds",!
. W !!,"Press "_IORVON_"<Enter>"_IORVOFF_" to Stop Monitor...",!
. S DIR(0)="EA"
. D ^DIR
. I '$D(DTOUT) S DGQUIT=1
. I STAT'="RUNNING" S DGQUIT=1
W @IOF
Q
;
FMTLINE(DGLINE,DGTB,DGTX) ; format a line
N DGEND
S DGLEN=$L(DGTX)
S DGEND=DGTB+DGLEN-1
S $E(DGLINE,DGTB,DGEND)=DGTX
Q DGLINE
;
SCRNSET ; setup screen variables
S:'$D(IOST(0)) IOST(0)="C-VT320"
S X="IOINORM;IOINHI;IOUON;IOUOFF;IOBON;IOBOFF;IORVON;IORVOFF;IOHOME"
S X=X_";IOELEOL" D ENDR^%ZISS
Q
;
CLRSCR ; clear screen and return to normal
W IOHOME,IORVOFF,IOBOFF,IOUOFF,IOINORM,@IOF
S $X=0,$Y=0
Q
;
MAIL ; mail stats
N HTEXT,TEXT,NAMSPC,LIN
S LIN=0
S NAMSPC=$$NAMSPC^DG488
K ^TMP(NAMSPC,$J)
;get last run data
D GETLAST^DG488
;build text for message
S HTEXT=ZTDESC_" "_STAT_" on "
S HTEXT=HTEXT_$$FMTE^XLFDT(STIME)
D BLDLINE(HTEXT)
D BLDLINE("Elapsed time: "_$$FMDIFF^XLFDT(STIME,BTIME,3))
D BLDLINE("")
I TESTING S TEXT="** TESTING **" D BLDLINE(TEXT)
D BLDLINE("")
S TEXT=" Total 408.12 Records Processed: "_$J($FN(DGT12,","),11)
D BLDLINE(TEXT)
S TEXT=" 408.12 bad records purged: "_$J($FN(DG12,","),11)
D BLDLINE(TEXT)
S TEXT=" 408.12 bad xrefs purged: "_$J($FN(DG12X,","),11)
D BLDLINE(TEXT)
D BLDLINE("")
S TEXT=" Total 408.21 Records Processed: "_$J($FN(DGT21,","),11)
D BLDLINE(TEXT)
S TEXT=" 408.21 bad records purged: "_$J($FN(DG21,","),11)
D BLDLINE(TEXT)
S TEXT=" 408.21 bad xrefs purged: "_$J($FN(DG21X,","),11)
D BLDLINE(TEXT)
D BLDLINE("")
S TEXT=" Total 408.22 Records Processed: "_$J($FN(DGT22,","),11)
D BLDLINE(TEXT)
S TEXT=" 408.22 bad records purged: "_$J($FN(DG22,","),11)
D BLDLINE(TEXT)
S TEXT=" 408.22 bad xrefs purged: "_$J($FN(DG22X,","),11)
D BLDLINE(TEXT)
;send the message
D MAILIT(HTEXT)
K ^TMP(NAMSPC,$J)
Q
;
BLDLINE(TEXT) ;
S LIN=LIN+1
S ^TMP(NAMSPC,$J,"MSG",LIN)=TEXT
Q
MAILIT(HTEXT) ; send the mail message
N XMY,XMDUZ,XMSUB,XMTEXT
S XMY(DUZ)="",XMDUZ=.5
S XMSUB=HTEXT_" Results"
S XMTEXT="^TMP(NAMSPC,$J,""MSG"","
D ^XMD
Q
;
DG488M ;ALB/GN - MONITOR/MAIL CLEANUP PATIENT RELATION & INCOME FILES;12/11/02 ; 2/4/03 12:56pm
+1 ;;5.3;REGISTRATION;**488,1015**;5-1-2001;Build 21
+2 ;
+3 QUIT
+4 ;
MONITOR ; Monitor job while running
+1 NEW IOINORM,IOINHI,IOUON,IOUOFF,IOBON,IOBOFF,IORVON,IORVOFF,IOHOME
+2 NEW IOELEOL,NAMSPC,DGT12,DG12,DG12X,DGT21,DG21,DG21X,DGT22,DG22,DG22X
+3 NEW STAT,DGLINE,DGBLNK,NOWTIM,%H,DTOUT,I,DGLEN,DGQUIT,TITLE,TLEN,X,REC
+4 NEW NAMSPC,NOWTIME,PCT,TESTING,TASKID,MODE,BTIME,DGFIL,DGIEN,STIME,RUN
+5 IF '$DATA(U)
SET U="^"
+6 SET NAMSPC=$$NAMSPC^DG488
+7 SET DGQUIT=0
+8 DO SCRNSET
+9 SET TESTING=+$GET(^XTMP(NAMSPC,0,"TESTING"))
+10 SET TASKID=$GET(^XTMP(NAMSPC,0,"TASKID"))
+11 ;
+12 FOR
Begin DoDot:1
+13 ;check lock status
+14 LOCK +^XTMP(NAMSPC):3
+15 IF '$TEST
SET RUN=1
+16 IF '$TEST
SET RUN=0
+17 LOCK -^XTMP(NAMSPC)
+18 ;get last run info
+19 DO GETLAST^DG488
+20 IF STAT=""
SET STAT="NOT RUNNING"
+21 SET NOWTIME=$$NOW^XLFDT
+22 IF (RUN&(STAT'="RUNNING"))!('RUN&(STAT="RUNNING"))
Begin DoDot:2
+23 SET STAT="ERRORED"
End DoDot:2
+24 DO CLRSCR
+25 SET $PIECE(DGBLNK," ",81)=""
+26 SET DGLINE=DGBLNK
+27 SET TITLE=$PIECE($GET(^XTMP(NAMSPC,0),"^^DG488 JOB"),U,3)
+28 SET TLEN=(80-$LENGTH(TITLE)\2)
+29 WRITE $$FMTE^XLFDT($$NOW^XLFDT,"2P")
+30 SET MODE=$SELECT(TESTING:"TEST",1:"LIVE")
+31 WRITE ?32,"** ",MODE," MODE **"
+32 WRITE ?63,"Task ID: ",TASKID
+33 WRITE !!
+34 ;title line
+35 WRITE ?TLEN,IOINHI,IOUON,TITLE,IOUOFF,IOINORM,!
+36 ;begin next line
+37 SET DGLINE=DGBLNK
+38 SET DGLINE=$$FMTLINE(DGLINE,4,"Status")
+39 SET DGLINE=$$FMTLINE(DGLINE,30,"Last ien")
+40 SET DGLINE=$$FMTLINE(DGLINE,58,"Completed Time")
+41 WRITE !!,IORVON,DGLINE,IORVOFF
+42 ;begin next line
+43 SET DGLINE=DGBLNK
+44 SET DGLINE=$$FMTLINE(DGLINE,4,STAT)
+45 SET DGLINE=$$FMTLINE(DGLINE,26,DGFIL_"/"_DGIEN)
+46 SET DGLINE=$$FMTLINE(DGLINE,58,$$FMTE^XLFDT(STIME,2))
+47 WRITE !,DGLINE
+48 ;begin next line
+49 SET DGLINE=DGBLNK
+50 SET DGLINE=$$FMTLINE(DGLINE,5,"Tot 408.12 recs")
+51 SET DGLINE=$$FMTLINE(DGLINE,30,"408.12 recs purged")
+52 SET DGLINE=$$FMTLINE(DGLINE,55,"408.12 bad xrefs")
+53 WRITE !!,IORVON,DGLINE,IORVOFF
+54 ;begin next line
+55 SET DGLINE=DGBLNK
+56 SET DGLINE=$$FMTLINE(DGLINE,7,$JUSTIFY($FNUMBER(DGT12,","),10))
+57 SET DGLINE=$$FMTLINE(DGLINE,32,$JUSTIFY($FNUMBER(DG12,","),10))
+58 SET DGLINE=$$FMTLINE(DGLINE,57,$JUSTIFY($FNUMBER(DG12X,","),10))
+59 WRITE !,DGLINE
+60 ;begin next line
+61 SET DGLINE=DGBLNK
+62 SET DGLINE=$$FMTLINE(DGLINE,5,"Tot 408.21 recs")
+63 SET DGLINE=$$FMTLINE(DGLINE,30,"408.21 recs purged")
+64 SET DGLINE=$$FMTLINE(DGLINE,55,"408.21 bad xrefs")
+65 WRITE !!,IORVON,DGLINE,IORVOFF
+66 ;begin next line
+67 SET DGLINE=DGBLNK
+68 SET DGLINE=$$FMTLINE(DGLINE,7,$JUSTIFY($FNUMBER(DGT21,","),10))
+69 SET DGLINE=$$FMTLINE(DGLINE,32,$JUSTIFY($FNUMBER(DG21,","),10))
+70 SET DGLINE=$$FMTLINE(DGLINE,57,$JUSTIFY($FNUMBER(DG21X,","),10))
+71 WRITE !,DGLINE
+72 ;begin next line
+73 SET DGLINE=DGBLNK
+74 SET DGLINE=$$FMTLINE(DGLINE,5,"Tot 408.22 recs")
+75 SET DGLINE=$$FMTLINE(DGLINE,30,"408.22 recs purged")
+76 SET DGLINE=$$FMTLINE(DGLINE,55,"408.22 bad xrefs")
+77 WRITE !!,IORVON,DGLINE,IORVOFF
+78 ;begin next line
+79 SET DGLINE=DGBLNK
+80 SET DGLINE=$$FMTLINE(DGLINE,7,$JUSTIFY($FNUMBER(DGT22,","),10))
+81 SET DGLINE=$$FMTLINE(DGLINE,32,$JUSTIFY($FNUMBER(DG22,","),10))
+82 SET DGLINE=$$FMTLINE(DGLINE,57,$JUSTIFY($FNUMBER(DG22X,","),10))
+83 WRITE !,DGLINE
+84 ;begin next line
+85 SET DGLINE=DGBLNK
+86 WRITE !!!
+87 KILL DIR
+88 SET DIR("T")=5
+89 WRITE ?15,"screen refreshes automatically every "_DIR("T")_" seconds",!
+90 WRITE !!,"Press "_IORVON_"<Enter>"_IORVOFF_" to Stop Monitor...",!
+91 SET DIR(0)="EA"
+92 DO ^DIR
+93 IF '$DATA(DTOUT)
SET DGQUIT=1
+94 IF STAT'="RUNNING"
SET DGQUIT=1
End DoDot:1
IF DGQUIT
QUIT
+95 WRITE @IOF
+96 QUIT
+97 ;
FMTLINE(DGLINE,DGTB,DGTX) ; format a line
+1 NEW DGEND
+2 SET DGLEN=$LENGTH(DGTX)
+3 SET DGEND=DGTB+DGLEN-1
+4 SET $EXTRACT(DGLINE,DGTB,DGEND)=DGTX
+5 QUIT DGLINE
+6 ;
SCRNSET ; setup screen variables
+1 IF '$DATA(IOST(0))
SET IOST(0)="C-VT320"
+2 SET X="IOINORM;IOINHI;IOUON;IOUOFF;IOBON;IOBOFF;IORVON;IORVOFF;IOHOME"
+3 SET X=X_";IOELEOL"
DO ENDR^%ZISS
+4 QUIT
+5 ;
CLRSCR ; clear screen and return to normal
+1 WRITE IOHOME,IORVOFF,IOBOFF,IOUOFF,IOINORM,@IOF
+2 SET $X=0
SET $Y=0
+3 QUIT
+4 ;
MAIL ; mail stats
+1 NEW HTEXT,TEXT,NAMSPC,LIN
+2 SET LIN=0
+3 SET NAMSPC=$$NAMSPC^DG488
+4 KILL ^TMP(NAMSPC,$JOB)
+5 ;get last run data
+6 DO GETLAST^DG488
+7 ;build text for message
+8 SET HTEXT=ZTDESC_" "_STAT_" on "
+9 SET HTEXT=HTEXT_$$FMTE^XLFDT(STIME)
+10 DO BLDLINE(HTEXT)
+11 DO BLDLINE("Elapsed time: "_$$FMDIFF^XLFDT(STIME,BTIME,3))
+12 DO BLDLINE("")
+13 IF TESTING
SET TEXT="** TESTING **"
DO BLDLINE(TEXT)
+14 DO BLDLINE("")
+15 SET TEXT=" Total 408.12 Records Processed: "_$JUSTIFY($FNUMBER(DGT12,","),11)
+16 DO BLDLINE(TEXT)
+17 SET TEXT=" 408.12 bad records purged: "_$JUSTIFY($FNUMBER(DG12,","),11)
+18 DO BLDLINE(TEXT)
+19 SET TEXT=" 408.12 bad xrefs purged: "_$JUSTIFY($FNUMBER(DG12X,","),11)
+20 DO BLDLINE(TEXT)
+21 DO BLDLINE("")
+22 SET TEXT=" Total 408.21 Records Processed: "_$JUSTIFY($FNUMBER(DGT21,","),11)
+23 DO BLDLINE(TEXT)
+24 SET TEXT=" 408.21 bad records purged: "_$JUSTIFY($FNUMBER(DG21,","),11)
+25 DO BLDLINE(TEXT)
+26 SET TEXT=" 408.21 bad xrefs purged: "_$JUSTIFY($FNUMBER(DG21X,","),11)
+27 DO BLDLINE(TEXT)
+28 DO BLDLINE("")
+29 SET TEXT=" Total 408.22 Records Processed: "_$JUSTIFY($FNUMBER(DGT22,","),11)
+30 DO BLDLINE(TEXT)
+31 SET TEXT=" 408.22 bad records purged: "_$JUSTIFY($FNUMBER(DG22,","),11)
+32 DO BLDLINE(TEXT)
+33 SET TEXT=" 408.22 bad xrefs purged: "_$JUSTIFY($FNUMBER(DG22X,","),11)
+34 DO BLDLINE(TEXT)
+35 ;send the message
+36 DO MAILIT(HTEXT)
+37 KILL ^TMP(NAMSPC,$JOB)
+38 QUIT
+39 ;
BLDLINE(TEXT) ;
+1 SET LIN=LIN+1
+2 SET ^TMP(NAMSPC,$JOB,"MSG",LIN)=TEXT
+3 QUIT
MAILIT(HTEXT) ; send the mail message
+1 NEW XMY,XMDUZ,XMSUB,XMTEXT
+2 SET XMY(DUZ)=""
SET XMDUZ=.5
+3 SET XMSUB=HTEXT_" Results"
+4 SET XMTEXT="^TMP(NAMSPC,$J,""MSG"","
+5 DO ^XMD
+6 QUIT
+7 ;