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
;
BDMGRA ; IHS/CMI/LAB - BDM DMS GUI Reports ;
+1 ;;2.0;BDM DIABETES MANAGEMENT SYSTEM;**1**;JUN 14, 2007
+2 ;
+3 ;
+4 ;cmi/anch/maw 1/25/2005 added line in FUR for uppercase dx type
+5 ;
DEBUG(BDMRET,BDMSTR) ;-- debugger
+1 DO DEBUG^%Serenji("FUR^BDMGR(.BDMRET,.BDMSTR)")
+2 QUIT
+3 ;
DMRA(BDMRET,BDMSTR) ;-- get random count of patients available
+1 NEW BDMI,P,R,BDMTYPE,BDMPCP,BDMCOM,BDMSTMP,BDMCMS,BDMCNT,BDMSTAT,BDMSTMPE,BDMCMSE
+2 SET P="|"
SET R="~"
+3 SET BDMCNT=0
+4 SET BDMI=0
+5 SET BDMRET="^BDMTMP("_$JOB_")"
+6 SET BDMTYPE=$PIECE(BDMSTR,P)
+7 SET BDMPCP=$PIECE(BDMSTR,P,2)
+8 SET BDMCOM=$PIECE(BDMSTR,P,3)
+9 SET BDMSTAT=$PIECE(BDMSTR,P,4)
+10 KILL ^BDMTMP($JOB)
+11 SET ^BDMTMP($JOB,BDMI)="T00010COUNT"_$CHAR(30)
+12 IF BDMTYPE="S"
Begin DoDot:1
+13 SET BDMSTMPE=$PIECE(BDMSTR,P,5)
+14 SET BDMSTMP=$ORDER(^DIBT("B",BDMSTMPE,0))
+15 IF 'BDMSTMP
QUIT
+16 NEW BDMDA
+17 SET BDMDA=0
FOR
SET BDMDA=$ORDER(^DIBT(BDMSTMP,1,BDMDA))
IF 'BDMDA
QUIT
Begin DoDot:2
+18 IF $GET(BDMCOM)
IF $PIECE($GET(^AUPNPAT(BDMDA,11)),U,17)'=BDMCOM
QUIT
+19 IF $GET(BDMPCP)
IF $PIECE($GET(^AUPNPAT(BDMDA,0)),U,14)'=BDMPCP
QUIT
+20 ;S ^TMP($J,"PATS",BDMDA)=""
+21 SET BDMCNT=BDMCNT+1
End DoDot:2
+22 SET ^BDMTMP($JOB,1)=BDMCNT_$CHAR(30)
End DoDot:1
+23 IF BDMTYPE="C"
Begin DoDot:1
+24 SET BDMCMSE=$PIECE(BDMSTR,P,5)
+25 SET BDMCMS=$ORDER(^ACM(41.1,"B",BDMCMSE,0))
+26 IF 'BDMCMS
QUIT
+27 NEW BDMDA
+28 SET BDMDA=0
FOR
SET BDMDA=$ORDER(^ACM(41,"B",BDMCMS,BDMDA))
IF 'BDMDA
QUIT
Begin DoDot:2
+29 SET BDMRPAT=$PIECE($GET(^ACM(41,BDMDA,0)),U,2)
+30 IF $GET(BDMCOM)
IF $PIECE($GET(^AUPNPAT(BDMRPAT,11)),U,17)'=BDMCOM
QUIT
+31 IF $GET(BDMPCP)
IF $PIECE($GET(^AUPNPAT(BDMRPAT,0)),U,14)'=BDMPCP
QUIT
+32 IF $GET(BDMSTAT)
IF $PIECE($GET(^ACM(41,BDMDA,"DT")),U)'=BDMSTAT
QUIT
+33 ;S ^TMP($J,"PATS",BDMDA)=""
+34 SET BDMCNT=BDMCNT+1
End DoDot:2
+35 SET ^BDMTMP($JOB,1)=BDMCNT_$CHAR(30)
End DoDot:1
+36 SET ^BDMTMP($JOB,2)=$CHAR(31)
+37 QUIT
+38 ;
DMA(BDMRET,BDMSTR) ;-- dm audit
+1 NEW P,R
+2 NEW BDMRG,BDMDAT,BDMTYP,BDMSTMP,BDMPCP,BDMLCOM,BDMRAND,BDMRCNT,BDMDSP
+3 NEW BDMCMS,BDMRGI,BDMSTAT,BDMPREP,BDMFILE,BDMPATS,BDMSTMPE,BDMCMSE,BDMH,BDMJ
+4 SET BDMH=$HOROLOG
SET BDMJ=$JOB
+5 SET P="|"
SET R="~"
+6 SET BDMRET="^BDMTMP("_$JOB_")"
+7 IF $GET(BDMSTR)=""
SET BDMSTR=$$CATSTR^BDMGU(.BDMSTR,.BDMSTR)
+8 SET BDMRGI=$PIECE(BDMSTR,P)
+9 SET BDMRG=$ORDER(^ACM(41.1,"B",BDMRGI,0))
+10 SET BDMDAT=$PIECE(BDMSTR,P,2)
+11 SET BDMTYP=$PIECE(BDMSTR,P,3)
+12 SET BDMPCP=$PIECE(BDMSTR,P,5)
+13 SET BDMCOM=$PIECE(BDMSTR,P,6)
+14 SET BDMRAND=$PIECE(BDMSTR,P,7)
+15 SET BDMRCNT=$PIECE(BDMSTR,P,8)
+16 SET BDMSTAT=$PIECE(BDMSTR,P,9)
+17 SET BDMPREP=$PIECE(BDMSTR,P,10)
+18 SET BDMFILE=$PIECE(BDMSTR,P,11)
+19 SET BDMDSP=$PIECE(BDMSTR,P,12)
+20 SET BDMDSP=""
+21 IF BDMTYP="P"
Begin DoDot:1
+22 SET BDMPATS=$PIECE(BDMSTR,P,4)
+23 NEW I
+24 FOR I=1:1
Begin DoDot:2
+25 IF $PIECE(BDMPATS,R,I)=""
QUIT
+26 SET ^XTMP("BDMDM31",BDMJ,BDMH,"PATS",$PIECE(BDMPATS,R,I))=""
End DoDot:2
IF $PIECE(BDMPATS,R,I)=""
QUIT
End DoDot:1
+27 IF BDMTYP="S"
Begin DoDot:1
+28 SET BDMSTMPE=$PIECE(BDMSTR,P,4)
+29 SET BDMSTMP=$ORDER(^DIBT("B",BDMSTMPE,0))
+30 IF 'BDMSTMP
QUIT
+31 NEW BDMDA
+32 SET BDMDA=0
FOR
SET BDMDA=$ORDER(^DIBT(BDMSTMP,1,BDMDA))
IF 'BDMDA
QUIT
Begin DoDot:2
+33 IF $GET(BDMCOM)
IF $PIECE($GET(^AUPNPAT(BDMDA,11)),U,17)'=BDMCOM
QUIT
+34 IF $GET(BDMPCP)
IF $PIECE($GET(^AUPNPAT(BDMDA,0)),U,14)'=BDMPCP
QUIT
+35 SET ^XTMP("BDMDM31",BDMJ,BDMH,"PATS",BDMDA)=""
End DoDot:2
End DoDot:1
+36 IF BDMTYP="C"
Begin DoDot:1
+37 SET BDMCMSE=$PIECE(BDMSTR,P,4)
+38 SET BDMCMS=$ORDER(^ACM(41.1,"B",BDMCMSE,0))
+39 IF 'BDMCMS
QUIT
+40 NEW BDMDA
+41 SET BDMDA=0
FOR
SET BDMDA=$ORDER(^ACM(41,"B",BDMCMS,BDMDA))
IF 'BDMDA
QUIT
Begin DoDot:2
+42 SET BDMRPAT=$PIECE($GET(^ACM(41,BDMDA,0)),U,2)
+43 IF $GET(BDMCOM)
IF $PIECE($GET(^AUPNPAT(BDMRPAT,11)),U,17)'=BDMCOM
QUIT
+44 IF $GET(BDMPCP)
IF $PIECE($GET(^AUPNPAT(BDMRPAT,0)),U,14)'=BDMPCP
QUIT
+45 IF $GET(BDMSTAT)]""
IF $PIECE($GET(^ACM(41,BDMDA,"DT")),U)'=BDMSTAT
QUIT
+46 SET ^XTMP("BDMDM31",BDMJ,BDMH,"PATS",BDMRPAT)=""
End DoDot:2
End DoDot:1
+47 IF BDMRAND="Y"
Begin DoDot:1
+48 NEW X
+49 KILL ^TMP($JOB,"PATS")
SET BDMCNT=0
SET X=0
FOR
SET X=$ORDER(^ACM(41,"B",BDMRG,X))
IF X'=+X
QUIT
Begin DoDot:2
+50 IF BDMSTAT]""
IF $PIECE($GET(^ACM(41,X,"DT")),U,1)=BDMSTAT
SET BDMCNT=BDMCNT+1
SET ^TMP($JOB,"PATS",BDMCNT,$PIECE(^ACM(41,X,0),U,2))=""
QUIT
+51 IF BDMSTAT=""
SET BDMCNT=BDMCNT+1
SET ^TMP($JOB,"PATS",BDMCNT,$PIECE(^ACM(41,X,0),U,2))=""
End DoDot:2
+52 KILL ^XTMP("BDMDM31",BDMJ,BDMH,"PATS")
+53 SET (X,BDMCNT)=0
FOR
SET X=$ORDER(^TMP($JOB,"PATS",X))
IF X'=+X
QUIT
SET BDMCNT=BDMCNT+1
+54 SET C=0
FOR N=1:1:BDMCNT
IF C=BDMRCNT
QUIT
SET I=$RANDOM(BDMCNT)
IF I
IF $DATA(^TMP($JOB,"PATS",I))
SET X=$ORDER(^TMP($JOB,"PATS",I,0))
SET ^XTMP("BDMDM31",BDMJ,BDMH,"PATS",X)=""
SET C=C+1
KILL ^TMP($JOB,"PATS",I,X)
+55 KILL ^TMP($JOB,"PATS")
End DoDot:1
+56 IF '$GET(BDMDSP)
SET ^BDMTMP($JOB,1)="T00010REPORTIEN"_$CHAR(30)
+57 DO BDMG^BDMD31(BDMJ,BDMH,BDMRG,BDMDAT,BDMTYP,$GET(BDMSTMP),BDMPCP,BDMCOM,$GET(BDMRAND),$GET(BDMRCNT),$GET(BDMCMS),$GET(BDMSTAT),BDMPREP,$GET(BDMFILE),$GET(BDMDSP),.BDMIEN)
+58 IF $GET(BDMDSP)
SET BDMIEN=1
DO NOWDMO
QUIT
+59 IF '$GET(BDMIEN)
SET BDMERR="Error Queueing DM Audit"
+60 IF '$GET(BDMDSP)
SET ^BDMTMP($JOB,2)=$CHAR(31)_$GET(BDMERR)
+61 QUIT
+62 ;
DMA5(BDMRET,BDMSTR) ;-- dm audit 2005
+1 NEW P,R
+2 NEW BDMRG,BDMDAT,BDMTYP,BDMSTMP,BDMPCP,BDMLCOM,BDMRAND,BDMRCNT,BDMDSP
+3 NEW BDMCMS,BDMRGI,BDMSTAT,BDMPREP,BDMFILE,BDMPATS,BDMSTMPE,BDMCMSE,BDMH,BDMJ
+4 SET BDMH=$HOROLOG
SET BDMJ=$JOB
+5 SET P="|"
SET R="~"
+6 SET BDMRET="^BDMTMP("_$JOB_")"
+7 IF $GET(BDMSTR)=""
SET BDMSTR=$$CATSTR^BDMGU(.BDMSTR,.BDMSTR)
+8 SET BDMRGI=$PIECE(BDMSTR,P)
+9 SET BDMRG=$ORDER(^ACM(41.1,"B",BDMRGI,0))
+10 SET BDMDAT=$PIECE(BDMSTR,P,2)
+11 SET BDMTYP=$PIECE(BDMSTR,P,3)
+12 SET BDMPCP=$PIECE(BDMSTR,P,5)
+13 SET BDMCOM=$PIECE(BDMSTR,P,6)
+14 SET BDMRAND=$PIECE(BDMSTR,P,7)
+15 SET BDMRCNT=$PIECE(BDMSTR,P,8)
+16 SET BDMSTAT=$PIECE(BDMSTR,P,9)
+17 SET BDMPREP=$PIECE(BDMSTR,P,10)
+18 SET BDMFILE=$PIECE(BDMSTR,P,11)
+19 SET BDMDSP=$PIECE(BDMSTR,P,15)
+20 SET BDMSDPI=$PIECE(BDMSTR,P,12)
+21 SET BDMSDPIN=$PIECE(BDMSTR,P,13)
+22 SET BDMCALL=$PIECE(BDMSTR,P,14)
+23 IF BDMCALL="DM Audit E"
Begin DoDot:1
+24 SET BDMTYP=""
End DoDot:1
+25 IF BDMTYP="P"
Begin DoDot:1
+26 SET BDMPATS=$PIECE(BDMSTR,P,4)
+27 NEW I
+28 FOR I=1:1
Begin DoDot:2
+29 IF $PIECE(BDMPATS,R,I)=""
QUIT
+30 SET ^XTMP("BDMDM51",BDMJ,BDMH,"PATS",$PIECE(BDMPATS,R,I))=""
+31 IF BDMCALL="DM Audit P"
Begin DoDot:3
+32 SET ^XTMP("BDMP51",BDMJ,BDMH,"PATS",$PIECE(BDMPATS,R,I))=""
End DoDot:3
End DoDot:2
IF $PIECE(BDMPATS,R,I)=""
QUIT
End DoDot:1
+33 IF BDMTYP="S"
Begin DoDot:1
+34 SET BDMSTMPE=$PIECE(BDMSTR,P,4)
+35 SET BDMSTMP=$ORDER(^DIBT("B",BDMSTMPE,0))
+36 IF 'BDMSTMP
QUIT
+37 NEW BDMDA
+38 SET BDMDA=0
FOR
SET BDMDA=$ORDER(^DIBT(BDMSTMP,1,BDMDA))
IF 'BDMDA
QUIT
Begin DoDot:2
+39 IF $GET(BDMCOM)
IF $PIECE($GET(^AUPNPAT(BDMDA,11)),U,17)'=BDMCOM
QUIT
+40 IF $GET(BDMPCP)
IF $PIECE($GET(^AUPNPAT(BDMDA,0)),U,14)'=BDMPCP
QUIT
+41 SET ^XTMP("BDMDM51",BDMJ,BDMH,"PATS",BDMDA)=""
+42 IF BDMCALL="DM Audit P"
Begin DoDot:3
+43 SET ^XTMP("BDMP51",BDMJ,BDMH,"PATS",BDMDA)=""
End DoDot:3
End DoDot:2
End DoDot:1
+44 IF BDMTYP="C"
Begin DoDot:1
+45 SET BDMCMSE=$PIECE(BDMSTR,P,4)
+46 IF $GET(BDMCMSE)=""
QUIT
+47 SET BDMCMS=$ORDER(^ACM(41.1,"B",BDMCMSE,0))
+48 IF 'BDMCMS
QUIT
+49 NEW BDMDA
+50 SET BDMDA=0
FOR
SET BDMDA=$ORDER(^ACM(41,"B",BDMCMS,BDMDA))
IF 'BDMDA
QUIT
Begin DoDot:2
+51 SET BDMRPAT=$PIECE($GET(^ACM(41,BDMDA,0)),U,2)
+52 IF $GET(BDMCOM)
IF $PIECE($GET(^AUPNPAT(BDMRPAT,11)),U,17)'=BDMCOM
QUIT
+53 IF $GET(BDMPCP)
IF $PIECE($GET(^AUPNPAT(BDMRPAT,0)),U,14)'=BDMPCP
QUIT
+54 IF $GET(BDMSTAT)]""
IF $PIECE($GET(^ACM(41,BDMDA,"DT")),U)'=BDMSTAT
QUIT
+55 SET ^XTMP("BDMDM51",BDMJ,BDMH,"PATS",BDMRPAT)=""
+56 IF BDMCALL="DM Audit P 05"
Begin DoDot:3
+57 SET ^XTMP("BDMP51",BDMJ,BDMH,"PATS",BDMRPAT)=""
End DoDot:3
End DoDot:2
End DoDot:1
+58 IF BDMRAND="Y"
Begin DoDot:1
+59 NEW X
+60 KILL ^TMP($JOB,"PATS")
SET BDMCNT=0
SET X=0
FOR
SET X=$ORDER(^ACM(41,"B",BDMRG,X))
IF X'=+X
QUIT
Begin DoDot:2
+61 IF BDMSTAT]""
IF $PIECE($GET(^ACM(41,X,"DT")),U,1)=BDMSTAT
SET BDMCNT=BDMCNT+1
SET ^TMP($JOB,"PATS",BDMCNT,$PIECE(^ACM(41,X,0),U,2))=""
QUIT
+62 IF BDMSTAT=""
SET BDMCNT=BDMCNT+1
SET ^TMP($JOB,"PATS",BDMCNT,$PIECE(^ACM(41,X,0),U,2))=""
End DoDot:2
+63 KILL ^XTMP("BDMDM51",BDMJ,BDMH,"PATS")
+64 SET (X,BDMCNT)=0
FOR
SET X=$ORDER(^TMP($JOB,"PATS",X))
IF X'=+X
QUIT
SET BDMCNT=BDMCNT+1
+65 SET C=0
FOR N=1:1:BDMCNT
IF C=BDMRCNT
QUIT
SET I=$RANDOM(BDMCNT)
IF I
IF $DATA(^TMP($JOB,"PATS",I))
SET X=$ORDER(^TMP($JOB,"PATS",I,0))
SET ^XTMP("BDMDM51",BDMJ,BDMH,"PATS",X)=""
SET C=C+1
KILL ^TMP($JOB,"PATS",I,X)
+66 KILL ^TMP($JOB,"PATS")
End DoDot:1
+67 IF '$GET(BDMDSP)
SET ^BDMTMP($JOB,1)="T00010REPORTIEN"_$CHAR(30)
+68 IF BDMCALL="DM Audit 2005"
Begin DoDot:1
+69 DO BDMG^BDMD51(BDMJ,BDMH,BDMRG,BDMDAT,BDMTYP,$GET(BDMSTMP),BDMPCP,BDMCOM,$GET(BDMRAND),$GET(BDMRCNT),$GET(BDMCMS),$GET(BDMSTAT),BDMPREP,$GET(BDMFILE),$GET(BDMDSP),.BDMIEN,BDMSDPI,BDMSDPIN)
End DoDot:1
+70 IF BDMCALL="DM Audit P 05"
Begin DoDot:1
+71 DO BDMG^BDMP51(BDMJ,BDMH,BDMRG,BDMDAT,BDMTYP,$GET(BDMSTMP),BDMPCP,BDMCOM,$GET(BDMRAND),$GET(BDMRCNT),$GET(BDMCMS),$GET(BDMSTAT),BDMPREP,$GET(BDMFILE),$GET(BDMDSP),.BDMIEN,BDMSDPI,BDMSDPIN)
End DoDot:1
+72 IF BDMCALL="DM Audit E 05"
Begin DoDot:1
+73 DO BDMG^BDMD51E(BDMJ,BDMH,BDMRG,BDMDAT,BDMTYP,$GET(BDMSTMP),BDMPCP,BDMCOM,$GET(BDMRAND),$GET(BDMRCNT),$GET(BDMCMS),$GET(BDMSTAT),BDMPREP,$GET(BDMFILE),$GET(BDMDSP),.BDMIEN,BDMSDPI,BDMSDPIN)
End DoDot:1
+74 IF $GET(BDMDSP)
SET BDMIEN=1
DO NOWDMO
QUIT
+75 IF '$GET(BDMIEN)
SET BDMERR="Error Queueing DM Audit"
+76 IF '$GET(BDMDSP)
SET ^BDMTMP($JOB,2)=$CHAR(31)_$GET(BDMERR)
+77 QUIT
+78 ;
DMA5P(BDMRET,BDMSTR) ;-- dm audit 2005
+1 NEW P,R
+2 NEW BDMRG,BDMDAT,BDMTYP,BDMSTMP,BDMPCP,BDMLCOM,BDMRAND,BDMRCNT,BDMDSP,BDMPNA
+3 NEW BDMCMS,BDMRGI,BDMSTAT,BDMPREP,BDMFILE,BDMPATS,BDMSTMPE,BDMCMSE,BDMH,BDMJ
+4 SET BDMH=$HOROLOG
SET BDMJ=$JOB
+5 SET P="|"
SET R="~"
+6 SET BDMRET="^BDMTMP("_$JOB_")"
+7 IF $GET(BDMSTR)=""
SET BDMSTR=$$CATSTR^BDMGU(.BDMSTR,.BDMSTR)
+8 SET BDMRGI=$PIECE(BDMSTR,P)
+9 SET BDMRG=$ORDER(^ACM(41.1,"B",BDMRGI,0))
+10 SET BDMRGI=$PIECE(BDMSTR,P)
+11 SET BDMRG=$ORDER(^ACM(41.1,"B",BDMRGI,0))
+12 SET BDMDAT=$PIECE(BDMSTR,P,2)
+13 SET BDMTYP=$PIECE(BDMSTR,P,3)
+14 SET BDMPCP=$PIECE(BDMSTR,P,5)
+15 SET BDMCOM=$PIECE(BDMSTR,P,6)
+16 SET BDMRAND=$PIECE(BDMSTR,P,7)
+17 SET BDMRCNT=$PIECE(BDMSTR,P,8)
+18 SET BDMSTAT=$PIECE(BDMSTR,P,9)
+19 SET BDMPREP=$PIECE(BDMSTR,P,10)
+20 SET BDMFILE=$PIECE(BDMSTR,P,11)
+21 SET BDMPNA=$PIECE(BDMSTR,P,15)
+22 SET BDMDSP=$PIECE(BDMSTR,P,16)
+23 SET BDMSDPI=$PIECE(BDMSTR,P,12)
+24 SET BDMSDPIN=$PIECE(BDMSTR,P,13)
+25 SET BDMCALL=$PIECE(BDMSTR,P,14)
+26 IF BDMTYP="P"
Begin DoDot:1
+27 SET BDMPATS=$PIECE(BDMSTR,P,4)
+28 NEW I
+29 FOR I=1:1
Begin DoDot:2
+30 IF $PIECE(BDMPATS,R,I)=""
QUIT
+31 SET ^XTMP("BDMDM51",BDMJ,BDMH,"PATS",$PIECE(BDMPATS,R,I))=""
End DoDot:2
IF $PIECE(BDMPATS,R,I)=""
QUIT
End DoDot:1
+32 IF BDMTYP="S"
Begin DoDot:1
+33 SET BDMSTMPE=$PIECE(BDMSTR,P,4)
+34 SET BDMSTMP=$ORDER(^DIBT("B",BDMSTMPE,0))
+35 IF 'BDMSTMP
QUIT
+36 NEW BDMDA
+37 SET BDMDA=0
FOR
SET BDMDA=$ORDER(^DIBT(BDMSTMP,1,BDMDA))
IF 'BDMDA
QUIT
Begin DoDot:2
+38 IF $GET(BDMCOM)
IF $PIECE($GET(^AUPNPAT(BDMDA,11)),U,17)'=BDMCOM
QUIT
+39 IF $GET(BDMPCP)
IF $PIECE($GET(^AUPNPAT(BDMDA,0)),U,14)'=BDMPCP
QUIT
+40 SET ^XTMP("BDMDM51",BDMJ,BDMH,"PATS",BDMDA)=""
End DoDot:2
End DoDot:1
+41 IF BDMTYP="C"
Begin DoDot:1
+42 SET BDMCMSE=$PIECE(BDMSTR,P,4)
+43 SET BDMCMS=$ORDER(^ACM(41.1,"B",BDMCMSE,0))
+44 IF 'BDMCMS
QUIT
+45 NEW BDMDA
+46 SET BDMDA=0
FOR
SET BDMDA=$ORDER(^ACM(41,"B",BDMCMS,BDMDA))
IF 'BDMDA
QUIT
Begin DoDot:2
+47 SET BDMRPAT=$PIECE($GET(^ACM(41,BDMDA,0)),U,2)
+48 IF $GET(BDMCOM)
IF $PIECE($GET(^AUPNPAT(BDMRPAT,11)),U,17)'=BDMCOM
QUIT
+49 IF $GET(BDMPCP)
IF $PIECE($GET(^AUPNPAT(BDMRPAT,0)),U,14)'=BDMPCP
QUIT
+50 IF $GET(BDMSTAT)]""
IF $PIECE($GET(^ACM(41,BDMDA,"DT")),U)'=BDMSTAT
QUIT
+51 SET ^XTMP("BDMDM51",BDMJ,BDMH,"PATS",BDMRPAT)=""
End DoDot:2
End DoDot:1
+52 IF '$GET(BDMDSP)
SET ^BDMTMP($JOB,1)="T00010REPORTIEN"_$CHAR(30)
+53 DO BDMG^BDMD51(BDMJ,BDMH,BDMRG,BDMDAT,BDMTYP,$GET(BDMSTMP),BDMPCP,BDMCOM,$GET(BDMRAND),$GET(BDMRCNT),$GET(BDMCMS),$GET(BDMSTAT),BDMPREP,$GET(BDMFILE),$GET(BDMDSP),.BDMIEN,BDMSDPI,BDMSDPIN)
+54 IF $GET(BDMDSP)
SET BDMIEN=1
DO NOWDMO
QUIT
+55 IF '$GET(BDMIEN)
SET BDMERR="Error Queueing DM Audit"
+56 IF '$GET(BDMDSP)
SET ^BDMTMP($JOB,2)=$CHAR(31)_$GET(BDMERR)
+57 QUIT
+58 ;
DMA5E(BDMRET,BDMSTR) ;-- dm audit 2005
+1 NEW P,R
+2 NEW BDMRG,BDMDAT,BDMTYP,BDMSTMP,BDMPCP,BDMLCOM,BDMRAND,BDMRCNT,BDMDSP
+3 NEW BDMCMS,BDMRGI,BDMSTAT,BDMPREP,BDMFILE,BDMPATS,BDMSTMPE,BDMCMSE,BDMH,BDMJ
+4 SET BDMH=$HOROLOG
SET BDMJ=$JOB
+5 SET P="|"
SET R="~"
+6 SET BDMRET="^BDMTMP("_$JOB_")"
+7 IF $GET(BDMSTR)=""
SET BDMSTR=$$CATSTR^BDMGU(.BDMSTR,.BDMSTR)
+8 SET BDMRGI=$PIECE(BDMSTR,P)
+9 SET BDMRG=$ORDER(^ACM(41.1,"B",BDMRGI,0))
+10 SET BDMDAT=$PIECE(BDMSTR,P,2)
+11 SET BDMTYP=$PIECE(BDMSTR,P,3)
+12 SET BDMPCP=$PIECE(BDMSTR,P,5)
+13 SET BDMCOM=$PIECE(BDMSTR,P,6)
+14 SET BDMRAND=$PIECE(BDMSTR,P,7)
+15 SET BDMRCNT=$PIECE(BDMSTR,P,8)
+16 SET BDMSTAT=$PIECE(BDMSTR,P,9)
+17 SET BDMPREP=$PIECE(BDMSTR,P,10)
+18 SET BDMFILE=$PIECE(BDMSTR,P,11)
+19 SET BDMDSP=$PIECE(BDMSTR,P,14)
+20 SET BDMSDPI=$PIECE(BDMSTR,P,12)
+21 SET BDMSDPIN=$PIECE(BDMSTR,P,13)
+22 IF BDMTYP="P"
Begin DoDot:1
+23 SET BDMPATS=$PIECE(BDMSTR,P,4)
+24 NEW I
+25 FOR I=1:1
Begin DoDot:2
+26 IF $PIECE(BDMPATS,R,I)=""
QUIT
+27 SET ^XTMP("BDMDM51",BDMJ,BDMH,"PATS",$PIECE(BDMPATS,R,I))=""
End DoDot:2
IF $PIECE(BDMPATS,R,I)=""
QUIT
End DoDot:1
+28 IF BDMTYP="S"
Begin DoDot:1
+29 SET BDMSTMPE=$PIECE(BDMSTR,P,4)
+30 SET BDMSTMP=$ORDER(^DIBT("B",BDMSTMPE,0))
+31 IF 'BDMSTMP
QUIT
+32 NEW BDMDA
+33 SET BDMDA=0
FOR
SET BDMDA=$ORDER(^DIBT(BDMSTMP,1,BDMDA))
IF 'BDMDA
QUIT
Begin DoDot:2
+34 IF $GET(BDMCOM)
IF $PIECE($GET(^AUPNPAT(BDMDA,11)),U,17)'=BDMCOM
QUIT
+35 IF $GET(BDMPCP)
IF $PIECE($GET(^AUPNPAT(BDMDA,0)),U,14)'=BDMPCP
QUIT
+36 SET ^XTMP("BDMDM51",BDMJ,BDMH,"PATS",BDMDA)=""
End DoDot:2
End DoDot:1
+37 IF BDMTYP="C"
Begin DoDot:1
+38 SET BDMCMSE=$PIECE(BDMSTR,P,4)
+39 SET BDMCMS=$ORDER(^ACM(41.1,"B",BDMCMSE,0))
+40 IF 'BDMCMS
QUIT
+41 NEW BDMDA
+42 SET BDMDA=0
FOR
SET BDMDA=$ORDER(^ACM(41,"B",BDMCMS,BDMDA))
IF 'BDMDA
QUIT
Begin DoDot:2
+43 SET BDMRPAT=$PIECE($GET(^ACM(41,BDMDA,0)),U,2)
+44 IF $GET(BDMCOM)
IF $PIECE($GET(^AUPNPAT(BDMRPAT,11)),U,17)'=BDMCOM
QUIT
+45 IF $GET(BDMPCP)
IF $PIECE($GET(^AUPNPAT(BDMRPAT,0)),U,14)'=BDMPCP
QUIT
+46 IF $GET(BDMSTAT)]""
IF $PIECE($GET(^ACM(41,BDMDA,"DT")),U)'=BDMSTAT
QUIT
+47 SET ^XTMP("BDMDM51",BDMJ,BDMH,"PATS",BDMRPAT)=""
End DoDot:2
End DoDot:1
+48 IF '$GET(BDMDSP)
SET ^BDMTMP($JOB,1)="T00010REPORTIEN"_$CHAR(30)
+49 DO BDMG^BDMD51(BDMJ,BDMH,BDMRG,BDMDAT,BDMTYP,$GET(BDMSTMP),BDMPCP,BDMCOM,$GET(BDMRAND),$GET(BDMRCNT),$GET(BDMCMS),$GET(BDMSTAT),BDMPREP,$GET(BDMFILE),$GET(BDMDSP),.BDMIEN,BDMSDPI,BDMSDPIN)
+50 IF $GET(BDMDSP)
SET BDMIEN=1
DO NOWDMO
QUIT
+51 IF '$GET(BDMIEN)
SET BDMERR="Error Queueing DM Audit"
+52 IF '$GET(BDMDSP)
SET ^BDMTMP($JOB,2)=$CHAR(31)_$GET(BDMERR)
+53 QUIT
+54 ;
DMO(BDMRET,BDMSTR) ;-- return DM Audit Output
+1 NEW P,BDMI,BDMDA,BDMFL,BDMRIEN
+2 SET P="|"
+3 SET BDMFL=$PIECE(BDMSTR,P)
+4 SET BDMRIEN=$EXTRACT(BDMFL,2,9)
+5 SET BDMRET="^BDMTMP("_$JOB_")"
+6 SET BDMI=0
+7 SET ^BDMTMP($JOB,BDMI)="T00250DATA"_$CHAR(30)
+8 IF $EXTRACT(BDMFL,1,1)="A"
Begin DoDot:1
+9 SET BDMDA=0
FOR
SET BDMDA=$ORDER(^BDMGUI(BDMRIEN,11,BDMDA))
IF 'BDMDA
QUIT
Begin DoDot:2
+10 SET BDMI=BDMI+1
+11 SET ^BDMTMP($JOB,BDMI)=$GET(^BDMGUI(BDMRIEN,11,BDMDA,0))_$CHAR(30)
End DoDot:2
End DoDot:1
+12 IF $EXTRACT(BDMFL,1,1)="B"
Begin DoDot:1
+13 SET BDMDA=0
FOR
SET BDMDA=$ORDER(^BDMGUI(BDMRIEN,11,BDMDA))
IF 'BDMDA
QUIT
Begin DoDot:2
+14 SET BDMI=BDMI+1
+15 SET ^BDMTMP($JOB,BDMI)=$GET(^BDMGUI(BDMRIEN,11,BDMDA,0))_$CHAR(30)
End DoDot:2
End DoDot:1
+16 SET ^BDMTMP($JOB,BDMI+1)=$CHAR(31)_$GET(BDMERR)
+17 QUIT
+18 ;
NOWDMO ;EP - return the output to the screen
+1 NEW BDMI,BDMDA
+2 SET BDMI=0
+3 SET ^BDMTMP($JOB,BDMI)="T00250DATA"_$CHAR(30)
+4 SET BDMDA=0
FOR
SET BDMDA=$ORDER(^TMP($JOB,"BDMDM51",BDMDA))
IF 'BDMDA
QUIT
Begin DoDot:1
+5 SET BDMI=BDMI+1
+6 SET ^BDMTMP($JOB,BDMI)=$GET(^TMP($JOB,"BDMDM51",BDMDA))_$CHAR(30)
End DoDot:1
+7 SET ^BDMTMP($JOB,BDMI+1)=$CHAR(31)+$GET(BDMERR)
+8 QUIT
+9 ;
NOWDMO6 ;EP - return the output to the screen
+1 NEW BDMI,BDMDA
+2 SET BDMI=0
+3 SET ^BDMTMP($JOB,BDMI)="T00250DATA"_$CHAR(30)
+4 SET BDMDA=0
FOR
SET BDMDA=$ORDER(^TMP($JOB,"BDMDM61",BDMDA))
IF 'BDMDA
QUIT
Begin DoDot:1
+5 SET BDMI=BDMI+1
+6 SET ^BDMTMP($JOB,BDMI)=$GET(^TMP($JOB,"BDMDM61",BDMDA))_$CHAR(30)
End DoDot:1
+7 SET ^BDMTMP($JOB,BDMI+1)=$CHAR(31)+$GET(BDMERR)
+8 QUIT
+9 ;