HMPMONJ ;ASMR/BL, monitor job listing ;Sep 13, 2016 20:03:08
;;2.0;ENTERPRISE HEALTH MANAGEMENT PLATFORM;**2,3**;April 14,2016;Build 15
;Per VA Directive 6402, this routine should not be modified.
;
Q ; no entry from top
;DE6526 - routine refactored, 25 August 2016
;
;
J ; polling job display
;in symbol table:
; HMPMNTR("server") = # of server record in file HMP Subscription (800000)
; HMPROMPT = current monitor prompt group
;
D FORMFEED^HMPMONL ; clear screen before report
N STREAM ; freshness stream subscript in ^XTMP
W !,$$HDR^HMPMONL("eHMP Jobs"),! ; header line
S STREAM=$$LASTREAM^HMPMONL ; get last freshness stream
;
D POLLJOBS(STREAM) ; show stream's polling jobs
D EXTRBTCH(STREAM) ; show extract batches
W !! D RTRN2CON^HMPMONL
Q
;
;
POLLJOBS(STREAM) ; show stream's polling jobs
;
Q:$G(STREAM)=""
W !!,"Polling job#:"
;
N JOBID,LINE,X,Y
S JOBID=""
F S JOBID=$O(^XTMP(STREAM,"job",JOBID)) Q:'JOBID D
. S LINE=" "_JOBID
. ; check if job is still active
. S X=JOBID X ^%ZOSF("JOBPARAM") S:Y="" LINE=LINE_" (inactive)"
. W !,LINE
;
Q
;
EXTRBTCH(STREAM) ; show extract batches
; STREAM - freshness stream
; called by:
; J
; ; symbol table:
; HMPMNTR("server") = # of server record in file HMP Subscription (800000)
; HMPROMPT = current dashboard prompt, ^ = exit now
; loop through extracts for this server
;
N BATCH,BTCHCNT,C,EXIT,EXTRACTS,FRESHPRE,PIECE,SLOTS,TASK,TSKLST
; BTCHCNT - batch counter
S SLOTS="Slots Open: "_$$SLOTS^HMPMONL ; # free slots, ^DD(3.54,1,0)="AVAILABLE SLOTS"
S EXTRACTS="Extract Batches:",$E(EXTRACTS,80-$L(SLOTS),79)=SLOTS ; extracts summary
W !!,EXTRACTS
;
S (BTCHCNT,EXIT)=0,FRESHPRE=$$FRESHPRE^HMPMONL,BATCH=FRESHPRE
F D Q:EXIT ; traverse batches
. S BATCH=$O(^XTMP(BATCH)) ; get next batch
. S:$E(BATCH,1,$L(FRESHPRE))'=FRESHPRE EXIT=1 Q ; done if it's a different freshness stream
. S BTCHCNT=BTCHCNT+1 W !,$J($P(BATCH,"~",3),12)_" Tasks"
. S TASK=0,TSKLST="",C=0 ; C is the count
. F S TASK=$O(^XTMP(BATCH,0,"task",TASK)) Q:'TASK S C=C+1,$P(TSKLST,",",C)=TASK ; comma-delimited string of tasks
. W !," "_C_" Task"_$E(C'=1,"s")_" found: "_TSKLST
. I '$D(^XTMP(BATCH,0,"wait")) W !,"Waiting: "_$$WAIT(BATCH)_" seconds" Q
. ;
. I '$L(TSKLST) W !,"No tasks found for "_BATCH_" batch." Q
. ;
. ; each comma $piece of the list is a task #
. F PIECE=1:1:$L(TSKLST,",") D
.. S TASK=$P(TSKLST,",",PIECE) W !,"Task "_TASK_" extracting: "_$$LASTITEM(BATCH,TASK),! ; last item in batch
;
I 'BTCHCNT W !," * No batches found. *",!
Q
;
WAIT(BATCH) ; function # seconds BATCH has waited
;
N START S START=$G(^XTMP(BATCH,0,"time"))
Q:'START 0 ; default to zero
Q $$HDIFF^XLFDT($H,START,2) ; return wait time in seconds
;
LASTITEM(BATCH,TASK) ; function, last domain retrieved for this BATCH and TASK
Q:'$L($G(BATCH)) "*no batch*" ; batch required
Q:'$G(TASK) "*no task*" ; task required
N DOMAIN,LSTITM,NUM S LSTITM="",DOMAIN=""
F D Q:DOMAIN=""!$L(LSTITM)
. S DOMAIN=$O(^XTMP(BATCH,0,"status",DOMAIN)) Q:'$L(DOMAIN)
. Q:$G(^XTMP(BATCH,0,"status",DOMAIN)) ; domain complete
. S NUM=$O(^XTMP(BATCH,TASK,DOMAIN,""),-1) ; go to last entry
. S LSTITM=DOMAIN_$S(NUM:" #"_NUM,1:"")
;
S:LSTITM="" LSTITM="<finished>"
Q LSTITM ; return last item
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HHMPMONJ 3387 printed Nov 22, 2024@17:04:27 Page 2
HMPMONJ ;ASMR/BL, monitor job listing ;Sep 13, 2016 20:03:08
+1 ;;2.0;ENTERPRISE HEALTH MANAGEMENT PLATFORM;**2,3**;April 14,2016;Build 15
+2 ;Per VA Directive 6402, this routine should not be modified.
+3 ;
+4 ; no entry from top
QUIT
+5 ;DE6526 - routine refactored, 25 August 2016
+6 ;
+7 ;
J ; polling job display
+1 ;in symbol table:
+2 ; HMPMNTR("server") = # of server record in file HMP Subscription (800000)
+3 ; HMPROMPT = current monitor prompt group
+4 ;
+5 ; clear screen before report
DO FORMFEED^HMPMONL
+6 ; freshness stream subscript in ^XTMP
NEW STREAM
+7 ; header line
WRITE !,$$HDR^HMPMONL("eHMP Jobs"),!
+8 ; get last freshness stream
SET STREAM=$$LASTREAM^HMPMONL
+9 ;
+10 ; show stream's polling jobs
DO POLLJOBS(STREAM)
+11 ; show extract batches
DO EXTRBTCH(STREAM)
+12 WRITE !!
DO RTRN2CON^HMPMONL
+13 QUIT
+14 ;
+15 ;
POLLJOBS(STREAM) ; show stream's polling jobs
+1 ;
+2 if $GET(STREAM)=""
QUIT
+3 WRITE !!,"Polling job#:"
+4 ;
+5 NEW JOBID,LINE,X,Y
+6 SET JOBID=""
+7 FOR
SET JOBID=$ORDER(^XTMP(STREAM,"job",JOBID))
if 'JOBID
QUIT
Begin DoDot:1
+8 SET LINE=" "_JOBID
+9 ; check if job is still active
+10 SET X=JOBID
XECUTE ^%ZOSF("JOBPARAM")
if Y=""
SET LINE=LINE_" (inactive)"
+11 WRITE !,LINE
End DoDot:1
+12 ;
+13 QUIT
+14 ;
EXTRBTCH(STREAM) ; show extract batches
+1 ; STREAM - freshness stream
+2 ; called by:
+3 ; J
+4 ; ; symbol table:
+5 ; HMPMNTR("server") = # of server record in file HMP Subscription (800000)
+6 ; HMPROMPT = current dashboard prompt, ^ = exit now
+7 ; loop through extracts for this server
+8 ;
+9 NEW BATCH,BTCHCNT,C,EXIT,EXTRACTS,FRESHPRE,PIECE,SLOTS,TASK,TSKLST
+10 ; BTCHCNT - batch counter
+11 ; # free slots, ^DD(3.54,1,0)="AVAILABLE SLOTS"
SET SLOTS="Slots Open: "_$$SLOTS^HMPMONL
+12 ; extracts summary
SET EXTRACTS="Extract Batches:"
SET $EXTRACT(EXTRACTS,80-$LENGTH(SLOTS),79)=SLOTS
+13 WRITE !!,EXTRACTS
+14 ;
+15 SET (BTCHCNT,EXIT)=0
SET FRESHPRE=$$FRESHPRE^HMPMONL
SET BATCH=FRESHPRE
+16 ; traverse batches
FOR
Begin DoDot:1
+17 ; get next batch
SET BATCH=$ORDER(^XTMP(BATCH))
+18 ; done if it's a different freshness stream
if $EXTRACT(BATCH,1,$LENGTH(FRESHPRE))'=FRESHPRE
SET EXIT=1
QUIT
+19 SET BTCHCNT=BTCHCNT+1
WRITE !,$JUSTIFY($PIECE(BATCH,"~",3),12)_" Tasks"
+20 ; C is the count
SET TASK=0
SET TSKLST=""
SET C=0
+21 ; comma-delimited string of tasks
FOR
SET TASK=$ORDER(^XTMP(BATCH,0,"task",TASK))
if 'TASK
QUIT
SET C=C+1
SET $PIECE(TSKLST,",",C)=TASK
+22 WRITE !," "_C_" Task"_$EXTRACT(C'=1,"s")_" found: "_TSKLST
+23 IF '$DATA(^XTMP(BATCH,0,"wait"))
WRITE !,"Waiting: "_$$WAIT(BATCH)_" seconds"
QUIT
+24 ;
+25 IF '$LENGTH(TSKLST)
WRITE !,"No tasks found for "_BATCH_" batch."
QUIT
+26 ;
+27 ; each comma $piece of the list is a task #
+28 FOR PIECE=1:1:$LENGTH(TSKLST,",")
Begin DoDot:2
+29 ; last item in batch
SET TASK=$PIECE(TSKLST,",",PIECE)
WRITE !,"Task "_TASK_" extracting: "_$$LASTITEM(BATCH,TASK),!
End DoDot:2
End DoDot:1
if EXIT
QUIT
+30 ;
+31 IF 'BTCHCNT
WRITE !," * No batches found. *",!
+32 QUIT
+33 ;
WAIT(BATCH) ; function # seconds BATCH has waited
+1 ;
+2 NEW START
SET START=$GET(^XTMP(BATCH,0,"time"))
+3 ; default to zero
if 'START
QUIT 0
+4 ; return wait time in seconds
QUIT $$HDIFF^XLFDT($HOROLOG,START,2)
+5 ;
LASTITEM(BATCH,TASK) ; function, last domain retrieved for this BATCH and TASK
+1 ; batch required
if '$LENGTH($GET(BATCH))
QUIT "*no batch*"
+2 ; task required
if '$GET(TASK)
QUIT "*no task*"
+3 NEW DOMAIN,LSTITM,NUM
SET LSTITM=""
SET DOMAIN=""
+4 FOR
Begin DoDot:1
+5 SET DOMAIN=$ORDER(^XTMP(BATCH,0,"status",DOMAIN))
if '$LENGTH(DOMAIN)
QUIT
+6 ; domain complete
if $GET(^XTMP(BATCH,0,"status",DOMAIN))
QUIT
+7 ; go to last entry
SET NUM=$ORDER(^XTMP(BATCH,TASK,DOMAIN,""),-1)
+8 SET LSTITM=DOMAIN_$SELECT(NUM:" #"_NUM,1:"")
End DoDot:1
if DOMAIN=""!$LENGTH(LSTITM)
QUIT
+9 ;
+10 if LSTITM=""
SET LSTITM="<finished>"
+11 ; return last item
QUIT LSTITM
+12 ;