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

APCL8A1.m

Go to the documentation of this file.
APCL8A1 ; IHS/CMI/LAB - Process APC 8A report ;
 ;;2.0;IHS PCC SUITE;**11**;MAY 14, 2009;Build 58
 ;
 ;cmi/anch/maw 9/7/2007 code set verisioning in CHKPV
 ;
START ;
 S APCLBT=$H,APCLJOB=$J
 K ^XTMP("APCL8A",APCLJOB,APCLBT)
 D XTMP^APCLOSUT("APCL8A","PCC VISITS NOT EXPORTED")
 S X1=APCLFY,X2=-1 D C^%DTC S APCLSD=X S X1=APCLFY,X2=365 D C^%DTC S APCLFYE=$E(X,1,3)_"0930"
V ; Run by visit date
 S APCLGRAN=0
 S APCLSD=APCLSD_".9999" F  S APCLSD=$O(^AUPNVSIT("B",APCLSD)) Q:APCLSD=""!((APCLSD\1)>APCLFYE)  D V1
XIT ;
 D EOJ
 S APCLET=$H
 Q
V1 ;
 S APCLVDFN="" F  S APCLVDFN=$O(^AUPNVSIT("B",APCLSD,APCLVDFN)) Q:APCLVDFN'=+APCLVDFN  I $D(^AUPNVSIT(APCLVDFN,0)) S APCLVREC=^(0) D PROC,EOJ
 Q
PROC ;
 ;K APCLSKIP
 ;Q:'$P(APCLVREC,U,9)
 ;Q:$P(APCLVREC,U,11)
 ;Q:"AORS"'[$P(APCLVREC,U,7)
 ;Q:$D(^APCLCNTL(4,11,"B",$P(APCLVREC,U,3)))
 I APCLLOC]"",APCLLOC'=$P(APCLVREC,U,6) Q
 S DFN=$P(APCLVREC,U,5)
 Q:$$DEMO^APCLUTL(DFN,$G(APCLDEMO))  ;IHS/CMI/LAB - all demo patients
 ;Q:'$D(^AUPNVPOV("AD",APCLVDFN))
 ;Q:'$D(^AUPNVPRV("AD",APCLVDFN))
 S APCLVLOC=$P(APCLVREC,U,6)
 Q:'$D(^DIC(4,APCLVLOC))
 Q:'$D(^AUTTLOC(APCLVLOC))
 ;S APCLCLIN=$P(APCLVREC,U,8) I APCLCLIN="" S APCLCLIN=25 G PROC1
CHKCL ;
 ;S APCLX=$S(APCLCLIN="":"",$D(^DIC(40.7,APCLCLIN,0)):$P(^DIC(40.7,APCLCLIN,0),U,2),1:"")
 ;Q:APCLX=""
 ;Q:$D(^APCLCNTL(2,11,"B",APCLX))
 ;I APCLX=56,'$D(^AUPNVMED("AD",APCLVDFN)) Q
PROC1 ;
 ;S (APCL1,APCL2)=0 F  S APCL2=$O(^AUPNVPRV("AD",APCLVDFN,APCL2)) Q:APCL2=""  I $P(^AUPNVPRV(APCL2,0),U,4)="P" S APCL1=APCL1+1,APCLAP=$P(^(0),U)
 ;Q:APCL1=0
 ;Q:APCL1>1
 ;S APCLDISC="" D CHKDISC
 ;Q:$D(APCLSKIP)
 ;S APCLPPOV=$O(^AUPNVPOV("AD",APCLVDFN,""))
 Q:'$$APCWL^APCLV(APCLVDFN)
 S APCLMOS=+$E(APCLSD,4,5)
 S APCLGRAN=APCLGRAN+1
 I $P($G(^AUPNVSIT(APCLVDFN,11)),U,6)="" D
 .S ^("NO EXPORT")=$S($D(^XTMP("APCL8A",APCLJOB,APCLBT,"NO EXPORT")):^("NO EXPORT")+1,1:1)
 .I $D(^AUPNVSIT("ADWO",$P(APCLVREC,U,2),APCLVDFN)) S ^("IN XREF")=$S($D(^XTMP("APCL8A",APCLJOB,APCLBT,"IN XREF")):^("IN XREF")+1,1:1) Q
 .I $D(^AUPNVSIT("ADWO",$P($P(APCLVREC,U,13),"."),APCLVDFN)) S ^("IN XREF")=$S($D(^XTMP("APCL8A",APCLJOB,APCLBT,"IN XREF")):^("IN XREF")+1,1:1) Q
 .D ERRORCK
 Q
EOJ K APCLVLOC,APCLVREC,APCLCLIN,APCLSKIP,APCL1,APCL2,APCLAP,APCLDISC,APCLPPOV,APCLDPTR,APCLLOCC,APCLX
 K X,X1,X2
 Q
ERRORCK ;
 S DFN=$P(APCLVREC,U,5)
 I $P(^DPT(DFN,0),U,2)="" S ^XTMP("APCL8A",APCLJOB,APCLBT,"VISITS",APCLVDFN)="Missing SEX of Patient" Q
 I $P(^DPT(DFN,0),U,3)="" S ^XTMP("APCL8A",APCLJOB,APCLBT,"VISITS",APCLVDFN)="Missing DOB of Patient" Q
COMM ;
 S APCLCOMX=0,APCLCOMP="" F  S APCLCOMX=$O(^AUPNPAT(DFN,51,APCLCOMX)) Q:APCLCOMX'=+APCLCOMX  S APCLCOMP=APCLCOMX
 I APCLCOMP="" S ^XTMP("APCL8A",APCLJOB,APCLBT,"VISITS",APCLVDFN)="No Community of Residence" Q
 S APCLCOMP=$P(^AUPNPAT(DFN,51,APCLCOMP,0),U,3) I APCLCOMP="" S ^XTMP("APCL8A",APCLJOB,APCLBT,"VISITS",APCLVDFN)="No Community of Residence" Q
 I '$D(^AUTTCOM(APCLCOMP,0)) S ^XTMP("APCL8A",APCLJOB,APCLBT,"VISITS",APCLVDFN)="Bad Community Pointer" Q
 I APCLCOMP]"",$P(^AUTTCOM(APCLCOMP,0),U,8)="" S ^XTMP("APCL8A",APCLJOB,APCLBT,"VISITS",APCLVDFN)="Community in Table Missing code" Q
TRIBE ;
 I '$D(^AUPNPAT(DFN,11)) S ^XTMP("APCL8A",APCLJOB,APCLBT,"VISITS",APCLVDFN)="No Tribe of Membership" Q
 S X=$P(^AUPNPAT(DFN,11),U,8) I X="" S ^XTMP("APCL8A",APCLJOB,APCLBT,"VISITS",APCLVDFN)="No Tribe of Membership" Q
 I $P(^AUTTTRI(X,0),U,4)="Y" S ^XTMP("APCL8A",APCLJOB,APCLBT,"VISITS",APCLVDFN)="Old/Unused Tribe Code" Q
 I $P(^AUTTTRI(X,0),U,2)="" S ^XTMP("APCL8A",APCLJOB,APCLBT,"VISITS",APCLVDFN)="Tribe Code Missing" Q
 D CHKPV
 Q:$D(^XTMP("APCL8A",APCLJOB,APCLBT,"VISITS",APCLVDFN))
 S ^XTMP("APCL8A",APCLJOB,APCLBT,"VISITS",APCLVDFN)="UNKNOWN WHY NOT EXPORTED"
 Q
CHKPV ;
 NEW X,E,P,I
 ;S X=0 F  S X=$O(^AUPNVPOV("AD",APCLVDFN,X)) Q:X'=+X  S P=$P(^AUPNVPOV(X,0),U),I=$P(^ICD9(P,0),U) D  ;cmi/anch/maw 9/7/2007 orig line
 ;cmi/anch/maw 9/7/2007 mods for code set versioning
 N APCLVDT
 S APCLVDT=+$P($G(^AUPNVSIT(APCLVDFN,0)),".")
 ;cmi/anch/maw 9/7/2007 end of mods
 S X=0 F  S X=$O(^AUPNVPOV("AD",APCLVDFN,X)) Q:X'=+X  S P=$$VALI^XBDIQ1(9000010.07,X,.01),I=$$VAL^XBDIQ1(9000010.07,X,.01) D
 .I $$CAUSE^APCDAPOV(P,$$IMP^AUPNSICD($$VD^APCLV(APCLVDFN))) S ^XTMP("APCL8A",APCLJOB,APCLBT,"VISITS",APCLVDFN)="Cause of Injury used a diagnosis" Q
 .I I=.9999!(I="ZZZ.999") S ^XTMP("APCL8A",APCLJOB,APCLBT,"VISITS",APCLVDFN)="Uncoded DX code used as POV" Q
 .;I $P(^ICD9(P,0),U,9)]"" S ^XTMP("APCL8A",APCLJOB,APCLBT,"VISITS",APCLVDFN)="Inactive ICD code used" Q
 .;I $L($P(I,".",2))>2 S ^XTMP("APCL8A",APCLJOB,APCLBT,"VISITS",APCLVDFN)="Invalid 6 digit ICD code used" Q
 .Q
 Q
CHKDISC ;
 I $P(^DD(9000010.06,.01,0),U,2)[6 G CHKDISC6 ;if not converted to 200 check file 6
 I '$D(^VA(200,APCLAP)) S APCLSKIP=1 Q
 S APCLDPTR=$$PROVCLS^XBFUNC1(APCLAP,"I") I APCLDPTR=""!(APCLDPTR="UNKNOWN") S APCLDISC="???" Q
 S APCLDISC=$$PROVCLSC^XBFUNC1(APCLAP) I APCLDISC="UNKNOWN"!(APCLDISC="") S APCLSKIP=1 Q
 S APCLLOCC=$E($P(^AUTTLOC(APCLVLOC,0),U,10),5,6)
 I (APCLDISC=13!(APCLDISC=32))&((APCLLOCC>49)!(APCLLOCC'=+APCLLOCC)) S APCLSKIP=1
 Q
CHKDISC6 ;
 I '$D(^DIC(6,APCLAP)) S APCLSKIP=1 Q
 S APCLDPTR=$P(^DIC(6,APCLAP,0),U,4)
 I APCLDPTR="" S APCLDISC="??" Q
 I '$D(^DIC(7,APCLDPTR,9999999)) S APCLDISC="??" Q
 S APCLDISC=$P(^DIC(7,APCLDPTR,9999999),U) I APCLDISC="" S APCLSKIP=1 Q
 S APCLLOCC=$E($P(^AUTTLOC(APCLVLOC,0),U,10),5,6)
 I (APCLDISC=13!(APCLDISC=32))&((APCLLOCC>49)!(APCLLOCC'=+APCLLOCC)) S APCLSKIP=1
 Q