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

BDMSMU1.m

Go to the documentation of this file.
BDMSMU1 ; IHS/CMI/LAB - utilities for hmr ;
 ;;2.0;DIABETES MANAGEMENT SYSTEM;**3,4,9**;JUN 14, 2007;Build 78
 ;
 ;
GETMEDS(P,BDMMBD,BDMMED,TAXM,TAXN,TAXC,BDMNAME,BDMZ) ;EP
 S TAXM=$G(TAXM)
 S TAXN=$G(TAXN)
 S TAXC=$G(TAXC)
 K ^TMP($J,"MEDS"),BDMZ
 S BDMNAME=$G(BDMNAME)
 NEW BDMC1,BDMINED,BDMINBD,BDMMIEN,BDMD,X,Y,T,T1,D,G,T2,C
 S BDMC1=0 K BDMZ
 I $G(BDMMBD)="" S BDMMBD=$$DOB^AUPNPAT(P)
 I $G(BDMMED)="" S BDMMED=DT
 S BDMINED=(9999999-BDMMED)-1,BDMINBD=(9999999-BDMMBD)
 F  S BDMINED=$O(^AUPNVMED("AA",P,BDMINED)) Q:BDMINED=""!(BDMINED>BDMINBD)  D
 .S BDMMIEN=0 F  S BDMMIEN=$O(^AUPNVMED("AA",P,BDMINED,BDMMIEN)) Q:BDMMIEN'=+BDMMIEN  D
 ..Q:'$D(^AUPNVMED(BDMMIEN,0))
 ..S BDMD=$P(^AUPNVMED(BDMMIEN,0),U)
 ..Q:BDMD=""
 ..Q:'$D(^PSDRUG(BDMD,0))
 ..S BDMC1=BDMC1+1
 ..S ^TMP($J,"MEDS","ORDER",(9999999-BDMINED),BDMC1)=(9999999-BDMINED)_U_$P(^PSDRUG(BDMD,0),U)_U_$P(^PSDRUG(BDMD,0),U)_U_BDMMIEN_U_$P(^AUPNVMED(BDMMIEN,0),U,3)
 ;reorder
 S BDMC1=0,X=0
 F  S X=$O(^TMP($J,"MEDS","ORDER",X)) Q:X'=+X  D
 .S Y=0 F  S Y=$O(^TMP($J,"MEDS","ORDER",X,Y)) Q:Y'=+Y  D
 ..S BDMC1=BDMC1+1
 ..S ^TMP($J,"MEDS",BDMC1)=^TMP($J,"MEDS","ORDER",X,Y)
 K ^TMP($J,"MEDS","ORDER")
 S T="" I TAXM]"" S T=$O(^ATXAX("B",TAXM,0))
 S T1="" I TAXN]"" S T1=$O(^ATXAX("B",TAXN,0))
 S T2="" I TAXC]"" S T2=$O(^ATXAX("B",TAXC,0))
 S BDMC1=0,X=0 F  S X=$O(^TMP($J,"MEDS",X)) Q:X'=+X  S Y=+$P(^TMP($J,"MEDS",X),U,4) D
 .Q:'$D(^AUPNVMED(Y,0))
 .S G=0
 .S D=$P(^AUPNVMED(Y,0),U)
 .S C=$P($G(^PSDRUG(D,0)),U,2)
 .I C]"",T2,$D(^ATXAX(T2,21,"B",C)) S G=1
 .S C=$P($G(^PSDRUG(D,2)),U,4)
 .I C]"",T1,$D(^ATXAX(T1,21,"B",C)) S G=1
 .I T,$D(^ATXAX(T,21,"B",D)) S G=1
 .I BDMNAME]"",$P(^PSDRUG(D,0),U)[BDMNAME S G=1
 .I TAXM="",TAXN="",TAXC="",BDMNAME="" S G=1  ;WANTS ALL MEDS
 .I G=1 S BDMC1=BDMC1+1,BDMZ(BDMC1)=^TMP($J,"MEDS",X)
 .Q
 K ^TMP($J,"MEDS")
 K BDMINED,BDMINBD,BDMMBD,BDMMED,BDMD,BDMC1,BDMNAME
 Q
CPTI(P,BDATE,EDATE,CPTI,SCEX,SCLN,SMOD) ;EP - did patient have this cpt (ien) in date range
 I '$G(P) Q ""
 I $G(CPTI)="" Q ""
 I $G(BDATE)="" Q ""
 I $G(EDATE)="" Q ""
 S SCEX=$G(SCEX)
 S SCLN=$G(SCLN)
 S SMOD=$G(SMOD)
 I '$D(^ICPT(CPTI)) Q ""  ;not a valid cpt ien
 I '$D(^AUPNVCPT("AA",P)) Q ""  ;no cpts for this patient
 NEW D,BD,ED,X,Y,D,G,V,I,M,M1,Z,J,K,Q
 S ED=9999999-EDATE-1,BD=9999999-BDATE,G=""
 F  S ED=$O(^AUPNVCPT("AA",P,CPTI,ED)) Q:ED=""!($P(ED,".")>BD)!(G)  D
 .S I=0 F  S I=$O(^AUPNVCPT("AA",P,CPTI,ED,I)) Q:I'=+I!(G)  D
 ..S V=$P($G(^AUPNVCPT(I,0)),U,3)
 ..I SCEX]"",SCEX[$P(^AUPNVSIT(V,0),U,7) Q
 ..I SCLN]"",$$CLINIC^APCLV(V,"C")=SCLN Q
 ..S M=$$VAL^XBDIQ1(9000010.18,I,.08)
 ..S M1=$$VAL^XBDIQ1(9000010.18,I,.09)
 ..S Q=0
 ..I SMOD]"" F J=1:1 S K=$P(SMOD,";",J) Q:K=""  I K=M S Q=1
 ..Q:Q
 ..I SMOD]"" F J=1:1 S K=$P(SMOD,";",J) Q:K=""  I K=M1 S Q=1
 ..Q:Q
 ..S G="1"_"^"_(9999999-ED)
 Q G
 ;
TRANI(P,BDATE,EDATE,CPTI) ;EP
 I '$G(P) Q ""
 I $G(TRANI)="" Q ""
 I $G(BDATE)="" Q ""
 I $G(EDATE)="" Q ""
 I '$D(^ICPT(CPTI)) Q ""
 I '$D(^AUPNVTC("AC",P)) Q ""  ;no cpts for this patient
 NEW X,V,C,G
 S G=""
 S X=0 F  S X=$O(^AUPNVTC("AC",P,X)) Q:X'=+X  D
 .S C=$P($G(^AUPNVTC(X,0)),U,7)
 .Q:C'=CPTI
 .S V=$P(^AUPNVTC(X,0),U,3)
 .S V=$P($P($G(^AUPNVSIT(V,0)),U),".")
 .Q:V<BDATE
 .Q:V>EDATE
 .S G="1"_"^"_V
 Q G
 ;
CPTREFT(P,BDATE,EDATE,T) ;EP - return ien of CPT entry if patient had this CPT
 I '$G(P) Q ""
 I '$G(T) Q ""
 I $G(EDATE)="" Q ""
 I $G(BDATE)="" S BDATE=$$FMADD^XLFDT(EDATE,-365)
 NEW G,X,Y,Z,I
 S G=""
 S I=0 F  S I=$O(^AUPNPREF("AA",P,81,I)) Q:I=""!($P(G,U))  D
 .S (X,G)=0 F  S X=$O(^AUPNPREF("AA",P,81,I,X)) Q:X'=+X!($P(G,U))  S Y=0 F  S Y=$O(^AUPNPREF("AA",P,81,I,X,Y)) Q:Y'=+Y  S D=$P(^AUPNPREF(Y,0),U,3) I D'<BDATE&(D'>EDATE) D
 ..Q:'$$ICD^BDMUTL(I,T,1)
 ..S G="1^"_D_"^"_$P(^AUPNPREF(Y,0),U,7)
 .Q
 Q G
REFTAX(P,F,T,B,E) ;EP - refused an item in a taxonomy
 I '$G(P) Q ""
 I '$G(F) Q ""
 I '$G(T) Q ""
 I $G(B)="" Q ""
 I $G(E)="" Q ""
 NEW G,X,Y,%DT,T1 S X=B,%DT="P" D ^%DT S B=Y
 S X=E,%DT="P" D ^%DT S E=Y
 S T1=0,G="" F  S T1=$O(^ATXAX(T,21,"B",T1)) Q:T1=""!(G)  D
 .S (X,G)=0 F  S X=$O(^AUPNPREF("AA",P,F,T1,X)) Q:X'=+X!(G)  S Y=0 F  S Y=$O(^AUPNPREF("AA",P,F,T1,X,Y)) Q:Y'=+Y  S D=$P(^AUPNPREF(Y,0),U,3) I D'<B&(D'>E) S G="1^"_D_"^"_$P(^AUPNPREF(Y,0),U,7)
 Q G
PAPCPTS ;;
 ;;88141
 ;;88142
 ;;88143
 ;;88144
 ;;88145
 ;;88146
 ;;88147
 ;;88148
 ;;88150
 ;;88152
 ;;88153
 ;;88154
 ;;88155
 ;;88156
 ;;88157
 ;;88158
 ;;88164
 ;;88165
 ;;88166
 ;;88167
 ;;
FLUCPTS ;;
 ;;90657
 ;;90656
 ;;90658
 ;;90655
 ;;90724
 ;;90711
 ;;90659
 ;;90660
 ;;
SIGCPTS ;;
 ;;45330
 ;;45331
 ;;45332
 ;;45333
 ;;45334
 ;;45336
 ;;45337
 ;;45338
 ;;45339
 ;;45341
 ;;45342
 ;;45345
 ;;
BECPTS ;;
 ;;74270
 ;;74275
 ;;74280
 ;;
COLOCPTS ;;
 ;;45355
 ;;45360
 ;;45361
 ;;45362
 ;;45363
 ;;45364
 ;;45365
 ;;45366
 ;;45367
 ;;45368
 ;;45369
 ;;45370
 ;;45371
 ;;45372
 ;;45378
 ;;45379
 ;;45380
 ;;45382
 ;;45383
 ;;45384
 ;;45385
 ;;45387
 ;;