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

BDMGRA.m

Go to the documentation of this file.
BDMGRA ; IHS/CMI/LAB - BDM DMS GUI Reports ;
 ;;2.0;BDM DIABETES MANAGEMENT SYSTEM;**1**;JUN 14, 2007
 ;
 ;
 ;cmi/anch/maw 1/25/2005 added line in FUR for uppercase dx type
 ;
DEBUG(BDMRET,BDMSTR) ;-- debugger
 D DEBUG^%Serenji("FUR^BDMGR(.BDMRET,.BDMSTR)")
 Q
 ;
DMRA(BDMRET,BDMSTR) ;-- get random count of patients available
 N BDMI,P,R,BDMTYPE,BDMPCP,BDMCOM,BDMSTMP,BDMCMS,BDMCNT,BDMSTAT,BDMSTMPE,BDMCMSE
 S P="|",R="~"
 S BDMCNT=0
 S BDMI=0
 S BDMRET="^BDMTMP("_$J_")"
 S BDMTYPE=$P(BDMSTR,P)
 S BDMPCP=$P(BDMSTR,P,2)
 S BDMCOM=$P(BDMSTR,P,3)
 S BDMSTAT=$P(BDMSTR,P,4)
 K ^BDMTMP($J)
 S ^BDMTMP($J,BDMI)="T00010COUNT"_$C(30)
 I BDMTYPE="S" D
 . S BDMSTMPE=$P(BDMSTR,P,5)
 . S BDMSTMP=$O(^DIBT("B",BDMSTMPE,0))
 . Q:'BDMSTMP
 . N BDMDA
 . S BDMDA=0 F  S BDMDA=$O(^DIBT(BDMSTMP,1,BDMDA)) Q:'BDMDA  D
 .. I $G(BDMCOM) Q:$P($G(^AUPNPAT(BDMDA,11)),U,17)'=BDMCOM
 .. I $G(BDMPCP) Q:$P($G(^AUPNPAT(BDMDA,0)),U,14)'=BDMPCP
 .. ;S ^TMP($J,"PATS",BDMDA)=""
 .. S BDMCNT=BDMCNT+1
 . S ^BDMTMP($J,1)=BDMCNT_$C(30)
 I BDMTYPE="C" D
 . S BDMCMSE=$P(BDMSTR,P,5)
 . S BDMCMS=$O(^ACM(41.1,"B",BDMCMSE,0))
 . Q:'BDMCMS
 . N BDMDA
 . S BDMDA=0 F  S BDMDA=$O(^ACM(41,"B",BDMCMS,BDMDA)) Q:'BDMDA  D
 .. S BDMRPAT=$P($G(^ACM(41,BDMDA,0)),U,2)
 .. I $G(BDMCOM) Q:$P($G(^AUPNPAT(BDMRPAT,11)),U,17)'=BDMCOM
 .. I $G(BDMPCP) Q:$P($G(^AUPNPAT(BDMRPAT,0)),U,14)'=BDMPCP
 .. I $G(BDMSTAT) Q:$P($G(^ACM(41,BDMDA,"DT")),U)'=BDMSTAT
 .. ;S ^TMP($J,"PATS",BDMDA)=""
 .. S BDMCNT=BDMCNT+1
 . S ^BDMTMP($J,1)=BDMCNT_$C(30)
 S ^BDMTMP($J,2)=$C(31)
 Q
 ;
DMA(BDMRET,BDMSTR) ;-- dm audit
 N P,R
 N BDMRG,BDMDAT,BDMTYP,BDMSTMP,BDMPCP,BDMLCOM,BDMRAND,BDMRCNT,BDMDSP
 N BDMCMS,BDMRGI,BDMSTAT,BDMPREP,BDMFILE,BDMPATS,BDMSTMPE,BDMCMSE,BDMH,BDMJ
 S BDMH=$H,BDMJ=$J
 S P="|",R="~"
 S BDMRET="^BDMTMP("_$J_")"
 I $G(BDMSTR)="" S BDMSTR=$$CATSTR^BDMGU(.BDMSTR,.BDMSTR)
 S BDMRGI=$P(BDMSTR,P)
 S BDMRG=$O(^ACM(41.1,"B",BDMRGI,0))
 S BDMDAT=$P(BDMSTR,P,2)
 S BDMTYP=$P(BDMSTR,P,3)
 S BDMPCP=$P(BDMSTR,P,5)
 S BDMCOM=$P(BDMSTR,P,6)
 S BDMRAND=$P(BDMSTR,P,7)
 S BDMRCNT=$P(BDMSTR,P,8)
 S BDMSTAT=$P(BDMSTR,P,9)
 S BDMPREP=$P(BDMSTR,P,10)
 S BDMFILE=$P(BDMSTR,P,11)
 S BDMDSP=$P(BDMSTR,P,12)
 S BDMDSP=""
 I BDMTYP="P" D
 . S BDMPATS=$P(BDMSTR,P,4)
 . N I
 . F I=1:1 D  Q:$P(BDMPATS,R,I)=""
 .. Q:$P(BDMPATS,R,I)=""
 .. S ^XTMP("BDMDM31",BDMJ,BDMH,"PATS",$P(BDMPATS,R,I))=""
 I BDMTYP="S" D
 . S BDMSTMPE=$P(BDMSTR,P,4)
 . S BDMSTMP=$O(^DIBT("B",BDMSTMPE,0))
 . Q:'BDMSTMP
 . N BDMDA
 . S BDMDA=0 F  S BDMDA=$O(^DIBT(BDMSTMP,1,BDMDA)) Q:'BDMDA  D
 .. I $G(BDMCOM) Q:$P($G(^AUPNPAT(BDMDA,11)),U,17)'=BDMCOM
 .. I $G(BDMPCP) Q:$P($G(^AUPNPAT(BDMDA,0)),U,14)'=BDMPCP
 .. S ^XTMP("BDMDM31",BDMJ,BDMH,"PATS",BDMDA)=""
 I BDMTYP="C" D
 . S BDMCMSE=$P(BDMSTR,P,4)
 . S BDMCMS=$O(^ACM(41.1,"B",BDMCMSE,0))
 . Q:'BDMCMS
 . N BDMDA
 . S BDMDA=0 F  S BDMDA=$O(^ACM(41,"B",BDMCMS,BDMDA)) Q:'BDMDA  D
 .. S BDMRPAT=$P($G(^ACM(41,BDMDA,0)),U,2)
 .. I $G(BDMCOM) Q:$P($G(^AUPNPAT(BDMRPAT,11)),U,17)'=BDMCOM
 .. I $G(BDMPCP) Q:$P($G(^AUPNPAT(BDMRPAT,0)),U,14)'=BDMPCP
 .. I $G(BDMSTAT)]"" Q:$P($G(^ACM(41,BDMDA,"DT")),U)'=BDMSTAT
 .. S ^XTMP("BDMDM31",BDMJ,BDMH,"PATS",BDMRPAT)=""
 I BDMRAND="Y" D
 . N X
 . K ^TMP($J,"PATS") S BDMCNT=0,X=0 F  S X=$O(^ACM(41,"B",BDMRG,X)) Q:X'=+X  D
 .. I BDMSTAT]"",$P($G(^ACM(41,X,"DT")),U,1)=BDMSTAT S BDMCNT=BDMCNT+1,^TMP($J,"PATS",BDMCNT,$P(^ACM(41,X,0),U,2))="" Q
 .. I BDMSTAT="" S BDMCNT=BDMCNT+1,^TMP($J,"PATS",BDMCNT,$P(^ACM(41,X,0),U,2))=""
 . K ^XTMP("BDMDM31",BDMJ,BDMH,"PATS")
 . S (X,BDMCNT)=0 F  S X=$O(^TMP($J,"PATS",X)) Q:X'=+X  S BDMCNT=BDMCNT+1
 . S C=0 F N=1:1:BDMCNT Q:C=BDMRCNT  S I=$R(BDMCNT) I I,$D(^TMP($J,"PATS",I)) S X=$O(^TMP($J,"PATS",I,0)),^XTMP("BDMDM31",BDMJ,BDMH,"PATS",X)="",C=C+1 K ^TMP($J,"PATS",I,X)
 . K ^TMP($J,"PATS")
 I '$G(BDMDSP) S ^BDMTMP($J,1)="T00010REPORTIEN"_$C(30)
 D BDMG^BDMD31(BDMJ,BDMH,BDMRG,BDMDAT,BDMTYP,$G(BDMSTMP),BDMPCP,BDMCOM,$G(BDMRAND),$G(BDMRCNT),$G(BDMCMS),$G(BDMSTAT),BDMPREP,$G(BDMFILE),$G(BDMDSP),.BDMIEN)
 I $G(BDMDSP) S BDMIEN=1 D NOWDMO Q
 I '$G(BDMIEN) S BDMERR="Error Queueing DM Audit"
 I '$G(BDMDSP) S ^BDMTMP($J,2)=$C(31)_$G(BDMERR)
 Q
 ;
DMA5(BDMRET,BDMSTR) ;-- dm audit 2005
 N P,R
 N BDMRG,BDMDAT,BDMTYP,BDMSTMP,BDMPCP,BDMLCOM,BDMRAND,BDMRCNT,BDMDSP
 N BDMCMS,BDMRGI,BDMSTAT,BDMPREP,BDMFILE,BDMPATS,BDMSTMPE,BDMCMSE,BDMH,BDMJ
 S BDMH=$H,BDMJ=$J
 S P="|",R="~"
 S BDMRET="^BDMTMP("_$J_")"
 I $G(BDMSTR)="" S BDMSTR=$$CATSTR^BDMGU(.BDMSTR,.BDMSTR)
 S BDMRGI=$P(BDMSTR,P)
 S BDMRG=$O(^ACM(41.1,"B",BDMRGI,0))
 S BDMDAT=$P(BDMSTR,P,2)
 S BDMTYP=$P(BDMSTR,P,3)
 S BDMPCP=$P(BDMSTR,P,5)
 S BDMCOM=$P(BDMSTR,P,6)
 S BDMRAND=$P(BDMSTR,P,7)
 S BDMRCNT=$P(BDMSTR,P,8)
 S BDMSTAT=$P(BDMSTR,P,9)
 S BDMPREP=$P(BDMSTR,P,10)
 S BDMFILE=$P(BDMSTR,P,11)
 S BDMDSP=$P(BDMSTR,P,15)
 S BDMSDPI=$P(BDMSTR,P,12)
 S BDMSDPIN=$P(BDMSTR,P,13)
 S BDMCALL=$P(BDMSTR,P,14)
 I BDMCALL="DM Audit E" D
 . S BDMTYP=""
 I BDMTYP="P" D
 . S BDMPATS=$P(BDMSTR,P,4)
 . N I
 . F I=1:1 D  Q:$P(BDMPATS,R,I)=""
 .. Q:$P(BDMPATS,R,I)=""
 .. S ^XTMP("BDMDM51",BDMJ,BDMH,"PATS",$P(BDMPATS,R,I))=""
 .. I BDMCALL="DM Audit P" D
 ... S ^XTMP("BDMP51",BDMJ,BDMH,"PATS",$P(BDMPATS,R,I))=""
 I BDMTYP="S" D
 . S BDMSTMPE=$P(BDMSTR,P,4)
 . S BDMSTMP=$O(^DIBT("B",BDMSTMPE,0))
 . Q:'BDMSTMP
 . N BDMDA
 . S BDMDA=0 F  S BDMDA=$O(^DIBT(BDMSTMP,1,BDMDA)) Q:'BDMDA  D
 .. I $G(BDMCOM) Q:$P($G(^AUPNPAT(BDMDA,11)),U,17)'=BDMCOM
 .. I $G(BDMPCP) Q:$P($G(^AUPNPAT(BDMDA,0)),U,14)'=BDMPCP
 .. S ^XTMP("BDMDM51",BDMJ,BDMH,"PATS",BDMDA)=""
 .. I BDMCALL="DM Audit P" D
 ... S ^XTMP("BDMP51",BDMJ,BDMH,"PATS",BDMDA)=""
 I BDMTYP="C" D
 . S BDMCMSE=$P(BDMSTR,P,4)
 . Q:$G(BDMCMSE)=""
 . S BDMCMS=$O(^ACM(41.1,"B",BDMCMSE,0))
 . Q:'BDMCMS
 . N BDMDA
 . S BDMDA=0 F  S BDMDA=$O(^ACM(41,"B",BDMCMS,BDMDA)) Q:'BDMDA  D
 .. S BDMRPAT=$P($G(^ACM(41,BDMDA,0)),U,2)
 .. I $G(BDMCOM) Q:$P($G(^AUPNPAT(BDMRPAT,11)),U,17)'=BDMCOM
 .. I $G(BDMPCP) Q:$P($G(^AUPNPAT(BDMRPAT,0)),U,14)'=BDMPCP
 .. I $G(BDMSTAT)]"" Q:$P($G(^ACM(41,BDMDA,"DT")),U)'=BDMSTAT
 .. S ^XTMP("BDMDM51",BDMJ,BDMH,"PATS",BDMRPAT)=""
 .. I BDMCALL="DM Audit P 05" D
 ... S ^XTMP("BDMP51",BDMJ,BDMH,"PATS",BDMRPAT)=""
 I BDMRAND="Y" D
 . N X
 . K ^TMP($J,"PATS") S BDMCNT=0,X=0 F  S X=$O(^ACM(41,"B",BDMRG,X)) Q:X'=+X  D
 .. I BDMSTAT]"",$P($G(^ACM(41,X,"DT")),U,1)=BDMSTAT S BDMCNT=BDMCNT+1,^TMP($J,"PATS",BDMCNT,$P(^ACM(41,X,0),U,2))="" Q
 .. I BDMSTAT="" S BDMCNT=BDMCNT+1,^TMP($J,"PATS",BDMCNT,$P(^ACM(41,X,0),U,2))=""
 . K ^XTMP("BDMDM51",BDMJ,BDMH,"PATS")
 . S (X,BDMCNT)=0 F  S X=$O(^TMP($J,"PATS",X)) Q:X'=+X  S BDMCNT=BDMCNT+1
 . S C=0 F N=1:1:BDMCNT Q:C=BDMRCNT  S I=$R(BDMCNT) I I,$D(^TMP($J,"PATS",I)) S X=$O(^TMP($J,"PATS",I,0)),^XTMP("BDMDM51",BDMJ,BDMH,"PATS",X)="",C=C+1 K ^TMP($J,"PATS",I,X)
 . K ^TMP($J,"PATS")
 I '$G(BDMDSP) S ^BDMTMP($J,1)="T00010REPORTIEN"_$C(30)
 I BDMCALL="DM Audit 2005" D
 . D BDMG^BDMD51(BDMJ,BDMH,BDMRG,BDMDAT,BDMTYP,$G(BDMSTMP),BDMPCP,BDMCOM,$G(BDMRAND),$G(BDMRCNT),$G(BDMCMS),$G(BDMSTAT),BDMPREP,$G(BDMFILE),$G(BDMDSP),.BDMIEN,BDMSDPI,BDMSDPIN)
 I BDMCALL="DM Audit P 05" D
 . D BDMG^BDMP51(BDMJ,BDMH,BDMRG,BDMDAT,BDMTYP,$G(BDMSTMP),BDMPCP,BDMCOM,$G(BDMRAND),$G(BDMRCNT),$G(BDMCMS),$G(BDMSTAT),BDMPREP,$G(BDMFILE),$G(BDMDSP),.BDMIEN,BDMSDPI,BDMSDPIN)
 I BDMCALL="DM Audit E 05" D
 . D BDMG^BDMD51E(BDMJ,BDMH,BDMRG,BDMDAT,BDMTYP,$G(BDMSTMP),BDMPCP,BDMCOM,$G(BDMRAND),$G(BDMRCNT),$G(BDMCMS),$G(BDMSTAT),BDMPREP,$G(BDMFILE),$G(BDMDSP),.BDMIEN,BDMSDPI,BDMSDPIN)
 I $G(BDMDSP) S BDMIEN=1 D NOWDMO Q
 I '$G(BDMIEN) S BDMERR="Error Queueing DM Audit"
 I '$G(BDMDSP) S ^BDMTMP($J,2)=$C(31)_$G(BDMERR)
 Q
 ;
DMA5P(BDMRET,BDMSTR) ;-- dm audit 2005
 N P,R
 N BDMRG,BDMDAT,BDMTYP,BDMSTMP,BDMPCP,BDMLCOM,BDMRAND,BDMRCNT,BDMDSP,BDMPNA
 N BDMCMS,BDMRGI,BDMSTAT,BDMPREP,BDMFILE,BDMPATS,BDMSTMPE,BDMCMSE,BDMH,BDMJ
 S BDMH=$H,BDMJ=$J
 S P="|",R="~"
 S BDMRET="^BDMTMP("_$J_")"
 I $G(BDMSTR)="" S BDMSTR=$$CATSTR^BDMGU(.BDMSTR,.BDMSTR)
 S BDMRGI=$P(BDMSTR,P)
 S BDMRG=$O(^ACM(41.1,"B",BDMRGI,0))
 S BDMRGI=$P(BDMSTR,P)
 S BDMRG=$O(^ACM(41.1,"B",BDMRGI,0))
 S BDMDAT=$P(BDMSTR,P,2)
 S BDMTYP=$P(BDMSTR,P,3)
 S BDMPCP=$P(BDMSTR,P,5)
 S BDMCOM=$P(BDMSTR,P,6)
 S BDMRAND=$P(BDMSTR,P,7)
 S BDMRCNT=$P(BDMSTR,P,8)
 S BDMSTAT=$P(BDMSTR,P,9)
 S BDMPREP=$P(BDMSTR,P,10)
 S BDMFILE=$P(BDMSTR,P,11)
 S BDMPNA=$P(BDMSTR,P,15)
 S BDMDSP=$P(BDMSTR,P,16)
 S BDMSDPI=$P(BDMSTR,P,12)
 S BDMSDPIN=$P(BDMSTR,P,13)
 S BDMCALL=$P(BDMSTR,P,14)
 I BDMTYP="P" D
 . S BDMPATS=$P(BDMSTR,P,4)
 . N I
 . F I=1:1 D  Q:$P(BDMPATS,R,I)=""
 .. Q:$P(BDMPATS,R,I)=""
 .. S ^XTMP("BDMDM51",BDMJ,BDMH,"PATS",$P(BDMPATS,R,I))=""
 I BDMTYP="S" D
 . S BDMSTMPE=$P(BDMSTR,P,4)
 . S BDMSTMP=$O(^DIBT("B",BDMSTMPE,0))
 . Q:'BDMSTMP
 . N BDMDA
 . S BDMDA=0 F  S BDMDA=$O(^DIBT(BDMSTMP,1,BDMDA)) Q:'BDMDA  D
 .. I $G(BDMCOM) Q:$P($G(^AUPNPAT(BDMDA,11)),U,17)'=BDMCOM
 .. I $G(BDMPCP) Q:$P($G(^AUPNPAT(BDMDA,0)),U,14)'=BDMPCP
 .. S ^XTMP("BDMDM51",BDMJ,BDMH,"PATS",BDMDA)=""
 I BDMTYP="C" D
 . S BDMCMSE=$P(BDMSTR,P,4)
 . S BDMCMS=$O(^ACM(41.1,"B",BDMCMSE,0))
 . Q:'BDMCMS
 . N BDMDA
 . S BDMDA=0 F  S BDMDA=$O(^ACM(41,"B",BDMCMS,BDMDA)) Q:'BDMDA  D
 .. S BDMRPAT=$P($G(^ACM(41,BDMDA,0)),U,2)
 .. I $G(BDMCOM) Q:$P($G(^AUPNPAT(BDMRPAT,11)),U,17)'=BDMCOM
 .. I $G(BDMPCP) Q:$P($G(^AUPNPAT(BDMRPAT,0)),U,14)'=BDMPCP
 .. I $G(BDMSTAT)]"" Q:$P($G(^ACM(41,BDMDA,"DT")),U)'=BDMSTAT
 .. S ^XTMP("BDMDM51",BDMJ,BDMH,"PATS",BDMRPAT)=""
 I '$G(BDMDSP) S ^BDMTMP($J,1)="T00010REPORTIEN"_$C(30)
 D BDMG^BDMD51(BDMJ,BDMH,BDMRG,BDMDAT,BDMTYP,$G(BDMSTMP),BDMPCP,BDMCOM,$G(BDMRAND),$G(BDMRCNT),$G(BDMCMS),$G(BDMSTAT),BDMPREP,$G(BDMFILE),$G(BDMDSP),.BDMIEN,BDMSDPI,BDMSDPIN)
 I $G(BDMDSP) S BDMIEN=1 D NOWDMO Q
 I '$G(BDMIEN) S BDMERR="Error Queueing DM Audit"
 I '$G(BDMDSP) S ^BDMTMP($J,2)=$C(31)_$G(BDMERR)
 Q
 ;
DMA5E(BDMRET,BDMSTR) ;-- dm audit 2005
 N P,R
 N BDMRG,BDMDAT,BDMTYP,BDMSTMP,BDMPCP,BDMLCOM,BDMRAND,BDMRCNT,BDMDSP
 N BDMCMS,BDMRGI,BDMSTAT,BDMPREP,BDMFILE,BDMPATS,BDMSTMPE,BDMCMSE,BDMH,BDMJ
 S BDMH=$H,BDMJ=$J
 S P="|",R="~"
 S BDMRET="^BDMTMP("_$J_")"
 I $G(BDMSTR)="" S BDMSTR=$$CATSTR^BDMGU(.BDMSTR,.BDMSTR)
 S BDMRGI=$P(BDMSTR,P)
 S BDMRG=$O(^ACM(41.1,"B",BDMRGI,0))
 S BDMDAT=$P(BDMSTR,P,2)
 S BDMTYP=$P(BDMSTR,P,3)
 S BDMPCP=$P(BDMSTR,P,5)
 S BDMCOM=$P(BDMSTR,P,6)
 S BDMRAND=$P(BDMSTR,P,7)
 S BDMRCNT=$P(BDMSTR,P,8)
 S BDMSTAT=$P(BDMSTR,P,9)
 S BDMPREP=$P(BDMSTR,P,10)
 S BDMFILE=$P(BDMSTR,P,11)
 S BDMDSP=$P(BDMSTR,P,14)
 S BDMSDPI=$P(BDMSTR,P,12)
 S BDMSDPIN=$P(BDMSTR,P,13)
 I BDMTYP="P" D
 . S BDMPATS=$P(BDMSTR,P,4)
 . N I
 . F I=1:1 D  Q:$P(BDMPATS,R,I)=""
 .. Q:$P(BDMPATS,R,I)=""
 .. S ^XTMP("BDMDM51",BDMJ,BDMH,"PATS",$P(BDMPATS,R,I))=""
 I BDMTYP="S" D
 . S BDMSTMPE=$P(BDMSTR,P,4)
 . S BDMSTMP=$O(^DIBT("B",BDMSTMPE,0))
 . Q:'BDMSTMP
 . N BDMDA
 . S BDMDA=0 F  S BDMDA=$O(^DIBT(BDMSTMP,1,BDMDA)) Q:'BDMDA  D
 .. I $G(BDMCOM) Q:$P($G(^AUPNPAT(BDMDA,11)),U,17)'=BDMCOM
 .. I $G(BDMPCP) Q:$P($G(^AUPNPAT(BDMDA,0)),U,14)'=BDMPCP
 .. S ^XTMP("BDMDM51",BDMJ,BDMH,"PATS",BDMDA)=""
 I BDMTYP="C" D
 . S BDMCMSE=$P(BDMSTR,P,4)
 . S BDMCMS=$O(^ACM(41.1,"B",BDMCMSE,0))
 . Q:'BDMCMS
 . N BDMDA
 . S BDMDA=0 F  S BDMDA=$O(^ACM(41,"B",BDMCMS,BDMDA)) Q:'BDMDA  D
 .. S BDMRPAT=$P($G(^ACM(41,BDMDA,0)),U,2)
 .. I $G(BDMCOM) Q:$P($G(^AUPNPAT(BDMRPAT,11)),U,17)'=BDMCOM
 .. I $G(BDMPCP) Q:$P($G(^AUPNPAT(BDMRPAT,0)),U,14)'=BDMPCP
 .. I $G(BDMSTAT)]"" Q:$P($G(^ACM(41,BDMDA,"DT")),U)'=BDMSTAT
 .. S ^XTMP("BDMDM51",BDMJ,BDMH,"PATS",BDMRPAT)=""
 I '$G(BDMDSP) S ^BDMTMP($J,1)="T00010REPORTIEN"_$C(30)
 D BDMG^BDMD51(BDMJ,BDMH,BDMRG,BDMDAT,BDMTYP,$G(BDMSTMP),BDMPCP,BDMCOM,$G(BDMRAND),$G(BDMRCNT),$G(BDMCMS),$G(BDMSTAT),BDMPREP,$G(BDMFILE),$G(BDMDSP),.BDMIEN,BDMSDPI,BDMSDPIN)
 I $G(BDMDSP) S BDMIEN=1 D NOWDMO Q
 I '$G(BDMIEN) S BDMERR="Error Queueing DM Audit"
 I '$G(BDMDSP) S ^BDMTMP($J,2)=$C(31)_$G(BDMERR)
 Q
 ;
DMO(BDMRET,BDMSTR) ;-- return DM Audit Output
 N P,BDMI,BDMDA,BDMFL,BDMRIEN
 S P="|"
 S BDMFL=$P(BDMSTR,P)
 S BDMRIEN=$E(BDMFL,2,9)
 S BDMRET="^BDMTMP("_$J_")"
 S BDMI=0
 S ^BDMTMP($J,BDMI)="T00250DATA"_$C(30)
 I $E(BDMFL,1,1)="A" D
 . S BDMDA=0 F  S BDMDA=$O(^BDMGUI(BDMRIEN,11,BDMDA)) Q:'BDMDA  D
 .. S BDMI=BDMI+1
 .. S ^BDMTMP($J,BDMI)=$G(^BDMGUI(BDMRIEN,11,BDMDA,0))_$C(30)
 I $E(BDMFL,1,1)="B" D
 .S BDMDA=0 F  S BDMDA=$O(^BDMGUI(BDMRIEN,11,BDMDA)) Q:'BDMDA  D
 .. S BDMI=BDMI+1
 .. S ^BDMTMP($J,BDMI)=$G(^BDMGUI(BDMRIEN,11,BDMDA,0))_$C(30)
 S ^BDMTMP($J,BDMI+1)=$C(31)_$G(BDMERR)
 Q
 ;
NOWDMO ;EP - return the output to the screen
 N BDMI,BDMDA
 S BDMI=0
 S ^BDMTMP($J,BDMI)="T00250DATA"_$C(30)
 S BDMDA=0 F  S BDMDA=$O(^TMP($J,"BDMDM51",BDMDA)) Q:'BDMDA  D
 . S BDMI=BDMI+1
 . S ^BDMTMP($J,BDMI)=$G(^TMP($J,"BDMDM51",BDMDA))_$C(30)
 S ^BDMTMP($J,BDMI+1)=$C(31)+$G(BDMERR)
 Q
 ;
NOWDMO6 ;EP - return the output to the screen
 N BDMI,BDMDA
 S BDMI=0
 S ^BDMTMP($J,BDMI)="T00250DATA"_$C(30)
 S BDMDA=0 F  S BDMDA=$O(^TMP($J,"BDMDM61",BDMDA)) Q:'BDMDA  D
 . S BDMI=BDMI+1
 . S ^BDMTMP($J,BDMI)=$G(^TMP($J,"BDMDM61",BDMDA))_$C(30)
 S ^BDMTMP($J,BDMI+1)=$C(31)+$G(BDMERR)
 Q
 ;