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

APCLDM7.m

Go to the documentation of this file.
APCLDM7 ; IHS/CMI/LAB - BLOOD SUGAR TAKEN/LAST 3 ;
 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
 ;
 ;
BSTAKEN ;EP
 K APCLLVST,APCLLGLU
 K ^TMP("APCLDM FETCH",$J) S APCLX=APCLPD_"^ALL LAB [DM AUDIT GLUCOSE TESTS TAX"_APCLDATE,APCLY="^TMP(""APCLDM FETCH"",$J," S APCLER=$$START1^APCLDF(APCLX,APCLY)
 I APCLER W !,"*** SCRIPT ERROR IN DMGLUCOSE^APCLDM7.  CONTACT SITE MANAGER" G BSTAKENX
 F APCLL=1:1 Q:'$D(^TMP("APCLDM FETCH",$J,APCLL))  S APCLLVST($P(^TMP("APCLDM FETCH",$J,APCLL),U,5))=$P(^AUPNVLAB(+$P(^TMP("APCLDM FETCH",$J,APCLL),U,4),0),U)_U_^TMP("APCLDM FETCH",$J,APCLL)
 K APCL,^TMP("APCLDM FETCH",$J)
 K APCL S APCLY="APCL(",APCLX=APCLPD_"^LAST LAB [DM AUDIT HGB A1C TAX"_APCLDATE S APCLER=$$START1^APCLDF(APCLX,APCLY) S ^TMP("APCL",$J,32)=$S($D(APCL(1)):$P(APCL(1),U,2)_"%",1:"-")
 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
 .I $D(APCLLVST(APCLVDFN)) S APCLYES=APCLYES+1 ;***
 .Q
 I 'APCLNTOT S ^TMP("APCL",$J,9)="No DM visits (01,06,28 clinics only)" G BSTAKENC
 NEW V S V=(APCLYES/APCLNTOT)*100,V=$J(V,2,0)
 S ^TMP("APCL",$J,9)=$S(V<75:"NO",1:"YES")_" - "_V_"%"
BSTAKENC I APCLCUML S APCLGOT1=$S(^TMP("APCL",$J,9)["YES":1,1:0),APCLSUB=15 D CUML^APCLDM1
BSTAKENX K APCLNTOT
LAST3BS ;GET LAST THREE
 K APCLLGLU,APCLL3R
 S V=0 F  S V=$O(APCLLVST(V)) Q:V'=+V  D
 .I $P(^AUPNVSIT(V,0),U,8)]"",$P(^(0),U,8)=APCLERCO Q  ;don't count er visits in last 3
 .S APCLLGLU(9999999-$P(APCLLVST(V),U,2),$P($P(APCLLVST(V),U,5),";"))=$P(APCLLVST(V),U,4)_" - "_$S($P(^LAB(60,$P(APCLLVST(V),U),0),U)["FAST":"FASTING",1:"RANDOM")_" - "_$P(APCLLVST(V),U,3)
 S (APCLX,APCLY,APCLZ)=0 F  Q:APCLZ=3  S APCLX=$O(APCLLGLU(APCLX)) Q:APCLX=""  F  S APCLY=$O(APCLLGLU(APCLX,APCLY)) Q:'APCLY!(APCLZ=3)  D
 .S APCLZ=APCLZ+1,^TMP("APCL",$J,10_"."_APCLZ)=APCLLGLU(APCLX,APCLY),Y=(9999999-APCLX) D DD^%DT S ^TMP("APCL",$J,38_"."_APCLZ)=Y
 I APCLCUML D BSLEVEL
 K APCLLVST,APCLBEL,APCLLAB,APCLCOUN,APCLTYPE,APCLLGLU,APCLTEST,APCLYES,APCLX,APCLY,APCLZ
 Q
 ;
X7 K APCLLVST,APCLBEL,APCLLAB,APCLCOUN,APCLTYPE,APCLERCO,APCLL3R,APCLLGLU
 Q
BSLEVEL ;calculate bs control
 ;get last Hemoglobin A1C in time frame, if there is one,
 ;use it to calculate :
 ;    ---> acceptable <=7.5
 ;    ---> fair       7.6-10.0
 ;    ---> high       10.1-12.0
 ;    ---> very high  >12.0
 ;quit
 ;if no hgla1c get last 3 bs's - if not three put in undocumented
 ;take mean of 3
 K APCL S APCLY="APCL(",APCLX=APCLPD_"^LAST LAB [DM AUDIT HGB A1C TAX"_APCLDATE
 S APCLER=$$START1^APCLDF(APCLX,APCLY) I $D(APCL(1)),$P(APCL(1),U,2)]"",$P(APCL(1),U,2)'="?" D  Q
 .S V=$P(APCL(1),U,2)
 .I V<7.6 S APCLGOT1=1,APCLSUB=16 D CUML^APCLDM1 D  Q
 ..S APCLGOT1=0 F APCLSUB=17,18,58,59 D CUML^APCLDM1
 .;
 .I V>7.5&(V<10.1) S APCLGOT1=1,APCLSUB=17 D CUML^APCLDM1 D  Q
 ..S APCLGOT1=0 F APCLSUB=16,18,58,59 D CUML^APCLDM1
 .;
 .I V>10.0&(V<12.1) S APCLGOT1=1,APCLSUB=18 D CUML^APCLDM1 D  Q
 ..S APCLGOT1=0 F APCLSUB=16,17,58,59 D CUML^APCLDM1
 .I V>12.0 S APCLGOT1=1,APCLSUB=58 D CUML^APCLDM1 D  Q
 ..S APCLGOT1=0 F APCLSUB=16,17,18,59 D CUML^APCLDM1
GLUCOSE ;check mean of last 3 glucose results
 I '$D(^TMP("APCL",$J,10.3)) S APCLGOT1=1,APCLSUB=59 D CUML^APCLDM1 D  Q
 .S APCLGOT1=0 F APCLSUB=16,17,18,58 D CUML^APCLDM1
 S APCLTOT=""
 S C=0 F X=10.1,10.2,10.3 S V=+(+$P(^TMP("APCL",$J,X),"- ",3)) I V S C=C+1,APCLTOT=APCLTOT+V
 I C'=3 S APCLGOT1=1,APCLSUB=59 D CUML^APCLDM1 D  Q
 .S APCLGOT1=0 F APCLSUB=16,17,18,58 D CUML^APCLDM1
 S X=APCLTOT/3
 I X<166 S APCLGOT1=1,APCLSUB=16 D CUML^APCLDM1 D  Q
 .S APCLGOT1=0 F APCLSUB=17,18,58,59 D CUML^APCLDM1
 I X>165,X<251 S APCLGOT1=1,APCLSUB=17 D CUML^APCLDM1 D  Q
 .S APCLGOT1=0 F APCLSUB=16,18,58,59 D CUML^APCLDM1
 I X>250,X<341 S APCLSUB=18,APCLGOT1=1 D CUML^APCLDM1 D  Q
 .S APCLGOT1=0 F APCLSUB=16,17,58,59 D CUML^APCLDM1
 I X>340 S APCLSUB=58,APCLGOT1=1 D CUML^APCLDM1 D  Q
 .S APCLGOT1=0 F APCLSUB=16,17,18,59 D CUML^APCLDM1
 Q