AMQQAT1 ; IHS/CMI/THL - GETS INFO FOR RANDOM SAMPLE COLLECTION ;
;;2.0;IHS PCC SUITE;;MAY 14, 2009
;-----
I $D(AMQQCHRT) W !!,"You cannot select a RANDOM SAMPLE and a SEARCH COHORT in the same query",!!,*7 K AMQQRAND Q
VAR S %=$S(AMQQCCLS="P":"^DPT",1:"^AUPNVSIT")
S AMQQRNDN=$P(@%@(0),U,4)\2
S AMQQRCNM=$S(AMQQCCLS="P":"PATIENT",1:"VISIT")
D NP
EXIT K AMQQRNDN,AMQQRCNM,%,I
Q
;
NP W !!,"There are ",(AMQQRNDN*2)," ",AMQQRCNM,"S in the database"
W !!?5,"1) Select a certain number of ",AMQQRCNM,"S for the sample"
W !?5,"2) Select a certain percentage of ",AMQQRCNM,"S for the sample",!
GET ; ENTRY POINT FROM AMQQAT11
R !,"YOUR CHOICE (1-2): 1// ",X:DTIME E S X=U
I X?1."?" W !!,"Enter 1 or 2. You may enter '^' to exit.",!! G GET
I X=U S AMQQQUIT="" Q
I X="" S X=1 W " (1)"
I X,X<3,$D(AMQQCRFL) K AMQQCRFL Q
I X,X<3 D SET Q
W " ??",*7 G GET
Q
;
SET D @("S"_X)
I Y=-1 Q
S ^UTILITY("AMQQ",$J,"LIST",.2)="W ?6,""A RANDOM SAMPLE OF "_$S(AMQQCNAM'["RANDOM":AMQQCNAM,1:$P(AMQQCNAM," ",4))_" WILL BE USED"""
S AMQQRAND=(AMQQRNDN*2)_";"_Y
S AMQQRNDF=""
D LIST^AMQQ
Q
;
S1 ; ENTRY POINT FROM AMQQAT11
W !!,"How many ",AMQQRCNM,"S do you want in the sample: "
R X:DTIME E S X=U
I X=U S Y=-1,AMQQQUIT="" Q
I X="" S Y=-1 Q
I X?1."?" W !!,"Enter a number between 1 and ",AMQQRNDN,!! G S1
I X,X'>(AMQQRNDN),X?1.9N S Y=X Q
W " ??",*7
G S1
;
S2 ; ENTRY POINT FROM AMQQAT11
W !!,"What percent of the patients do you want in the sample: "
R X:DTIME E S X=U
I X=U S Y=-1,AMQQQUIT="" Q
I X="" S Y=-1 Q
I X?1."?" W !!,"Enter a number between 1 and 50" G S2
I X?1.2N,X,X<51 Q:$D(AMQQRCFL) S Y=AMQQRNDN*X\50 W "%" Q
W " ??",*7
G S2
;
COHORT ; ENTRY POINT FOR SEARCH TEMPLATE COHORTS
S AMQQRCNM=$S(AMQQCCLS="P":"PATIENT",1:"VISIT")
I AMQQATNM="FILE ENTRY" D ^AMQQAT2 Q
I $D(AMQQRAND) W !!,"You cannot select a RANDOM SAMPLE and a SEARCH COHORT in the same query",!!,*7 K AMQQCHRT Q
I '$D(AMQQCHRT),'$D(AMQQYYYY) S DIC="^DIBT(",DIC(0)="AEQ" G CODIC
I $D(AMQQYYYY) S AMQQCHRT=$P(AMQQYYYY,";",3)
S X=$E(AMQQCHRT,2,99)
I $E(X,$L(X))="]" S X=$E(X,1,$L(X)-1)
S DIC="^DIBT("
S DIC(0)="EQ"
K AMQQCHRT
I $D(AMQQXX) S DIC(0)=""
CODIC S DIC("S")="S %=$P(^(0),U,4) I %=2!(%=9000001)"
S %=$P(^AMQQ(1,AMQQLINK,0),U,2)
I %'=2 S DIC("S")="I $P(^(0),U,4)="_%
D ^DIC
K DIC
I Y=-1,X=U S AMQQQUIT="" Q
I Y=-1 Q
S AMQQCHRT=+Y,X=$P(Y,U,2)
D COEX
Q
;
COEX I $D(AMQQXX) S X=1 Q
I '$D(^DIBT(AMQQCHRT,1)) W !!,"Sorry, this template is empty!!",!!,*7 S AMQQQUIT="" H 3 Q
W !!,"Select one of the following =>",!!?5
W "1) ",AMQQCNAM," must be a member of the ",X," cohort",!?5
W "2) ",AMQQCNAM," must NOT be a member of the ",X," cohort",!?5
W "3) Select a random sample of the ",X," cohort",!?5
W "4) Count the number of entries in the ",X," cohort",!!
CQ W "Your choice (1-4): 1// " R X:DTIME E S X=U
I X=4 D COUNT^AMQQAT11 G COEX
I X="" S X=1
I $E(X)=U S AMQQQUIT="" Q
I X?1N,X,X<5 G CQ1
W " ??",*7,!
G CQ
CQ1 I X=2 S AMQQLINK=$S(AMQQCCLS="P":151,1:85) Q
I X=1 Q
D CNP
Q
;
CNP S AMQQCRFG=""
D COUNT^AMQQAT11
K AMQQCRFG
S AMQQCHTT=I
S AMQQRNDN=AMQQCHTT\2
CNP1 ; ENTRY POINT FROM AMQQAT2
D ^AMQQAT11
Q
;
AMQQAT1 ; IHS/CMI/THL - GETS INFO FOR RANDOM SAMPLE COLLECTION ;
+1 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
+2 ;-----
+3 IF $DATA(AMQQCHRT)
WRITE !!,"You cannot select a RANDOM SAMPLE and a SEARCH COHORT in the same query",!!,*7
KILL AMQQRAND
QUIT
VAR SET %=$SELECT(AMQQCCLS="P":"^DPT",1:"^AUPNVSIT")
+1 SET AMQQRNDN=$PIECE(@%@(0),U,4)\2
+2 SET AMQQRCNM=$SELECT(AMQQCCLS="P":"PATIENT",1:"VISIT")
+3 DO NP
EXIT KILL AMQQRNDN,AMQQRCNM,%,I
+1 QUIT
+2 ;
NP WRITE !!,"There are ",(AMQQRNDN*2)," ",AMQQRCNM,"S in the database"
+1 WRITE !!?5,"1) Select a certain number of ",AMQQRCNM,"S for the sample"
+2 WRITE !?5,"2) Select a certain percentage of ",AMQQRCNM,"S for the sample",!
GET ; ENTRY POINT FROM AMQQAT11
+1 READ !,"YOUR CHOICE (1-2): 1// ",X:DTIME
IF '$TEST
SET X=U
+2 IF X?1."?"
WRITE !!,"Enter 1 or 2. You may enter '^' to exit.",!!
GOTO GET
+3 IF X=U
SET AMQQQUIT=""
QUIT
+4 IF X=""
SET X=1
WRITE " (1)"
+5 IF X
IF X<3
IF $DATA(AMQQCRFL)
KILL AMQQCRFL
QUIT
+6 IF X
IF X<3
DO SET
QUIT
+7 WRITE " ??",*7
GOTO GET
+8 QUIT
+9 ;
SET DO @("S"_X)
+1 IF Y=-1
QUIT
+2 SET ^UTILITY("AMQQ",$JOB,"LIST",.2)="W ?6,""A RANDOM SAMPLE OF "_$SELECT(AMQQCNAM'["RANDOM":AMQQCNAM,1:$PIECE(AMQQCNAM," ",4))_" WILL BE USED"""
+3 SET AMQQRAND=(AMQQRNDN*2)_";"_Y
+4 SET AMQQRNDF=""
+5 DO LIST^AMQQ
+6 QUIT
+7 ;
S1 ; ENTRY POINT FROM AMQQAT11
+1 WRITE !!,"How many ",AMQQRCNM,"S do you want in the sample: "
+2 READ X:DTIME
IF '$TEST
SET X=U
+3 IF X=U
SET Y=-1
SET AMQQQUIT=""
QUIT
+4 IF X=""
SET Y=-1
QUIT
+5 IF X?1."?"
WRITE !!,"Enter a number between 1 and ",AMQQRNDN,!!
GOTO S1
+6 IF X
IF X'>(AMQQRNDN)
IF X?1.9N
SET Y=X
QUIT
+7 WRITE " ??",*7
+8 GOTO S1
+9 ;
S2 ; ENTRY POINT FROM AMQQAT11
+1 WRITE !!,"What percent of the patients do you want in the sample: "
+2 READ X:DTIME
IF '$TEST
SET X=U
+3 IF X=U
SET Y=-1
SET AMQQQUIT=""
QUIT
+4 IF X=""
SET Y=-1
QUIT
+5 IF X?1."?"
WRITE !!,"Enter a number between 1 and 50"
GOTO S2
+6 IF X?1.2N
IF X
IF X<51
IF $DATA(AMQQRCFL)
QUIT
SET Y=AMQQRNDN*X\50
WRITE "%"
QUIT
+7 WRITE " ??",*7
+8 GOTO S2
+9 ;
COHORT ; ENTRY POINT FOR SEARCH TEMPLATE COHORTS
+1 SET AMQQRCNM=$SELECT(AMQQCCLS="P":"PATIENT",1:"VISIT")
+2 IF AMQQATNM="FILE ENTRY"
DO ^AMQQAT2
QUIT
+3 IF $DATA(AMQQRAND)
WRITE !!,"You cannot select a RANDOM SAMPLE and a SEARCH COHORT in the same query",!!,*7
KILL AMQQCHRT
QUIT
+4 IF '$DATA(AMQQCHRT)
IF '$DATA(AMQQYYYY)
SET DIC="^DIBT("
SET DIC(0)="AEQ"
GOTO CODIC
+5 IF $DATA(AMQQYYYY)
SET AMQQCHRT=$PIECE(AMQQYYYY,";",3)
+6 SET X=$EXTRACT(AMQQCHRT,2,99)
+7 IF $EXTRACT(X,$LENGTH(X))="]"
SET X=$EXTRACT(X,1,$LENGTH(X)-1)
+8 SET DIC="^DIBT("
+9 SET DIC(0)="EQ"
+10 KILL AMQQCHRT
+11 IF $DATA(AMQQXX)
SET DIC(0)=""
CODIC SET DIC("S")="S %=$P(^(0),U,4) I %=2!(%=9000001)"
+1 SET %=$PIECE(^AMQQ(1,AMQQLINK,0),U,2)
+2 IF %'=2
SET DIC("S")="I $P(^(0),U,4)="_%
+3 DO ^DIC
+4 KILL DIC
+5 IF Y=-1
IF X=U
SET AMQQQUIT=""
QUIT
+6 IF Y=-1
QUIT
+7 SET AMQQCHRT=+Y
SET X=$PIECE(Y,U,2)
+8 DO COEX
+9 QUIT
+10 ;
COEX IF $DATA(AMQQXX)
SET X=1
QUIT
+1 IF '$DATA(^DIBT(AMQQCHRT,1))
WRITE !!,"Sorry, this template is empty!!",!!,*7
SET AMQQQUIT=""
HANG 3
QUIT
+2 WRITE !!,"Select one of the following =>",!!?5
+3 WRITE "1) ",AMQQCNAM," must be a member of the ",X," cohort",!?5
+4 WRITE "2) ",AMQQCNAM," must NOT be a member of the ",X," cohort",!?5
+5 WRITE "3) Select a random sample of the ",X," cohort",!?5
+6 WRITE "4) Count the number of entries in the ",X," cohort",!!
CQ WRITE "Your choice (1-4): 1// "
READ X:DTIME
IF '$TEST
SET X=U
+1 IF X=4
DO COUNT^AMQQAT11
GOTO COEX
+2 IF X=""
SET X=1
+3 IF $EXTRACT(X)=U
SET AMQQQUIT=""
QUIT
+4 IF X?1N
IF X
IF X<5
GOTO CQ1
+5 WRITE " ??",*7,!
+6 GOTO CQ
CQ1 IF X=2
SET AMQQLINK=$SELECT(AMQQCCLS="P":151,1:85)
QUIT
+1 IF X=1
QUIT
+2 DO CNP
+3 QUIT
+4 ;
CNP SET AMQQCRFG=""
+1 DO COUNT^AMQQAT11
+2 KILL AMQQCRFG
+3 SET AMQQCHTT=I
+4 SET AMQQRNDN=AMQQCHTT\2
CNP1 ; ENTRY POINT FROM AMQQAT2
+1 DO ^AMQQAT11
+2 QUIT
+3 ;