YTXUTL ;SLC/KCM - Debug Utilities ; 9/15/2015
;;5.01;MENTAL HEALTH;**121**;Dec 30, 1994;Build 61
;
; View instrument spec as a tree
;
VIEWTREE ;
N DIC,X,Y
S DIC="^YTT(601.95,",DIC(0)="AEMQ" D ^DIC Q:'Y
K ^TMP($J)
D SPEC2TR^YTXCHGT(+Y,$NA(^TMP($J)))
W !,"Use ^TMP($J) to view tree"
Q
; Look for usages of an ID (question ID, display ID, etc.) in the MHA files.
; Can be used, for example, to see if a question is used by multiple tests.
;
QLOOP(IDFILE) ; Repeat prompt for ID to search for usages
; IDFILE: Reference file where the ID resides
N X
F W !,"IEN: " R X:DTIME Q:'$L(X) D
. W ?20,$G(^YTT(IDFILE,+X,0))
. D QUSAGE(+X,IDFILE)
Q
QUSAGE(ID,IDFILE) ; Search files for usage of QUEST
; ID: Identifier (IEN) that we are finding usages of
; IDFILE: File number -- tells which file:field map to use
N I,X,MAP,QMAP,FILE,PIECE,IEN,TESTP
; Build the map -- MAP(file,piece)=testPiece
S QMAP="Q"_$P(IDFILE,".",2)
F I=1:1 S X=$P($T(@QMAP+I),";;",2,99) Q:X="zzzzz" D
. S MAP($P(X,U),$P(X,U,2))=$P(X,U,3)
; Search thru files, pieces for usage of ID
S FILE=0 F S FILE=$O(MAP(FILE)) Q:'FILE D
. S PIECE=0 F S PIECE=$O(MAP(FILE,PIECE)) Q:'PIECE D
. . S TESTP=MAP(FILE,PIECE)
. . S IEN=0 F S IEN=$O(^YTT(FILE,IEN)) Q:'IEN D
. . . I $P(^YTT(FILE,IEN,0),U,PIECE)=ID D QOUT(FILE,IEN,TESTP)
Q
QCTYP(ID) ; Find instruments using this choice type
S IEN=0 F S IEN=$O(^YTT(601.72,IEN)) Q:'IEN D
. I $P($G(^YTT(601.72,IEN,2)),U,3)=ID D QUSAGE(IEN,601.72)
Q
QOUT(FILE,IEN,TESTP) ; Write out using IEN, Instrument
; FILE: file number that contains the usage
; IEN: IEN of the usage
; TESTP: piece number of the instrument pointer (or S or R)
N TEST
I TESTP S TEST=$P(^YTT(FILE,IEN,0),U,TESTP)
I TESTP="R" D ; from rule file (601.82)
. N RULE S RULE=+^YTT(601.82,IEN,0)
. S TEST=$P(^YTT(601.83,IEN,0),U,2)
I TESTP="S" D ; from scoring key file (601.91)
. N SCALE S SCALE=$P(^YTT(601.91,IEN,0),U,2)
. N GROUP S GROUP=$P(^YTT(601.87,SCALE,0),U,2)
. S TEST=$P(^YTT(601.86,GROUP,0),U,2)
W !,FILE," IEN:",IEN,?20,"Instrument: ",$P($G(^YTT(601.71,TEST,0)),U)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HYTXUTL 2158 printed Oct 16, 2024@18:22:52 Page 2
YTXUTL ;SLC/KCM - Debug Utilities ; 9/15/2015
+1 ;;5.01;MENTAL HEALTH;**121**;Dec 30, 1994;Build 61
+2 ;
+3 ; View instrument spec as a tree
+4 ;
VIEWTREE ;
+1 NEW DIC,X,Y
+2 SET DIC="^YTT(601.95,"
SET DIC(0)="AEMQ"
DO ^DIC
if 'Y
QUIT
+3 KILL ^TMP($JOB)
+4 DO SPEC2TR^YTXCHGT(+Y,$NAME(^TMP($JOB)))
+5 WRITE !,"Use ^TMP($J) to view tree"
+6 QUIT
+7 ; Look for usages of an ID (question ID, display ID, etc.) in the MHA files.
+8 ; Can be used, for example, to see if a question is used by multiple tests.
+9 ;
QLOOP(IDFILE) ; Repeat prompt for ID to search for usages
+1 ; IDFILE: Reference file where the ID resides
+2 NEW X
+3 FOR
WRITE !,"IEN: "
READ X:DTIME
if '$LENGTH(X)
QUIT
Begin DoDot:1
+4 WRITE ?20,$GET(^YTT(IDFILE,+X,0))
+5 DO QUSAGE(+X,IDFILE)
End DoDot:1
+6 QUIT
QUSAGE(ID,IDFILE) ; Search files for usage of QUEST
+1 ; ID: Identifier (IEN) that we are finding usages of
+2 ; IDFILE: File number -- tells which file:field map to use
+3 NEW I,X,MAP,QMAP,FILE,PIECE,IEN,TESTP
+4 ; Build the map -- MAP(file,piece)=testPiece
+5 SET QMAP="Q"_$PIECE(IDFILE,".",2)
+6 FOR I=1:1
SET X=$PIECE($TEXT(@QMAP+I),";;",2,99)
if X="zzzzz"
QUIT
Begin DoDot:1
+7 SET MAP($PIECE(X,U),$PIECE(X,U,2))=$PIECE(X,U,3)
End DoDot:1
+8 ; Search thru files, pieces for usage of ID
+9 SET FILE=0
FOR
SET FILE=$ORDER(MAP(FILE))
if 'FILE
QUIT
Begin DoDot:1
+10 SET PIECE=0
FOR
SET PIECE=$ORDER(MAP(FILE,PIECE))
if 'PIECE
QUIT
Begin DoDot:2
+11 SET TESTP=MAP(FILE,PIECE)
+12 SET IEN=0
FOR
SET IEN=$ORDER(^YTT(FILE,IEN))
if 'IEN
QUIT
Begin DoDot:3
+13 IF $PIECE(^YTT(FILE,IEN,0),U,PIECE)=ID
DO QOUT(FILE,IEN,TESTP)
End DoDot:3
End DoDot:2
End DoDot:1
+14 QUIT
QCTYP(ID) ; Find instruments using this choice type
+1 SET IEN=0
FOR
SET IEN=$ORDER(^YTT(601.72,IEN))
if 'IEN
QUIT
Begin DoDot:1
+2 IF $PIECE($GET(^YTT(601.72,IEN,2)),U,3)=ID
DO QUSAGE(IEN,601.72)
End DoDot:1
+3 QUIT
QOUT(FILE,IEN,TESTP) ; Write out using IEN, Instrument
+1 ; FILE: file number that contains the usage
+2 ; IEN: IEN of the usage
+3 ; TESTP: piece number of the instrument pointer (or S or R)
+4 NEW TEST
+5 IF TESTP
SET TEST=$PIECE(^YTT(FILE,IEN,0),U,TESTP)
+6 ; from rule file (601.82)
IF TESTP="R"
Begin DoDot:1
+7 NEW RULE
SET RULE=+^YTT(601.82,IEN,0)
+8 SET TEST=$PIECE(^YTT(601.83,IEN,0),U,2)
End DoDot:1
+9 ; from scoring key file (601.91)
IF TESTP="S"
Begin DoDot:1
+10 NEW SCALE
SET SCALE=$PIECE(^YTT(601.91,IEN,0),U,2)
+11 NEW GROUP
SET GROUP=$PIECE(^YTT(601.87,SCALE,0),U,2)
+12 SET TEST=$PIECE(^YTT(601.86,GROUP,0),U,2)
End DoDot:1
+13 WRITE !,FILE," IEN:",IEN,?20,"Instrument: ",$PIECE($GET(^YTT(601.71,TEST,0)),U)
+14 QUIT