SCCVLOG ;ALB/RMO,TMP - CST/AST Log Utilities - Log Event; [ 04/05/95 8:39 AM ]
;;5.3;Scheduling;**211**;Aug 13, 1993
;
UPDREC(SCLOG,SCIEN,SCCVT) ;Update CST/AST last entry and number of records
; Input -- SCLOG CST/AST log IEN
; SCIEN Last entry IEN
; SCCVT 'AST' or 'CST' for type of template
; Output -- None
N SCDATA,SCCVFL
S SCCVFL=$S(SCCVT="CST":"404.98",1:"404.99")
S SCDATA(1.01)=SCIEN ;last entry converted
S SCDATA(1.02)=$G(SCTOT(1.02)) ;number of records converted
S SCDATA(2.06)=$G(SCTOT(2.06)) ;number of records not converted
I $D(^SD(SCCVFL,+SCLOG,0)) D UPD^SCCVDBU(SCCVFL,SCLOG,.SCDATA)
Q
;
UPD(SCCVT,SCLOG,SCSTDT,SCENDT,SCOMBUL,SCTSK,SCVOL,SCACT) ;Update CST or AST log entry
; Input -- SCCVT 'AST' or 'CST' for type of template
; SCLOG CST or AST log IEN
; SCSTDT Start date [optional]
; SCENDT End date [optional]
; SCOMBUL Bulletin upon completion [optional]
; SCTSK Task # [optional]
; SCVOL Volume set [optional]
; SCACT Action [optional]
; Output -- None
N SCDATA,SCCVFL
S SCCVFL=$S(SCCVT="CST":"404.98",1:"404.99")
I $G(SCACT) D HIS($$NOW^XLFDT,SCLOG,SCACT,"",SCCVFL,$G(SCTSK))
S:$G(SCSTDT) SCDATA(.03)=SCSTDT ;start date
S:$G(SCENDT) SCDATA(.04)=SCENDT ;end date
S:$G(SCOMBUL)'="" SCDATA(.06)=SCOMBUL ;bulletin upon completion
I $G(SCACT)=2,$P($G(^SD(SCCVFL,SCLOG,0)),U,8)'=3 D ;initialize fields when starting, but not on a restart
. S SCDATA(1.01)="@" ;last entry
. S SCDATA(1.02)=0 ;number of records
. S SCDATA(2.06)=0 ;number of records
S:$G(SCTSK)'="" SCDATA(1.03)=SCTSK ;task #
S:$G(SCVOL)'="" SCDATA(1.04)=SCVOL ;volume set
I $D(SCDATA) D UPD^SCCVDBU(SCCVFL,SCLOG,.SCDATA)
Q
;
HIS(SCEVDTM,SCLOG,SCACT,SCCVEVT,SCCVFL,SCTSK) ; CST/AST Log history
; Input -- SCEVDTM Event date/time
; SCLOG CST/AST log IEN
; SCACT Action
; SCCVEVT Last log status
; SCCVFL 'AST' or 'CST' file # (404.98 or 404.99)
; SCTSK task # [optional]
; Output -- None
N C,SCACTD,SCCVEVTD,SCDATA,SCHIS,SCIENS,SCLOG0,Y
S SCHIS=+$O(^SD(SCCVFL,SCLOG,"E","AEV",SCEVDTM,SCACT,0))
G HISQ:SCHIS
S SCIENS="+1,"_SCLOG
S SCDATA(.01)=SCEVDTM ;event date/time
S SCDATA(.02)=$S(SCCVEVT'=3:SCACT,1:7) ;action
S SCLOG0=$G(^SD(SCCVFL,SCLOG,0))
S:$G(SCCVEVT)="" SCCVEVT=$S('$P(SCLOG0,U,9):$P(SCLOG0,U,5),1:3)
S:$G(SCCVEVT)'="" SCDATA(.03)=SCCVEVT ;event
IF '$G(SCTSK) N SCTSK S SCTSK=$P($G(^SD(SCCVFL,SCLOG,1)),U,3) ;task number
I SCTSK D ;task comment
. S SCACTD=$$LOW^XLFSTR($$EXPAND^SCCVDSP2(SCCVFL_"75",.02,SCACT))
. I $G(SCCVEVT)'="",SCCVEVT<3 D
. . S Y=$$EXPAND^SCCVDSP2(SCCVFL_"75",.03,SCCVEVT)
. . S SCCVEVTD=$E(Y,1)_$$LOW^XLFSTR($E(Y,2,$L(Y)))
. S:$G(SCCVEVT)<3 SCDATA(50,"WP",1)=SCCVEVTD_" "_SCACTD_" as task #"_SCTSK
. S:$G(SCCVEVT)=3 SCDATA(50,"WP",1)="Template canceled by user #: "_$G(DUZ)
. S SCDATA(50)=$NA(SCDATA(50,"WP"))
D ADD^SCCVDBU(SCCVFL_"75",SCIENS,.SCDATA)
I SCCVFL=404.98,"^3^5^"[(U_SCACT_U) D
. ;Update file with estimate totals
. I 'SCCVEVT,SCACT=5,$O(SCTOT(0)) D UPDTOTL^SCCVEGU1(SCLOG,.SCTOT)
. ;
. I $P($G(^SD(404.98,SCLOG,0)),U,6) D ;send bulletin
. . I SCCVEVT D ;convert if complete or stopped
. . . D SEND^SCCVLOG2(SCLOG,SCACT)
. . ELSE I SCACT=5 D ;estimate only when complete
. . . D MAILSUM^SCCVEGD0(SCLOG)
HISQ Q
;
CHKACT(SCLOG,SCCVEVT,SCACT,SCCVT) ;Check log entry action for a specific log event
; Input -- SCLOG CST/AST log IEN
; SCCVEVT CST/AST event
; SCACT Action
; SCCVT 'AST' or 'CST' for type of template
; Output -- 1=Found and 0=Not Found
N A,D,E,Y,SCCVFL
S (D,Y)=0
S SCCVFL=$S(SCCVT="CST":"404.98",1:"404.99")
F S D=$O(^SD(SCCVFL,SCLOG,"E","AEV",D)) Q:'D!(Y) D
. S E=""
. F E=$O(^SD(SCCVFL,SCLOG,"E","AEV",D,E)) Q:E=""!(Y) I E=SCCVEVT D
. . S A=0
. . F S A=$O(^SD(SCCVFL,SCLOG,"E","AEV",D,E,A)) Q:'A!(Y) I A=SCACT S Y=1
Q +$G(Y)
;
STOP(SCLOG,SCREQ,SCSTOPF) ;Stop conversion/estimate
; Input -- SCLOG CST log IEN
; SCREQ CST request IEN
; SCSTOPF Force exit [optional]
; Output -- SCSTOPF 1=Stopped and 0=Not stopped
N SCREQ0,SCLOG1,SCFORCEX
;
; -- force exit if calling routine says to
S SCFORCEX=+$G(SCSTOPF)
;
; -- force exit if too many errors have occurred
IF 'SCFORCEX,$G(SCCVMAXE),$G(SCCVERRH)>SCCVMAXE S SCFORCEX=1
;
S SCSTOPF=0
;
I +$$LSTACT(SCLOG)=5 G STOPQ ;already completed
S SCREQ0=$G(^SD(404.98,SCLOG,"R",SCREQ,0))
S SCLOG1=$G(^SD(404.98,SCLOG,1))
I $S(SCFORCEX:1,$$S^%ZTLOAD:1,$P(SCREQ0,U,2)=2:1,$P(SCREQ0,U,5):$P(SCREQ0,U,5)<$$NOW^XLFDT,1:0) D
. D UPD("CST",SCLOG,"","","","@","@",3)
. ;
I +$$LSTACT(SCLOG)=3 D
. S SCSTOPF=1
. ;
. ; stopping a running task
. I $D(ZTQUEUED) S ZTSTOP=1 Q
. ;
. ; -- kill/stop a pending task
. N ZTSK
. S ZTSK=$P(SCLOG1,U,3)
. ; -- get status
. IF ZTSK]"" D ISQED^%ZTLOAD
. ; -- kill task if task is pending
. IF $G(ZTSK(0)) D KILL^%ZTLOAD
. ;
STOPQ Q
;
LSTACT(SCLOG) ;Last action taken on CST log entry
; Input -- SCLOG CST log IEN
; Output -- Action^Description
N SCACT,Y
S SCACT=$P($G(^SD(404.98,SCLOG,0)),U,7)
I $G(SCACT) S Y=SCACT_U_$$EXPAND^SCCVDSP2(404.9875,.02,SCACT)
Q $G(Y)
;
LSTEVT(SCLOG) ;Last event performed on CST log entry
; Input -- SCLOG CST log IEN
; Output -- event
N SCEVT
S SCEVT=$P($G(^SD(404.98,SCLOG,0)),U,5)
Q SCEVT
;
LSTREQ(SCLOG) ;Returns the # of the last request for a CST
; Input -- SCLOG CST log IEN
; Output -- Last request ien
;
Q +$O(^SD(404.98,SCLOG,"R","A"),-1)
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSCCVLOG 5838 printed Dec 13, 2024@02:38:56 Page 2
SCCVLOG ;ALB/RMO,TMP - CST/AST Log Utilities - Log Event; [ 04/05/95 8:39 AM ]
+1 ;;5.3;Scheduling;**211**;Aug 13, 1993
+2 ;
UPDREC(SCLOG,SCIEN,SCCVT) ;Update CST/AST last entry and number of records
+1 ; Input -- SCLOG CST/AST log IEN
+2 ; SCIEN Last entry IEN
+3 ; SCCVT 'AST' or 'CST' for type of template
+4 ; Output -- None
+5 NEW SCDATA,SCCVFL
+6 SET SCCVFL=$SELECT(SCCVT="CST":"404.98",1:"404.99")
+7 ;last entry converted
SET SCDATA(1.01)=SCIEN
+8 ;number of records converted
SET SCDATA(1.02)=$GET(SCTOT(1.02))
+9 ;number of records not converted
SET SCDATA(2.06)=$GET(SCTOT(2.06))
+10 IF $DATA(^SD(SCCVFL,+SCLOG,0))
DO UPD^SCCVDBU(SCCVFL,SCLOG,.SCDATA)
+11 QUIT
+12 ;
UPD(SCCVT,SCLOG,SCSTDT,SCENDT,SCOMBUL,SCTSK,SCVOL,SCACT) ;Update CST or AST log entry
+1 ; Input -- SCCVT 'AST' or 'CST' for type of template
+2 ; SCLOG CST or AST log IEN
+3 ; SCSTDT Start date [optional]
+4 ; SCENDT End date [optional]
+5 ; SCOMBUL Bulletin upon completion [optional]
+6 ; SCTSK Task # [optional]
+7 ; SCVOL Volume set [optional]
+8 ; SCACT Action [optional]
+9 ; Output -- None
+10 NEW SCDATA,SCCVFL
+11 SET SCCVFL=$SELECT(SCCVT="CST":"404.98",1:"404.99")
+12 IF $GET(SCACT)
DO HIS($$NOW^XLFDT,SCLOG,SCACT,"",SCCVFL,$GET(SCTSK))
+13 ;start date
if $GET(SCSTDT)
SET SCDATA(.03)=SCSTDT
+14 ;end date
if $GET(SCENDT)
SET SCDATA(.04)=SCENDT
+15 ;bulletin upon completion
if $GET(SCOMBUL)'=""
SET SCDATA(.06)=SCOMBUL
+16 ;initialize fields when starting, but not on a restart
IF $GET(SCACT)=2
IF $PIECE($GET(^SD(SCCVFL,SCLOG,0)),U,8)'=3
Begin DoDot:1
+17 ;last entry
SET SCDATA(1.01)="@"
+18 ;number of records
SET SCDATA(1.02)=0
+19 ;number of records
SET SCDATA(2.06)=0
End DoDot:1
+20 ;task #
if $GET(SCTSK)'=""
SET SCDATA(1.03)=SCTSK
+21 ;volume set
if $GET(SCVOL)'=""
SET SCDATA(1.04)=SCVOL
+22 IF $DATA(SCDATA)
DO UPD^SCCVDBU(SCCVFL,SCLOG,.SCDATA)
+23 QUIT
+24 ;
HIS(SCEVDTM,SCLOG,SCACT,SCCVEVT,SCCVFL,SCTSK) ; CST/AST Log history
+1 ; Input -- SCEVDTM Event date/time
+2 ; SCLOG CST/AST log IEN
+3 ; SCACT Action
+4 ; SCCVEVT Last log status
+5 ; SCCVFL 'AST' or 'CST' file # (404.98 or 404.99)
+6 ; SCTSK task # [optional]
+7 ; Output -- None
+8 NEW C,SCACTD,SCCVEVTD,SCDATA,SCHIS,SCIENS,SCLOG0,Y
+9 SET SCHIS=+$ORDER(^SD(SCCVFL,SCLOG,"E","AEV",SCEVDTM,SCACT,0))
+10 if SCHIS
GOTO HISQ
+11 SET SCIENS="+1,"_SCLOG
+12 ;event date/time
SET SCDATA(.01)=SCEVDTM
+13 ;action
SET SCDATA(.02)=$SELECT(SCCVEVT'=3:SCACT,1:7)
+14 SET SCLOG0=$GET(^SD(SCCVFL,SCLOG,0))
+15 if $GET(SCCVEVT)=""
SET SCCVEVT=$SELECT('$PIECE(SCLOG0,U,9):$PIECE(SCLOG0,U,5),1:3)
+16 ;event
if $GET(SCCVEVT)'=""
SET SCDATA(.03)=SCCVEVT
+17 ;task number
IF '$GET(SCTSK)
NEW SCTSK
SET SCTSK=$PIECE($GET(^SD(SCCVFL,SCLOG,1)),U,3)
+18 ;task comment
IF SCTSK
Begin DoDot:1
+19 SET SCACTD=$$LOW^XLFSTR($$EXPAND^SCCVDSP2(SCCVFL_"75",.02,SCACT))
+20 IF $GET(SCCVEVT)'=""
IF SCCVEVT<3
Begin DoDot:2
+21 SET Y=$$EXPAND^SCCVDSP2(SCCVFL_"75",.03,SCCVEVT)
+22 SET SCCVEVTD=$EXTRACT(Y,1)_$$LOW^XLFSTR($EXTRACT(Y,2,$LENGTH(Y)))
End DoDot:2
+23 if $GET(SCCVEVT)<3
SET SCDATA(50,"WP",1)=SCCVEVTD_" "_SCACTD_" as task #"_SCTSK
+24 if $GET(SCCVEVT)=3
SET SCDATA(50,"WP",1)="Template canceled by user #: "_$GET(DUZ)
+25 SET SCDATA(50)=$NAME(SCDATA(50,"WP"))
End DoDot:1
+26 DO ADD^SCCVDBU(SCCVFL_"75",SCIENS,.SCDATA)
+27 IF SCCVFL=404.98
IF "^3^5^"[(U_SCACT_U)
Begin DoDot:1
+28 ;Update file with estimate totals
+29 IF 'SCCVEVT
IF SCACT=5
IF $ORDER(SCTOT(0))
DO UPDTOTL^SCCVEGU1(SCLOG,.SCTOT)
+30 ;
+31 ;send bulletin
IF $PIECE($GET(^SD(404.98,SCLOG,0)),U,6)
Begin DoDot:2
+32 ;convert if complete or stopped
IF SCCVEVT
Begin DoDot:3
+33 DO SEND^SCCVLOG2(SCLOG,SCACT)
End DoDot:3
+34 ;estimate only when complete
IF '$TEST
IF SCACT=5
Begin DoDot:3
+35 DO MAILSUM^SCCVEGD0(SCLOG)
End DoDot:3
End DoDot:2
End DoDot:1
HISQ QUIT
+1 ;
CHKACT(SCLOG,SCCVEVT,SCACT,SCCVT) ;Check log entry action for a specific log event
+1 ; Input -- SCLOG CST/AST log IEN
+2 ; SCCVEVT CST/AST event
+3 ; SCACT Action
+4 ; SCCVT 'AST' or 'CST' for type of template
+5 ; Output -- 1=Found and 0=Not Found
+6 NEW A,D,E,Y,SCCVFL
+7 SET (D,Y)=0
+8 SET SCCVFL=$SELECT(SCCVT="CST":"404.98",1:"404.99")
+9 FOR
SET D=$ORDER(^SD(SCCVFL,SCLOG,"E","AEV",D))
if 'D!(Y)
QUIT
Begin DoDot:1
+10 SET E=""
+11 FOR E=$ORDER(^SD(SCCVFL,SCLOG,"E","AEV",D,E))
if E=""!(Y)
QUIT
IF E=SCCVEVT
Begin DoDot:2
+12 SET A=0
+13 FOR
SET A=$ORDER(^SD(SCCVFL,SCLOG,"E","AEV",D,E,A))
if 'A!(Y)
QUIT
IF A=SCACT
SET Y=1
End DoDot:2
End DoDot:1
+14 QUIT +$GET(Y)
+15 ;
STOP(SCLOG,SCREQ,SCSTOPF) ;Stop conversion/estimate
+1 ; Input -- SCLOG CST log IEN
+2 ; SCREQ CST request IEN
+3 ; SCSTOPF Force exit [optional]
+4 ; Output -- SCSTOPF 1=Stopped and 0=Not stopped
+5 NEW SCREQ0,SCLOG1,SCFORCEX
+6 ;
+7 ; -- force exit if calling routine says to
+8 SET SCFORCEX=+$GET(SCSTOPF)
+9 ;
+10 ; -- force exit if too many errors have occurred
+11 IF 'SCFORCEX
IF $GET(SCCVMAXE)
IF $GET(SCCVERRH)>SCCVMAXE
SET SCFORCEX=1
+12 ;
+13 SET SCSTOPF=0
+14 ;
+15 ;already completed
IF +$$LSTACT(SCLOG)=5
GOTO STOPQ
+16 SET SCREQ0=$GET(^SD(404.98,SCLOG,"R",SCREQ,0))
+17 SET SCLOG1=$GET(^SD(404.98,SCLOG,1))
+18 IF $SELECT(SCFORCEX:1,$$S^%ZTLOAD:1,$PIECE(SCREQ0,U,2)=2:1,$PIECE(SCREQ0,U,5):$PIECE(SCREQ0,U,5)<$$NOW^XLFDT,1:0)
Begin DoDot:1
+19 DO UPD("CST",SCLOG,"","","","@","@",3)
+20 ;
End DoDot:1
+21 IF +$$LSTACT(SCLOG)=3
Begin DoDot:1
+22 SET SCSTOPF=1
+23 ;
+24 ; stopping a running task
+25 IF $DATA(ZTQUEUED)
SET ZTSTOP=1
QUIT
+26 ;
+27 ; -- kill/stop a pending task
+28 NEW ZTSK
+29 SET ZTSK=$PIECE(SCLOG1,U,3)
+30 ; -- get status
+31 IF ZTSK]""
DO ISQED^%ZTLOAD
+32 ; -- kill task if task is pending
+33 IF $GET(ZTSK(0))
DO KILL^%ZTLOAD
+34 ;
End DoDot:1
STOPQ QUIT
+1 ;
LSTACT(SCLOG) ;Last action taken on CST log entry
+1 ; Input -- SCLOG CST log IEN
+2 ; Output -- Action^Description
+3 NEW SCACT,Y
+4 SET SCACT=$PIECE($GET(^SD(404.98,SCLOG,0)),U,7)
+5 IF $GET(SCACT)
SET Y=SCACT_U_$$EXPAND^SCCVDSP2(404.9875,.02,SCACT)
+6 QUIT $GET(Y)
+7 ;
LSTEVT(SCLOG) ;Last event performed on CST log entry
+1 ; Input -- SCLOG CST log IEN
+2 ; Output -- event
+3 NEW SCEVT
+4 SET SCEVT=$PIECE($GET(^SD(404.98,SCLOG,0)),U,5)
+5 QUIT SCEVT
+6 ;
LSTREQ(SCLOG) ;Returns the # of the last request for a CST
+1 ; Input -- SCLOG CST log IEN
+2 ; Output -- Last request ien
+3 ;
+4 QUIT +$ORDER(^SD(404.98,SCLOG,"R","A"),-1)
+5 ;