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

AMHRPT4.m

Go to the documentation of this file.
AMHRPT4 ; IHS/CMI/LAB - PROCESS VISIT LIST ;
 ;;4.0;IHS BEHAVIORAL HEALTH;;MAY 14, 2010
 ;
 ;
 ;
START ;
 S (AMHBT,AMHBTH)=$H,AMHJOB=$J
 D XTMP^AMHUTIL("AMHRPT","BH REPORT")
 I $P(^AMHRCNT(AMHRPTC,0),U,11)]"" S AMHRPREP=$P(^(0),U,11) S AMHRPREP=$TR(AMHRPREP,"~","^") D @AMHRPREP
 D D,END
 Q
 ;
S ;run by search template
 S AMHR=0 F  S AMHR=$O(^DIBT(AMHSEAT,1,AMHR)) Q:AMHR'=+AMHR  D PROC,EOJ
 Q
D ; Run by visit 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 V1
 Q
 ;
END ;
 I $P(^AMHRCNT(AMHRPTC,0),U,9)]"" S AMHRPOSP=$P(^(0),U,9) S AMHRPOSP=$TR(AMHRPOSP,"~","^") D @AMHRPOSP
 S AMHET=$H
 D EOJ
 Q
EOJ ;
 K AMHB,AMHI,AMHR,AMHRCNT
 Q
V1 ;
 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 $P(AMHR0,U,8) Q:'$$ALLOWP^AMHUTIL(DUZ,$P(AMHR0,U,8))
 Q:$P(AMHR0,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