AMQQF2 ; IHS/CMI/THL - MORE ANALYTIC FUNCTIONS ;
;;2.0;IHS PCC SUITE;;MAY 14, 2009
;-----
LAST N I,J,N,X,Y,Z,%
S J=0
F %=0:0 S %=$O(^UTILITY("AMQQ",$J,AMQQAG,AMQQUATN,%)) Q:'% S J=J+1,Y=$P(^(%),U,2) I Y S ^UTILITY("AMQQ",$J,"TMP",Y,%)=""
S Z=J-AMQQCOMP
I '$D(AMQQNOT),Z<1 G LAEXIT
I '$D(AMQQNOT) D LA1 G LAEXIT
I Z<1 K ^UTILITY("AMQQ",$J,AMQQAG,AMQQUATN) G LAEXIT
LA2 S (X,N)=0
F S X=$O(^UTILITY("AMQQ",$J,"TMP",X)) Q:'X F Y=0:0 S Y=$O(^UTILITY("AMQQ",$J,"TMP",X,Y)) Q:'Y S N=N+1 I N>Z K ^UTILITY("AMQQ",$J,AMQQAG,AMQQUATN,Y)
LAEXIT K ^UTILITY("AMQQ",$J,"TMP"),AMQQNOT
Q
;
LA1 S (X,I)=0
F S X=$O(^UTILITY("AMQQ",$J,"TMP",X)) Q:'X F Y=0:0 S Y=$O(^UTILITY("AMQQ",$J,"TMP",X,Y)) Q:'Y K ^UTILITY("AMQQ",$J,AMQQAG,AMQQUATN,Y) S I=I+1 I I=Z G LA1EXIT
LA1EXIT Q
;
FIRST N I,J,N,Y,Z,%
S J=0
F %=0:0 S %=$O(^UTILITY("AMQQ",$J,AMQQAG,AMQQUATN,%)) Q:'% S J=J+1,Y=$P(^(%),U,2) I Y S ^UTILITY("AMQQ",$J,"TMP",Y,%)=""
S Z=J-AMQQCOMP
I '$D(AMQQNOT),Z<1 G FIEXIT
I '$D(AMQQNOT) D FI1 G FIEXIT
I Z<1 K ^UTILITY("AMQQ",$J,AMQQAG,AMQQUATN) G FIEXIT
FI2 S (X,N)=0
F S X=$O(^UTILITY("AMQQ",$J,"TMP",X)) Q:'X F Y=0:0 S Y=$O(^UTILITY("AMQQ",$J,"TMP",X,Y)) Q:'Y S N=N+1 K ^UTILITY("AMQQ",$J,AMQQAG,AMQQUATN,Y) I N=AMQQCOMP G FIEXIT
FIEXIT K ^UTILITY("AMQQ",$J,"TMP"),AMQQNOT
Q
;
FI1 S (X,I)=0
F S X=$O(^UTILITY("AMQQ",$J,"TMP",X)) Q:'X F Y=0:0 S Y=$O(^UTILITY("AMQQ",$J,"TMP",X,Y)) Q:'Y S I=I+1 I I>AMQQCOMP K ^UTILITY("AMQQ",$J,AMQQAG,AMQQUATN,Y)
Q
;
HIGH N I,J,N,X,Y,Z,%
S J=0
F %=0:0 S %=$O(^UTILITY("AMQQ",$J,AMQQAG,AMQQUATN,%)) Q:'% S J=J+1,Y=+^(%),^UTILITY("AMQQ",$J,"TMP",Y,%)=""
S Z=J-AMQQCOMP
I '$D(AMQQNOT),Z<1 G HGEXIT
I '$D(AMQQNOT) D HG1 G HGEXIT
I Z<1 K ^UTILITY("AMQQ",$J,AMQQAG,AMQQUATN) G HGEXIT
HG2 S (X,N)=0
F S X=$O(^UTILITY("AMQQ",$J,"TMP",X)) Q:'X F Y=0:0 S Y=$O(^UTILITY("AMQQ",$J,"TMP",X,Y)) Q:'Y S N=N+1 I N>Z K ^UTILITY("AMQQ",$J,AMQQAG,AMQQUATN,Y)
HGEXIT K ^UTILITY("AMQQ",$J,"TMP"),AMQQNOT
Q
;
HG1 S (X,I)=0
F S X=$O(^UTILITY("AMQQ",$J,"TMP",X)) Q:'X F Y=0:0 S Y=$O(^UTILITY("AMQQ",$J,"TMP",X,Y)) Q:'Y K ^UTILITY("AMQQ",$J,AMQQAG,AMQQUATN,Y) S I=I+1 I I=Z G HG1EXIT
HG1EXIT Q
;
LOW N I,J,N,X,Y,Z,%
S J=0
F %=0:0 S %=$O(^UTILITY("AMQQ",$J,AMQQAG,AMQQUATN,%)) Q:'% S J=J+1,Y=+^(%),^UTILITY("AMQQ",$J,"TMP",Y,%)=""
S Z=J-AMQQCOMP
I '$D(AMQQNOT),Z<1 G LOEXIT
I '$D(AMQQNOT) D LO1 G LOEXIT
I Z<1 K ^UTILITY("AMQQ",$J,AMQQAG,AMQQUATN) G LOEXIT
LO2 S (X,N)=0
F S X=$O(^UTILITY("AMQQ",$J,"TMP",X)) Q:'X F Y=0:0 S Y=$O(^UTILITY("AMQQ",$J,"TMP",X,Y)) Q:'Y S N=N+1 K ^UTILITY("AMQQ",$J,AMQQAG,AMQQUATN,Y) I N=AMQQCOMP G LOEXIT
LOEXIT K ^UTILITY("AMQQ",$J,"TMP"),AMQQNOT
Q
;
LO1 S (X,I)=0
F S X=$O(^UTILITY("AMQQ",$J,"TMP",X)) Q:'X F Y=0:0 S Y=$O(^UTILITY("AMQQ",$J,"TMP",X,Y)) Q:'Y S I=I+1 I I>AMQQCOMP K ^UTILITY("AMQQ",$J,AMQQAG,AMQQUATN,Y)
Q
TYPES ;
Q
AMQQF2 ; IHS/CMI/THL - MORE ANALYTIC FUNCTIONS ;
+1 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
+2 ;-----
LAST NEW I,J,N,X,Y,Z,%
+1 SET J=0
+2 FOR %=0:0
SET %=$ORDER(^UTILITY("AMQQ",$JOB,AMQQAG,AMQQUATN,%))
IF '%
QUIT
SET J=J+1
SET Y=$PIECE(^(%),U,2)
IF Y
SET ^UTILITY("AMQQ",$JOB,"TMP",Y,%)=""
+3 SET Z=J-AMQQCOMP
+4 IF '$DATA(AMQQNOT)
IF Z<1
GOTO LAEXIT
+5 IF '$DATA(AMQQNOT)
DO LA1
GOTO LAEXIT
+6 IF Z<1
KILL ^UTILITY("AMQQ",$JOB,AMQQAG,AMQQUATN)
GOTO LAEXIT
LA2 SET (X,N)=0
+1 FOR
SET X=$ORDER(^UTILITY("AMQQ",$JOB,"TMP",X))
IF 'X
QUIT
FOR Y=0:0
SET Y=$ORDER(^UTILITY("AMQQ",$JOB,"TMP",X,Y))
IF 'Y
QUIT
SET N=N+1
IF N>Z
KILL ^UTILITY("AMQQ",$JOB,AMQQAG,AMQQUATN,Y)
LAEXIT KILL ^UTILITY("AMQQ",$JOB,"TMP"),AMQQNOT
+1 QUIT
+2 ;
LA1 SET (X,I)=0
+1 FOR
SET X=$ORDER(^UTILITY("AMQQ",$JOB,"TMP",X))
IF 'X
QUIT
FOR Y=0:0
SET Y=$ORDER(^UTILITY("AMQQ",$JOB,"TMP",X,Y))
IF 'Y
QUIT
KILL ^UTILITY("AMQQ",$JOB,AMQQAG,AMQQUATN,Y)
SET I=I+1
IF I=Z
GOTO LA1EXIT
LA1EXIT QUIT
+1 ;
FIRST NEW I,J,N,Y,Z,%
+1 SET J=0
+2 FOR %=0:0
SET %=$ORDER(^UTILITY("AMQQ",$JOB,AMQQAG,AMQQUATN,%))
IF '%
QUIT
SET J=J+1
SET Y=$PIECE(^(%),U,2)
IF Y
SET ^UTILITY("AMQQ",$JOB,"TMP",Y,%)=""
+3 SET Z=J-AMQQCOMP
+4 IF '$DATA(AMQQNOT)
IF Z<1
GOTO FIEXIT
+5 IF '$DATA(AMQQNOT)
DO FI1
GOTO FIEXIT
+6 IF Z<1
KILL ^UTILITY("AMQQ",$JOB,AMQQAG,AMQQUATN)
GOTO FIEXIT
FI2 SET (X,N)=0
+1 FOR
SET X=$ORDER(^UTILITY("AMQQ",$JOB,"TMP",X))
IF 'X
QUIT
FOR Y=0:0
SET Y=$ORDER(^UTILITY("AMQQ",$JOB,"TMP",X,Y))
IF 'Y
QUIT
SET N=N+1
KILL ^UTILITY("AMQQ",$JOB,AMQQAG,AMQQUATN,Y)
IF N=AMQQCOMP
GOTO FIEXIT
FIEXIT KILL ^UTILITY("AMQQ",$JOB,"TMP"),AMQQNOT
+1 QUIT
+2 ;
FI1 SET (X,I)=0
+1 FOR
SET X=$ORDER(^UTILITY("AMQQ",$JOB,"TMP",X))
IF 'X
QUIT
FOR Y=0:0
SET Y=$ORDER(^UTILITY("AMQQ",$JOB,"TMP",X,Y))
IF 'Y
QUIT
SET I=I+1
IF I>AMQQCOMP
KILL ^UTILITY("AMQQ",$JOB,AMQQAG,AMQQUATN,Y)
+2 QUIT
+3 ;
HIGH NEW I,J,N,X,Y,Z,%
+1 SET J=0
+2 FOR %=0:0
SET %=$ORDER(^UTILITY("AMQQ",$JOB,AMQQAG,AMQQUATN,%))
IF '%
QUIT
SET J=J+1
SET Y=+^(%)
SET ^UTILITY("AMQQ",$JOB,"TMP",Y,%)=""
+3 SET Z=J-AMQQCOMP
+4 IF '$DATA(AMQQNOT)
IF Z<1
GOTO HGEXIT
+5 IF '$DATA(AMQQNOT)
DO HG1
GOTO HGEXIT
+6 IF Z<1
KILL ^UTILITY("AMQQ",$JOB,AMQQAG,AMQQUATN)
GOTO HGEXIT
HG2 SET (X,N)=0
+1 FOR
SET X=$ORDER(^UTILITY("AMQQ",$JOB,"TMP",X))
IF 'X
QUIT
FOR Y=0:0
SET Y=$ORDER(^UTILITY("AMQQ",$JOB,"TMP",X,Y))
IF 'Y
QUIT
SET N=N+1
IF N>Z
KILL ^UTILITY("AMQQ",$JOB,AMQQAG,AMQQUATN,Y)
HGEXIT KILL ^UTILITY("AMQQ",$JOB,"TMP"),AMQQNOT
+1 QUIT
+2 ;
HG1 SET (X,I)=0
+1 FOR
SET X=$ORDER(^UTILITY("AMQQ",$JOB,"TMP",X))
IF 'X
QUIT
FOR Y=0:0
SET Y=$ORDER(^UTILITY("AMQQ",$JOB,"TMP",X,Y))
IF 'Y
QUIT
KILL ^UTILITY("AMQQ",$JOB,AMQQAG,AMQQUATN,Y)
SET I=I+1
IF I=Z
GOTO HG1EXIT
HG1EXIT QUIT
+1 ;
LOW NEW I,J,N,X,Y,Z,%
+1 SET J=0
+2 FOR %=0:0
SET %=$ORDER(^UTILITY("AMQQ",$JOB,AMQQAG,AMQQUATN,%))
IF '%
QUIT
SET J=J+1
SET Y=+^(%)
SET ^UTILITY("AMQQ",$JOB,"TMP",Y,%)=""
+3 SET Z=J-AMQQCOMP
+4 IF '$DATA(AMQQNOT)
IF Z<1
GOTO LOEXIT
+5 IF '$DATA(AMQQNOT)
DO LO1
GOTO LOEXIT
+6 IF Z<1
KILL ^UTILITY("AMQQ",$JOB,AMQQAG,AMQQUATN)
GOTO LOEXIT
LO2 SET (X,N)=0
+1 FOR
SET X=$ORDER(^UTILITY("AMQQ",$JOB,"TMP",X))
IF 'X
QUIT
FOR Y=0:0
SET Y=$ORDER(^UTILITY("AMQQ",$JOB,"TMP",X,Y))
IF 'Y
QUIT
SET N=N+1
KILL ^UTILITY("AMQQ",$JOB,AMQQAG,AMQQUATN,Y)
IF N=AMQQCOMP
GOTO LOEXIT
LOEXIT KILL ^UTILITY("AMQQ",$JOB,"TMP"),AMQQNOT
+1 QUIT
+2 ;
LO1 SET (X,I)=0
+1 FOR
SET X=$ORDER(^UTILITY("AMQQ",$JOB,"TMP",X))
IF 'X
QUIT
FOR Y=0:0
SET Y=$ORDER(^UTILITY("AMQQ",$JOB,"TMP",X,Y))
IF 'Y
QUIT
SET I=I+1
IF I>AMQQCOMP
KILL ^UTILITY("AMQQ",$JOB,AMQQAG,AMQQUATN,Y)
+2 QUIT
TYPES ;
+1 QUIT