SDRPA02 ;bp-oifo/swo pait utils ; 9/10/04 9:33am
;;5.3;Scheduling;**349,376**;AUG 13, 1993
Q ;no entry from top
DUP(RUNIEN,BATCHIDO) ;check for duplicate ACK response
;RUNIEN : the ien in file 409.6 of the run
;BATCHIDO : batchid pulled from the ACK message
;V3 : returns 0 if dup ACK or error and 1 new ACK
N V1,V2,V3,VNODE
S V3=0
I $G(RUNIEN)="" Q V3
I $G(BATCHIDO)="" Q V3
I $G(^SDWL(409.6,RUNIEN,2,0))="" Q V3
S V1=$O(^SDWL(409.6,RUNIEN,2,"B",BATCHIDO,"")) I V1="" Q V3
S VNODE=$G(^SDWL(409.6,RUNIEN,2,V1,0))
I $P(VNODE,"^")'=BATCHIDO Q V3
I $P(VNODE,"^",4)="" S V3=1
Q V3
RSTAT ;check the status of the last run
;V1 : last run ien
;VNODE : zero node of the run
;ZTSK : the task number
N V1,V2,V3,VNODE,ZTSK
S V1=$O(^SDWL(409.6,999999999),-1) Q:'V1
S VNODE=$G(^SDWL(409.6,V1,0)) Q:VNODE=""
I $P(VNODE,"^",7) Q ;the run has finished
S ZTSK=$P(VNODE,"^",2) Q:'ZTSK
D STAT^%ZTLOAD
I ZTSK(1)=1!(ZTSK(1)=2) Q ;still running
;S V2=$$RPAIT^SDRPA03(V1) ADD MESSAGE TO HELP DESK THAT TASK ERRORED
Q
RUNCK() ;date check for run start
;V1 : ien file 19.2
;V2 : returns 0=do not run, 1=okay to run
;V3 : 1st day of scheduling pattern
;V4 : 2nd day of scheduling pattern
;VNODE : zero node of 19.2
;VDAY : current day plussed
;run may be started on the 1st or 15th with a 3 day grace window
;if no entry in 19.2 allow to run anytime
;if scheduling pattern is not 1M(1,15) allow to run anytime
N V1,V2,V3,V4,VNODE,VDAY
S V2=0
S V1=$O(^DIC(19,"B","SD-PAIT TASKED TRANSMISSION","")) ;is the option scheduled?
S V1=$O(^DIC(19.2,"B",V1,""))
I V1="" S V2=1 D NSMSG Q V2 ;not scheduled, allow to run anytime
S VNODE=$G(^DIC(19.2,V1,0))
I VNODE="" S V2=1 Q V2 ;b xref, but no entry, allow to run anytime
I $P(VNODE,"^",6)'?1"1M("1.2N1","1.2N1")" S V2=1 D NSMSG Q V2 ;not our scheduling pattern, allow to run anytime
S V3=+$P($P($P(VNODE,"^",6),"(",2),",") ;1st date in month to run
S V4=+$P($P($P(VNODE,"^",6),",",2),")") ;2nd date in month to run
S VDAY=+$E($$DT^XLFDT(),6,7)
I VDAY'=V3,VDAY'=(V3+1),VDAY'=(V3+2),VDAY'=(V3+3),VDAY'=V4,VDAY'=(V4+1),VDAY'=(V4+2),VDAY'=(V4+3) D NRMSG Q V2
S V2=1
Q V2
NRMSG ;no run message
N XMSUB,XMY,XMTEXT,XMDUZ,SDAMX,SDNOW,SDNAM
S XMSUB="PAIT Transmission"
S XMY("G.SD-PAIT")=""
S XMTEXT="SDAMX("
S XMDUZ="POSTMASTER"
S SDNOW=$$HTE^XLFDT($H,)
S SDNAM=$$GET1^DIQ(200,+$G(DUZ)_",",.01,"I")
S SDAMX(1)=SDNAM_" (DUZ="_DUZ_") attempted to start the PAIT transmission"
S SDAMX(2)="on "_SDNOW_", outside the authorized transmission dates."
S SDAMX(3)="The job has been cancelled"
D ^XMD
Q
NSMSG ;non scheduled start-up
N XMSUB,XMY,XMTEXT,XMDUZ,SDAMX,SDNOW,SDNAM
S XMSUB="PAIT Transmission"
S XMY("G.SD-PAIT")=""
;S XMY("VHACIONHD@DOMAIN.EXT")
S XMTEXT="SDAMX("
S XMDUZ="POSTMASTER"
S SDNOW=$$HTE^XLFDT($H,)
S SDNAM=$$GET1^DIQ(200,+$G(DUZ)_",",.01,"I")
S SDAMX(1)=SDNAM_" (DUZ="_DUZ_") started the PAIT transmission "
S SDAMX(2)="on "_SDNOW_". Option SD-PAIT TASKED TRANSMISSION has no "
S SDAMX(3)="entry or an incorrect entry for scheduling frequency. The correct frequency "
S SDAMX(4)="is 1M(1,15). The National Help Desk has been notified to initiate a NOIS"
D ^XMD
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDRPA02 3308 printed Dec 13, 2024@03:00:13 Page 2
SDRPA02 ;bp-oifo/swo pait utils ; 9/10/04 9:33am
+1 ;;5.3;Scheduling;**349,376**;AUG 13, 1993
+2 ;no entry from top
QUIT
DUP(RUNIEN,BATCHIDO) ;check for duplicate ACK response
+1 ;RUNIEN : the ien in file 409.6 of the run
+2 ;BATCHIDO : batchid pulled from the ACK message
+3 ;V3 : returns 0 if dup ACK or error and 1 new ACK
+4 NEW V1,V2,V3,VNODE
+5 SET V3=0
+6 IF $GET(RUNIEN)=""
QUIT V3
+7 IF $GET(BATCHIDO)=""
QUIT V3
+8 IF $GET(^SDWL(409.6,RUNIEN,2,0))=""
QUIT V3
+9 SET V1=$ORDER(^SDWL(409.6,RUNIEN,2,"B",BATCHIDO,""))
IF V1=""
QUIT V3
+10 SET VNODE=$GET(^SDWL(409.6,RUNIEN,2,V1,0))
+11 IF $PIECE(VNODE,"^")'=BATCHIDO
QUIT V3
+12 IF $PIECE(VNODE,"^",4)=""
SET V3=1
+13 QUIT V3
RSTAT ;check the status of the last run
+1 ;V1 : last run ien
+2 ;VNODE : zero node of the run
+3 ;ZTSK : the task number
+4 NEW V1,V2,V3,VNODE,ZTSK
+5 SET V1=$ORDER(^SDWL(409.6,999999999),-1)
if 'V1
QUIT
+6 SET VNODE=$GET(^SDWL(409.6,V1,0))
if VNODE=""
QUIT
+7 ;the run has finished
IF $PIECE(VNODE,"^",7)
QUIT
+8 SET ZTSK=$PIECE(VNODE,"^",2)
if 'ZTSK
QUIT
+9 DO STAT^%ZTLOAD
+10 ;still running
IF ZTSK(1)=1!(ZTSK(1)=2)
QUIT
+11 ;S V2=$$RPAIT^SDRPA03(V1) ADD MESSAGE TO HELP DESK THAT TASK ERRORED
+12 QUIT
RUNCK() ;date check for run start
+1 ;V1 : ien file 19.2
+2 ;V2 : returns 0=do not run, 1=okay to run
+3 ;V3 : 1st day of scheduling pattern
+4 ;V4 : 2nd day of scheduling pattern
+5 ;VNODE : zero node of 19.2
+6 ;VDAY : current day plussed
+7 ;run may be started on the 1st or 15th with a 3 day grace window
+8 ;if no entry in 19.2 allow to run anytime
+9 ;if scheduling pattern is not 1M(1,15) allow to run anytime
+10 NEW V1,V2,V3,V4,VNODE,VDAY
+11 SET V2=0
+12 ;is the option scheduled?
SET V1=$ORDER(^DIC(19,"B","SD-PAIT TASKED TRANSMISSION",""))
+13 SET V1=$ORDER(^DIC(19.2,"B",V1,""))
+14 ;not scheduled, allow to run anytime
IF V1=""
SET V2=1
DO NSMSG
QUIT V2
+15 SET VNODE=$GET(^DIC(19.2,V1,0))
+16 ;b xref, but no entry, allow to run anytime
IF VNODE=""
SET V2=1
QUIT V2
+17 ;not our scheduling pattern, allow to run anytime
IF $PIECE(VNODE,"^",6)'?1"1M("1.2N1","1.2N1")"
SET V2=1
DO NSMSG
QUIT V2
+18 ;1st date in month to run
SET V3=+$PIECE($PIECE($PIECE(VNODE,"^",6),"(",2),",")
+19 ;2nd date in month to run
SET V4=+$PIECE($PIECE($PIECE(VNODE,"^",6),",",2),")")
+20 SET VDAY=+$EXTRACT($$DT^XLFDT(),6,7)
+21 IF VDAY'=V3
IF VDAY'=(V3+1)
IF VDAY'=(V3+2)
IF VDAY'=(V3+3)
IF VDAY'=V4
IF VDAY'=(V4+1)
IF VDAY'=(V4+2)
IF VDAY'=(V4+3)
DO NRMSG
QUIT V2
+22 SET V2=1
+23 QUIT V2
NRMSG ;no run message
+1 NEW XMSUB,XMY,XMTEXT,XMDUZ,SDAMX,SDNOW,SDNAM
+2 SET XMSUB="PAIT Transmission"
+3 SET XMY("G.SD-PAIT")=""
+4 SET XMTEXT="SDAMX("
+5 SET XMDUZ="POSTMASTER"
+6 SET SDNOW=$$HTE^XLFDT($HOROLOG,)
+7 SET SDNAM=$$GET1^DIQ(200,+$GET(DUZ)_",",.01,"I")
+8 SET SDAMX(1)=SDNAM_" (DUZ="_DUZ_") attempted to start the PAIT transmission"
+9 SET SDAMX(2)="on "_SDNOW_", outside the authorized transmission dates."
+10 SET SDAMX(3)="The job has been cancelled"
+11 DO ^XMD
+12 QUIT
NSMSG ;non scheduled start-up
+1 NEW XMSUB,XMY,XMTEXT,XMDUZ,SDAMX,SDNOW,SDNAM
+2 SET XMSUB="PAIT Transmission"
+3 SET XMY("G.SD-PAIT")=""
+4 ;S XMY("VHACIONHD@DOMAIN.EXT")
+5 SET XMTEXT="SDAMX("
+6 SET XMDUZ="POSTMASTER"
+7 SET SDNOW=$$HTE^XLFDT($HOROLOG,)
+8 SET SDNAM=$$GET1^DIQ(200,+$GET(DUZ)_",",.01,"I")
+9 SET SDAMX(1)=SDNAM_" (DUZ="_DUZ_") started the PAIT transmission "
+10 SET SDAMX(2)="on "_SDNOW_". Option SD-PAIT TASKED TRANSMISSION has no "
+11 SET SDAMX(3)="entry or an incorrect entry for scheduling frequency. The correct frequency "
+12 SET SDAMX(4)="is 1M(1,15). The National Help Desk has been notified to initiate a NOIS"
+13 DO ^XMD
+14 QUIT