YTQGMTS ;SLC/KCM - MHA Health Summary APIs ; 9/15/2015
;;5.01;MENTAL HEALTH;**119**;Dec 30, 1994;Build 40
;
; Usage of SEL():
; I GMTSFI=601.71 D SEL^YTQGMTS(GMTSRT,GMTSI,GMTSCNT,GMTSDIR) Q
;
SEL(YTQROOT,YTQFROM,YTQMAX,YTQDIR) ; Get instrument list for health summary
I '$L($G(YTQROOT)) Q
S YTQMAX=$G(YTQMAX,44),YTQDIR=$G(YTQDIR,1)
;
N NM,IEN,CNT
S NM=$G(YTQFROM),CNT=0
F Q:CNT'<YTQMAX S NM=$O(^YTT(601.71,"B",NM),YTQDIR) Q:NM="" D
. S IEN=0 F S IEN=$O(^YTT(601.71,"B",NM,IEN)) Q:'IEN I $$VALID(IEN) D
. . S CNT=CNT+1,@YTQROOT@(CNT)=IEN_"^"_NM
Q
;
; Usage of $$ITER:
; S GMTSI=0_U_GMTSFM
; F S GMTSI=$$ITER^YTQGMTS(.GMTSI,DIR) Q:'GMTSI D
; . S GMTSC=GMTSC+1,^TMP("ORDATA",$J,1,GMTSC)=GMTSI
;
ITER(YTQITER,YTQDIR) ; pass in iterator to get next instrument
; YTQITER=fromIEN^fromName
N IEN,FROM,ITER
S IEN=+$P(YTQITER,U),FROM=$P(YTQITER,U,2),ITER=""
S YTQDIR=$G(YTQDIR,1)
F D Q:$$VALID(ITER)
. ; see if another IEN for this FROM
. I $L(FROM),IEN S IEN=$O(^YTT(601.71,"B",FROM,IEN))
. I IEN S ITER=IEN_U_FROM Q
. ; move to next/previous FROM
. S FROM=$O(^YTT(601.71,"B",FROM),YTQDIR)
. I '$L(FROM) S ITER="" Q
. S ITER=+$O(^YTT(601.71,"B",FROM,0))_U_FROM
Q ITER
;
VALID(ITER) ; return true if valid iterator (if instrument should be shown)
I ITER="" Q 1 ; end of list
I '$D(^YTT(601.71,+ITER,0)) Q 0 ; bad IEN
I $P($G(^YTT(601.71,+ITER,9)),U,1,2)="DLL^YTSCORE" Q 0 ; complex instrument
I $P($G(^YTT(601.71,+ITER,2)),U,5)'="Y" Q 0 ; never used
Q 1
;
; Tests:
;
TESTSEL(DIR) ; test SEL tag
N ROOT,I
K ^TMP("YTQGMTS",$J)
S ROOT=$NA(^TMP("YTQGMTS",$J,1))
W !,"FORWARD -------------"
D SEL(ROOT,"",100)
S I=0 F S I=$O(@ROOT@(I)) Q:'I W !,I,?10,@ROOT@(I)
K @ROOT
W !!,"REVERSE ------------"
D SEL(ROOT,"MMPI",20,-1)
S I=0 F S I=$O(@ROOT@(I)) Q:'I W !,I,?10,@ROOT@(I)
K @ROOT
Q
;
TESTFWD ; test forward iteration
D TESTLOOP(1)
Q
TESTREV ; test reverse iteration
D TESTLOOP(-1)
Q
TESTLOOP(DIR) ;
N GMTSI,GMTSC
S GMTSI="",GMTSC=0
F S GMTSI=$$ITER^YTQGMTS(.GMTSI,DIR) Q:'GMTSI S GMTSC=GMTSC+1 D
. W !,GMTSC,?10,GMTSI
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HYTQGMTS 2248 printed Dec 13, 2024@02:18:28 Page 2
YTQGMTS ;SLC/KCM - MHA Health Summary APIs ; 9/15/2015
+1 ;;5.01;MENTAL HEALTH;**119**;Dec 30, 1994;Build 40
+2 ;
+3 ; Usage of SEL():
+4 ; I GMTSFI=601.71 D SEL^YTQGMTS(GMTSRT,GMTSI,GMTSCNT,GMTSDIR) Q
+5 ;
SEL(YTQROOT,YTQFROM,YTQMAX,YTQDIR) ; Get instrument list for health summary
+1 IF '$LENGTH($GET(YTQROOT))
QUIT
+2 SET YTQMAX=$GET(YTQMAX,44)
SET YTQDIR=$GET(YTQDIR,1)
+3 ;
+4 NEW NM,IEN,CNT
+5 SET NM=$GET(YTQFROM)
SET CNT=0
+6 FOR
if CNT'<YTQMAX
QUIT
SET NM=$ORDER(^YTT(601.71,"B",NM),YTQDIR)
if NM=""
QUIT
Begin DoDot:1
+7 SET IEN=0
FOR
SET IEN=$ORDER(^YTT(601.71,"B",NM,IEN))
if 'IEN
QUIT
IF $$VALID(IEN)
Begin DoDot:2
+8 SET CNT=CNT+1
SET @YTQROOT@(CNT)=IEN_"^"_NM
End DoDot:2
End DoDot:1
+9 QUIT
+10 ;
+11 ; Usage of $$ITER:
+12 ; S GMTSI=0_U_GMTSFM
+13 ; F S GMTSI=$$ITER^YTQGMTS(.GMTSI,DIR) Q:'GMTSI D
+14 ; . S GMTSC=GMTSC+1,^TMP("ORDATA",$J,1,GMTSC)=GMTSI
+15 ;
ITER(YTQITER,YTQDIR) ; pass in iterator to get next instrument
+1 ; YTQITER=fromIEN^fromName
+2 NEW IEN,FROM,ITER
+3 SET IEN=+$PIECE(YTQITER,U)
SET FROM=$PIECE(YTQITER,U,2)
SET ITER=""
+4 SET YTQDIR=$GET(YTQDIR,1)
+5 FOR
Begin DoDot:1
+6 ; see if another IEN for this FROM
+7 IF $LENGTH(FROM)
IF IEN
SET IEN=$ORDER(^YTT(601.71,"B",FROM,IEN))
+8 IF IEN
SET ITER=IEN_U_FROM
QUIT
+9 ; move to next/previous FROM
+10 SET FROM=$ORDER(^YTT(601.71,"B",FROM),YTQDIR)
+11 IF '$LENGTH(FROM)
SET ITER=""
QUIT
+12 SET ITER=+$ORDER(^YTT(601.71,"B",FROM,0))_U_FROM
End DoDot:1
if $$VALID(ITER)
QUIT
+13 QUIT ITER
+14 ;
VALID(ITER) ; return true if valid iterator (if instrument should be shown)
+1 ; end of list
IF ITER=""
QUIT 1
+2 ; bad IEN
IF '$DATA(^YTT(601.71,+ITER,0))
QUIT 0
+3 ; complex instrument
IF $PIECE($GET(^YTT(601.71,+ITER,9)),U,1,2)="DLL^YTSCORE"
QUIT 0
+4 ; never used
IF $PIECE($GET(^YTT(601.71,+ITER,2)),U,5)'="Y"
QUIT 0
+5 QUIT 1
+6 ;
+7 ; Tests:
+8 ;
TESTSEL(DIR) ; test SEL tag
+1 NEW ROOT,I
+2 KILL ^TMP("YTQGMTS",$JOB)
+3 SET ROOT=$NAME(^TMP("YTQGMTS",$JOB,1))
+4 WRITE !,"FORWARD -------------"
+5 DO SEL(ROOT,"",100)
+6 SET I=0
FOR
SET I=$ORDER(@ROOT@(I))
if 'I
QUIT
WRITE !,I,?10,@ROOT@(I)
+7 KILL @ROOT
+8 WRITE !!,"REVERSE ------------"
+9 DO SEL(ROOT,"MMPI",20,-1)
+10 SET I=0
FOR
SET I=$ORDER(@ROOT@(I))
if 'I
QUIT
WRITE !,I,?10,@ROOT@(I)
+11 KILL @ROOT
+12 QUIT
+13 ;
TESTFWD ; test forward iteration
+1 DO TESTLOOP(1)
+2 QUIT
TESTREV ; test reverse iteration
+1 DO TESTLOOP(-1)
+2 QUIT
TESTLOOP(DIR) ;
+1 NEW GMTSI,GMTSC
+2 SET GMTSI=""
SET GMTSC=0
+3 FOR
SET GMTSI=$$ITER^YTQGMTS(.GMTSI,DIR)
if 'GMTSI
QUIT
SET GMTSC=GMTSC+1
Begin DoDot:1
+4 WRITE !,GMTSC,?10,GMTSI
End DoDot:1
+5 QUIT