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

BDMP718.m

Go to the documentation of this file.
  1. BDMP718 ; IHS/CMI/LAB - 2003 DIABETES AUDIT ;
  1. ;;2.0;DIABETES MANAGEMENT SYSTEM;**2**;JUN 14, 2007
  1. ;
  1. ;cmi/anch/maw 9/10/2007 code set versioning in WT
  1. ;
  1. HT(P,BDATE,EDATE) ;PEP - CALLED TO GET LAST HEIGHT VALUE IN DATE RANGE BDATE TO EDATE
  1. I 'P Q ""
  1. NEW %,BDMARRY,H,E
  1. S %=P_"^LAST MEAS HT;DURING "_BDATE_"-"_EDATE NEW X S E=$$START1^APCLDF(%,"BDMARRY(") S H=$P($G(BDMARRY(1)),U,2)
  1. I H="" Q H
  1. I H["?" Q ""
  1. S H=$J(H,4,1)
  1. Q H
  1. WT(P,BDATE,EDATE) ;EP
  1. I 'P Q ""
  1. NEW %,E,BDMW,X,BDMN,BDM,BDMD,BDMZ,BDMX,ICD
  1. K BDM S BDMW="" S BDMX=P_"^LAST 24 MEAS WT;DURING "_BDATE_"-"_EDATE S E=$$START1^APCLDF(BDMX,"BDM(")
  1. S BDMN=0 F S BDMN=$O(BDM(BDMN)) Q:BDMN'=+BDMN!(BDMW]"") D
  1. .S BDMZ=$P(BDM(BDMN),U,5)
  1. .I '$D(^AUPNVPOV("AD",BDMZ)) S BDMW=$P(BDM(BDMN),U,2) Q
  1. . S BDMD=0 F S BDMD=$O(^AUPNVPOV("AD",BDMZ,BDMD)) Q:'BDMD!(BDMW]"") D
  1. .. ;S ICD=$P(^ICD9($P(^AUPNVPOV(BDMD,0),U),0),U) D ;cmi/anch/maw 9/12/2007 orig line
  1. .. S ICD=$P($$ICDDX^ICDCODE($P(^AUPNVPOV(BDMD,0),U)),U,2) D ;cmi/anch/maw 9/12/2007 csv
  1. ...I $E(ICD,1,3)="V22" Q
  1. ...I $E(ICD,1,3)="V23" Q
  1. ...I $E(ICD,1,3)="V27" Q
  1. ...I $E(ICD,1,3)="V28" Q
  1. ...I ICD>629.9999&(ICD<676.95) Q
  1. ...I ICD>61.49&(ICD<61.71) Q
  1. ...S BDMW=$P(BDM(BDMN),U,2)
  1. ..Q
  1. Q BDMW
  1. BMI(P,BDATE,EDATE) ;EP
  1. I 'P Q -1
  1. NEW %,W,H,B,D,%DT
  1. S %DT="P",X=EDATE D ^%DT S D=Y
  1. S %=""
  1. I $$AGE^AUPNPAT(P,D)>19 D Q %
  1. .S W=$$WT(P,BDATE,EDATE) I W="" Q
  1. .S HDATE=$$FMTE^XLFDT($$FMADD^XLFDT($P(^DPT(P,0),U,3),(19*365)))
  1. .S H=$$HT(P,HDATE,EDATE) I H="" Q
  1. .S W=W*.45359,H=(H*.0254),H=(H*H),%=(W/H),%=$J(%,4,1)
  1. S X=$$HTWTSD(P,BDATE,EDATE)
  1. I '$P(X,"^") Q %
  1. I '$P(X,"^",2) Q %
  1. S W=$P(X,"^"),H=$P(X,"^",2)
  1. S W=W*.45359,H=(H*.0254),H=(H*H),%=(W/H),%=$J(%,4,1)
  1. Q %
  1. HTWTSD(P,BDATE,EDATE) ;get last ht / wt on same day
  1. I '$G(P) Q ""
  1. NEW BDMWTS,BDMHTS,%,X,BDMWTS1,BDMHTS1
  1. ;get all hts during time frame
  1. S %=P_"^ALL MEAS HT;DURING "_BDATE_"-"_EDATE NEW X S E=$$START1^APCLDF(%,"BDMHTS(")
  1. ;set the array up by date
  1. K BDMHTS1 S X=0 F S X=$O(BDMHTS(X)) Q:X'=+X S BDMHTS1($P(BDMHTS(X),U))=X
  1. ;get all wts during time frame
  1. S %=P_"^ALL MEAS WT;DURING "_BDATE_"-"_EDATE NEW X S E=$$START1^APCLDF(%,"BDMWTS(")
  1. ;set the array up by date
  1. K BDMWTS1 S X=0 F S X=$O(BDMWTS(X)) Q:X'=+X S BDMWTS1($P(BDMWTS(X),U))=X
  1. NEW BDMCHT S BDMCHT="",X=9999999 F S X=$O(BDMWTS1(X),-1) Q:X=""!(BDMCHT]"") I $D(BDMHTS1(X)) S BDMCHT=$P(BDMWTS(BDMWTS1(X)),U,2)_U_$P(BDMHTS(BDMHTS1(X)),U,2)
  1. Q BDMCHT