IVM2133A ;ALB/PHH - IVM*2.0*133 Address Change Log Cleanup ; 10/6/2008
;;2.0;INCOME VERIFICATION MATCH;**133**; 21-OCT-94;Build 2
Q
POST ; Post-Install
D START
D START^IVM2133B
Q
RESET ; Reset the data for the cleanup process
K ^XTMP($$NAMESPC)
Q
TEST ; Simulate Live Run
N MODE
S MODE=0
START ; Start Processor
N NAMESPC,QTIME
S NAMESPC=$$NAMESPC
Q:$$RUNCHK(NAMESPC) ; Quit if already running or has run to completion
Q:$$QTIME(.QTIME)
S:$D(^XTMP(NAMESPC,"CONFIG","RUN MODE")) MODE=^XTMP(NAMESPC,"CONFIG","RUN MODE")
S:'$D(^XTMP(NAMESPC,"CONFIG","RUN MODE")) ^XTMP(NAMESPC,"CONFIG","RUN MODE")=$S($G(MODE)=0:0,1:1)
S ^XTMP(NAMESPC,"CONFIG","USER")=$S($G(DUZ)'="":DUZ,1:"UNKNOWN")
S:'$$QUEUE(QTIME) ^XTMP(NAMESPC,"CONFIG","RUNNING")=""
Q
NAMESPC() ; API returns the name space for this patch
Q "IVM133A"
RUNCHK(NAMESPC) ; Check to see if clean up is already running
Q:NAMESPC="" 1 ; Name Space must be defined
Q:$D(^XTMP(NAMESPC,"CONFIG","RUNNING")) 1
Q:$D(^XTMP(NAMESPC,"CONFIG","COMPLETE")) 1
Q 0
QTIME(WHEN) ; Get the run time for queuing
N %,%H,%I,X
D NOW^%DTC
S WHEN=$P(%,".")_"."_$E($P(%,".",2),1,4)
Q 0
QUEUE(ZTDTH) ; Queue the process
N NAMESPC,QUEERR,ZTDESC,ZTRTN,ZTSK,ZTIO
S NAMESPC=$$NAMESPC
S QUEERR=0
S ZTRTN="CLEAN^IVM2"_$P(NAMESPC,"IVM",2)
S ZTDESC=NAMESPC_" - Address Change Log Cleanup Process"
S ZTIO=""
D ^%ZTLOAD
K ^XTMP(NAMESPC,"CONFIG","ZTSK")
I '$D(ZTSK) S ^XTMP(NAMESPC,"CONFIG","ZTSK")="Unable to queue post-install process.",QUEERR=1
I $D(ZTSK) S ^XTMP(NAMESPC,"CONFIG","ZTSK")="Post-install queued. Task ID: "_$G(ZTSK)
D HOME^%ZIS
Q QUEERR
CLEAN ; Actual cleanup process
N NAMESPC,MODE,USER,TASKID,%,%H,%I,X,X1,X2,CHKCNT,ZTSTOP,TMSWT,TOTADR,IEN
S NAMESPC=$$NAMESPC
K ^XTMP(NAMESPC,"CONFIG","ABORT TIME")
S MODE=$G(^XTMP(NAMESPC,"CONFIG","RUN MODE"),0)
S USER=$G(^XTMP(NAMESPC,"CONFIG","USER"),"UNKNOWN")
S TASKID=$G(^XTMP(NAMESPC,"CONFIG","ZTSK"),"UNKNOWN")
;
I '$D(^XTMP(NAMESPC,0)) D
.K ^XTMP(NAMESPC)
.S ^XTMP(NAMESPC,"CONFIG","IEN")=0
.S ^XTMP(NAMESPC,"CONFIG","TOTPR")=0
.S ^XTMP(NAMESPC,"CONFIG","PERCENT COMPLETE")=0
.S ^XTMP(NAMESPC,"CONFIG","RUN MODE")=MODE
.S ^XTMP(NAMESPC,"CONFIG","USER")=USER
.S ^XTMP(NAMESPC,"CONFIG","ZTSK")=TASKID
.D NOW^%DTC
.S ^XTMP(NAMESPC,"CONFIG","START TIME")=%
.S X1=$$DT^XLFDT,X2=90
.D C^%DTC
.S ^XTMP(NAMESPC,0)=X_U_$$DT^XLFDT_U_NAMESPC_" - ADDRESS CHANGE LOG CLEANUP"
;
S CHKCNT=250,(ZTSTOP,TMSWT)=0,TOTADR=+$P($G(^IVM(301.7,0)),"^",4)
S IEN=$G(^XTMP(NAMESPC,"CONFIG","IEN"))
F S IEN=$O(^IVM(301.7,IEN)) Q:'IEN!(TMSWT) D
.D PROC(IEN,MODE)
.S ^XTMP(NAMESPC,"CONFIG","TOTPR")=$G(^XTMP(NAMESPC,"CONFIG","TOTPR"))+1
.S ^XTMP(NAMESPC,"CONFIG","IEN")=IEN
.I TOTADR D
..S ^XTMP(NAMESPC,"CONFIG","PERCENT COMPLETE")=+$G(^XTMP(NAMESPC,"CONFIG","TOTPR"))/TOTADR
..S ^XTMP(NAMESPC,"CONFIG","PERCENT COMPLETE")=+$P((^XTMP(NAMESPC,"CONFIG","PERCENT COMPLETE")*100),".")
.I +$G(^XTMP(NAMESPC,"CONFIG","TOTPR"))#CHKCNT=0 D
..S TMSWT=$$STOPIT()
..I TMSWT D
...S ZTSTOP=1
...N %,%H,%I,X
...D NOW^%DTC
...S ^XTMP(NAMESPC,"CONFIG","ABORT TIME")=%
...D ABORTMSG
;
I 'IEN,'TMSWT D
.N %,%H,%I,X
.D NOW^%DTC
.S ^XTMP(NAMESPC,"CONFIG","COMPLETE")=%
.S ^XTMP(NAMESPC,"CONFIG","PERCENT COMPLETE")=100
.D DONEMSG
;
K ^XTMP(NAMESPC,"CONFIG","RUNNING")
Q
PROC(IEN,MODE) ; Process the IEN
; Update "IVM AUTO ADDR JOB" to "POSTMASTER"
N DA,DIE,DR,X,NAMESPC
S DA=IEN,DIE="^IVM(301.7,",DR=""
I $P($G(^IVM(301.7,IEN,0)),"^",3)="IVM AUTO ADDR JOB" S DR=DR_"2////.5"
I $P($G(^IVM(301.7,IEN,1)),"^",2)="IVM AUTO ADDR JOB" D
.I DR="" S DR="5////.5" Q
.S DR=DR_";5////.5"
Q:DR=""
S NAMESPC=$$NAMESPC
S ^XTMP(NAMESPC,"DATA",IEN)=""
S ^XTMP(NAMESPC,"CONFIG","ANOMALY")=$G(^XTMP(NAMESPC,"CONFIG","ANOMALY"))+1
;
; Update only if this is running in live mode
I MODE D ^DIE
;
S ^XTMP(NAMESPC,"CONFIG","SUCCESS")=$G(^XTMP(NAMESPC,"CONFIG","SUCCESS"))+1
Q
STOPIT() ; Checks if user requested task to stop
N X,STOPIT
S STOPIT=0
S X=$$S^%ZTLOAD
I X D ;
.S STOPIT=1
.I $G(ZTSK) S ZTSTOP=1
Q STOPIT
ABORTMSG ; Send the user aborted message:
N NAMESPC,NAMESPCN,TMP,XMY,XMDUZ,XMTEXT,XMSUB
S NAMESPC=$$NAMESPC
S NAMESPCN=+$P(NAMESPC,"IVM",2)
S XMY(DUZ)="",XMDUZ="IVM PACKAGE",XMTEXT="TMP("_NAMESPCN_","
S XMSUB="IVM*2.0*"_NAMESPCN_": ADDRESS CHANGE LOG CLEANUP - PROCESS STOPPED BY USER"
S TMP(NAMESPCN,1)="CLEANUP PROCESSING"
S TMP(NAMESPCN,2)="------------------"
S TMP(NAMESPCN,3)=""
S TMP(NAMESPCN,4)="The cleanup process was aborted prematurely. Here is the current status:"
S TMP(NAMESPCN,5)=""
S TMP(NAMESPCN,6)=" Start Date/Time: "_$$FMTE^XLFDT(+$G(^XTMP(NAMESPC,"CONFIG","START TIME")),"P")
S TMP(NAMESPCN,7)=" End Date/Time: "_$$FMTE^XLFDT(+$G(^XTMP(NAMESPC,"CONFIG","ABORT TIME")),"P")
S TMP(NAMESPCN,8)=""
S TMP(NAMESPCN,9)="Current Counts: "
S TMP(NAMESPCN,10)=" Total Records Processed: "_+$G(^XTMP(NAMESPC,"CONFIG","TOTPR"))
S TMP(NAMESPCN,11)=" Total Anomalies Corrected: "_+$G(^XTMP(NAMESPC,"CONFIG","SUCCESS"))
S TMP(NAMESPCN,12)=" Percentage Completed: "_+$G(^XTMP(NAMESPC,"CONFIG","PERCENT COMPLETE"))_"%"
S TMP(NAMESPCN,13)=""
S TMP(NAMESPCN,14)=""
D ^XMD
Q
DONEMSG ; Send the user aborted message:
N NAMESPC,NAMESPCN,TMP,XMY,XMDUZ,XMTEXT,XMSUB
S NAMESPC=$$NAMESPC
S NAMESPCN=+$P(NAMESPC,"IVM",2)
S XMY(DUZ)="",XMDUZ="IVM PACKAGE",XMTEXT="TMP("_NAMESPCN_","
S XMSUB="IVM*2.0*"_NAMESPCN_": ADDRESS CHANGE LOG CLEANUP - SUMMARY REPORT"
S TMP(NAMESPCN,1)="CLEANUP PROCESSING"
S TMP(NAMESPCN,2)="------------------"
S TMP(NAMESPCN,3)=""
S TMP(NAMESPCN,4)="The cleanup has run to completion. Here are the results:"
S TMP(NAMESPCN,5)=""
S TMP(NAMESPCN,6)=" Start Date/Time: "_$$FMTE^XLFDT(+$G(^XTMP(NAMESPC,"CONFIG","START TIME")),"P")
S TMP(NAMESPCN,7)=" End Date/Time: "_$$FMTE^XLFDT(+$G(^XTMP(NAMESPC,"CONFIG","COMPLETE")),"P")
S TMP(NAMESPCN,8)=""
S TMP(NAMESPCN,9)="Current Counts: "
S TMP(NAMESPCN,10)=" Total Records Processed: "_+$G(^XTMP(NAMESPC,"CONFIG","TOTPR"))
S TMP(NAMESPCN,11)=" Total Anomalies Corrected: "_+$G(^XTMP(NAMESPC,"CONFIG","SUCCESS"))
S TMP(NAMESPCN,12)=" Percentage Completed: 100%"
S TMP(NAMESPCN,13)=""
S TMP(NAMESPCN,14)=""
D ^XMD
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HIVM2133A 6436 printed Nov 22, 2024@17:10:56 Page 2
IVM2133A ;ALB/PHH - IVM*2.0*133 Address Change Log Cleanup ; 10/6/2008
+1 ;;2.0;INCOME VERIFICATION MATCH;**133**; 21-OCT-94;Build 2
+2 QUIT
POST ; Post-Install
+1 DO START
+2 DO START^IVM2133B
+3 QUIT
RESET ; Reset the data for the cleanup process
+1 KILL ^XTMP($$NAMESPC)
+2 QUIT
TEST ; Simulate Live Run
+1 NEW MODE
+2 SET MODE=0
START ; Start Processor
+1 NEW NAMESPC,QTIME
+2 SET NAMESPC=$$NAMESPC
+3 ; Quit if already running or has run to completion
if $$RUNCHK(NAMESPC)
QUIT
+4 if $$QTIME(.QTIME)
QUIT
+5 if $DATA(^XTMP(NAMESPC,"CONFIG","RUN MODE"))
SET MODE=^XTMP(NAMESPC,"CONFIG","RUN MODE")
+6 if '$DATA(^XTMP(NAMESPC,"CONFIG","RUN MODE"))
SET ^XTMP(NAMESPC,"CONFIG","RUN MODE")=$SELECT($GET(MODE)=0:0,1:1)
+7 SET ^XTMP(NAMESPC,"CONFIG","USER")=$SELECT($GET(DUZ)'="":DUZ,1:"UNKNOWN")
+8 if '$$QUEUE(QTIME)
SET ^XTMP(NAMESPC,"CONFIG","RUNNING")=""
+9 QUIT
NAMESPC() ; API returns the name space for this patch
+1 QUIT "IVM133A"
RUNCHK(NAMESPC) ; Check to see if clean up is already running
+1 ; Name Space must be defined
if NAMESPC=""
QUIT 1
+2 if $DATA(^XTMP(NAMESPC,"CONFIG","RUNNING"))
QUIT 1
+3 if $DATA(^XTMP(NAMESPC,"CONFIG","COMPLETE"))
QUIT 1
+4 QUIT 0
QTIME(WHEN) ; Get the run time for queuing
+1 NEW %,%H,%I,X
+2 DO NOW^%DTC
+3 SET WHEN=$PIECE(%,".")_"."_$EXTRACT($PIECE(%,".",2),1,4)
+4 QUIT 0
QUEUE(ZTDTH) ; Queue the process
+1 NEW NAMESPC,QUEERR,ZTDESC,ZTRTN,ZTSK,ZTIO
+2 SET NAMESPC=$$NAMESPC
+3 SET QUEERR=0
+4 SET ZTRTN="CLEAN^IVM2"_$PIECE(NAMESPC,"IVM",2)
+5 SET ZTDESC=NAMESPC_" - Address Change Log Cleanup Process"
+6 SET ZTIO=""
+7 DO ^%ZTLOAD
+8 KILL ^XTMP(NAMESPC,"CONFIG","ZTSK")
+9 IF '$DATA(ZTSK)
SET ^XTMP(NAMESPC,"CONFIG","ZTSK")="Unable to queue post-install process."
SET QUEERR=1
+10 IF $DATA(ZTSK)
SET ^XTMP(NAMESPC,"CONFIG","ZTSK")="Post-install queued. Task ID: "_$GET(ZTSK)
+11 DO HOME^%ZIS
+12 QUIT QUEERR
CLEAN ; Actual cleanup process
+1 NEW NAMESPC,MODE,USER,TASKID,%,%H,%I,X,X1,X2,CHKCNT,ZTSTOP,TMSWT,TOTADR,IEN
+2 SET NAMESPC=$$NAMESPC
+3 KILL ^XTMP(NAMESPC,"CONFIG","ABORT TIME")
+4 SET MODE=$GET(^XTMP(NAMESPC,"CONFIG","RUN MODE"),0)
+5 SET USER=$GET(^XTMP(NAMESPC,"CONFIG","USER"),"UNKNOWN")
+6 SET TASKID=$GET(^XTMP(NAMESPC,"CONFIG","ZTSK"),"UNKNOWN")
+7 ;
+8 IF '$DATA(^XTMP(NAMESPC,0))
Begin DoDot:1
+9 KILL ^XTMP(NAMESPC)
+10 SET ^XTMP(NAMESPC,"CONFIG","IEN")=0
+11 SET ^XTMP(NAMESPC,"CONFIG","TOTPR")=0
+12 SET ^XTMP(NAMESPC,"CONFIG","PERCENT COMPLETE")=0
+13 SET ^XTMP(NAMESPC,"CONFIG","RUN MODE")=MODE
+14 SET ^XTMP(NAMESPC,"CONFIG","USER")=USER
+15 SET ^XTMP(NAMESPC,"CONFIG","ZTSK")=TASKID
+16 DO NOW^%DTC
+17 SET ^XTMP(NAMESPC,"CONFIG","START TIME")=%
+18 SET X1=$$DT^XLFDT
SET X2=90
+19 DO C^%DTC
+20 SET ^XTMP(NAMESPC,0)=X_U_$$DT^XLFDT_U_NAMESPC_" - ADDRESS CHANGE LOG CLEANUP"
End DoDot:1
+21 ;
+22 SET CHKCNT=250
SET (ZTSTOP,TMSWT)=0
SET TOTADR=+$PIECE($GET(^IVM(301.7,0)),"^",4)
+23 SET IEN=$GET(^XTMP(NAMESPC,"CONFIG","IEN"))
+24 FOR
SET IEN=$ORDER(^IVM(301.7,IEN))
if 'IEN!(TMSWT)
QUIT
Begin DoDot:1
+25 DO PROC(IEN,MODE)
+26 SET ^XTMP(NAMESPC,"CONFIG","TOTPR")=$GET(^XTMP(NAMESPC,"CONFIG","TOTPR"))+1
+27 SET ^XTMP(NAMESPC,"CONFIG","IEN")=IEN
+28 IF TOTADR
Begin DoDot:2
+29 SET ^XTMP(NAMESPC,"CONFIG","PERCENT COMPLETE")=+$GET(^XTMP(NAMESPC,"CONFIG","TOTPR"))/TOTADR
+30 SET ^XTMP(NAMESPC,"CONFIG","PERCENT COMPLETE")=+$PIECE((^XTMP(NAMESPC,"CONFIG","PERCENT COMPLETE")*100),".")
End DoDot:2
+31 IF +$GET(^XTMP(NAMESPC,"CONFIG","TOTPR"))#CHKCNT=0
Begin DoDot:2
+32 SET TMSWT=$$STOPIT()
+33 IF TMSWT
Begin DoDot:3
+34 SET ZTSTOP=1
+35 NEW %,%H,%I,X
+36 DO NOW^%DTC
+37 SET ^XTMP(NAMESPC,"CONFIG","ABORT TIME")=%
+38 DO ABORTMSG
End DoDot:3
End DoDot:2
End DoDot:1
+39 ;
+40 IF 'IEN
IF 'TMSWT
Begin DoDot:1
+41 NEW %,%H,%I,X
+42 DO NOW^%DTC
+43 SET ^XTMP(NAMESPC,"CONFIG","COMPLETE")=%
+44 SET ^XTMP(NAMESPC,"CONFIG","PERCENT COMPLETE")=100
+45 DO DONEMSG
End DoDot:1
+46 ;
+47 KILL ^XTMP(NAMESPC,"CONFIG","RUNNING")
+48 QUIT
PROC(IEN,MODE) ; Process the IEN
+1 ; Update "IVM AUTO ADDR JOB" to "POSTMASTER"
+2 NEW DA,DIE,DR,X,NAMESPC
+3 SET DA=IEN
SET DIE="^IVM(301.7,"
SET DR=""
+4 IF $PIECE($GET(^IVM(301.7,IEN,0)),"^",3)="IVM AUTO ADDR JOB"
SET DR=DR_"2////.5"
+5 IF $PIECE($GET(^IVM(301.7,IEN,1)),"^",2)="IVM AUTO ADDR JOB"
Begin DoDot:1
+6 IF DR=""
SET DR="5////.5"
QUIT
+7 SET DR=DR_";5////.5"
End DoDot:1
+8 if DR=""
QUIT
+9 SET NAMESPC=$$NAMESPC
+10 SET ^XTMP(NAMESPC,"DATA",IEN)=""
+11 SET ^XTMP(NAMESPC,"CONFIG","ANOMALY")=$GET(^XTMP(NAMESPC,"CONFIG","ANOMALY"))+1
+12 ;
+13 ; Update only if this is running in live mode
+14 IF MODE
DO ^DIE
+15 ;
+16 SET ^XTMP(NAMESPC,"CONFIG","SUCCESS")=$GET(^XTMP(NAMESPC,"CONFIG","SUCCESS"))+1
+17 QUIT
STOPIT() ; Checks if user requested task to stop
+1 NEW X,STOPIT
+2 SET STOPIT=0
+3 SET X=$$S^%ZTLOAD
+4 ;
IF X
Begin DoDot:1
+5 SET STOPIT=1
+6 IF $GET(ZTSK)
SET ZTSTOP=1
End DoDot:1
+7 QUIT STOPIT
ABORTMSG ; Send the user aborted message:
+1 NEW NAMESPC,NAMESPCN,TMP,XMY,XMDUZ,XMTEXT,XMSUB
+2 SET NAMESPC=$$NAMESPC
+3 SET NAMESPCN=+$PIECE(NAMESPC,"IVM",2)
+4 SET XMY(DUZ)=""
SET XMDUZ="IVM PACKAGE"
SET XMTEXT="TMP("_NAMESPCN_","
+5 SET XMSUB="IVM*2.0*"_NAMESPCN_": ADDRESS CHANGE LOG CLEANUP - PROCESS STOPPED BY USER"
+6 SET TMP(NAMESPCN,1)="CLEANUP PROCESSING"
+7 SET TMP(NAMESPCN,2)="------------------"
+8 SET TMP(NAMESPCN,3)=""
+9 SET TMP(NAMESPCN,4)="The cleanup process was aborted prematurely. Here is the current status:"
+10 SET TMP(NAMESPCN,5)=""
+11 SET TMP(NAMESPCN,6)=" Start Date/Time: "_$$FMTE^XLFDT(+$GET(^XTMP(NAMESPC,"CONFIG","START TIME")),"P")
+12 SET TMP(NAMESPCN,7)=" End Date/Time: "_$$FMTE^XLFDT(+$GET(^XTMP(NAMESPC,"CONFIG","ABORT TIME")),"P")
+13 SET TMP(NAMESPCN,8)=""
+14 SET TMP(NAMESPCN,9)="Current Counts: "
+15 SET TMP(NAMESPCN,10)=" Total Records Processed: "_+$GET(^XTMP(NAMESPC,"CONFIG","TOTPR"))
+16 SET TMP(NAMESPCN,11)=" Total Anomalies Corrected: "_+$GET(^XTMP(NAMESPC,"CONFIG","SUCCESS"))
+17 SET TMP(NAMESPCN,12)=" Percentage Completed: "_+$GET(^XTMP(NAMESPC,"CONFIG","PERCENT COMPLETE"))_"%"
+18 SET TMP(NAMESPCN,13)=""
+19 SET TMP(NAMESPCN,14)=""
+20 DO ^XMD
+21 QUIT
DONEMSG ; Send the user aborted message:
+1 NEW NAMESPC,NAMESPCN,TMP,XMY,XMDUZ,XMTEXT,XMSUB
+2 SET NAMESPC=$$NAMESPC
+3 SET NAMESPCN=+$PIECE(NAMESPC,"IVM",2)
+4 SET XMY(DUZ)=""
SET XMDUZ="IVM PACKAGE"
SET XMTEXT="TMP("_NAMESPCN_","
+5 SET XMSUB="IVM*2.0*"_NAMESPCN_": ADDRESS CHANGE LOG CLEANUP - SUMMARY REPORT"
+6 SET TMP(NAMESPCN,1)="CLEANUP PROCESSING"
+7 SET TMP(NAMESPCN,2)="------------------"
+8 SET TMP(NAMESPCN,3)=""
+9 SET TMP(NAMESPCN,4)="The cleanup has run to completion. Here are the results:"
+10 SET TMP(NAMESPCN,5)=""
+11 SET TMP(NAMESPCN,6)=" Start Date/Time: "_$$FMTE^XLFDT(+$GET(^XTMP(NAMESPC,"CONFIG","START TIME")),"P")
+12 SET TMP(NAMESPCN,7)=" End Date/Time: "_$$FMTE^XLFDT(+$GET(^XTMP(NAMESPC,"CONFIG","COMPLETE")),"P")
+13 SET TMP(NAMESPCN,8)=""
+14 SET TMP(NAMESPCN,9)="Current Counts: "
+15 SET TMP(NAMESPCN,10)=" Total Records Processed: "_+$GET(^XTMP(NAMESPC,"CONFIG","TOTPR"))
+16 SET TMP(NAMESPCN,11)=" Total Anomalies Corrected: "_+$GET(^XTMP(NAMESPC,"CONFIG","SUCCESS"))
+17 SET TMP(NAMESPCN,12)=" Percentage Completed: 100%"
+18 SET TMP(NAMESPCN,13)=""
+19 SET TMP(NAMESPCN,14)=""
+20 DO ^XMD
+21 QUIT