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