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

CIMGAGP2.m

Go to the documentation of this file.
CIMGAGP2 ; CMI/TUCSON/LAB - aberdeen area GPRA ;   [ 03/15/00  8:38 AM ]
 ;;1.0;ABERDEEN GPRA REPORT;;JAN 22, 2000
 ;
 ;
IND44 ;
 G:'CIMDMPAT IND55
 S V=$$LDL(DFN,CIMEDATE)
 I V]"" D S(CIMRPT,$S(CIMTIME:19,1:20),1,1)
 I $D(CIMLIST(5)),CIMTIME S ^XTMP("CIMGAGP",CIMGJ,CIMGH,"LIST",5,$S($P($G(^AUPNPAT(DFN,11)),U,18)]"":$P(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$P(^DPT(DFN,0),U,2),CIMAGE,DFN)=V
IND55 ;
 G:'CIMDMPAT IND66
 S V=$$PROTEIN(DFN,CIMEDATE)
 I V]"" D S(CIMRPT,$S(CIMTIME:19,1:20),2,1)
 I $D(CIMLIST(6)),CIMTIME S ^XTMP("CIMGAGP",CIMGJ,CIMGH,"LIST",6,$S($P($G(^AUPNPAT(DFN,11)),U,18)]"":$P(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$P(^DPT(DFN,0),U,2),CIMAGE,DFN)=V
IND66 ;WH ANNUAL PAP
 S CIMAGE=$$AGE^AUPNPAT(DFN,CIMBDATE) ;recalc age at beginning of time frame
 I $P(^DPT(DFN,0),U,2)="F",CIMAGE>17 D
 .D S(CIMRPT,$S(CIMTIME:19,1:20),3,1) ;wh denom pap
 .S V=$$PAP(DFN,CIMEDATE)
 .I V["Yes" D S(CIMRPT,$S(CIMTIME:19,1:20),4,1)
 .I $D(CIMLIST(7)),CIMTIME S ^XTMP("CIMGAGP",CIMGJ,CIMGH,"LIST",7,$S($P($G(^AUPNPAT(DFN,11)),U,18)]"":$P(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$P(^DPT(DFN,0),U,2),CIMAGE,DFN)=V
 .Q
IND77 ;WH MAMMOGRAM
 S CIMAGE=$$AGE^AUPNPAT(DFN,CIMBDATE) ;recalc age at beginning of time frame
 I $P(^DPT(DFN,0),U,2)="F",CIMAGE>39,CIMAGE<70 D
 .D S(CIMRPT,$S(CIMTIME:19,1:20),5,1) ;wh denom pap
 .S V=$$MAMMOG(DFN,CIMEDATE)
 .I V["Yes" D S(CIMRPT,$S(CIMTIME:19,1:20),6,1)
 .I $D(CIMLIST(8)),CIMTIME S ^XTMP("CIMGAGP",CIMGJ,CIMGH,"LIST",8,$S($P($G(^AUPNPAT(DFN,11)),U,18)]"":$P(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$P(^DPT(DFN,0),U,2),CIMAGE,DFN)=V
 .Q
IND88 ;
 K CIMP
 ;calculate age in months at beginning of time frame
 S CIMAMON=$$MON(DFN,CIMBDATE,CIMQTR)
 I CIMAMON D
 .D S(CIMRPT,$S(CIMTIME:19,1:20),7,1)
 .S CIMP=$$WCV(DFN)
 .I CIMP>3 D S(CIMRPT,$S(CIMTIME:19,1:20),8,1)
 .I $D(CIMLIST(9)),CIMTIME S ^XTMP("CIMGAGP",CIMGJ,CIMGH,"LIST",9,$S($P($G(^AUPNPAT(DFN,11)),U,18)]"":$P(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$P(^DPT(DFN,0),U,2),CIMAGE,DFN)=CIMP_" well child visits"
IND1112 ;dental
 S V=$$DENT(DFN,CIMEDATE)
 I V]"" D S(CIMRPT,$S(CIMTIME:19,1:20),9,1) D
 .I $D(CIMLIST(10)),CIMTIME S ^XTMP("CIMGAGP",CIMGJ,CIMGH,"LIST",10,$S($P($G(^AUPNPAT(DFN,11)),U,18)]"":$P(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$P(^DPT(DFN,0),U,2),CIMAGE,DFN)=V
IND1213 ;
 S CIMAGE=$$AGE^AUPNPAT(DFN,CIMBDATE)
 I CIMAGE=6!(CIMAGE=7)!(CIMAGE=8) D
 .D S(CIMRPT,$S(CIMTIME:19,1:20),10,1) ;denom
 .S V=$$SEAL(DFN,CIMEDATE)
 .I V]"" D S(CIMRPT,$S(CIMTIME:19,1:20),11,1) I $D(CIMLIST(11)),CIMTIME S ^XTMP("CIMGAGP",CIMGJ,CIMGH,"LIST",11,$S($P($G(^AUPNPAT(DFN,11)),U,18)]"":$P(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$P(^DPT(DFN,0),U,2),CIMAGE,DFN)=V
 I CIMAGE=14!(CIMAGE=15) D
 .D S(CIMRPT,$S(CIMTIME:19,1:20),27,1) ;denom
 .S V=$$SEAL(DFN,CIMEDATE)
 .I V]"" D S(CIMRPT,$S(CIMTIME:19,1:20),28,1) I $D(CIMLIST(11)),CIMTIME S ^XTMP("CIMGAGP",CIMGJ,CIMGH,"LIST",11,$S($P($G(^AUPNPAT(DFN,11)),U,18)]"":$P(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$P(^DPT(DFN,0),U,2),CIMAGE,DFN)=V
IND1820 ;immunizations
 I $$AGE^AUPNPAT(DFN,CIMEDATE)=2 D
 .D S(CIMRPT,$S(CIMTIME:19,1:20),12,1)
 .S CIMGDAT=$P(^DPT(DFN,0),U,3)+20000
 .S X=$$KIDS^CIMGAGPR(DFN,CIMGDAT)
 .I X=1 D S(CIMRPT,$S(CIMTIME:19,1:20),13,1)
 .I X=2 S V=^TMP("CIMGAGPR",$J,"CHILD",$P(^DPT(DFN,0),U),DFN,"NEEDS")
 .I X=1 S V="UP TO DATE"
 .I $D(CIMLIST(12)),CIMTIME S ^XTMP("CIMGAGP",CIMGJ,CIMGH,"LIST",12,$S($P($G(^AUPNPAT(DFN,11)),U,18)]"":$P(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$P(^DPT(DFN,0),U,2),CIMAGE,DFN)=V
 I $$MONAGE(DFN,CIMEDATE)>26&($$MONAGE(DFN,CIMEDATE)<40) D
 .D S(CIMRPT,$S(CIMTIME:22,1:23),12,1)
 .S CIMGDAT=$$FMADD^XLFDT($P(^DPT(DFN,0),U,3),(27*30.5))
 .S X=$$KIDS^CIMGAGPR(DFN,CIMGDAT)
 .I X=1 D S(CIMRPT,$S(CIMTIME:22,1:23),13,1)
IND2023 ;obesity
 D IND2023^CIMGAGP4
 D ^CIMGAGP3
 Q
S(R,N,P,V) ;
 I 'R Q
 S $P(^CIMAGP(R,N),U,P)=$P($G(^CIMAGP(R,N)),U,P)+V
 Q
 ;
WCPV(V) ;
 I '$G(V) Q ""
 NEW X,I,G S (X,G)=0 F  S X=$O(^AUPNVPOV("AD",V,X)) Q:X'=+X!(G)  S I=$P(^AUPNVPOV(X,0),U),I=$P(^ICD9(I,0),U) I I="V20.1"!(I="V20.2") S G=1
 Q G
WCV(P) ;
 ;return # of well child visits between dob and 27 month birthday
 NEW C S C=0
 I '$D(^AUPNVSIT("AA",P)) Q C
 NEW B S B=$P(^DPT(P,0),U,3)
 I B="" Q C
 NEW X,E S E=$$FMADD^XLFDT(B,(27*30.5))
 S X=0 F  S X=$O(^AUPNVSIT("AC",P,X)) Q:X'=+X  S D=$P($P(^AUPNVSIT(X,0),U),".") I D<E,$$CLINIC^APCLV(X,"C")=24!($$CLINIC^APCLV(X,"C")=27)!($$CLINIC^APCLV(X,"C")=57)!($$WCPV(X)) S C=C+1
 Q C
DNKA(V) ;is this a DNKA visit?
 I '$G(V) Q ""
 NEW D,N S D=$$PRIMPOV^APCLV(V,"C")
 I D=".0860" Q 1
 S N=$$PRIMPOV^APCLV(V,"N")
 I $E(D)="V",N["DNKA" Q 1
 I $E(D)="V",N["DID NOT KEEP APPOINTMENT" Q 1
 I $E(D)="V",N["DID NOT KEEP APPT" Q 1
 Q 0
MONAGE(P,D) ;
 I '$G(P) Q ""
 I '$D(^DPT(P,0)) Q ""
 NEW % S %=$$FMDIFF^XLFDT(D,$P(^DPT(P,0),U,3))
 Q %\30.5
MON(P,D,Q) ;
 I $P(^DPT(P,0),U,3)="" Q ""
 NEW %
 S %=$$FMDIFF^XLFDT(D,$P(^DPT(P,0),U,3))
 S %=%\30
 I 'Q,%>14,%<28 Q 1
 I Q,%>23,%<28 Q 1
 Q 0
 ;
PAP(P,EDATE) ;
 NEW CIM,%,E,BDATE S BDATE=$$FMADD^XLFDT(EDATE,-(365*3)),%=P_"^LAST LAB PAP SMEAR;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"CIM(")
 I $D(CIM(1)) Q "Yes  "_$$FMTE^XLFDT($P(CIM(1),U))
 K CIM S %=P_"^LAST DX V76.2;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"CIM(")
 I $D(CIM(1)) Q "Yes  "_$$FMTE^XLFDT($P(CIM(1),U))
 K CIM S %=P_"^LAST PROCEDURE 91.46;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"CIM(")
 I $D(CIM(1)) Q "Yes  "_$$FMTE^XLFDT($P(CIM(1),U))
 Q "No"
MAMMOG(P,EDATE) ;
 NEW CIM,%,E,BDATE S BDATE=$$FMADD^XLFDT(EDATE,-365)
 I '$G(P) Q ""
 NEW LMAM S LMAM=""
 NEW CIM S %=P_"^LAST RAD MAMMOGRAM BILAT;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"CIM(")
 I $D(CIM(1)) D
 .Q:LMAM>$P(CIM(1),U)
 .S LMAM=$P(CIM(1),U)
 K CIM S %=P_"^LAST RAD SCREENING MAMMOGRAM;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"CIM(")
 I $D(CIM(1)) D
 .Q:LMAM>$P(CIM(1),U)
 .S LMAM=$P(CIM(1),U)
 K CIM S %=P_"^LAST DX V76.11;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"CIM(")
 I $D(CIM(1)) D
 .Q:LMAM>$P(CIM(1),U)
 .S LMAM=$P(CIM(1),U)
 K CIM S %=P_"^LAST DX V76.12;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"CIM(")
 I $D(CIM(1)) D
 .Q:LMAM>$P(CIM(1),U)
 .S LMAM=$P(CIM(1),U)
 K CIM S %=P_"^LAST PROCEDURE 87.37;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"CIM(")
 I $D(CIM(1)) D
 .Q:LMAM>$P(CIM(1),U)
 .S LMAM=$P(CIM(1),U)
 Q $S(LMAM]"":"Yes  "_$$FMTE^XLFDT(LMAM),1:"No")
 ;
DENT(P,EDATE) ;
 NEW CIM,X,%,E,R,V,BDATE
 K CIM
 S BDATE=$$FMADD^XLFDT(EDATE,-365)
 S %=P_"^LAST ADA 0000;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"CIM(")
 I $D(CIM(1)) Q $$FMTE^XLFDT($P(CIM(1),U))
 ;look for dental clinic or dental provider visit date
 K CIM
 S %=P_"^ALL VISITS;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"CIM(")
 NEW X,Y S X=0,Y="" F  S X=$O(CIM(X)) Q:X'=+X!(Y]"")  I $$CLINIC^APCLV($P(CIM(X),U,5),"C")=56,'$$DNKA($P(CIM(X),U,5)) S Y=$$FMTE^XLFDT($P(CIM(X),U))
 I Y]"" Q Y
 S X=0,Y="" F  S X=$O(CIM(X)) Q:X'=+X!(Y]"")  I $$PRIMPROV^APCLV($P(CIM(X),U,5),"D")=52,'$$DNKA($P(CIM(X),U,5)) S Y=$$FMTE^XLFDT($P(CIM(X),U))
 Q Y
SEAL(P,EDATE) ;
 NEW CIM,X,%,E,R,V
 K CIM
 S %=P_"^LAST ADA 1351;DURING "_$$FMTE^XLFDT($P(^DPT(P,0),U,3))_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"CIM(")
 I '$D(CIM(1)) Q ""
 Q $$FMTE^XLFDT($P(CIM(1),U))
LDL(P,EDATE) ;
 NEW CIM,X,%,E,R,V,BDATE
 K CIM
 S BDATE=$$FMADD^XLFDT(EDATE,-365)
 S %=P_"^LAST LAB [DM AUDIT LIPID PROFILE TAX;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"CIM(")
 I $D(CIM(1)) Q $P(^AUPNVLAB(+$P(CIM(1),U,4),0),U,4)_" mg/dl "_$$FMTE^XLFDT($P(CIM(1),U),5)
 S %=P_"^LAST LAB [DM AUDIT LDL CHOLESTEROL TAX;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"CIM(")
 I $D(CIM(1)) Q $P(^AUPNVLAB(+$P(CIM(1),U,4),0),U,4)_" mg/dl "_$$FMTE^XLFDT($P(CIM(1),U),5)
 S %=P_"^LAST LAB [DM AUDIT TRIGLYCERIDE TAX;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"CIM(")
 I $D(CIM(1)) Q $P(^AUPNVLAB(+$P(CIM(1),U,4),0),U,4)_" mg/dl "_$$FMTE^XLFDT($P(CIM(1),U),5)
 Q ""
PROTEIN(P,EDATE) ;EP
 NEW CIM,X,%,E,R,V,BDATE
 K CIM
 S BDATE=$$FMADD^XLFDT(EDATE,-365)
 S %=P_"^LAST LAB [DM AUDIT URINE PROTEIN TAX;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"CIM(")
 I '$D(CIM(1)) Q ""
 S %=$P(^AUPNVLAB(+$P(CIM(1),U,4),0),U,4)
 Q %_" "_$$FMTE^XLFDT($P(CIM(1),U),"5")