Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: HMPMOND

HMPMOND.m

Go to the documentation of this file.
  1. 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
  1. ;Per VA Directive 6402, this routine should not be modified.
  1. ;
  1. Q ; no entry from top
  1. ;DE6526, DE6644 - routine refactored, 7 September 2016
  1. ;
  1. U ; monitor screen update - default activity in monitor
  1. ; called by:
  1. ; OPTION^HMPMON
  1. ; passed in symbol table:
  1. ; HMPMNTR("exit") - monitor exit flag
  1. ; HMPMNTR("server") = # of server record in file HMP Subscription (800000)
  1. ; HMPMNTR("zero node") = HMP SUBSCRIPTION entry's zero node
  1. ; HMPROMPT = current prompt; ^ to exit option, else leave alone
  1. ;DSPLN - lines to display, first character in subscript is display order
  1. ; this array is created for enhancements such as a remote procedure
  1. N DSPLN,HMPRSLT,JBID,STREAM,X,Y
  1. S DSPLN("1hdr")=$$HDR^HMPMONL($P(HMPMNTR("zero node"),U)) ; server name in header
  1. W !,DSPLN("1hdr"),! ; line 1: screen header
  1. ; freshness stream subscript from ^XTMP
  1. S STREAM=$$LASTREAM^HMPMONL ; get last freshness stream
  1. I STREAM="" W !!," * No eHMP Extract Stream Found *" Q ; nothing else to show
  1. ;create line 2
  1. D CHKXTMP^HMPMONX(.HMPRSLT)
  1. S Y=" "_$P(HMPRSLT(1),U,3)_": "_$P(HMPRSLT(2),U,3) ; total patients in queue
  1. ; if there are patients show number staging & complete
  1. I $P(HMPRSLT(2),U,3) F X=4,5 S Y=Y_" - "_$P(HMPRSLT(1),U,X)_": "_$P(HMPRSLT(2),U,X)
  1. S DSPLN("2Patients")=Y W !,DSPLN("2Patients"),! ; line 2: patients in queue
  1. ; create line 3
  1. S JBID=0
  1. F S JBID=$O(^XTMP(STREAM,"job",JBID)) Q:'JBID D
  1. . S JBID("count")=$G(JBID("count"))+1 ; count of job numbers found
  1. . S X=JBID X ^%ZOSF("JOBPARAM") ; set JOB into X to check if job active
  1. . S:Y="" JBID("inactv")=$G(JBID("inactv"))+1 ; Y returned by ^%ZOSF("JOBPARAM")
  1. . S $P(JBID("list"),",",JBID("count"))=JBID
  1. S Y=" Polling job#"
  1. S:$G(JBID("list")) Y=Y_" "_JBID("list") S:$G(JBID("inactv")) Y=Y_" ("_JBID("inactv")_" inactive)"
  1. S DSPLN("3PollJobs")=Y W !,DSPLN("3PollJobs") ; line 3: jobs polling in this stream
  1. ;create line 4
  1. S Y=$P(HMPMNTR("zero node"),U,2) ; ^DD(800000,.02,0)="LASTUPDATE"
  1. S Y=" Last Update: "_Y
  1. S:$P(HMPMNTR("zero node"),U,4) Y=Y_" x"_$P(HMPMNTR("zero node"),U,4) ; ^DD(800000,.04,0)="REPEAT POLLS"
  1. S DSPLN("4LastUpdt")=Y ; lastupdate
  1. S Y="eHMP Errors: "_$FN($$ETOTL^HMPMONE,",") ; # ehmp errors in all logs
  1. S $E(DSPLN("4LastUpdt"),80-$L(Y),79)=Y
  1. W !,DSPLN("4LastUpdt") ; line 4: last update & errors
  1. ; create line 5
  1. S Y="eHMP's ^XTMP size: "_$J($P(HMPRSLT(2),U,6)/1024,6,2)_" KB" ; size of eHMP in ^XTMP
  1. S DSPLN("5XEoQXtmp")=$J("",79-$L(Y))_Y ; right-justify line
  1. S Y="" ; used for end of queue on next line
  1. S:$D(^XTMP(STREAM)) Y=" End of Queue: "_$P(STREAM,"~",3)_"-"_$G(^XTMP(STREAM,"last"))
  1. S:$L(Y) $E(DSPLN("5XEoQXtmp"),1,$L(Y))=Y ; if end of queue found insert at beginning
  1. W !,DSPLN("5XEoQXtmp") ; line 5: end of queue, xtmp size
  1. ;
  1. D QUEUE(STREAM,10) ; show last 10 items in queue
  1. Q
  1. ;
  1. QUEUE(STREAM,MAX) ; show last max items in freshness queue
  1. ; called by:
  1. ; U
  1. ; calls:
  1. ; QLIST: get size and last max items
  1. ; QHEAD: show freshness-queue header
  1. ; $$QROW = each row of the report
  1. ; input:
  1. ; STREAM = last freshness stream
  1. ; MAX = maximum # items to show
  1. ; input from the database
  1. ; output:
  1. ; HMPEXIT = whether to exit option report to current device
  1. ;
  1. N ITEM,LIST,X,Y ; size of queue
  1. ; LIST - array of last max items
  1. D QLIST(.LIST,STREAM,MAX) ; get items to display, LIST is total, returns MAX items
  1. ;set total into X to adjust length into Y, LIST varies
  1. S Y="Freshness Queue (last "_MAX_" items):",X="Total items in queue: "_LIST,$E(Y,80-$L(X),79)=X
  1. W !!,Y,!
  1. W !,"item patient transaction type waiting"
  1. W !,"-------- ----------- ------------ --------------------------------- -------"
  1. ; create report lines in Y
  1. S ITEM="" F S ITEM=$O(LIST(ITEM),-1) Q:'ITEM D ; display ITEM array
  1. . S X=" "_$$QWAIT(LIST(ITEM)),Y="" ; space in front of wait time in X
  1. . S $E(Y,1,9)=$E(ITEM,1,9) ; item #
  1. . S $E(Y,11,23)=$E($P(LIST(ITEM),U),1,13) ; patient
  1. . S $E(Y,24,37)=$E($P(LIST(ITEM),U,2),1,14) ; transaction
  1. . S $E(Y,38,74)=$E($P($P(LIST(ITEM),U,3),"#"),1,37) ; type
  1. . S $E(Y,80-$L(X),79)=X ; waiting time
  1. . W !,Y ; display row of report
  1. ;
  1. Q
  1. ;
  1. QLIST(ITMLST,STREAM,MAX) ; items from freshness queue, return last MAX items
  1. ; ITMLST passed by reference, returns:
  1. ; ITMLST = total # items in freshness queue
  1. ; ITMLST(item #) = record for each of the last max items
  1. ;
  1. K ITMLST S ITMLST=0 ; clear any residue
  1. N ITM S ITM=$C(1) ; reverse iteration from first subscript after numerics
  1. F S ITM=$O(^XTMP(STREAM,ITM),-1) Q:'ITM D:ITMLST<MAX S ITMLST=ITMLST+1
  1. . S ITMLST(ITM)=$G(^XTMP(STREAM,ITM)) ; save item, use $GET because queue is dynamic
  1. ;
  1. Q
  1. ;
  1. QWAIT(RECORD) ; function, return waiting value for RECORD
  1. ; RECORD = record of item in the queue
  1. ; examples:
  1. ; $$QWAIT("3^visit^H4721^^52660^54378") = "done"
  1. ; if $H = "64272,54378" then:
  1. ; $$QWAIT("3^visit^H4721^^52660^") = "1,718 s"
  1. ; $$QWAIT("3^visit^H4721^^") = ""
  1. ; $$QWAIT("") = ""
  1. ;
  1. Q:$G(RECORD)="" "" ; return null if no RECORD
  1. Q:$P(RECORD,U,6) "done" ; item complete, return literal
  1. N START,WTING
  1. S START=$P(RECORD,U,5) Q:'START "" ; no start time, return null
  1. S WTING=$P($H,",",2)-START S:WTING<0 WTING=86400-WTING ; handle midnight
  1. Q $FN(WTING,",")_" s" ; make pretty
  1. ;