SCCVU1 ;ALB/RMO,TMP - SCHED VISITS CONVERT/ARCHIVE UTILITIES; [ 10/10/95 2:39 PM ]
;;5.3;Scheduling;**211**;Aug 13, 1993
;
CHKDT(SCRESULT,SC,SCCVTYP) ; -- Check date range
; Input -- SC Array:
; SC("STARTDT") Start date
; ("ENDDT") End date
; -- SCCVTYP "CST" for convert function
; "AST" for archive function
; Output -- SCRESULT (#=Error number | 0=No Error)^Message
;
N SCENDT,SCERRMSG,SCERRNB,SCSTDT
;
S SCERRNB=0
;
S SCSTDT=$G(SC("STARTDT"))
S SCENDT=$G(SC("ENDDT"))
;
;Check if start date or end date not defined
I 'SCSTDT,'SCENDT D
. S SCERRNB=4049006.005
. D GETERR^SCCVLOG1(SCERRNB,"","","",1,.SCERRMSG)
;
;Verify date range
I 'SCERRNB S SCERRNB=$$VERDT^SCCVU2(SCSTDT,SCENDT,"",.SCERRMSG)
;
S SCRESULT=SCERRNB
I SCERRNB S SCRESULT=SCRESULT_U_$$BLDSTR(.SCERRMSG)
;
CHKDTQ Q
;
CHKDUP(SCRESULT,SC,SCCVT) ; -- Check duplicate log entries
; Input -- SC Array:
; SC("TYPE") Conversion type
; ("STARTDT") Start date
; ("ENDDT") End date
; ("TEMPLNO") Template number ien
; -- SCCVT "CST" for convert function
; "AST" for archive function
; Output -- SCRESULT (#=Error number | 0=No Error)^Message
;
N SCCVTYP,SCENDT,SCERRMSG,SCERRNB,SCLOG,SCSTDT
;
S SCERRNB=0
;
S SCCVTYP=$G(SC("TYPE"))
S SCSTDT=$G(SC("STARTDT"))
S SCENDT=$G(SC("ENDDT"))
S SCLOG=$G(SC("TEMPLNO"))
;
;Check if type, date range and Template number ien are defined
I 'SCCVTYP!('SCSTDT)!('SCENDT)!('SCLOG) D
. S SCERRNB=4049006.002
. D GETERR^SCCVLOG1(SCERRNB,"","","",1,.SCERRMSG)
;
;Check duplicate log entries
I 'SCERRNB S SCERRNB=$$CHKDUP^SCCVU2(SCCVTYP,SCSTDT,SCENDT,SCLOG,.SCERRMSG)
;
S SCRESULT=SCERRNB
I SCERRNB S SCRESULT=SCRESULT_U_$$BLDSTR(.SCERRMSG)
;
CHKDUPQ Q
;
PROCREQ(SCRESULT,SC) ; -- Process conversion/estimate request
; Input -- SC Array:
; SC("TEMPLNO") Template number ien
; ("REQNUM") Request number ien
; Output -- SCRESULT (#=Error number | 0=No Error)^Message
;
N SCERRMSG,SCERRNB,SCLOG,SCREQ,SCREQACT,SCREQEVT
S SCERRNB=0
;
S SCLOG=$G(SC("TEMPLNO"))
S SCREQ=$G(SC("REQNUM"))
;
;Quit if Template number ien or request ien are not defined
I 'SCLOG!('SCREQ) D
. S SCERRNB=4049006.003
. D GETERR^SCCVLOG1(SCERRNB,"","","",1,.SCERRMSG)
;
S SCRESULT=$S('SCERRNB:0,1:SCERRNB_U_$$BLDSTR(.SCERRMSG))
;
G:SCERRNB PROCREQQ
;
; Set request action
S SCREQACT=$P($G(^SD(404.98,SCLOG,"R",SCREQ,0)),U,2)
S SCREQEVT=$P($G(^SD(404.98,SCLOG,"R",SCREQ,0)),U,3)
;
; Queue conversion request to start or re-start
I "^1^3^"[(U_SCREQACT_U) D
. D QUE^SCCVE(SCLOG,SCREQ)
. IF SCREQEVT D JOURNAL(SCLOG)
;
; Process conversion request to stop
I SCREQACT=2 D STOP^SCCVE(SCLOG,SCREQ)
;
PROCREQQ Q
;
TASKSTA(SCRESULT,SCLOG) ; -- Retrieve task status description
; Input -- SCLOG Template number ien
; Output --
; SCRESULT (0^Task status description^status code or Error #^Message)
;
N SCERRNB,SCTSKD,ZTCPU
;
S SCERRNB=0
S SCTSKD="Unknown"
;
;Quit if Template number ien is not defined
I '$G(SCLOG) D G TASKSTAQ
. S SCERRNB=4049006.004
. D GETERR^SCCVLOG1(SCERRNB,"","","",0,.SCERRMSG)
;
;Get task status description
I 'SCERRNB D
. S ZTSK=$P($G(^SD(404.98,SCLOG,1)),U,3),ZTCPU=$P($G(^(1)),U,4)
. I ZTSK D
. . D STAT^%ZTLOAD
. . S SCTSKD=ZTSK(2)_U_ZTSK(1)
;
S SCRESULT=SCERRNB_U_SCTSKD
;
TASKSTAQ Q
;
BLDSTR(E) ; -- Build error message string
; Input -- E Error message array
; Output -- Error message string for display purposes
N I,Y,STOP
S Y=""
S (I,STOP)=0
F S I=$O(E(I)) Q:'I D Q:STOP
. I ($L(Y)+$L(E(I)))<240 S Y=Y_" "_E(I) Q
. S STOP=1
Q $G(Y)
DTOK(SC) ; -- Verify that date range is OK
N SCERR,SCOK
S SCOK=1
D CHKDT(.SCERR,.SC)
G:$G(SCERR) DTOKQ
S SC("TEMPLNO")=DA,SC("TYPE")=1
D CHKDUP(.SCERR,.SC,"CST")
;
DTOKQ ;
I +$G(SCERR) W !!,*7,$P(SCERR,U,2),!! S SCOK=0
Q SCOK
;
CNVTSCH(SCLOG) ; -- Function determines if any convert was scheduled
; Returns 0 if none scheduled, 1 if any ever scheduled
N SCSCH,Z
S SCSCH=0
S Z=0 F S Z=$O(^SD(404.98,SCLOG,"R",Z)) Q:'Z I $P($G(^(Z,0)),U,3) S SCSCH=1 Q
Q SCSCH
;
JOURNAL(SCLOG) ; -- display journal message and global growth estimates
N DIC,DR,DIQ,DA,SCDATA,SCTOT,FLD
S DIC="404.98",DA=SCLOG,DR="207:211",DIQ="SCDATA",DIQ(0)="E"
D EN^DIQ1
S SCTOT=0
F FLD=207:1:211 S SCTOT=SCTOT+$G(SCDATA(404.98,SCLOG,FLD,"E"))
;
W !
W !,">>> The estimated global growth profile for this template is the following:"
W !
W !,?10,"Global",?25,"Blocks",?40,"[Block Size: ",$$BLKSIZE^SCCVEGU1()," bytes]"
W !,?10,"---------",?25,"-----------"
W !,?10,"^SCE",?25,$J($FN($G(SCDATA(404.98,SCLOG,207,"E")),","),11)
W !,?10,"^AUPNVSIT",?25,$J($FN($G(SCDATA(404.98,SCLOG,208,"E")),","),11)
W !,?10,"^AUPNVPRV",?25,$J($FN($G(SCDATA(404.98,SCLOG,209,"E")),","),11)
W !,?10,"^AUPNVPOV",?25,$J($FN($G(SCDATA(404.98,SCLOG,210,"E")),","),11)
W !,?10,"^AUPNVCPT",?25,$J($FN($G(SCDATA(404.98,SCLOG,211,"E")),","),11)
W !,?10,"---------",?25,"-----------"
W !,?10,"Total",?25,$J($FN(SCTOT,","),11)
;
W !
W !,">>> Please verify that enough global disk space and journal space"
W !," are available for these anticipated increases."
W !
W !,">>> Also, please verify that system backup is not scheduled to"
W !," run within the start and stop times of this conversion job."
W !
D PAUSE^SCCVU
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSCCVU1 5711 printed Dec 13, 2024@02:39:02 Page 2
SCCVU1 ;ALB/RMO,TMP - SCHED VISITS CONVERT/ARCHIVE UTILITIES; [ 10/10/95 2:39 PM ]
+1 ;;5.3;Scheduling;**211**;Aug 13, 1993
+2 ;
CHKDT(SCRESULT,SC,SCCVTYP) ; -- Check date range
+1 ; Input -- SC Array:
+2 ; SC("STARTDT") Start date
+3 ; ("ENDDT") End date
+4 ; -- SCCVTYP "CST" for convert function
+5 ; "AST" for archive function
+6 ; Output -- SCRESULT (#=Error number | 0=No Error)^Message
+7 ;
+8 NEW SCENDT,SCERRMSG,SCERRNB,SCSTDT
+9 ;
+10 SET SCERRNB=0
+11 ;
+12 SET SCSTDT=$GET(SC("STARTDT"))
+13 SET SCENDT=$GET(SC("ENDDT"))
+14 ;
+15 ;Check if start date or end date not defined
+16 IF 'SCSTDT
IF 'SCENDT
Begin DoDot:1
+17 SET SCERRNB=4049006.005
+18 DO GETERR^SCCVLOG1(SCERRNB,"","","",1,.SCERRMSG)
End DoDot:1
+19 ;
+20 ;Verify date range
+21 IF 'SCERRNB
SET SCERRNB=$$VERDT^SCCVU2(SCSTDT,SCENDT,"",.SCERRMSG)
+22 ;
+23 SET SCRESULT=SCERRNB
+24 IF SCERRNB
SET SCRESULT=SCRESULT_U_$$BLDSTR(.SCERRMSG)
+25 ;
CHKDTQ QUIT
+1 ;
CHKDUP(SCRESULT,SC,SCCVT) ; -- Check duplicate log entries
+1 ; Input -- SC Array:
+2 ; SC("TYPE") Conversion type
+3 ; ("STARTDT") Start date
+4 ; ("ENDDT") End date
+5 ; ("TEMPLNO") Template number ien
+6 ; -- SCCVT "CST" for convert function
+7 ; "AST" for archive function
+8 ; Output -- SCRESULT (#=Error number | 0=No Error)^Message
+9 ;
+10 NEW SCCVTYP,SCENDT,SCERRMSG,SCERRNB,SCLOG,SCSTDT
+11 ;
+12 SET SCERRNB=0
+13 ;
+14 SET SCCVTYP=$GET(SC("TYPE"))
+15 SET SCSTDT=$GET(SC("STARTDT"))
+16 SET SCENDT=$GET(SC("ENDDT"))
+17 SET SCLOG=$GET(SC("TEMPLNO"))
+18 ;
+19 ;Check if type, date range and Template number ien are defined
+20 IF 'SCCVTYP!('SCSTDT)!('SCENDT)!('SCLOG)
Begin DoDot:1
+21 SET SCERRNB=4049006.002
+22 DO GETERR^SCCVLOG1(SCERRNB,"","","",1,.SCERRMSG)
End DoDot:1
+23 ;
+24 ;Check duplicate log entries
+25 IF 'SCERRNB
SET SCERRNB=$$CHKDUP^SCCVU2(SCCVTYP,SCSTDT,SCENDT,SCLOG,.SCERRMSG)
+26 ;
+27 SET SCRESULT=SCERRNB
+28 IF SCERRNB
SET SCRESULT=SCRESULT_U_$$BLDSTR(.SCERRMSG)
+29 ;
CHKDUPQ QUIT
+1 ;
PROCREQ(SCRESULT,SC) ; -- Process conversion/estimate request
+1 ; Input -- SC Array:
+2 ; SC("TEMPLNO") Template number ien
+3 ; ("REQNUM") Request number ien
+4 ; Output -- SCRESULT (#=Error number | 0=No Error)^Message
+5 ;
+6 NEW SCERRMSG,SCERRNB,SCLOG,SCREQ,SCREQACT,SCREQEVT
+7 SET SCERRNB=0
+8 ;
+9 SET SCLOG=$GET(SC("TEMPLNO"))
+10 SET SCREQ=$GET(SC("REQNUM"))
+11 ;
+12 ;Quit if Template number ien or request ien are not defined
+13 IF 'SCLOG!('SCREQ)
Begin DoDot:1
+14 SET SCERRNB=4049006.003
+15 DO GETERR^SCCVLOG1(SCERRNB,"","","",1,.SCERRMSG)
End DoDot:1
+16 ;
+17 SET SCRESULT=$SELECT('SCERRNB:0,1:SCERRNB_U_$$BLDSTR(.SCERRMSG))
+18 ;
+19 if SCERRNB
GOTO PROCREQQ
+20 ;
+21 ; Set request action
+22 SET SCREQACT=$PIECE($GET(^SD(404.98,SCLOG,"R",SCREQ,0)),U,2)
+23 SET SCREQEVT=$PIECE($GET(^SD(404.98,SCLOG,"R",SCREQ,0)),U,3)
+24 ;
+25 ; Queue conversion request to start or re-start
+26 IF "^1^3^"[(U_SCREQACT_U)
Begin DoDot:1
+27 DO QUE^SCCVE(SCLOG,SCREQ)
+28 IF SCREQEVT
DO JOURNAL(SCLOG)
End DoDot:1
+29 ;
+30 ; Process conversion request to stop
+31 IF SCREQACT=2
DO STOP^SCCVE(SCLOG,SCREQ)
+32 ;
PROCREQQ QUIT
+1 ;
TASKSTA(SCRESULT,SCLOG) ; -- Retrieve task status description
+1 ; Input -- SCLOG Template number ien
+2 ; Output --
+3 ; SCRESULT (0^Task status description^status code or Error #^Message)
+4 ;
+5 NEW SCERRNB,SCTSKD,ZTCPU
+6 ;
+7 SET SCERRNB=0
+8 SET SCTSKD="Unknown"
+9 ;
+10 ;Quit if Template number ien is not defined
+11 IF '$GET(SCLOG)
Begin DoDot:1
+12 SET SCERRNB=4049006.004
+13 DO GETERR^SCCVLOG1(SCERRNB,"","","",0,.SCERRMSG)
End DoDot:1
GOTO TASKSTAQ
+14 ;
+15 ;Get task status description
+16 IF 'SCERRNB
Begin DoDot:1
+17 SET ZTSK=$PIECE($GET(^SD(404.98,SCLOG,1)),U,3)
SET ZTCPU=$PIECE($GET(^(1)),U,4)
+18 IF ZTSK
Begin DoDot:2
+19 DO STAT^%ZTLOAD
+20 SET SCTSKD=ZTSK(2)_U_ZTSK(1)
End DoDot:2
End DoDot:1
+21 ;
+22 SET SCRESULT=SCERRNB_U_SCTSKD
+23 ;
TASKSTAQ QUIT
+1 ;
BLDSTR(E) ; -- Build error message string
+1 ; Input -- E Error message array
+2 ; Output -- Error message string for display purposes
+3 NEW I,Y,STOP
+4 SET Y=""
+5 SET (I,STOP)=0
+6 FOR
SET I=$ORDER(E(I))
if 'I
QUIT
Begin DoDot:1
+7 IF ($LENGTH(Y)+$LENGTH(E(I)))<240
SET Y=Y_" "_E(I)
QUIT
+8 SET STOP=1
End DoDot:1
if STOP
QUIT
+9 QUIT $GET(Y)
DTOK(SC) ; -- Verify that date range is OK
+1 NEW SCERR,SCOK
+2 SET SCOK=1
+3 DO CHKDT(.SCERR,.SC)
+4 if $GET(SCERR)
GOTO DTOKQ
+5 SET SC("TEMPLNO")=DA
SET SC("TYPE")=1
+6 DO CHKDUP(.SCERR,.SC,"CST")
+7 ;
DTOKQ ;
+1 IF +$GET(SCERR)
WRITE !!,*7,$PIECE(SCERR,U,2),!!
SET SCOK=0
+2 QUIT SCOK
+3 ;
CNVTSCH(SCLOG) ; -- Function determines if any convert was scheduled
+1 ; Returns 0 if none scheduled, 1 if any ever scheduled
+2 NEW SCSCH,Z
+3 SET SCSCH=0
+4 SET Z=0
FOR
SET Z=$ORDER(^SD(404.98,SCLOG,"R",Z))
if 'Z
QUIT
IF $PIECE($GET(^(Z,0)),U,3)
SET SCSCH=1
QUIT
+5 QUIT SCSCH
+6 ;
JOURNAL(SCLOG) ; -- display journal message and global growth estimates
+1 NEW DIC,DR,DIQ,DA,SCDATA,SCTOT,FLD
+2 SET DIC="404.98"
SET DA=SCLOG
SET DR="207:211"
SET DIQ="SCDATA"
SET DIQ(0)="E"
+3 DO EN^DIQ1
+4 SET SCTOT=0
+5 FOR FLD=207:1:211
SET SCTOT=SCTOT+$GET(SCDATA(404.98,SCLOG,FLD,"E"))
+6 ;
+7 WRITE !
+8 WRITE !,">>> The estimated global growth profile for this template is the following:"
+9 WRITE !
+10 WRITE !,?10,"Global",?25,"Blocks",?40,"[Block Size: ",$$BLKSIZE^SCCVEGU1()," bytes]"
+11 WRITE !,?10,"---------",?25,"-----------"
+12 WRITE !,?10,"^SCE",?25,$JUSTIFY($FNUMBER($GET(SCDATA(404.98,SCLOG,207,"E")),","),11)
+13 WRITE !,?10,"^AUPNVSIT",?25,$JUSTIFY($FNUMBER($GET(SCDATA(404.98,SCLOG,208,"E")),","),11)
+14 WRITE !,?10,"^AUPNVPRV",?25,$JUSTIFY($FNUMBER($GET(SCDATA(404.98,SCLOG,209,"E")),","),11)
+15 WRITE !,?10,"^AUPNVPOV",?25,$JUSTIFY($FNUMBER($GET(SCDATA(404.98,SCLOG,210,"E")),","),11)
+16 WRITE !,?10,"^AUPNVCPT",?25,$JUSTIFY($FNUMBER($GET(SCDATA(404.98,SCLOG,211,"E")),","),11)
+17 WRITE !,?10,"---------",?25,"-----------"
+18 WRITE !,?10,"Total",?25,$JUSTIFY($FNUMBER(SCTOT,","),11)
+19 ;
+20 WRITE !
+21 WRITE !,">>> Please verify that enough global disk space and journal space"
+22 WRITE !," are available for these anticipated increases."
+23 WRITE !
+24 WRITE !,">>> Also, please verify that system backup is not scheduled to"
+25 WRITE !," run within the start and stop times of this conversion job."
+26 WRITE !
+27 DO PAUSE^SCCVU
+28 QUIT
+29 ;