Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: AGSAMPG

AGSAMPG.m

Go to the documentation of this file.
AGSAMPG ; IHS/ASDS/EFG - DRAW RANDOM SAMPLE OF FACILITY CHARTS ;   
 ;;7.1;PATIENT REGISTRATION;;AUG 25,2005
 W @IOF,?10,"***   GENERATE RANDOM SAMPLE OF PATIENTS   ***",!!
 G:$D(DUZ)=0!($D(DUZ)=10) NOUSER D ^XBSITE G:'$D(DUZ(2)) NOUSER
 S AGTMP="^AGSAMPLE" K @AGTMP S ^AGSAMPLE(0)=DUZ(2)
A1 W !!,?10,"ENTER SAMPLE SIZE BETWEEN 1 AND 1000 " D READ I +Y<1!(+Y>1000) W *7,"  ??" G A1
 S AGV("SIZE")=+Y,AGRANGE=+$P(^AUPNPAT(0),U,3),AGV("SKIP")=0,AGV("SEL")=0,AGV("TRY")=0 W !!
B0 S XX=$R(AGRANGE),AGV("TRY")=AGV("TRY")+1 G B0:'$D(^AUPNPAT(XX)),B0:'$D(^AUPNPAT(XX,41,DUZ(2)))
 S AGHRN=$P(^AUPNPAT(XX,41,DUZ(2),0),U,2),AGLEN=$L(AGHRN),AGV("TDIG")=$E(AGHRN,AGLEN-1,AGLEN) I AGLEN>6 G B0
ELIG ;
 S (AGSTRIBE,AGSBEN,AGSBLOOD)=""
 G:'$D(^AUPNPAT(XX,11)) B0 S:$P(^AUPNPAT(XX,11),U,8)'="" AGSTRIBE=$P($G(^AUTTTRI($P(^AUPNPAT(XX,11),U,8),0)),U,2)
 S:$P(^AUPNPAT(XX,11),U,11)'="" AGSBEN=$P(^AUTTBEN($P(^AUPNPAT(XX,11),U,11),0),U,2)
 S AGSBLOOD=$P(^AUPNPAT(XX,11),U,10)
 G:AGSBEN'="01"!(AGSTRIBE="000")!(AGSTRIBE="998")!(AGSTRIBE="999")!(AGSBLOOD="NONE")!(AGSBLOOD="UNSPECIFIED")!(AGSBLOOD="UNKNOWN")!(AGSBLOOD="") B0
 K AGSTRIBE,AGSBEN,AGSBLOOD
RES ;
 G:'$D(^AUPNPAT(XX,51)) B0
 S AGS=0,(AGS1,AGSRES,AGSLOC)=""
RES1 ;
 S AGS=$O(^AUPNPAT(XX,51,AGS)) G:AGS="" RES2
 S AGS1=AGS G RES1
RES2 G:AGS1="" B0 S AGS=AGS1
 G:$P(^AUPNPAT(XX,51,AGS,0),U,3)="" B0          ;COMMUNITY OF RESIDENCE
 G:$P(^AUTTCOM($P(^AUPNPAT(XX,51,AGS,0),U,3),0),U,6)="" B0   ;AREA
 G:$P(^AUTTCOM($P(^AUPNPAT(XX,51,AGS,0),U,3),0),U,5)="" B0   ;SERVICE UNIT
 S AGSRES=$P(^AUTTAREA($P(^AUTTCOM($P(^AUPNPAT(XX,51,AGS,0),U,3),0),U,6),0),U,2)       ;CODE
 S AGSRES=AGSRES_$P(^AUTTSU($P(^AUTTCOM($P(^AUPNPAT(XX,51,AGS,0),U,3),0),U,5),0),U,3)  ;CODE
 S AGSLOC=$P(^AUTTLOC(DUZ(2),0),U,10)   ;ASUFAC INDEX
 G:$E(AGSLOC,1,4)'=AGSRES B0
 K AGS,AGS1,AGSLOC,AGSRES
 G:+AGV("SKIP")>100 B9
 S AGV("SKIP")=AGV("SKIP")+1
 I $D(^AGSAMPLE(AGV("TDIG"),AGHRN)) G B0
 S AGV("SKIP")=0
 W $J(AGV("SEL")+1,5),".  ",$J(AGV("TDIG"),2),?18,AGHRN,?28,$P(^DPT(XX,0),U),!
 S ^AGSAMPLE(AGV("TDIG"),AGHRN)=AGV("TDIG")_U_AGHRN_U_$P(^DPT(XX,0),U),AGV("SEL")=AGV("SEL")+1
 G:AGV("SEL")<AGV("SIZE") B0
B9 W !!,"NUMBER OF RECORDS EXAMINED = ",$J(AGV("TRY"),5),!!,"NUMBER OF RECORDS SELECTED = ",$J(AGV("SEL"),5)
 K AGLEN,AGHRN,AGV("TDIG"),AGRANGE,AGV("SKIP"),AGV("SEL"),AGV("SIZE"),AGV("TRY")
 Q
NOUSER W !,"The USER has not been set - please set it thru the KERNEL "
 Q
READ K DFOUT,DTOUT,DUOUT,DQOUT,DLOUT R Y:DTIME I '$T W *7 R Y:5 G READ:Y="." I '$T S (DTOUT,Y)="" Q
 S:Y="/.," (DFOUT,Y)="" S:Y="" DLOUT="" S:Y="^" (DUOUT,Y)="" S:Y?1"?".E!(Y["^") (DQOUT,Y)=""
 Q