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

AMHRP31.m

Go to the documentation of this file.
AMHRP31 ; IHS/CMI/LAB - PROCESS REPORT ;
 ;;4.0;IHS BEHAVIORAL HEALTH;;MAY 14, 2010
 ;
 ;
 ;
 ;
START ;
 D XTMP^AMHUTIL("AMHRP3","BH ACTIVITY BY PRIMPROV")
 S (AMHBT,AMHBTH)=$H,AMHJOB=$J
 D D,END
 Q
 ;
D ; Run by encounter date
 S X1=AMHBD,X2=-1 D C^%DTC S AMHSD=X
 S AMHODAT=AMHSD_".9999" F  S AMHODAT=$O(^AMHREC("B",AMHODAT)) Q:AMHODAT=""!((AMHODAT\1)>AMHED)  D D1
 Q
 ;
END ;
 S AMHET=$H
 D EOJ
 Q
EOJ ;
 Q
D1 ;
 S (AMHR,AMHRCNT)=0 F  S AMHR=$O(^AMHREC("B",AMHODAT,AMHR)) Q:AMHR'=+AMHR  I $D(^AMHREC(AMHR,0)),$P(^(0),U,2)]"",$P(^(0),U,3)]"" S AMHR0=^(0) D PROC
 Q
PROC ;
 Q:'$$ALLOWVI^AMHUTIL(DUZ,AMHR)
 I $P(AMHR0,U,8) Q:$$DEMO^AMHUTIL1($P(AMHR0,U,8),$G(AMHDEMO))
 I AMHPROG]"",$P(AMHR0,U,2)'=AMHPROG Q
 I AMHPRV S (X,G)=0 F  S X=$O(^AMHRPROV("AD",AMHR,X)) Q:X'=+X  I $P(^AMHRPROV(X,0),U)=AMHPRV S G=1
 I AMHPRV,'G Q
 K X,G
 S AMHLOC=$P(AMHR0,U,4) Q:AMHLOC=""  S AMHAREA=$P(^AUTTLOC(AMHLOC,0),U,4),AMHSU=$P(^AUTTLOC(AMHLOC,0),U,5)
 S AMHACT=$P(AMHR0,U,6),AMHACT=$S(AMHACT]"":$P(^AMHTACT(AMHACT,0),U)_"-"_$P(^(0),U,2),1:"9999-UNKNOWN")
 S AMHPIEN=$O(^AMHRPRO("AD",AMHR,"")) S AMHPIEN=$S(AMHPIEN]"":$P(^AMHRPRO(AMHPIEN,0),U),1:"")
 S AMHPROB=$S(AMHPIEN]"":$P(^AMHPROB(AMHPIEN,0),U)_"-"_$P(^AMHPROB(AMHPIEN,0),U,2),1:"NO PROBLEM RECORDED")
 S AMHX=0 F  S AMHX=$O(^AMHRPROV("AD",AMHR,AMHX)) Q:AMHX'=+AMHX  D
 .I AMHPRV,AMHPRV'=$P(^AMHRPROV(AMHX,0),U) Q
 .I AMHPSP="P",$P(^AMHRPROV(AMHX,0),U,4)'="P" Q
 .S AMHPNAME=$P(^VA(200,$P(^AMHRPROV(AMHX,0),U),0),U),AMHDISC=$$PROVCLS^XBFUNC1($P(^AMHRPROV(AMHX,0),U),"E"),AMHPROV=AMHPNAME_" ("_AMHDISC_")"
 .S $P(^(AMHPROB),U)=$S($D(^XTMP("AMHRP3",AMHJOB,AMHBT,"RECORDS",AMHAREA,AMHSU,AMHLOC,AMHPROV,AMHACT,AMHPROB)):$P(^(AMHPROB),U)+1,1:1)
 .S $P(^XTMP("AMHRP3",AMHJOB,AMHBT,"RECORDS",AMHAREA,AMHSU,AMHLOC,AMHPROV,AMHACT,AMHPROB),U,2)=$P(^XTMP("AMHRP3",AMHJOB,AMHBT,"RECORDS",AMHAREA,AMHSU,AMHLOC,AMHPROV,AMHACT,AMHPROB),U,2)+$P(AMHR0,U,12)
 .S $P(^XTMP("AMHRP3",AMHJOB,AMHBT,"RECORDS",AMHAREA,AMHSU,AMHLOC,AMHPROV,AMHACT,AMHPROB),U,4)=$P(^XTMP("AMHRP3",AMHJOB,AMHBT,"RECORDS",AMHAREA,AMHSU,AMHLOC,AMHPROV,AMHACT,AMHPROB),U,4)+$P(AMHR0,U,9)
 .Q:$P(AMHR0,U,8)=""
 .Q:$D(^XTMP("AMHRP3",AMHJOB,AMHBT,"PATIENT",AMHAREA,AMHSU,AMHLOC,AMHPROV,AMHACT,AMHPROB,$P(AMHR0,U,8)))
 .S ^XTMP("AMHRP3",AMHJOB,AMHBT,"PATIENT",AMHAREA,AMHSU,AMHLOC,AMHPROV,AMHACT,AMHPROB,$P(AMHR0,U,8))=""
 .S $P(^XTMP("AMHRP3",AMHJOB,AMHBT,"RECORDS",AMHAREA,AMHSU,AMHLOC,AMHPROV,AMHACT,AMHPROB),U,3)=$P(^XTMP("AMHRP3",AMHJOB,AMHBT,"RECORDS",AMHAREA,AMHSU,AMHLOC,AMHPROV,AMHACT,AMHPROB),U,3)+1
 Q