HMPMOND ;ASMR/BL, monitor display ;Sep 24, 2016 03:07:36
;;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, DE6644 - routine refactored, 7 September 2016
;
U ; monitor screen update - default activity in monitor
; called by:
; OPTION^HMPMON
; passed in symbol table:
; HMPMNTR("exit") - monitor exit flag
; HMPMNTR("server") = # of server record in file HMP Subscription (800000)
; HMPMNTR("zero node") = HMP SUBSCRIPTION entry's zero node
; HMPROMPT = current prompt; ^ to exit option, else leave alone
;DSPLN - lines to display, first character in subscript is display order
; this array is created for enhancements such as a remote procedure
N DSPLN,HMPRSLT,JBID,STREAM,X,Y
S DSPLN("1hdr")=$$HDR^HMPMONL($P(HMPMNTR("zero node"),U)) ; server name in header
W !,DSPLN("1hdr"),! ; line 1: screen header
; freshness stream subscript from ^XTMP
S STREAM=$$LASTREAM^HMPMONL ; get last freshness stream
I STREAM="" W !!," * No eHMP Extract Stream Found *" Q ; nothing else to show
;create line 2
D CHKXTMP^HMPMONX(.HMPRSLT)
S Y=" "_$P(HMPRSLT(1),U,3)_": "_$P(HMPRSLT(2),U,3) ; total patients in queue
; if there are patients show number staging & complete
I $P(HMPRSLT(2),U,3) F X=4,5 S Y=Y_" - "_$P(HMPRSLT(1),U,X)_": "_$P(HMPRSLT(2),U,X)
S DSPLN("2Patients")=Y W !,DSPLN("2Patients"),! ; line 2: patients in queue
; create line 3
S JBID=0
F S JBID=$O(^XTMP(STREAM,"job",JBID)) Q:'JBID D
. S JBID("count")=$G(JBID("count"))+1 ; count of job numbers found
. S X=JBID X ^%ZOSF("JOBPARAM") ; set JOB into X to check if job active
. S:Y="" JBID("inactv")=$G(JBID("inactv"))+1 ; Y returned by ^%ZOSF("JOBPARAM")
. S $P(JBID("list"),",",JBID("count"))=JBID
S Y=" Polling job#"
S:$G(JBID("list")) Y=Y_" "_JBID("list") S:$G(JBID("inactv")) Y=Y_" ("_JBID("inactv")_" inactive)"
S DSPLN("3PollJobs")=Y W !,DSPLN("3PollJobs") ; line 3: jobs polling in this stream
;create line 4
S Y=$P(HMPMNTR("zero node"),U,2) ; ^DD(800000,.02,0)="LASTUPDATE"
S Y=" Last Update: "_Y
S:$P(HMPMNTR("zero node"),U,4) Y=Y_" x"_$P(HMPMNTR("zero node"),U,4) ; ^DD(800000,.04,0)="REPEAT POLLS"
S DSPLN("4LastUpdt")=Y ; lastupdate
S Y="eHMP Errors: "_$FN($$ETOTL^HMPMONE,",") ; # ehmp errors in all logs
S $E(DSPLN("4LastUpdt"),80-$L(Y),79)=Y
W !,DSPLN("4LastUpdt") ; line 4: last update & errors
; create line 5
S Y="eHMP's ^XTMP size: "_$J($P(HMPRSLT(2),U,6)/1024,6,2)_" KB" ; size of eHMP in ^XTMP
S DSPLN("5XEoQXtmp")=$J("",79-$L(Y))_Y ; right-justify line
S Y="" ; used for end of queue on next line
S:$D(^XTMP(STREAM)) Y=" End of Queue: "_$P(STREAM,"~",3)_"-"_$G(^XTMP(STREAM,"last"))
S:$L(Y) $E(DSPLN("5XEoQXtmp"),1,$L(Y))=Y ; if end of queue found insert at beginning
W !,DSPLN("5XEoQXtmp") ; line 5: end of queue, xtmp size
;
D QUEUE(STREAM,10) ; show last 10 items in queue
Q
;
QUEUE(STREAM,MAX) ; show last max items in freshness queue
; called by:
; U
; calls:
; QLIST: get size and last max items
; QHEAD: show freshness-queue header
; $$QROW = each row of the report
; input:
; STREAM = last freshness stream
; MAX = maximum # items to show
; input from the database
; output:
; HMPEXIT = whether to exit option report to current device
;
N ITEM,LIST,X,Y ; size of queue
; LIST - array of last max items
D QLIST(.LIST,STREAM,MAX) ; get items to display, LIST is total, returns MAX items
;set total into X to adjust length into Y, LIST varies
S Y="Freshness Queue (last "_MAX_" items):",X="Total items in queue: "_LIST,$E(Y,80-$L(X),79)=X
W !!,Y,!
W !,"item patient transaction type waiting"
W !,"-------- ----------- ------------ --------------------------------- -------"
; create report lines in Y
S ITEM="" F S ITEM=$O(LIST(ITEM),-1) Q:'ITEM D ; display ITEM array
. S X=" "_$$QWAIT(LIST(ITEM)),Y="" ; space in front of wait time in X
. S $E(Y,1,9)=$E(ITEM,1,9) ; item #
. S $E(Y,11,23)=$E($P(LIST(ITEM),U),1,13) ; patient
. S $E(Y,24,37)=$E($P(LIST(ITEM),U,2),1,14) ; transaction
. S $E(Y,38,74)=$E($P($P(LIST(ITEM),U,3),"#"),1,37) ; type
. S $E(Y,80-$L(X),79)=X ; waiting time
. W !,Y ; display row of report
;
Q
;
QLIST(ITMLST,STREAM,MAX) ; items from freshness queue, return last MAX items
; ITMLST passed by reference, returns:
; ITMLST = total # items in freshness queue
; ITMLST(item #) = record for each of the last max items
;
K ITMLST S ITMLST=0 ; clear any residue
N ITM S ITM=$C(1) ; reverse iteration from first subscript after numerics
F S ITM=$O(^XTMP(STREAM,ITM),-1) Q:'ITM D:ITMLST<MAX S ITMLST=ITMLST+1
. S ITMLST(ITM)=$G(^XTMP(STREAM,ITM)) ; save item, use $GET because queue is dynamic
;
Q
;
QWAIT(RECORD) ; function, return waiting value for RECORD
; RECORD = record of item in the queue
; examples:
; $$QWAIT("3^visit^H4721^^52660^54378") = "done"
; if $H = "64272,54378" then:
; $$QWAIT("3^visit^H4721^^52660^") = "1,718 s"
; $$QWAIT("3^visit^H4721^^") = ""
; $$QWAIT("") = ""
;
Q:$G(RECORD)="" "" ; return null if no RECORD
Q:$P(RECORD,U,6) "done" ; item complete, return literal
N START,WTING
S START=$P(RECORD,U,5) Q:'START "" ; no start time, return null
S WTING=$P($H,",",2)-START S:WTING<0 WTING=86400-WTING ; handle midnight
Q $FN(WTING,",")_" s" ; make pretty
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HHMPMOND 5578 printed Nov 22, 2024@17:04:22 Page 2
HMPMOND ;ASMR/BL, monitor display ;Sep 24, 2016 03:07:36
+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, DE6644 - routine refactored, 7 September 2016
+6 ;
U ; monitor screen update - default activity in monitor
+1 ; called by:
+2 ; OPTION^HMPMON
+3 ; passed in symbol table:
+4 ; HMPMNTR("exit") - monitor exit flag
+5 ; HMPMNTR("server") = # of server record in file HMP Subscription (800000)
+6 ; HMPMNTR("zero node") = HMP SUBSCRIPTION entry's zero node
+7 ; HMPROMPT = current prompt; ^ to exit option, else leave alone
+8 ;DSPLN - lines to display, first character in subscript is display order
+9 ; this array is created for enhancements such as a remote procedure
+10 NEW DSPLN,HMPRSLT,JBID,STREAM,X,Y
+11 ; server name in header
SET DSPLN("1hdr")=$$HDR^HMPMONL($PIECE(HMPMNTR("zero node"),U))
+12 ; line 1: screen header
WRITE !,DSPLN("1hdr"),!
+13 ; freshness stream subscript from ^XTMP
+14 ; get last freshness stream
SET STREAM=$$LASTREAM^HMPMONL
+15 ; nothing else to show
IF STREAM=""
WRITE !!," * No eHMP Extract Stream Found *"
QUIT
+16 ;create line 2
+17 DO CHKXTMP^HMPMONX(.HMPRSLT)
+18 ; total patients in queue
SET Y=" "_$PIECE(HMPRSLT(1),U,3)_": "_$PIECE(HMPRSLT(2),U,3)
+19 ; if there are patients show number staging & complete
+20 IF $PIECE(HMPRSLT(2),U,3)
FOR X=4,5
SET Y=Y_" - "_$PIECE(HMPRSLT(1),U,X)_": "_$PIECE(HMPRSLT(2),U,X)
+21 ; line 2: patients in queue
SET DSPLN("2Patients")=Y
WRITE !,DSPLN("2Patients"),!
+22 ; create line 3
+23 SET JBID=0
+24 FOR
SET JBID=$ORDER(^XTMP(STREAM,"job",JBID))
if 'JBID
QUIT
Begin DoDot:1
+25 ; count of job numbers found
SET JBID("count")=$GET(JBID("count"))+1
+26 ; set JOB into X to check if job active
SET X=JBID
XECUTE ^%ZOSF("JOBPARAM")
+27 ; Y returned by ^%ZOSF("JOBPARAM")
if Y=""
SET JBID("inactv")=$GET(JBID("inactv"))+1
+28 SET $PIECE(JBID("list"),",",JBID("count"))=JBID
End DoDot:1
+29 SET Y=" Polling job#"
+30 if $GET(JBID("list"))
SET Y=Y_" "_JBID("list")
if $GET(JBID("inactv"))
SET Y=Y_" ("_JBID("inactv")_" inactive)"
+31 ; line 3: jobs polling in this stream
SET DSPLN("3PollJobs")=Y
WRITE !,DSPLN("3PollJobs")
+32 ;create line 4
+33 ; ^DD(800000,.02,0)="LASTUPDATE"
SET Y=$PIECE(HMPMNTR("zero node"),U,2)
+34 SET Y=" Last Update: "_Y
+35 ; ^DD(800000,.04,0)="REPEAT POLLS"
if $PIECE(HMPMNTR("zero node"),U,4)
SET Y=Y_" x"_$PIECE(HMPMNTR("zero node"),U,4)
+36 ; lastupdate
SET DSPLN("4LastUpdt")=Y
+37 ; # ehmp errors in all logs
SET Y="eHMP Errors: "_$FNUMBER($$ETOTL^HMPMONE,",")
+38 SET $EXTRACT(DSPLN("4LastUpdt"),80-$LENGTH(Y),79)=Y
+39 ; line 4: last update & errors
WRITE !,DSPLN("4LastUpdt")
+40 ; create line 5
+41 ; size of eHMP in ^XTMP
SET Y="eHMP's ^XTMP size: "_$JUSTIFY($PIECE(HMPRSLT(2),U,6)/1024,6,2)_" KB"
+42 ; right-justify line
SET DSPLN("5XEoQXtmp")=$JUSTIFY("",79-$LENGTH(Y))_Y
+43 ; used for end of queue on next line
SET Y=""
+44 if $DATA(^XTMP(STREAM))
SET Y=" End of Queue: "_$PIECE(STREAM,"~",3)_"-"_$GET(^XTMP(STREAM,"last"))
+45 ; if end of queue found insert at beginning
if $LENGTH(Y)
SET $EXTRACT(DSPLN("5XEoQXtmp"),1,$LENGTH(Y))=Y
+46 ; line 5: end of queue, xtmp size
WRITE !,DSPLN("5XEoQXtmp")
+47 ;
+48 ; show last 10 items in queue
DO QUEUE(STREAM,10)
+49 QUIT
+50 ;
QUEUE(STREAM,MAX) ; show last max items in freshness queue
+1 ; called by:
+2 ; U
+3 ; calls:
+4 ; QLIST: get size and last max items
+5 ; QHEAD: show freshness-queue header
+6 ; $$QROW = each row of the report
+7 ; input:
+8 ; STREAM = last freshness stream
+9 ; MAX = maximum # items to show
+10 ; input from the database
+11 ; output:
+12 ; HMPEXIT = whether to exit option report to current device
+13 ;
+14 ; size of queue
NEW ITEM,LIST,X,Y
+15 ; LIST - array of last max items
+16 ; get items to display, LIST is total, returns MAX items
DO QLIST(.LIST,STREAM,MAX)
+17 ;set total into X to adjust length into Y, LIST varies
+18 SET Y="Freshness Queue (last "_MAX_" items):"
SET X="Total items in queue: "_LIST
SET $EXTRACT(Y,80-$LENGTH(X),79)=X
+19 WRITE !!,Y,!
+20 WRITE !,"item patient transaction type waiting"
+21 WRITE !,"-------- ----------- ------------ --------------------------------- -------"
+22 ; create report lines in Y
+23 ; display ITEM array
SET ITEM=""
FOR
SET ITEM=$ORDER(LIST(ITEM),-1)
if 'ITEM
QUIT
Begin DoDot:1
+24 ; space in front of wait time in X
SET X=" "_$$QWAIT(LIST(ITEM))
SET Y=""
+25 ; item #
SET $EXTRACT(Y,1,9)=$EXTRACT(ITEM,1,9)
+26 ; patient
SET $EXTRACT(Y,11,23)=$EXTRACT($PIECE(LIST(ITEM),U),1,13)
+27 ; transaction
SET $EXTRACT(Y,24,37)=$EXTRACT($PIECE(LIST(ITEM),U,2),1,14)
+28 ; type
SET $EXTRACT(Y,38,74)=$EXTRACT($PIECE($PIECE(LIST(ITEM),U,3),"#"),1,37)
+29 ; waiting time
SET $EXTRACT(Y,80-$LENGTH(X),79)=X
+30 ; display row of report
WRITE !,Y
End DoDot:1
+31 ;
+32 QUIT
+33 ;
QLIST(ITMLST,STREAM,MAX) ; items from freshness queue, return last MAX items
+1 ; ITMLST passed by reference, returns:
+2 ; ITMLST = total # items in freshness queue
+3 ; ITMLST(item #) = record for each of the last max items
+4 ;
+5 ; clear any residue
KILL ITMLST
SET ITMLST=0
+6 ; reverse iteration from first subscript after numerics
NEW ITM
SET ITM=$CHAR(1)
+7 FOR
SET ITM=$ORDER(^XTMP(STREAM,ITM),-1)
if 'ITM
QUIT
if ITMLST<MAX
Begin DoDot:1
+8 ; save item, use $GET because queue is dynamic
SET ITMLST(ITM)=$GET(^XTMP(STREAM,ITM))
End DoDot:1
SET ITMLST=ITMLST+1
+9 ;
+10 QUIT
+11 ;
QWAIT(RECORD) ; function, return waiting value for RECORD
+1 ; RECORD = record of item in the queue
+2 ; examples:
+3 ; $$QWAIT("3^visit^H4721^^52660^54378") = "done"
+4 ; if $H = "64272,54378" then:
+5 ; $$QWAIT("3^visit^H4721^^52660^") = "1,718 s"
+6 ; $$QWAIT("3^visit^H4721^^") = ""
+7 ; $$QWAIT("") = ""
+8 ;
+9 ; return null if no RECORD
if $GET(RECORD)=""
QUIT ""
+10 ; item complete, return literal
if $PIECE(RECORD,U,6)
QUIT "done"
+11 NEW START,WTING
+12 ; no start time, return null
SET START=$PIECE(RECORD,U,5)
if 'START
QUIT ""
+13 ; handle midnight
SET WTING=$PIECE($HOROLOG,",",2)-START
if WTING<0
SET WTING=86400-WTING
+14 ; make pretty
QUIT $FNUMBER(WTING,",")_" s"
+15 ;