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

AMHRLU.m

Go to the documentation of this file.
AMHRLU ; IHS/CMI/LAB - TUCSON-OHPRD/LAB - GEN RETR UTILITIES 03 Jun 2009 12:08 PM ;
 ;;4.0;IHS BEHAVIORAL HEALTH;;MAY 14, 2010
 ;
CASE ;EP - called from BH REPORT SORT
 K X
 Q:'$G(P)
 S Y=0 F  S Y=$O(^AMHPCASE("C",DFN,Y)) Q:Y'=+Y  S D=$P(^AMHPCASE(Y,0),U,P) D
 .Q:'$$ALLOWCD^AMHLCD(DUZ,Y)
 .Q:D=""
 .Q:$P(^AMHTRPT(AMHRPT,11,AMHI,11,1,0),U)]D
 .Q:D]$P(^AMHTRPT(AMHRPT,11,AMHI,11,1,0),U,2)
 .S X(D)=""
 .Q
 K P,D,Y
 Q
MCR(P,D) ;EP is patient medicare eligible on this date
 NEW AMHMIFN,AMHFLG
 S AMHFLG=0
 I '$D(^DPT(P,0)) G MCRX
 I $P(^DPT(P,0),U,19) G MCRX
 I '$D(^AUPNPAT(P,0)) G MCRX
 I '$D(^AUPNMCR(P,11)) G MCRX
 I $D(^DPT(P,.35)),$P(^(.35),U)]"",$P(^(.35),U)<D G MCRX
 S AMHMIFN=0 F  S AMHMIFN=$O(^AUPNMCR(P,11,AMHMIFN)) Q:AMHMIFN'=+AMHMIFN  D
 .Q:$P(^AUPNMCR(P,11,AMHMIFN,0),U)>D
 .I $P(^AUPNMCR(P,11,AMHMIFN,0),U,2)]"",$P(^(0),U,2)<D Q
 .S AMHFLG=1
 .Q
MCRX ;
 Q AMHFLG
 ;
MCD(P,D) ;EP
 NEW AMHMIFN,AMHNIFN,AMHFLG
 S AMHFLG=0
 I '$D(^DPT(P,0)) G MCRX
 I $P(^DPT(P,0),U,19) G MCRX
 I '$D(^AUPNPAT(P,0)) G MCDX
 I $D(^DPT(P,.35)),$P(^(.35),U)]"",$P(^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