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

APCLYV51.m

Go to the documentation of this file.
APCLYV51 ; IHS/CMI/LAB - INPATIENT VISITS (CALC) ;
 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
 ;
CALC ;find visits by date then store by patient name
 S APCLBT=$H
 D XTMP^APCLOSUT("APCLYV5","PCC - HOSP DISCH LISTING")
 ;
 S APCLDDT=APCLBD-.0001 G HOSP:APCLSRT="D"
 S APCLVDT=APCLDDT
VST S APCLVDT=$O(^AUPNVSIT("B",APCLVDT))
 G NEXT:APCLVDT="",NEXT:APCLVDT>(APCLED+.2359) S APCLVDFN=0
VST1 S APCLVDFN=$O(^AUPNVSIT("B",APCLVDT,APCLVDFN)) G VST:APCLVDFN=""
 S APCLDDT="A"
 G VST1:'$D(^AUPNVINP("AD",APCLVDFN))
 G VST1:$$DEMO^APCLUTL($P(^AUPNVSIT(APCLVDFN,0),U,5),$G(APCLDEMO))
 S APCLIDFN=$O(^AUPNVINP("AD",APCLVDFN,0)),APCLSTR1=^AUPNVINP(APCLIDFN,0)
 S APCLDDT=$P(APCLSTR1,U) D SCREENS G VST1
 ;
HOSP ;
 S APCLDDT=$O(^AUPNVINP("B",APCLDDT))
 G NEXT:APCLDDT="",NEXT:APCLDDT>(APCLED+.2359) S APCLIDFN=0
HOSP1 S APCLIDFN=$O(^AUPNVINP("B",APCLDDT,APCLIDFN)) G HOSP:APCLIDFN=""
 G HOSP1:'$D(^AUPNVINP(APCLIDFN,0)) S APCLSTR1=^(0)
 S APCLVDFN=$P(APCLSTR1,U,3) D SCREENS G HOSP1
 ;
SCREENS ;SCREEN OUT VISITS NOT ASKED FOR
 Q:'$D(^AUPNVSIT(APCLVDFN,0))  S APCLSTR=^(0)
 Q:$P(APCLSTR,U,7)'="H"
 Q:$P(APCLSTR,"^",11)  ;screen out deleted visits
 Q:$P(APCLSTR,"^",6)'=APCLLOC  ;screen out other facilities
 I APCLSRT="A",APCLSV>0,$P(APCLSTR1,U,4)'=APCLSV
 I APCLSRT="D",APCLSV>0,$P(APCLSTR1,U,5)'=APCLSV Q
 S APCLFLG=$S(APCLICD=1:1,1:0) D POV:APCLICD=2,PRC:APCLICD=3,PROV:APCLICD=4
 Q:'APCLFLG
 ;
 S DFN=$P(APCLSTR,U,5)
 I $G(APCLLOC)]"",$D(^AUPNPAT(DFN,41,APCLLOC,0)) S APCLNAME=$P(^AUPNPAT(DFN,41,APCLLOC,0),U,2) G L
 S APCLNAME=$S($D(^AUPNPAT(DFN,41,DUZ(2),0)):$P(^(0),U,2),1:"NONE")
L S:APCLSRT="D" APCLVDT=$P(APCLSTR,U)
 S ^XTMP("APCLYV5",APCLJOB,APCLBTH,"VISITS",APCLNAME,DFN,APCLDDT)=APCLVDFN_"^"_APCLVDT Q
 ;
NEXT ;
 S APCLET=$H
 Q
 ;
 ;
PROV ;does visit have Provider selection?
 S APCLPROV=0
 ;
PROV1 S APCLPROV=$O(^AUPNVPRV("AD",APCLVDFN,APCLPROV)) Q:APCLPROV=""
 G PROV1:'$D(^AUPNVPRV(APCLPROV,0)) S X=$P(^(0),"^")
 G PROV1:'$D(^XTMP("APCLYV5",APCLJOB,APCLBTH,"ICD",X))
 S APCLFLG=1
 Q
POV ;does visit have POV within selected range?
 S APCLPV=0
PV1 S APCLPV=$O(^AUPNVPOV("AD",APCLVDFN,APCLPV)) Q:APCLPV=""
 G PV1:'$D(^AUPNVPOV(APCLPV,0)) S X=$P(^(0),"^") G PV1:'$D(^ICD9(X,0))
 G PV1:'$D(^XTMP("APCLYV5",APCLJOB,APCLBTH,"ICD",X))
 S APCLFLG=1
 Q
 ;
PRC ;does visit have procedure(s) within selected range?
 S APCLPRC=0
PRC1 S APCLPRC=$O(^AUPNVPRC("AD",APCLVDFN,APCLPRC)) Q:APCLPRC=""
 G PRC1:'$D(^AUPNVPRC(APCLPRC,0)) S X=$P(^(0),"^")
 G PRC1:'$D(^ICD0(X,0))
 I $D(^XTMP("APCLYV5",APCLJOB,APCLBTH,"ICD",X)) S APCLFLG=1 Q
 G PRC1