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

AMHRP21.m

Go to the documentation of this file.
AMHRP21 ; IHS/CMI/LAB - PROCESS REPORT ;
 ;;4.0;IHS BEHAVIORAL HEALTH;;MAY 14, 2010
 ;
 ;
 ;
 ;
START ;
 D XTMP^AMHUTIL("AMHRP2","BH - GARS 1")
 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 ;
 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
 Q:'$$ALLOWVI^AMHUTIL(DUZ,AMHR)
 I $P(AMHR0,U,8) Q:$$DEMO^AMHUTIL1($P(AMHR0,U,8),$G(AMHDEMO))
 S AMHLOC=$P(AMHR0,U,4) Q:'$P(AMHR0,U,4)  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 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(^(AMHACT),U)=$S($D(^XTMP("AMHRP2",AMHJOB,AMHBT,"RECORDS",AMHAREA,AMHSU,AMHLOC,AMHPROV,AMHACT)):$P(^(AMHACT),U)+1,1:1)
 .S $P(^XTMP("AMHRP2",AMHJOB,AMHBT,"RECORDS",AMHAREA,AMHSU,AMHLOC,AMHPROV,AMHACT),U,2)=$P(^XTMP("AMHRP2",AMHJOB,AMHBT,"RECORDS",AMHAREA,AMHSU,AMHLOC,AMHPROV,AMHACT),U,2)+$P(AMHR0,U,12)
 .S $P(^XTMP("AMHRP2",AMHJOB,AMHBT,"RECORDS",AMHAREA,AMHSU,AMHLOC,AMHPROV,AMHACT),U,4)=$P(^XTMP("AMHRP2",AMHJOB,AMHBT,"RECORDS",AMHAREA,AMHSU,AMHLOC,AMHPROV,AMHACT),U,4)+$P(AMHR0,U,9)
 .Q:$P(AMHR0,U,8)=""
 .Q:$D(^XTMP("AMHRP2",AMHJOB,AMHBT,"PATIENT",AMHAREA,AMHSU,AMHLOC,AMHPROV,AMHACT,$P(AMHR0,U,8)))
 .S ^XTMP("AMHRP2",AMHJOB,AMHBT,"PATIENT",AMHAREA,AMHSU,AMHLOC,AMHPROV,AMHACT,$P(AMHR0,U,8))=""
 .S $P(^XTMP("AMHRP2",AMHJOB,AMHBT,"RECORDS",AMHAREA,AMHSU,AMHLOC,AMHPROV,AMHACT),U,3)=$P(^XTMP("AMHRP2",AMHJOB,AMHBT,"RECORDS",AMHAREA,AMHSU,AMHLOC,AMHPROV,AMHACT),U,3)+1
 Q