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

AMHRPTST.m

Go to the documentation of this file.
AMHRPTST ; IHS/CMI/LAB - PROCESS REPORT ;
 ;;4.0;IHS BEHAVIORAL HEALTH;**4**;JUN 18, 2010;Build 28
 ;
SETTMP2 ;EP
UTL ;
 D PROBPROC
 Q
 ;
SET F AMHPOV=0:0 S AMHPOV=$O(@AMHA) Q:'AMHPOV  S %=^(AMHPOV),@AMHC@(9999999-%,AMHPOV)=""
 Q
SETTMP1 ;EP ; SET TMP FOR PROGRAM ACTIVITY REPORT
 D XTMP^AMHUTIL("AMHRAT2","BH RPOGRAM REPORT")
 S AMHPRIM="P"
 S (AMHCOUNT,AMHPPOV)="" F  S AMHPPOV=$O(^AMHRPRO("AD",AMHR,AMHPPOV)) Q:AMHPPOV'=+AMHPPOV!(AMHCOUNT>0&(AMHPRIM="P"))  S AMHCOUNT=AMHCOUNT+1 D @AMHRPROC,SETTMP11
 Q
SETTMP11 ;
 S ^("REC TOTAL")=$S($D(^XTMP("AMHRAT2",AMHJOB,AMHBTH,@AMHSORT,$P(AMHR0,U,2),"REC TOTAL")):^("REC TOTAL")+1,1:1)
 S ^("REC TOTAL")=$S($D(^XTMP("AMHRAT2",AMHJOB,AMHBTH,@AMHSORT,"C","REC TOTAL")):^("REC TOTAL")+1,1:1)
 S ^("TIME TOTAL")=$S($D(^XTMP("AMHRAT2",AMHJOB,AMHBTH,@AMHSORT,$P(AMHR0,U,2),"TIME TOTAL")):^("TIME TOTAL")+($P(AMHR0,U,12)),1:$P(AMHR0,U,12))
 S ^("TIME TOTAL")=$S($D(^XTMP("AMHRAT2",AMHJOB,AMHBTH,@AMHSORT,"C","TIME TOTAL")):^("TIME TOTAL")+($P(AMHR0,U,12)),1:$P(AMHR0,U,12))
 Q:$P(AMHR0,U,8)=""
 Q:$D(^XTMP("AMHRAT2",AMHJOB,AMHBTH,@AMHSORT,$P(AMHR0,U,2),"PATS",$P(AMHR0,U,8),@AMHSORT))
 S ^XTMP("AMHRAT2",AMHJOB,AMHBTH,@AMHSORT,$P(AMHR0,U,2),"PATS",$P(AMHR0,U,8),@AMHSORT)=""
 S ^("PATIENT TOTAL")=$S($D(^XTMP("AMHRAT2",AMHJOB,AMHBTH,@AMHSORT,$P(AMHR0,U,2),"PATIENT TOTAL")):^("PATIENT TOTAL")+1,1:1)
 S ^("PATIENT TOTAL")=$S($D(^XTMP("AMHRAT2",AMHJOB,AMHBTH,@AMHSORT,"C","PATIENT TOTAL")):^("PATIENT TOTAL")+1,1:1)
 Q
 ;
SETTMP ;EP - CALLED FROM AMHPT4
 D XTMP^AMHUTIL("AMHRAP2","BH ACTIVITY COUNTS")
 S AMHPPOV=$O(^AMHRPRO("AD",AMHR,""))
 D @AMHRPROC
 S ^(AMHSRT2)=$S($D(^XTMP("AMHRAP2",AMHJOB,AMHBTH,"TOTAL",@AMHSORT,AMHSRT2)):^(AMHSRT2)+1,1:1)
 S ^(AMHSRT2)=$S($D(^XTMP("AMHRAP2",AMHJOB,AMHBTH,"TIME TOTAL",@AMHSORT,AMHSRT2)):^(AMHSRT2)+$P(AMHR0,U,12),1:$P(AMHR0,U,12))
 S ^(AMHSRT2)=$S($D(^XTMP("AMHRAP2",AMHJOB,AMHBTH,"# SERVED",@AMHSORT,AMHSRT2)):^(AMHSRT2)+$P(AMHR0,U,9),1:$P(AMHR0,U,9))
 Q:$P(AMHR0,U,8)=""
 Q:$D(^XTMP("AMHRAP2",AMHJOB,AMHBTH,"PATS",$P(AMHR0,U,8),@AMHSORT))
 S ^XTMP("AMHRAP2",AMHJOB,AMHBTH,"PATS",$P(AMHR0,U,8),@AMHSORT)=""
 S ^(AMHSRT2)=$S($D(^XTMP("AMHRAP2",AMHJOB,AMHBTH,"PATIENT",@AMHSORT,AMHSRT2)):^(AMHSRT2)+1,1:1)
 Q
PROG ;
 S AMHPROG=$P(AMHR0,U,2) I AMHPROG="" S AMHPROG="NO PROGRAM ENTERED",AMHSRT2="--" Q
  S AMHSRT2=$P(AMHR0,U,2),AMHPROG=$S($P(AMHR0,U,2)="M":"MENTAL HEALTH",$P(AMHR0,U,2)="S":"SOCIAL SERVICES",$P(AMHR0,U,2)="C":"CHEMICAL DEPENDENCY or ALCOHOL/SUBSTANCE ABUSE",$P(AMHR0,U,2)="O":"OTHER",1:"NO PROGRAM ENTERED")
 Q
 ;
APWI ;
 S AMHAPWI=$P(AMHR0,U,11) I AMHAPWI="" S AMHAPWI="NO APPT/WALK-IN RECORDED",AMHSRT2="--" Q
 S AMHSRT2=$P(AMHR0,U,11),AMHAPWI=$S($P(AMHR0,U,11)="A":"APPOINTMENT",$P(AMHR0,U,11)="W":"WALK-IN",$P(AMHR0,U,11)="U":"UNSPECIFIED",1:"NO PROGRAM ENTERED")
 Q
 ;
INT ;
 S AMHINTR=$P(AMHR0,U,15) I AMHINTR="" S AMHINTR="NOT RECORDED",AMHSRT2="--" Q
 S AMHSRT2=$P(AMHR0,U,15),AMHINTR=$S($P(AMHR0,U,15)=1:"YES, INTERPRETOR UTILIZED",1:"INTERPRETOR NOT UTILIZED")
 Q
TOC ;
 S AMHCAT=$P(^AMHTSET($P(AMHR0,U,7),0),U)
 S AMHSRT2=$P(^AMHTSET($P(AMHR0,U,7),0),U,2)
 K ^UTILITY("DIQ1",$J)
 Q
DATE ;
 S AMHDATE=$P(AMHODAT,".")
 S X=AMHDATE D H^%DTC S AMHSRT2=$P("SUNDAY;MONDAY;TUESDAY;WEDNESDAY;THURSDAY;FRIDAY;SATURDAY",";",%Y+1) I AMHSRT2="" S AMHSRT2="UNKNOWN"
 Q
DISC ;
 S AMHDISC=$E($$PPCLS^AMHUTIL(AMHR,"E"),1,25),AMHSRT2=$$PPCLSC^AMHUTIL(AMHR)
 Q
PROV ;
 S AMHPROV=$$PPNAME^AMHUTIL(AMHR),AMHSRT2=$E($$PPCLS^AMHUTIL(AMHR,"E"),1,20)
 Q
COMM ;
 S AMHCOMM=$P(^AUTTCOM($P(AMHR0,U,5),0),U),AMHSRT2=$P(^(0),U,8)
 Q
ACTC ;
 K ^UTILITY("DIQ1",$J)
 K DIQ,DIC,DA,DR
 S DIC="^AMHTACT(",DR=".03",DA=$P(AMHR0,U,6),DIQ(0)="E" D EN^DIQ1 K DIC,DA,DR,DIQ
 S AMHACTC=^UTILITY("DIQ1",$J,9002012,$P(AMHR0,U,6),.03,"E")
 S AMHSRT2=$P(^AMHTACT($P(AMHR0,U,6),0),U,3)
 K ^UTILITY("DIQ1",$J)
 Q
ACT ;
 S AMHACT=$E($P(^AMHTACT($P(AMHR0,U,6),0),U,2),1,60),AMHSRT2=$P(^AMHTACT($P(AMHR0,U,6),0),U)
 Q
SU ;
 S AMHSU=$P(^AUTTLOC($P(AMHR0,U,4),0),U,5) I AMHSU="" S AMHSU="NONE ENTERED",AMHSRT2="9999" Q
 S AMHSRT2=$P(^AUTTSU(AMHSU,0),U,4),AMHSU=$P(^AUTTSU(AMHSU,0),U)
 Q
AGE ;
 I $P(AMHR0,U,8)="" S AMHAGE="--",AMHSRT2="--" Q
 S AMHAGE=$$AGE^AUPNPAT($P(AMHR0,U,8),$P($P(AMHR0,U),".")),AMHSRT2="--"
 Q
GENDER ;
 I $P(AMHR0,U,8)="" S AMHSEX="--",AMHSRT2="--" Q
 S AMHSRT2=$P(^DPT($P(AMHR0,U,8),0),U,2),AMHSEX=$S(AMHSRT2="F":"FEMALE",AMHSRT2="M":"MALE",1:"UNKNOWN")
 Q
CLN ;
 S AMHCLN=$P(AMHR0,U,25)
 I AMHCLN S AMHSRT2=$P(^DIC(40.7,AMHCLN,0),U,2),AMHCLN=$P(^DIC(40.7,AMHCLN,0),U)
 I AMHCLN="" S AMHCLN="<none entered>",AMHSRT2="--"
 I $G(AMHSRT2)="" S AMHSRT2="--"
 Q
LSS ;
 S AMHLSS=$P(AMHR0,U,31)
 I AMHLSS S AMHSRT2=$P(^AMHLSS(AMHLSS,0),U,2),AMHLSS=$P(^AMHLSS(AMHLSS,0),U)
 I AMHLSS="" S AMHLSS="<none entered>"
 I $G(AMHSRT2)="" S AMHSRT2="--"
 Q
LOS ;
 S AMHVLOC=$P(^DIC(4,$P(AMHR0,U,4),0),U),AMHSRT2=$P(^AUTTLOC($P(AMHR0,U,4),0),U,10)
 Q
 ;
PROBPROC ;
 I AMHRRPT="A"!(AMHRRPT="AC") S AMHPPOV=$O(^AMHRPRO("AD",AMHR,0)) D @AMHRPROC,SETTMP21 Q
 S (AMHCOUNT,AMHPPOV)="" F  S AMHPPOV=$O(^AMHRPRO("AD",AMHR,AMHPPOV)) Q:AMHPPOV'=+AMHPPOV!(AMHCOUNT>0&(AMHPRIM="P"))  S AMHCOUNT=AMHCOUNT+1 D @AMHRPROC,SETTMP21
 Q
SETTMP21 ;
 S X=AMHA
 S AMHPOV=@AMHSORT
 I '$D(@X) S @X=0
 S AMHTACT=$P(^AMHREC(AMHR,0),U,12)
 S %=+(@X),%=%+1,%1=$P((@X),U,3),%1=%1+AMHTACT,@X=%_"^"_AMHSRT2_"^"_%1
 K %,%1
 Q
PROB ;
 ;S AMHPPOV=$O(^AMHRPRO("AD",AMHR,""))
 I AMHPPOV="" S AMHPROB="NO PROBLEMS/POVS ENTERED",AMHSRT2="---" Q
 S AMHPROB=$P(^AMHRPRO(AMHPPOV,0),U),AMHPROB=$P(^AMHPROB(AMHPROB,0),U,3),AMHPROB=$E($P(^AMHPROBC(AMHPROB,0),U,2),1,60)
 S AMHSRT2=$P(^AMHRPRO(AMHPPOV,0),U),AMHSRT2=$P(^AMHPROB(AMHSRT2,0),U,3),AMHSRT2=$P(^AMHPROBC(AMHSRT2,0),U)
 Q
PROBD ;
 ;S AMHPPOV=$O(^AMHRPRO("AD",AMHR,""))
 I AMHPPOV="" S AMHPROB="NO PROBLEMS/POVS ENTERED",AMHSRT2="---" Q
 S AMHSRT2=$P(^AMHPROB($P(^AMHRPRO(AMHPPOV,0),U),0),U)
 S AMHPROB=$E($P(^AMHPROB($P(^AMHRPRO(AMHPPOV,0),U),0),U,2),1,60)
 Q
PROBCAT ;
 ;S AMHPPOV=$O(^AMHRPRO("AD",AMHR,""))
 I AMHPPOV="" S AMHPROB="NO PROBLEMS/POVS ENTERED",AMHSRT2="---" Q
 S AMHSRT2=$P(^AMHPROB($P(^AMHRPRO(AMHPPOV,0),U),0),U,3),AMHSRT2=$P(^AMHPROBC(AMHSRT2,0),U,3)
 S AMHPROB=$E($P(^AMHPCAT(AMHSRT2,0),U),1,60)
 Q