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

AMHRBV2.m

Go to the documentation of this file.
AMHRBV2 ; IHS/CMI/LAB - gather billable visits 03 Jun 2009 1:01 PM ;
 ;;4.0;IHS BEHAVIORAL HEALTH;;MAY 14, 2010
 ;
 ;CMI/TUCSON/LAB - 09/22/97 - modified activity data to not bomb if null
 ;SEARCH VISIT FILE FOR DATE RANGE AND GENERATE CLINIC COUNTS
 ;
 S AMHJOB=$J,AMHBT=$H
 K ^XTMP("AMHRBV",AMHJOB,AMHBT)
 D XTMP^AMHUTIL("AMHRBV","BH - BILLABLE VISITS")
 S AMHS=AMHSD-.000001
 D @AMHPROC
 S AMHET=$H
 Q
1 F X="03","04","30","31" S Y=$O(^AUTTBEN("C",X,"")) S AMHCOAR(Y)="" S AMHCOPN(Y)=$P(^AUTTBEN(Y,0),U)
 D V
 ;
 Q
V ;
 F I=0:0 S AMHS=$O(^AMHREC("B",AMHS)) Q:AMHS=""!($P(AMHS,".")>AMHED)  D V1
 Q
V1 ;
 S AMHVDFN="" F J=0:0 S AMHVDFN=$O(^AMHREC("B",AMHS,AMHVDFN)) Q:AMHVDFN=""  I $$ALLOWVI^AMHUTIL(DUZ,AMHVDFN) S AMHVN0=^AMHREC(AMHVDFN,0) S DFN=$P(AMHVN0,U,8) I DFN]"" D @(AMHPROC_"2")
 Q
12 ;
 Q:'$D(^AUPNPAT(DFN,41,AMHSU,0))
 Q:'$D(^AUPNPAT(DFN,11))
 S AMHCOP=$P(^AUPNPAT(DFN,11),U,11) Q:AMHCOP=""
 Q:'$D(AMHCOAR(AMHCOP))
VC ;
 S AMHACT=$P(AMHVN0,U,6) Q:'AMHACT  Q:'$P(^AMHTACT(AMHACT,0),U,6)  ;do not use non patient activities CMI/TUCSON/LAB - added Q:'AMHACT to not bomb if activity null
 S AMHVISIT=$P(AMHVN0,U,16)
 Q:'$D(^AMHRPROV("A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