AMQQAT11 ; IHS/CMI/THL - GETS OVERFLOW FROM AMQQAT1 ;
;;2.0;IHS PCC SUITE;;MAY 14, 2009
;-----
RUN W !,"Maximum sample size allowed is 50% of this total (",AMQQRNDN,")"
W !!,"There are 2 ways to determine sample size =>",!
W !?5,"1) Sample a certain NUMBER of cohort members"
W !?5,"2) Sample a certain PERCENT of cohort members",!
S AMQQCRFL=""
D GET^AMQQAT1
I $D(AMQQQUIT) Q
I X=1 D S1^AMQQAT1 Q:$D(AMQQQUIT) S AMQQCHNN=X G RAND
D S2^AMQQAT1
Q:$D(AMQQQUIT)
S X=X*.01*AMQQCHTT
S AMQQCHNN=X\1
RAND I $D(AMQQFFIL) Q
N I,X,Y,Z,N,I
I IOST["C-" W !!,"Collecting a random sample",!
I +AMQQCHRT K ^UTILITY("AMQQ RAND",$J,+AMQQCHRT)
S X=0
S AMQQCHRT=AMQQCHRT_";"_$J_";"_AMQQCHNN
S I=0
S N=AMQQCHTT-1
S AMQQLINK=$S(AMQQCCLS="P":166,1:86)
F S Y=$R(N)+1,Z=$O(^UTILITY("AMQQ TEMP",$J,Y,"")) I Z,'$D(^UTILITY("AMQQ RAND",$J,+AMQQCHRT,Z)) S ^(Z)="",I=I+1 W:IOST["C-" $C(13),I I I=AMQQCHNN Q
K ^UTILITY("AMQQ TEMP",$J),AMQQRNDN
Q
;
COUNT ; ENTRY POINT FROM AMQQAT1
I IOST["C-" W !!!,"Counting " W:$D(AMQQCRFG) "cohort before sampling" W "...",!
S X=0
F I=0:1 S X=$O(^DIBT(AMQQCHRT,1,X)) Q:'X W:IOST["C-"&('(I#100)) $C(13),I I $D(AMQQCRFG) S ^UTILITY("AMQQ TEMP",$J,I+1,X)=""
I IOST["C-" W $C(13)," ",$C(13),!!,"There are ",I," entries in this cohort" W:'$D(AMQQCRFG) !!!
Q
;
STUFF ; ENTRY POINT FROM METADICTIONARY
S AMQQCHRT=%
S AMQQCRFG=""
S AMQQCHNN=%(1)
D COUNT
K AMQQCRFG
S AMQQCHTT=I
D RAND
K %,AMQQCHNN,AMQQCHRT,AMQQCHTT
Q
;
AMQQAT11 ; IHS/CMI/THL - GETS OVERFLOW FROM AMQQAT1 ;
+1 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
+2 ;-----
RUN WRITE !,"Maximum sample size allowed is 50% of this total (",AMQQRNDN,")"
+1 WRITE !!,"There are 2 ways to determine sample size =>",!
+2 WRITE !?5,"1) Sample a certain NUMBER of cohort members"
+3 WRITE !?5,"2) Sample a certain PERCENT of cohort members",!
+4 SET AMQQCRFL=""
+5 DO GET^AMQQAT1
+6 IF $DATA(AMQQQUIT)
QUIT
+7 IF X=1
DO S1^AMQQAT1
IF $DATA(AMQQQUIT)
QUIT
SET AMQQCHNN=X
GOTO RAND
+8 DO S2^AMQQAT1
+9 IF $DATA(AMQQQUIT)
QUIT
+10 SET X=X*.01*AMQQCHTT
+11 SET AMQQCHNN=X\1
RAND IF $DATA(AMQQFFIL)
QUIT
+1 NEW I,X,Y,Z,N,I
+2 IF IOST["C-"
WRITE !!,"Collecting a random sample",!
+3 IF +AMQQCHRT
KILL ^UTILITY("AMQQ RAND",$JOB,+AMQQCHRT)
+4 SET X=0
+5 SET AMQQCHRT=AMQQCHRT_";"_$JOB_";"_AMQQCHNN
+6 SET I=0
+7 SET N=AMQQCHTT-1
+8 SET AMQQLINK=$SELECT(AMQQCCLS="P":166,1:86)
+9 FOR
SET Y=$RANDOM(N)+1
SET Z=$ORDER(^UTILITY("AMQQ TEMP",$JOB,Y,""))
IF Z
IF '$DATA(^UTILITY("AMQQ RAND",$JOB,+AMQQCHRT,Z))
SET ^(Z)=""
SET I=I+1
IF IOST["C-"
WRITE $CHAR(13),I
IF I=AMQQCHNN
QUIT
+10 KILL ^UTILITY("AMQQ TEMP",$JOB),AMQQRNDN
+11 QUIT
+12 ;
COUNT ; ENTRY POINT FROM AMQQAT1
+1 IF IOST["C-"
WRITE !!!,"Counting "
IF $DATA(AMQQCRFG)
WRITE "cohort before sampling"
WRITE "...",!
+2 SET X=0
+3 FOR I=0:1
SET X=$ORDER(^DIBT(AMQQCHRT,1,X))
IF 'X
QUIT
IF IOST["C-"&('(I#100))
WRITE $CHAR(13),I
IF $DATA(AMQQCRFG)
SET ^UTILITY("AMQQ TEMP",$JOB,I+1,X)=""
+4 IF IOST["C-"
WRITE $CHAR(13)," ",$CHAR(13),!!,"There are ",I," entries in this cohort"
IF '$DATA(AMQQCRFG)
WRITE !!!
+5 QUIT
+6 ;
STUFF ; ENTRY POINT FROM METADICTIONARY
+1 SET AMQQCHRT=%
+2 SET AMQQCRFG=""
+3 SET AMQQCHNN=%(1)
+4 DO COUNT
+5 KILL AMQQCRFG
+6 SET AMQQCHTT=I
+7 DO RAND
+8 KILL %,AMQQCHNN,AMQQCHRT,AMQQCHTT
+9 QUIT
+10 ;