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

HLDIEDB1.m

Go to the documentation of this file.
  1. HLDIEDB1 ;CIOFO-O/LJA - DEBUG Menu ;1/8/04 @ 01:28
  1. ;;1.6;HEALTH LEVEL SEVEN;**109**;Oct 13,1995
  1. ;
  1. INIT ;
  1. N A7UMENU,A7UOK,A7UOPT,NOMENU,I,T,X,Y
  1. ;
  1. CTRL ;
  1. D HEADER
  1. D M
  1. D ASK I 'A7UOK QUIT ;->
  1. D XEC
  1. D BT QUIT:'A7UOK ;->
  1. G CTRL ;->
  1. ;
  1. BT ;
  1. N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
  1. W !
  1. S A7UOK=0
  1. N DIR
  1. S DIR(0)="EA",DIR("A")="Press RETURN to continue, or '^' to exit... "
  1. D ^DIR
  1. QUIT:+Y'=1 ;->
  1. S A7UOK=1
  1. QUIT
  1. ;
  1. N DEBUG,IOINHI,IOINORM,X
  1. W @IOF,$$CJ^XLFSTR("HLDIE Debug Utility",IOM)
  1. S DEBUG=$G(^XTMP("HLDIE-DEBUG","STATUS"))
  1. I DEBUG]"" D ; Show debug string...
  1. . S X="IOINORM;IOINHI" D ENDR^%ZISS
  1. . S DEBUG="Pre-call: "_$$CD($P(DEBUG,U))_" Post-call: "_$$CD($P(DEBUG,U,2))_" Screen: "_$$CD($P(DEBUG,U,3))
  1. . W !,?17,DEBUG
  1. W !,$$REPEAT^XLFSTR("=",80)
  1. QUIT
  1. ;
  1. CD(TXT) ; debug information
  1. ; IOINORM,IOINHI -- req
  1. QUIT:TXT']"" "OFF" ;->
  1. QUIT IOINHI_"ON["_TXT_"]"_IOINORM ;->
  1. ;
  1. M KILL A7UMENU N I,T F I=1:1 S T=$T(M+I) QUIT:T'[";;" S T=$P(T,";;",2,99),A7UMENU(I)=$P(T,"~",2,99) W !,$J(I,2),". ",$P(T,"~") S NOMENU=I
  1. ;;Display debug documentation~D DOC
  1. ;;Display debug data - API~D API^HLDIEDB0
  1. ;;Display debug data - FILE,IEN~D FILEIEN^HLDIEDB0
  1. ;;Display debug data - SEARCH~D SEARCH^HLDIEDB0
  1. ;;Display debug data - REALTIME~D REALTIME^HLDIEDB1
  1. ;;Display debug data - JOB~D JOB^HLDIEDB3
  1. ;;Set debug control string (Turn debugging on/off)~D SETDEBUG^HLDIEDBG
  1. ;;Kill debug data~D KILLALL^HLDIEDBG
  1. QUIT
  1. ;
  1. ASK ;
  1. ; NOMENU -- req
  1. N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
  1. W !
  1. S A7UOK=0
  1. N DIR
  1. S DIR(0)="NO^1:"_NOMENU,DIR("A")="Select option"
  1. D ^DIR
  1. QUIT:'$D(A7UMENU(+Y)) ;->
  1. S A7UOPT=+Y
  1. S A7UOK=1
  1. QUIT
  1. ;
  1. XEC ;
  1. S X=A7UMENU(+A7UOPT) X X
  1. QUIT
  1. ;
  1. REALTIME ; real-time monitoring...
  1. N C2,C3,C4,C5,C6,C7,C8,CT,GBL,LAST,STOP,X
  1. ;
  1. S GBL="^XTMP(""HLDIE-DEBUGN"",""N"")",LAST=$G(@GBL)
  1. S C2=7,C3=18,C4=30,C5=40,C6=52,C7=70,C8=75
  1. ;
  1. S CT=0
  1. ;
  1. D REALHDR
  1. ;
  1. F D Q:STOP
  1. . S STOP=1,CT=CT+1
  1. . D REALSHOW
  1. . R X:60 QUIT:X]"" ;->
  1. . S STOP=0
  1. ;
  1. Q
  1. ;
  1. REALHDR ; Header for real-time display...
  1. ; Cn -- req
  1. W !!,"#",?C2,"NOW",?C3,"File [#IEN]",?C4,"DataTM",?C5,"$J"
  1. W ?C6,"Rtn",?C7,"LOC",?C8,"Edtor"
  1. W !,$$REPEAT^XLFSTR("=",IOM)
  1. Q
  1. ;
  1. REALSHOW ; Show information...
  1. ;C2,C3,GBL,LAST -- req --> LAST
  1. N DNO,NOW,NUM
  1. ;
  1. S NUM=$G(@GBL),NOW=$$TIME($$NOW^XLFDT)
  1. ;
  1. I CT=1 D QUIT ;->
  1. . W !,?C2,NOW,?C3,"Collecting data..."
  1. ;
  1. I NUM=LAST D QUIT ;->
  1. . W:$X>0 !
  1. . W ?C2,NOW,?C3,"[No change]"
  1. ;
  1. F DNO=(LAST+1):1:NUM D REALONE(DNO)
  1. ;
  1. S LAST=NUM
  1. ;
  1. Q
  1. ;
  1. REALONE(DNO) ; Show one entry...
  1. ; Cn -- req
  1. N DATA,DATE,EDITOR,FILE,IEN,JOB,LOC,RTN,SNO,TIME
  1. ;
  1. S DATA=$G(@GBL@(DNO))
  1. S FILE=$P(DATA,U),IEN=$P(DATA,U,2),TIME=$P(DATA,U,3),JOB=$P(DATA,U,4)
  1. S RTN=$P(DATA,U,5),SNO=$P(DATA,U,6),EDITOR=$P(DATA,U,7)
  1. ;
  1. S TIME=$$TIME(TIME)
  1. ;
  1. W !,$J(DNO,5),?C2,NOW,?C3,FILE," [#",IEN,"]",?C4,TIME,?C5,JOB
  1. W ?C6,RTN,?C7,SNO,?C8,$S(EDITOR["HLDIE":"HL",1:"FM")
  1. ;
  1. Q
  1. ;
  1. TIME(FMTIME) ; Return HH:MM:SS
  1. S FMTIME=$P(FMTIME_"000000",".",2)
  1. QUIT $E(FMTIME,1,2)_":"_$E(FMTIME,3,4)_":"_$E(FMTIME,5,6)
  1. ;
  1. ;
  1. ;
  1. DOC N C,I,IOINHI,IOINORM,T,X
  1. S X="IOINHI;IOINORM" D ENDR^%ZISS
  1. F I=4:1 S T=$T(DOC+I) QUIT:T'[";;"!($G(X)[U) D
  1. . S T=$P(T,";;",2,99) S:$E(T,1,2)="[[" T=IOINHI_$TR(T,"[]","")_IOINORM W !,T
  1. ;;[[OVERVIEW]]
  1. ;; HLDIE debug data can be captured for evaluation by setting a "debug string."
  1. ;; The debug string is stored on the ^XTMP("HLDIE-DEBUG","STATUS") node.
  1. ;; This debug string should be set using the 'Set debug control string (Turn
  1. ;; debugging on/off)' menu choice.
  1. ;;
  1. ;;
  1. ;;[[DEBUG STRING DETAILS]]
  1. ;; The "debug string" had three(3) pieces:
  1. ;;
  1. ;; * Piece 1 controls data capture prior to FILE^DIE or FILE^HLDIE call.
  1. ;; - If set to 1, "select" data (see below) is captures.
  1. ;; - If set to 2, all local variables are captures.
  1. ;; - If set to "", no data is collected.
  1. ;;
  1. ;; * Piece 2 controls data capture after FILE^DIE or FILE^HLDIE call.
  1. ;; - See piece 1 above for setting details.
  1. ;;
  1. ;; * Piece 3 activates data capture screening.
  1. ;; - Piece 3 can be set to 1 to activate the data screen held in
  1. ;; $$STORESCR^HLDIEDB2. This API holds no M code, but is a placeholder
  1. ;; for M code that can evaluate the environment and on-the-fly turn on
  1. ;; or off data storage. (It can also control whethere "select" or all
  1. ;; data is captured.)
  1. ;;
  1. ;;
  1. ;;[[PIECE 3 DATA SCREEN DETAILS]]
  1. ;; If piece 3 of the debug control string equals 1, the following
  1. ;; occurs:
  1. ;;
  1. ;; * $$STORESCR^HLDIEDB2 is called by debugging process in FILE^HLDIE.
  1. ;; * The local variable STORE holds the value null, 1 or 2 (see above),
  1. ;; specifying whether data should be captured, and if so, whether "select"
  1. ;; or all local variables should be stored.
  1. ;; * If M code has been added to $$STORESCR^HLDIEDB2, it may evaluate the
  1. ;; environment and optionally reset STORE to null, 1 or 2.
  1. ;; * The value of STORE after M code execution is returned to the debugging
  1. ;; process. (And, if set to null, no data is captured.)
  1. ;;
  1. ;; The following variables are defined for use by the M code added to
  1. ;; $$STORESCR^HLDIEDB2:
  1. ;;
  1. ;; * CT - The number occurences already stored for TODAY/JOB#/API.
  1. ;; (When a job calls STATUS^HLTF0, a call is made to FILE^HLDIE which
  1. ;; can result in the creation of a debug data capture entry. Every
  1. ;; such call by the job to STATUS^HLTF0 results in the creation of
  1. ;; another data capture. Twenty such calls can be made, after which
  1. ;; the oldest capture is removed by the FIFO method. The value of CT
  1. ;; holds the total number of data capture occurences.)
  1. ;; * DEBUGNO - The sequential number to be used during data storage.
  1. ;; * DEBUGNOW - The date/time that will be used during data storage.
  1. ;; * HLFILE - The file being edited.
  1. ;; * HLIEN - The file's IEN being edited.
  1. ;; * LOC - 1 (before call) or 2 (after call).
  1. ;; * RTN - RTN~SUBRTN (from the 4th & 5th FILE^HLDIE parameters.)
  1. ;; * STORE - "" (don't store), 1 (store "select"), or 2 (store all.)
  1. ;;
  1. ;;
  1. ;;[[DEBUGGING - ALL VARIABLE STORAGE]]
  1. ;; Unrelated to the above debugging instructions, the
  1. ;; LOG^HLDIEDBG(SUBSV,KEEP,STOP) API can be used by VistA HL7 developers to
  1. ;; store all variables. (The DOLRO^%ZOSV API is used.) Data created by this
  1. ;; call is stored in:
  1. ;;
  1. ;; ^XTMP("HLDIE-"_DT,SUBSV,#,VAR)=VALUE
  1. ;;
  1. ;; Entries in this global are sequential at the '#' subscript level. When a
  1. ;; call is made to this API, all local variables are stored at the VAR
  1. ;; subscript level.
  1. ;;
  1. ;; The LOG API has the following parameters:
  1. ;;
  1. ;; * SUBSV - The subscript to be used when storing data. (The value of this
  1. ;; parameter is usually RTN~SUBRTN.)
  1. ;; * KEEP - The number of entries to store. (The entry of this parameter is
  1. ;; optional, defaulting to 20.)
  1. ;; * STOP - If set to 1, after KEEP number of entries are stored, no more
  1. ;; data is captured, (and no data is deleted.) If not set to 1,
  1. ;; KEEP number of entries are stored, the first entry stored is
  1. ;; deleted in FIFO manner, to ensure that no more than KEEP entries
  1. ;; exist.
  1. Q
  1. ;
  1. ERR ; If error occurs during screening...
  1. ; The SENDUZ(DUZ)="" array *MUST* already be defined...
  1. N C,DATA,ERRTXT,LP,NO,ST,STORERR,TEXT,TIME,X,XMDUZ,XMSUB,XMTEXT,XMZ
  1. ;
  1. ; Before continuing, specify that NOTHING should be stored...
  1. ; This email message is ALL that will be stored or sent.
  1. S STORE="" ; This variable is returned to FILE^HLDIE execution
  1. ;
  1. ; Also, turn off STORE capture!
  1. S ^XTMP("HLDIE-DEBUG","STATUS")=""
  1. ;
  1. ; Record an error in logger...
  1. S ERRTXT=$$EC^%ZOSV
  1. S X=$$LOG^HLEVAPI2("FILE-HLDIE","ERRTXT")
  1. ;
  1. ; setup things...
  1. S XMDUZ=.5,XMSUB="HLDIE $$STORESCR Error"
  1. S XMTEXT="^TMP("_$J_",""HLMSG"","
  1. KILL ^TMP($J,"HLMSG"),^TMP($J,"HLVAR")
  1. S NO=0
  1. ;
  1. ; Add text...
  1. D MAILADD("An error occurred in $$STORESCR^HLDIEDB2 that must be checked. The")
  1. D MAILADD("variables that existed at the time of the error are listed below.")
  1. D MAILADD("")
  1. D MAILADD("The error was '"_$$EC^%ZOSV_"'.")
  1. D MAILADD("")
  1. D MAILADD("IMPORTANT!! All debugging was turned off. Please review the problem,")
  1. D MAILADD(" then turn debugging back on.")
  1. D MAILADD("")
  1. D MAILADD("Local Variable List"),MAILADD("--------------------")
  1. ;
  1. S X="^TMP("_$J_",""HLVAR""," D DOLRO^%ZOSV
  1. S LP="^TMP("_$J_",""HLVAR""",ST=LP_",",LP=LP_")",C=","
  1. F S LP=$Q(@LP) Q:LP'[ST D
  1. . S DATA=$TR($P($P(LP,ST,2),")"),"""","")
  1. . I DATA[C S DATA=$P(DATA,C)_"("_$P(DATA,C,2,99)_")"
  1. . D MAILADD(DATA_"="_@LP)
  1. ;
  1. MERGE XMY=SENDUZ
  1. I $O(XMY(0))'>0 S XMY(+$G(DUZ))=""
  1. ;
  1. D ^XMD
  1. ;
  1. KILL ^TMP($J,"HLMSG"),^TMP($J,"HLVAR")
  1. ;
  1. D UNWIND^%ZTER
  1. ;
  1. Q
  1. ;
  1. MAILADD(T) S NO=$G(NO)+1,^TMP($J,"HLMSG",NO)=T
  1. QUIT
  1. ;
  1. EOR ;HLDIEDB1 - DEBUG Menu ;1/8/04 @ 01:28