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

APCLACC2.m

Go to the documentation of this file.
APCLACC2 ; IHS/CMI/LAB - process active user report ;
 ;;2.0;IHS PCC SUITE;**11**;MAY 14, 2009;Build 58
 ;IHS/CMI/LAB - added template creation
 ;
 S APCLJOB=$J,APCLBT=$H
 K ^XTMP("APCLACC",APCLJOB,APCLBT),^XTMP("APCLACCR",APCLJOB,APCLBT),^XTMP("APCLACC SU",APCLJOB,APCLBT)
 D XTMP^APCLOSUT("APCLACC","PCC ACTIVE USERS REPORT")
 D XTMP^APCLOSUT("APCLACCR","PCC ACTIVE USERS REPORT")
 D XTMP^APCLOSUT("APCLACC SU","PCC ACTIVE USERS REPORT")
 S APCLMAJ=$S(APCLSORT="C":"APCLCOMN",APCLSORT="T":"APCLTRI",1:"APCLSUR")
 S APCLMIN=$S(APCLSORT="C":"APCLTRI",1:"APCLCOMN")
X S X1=APCLFYE,X2=1 D C^%DTC S APCLFYB=($E(X,1,3)-3)_$E(X,4,7) S Y=APCLFYB D DD^%DT S APCLFYBY=Y
 ;S X1=APCLFYE,X2=$S(+$E(APCLFYE,4,7)>930:-1096,1:-1461) D C^%DTC
 ;S APCLFYB=$E(X,1,3)_"1001" S Y=APCLFYB D DD^%DT S APCLFYBY=Y
 K X,X1,X2,Y
 S APCLJ=0
 I APCLFS="F" S X=0 F  S X=$O(APCLSU(X)) Q:X'=+X  S ^XTMP("APCLACC SU",APCLJOB,APCLBT,X)=""
 I APCLFS="F" G PAT
LOC S X=0 F  S X=$O(^AUTTLOC(X)) Q:X'=+X  I $P(^AUTTLOC(X,0),U,5),$D(APCLSU($P(^AUTTLOC(X,0),U,5))) S ^XTMP("APCLACC SU",APCLJOB,APCLBT,X)=""
PAT S APCLDFN=0 F I=0:0 S APCLDFN=$O(^AUPNPAT(APCLDFN)) Q:APCLDFN'=+APCLDFN  D C1
 K APCLDFN,APCLV,APCLFYBI,APCLFYEI,APCLGOTA
 S APCLET=$H
 Q
C1 ;
 Q:'$D(^DPT(APCLDFN,0))
 Q:$P(^DPT(APCLDFN,0),U,19)]""
 Q:$$DEMO^APCLUTL(APCLDFN,$G(APCLDEMO))
 I '$D(^AUPNPAT(APCLDFN,11)),APCLIND=0 S APCLTRI="NO TRIBE ENTERED" G C11
 Q:'$D(^AUPNPAT(APCLDFN,11))
C1A I $P(^AUPNPAT(APCLDFN,11),U,8)="",APCLIND=0 S APCLTRI="NO TRIBE ENTERED" G C11
 Q:$P(^AUPNPAT(APCLDFN,11),U,8)=""
 S APCLTRI=$P(^AUPNPAT(APCLDFN,11),U,8)
 Q:'$D(^AUTTTRI(APCLTRI))
 S APCLTRIC=$P(^AUTTTRI(APCLTRI,0),U,2)
 I APCLIND=1 Q:'(+APCLTRIC&(APCLTRIC<969!(APCLTRIC=997)!(APCLTRIC=999)))
 S APCLTRI=$P(^AUTTTRI(APCLTRI,0),U)
C11 S (APCLJ,APCLSVJ)=0 F J=0:0 S APCLJ=$O(^AUPNPAT(APCLDFN,51,APCLJ)) Q:APCLJ'=+APCLJ  S APCLSVJ=APCLJ
 I 'APCLSVJ,APCLSSUR=0 S APCLCOMN="NO COMMUNITY ENTERED *",APCLSUR="NO SU OF RESIDENCE" G HRN
 Q:'APCLSVJ
 S APCLCOMM=+$P(^AUPNPAT(APCLDFN,51,APCLSVJ,0),U,3) I 'APCLCOMM,APCLSSUR=0 S APCLCOMN="NO COMMUNITY ENTERED *",APCLSUR="NO SU OF RESIDENCE" G HRN
 Q:'APCLCOMM
 Q:'$D(^AUTTCOM(APCLCOMM,0))
 S APCLCOMN=$P(^AUTTCOM(APCLCOMM,0),U)
 I '$P(^AUTTCOM(APCLCOMM,0),U,5),APCLSSUR=0 S APCLCOMN=APCLCOMN_" *" G SETSUR
 I '$P(^AUTTCOM(APCLCOMM,0),U,5),APCLSSUR Q  ;no su and want only people living in that service unit
 I '$D(APCLSUF($P(^AUTTCOM(APCLCOMM,0),U,5))),APCLSSUR=0 S APCLCOMN=APCLCOMN_" *" G SETSUR
 Q:'$D(APCLSUF($P(^AUTTCOM(APCLCOMM,0),U,5)))
SETSUR S APCLSUR=$P(^AUTTCOM(APCLCOMM,0),U,5)
 I APCLSUR="" S APCLSUR="NO SU OF RESIDENCE" G HRN
 S APCLSUR=$P(^AUTTSU(APCLSUR,0),U)
HRN S (APCLGOT1,APCLHRN)=0 F J=0:0 S APCLHRN=$O(^AUPNPAT(APCLDFN,41,APCLHRN)) Q:APCLHRN'=+APCLHRN!(APCLGOT1)  D C2
 Q
C2 I $D(^XTMP("APCLACC SU",APCLJOB,APCLBT,$P(^AUPNPAT(APCLDFN,41,APCLHRN,0),U))) S APCLGOT1=1 D C3
 Q
C3 I $D(^DPT(APCLDFN,.35)),$P(^(.35),U)]"",APCLRPTT'="T" S ^(@APCLMIN)=$S($D(^XTMP("APCLACC",APCLJOB,APCLBT,@APCLMAJ,@APCLMIN)):(+^(@APCLMIN)+0)_U_$P(^(@APCLMIN),U,2),1:"0^0") G VISITS
C3ND I APCLRPTT'="T" S ^(@APCLMIN)=$S($D(^XTMP("APCLACC",APCLJOB,APCLBT,@APCLMAJ,@APCLMIN)):(+^(@APCLMIN)+1)_U_$P(^(@APCLMIN),U,2),1:"1^0")
VISITS ;
 S APCLFYBI=9999999-APCLFYB,APCLFYEI=9999999-APCLFYE
 K APCLGOTA,APCLSKIP
 S APCLV=0 F  S APCLV=$O(^AUPNVSIT("AA",APCLDFN,APCLV)) Q:APCLV'=+APCLV!($D(APCLGOTA))!($P(APCLV,".")>APCLFYBI)  S APCLVD=$P(APCLV,".") D PROC
 Q
PROC ;
 S APCLVDFN=0 F  S APCLVDFN=$O(^AUPNVSIT("AA",APCLDFN,APCLV,APCLVDFN)) Q:APCLVDFN'=+APCLVDFN  D ACTIVE
 Q
ACTIVE ;determine if patient was seen in FYs
 ;home clinic, telephone and employee health clinics ignored
 Q:$D(APCLGOTA)
 Q:APCLVD>APCLFYBI
 Q:APCLVD<APCLFYEI
 Q:$P(^AUPNVSIT(APCLVDFN,0),U,11)
 Q:'$P(^AUPNVSIT(APCLVDFN,0),U,9)
 Q:"DXECT"[$P(^AUPNVSIT(APCLVDFN,0),U,7)
 S %=$$CLINIC^APCLV(APCLVDFN,"C") I %=11!(%=68)!(%=51) Q
 ;Q:"V"[$P(^AUPNVSIT(APCLVDFN,0),U,3)  ;LAB/TUCSON COMMENTED OUT FOR VA
 Q:'$D(^AUPNVPOV("AD",APCLVDFN))
 Q:'$D(^AUPNVPRV("AD",APCLVDFN))
 S APCLGOTA="" I APCLRPTT'="T" S $P(^XTMP("APCLACC",APCLJOB,APCLBT,@APCLMAJ,@APCLMIN),U,2)=$P(^XTMP("APCLACC",APCLJOB,APCLBT,@APCLMAJ,@APCLMIN),U,2)+1
 I APCLRPTT="T" S ^XTMP("APCLACC",APCLJOB,APCLBT,"TEMPLATE PATIENTS",APCLDFN)=""
 Q
 ;
 ;