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

AMERBIN.m

Go to the documentation of this file.
AMERBIN ; IHS/ANMC/GIS - MAKES AGE BIN REPORTS ; 
 ;;3.0;ER VISIT SYSTEM;;FEB 23, 2009
 ;
 N AMERA,AMERX,AMERY,AMERZ,%DT,AMERLINE
 I '$D(AMERZZZ) S (AMERZZZ,AMERXXX)=0
 S AMERZZZ=AMERZZZ+1
VAR S AMERDFN=@$S($D(AMERDEEP):($E("DDDDDD",1,AMERDEEP)_"D0"),$D(DD0):"DD0",1:"D0"),AMERVAL=Y I '$D(^DPT(AMERDFN)) D FAIL Q
 S AMERDOB=$P(^DPT(AMERDFN,0),U,3)
 I AMERDOB="" D FAIL Q
 I IOST["C-",AMERZZZ>1 W *13,AMERZZZ I AMERXXX W "  (",AMERXXX,")"
 I AMERVAL="" S AMERVAL="UNSPECIFIED"
 I $D(AMERBIN) D ATT Q
REP I '$D(^TMP("AMERAGE",$J)) D SETBIN
 S AMERNN=^TMP("AMERAGE",$J),AMERA=""
 S DIOEND="D BLIST^AMERBIN"
 I IOST["C-" W !!!!,"CRUNCH, CRUNCH....",!!
 K ^TMP("AMERBIN",$J)
 F I=1:1 S AMERX=$P(AMERNN,";",I) Q:AMERX=""  D SETA
 S AMERBIN=AMERA
 F I=1:1:$L(AMERA,";") S ^TMP("AMERBIN",$J,"B",I)=0
 D ATT
 Q
 ;
FAIL S AMERXXX=AMERXXX+1
 I AMERZZZ>1 W *13,AMERZZZ,"  (",AMERXXX,")"
 Q
 ;
SETA S AMERY=$P(AMERX,":"),AMERZ=$P(AMERX,":",2)
 I AMERA'="" S AMERA=AMERA_";"
 S AMERA=AMERA_(DT+1-(10000*(AMERZ+1)))_":"_(DT-(AMERY*10000))
 Q
 ;
ATT S AMERA=AMERBIN
 F I=1:1 S AMERNN=$P(AMERA,";",I) Q:AMERNN=""  S AMERX=$P(AMERNN,":"),AMERY=$P(AMERNN,":",2) I AMERDOB'<AMERX,AMERDOB'>AMERY D SETV Q
 Q
 ;
SETV ;
 I '$D(^TMP("AMERBIN",$J,"V",AMERVAL)) S ^(AMERVAL)=0
 S ^TMP("AMERBIN",$J,"V",AMERVAL)=^TMP("AMERBIN",$J,"V",AMERVAL)+1
 S ^TMP("AMERBIN",$J,"B",I)=^TMP("AMERBIN",$J,"B",I)+1
 I '$D(^TMP("AMERBIN",$J,1,AMERVAL,I)) S ^(I)=0
 S ^TMP("AMERBIN",$J,1,AMERVAL,I)=^TMP("AMERBIN",$J,1,AMERVAL,I)+1
 Q
 ;
BLIST ; I IOST["C-" R !!,"<>",AMERX#1:DTIME
 I '$D(^TMP("AMERAGE",$J)) D SETBIN
 D HEADER
BLVAR ;
 S N=""
 S AMERLINE=""
 F AMERLINE=1:1 S I=0,N=$O(^TMP("AMERBIN",$J,1,N)) Q:N=""  D:'(AMERLINE#(IOSL-4)) PAUSE Q:AMERLINE=999999  W !,$E(N,1,12) D B1
 W !!,"TOTAL"
 S (I,AMERZ)=0 F J=16:7 S I=$O(^TMP("AMERBIN",$J,"B",I)) Q:'I  W ?J,^(I) S AMERZ=AMERZ+^(I)
 W ?J,AMERZ
 I $D(AMERXXX),AMERXXX W !!,AMERXXX," ENTR",$S(AMERXXX>1:"IES",1:"Y")," NOT INCLUDED BECAUSE OF BAD POINTERS OR LACK OF DOB"
 I IOST'?1"C-".E W @IOF D ^%ZISC G EXIT
 D ^%ZISC W !! S DIR(0)="E",DIR("A")="<>" D ^DIR S AMERX=Y K DIR,Y
EXIT K ^TMP("AMERBIN",$J),^TMP("AMERAGE",$J),X,Y,Z,AMERNN,AMERVAL,AMERAV,AMERDFN,AMERDOB,AMERSNA,AMERSNO,A,G,AMERDEEP,AMERZZZ,AMERXXX,AMERLINE,AMERBIN,N
 Q
 ;
B1 ;
 F J=16:7 D
 .S I=I+1 Q:I>$L(^TMP("AMERAGE",$J),";")
 .W ?J,$S($D(^TMP("AMERBIN",$J,1,N,I)):^(I),1:".")
 .I I+1>$L(^TMP("AMERAGE",$J),";") W ?(J+7),^TMP("AMERBIN",$J,"V",N)
 Q
 ;
PAUSE ;
 I IOST["C-" W ! S DIR(0)="E",DIR("A")="<>" D ^DIR S AMERQ=Y K DIR,Y
 S:'$T!(AMERQ=U) AMERLINE=999999 K AMERQ
 D HEADER
 Q
 ;
 W !,?35,"AGE GROUPS",!
 I '$D(AMERSNA) S AMERSNA="ATTRIBUTE"
 S AMERNN=$E(AMERSNA,1,12) I $L(AMERNN)<12 S AMERNN=AMERNN_$J("",12-$L(AMERNN))
 W AMERNN
 S AMERNN=^TMP("AMERAGE",$J),AMERI=0
 S AMERJ=""
 F AMERJ=14:7 S AMERI=AMERI+1,AMERX=$P(AMERNN,";",AMERI) Q:AMERX=""  W ?AMERJ,$S($P(AMERX,":")=$P(AMERX,":",2):"  ",1:($P(AMERX,":")_"-")),$P(AMERX,":",2)
 W ?(AMERJ+2),"TOT"
 S AMERX="",$P(AMERX,"-",80)="" W !,AMERX
 K AMERI,AMERJ,AMERX
 Q
 ;
SETBIN S ^TMP("AMERAGE",$J)="0:1;2:4;5:12;13:19;20:39;40:59;60:79;80:199"
 Q