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

BDMDM1.m

Go to the documentation of this file.
BDMDM1 ; IHS/CMI/LAB -IHS -GETS DATA FOR DIABETES QA REPORT ;
 ;;2.0;DIABETES MANAGEMENT SYSTEM;**2**;JUN 14, 2007
 ;
 ;
EN ; - ENTRY POINT - from ^BDMASK
 S BDMER=0
 D EN^BDMDM5 ;header and patient ident
 D CLINICAL
 D CLEAN^BDMDM5
XIT Q
 ;
 ;
CUML ; - ENTRY POINT - Set cumulative nodes
 I '$D(^TMP("BDMCUML",$J,BDMSUB)) S ^TMP("BDMCUML",$J,BDMSUB)=BDMGOT1_"/"_1
 E  S ^(BDMSUB)=$S(BDMGOT1:$P(^TMP("BDMCUML",$J,BDMSUB),"/")+1,1:$P(^TMP("BDMCUML",$J,BDMSUB),"/"))_"/"_($P(^(BDMSUB),"/",2)+1)
 Q
 ;
CLINICAL ; Get clinical data
 D DMVISITS
 G:BDMER X
 D VISITS
 F BDMI=1:1 Q:$T(@BDMI)=""  K BDMX S BDMY="BDM(" D @BDMI K BDM
 D ^BDMDM1A
 D ^BDMDM2
 D ^BDMDM3
 D ^BDMDM4
X K BDMY Q
 ;
DMVISITS ; Gets all visits where dx was DM for indicated time period
 K ^TMP("BDMDM FETCH",$J) ;IHS/CMI/LAB - ADDED
 S BDMX=BDMPD_"^DX [SURVEILLANCE DIABETES"_BDMDATE,BDMY="^TMP(""BDMDM FETCH"",$J," S BDMER=$$START1^APCLDF(BDMX,BDMY)
 I BDMER W !,"*** SCRIPT ERROR IN DMVISITS^BDMDM1.  CONTACT SITE MANAGER" G X1
 K ^TMP("BDMDM V",$J) S BDMC=0 F BDML=1:1 Q:'$D(^TMP("BDMDM FETCH",$J,BDML))  D
 .S V=$P(^TMP("BDMDM FETCH",$J,BDML),U,5) Q:$D(^TMP("BDMDM V",$J,V))  S ^TMP("BDMDM V",$J,V)="",C=$$CLINIC^APCLV(V,"C")
 .I C'="06"&(C'="01")&(C'="28") Q
 .I "TC"[$P(^AUPNVSIT(V,0),U,7) Q  ;IHS/CMI/LAB - no tele,cr
 .S BDMC=BDMC+1,^TMP("BDMDM DXVS",$J,BDMC)=$P(^TMP("BDMDM FETCH",$J,BDML),U,5)
 S BDMTOT=BDMC K ^TMP("BDMDM V",$J),BDMC
 I 'BDMTOT S BDMTOT=1
 K BDMDX,BDM,^TMP("BDMDM FETCH",$J)
X1 Q
 ;
VISITS ; Get all visits for indicated time period
 S BDMX=BDMPD_"^VISIT"_BDMDATE,BDMY="^TMP(""BDMDM FETCH"",$J," S BDMER=$$START1^APCLDF(BDMX,BDMY)
 F BDML=1:1 Q:'$D(^TMP("BDMDM FETCH",$J,BDML))  S ^TMP("BDMDM VST",$J,$P(^TMP("BDMDM FETCH",$J,BDML),U,5))=""
 K BDM
 Q
 ;
1 ;
TOBACCO ;
 D TOBACCO^BDMDM6
 Q
2 ;
FIRSTDX ;
 K BDM
 S BDMX=BDMPD_"^FIRST DX [SURVEILLANCE DIABETES" S BDMER=$$START1^APCLDF(BDMX,BDMY) S Y=$P($G(BDM(1)),U) I Y]"" D DD^%DT
 S ^TMP("BDM",$J,2)=Y
X2 ;
 S:BDMER ^TMP("BDM",$J,2)="*** SCRIPT ERROR IN FIRSTDX^BDMDM1.  CONTACT SITE MANAGER"
 K BDM
 Q
4 ;DATE OF ONSET
 D CMSFDX I $D(^TMP("BDM",$J,37)) G 41
 D PLFDX I $D(^TMP("BDM",$J,37)) G 41
 S ^TMP("BDM",$J,37)="Date of Onset not recorded"
41 ;
 I ^TMP("BDM",$J,37)="Date of Onset not recorded" D  G X4
 . S BDMGOT1=1,BDMSUB=47 D CUML
 . F BDMSUB=45,46 S BDMGOT1=0 D CUML
 . Q
 S X=^TMP("BDM",$J,37),%DT="" D ^%DT S X1=DT,X2=Y D ^%DTC S BDMGOT1=1,BDMSUB=$S(X'<3652.5:46,1:45) D CUML S BDMSUB=$S(BDMSUB=46:45,1:46),BDMGOT1=0 D CUML S BDMSUB=47,BDMGOT1=0 D CUML
X4 ;
 K BDM,BDMSUB,BDMGOT1
 Q
CMSFDX ;get first dm dx from case management
 K BDMFDX
 Q:'$G(BDMDMRG)
 S BDMX=0 F  S BDMX=$O(^ACM(44,"C",BDMPD,BDMX)) Q:BDMX'=+BDMX!($D(BDMFDX))  I $P(^ACM(44,BDMX,0),U,4)=BDMDMRG D
 .S BDMFDX=$P($G(^ACM(44,BDMX,"SV")),U,2)
 .Q:BDMFDX=""
 .S BDM(1)=BDMFDX,Y=BDMFDX D DD^%DT S ^TMP("BDM",$J,37)=Y,^TMP("BDM",$J,40)="CMS"
 .Q
 Q
PLFDX ;get first dm dx from problem list
 S BDMX=BDMPD_"^PROBLEM [DM AUDIT PROBLEM DIABETES DX" S BDMER=$$START1^APCLDF(BDMX,BDMY) G:BDMER PLFDXX I $D(BDM(1)) D
 .S BDM(1)=$P(^AUPNPROB(+$P(BDM(1),U,4),0),U,13) I BDM(1)="" K BDM(1) Q
 .S Y=BDM(1) D DD^%DT S ^TMP("BDM",$J,37)=Y,^TMP("BDM",$J,40)="PCC Problem List"
 .Q
PLFDXX Q
3 ;
LASTHT S BDMX=BDMPD_"^LAST MEAS HT" S BDMER=$$START1^APCLDF(BDMX,BDMY) S (BDMHT,BDMHTKI)=$P($G(BDM(1)),U,2) I BDMHT]"" S BDMHT=(BDMHT\12)_" feet "_(BDMHT#12)_" inches"
 S ^TMP("BDM",$J,3)=BDMHT
 I BDMCUML S BDMGOT1=$S(^TMP("BDM",$J,3)]"":1,1:0),BDMSUB=9 D CUML
 Q
 ;