BDMGRJ ; IHS/CMI/LAB - BDM DMS GUI Reports ; 14 Nov 2017 9:56 AM
;;2.0;DIABETES MANAGEMENT SYSTEM;**12**;JUN 14, 2007;Build 51
;
DEBUG(BDMRET,BDMSTR) ;-- debugger
D DEBUG^%Serenji("DMA12P^BDMGRE(.BDMRET,.BDMSTR)")
Q
;
DMA19(RETVAL,BDMSTR) ;-- dm audit 2019
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
N BDMDZ2,BDMDEMO,BDMBEN,BDMPREG,BDMBD,BDMDQ
S BDMH=$H,BDMJ=$J
S P="|",R="~"
S RETVAL="^BDMTMP("_$J_")"
I $G(BDMSTR)="" D 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 BDMBD=($E(BDMDAT,1,3)-1)_$E(BDMDAT,4,7),BDMBD=$$FMADD^XLFDT(BDMBD,1)
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)
S BDMDZ2=$P(BDMSTR,P,17)
S BDMDEMO=$P(BDMSTR,P,18)
S BDMBEN=$P(BDMSTR,P,19)
S BDMPREG=$P(BDMSTR,P,20)
S BDMDQ=$P(BDMSTR,P,21)
S BDMEAUDA=$P(BDMSTR,P,22)
I BDMCALL="DM Audit E 19" 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("BDMDM19",BDMJ,BDMH,"PATS",$P(BDMPATS,R,I))=""
.. I BDMCALL="DM Audit P 19" D
... S ^XTMP("BDMPG1",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,BDMCNT
. S BDMCNT=0
. 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 BDMCNT=BDMCNT+1
.. I BDMBEN=1,$$BEN^AUPNPAT(BDMDA,"C")'="01" Q
.. I BDMBEN=2,$$BEN^AUPNPAT(BDMDA,"C")="01" Q
.. I BDMPREG="E" Q:$$PREG^BDMDG1B(BDMDA,BDMBD,BDMDAT,1,1)
.. S ^XTMP("BDMDM19",BDMJ,BDMH,"PATS",BDMDA)=""
.. S ^TMP($J,"PATS",BDMCNT,BDMDA)=""
.. I BDMCALL="DM Audit P 19" D
... S ^XTMP("BDMPG1",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,BDMCNT
. S BDMCNT=0
. 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
.. I BDMBEN=1,$$BEN^AUPNPAT(BDMRPAT,"C")'="01" Q
.. I BDMBEN=2,$$BEN^AUPNPAT(BDMRPAT,"C")="01" Q
.. I BDMPREG="E" Q:$$PREG^BDMDG1B(BDMRPAT,BDMBD,BDMDAT,1,1)
.. S ^XTMP("BDMDM19",BDMJ,BDMH,"PATS",BDMRPAT)=""
.. I BDMSTAT]"",$P($G(^ACM(41,BDMDA,"DT")),U,1)=BDMSTAT S BDMCNT=BDMCNT+1,^TMP($J,"PATS",BDMCNT,BDMRPAT)=""
.. I BDMSTAT="" S BDMCNT=BDMCNT+1,^TMP($J,"PATS",BDMCNT,BDMRPAT)=""
.. I BDMCALL="DM Audit P 19" D
... S ^XTMP("BDMPG1",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))=""
.. I BDMSTAT="" S BDMCNT=BDMCNT+1,^TMP($J,"PATS",BDMCNT,$P(^ACM(41,X,0),U,2))=""
. K ^XTMP("BDMDM19",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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=$P(BDMSTR,P,21)
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("BDMDM19",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
.. I BDMPREG="E" Q:$$PREG^BDMDG1B(BDMDA,BDMBD,BDMDAT,1,1)
.. S ^XTMP("BDMDM19",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
.. I BDMPREG="E" Q:$$PREG^BDMDG1B(BDMRPAT,BDMBD,BDMDAT,1,1)
.. S ^XTMP("BDMDM19",BDMJ,BDMH,"PATS",BDMRPAT)=""
I '$G(BDMDSP) S ^BDMTMP($J,1)="T00010REPORTIEN"_$C(30)
D BDMG^BDMDG1(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,BDMPNA,BDMDZ2,BDMDEMO,BDMBEN,$G(BDMDQ))
I $G(BDMDSP) S BDMIEN=1 D NOWDMO19 Q
I '$G(BDMIEN) S BDMERR="Error Queueing DM Audit"
I '$G(BDMDSP) S ^BDMTMP($J,2)=$C(31)_$G(BDMERR)
Q
;
NOWDMO19 ;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,"BDMDM19",BDMDA)) Q:'BDMDA D
. S BDMI=BDMI+1
. S ^BDMTMP($J,BDMI)=$G(^TMP($J,"BDMDM19",BDMDA))_$C(30)
S ^BDMTMP($J,BDMI+1)=$C(31)+$G(BDMERR)
Q
;
BDMGRJ ; IHS/CMI/LAB - BDM DMS GUI Reports ; 14 Nov 2017 9:56 AM
+1 ;;2.0;DIABETES MANAGEMENT SYSTEM;**12**;JUN 14, 2007;Build 51
+2 ;
DEBUG(BDMRET,BDMSTR) ;-- debugger
+1 DO DEBUG^%Serenji("DMA12P^BDMGRE(.BDMRET,.BDMSTR)")
+2 QUIT
+3 ;
DMA19(RETVAL,BDMSTR) ;-- dm audit 2019
+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 NEW BDMDZ2,BDMDEMO,BDMBEN,BDMPREG,BDMBD,BDMDQ
+5 SET BDMH=$HOROLOG
SET BDMJ=$JOB
+6 SET P="|"
SET R="~"
+7 SET RETVAL="^BDMTMP("_$JOB_")"
+8 IF $GET(BDMSTR)=""
DO CATSTR^BDMGU(.BDMSTR,.BDMSTR)
+9 SET BDMRGI=$PIECE(BDMSTR,P)
+10 SET BDMRG=$ORDER(^ACM(41.1,"B",BDMRGI,0))
+11 SET BDMDAT=$PIECE(BDMSTR,P,2)
+12 SET BDMBD=($EXTRACT(BDMDAT,1,3)-1)_$EXTRACT(BDMDAT,4,7)
SET BDMBD=$$FMADD^XLFDT(BDMBD,1)
+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 SET BDMDZ2=$PIECE(BDMSTR,P,17)
+27 SET BDMDEMO=$PIECE(BDMSTR,P,18)
+28 SET BDMBEN=$PIECE(BDMSTR,P,19)
+29 SET BDMPREG=$PIECE(BDMSTR,P,20)
+30 SET BDMDQ=$PIECE(BDMSTR,P,21)
+31 SET BDMEAUDA=$PIECE(BDMSTR,P,22)
+32 IF BDMCALL="DM Audit E 19"
Begin DoDot:1
+33 SET BDMTYP=""
End DoDot:1
+34 IF BDMTYP="P"
Begin DoDot:1
+35 SET BDMPATS=$PIECE(BDMSTR,P,4)
+36 NEW I
+37 FOR I=1:1
Begin DoDot:2
+38 IF $PIECE(BDMPATS,R,I)=""
QUIT
+39 SET ^XTMP("BDMDM19",BDMJ,BDMH,"PATS",$PIECE(BDMPATS,R,I))=""
+40 IF BDMCALL="DM Audit P 19"
Begin DoDot:3
+41 SET ^XTMP("BDMPG1",BDMJ,BDMH,"PATS",$PIECE(BDMPATS,R,I))=""
End DoDot:3
End DoDot:2
IF $PIECE(BDMPATS,R,I)=""
QUIT
End DoDot:1
+42 IF BDMTYP="S"
Begin DoDot:1
+43 SET BDMSTMPE=$PIECE(BDMSTR,P,4)
+44 SET BDMSTMP=$ORDER(^DIBT("B",BDMSTMPE,0))
+45 IF 'BDMSTMP
QUIT
+46 NEW BDMDA,BDMCNT
+47 SET BDMCNT=0
+48 SET BDMDA=0
FOR
SET BDMDA=$ORDER(^DIBT(BDMSTMP,1,BDMDA))
IF 'BDMDA
QUIT
Begin DoDot:2
+49 IF $GET(BDMCOM)
IF $PIECE($GET(^AUPNPAT(BDMDA,11)),U,17)'=BDMCOM
QUIT
+50 IF $GET(BDMPCP)
IF $PIECE($GET(^AUPNPAT(BDMDA,0)),U,14)'=BDMPCP
QUIT
+51 SET BDMCNT=BDMCNT+1
+52 IF BDMBEN=1
IF $$BEN^AUPNPAT(BDMDA,"C")'="01"
QUIT
+53 IF BDMBEN=2
IF $$BEN^AUPNPAT(BDMDA,"C")="01"
QUIT
+54 IF BDMPREG="E"
IF $$PREG^BDMDG1B(BDMDA,BDMBD,BDMDAT,1,1)
QUIT
+55 SET ^XTMP("BDMDM19",BDMJ,BDMH,"PATS",BDMDA)=""
+56 SET ^TMP($JOB,"PATS",BDMCNT,BDMDA)=""
+57 IF BDMCALL="DM Audit P 19"
Begin DoDot:3
+58 SET ^XTMP("BDMPG1",BDMJ,BDMH,"PATS",BDMDA)=""
End DoDot:3
End DoDot:2
End DoDot:1
+59 IF BDMTYP="C"
Begin DoDot:1
+60 SET BDMCMSE=$PIECE(BDMSTR,P,4)
+61 IF $GET(BDMCMSE)=""
QUIT
+62 SET BDMCMS=$ORDER(^ACM(41.1,"B",BDMCMSE,0))
+63 IF 'BDMCMS
QUIT
+64 NEW BDMDA,BDMCNT
+65 SET BDMCNT=0
+66 SET BDMDA=0
FOR
SET BDMDA=$ORDER(^ACM(41,"B",BDMCMS,BDMDA))
IF 'BDMDA
QUIT
Begin DoDot:2
+67 SET BDMRPAT=$PIECE($GET(^ACM(41,BDMDA,0)),U,2)
+68 IF $GET(BDMCOM)
IF $PIECE($GET(^AUPNPAT(BDMRPAT,11)),U,17)'=BDMCOM
QUIT
+69 IF $GET(BDMPCP)
IF $PIECE($GET(^AUPNPAT(BDMRPAT,0)),U,14)'=BDMPCP
QUIT
+70 IF $GET(BDMSTAT)]""
IF $PIECE($GET(^ACM(41,BDMDA,"DT")),U)'=BDMSTAT
QUIT
+71 IF BDMBEN=1
IF $$BEN^AUPNPAT(BDMRPAT,"C")'="01"
QUIT
+72 IF BDMBEN=2
IF $$BEN^AUPNPAT(BDMRPAT,"C")="01"
QUIT
+73 IF BDMPREG="E"
IF $$PREG^BDMDG1B(BDMRPAT,BDMBD,BDMDAT,1,1)
QUIT
+74 SET ^XTMP("BDMDM19",BDMJ,BDMH,"PATS",BDMRPAT)=""
+75 IF BDMSTAT]""
IF $PIECE($GET(^ACM(41,BDMDA,"DT")),U,1)=BDMSTAT
SET BDMCNT=BDMCNT+1
SET ^TMP($JOB,"PATS",BDMCNT,BDMRPAT)=""
+76 IF BDMSTAT=""
SET BDMCNT=BDMCNT+1
SET ^TMP($JOB,"PATS",BDMCNT,BDMRPAT)=""
+77 IF BDMCALL="DM Audit P 19"
Begin DoDot:3
+78 SET ^XTMP("BDMPG1",BDMJ,BDMH,"PATS",BDMRPAT)=""
End DoDot:3
End DoDot:2
End DoDot:1
+79 IF BDMRAND="Y"
Begin DoDot:1
+80 NEW X
+81 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
+82 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))=""
+83 IF BDMSTAT=""
SET BDMCNT=BDMCNT+1
SET ^TMP($JOB,"PATS",BDMCNT,$PIECE(^ACM(41,X,0),U,2))=""
End DoDot:2
+84 KILL ^XTMP("BDMDM19",BDMJ,BDMH,"PATS")
+85 SET (X,BDMCNT)=0
FOR
SET X=$ORDER(^TMP($JOB,"PATS",X))
IF X'=+X
QUIT
SET BDMCNT=BDMCNT+1
+86 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("BDMDM19",BDMJ,BDMH,"PATS",X)=""
SET C=C+1
KILL ^TMP($JOB,"PATS",I,X)
+87 KILL ^TMP($JOB,"PATS")
End DoDot:1
+88 IF '$GET(BDMDSP)
SET ^BDMTMP($JOB,1)="T00010REPORTIEN"_$CHAR(30)
+89 IF BDMCALL="DM Audit 2019"
Begin DoDot:1
+90 DO BDMG^BDMDG1(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,BDMPNA,BDMDZ2,BDMDEMO,BDMBEN,$GET(BDMDQ),$GET(BD
MEAUDA))
End DoDot:1
+91 IF BDMCALL="DM Audit P 19"
Begin DoDot:1
+92 DO BDMG^BDMPG1(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,BDMPNA,BDMDZ2,BDMDEMO,BDMBEN,$GET(BDMDQ))
End DoDot:1
+93 IF BDMCALL="DM Audit E 19"
Begin DoDot:1
+94 DO BDMG^BDMDG1E(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,BDMDZ2,BDMDEMO,$GET(BDMDQ))
End DoDot:1
+95 IF BDMCALL="DMQ"
Begin DoDot:1
+96 DO BDMG^BDMDG1Y(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,BDMPNA,BDMDZ2,BDMDEMO,BDMBEN,$GET(BDMDQ),$GET(B
DMEAUDA))
End DoDot:1
+97 IF $GET(BDMDSP)
SET BDMIEN=1
DO NOWDMO19
QUIT
+98 IF '$GET(BDMIEN)
SET BDMERR="Error Queueing DM Audit"
+99 IF '$GET(BDMDSP)
SET ^BDMTMP($JOB,2)=$CHAR(31)_$GET(BDMERR)
+100 DO EN^XBVK("BDM")
+101 QUIT
+102 ;
DMA19P(BDMRET,BDMSTR) ;-- dm audit 2019
+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 NEW BDMDZ2,BDMDEMO,BDMBEN,BDMPREG,BDMBD,BDMDQ
+5 SET BDMH=$HOROLOG
SET BDMJ=$JOB
+6 SET P="|"
SET R="~"
+7 SET BDMRET="^BDMTMP("_$JOB_")"
+8 IF $GET(BDMSTR)=""
DO CATSTR^BDMGU(.BDMSTR,.BDMSTR)
+9 SET BDMRGI=$PIECE(BDMSTR,P)
+10 SET BDMRG=$ORDER(^ACM(41.1,"B",BDMRGI,0))
+11 SET BDMDAT=$PIECE(BDMSTR,P,2)
+12 SET BDMBD=($EXTRACT(BDMDAT,1,3)-1)_$EXTRACT(BDMDAT,4,7)
SET BDMBD=$$FMADD^XLFDT(BDMBD,1)
+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 SET BDMDZ2=$PIECE(BDMSTR,P,17)
+27 SET BDMDEMO=$PIECE(BDMSTR,P,18)
+28 SET BDMBEN=$PIECE(BDMSTR,P,19)
+29 SET BDMPREG=$PIECE(BDMSTR,P,20)
+30 SET BDMDQ=$PIECE(BDMSTR,P,21)
+31 IF BDMTYP="P"
Begin DoDot:1
+32 SET BDMPATS=$PIECE(BDMSTR,P,4)
+33 NEW I
+34 FOR I=1:1
Begin DoDot:2
+35 IF $PIECE(BDMPATS,R,I)=""
QUIT
+36 SET ^XTMP("BDMDM19",BDMJ,BDMH,"PATS",$PIECE(BDMPATS,R,I))=""
End DoDot:2
IF $PIECE(BDMPATS,R,I)=""
QUIT
End DoDot:1
+37 IF BDMTYP="S"
Begin DoDot:1
+38 SET BDMSTMPE=$PIECE(BDMSTR,P,4)
+39 SET BDMSTMP=$ORDER(^DIBT("B",BDMSTMPE,0))
+40 IF 'BDMSTMP
QUIT
+41 NEW BDMDA
+42 SET BDMDA=0
FOR
SET BDMDA=$ORDER(^DIBT(BDMSTMP,1,BDMDA))
IF 'BDMDA
QUIT
Begin DoDot:2
+43 IF $GET(BDMCOM)
IF $PIECE($GET(^AUPNPAT(BDMDA,11)),U,17)'=BDMCOM
QUIT
+44 IF $GET(BDMPCP)
IF $PIECE($GET(^AUPNPAT(BDMDA,0)),U,14)'=BDMPCP
QUIT
+45 IF BDMPREG="E"
IF $$PREG^BDMDG1B(BDMDA,BDMBD,BDMDAT,1,1)
QUIT
+46 SET ^XTMP("BDMDM19",BDMJ,BDMH,"PATS",BDMDA)=""
End DoDot:2
End DoDot:1
+47 IF BDMTYP="C"
Begin DoDot:1
+48 SET BDMCMSE=$PIECE(BDMSTR,P,4)
+49 SET BDMCMS=$ORDER(^ACM(41.1,"B",BDMCMSE,0))
+50 IF 'BDMCMS
QUIT
+51 NEW BDMDA
+52 SET BDMDA=0
FOR
SET BDMDA=$ORDER(^ACM(41,"B",BDMCMS,BDMDA))
IF 'BDMDA
QUIT
Begin DoDot:2
+53 SET BDMRPAT=$PIECE($GET(^ACM(41,BDMDA,0)),U,2)
+54 IF $GET(BDMCOM)
IF $PIECE($GET(^AUPNPAT(BDMRPAT,11)),U,17)'=BDMCOM
QUIT
+55 IF $GET(BDMPCP)
IF $PIECE($GET(^AUPNPAT(BDMRPAT,0)),U,14)'=BDMPCP
QUIT
+56 IF $GET(BDMSTAT)]""
IF $PIECE($GET(^ACM(41,BDMDA,"DT")),U)'=BDMSTAT
QUIT
+57 IF BDMPREG="E"
IF $$PREG^BDMDG1B(BDMRPAT,BDMBD,BDMDAT,1,1)
QUIT
+58 SET ^XTMP("BDMDM19",BDMJ,BDMH,"PATS",BDMRPAT)=""
End DoDot:2
End DoDot:1
+59 IF '$GET(BDMDSP)
SET ^BDMTMP($JOB,1)="T00010REPORTIEN"_$CHAR(30)
+60 DO BDMG^BDMDG1(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,BDMPNA,BDMDZ2,BDMDEMO,BDMBEN,$GET(BDMDQ))
+61 IF $GET(BDMDSP)
SET BDMIEN=1
DO NOWDMO19
QUIT
+62 IF '$GET(BDMIEN)
SET BDMERR="Error Queueing DM Audit"
+63 IF '$GET(BDMDSP)
SET ^BDMTMP($JOB,2)=$CHAR(31)_$GET(BDMERR)
+64 QUIT
+65 ;
NOWDMO19 ;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,"BDMDM19",BDMDA))
IF 'BDMDA
QUIT
Begin DoDot:1
+5 SET BDMI=BDMI+1
+6 SET ^BDMTMP($JOB,BDMI)=$GET(^TMP($JOB,"BDMDM19",BDMDA))_$CHAR(30)
End DoDot:1
+7 SET ^BDMTMP($JOB,BDMI+1)=$CHAR(31)+$GET(BDMERR)
+8 QUIT
+9 ;