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

APCLDM1A.m

Go to the documentation of this file.
APCLDM1A ; IHS/CMI/LAB -CONTINUATION OF APCLDM1 FOR DM AUDIT DATA FETCHING ;
 ;;2.0;IHS PCC SUITE;**4**;MAY 14, 2009
 ;
EN ; - EP - from ^APCLDM1
 ;
 F APCLI=1:1 Q:$T(@APCLI)=""  K APCLX S APCLY="APCL(" D @APCLI K APCL
 Q
 ;
1 ;
WTTAKEN S APCLMEAS=$O(^AUTTMSR("B","WT","")) D TAKEN
 S ^TMP("APCL",$J,4)=APCLMEAS
 K APCLMEAS
 I APCLCUML S APCLGOT1=$S(^TMP("APCL",$J,4)["YES":1,1:0),APCLSUB=10 D CUML^APCLDM1
 Q
2 ;
LASTWT S APCLW="" S APCLX=APCLPD_"^LAST 24 MEAS WT" S APCLER=$$START1^APCLDF(APCLX,APCLY)
 S APCLV221=$O(^ICD9("BA","V22.1 ",""))
 F APCLN=1:1 Q:'$D(APCL(APCLN))!$D(^TMP("APCL",$J,5))  S APCLZ=$P(APCL(APCLN),U,5) S APCLD=0 F  S APCLD=$O(^AUPNVPOV("AD",APCLZ,APCLD)) Q:'APCLD!$D(^TMP("APCL",$J,5))  D
 . I $P(^AUPNVPOV(APCLD,0),U)'=APCLV221 S APCLW=$P(APCL(APCLN),U,2),^TMP("APCL",$J,5)=$P(APCL(APCLN),U,2)_" lbs",Y=$P(APCL(APCLN),U) D DD^%DT S ^TMP("APCL",$J,33)=Y
 .Q
 I '$D(^TMP("APCL",$J,5)) S ^(5)="NO WT AVAILABLE",^TMP("APCL",$J,33.1)="" I APCLCUML S APCLSUB=54,APCLGOT1=1 D CUML^APCLDM1 S APCLGOT1=0 S APCLSUB=48 D CUML^APCLDM1 S APCLSUB=49,APCLGOT1=0 D CUML^APCLDM1 G X2
 I '$G(APCLCUML) G X2
 S H=APCLHTKI I 'H S ^TMP("APCL",$J,33.1)="",APCLSUB=54,APCLGOT1=1 D CUML^APCLDM1 S APCLSUB=48,APCLGOT1=0 D CUML^APCLDM1 S APCLSUB=49,APCLGOT1=0 D CUML^APCLDM1 G X2
 S APCLW=APCLW*.4536,H=((H*.0254)*(H*.0254)),B=APCLW/H,^TMP("APCL",$J,33.1)=$J(B,4,1)
 I $$SEX^AUPNPAT(APCLPD)="M"&(B>31.0)!($$SEX^AUPNPAT(APCLPD)="F"&(B>32.2)) S APCLSUB=49,APCLGOT1=1 D CUML^APCLDM1 S APCLSUB=54,APCLGOT1=0 D CUML^APCLDM1 S APCLGOT1=1,APCLSUB=48 D CUML^APCLDM1 G X2
 I $$SEX^AUPNPAT(APCLPD)="M"&(B>27.7)!($$SEX^AUPNPAT(APCLPD)="F"&(B>27.2)) S APCLSUB=48,APCLGOT1=1 D CUML^APCLDM1 S APCLSUB=54,APCLGOT1=0 D CUML^APCLDM1 S APCLSUB=49,APCLGOT1=0 D CUML^APCLDM1 G X2
 ;I $E(APCLRWPT)="*" S APCLSUB=54,APCLGOT1=1 D CUML^APCLDM1 S APCLGOT1=0,APCLSUB=48 D CUML^APCLDM1 S APCLSUB=49 D CUML^APCLDM1 G X2
 ;I +APCLRWPT>154 S APCLSUB=49,APCLGOT1=1 D CUML^APCLDM1 S APCLGOT1=0,APCLSUB=48 D CUML^APCLDM1 S APCLSUB=54 D CUML^APCLDM1 G X2
 ;I +APCLRWPT>125 S APCLSUB=48,APCLGOT1=1 D CUML^APCLDM1 S APCLGOT1=0,APCLSUB=49 D CUML^APCLDM1 S APCLSUB=54 D CUML^APCLDM1 G X2
 F APCLSUB=48,49,54 S APCLGOT1=0 D CUML^APCLDM1
X2 ;
 K APCLSUB,APCLGOT1,APCLRWPT,APCLZ,APCLN,APCLD,APCLV221,APCLX
 Q
3 ;
BPTAKEN S APCLMEAS=$O(^AUTTMSR("B","BP","")) D TAKEN
 S ^TMP("APCL",$J,6)=APCLMEAS
 I APCLCUML S APCLGOT1=$S(^TMP("APCL",$J,6)["YES":1,1:0),APCLSUB=11 D CUML^APCLDM1
 K APCLMEAS
 Q
 ;
TAKEN ; Is BP or WT taken 75% of time during the last year's diabetic visits 
 S (APCLYES,APCLNTOT)=0 F APCLL=1:1:APCLTOT Q:'$D(^TMP("APCLDM DXVS",$J,APCLL))  D
 .S APCLVDFN=^TMP("APCLDM DXVS",$J,APCLL)
 .S APCLNTOT=APCLNTOT+1
 .S (APCLMDFN,APCLFOUN)=0 F  S APCLMDFN=$O(^AUPNVMSR("AD",APCLVDFN,APCLMDFN)) Q:'APCLMDFN!(APCLFOUN)  D
 ..Q:$P($G(^AUPNVMSR(APCLMDFN,2)),U,1)  ;entered in error
 ..I APCLMDFN,+^AUPNVMSR(APCLMDFN,0)=APCLMEAS S APCLYES=APCLYES+1,APCLFOUN=1 Q
 ..Q
 ;***
 I 'APCLNTOT S APCLMEAS="No DM visits (01,06,28 clinics only)" G TAKENX
 NEW V
 S V=(APCLYES/APCLNTOT)*100,V=$J(V,2,0)
 S APCLMEAS=$S(V<75:"NO",1:"YES")_" - "_V_"%"
 K APCLNTOT
TAKENX Q
 ;
4 ;
HTNDX ;
 D HTNPLDX I $D(APCL(1)) G X
 S X=APCLEDT,%DT="" D ^%DT S X1=$S(Y>DT:DT,1:Y) S APCLHTNE=Y,X2=1 D C^%DTC S APCLHTNE=($E(X,1,3)-5)_$E(X,4,7) S Y=APCLHTNE D DD^%DT S APCLHTNE=Y
 S APCLX=APCLPD_"^LAST DX [SURVEILLANCE HYPERTENSION;DURING "_APCLHTNE_"-"_APCLEDT S APCLER=$$START1^APCLDF(APCLX,APCLY) G:APCLER X S ^TMP("APCL",$J,7)=$S($D(APCL(1)):"YES",1:"NO")
X I APCLER S ^TMP("APCL",$J,7)="*** SCRIPT ERROR IN HTNDX^APCLDM1A.  CONTACT SITE MANAGER"
 K APCL
 Q
HTNPLDX ;see if htn on problem list
 S APCLX=APCLPD_"^PROBLEM [DM AUDIT PROBLEM HTN DIAGNOSES",APCLY="APCL(" S APCLER=$$START1^APCLDF(APCLX,APCLY) G:APCLER X I $D(APCL(1)) S ^TMP("APCL",$J,7)="YES"
 Q
5 ;
BPS ;
 S APCLERCO=$O(^DIC(40.7,"C",30,"")),APCLLL=0
 S APCLX=APCLPD_"^LAST 50 MEAS BP"_APCLDATE S APCLER=$$START1^APCLDF(APCLX,APCLY) F APCLL=1:1:20 Q:'$D(APCL(APCLL))  S APCLBP=$P($G(APCL(APCLL)),U,2)_$S($P($G(APCL(APCLL)),U,2)]"":" mm HG",1:"") D
 .Q:$P(^AUPNVSIT($P(APCL(APCLL),U,5),0),U,8)=APCLERCO
 .S APCLLL=APCLLL+1,^TMP("APCL",$J,8_"."_APCLLL)=APCLBP S Y=$P(APCL(APCLL),U,1) D DD^%DT S ^TMP("APCL",$J,34_"."_APCLLL)=Y
 I APCLCUML,$G(^TMP("APCL",$J,8.1))]"" S (APCLSYS,APCLDIA,APCLBPS)=0 F APCLL=1:1:3 Q:'$D(^TMP("APCL",$J,8_"."_APCLL))  S APCLBPS=APCLBPS+1,APCLSYS=APCLSYS+^(8_"."_APCLL),APCLDIA=APCLDIA+$P(^(8_"."_APCLL),"/",2)
CONTROL ;
 I '$G(APCLCUML) G X5
 I $G(^TMP("APCL",$J,8.3))="" S APCLGOT1=1,APCLSUB=61 D CUML^APCLDM1 D  G X5  ;if not at least 3 bps - undocumented
 .S APCLGOT1=0 F APCLSUB=12,13,14,60 D CUML^APCLDM1
 S APCLSYS=$J((APCLSYS/APCLBPS),0,0),APCLDIA=$J((APCLDIA/APCLBPS),0,0)
 I ^TMP("APCL",$J,7)="NO",APCLSYS<140,APCLDIA<90 S APCLGOT1=1,APCLSUB=12 D CUML^APCLDM1 D  G X5
 .S APCLGOT1=0 F APCLSUB=13,14,60,61 D CUML^APCLDM1
 I ^TMP("APCL",$J,7)="YES",APCLSYS<140,APCLDIA<90 S APCLGOT1=1,APCLSUB=13 D CUML^APCLDM1 D  G X5
 .S APCLGOT1=0 F APCLSUB=12,14,60,61 D CUML^APCLDM1
 I APCLSYS>159!(APCLDIA>94) S APCLGOT1=1,APCLSUB=60 D CUML^APCLDM1 D  G X5
 .S APCLGOT1=0 F APCLSUB=12,13,14,61 D CUML^APCLDM1
 I (APCLSYS>139&(APCLSYS<160))!(APCLDIA>89&(APCLDIA<95)) S APCLGOT1=1,APCLSUB=14 D CUML^APCLDM1 D  G X5
 .S APCLGOT1=0 F APCLSUB=12,13,60,61 D CUML^APCLDM1
X5 K APCLBP,APCLBPS,APCLSYS,APCLDIA,APCLHYP
 Q
6 ;
BSTAKEN ;
 D BSTAKEN^APCLDM7
 Q
 ;