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

BDMS9B5.m

Go to the documentation of this file.
BDMS9B5 ; IHS/CMI/LAB - DIABETIC CARE SUMMARY SUPPLEMENT ;
 ;;2.0;DIABETES MANAGEMENT SYSTEM;**3,8,9**;JUN 14, 2007;Build 78
 ;
 ;
MAM ;EP
 K BDMSDAT,BDMSTEX
 S BDMSDAT=""
 ;BDMsdat=date of last, BDMstex is display
 Q:$P(^DPT(BDMSPAT,0),U,2)="M"
 K BDMSEXD,BDMSDF1
 S BDMSTXN=0
 S BDMSDAT=$$LASTMAM^APCLAPI1(BDMSPAT)_"^"_$$MAMREF^BDMS9B4(BDMSPAT,BDMSDAT)
 I $$VERSION^XPDUTL("BW")>2.9 G MAMA
 S BDMSBWR=0 S:$D(X) BDMSAVX=X S X="BWUTL1" X ^%ZOSF("TEST") S:$D(BDMSAVX) X=BDMSAVX K BDMSAVX I $T S BDMSBWR=1
 I BDMSBWR,$D(^BWP(BDMSPAT,0)) S BDMSTXN=BDMSTXN+1,BDMSTEX(BDMSTXN)=$$BNEED^BWUTL1(BDMSPAT) I BDMSTEX(1)="UNKNOWN" K BDMSTEX(1) S BDMSTXN=0
 I $O(BDMSTEX("")) Q
MAMA ;
 Q:$$AGE^AUPNPAT(BDMSPAT,DT,"Y")<50
 Q:$$AGE^AUPNPAT(BDMSPAT,DT,"Y")>69
 K BDMSTXN
 S BDMSINT=365
 I $P(BDMSDAT,U,2)]"" S BDMSTEX(1)=$P(BDMSDAT,U,2),BDMSDAT=$P(BDMSDAT,U) Q
 I BDMSDAT="" S BDMSTEX(1)="MAY BE DUE NOW" Q
 K BDMSBWR
 S X1=BDMSDAT,X2=BDMSINT D C^%DTC S Y=X X BDMSCVD S BDMSTEX(1)="Next Due: "_Y,BDMSWD=Y
 S X2=BDMSDAT,X1=DT D ^%DTC I X>BDMSINT S BDMSTEX(1)=$S('$D(BDMSDD):"MAY BE DUE NOW (WAS DUE "_BDMSWD_")",1:"MAY BE DUE NOW")
 Q
 ;
 ;
PAP ;EP
 K BDMSDAT,BDMSTEX,BDMSTP
 S BDMSDAT=""
 ;BDMsdat=date of last, BDMstex is display
 Q:$$AGE^AUPNPAT(BDMSPAT,DT,"Y")<18!($P(^DPT(BDMSPAT,0),U,2)="M")
 K BDMSEXD,BDMSDF1
 S BDMSTXN=0
 I $$VERSION^XPDUTL("BW")>2.9 G PAPA
 S BDMSBWR=0 S:$D(X) BDMSAVX=X S X="BWUTL1" X ^%ZOSF("TEST") S:$D(BDMSAVX) X=BDMSAVX K BDMSAVX I $T S BDMSBWR=1
 I BDMSBWR,$D(^BWP(BDMSPAT,0)) S BDMSTXN=BDMSTXN+1,BDMSTEX(BDMSTXN)=$$CNEED^BWUTL1(BDMSPAT) I BDMSTEX(1)="UNKNOWN" K BDMSTEX(1) S BDMSTXN=0
PAPA ;
 ;S BDMSTP=$$HYSTER^BDMS9B4(BDMSPAT,DT)
 S BDMSTP=$$HYSTER^BDMPB12(BDMSPAT,DT)
 I BDMSTP]"" S BDMSTXN=BDMSTXN+1,BDMSTEX(BDMSTXN)="Pt had hysterectomy.  Pap may be necessary",BDMSTXN=BDMSTXN+1,BDMSTEX(BDMSTXN)="based on individual followup."
 I $O(BDMSTEX("")) S BDMSDAT="" Q
 Q
 ;
 ;
ACE(P,D) ;EP - return date of last ACE iNHIBITOR
 ;IHS/CMI/LAB patch 3 - added this subroutine
 ;go through all v meds until 9999999-D and find all drugs with class CV800 or CV805
 ;if none found check taxonomy
 G ACE^BDMS9B4
 I '$G(P) Q ""
 I '$G(D) S D=0 ;if don't pass date look at all time
 NEW V,I,%
 S %=""
 S I=0 F  S I=$O(^AUPNVMED("AA",P,I)) Q:I'=+I!(%)!(I>(9999999-D))  D
 .S V=0 F  S V=$O(^AUPNVMED("AA",P,I,V)) Q:V'=+V  I $D(^AUPNVMED(V,0)) S G=$P(^AUPNVMED(V,0),U) I $P($G(^PSDRUG(G,0)),U,2)="CV800"!($P($G(^PSDRUG(G,0)),U,2)="CV805") S %=V
 I %]"" D  Q %
 .I $P(^AUPNVMED(%,0),U,8)="" S %="Yes - "_$$FMTE^XLFDT($P($P(^AUPNVSIT($P(^AUPNVMED(%,0),U,3),0),U),".")) Q
 .I $P(^AUPNVMED(%,0),U,8)]"" S %="Discontinued - "_$$FMTE^XLFDT($P($P(^AUPNVSIT($P(^AUPNVMED(%,0),U,3),0),U),".")) Q
 NEW T S T=$O(^ATXAX("B","DM AUDIT ACE INHIBITORS",0))
 I 'T Q ""
 S I=0 F  S I=$O(^AUPNVMED("AA",P,I)) Q:I'=+I!(%)!(I>(9999999-D))  D
 .S V=0 F  S V=$O(^AUPNVMED("AA",P,I,V)) Q:V'=+V  I $D(^AUPNVMED(V,0)) S G=$P(^AUPNVMED(V,0),U) I $D(^ATXAX(T,21,"B",G)) S %=V
 I %]"" D  Q %
 .I $P(^AUPNVMED(%,0),U,8)="" S %="Yes - "_$$FMTE^XLFDT($P($P(^AUPNVSIT($P(^AUPNVMED(%,0),U,3),0),U),".")) Q
 .I $P(^AUPNVMED(%,0),U,8)]"" S %="Discontinued - "_$$FMTE^XLFDT($P($P(^AUPNVSIT($P(^AUPNVMED(%,0),U,3),0),U),".")) Q
 Q "No"
 ;
ASPREF(P) ;EP - CHECK FOR ASPIRIN NMI OR REFUSAL
 I '$G(P) Q ""
 NEW X,N,Z,D,IEN,DATE,DRUG
 K X
 S T=$O(^ATXAX("B","DM AUDIT ASPIRIN DRUGS",0))
 I 'T Q ""
 S (D,G)=0 F  S D=$O(^AUPNPREF("AA",P,50,D)) Q:D'=+D!(G)  D
 .Q:'$D(^ATXAX(T,21,"B",D))
 .S X=$O(^AUPNPREF("AA",P,50,D,0))
 .S N=$O(^AUPNPREF("AA",P,50,D,X,0))
 .S G=1,DATE=9999999-X,DRUG=D,IEN=N
 I 'G Q ""
 Q $$VAL^XBDIQ1(50,DRUG,.01)_" "_$$TYPEREF^BDMSMU(IEN)_" on "_$$FMTE^XLFDT(DATE)