BQIMUEXP ;GDIT/HS/ALA-MU CQ Export ; 01 Sep 2010 8:35 PM
;;2.3;ICARE MANAGEMENT SYSTEM;**3,4**;Apr 18, 2012;Build 66
;
;
EN(FLAG) ; Entry Point
NEW ASUFAC,ASUN,ASUNM,CT,DATE,DELIM,EXIEN,HDR,IEN,IN,N,VISIT,XBFLG,XBPAFN,XBS1,ZISHFL
NEW RECORD,VDATE,XBE,XBF,ZTQUEUED,ERROR,ZISHC,ZISHDA1,BEGDT,ENDT,TMFRAME,CQN,DEN,NUM
NEW EXC,MDATA,MS,MSNM,MSID,MSN,PRECORD,ALT,TIME,FLNM
;
S ZTQUEUED=1
;
;If export is turned off, quit
I $P(^BQI(90508,1,0),U,7)=1 Q
S FLAG=$G(FLAG,0)
;
S ASUN=$P(^AUTTSITE(1,0),U),ASUFAC=$P($G(^AUTTLOC(ASUN,0)),U,10),ASUNM=$P(^DIC(4,ASUN,0),U)
;
K ^BQIDATA($J)
S IN=0,CT=0,DELIM="^"
;
I 'FLAG D
. S IEN=0
. F S IEN=$O(^XTMP("BQIMUMON",IEN)) Q:'IEN D
.. S BEGDT=$P(^XTMP("BQIMUMON",IEN),U,1),ENDT=$P(^XTMP("BQIMUMON",IEN),U,2)
.. S TMFRAME=$$FMTE^BQIUL1(BEGDT)_" - "_$$FMTE^BQIUL1(ENDT)
.. ; ASUFAC
.. S RECORD=ASUFAC
.. ; Unique Identifier
.. S $P(RECORD,DELIM,2)=$$UID(IEN)
.. ; Timeframe
.. S $P(RECORD,DELIM,3)=TMFRAME
.. ; Measures
.. S BQTDT=$E(ENDT,1,5)_"00"
.. S CQN=$O(^BQIPROV(IEN,50,"B",BQTDT,"")) I CQN="" Q
.. S MSN=0
.. F S MSN=$O(^BQIPROV(IEN,50,CQN,1,MSN)) Q:'MSN D
... S PRECORD=RECORD
... S MDATA=^BQIPROV(IEN,50,CQN,1,MSN,0)
... S MSID=$P(MDATA,U,1),DEN=+$P(MDATA,U,2),NUM=+$P(MDATA,U,3),EXC=+$P(MDATA,U,4)
... I NUM>DEN S DEN=+$P(MDATA,U,3),NUM=+$P(MDATA,U,2)
... S MS=$O(^BGPMUIND(90596.11,"C",MSID,"")) I MS="" Q
... S MSNM=$P($G(^BGPMUIND(90596.11,MS,17)),U,3),MN=$P(^BGPMUIND(90596.11,MS,0),U,1)
... S ALT=$G(^BGPMUIND(90595.11,MN,18,1,0))
... ;
... S $P(PRECORD,DELIM,4)=ALT
... S $P(PRECORD,DELIM,5)=MSID
... S $P(PRECORD,DELIM,6)=MSNM
... S $P(PRECORD,DELIM,7)=DEN
... S $P(PRECORD,DELIM,8)=NUM
... S $P(PRECORD,DELIM,9)=EXC
... S IN=IN+1,^BQIDATA($J,IN)=PRECORD
. ;
. D WRITE
. K ^XTMP("BQIMUMON")
;
I FLAG D
. S DN=0
. F S DN=$O(^BQI(90508,1,19,DN)) Q:'DN D
.. S BEGDT=$P(^BQI(90508,1,19,DN,0),U,2),ENDT=$P(^(0),U,3)
.. S TMFRAME=$$FMTE^BQIUL1(BEGDT)_" - "_$$FMTE^BQIUL1(ENDT)
.. S IEN=0
.. F S IEN=$O(^BQIPROV(IEN)) Q:'IEN D
... ; ASUFAC
... S RECORD=ASUFAC
... ; Unique Identifier
... S $P(RECORD,DELIM,2)=$$UID(IEN)
... ; 90 Day Timeframe
... S $P(RECORD,DELIM,3)=TMFRAME
... ; Measures
... S BQTDT=$E(ENDT,1,5)_"00"
... S CQN=$O(^BQIPROV(IEN,50,"B",BQTDT,"")) I CQN="" Q
... S MSN=0
... F S MSN=$O(^BQIPROV(IEN,50,CQN,1,MSN)) Q:'MSN D
.... S PRECORD=RECORD
.... S MDATA=^BQIPROV(IEN,50,CQN,1,MSN,0)
.... S MSID=$P(MDATA,U,1),DEN=+$P(MDATA,U,2),NUM=+$P(MDATA,U,3),EXC=+$P(MDATA,U,4)
.... I NUM>DEN S DEN=+$P(MDATA,U,3),NUM=+$P(MDATA,U,2)
.... S MS=$O(^BGPMUIND(90596.11,"C",MSID,"")) I MS="" Q
.... S MSNM=$P($G(^BGPMUIND(90596.11,MS,17)),U,3),MN=$P(^BGPMUIND(90596.11,MS,0),U,1)
.... S ALT=$G(^BGPMUIND(90595.11,MN,18,1,0))
.... ;
.... S $P(PRECORD,DELIM,4)=ALT
.... S $P(PRECORD,DELIM,5)=MSID
.... S $P(PRECORD,DELIM,6)=MSNM
.... S $P(PRECORD,DELIM,7)=DEN
.... S $P(PRECORD,DELIM,8)=NUM
.... S $P(PRECORD,DELIM,9)=EXC
.... S IN=IN+1,^BQIDATA($J,IN)=PRECORD
;
D WRITE
Q
;
UID(BQIIEN) ;EP - Given IEN of provider return unique Provider record id.
I $P($G(^VA(200,BQIIEN,"NPI")),U,1)'="" Q $P($G(^VA(200,BQIIEN,"NPI")),U,1)
Q "Z"_$$GET1^DIQ(9999999.06,$P(^AUTTSITE(1,0),U),.32)_$E("0000000000",1,10-$L(BQIIEN))_BQIIEN
;
JDATE(DATE) ;EP - Format the date
I $G(DATE)="" Q ""
NEW A
S A=$$FMTE^XLFDT(DATE)
Q $E(DATE,6,7)_$$UP^XLFSTR($P(A," ",1))_(1700+$E(DATE,1,3))
;
DATE(D) ;
Q (1700+$E(D,1,3))_$E(D,4,5)_$E(D,6,7)
;
TIME() ;
S TIME=$$NOW^XLFDT(),TIME=$P(TIME,".",2)
S TIME=$E(TIME,1,4)
;,TIME=TIME_$E("000",$L(TIME)+1,$L(TIME))
Q TIME
;
;send file
WRITE ; use XBGSAVE to save the temp global (BQIDATA) to a file that is exported
;
NEW XBGL,XBQ,XBQTO,XBNAR,XBMED,XBFLT,XBUF,XBFN,TIME
S XBMED="F",XBQ="N",XBFLT=1,XBF=$J,XBE=$J
S XBGL="BQIDATA"
S XBNAR="MU PROVIDER CLINICAL QUALITY EXPORT"
S ASUFAC=$P($G(^AUTTLOC($P(^AUTTSITE(1,0),U),0)),U,10) ;asufac for file name
S FLNM=$S('$$PROD^XUPROD():"MUCQEPZ",1:"MUCQEP")
S XBFN=FLNM_"_"_ASUFAC_"_"_$$DATE(DT)_"_"_$$TIME()_".txt"
;S XBFN="MUCQPR_"_ASUFAC_"_"_$$DATE(DT)_".txt"
S XBS1="CANE SURVEILLANCE SEND"
S XBUF=$P($G(^AUTTSITE(1,1)),"^",2)
I XBUF="" S XBUF=$P($G(^XTV(8989.3,1,"DEV")),"^",1)
;
D ^XBGSAVE
;
K ^BQIDATA($J)
Q
;
HOS(FLAG) ;EP - Hospital Export
NEW ASUFAC,ASUN,ASUNM,CT,DATE,DELIM,EXIEN,HDR,IEN,IN,N,VISIT,XBFLG,XBPAFN,XBS1,ZISHFL
NEW RECORD,VDATE,XBE,XBF,ZTQUEUED,ERROR,ZISHC,ZISHDA1,BEGDT,ENDT,TMFRAME,CQN,DEN,NUM
NEW EXC,MDATA,MS,MSNM,MSID,MSN,PRECORD,ALT,TIME,FLNM
S ZTQUEUED=1
;
;If export is turned off, quit
I $P(^BQI(90508,1,0),U,7)=1 Q
S FLAG=$G(FLAG,0)
;
S ASUN=$P(^BQI(90508,1,0),U),ASUFAC=$P($G(^AUTTLOC(ASUN,0)),U,10),ASUNM=$P(^DIC(4,ASUN,0),U)
;
K ^BQIDATA($J)
S IN=0,CT=0,DELIM="^"
;
I 'FLAG D
. S BEGDT=$$GET1^DIQ(90508,"1,",12.08,"I"),ENDT=$$GET1^DIQ(90508,"1,",12.09,"I")
. S TMFRAME=$$FMTE^BQIUL1(BEGDT)_" - "_$$FMTE^BQIUL1(ENDT)
. ;
. ; ASUFAC
. S RECORD=ASUFAC
. ; Timeframe
. S $P(RECORD,DELIM,2)=TMFRAME
. ; Measures
. S BQTDT=$E(ENDT,1,5)_"00"
. S CQN=$O(^BQIFAC(ASUN,50,"B",BQTDT,"")) I CQN="" Q
. I $P($G(^BQIFAC(ASUN,3)),U,1)=TMFRAME Q
. S MSN=0
. F S MSN=$O(^BQIFAC(ASUN,50,CQN,1,MSN)) Q:'MSN D
.. S PRECORD=RECORD
.. S MDATA=^BQIFAC(ASUN,50,CQN,1,MSN,0)
.. S MSID=$P(MDATA,U,1),DEN=+$P(MDATA,U,2),NUM=+$P(MDATA,U,3),EXC=+$P(MDATA,U,4)
.. S MS=$O(^BGPMUIND(90596.11,"C",MSID,"")) I MS="" Q
.. S MSNM=$P($G(^BGPMUIND(90596.11,MS,17)),U,3),MN=$P(^BGPMUIND(90596.11,MS,0),U,1)
.. S ALT=$G(^BGPMUIND(90595.11,MN,18,1,0))
.. ;
.. S $P(PRECORD,DELIM,3)=ALT
.. S $P(PRECORD,DELIM,4)=MSID
.. S $P(PRECORD,DELIM,5)=MSNM
.. S $P(PRECORD,DELIM,6)=DEN
.. S $P(PRECORD,DELIM,7)=NUM
.. S $P(PRECORD,DELIM,8)=EXC
.. S IN=IN+1,^BQIDATA($J,IN)=PRECORD
;
I FLAG D
. S DN=0
. F S DN=$O(^BQI(90508,1,19,DN)) Q:'DN D
.. S BEGDT=$P(^BQI(90508,1,19,DN,0),U,2),ENDT=$P(^(0),U,3)
.. S TMFRAME=$$FMTE^BQIUL1(BEGDT)_" - "_$$FMTE^BQIUL1(ENDT)
.. ; ASUFAC
.. S RECORD=ASUFAC
.. ; Timeframe
.. S $P(RECORD,DELIM,2)=TMFRAME
.. ; Measures
.. S BQTDT=$E(ENDT,1,5)_"00"
.. S CQN=$O(^BQIFAC(ASUN,50,"B",BQTDT,"")) I CQN="" Q
.. I $P($G(^BQIFAC(ASUN,3)),U,1)=TMFRAME Q
.. S MSN=0
.. F S MSN=$O(^BQIFAC(ASUN,50,CQN,1,MSN)) Q:'MSN D
... S PRECORD=RECORD
... S MDATA=^BQIFAC(ASUN,50,CQN,1,MSN,0)
... S MSID=$P(MDATA,U,1),DEN=+$P(MDATA,U,2),NUM=+$P(MDATA,U,3),EXC=+$P(MDATA,U,4)
... I NUM>DEN S DEN=+$P(MDATA,U,3),NUM=+$P(MDATA,U,2)
... S MS=$O(^BGPMUIND(90596.11,"C",MSID,"")) I MS="" Q
... S MSNM=$P($G(^BGPMUIND(90596.11,MS,17)),U,3),MN=$P(^BGPMUIND(90596.11,MS,0),U,1)
... S ALT=$G(^BGPMUIND(90595.11,MN,18,1,0))
... ;
... S $P(PRECORD,DELIM,3)=ALT
... S $P(PRECORD,DELIM,4)=MSID
... S $P(PRECORD,DELIM,5)=MSNM
... S $P(PRECORD,DELIM,6)=DEN
... S $P(PRECORD,DELIM,7)=NUM
... S $P(PRECORD,DELIM,8)=EXC
... S IN=IN+1,^BQIDATA($J,IN)=PRECORD
;
NEW XBGL,XBQ,XBQTO,XBNAR,XBMED,XBFLT,XBUF,XBFN
S XBMED="F",XBQ="N",XBFLT=1,XBF=$J,XBE=$J
S XBGL="BQIDATA"
S XBNAR="MU HOSPITAL CLINICAL QUALITY EXPORT"
S ASUFAC=$P($G(^AUTTLOC($P(^AUTTSITE(1,0),U),0)),U,10) ;asufac for file name
S FLNM=$S('$$PROD^XUPROD():"MUCQEHZ",1:"MUCQEH")
S XBFN=FLNM_"_"_ASUFAC_"_"_$$DATE(DT)_"_"_$$TIME()_".txt"
S XBS1="CANE SURVEILLANCE SEND"
S XBUF=$P($G(^AUTTSITE(1,1)),"^",2)
I XBUF="" S XBUF=$P($G(^XTV(8989.3,1,"DEV")),"^",1)
;
D ^XBGSAVE
;
K ^BQIDATA($J)
S $P(^BQIFAC(ASUN,3),U,1)=TMFRAME
Q
BQIMUEXP ;GDIT/HS/ALA-MU CQ Export ; 01 Sep 2010 8:35 PM
+1 ;;2.3;ICARE MANAGEMENT SYSTEM;**3,4**;Apr 18, 2012;Build 66
+2 ;
+3 ;
EN(FLAG) ; Entry Point
+1 NEW ASUFAC,ASUN,ASUNM,CT,DATE,DELIM,EXIEN,HDR,IEN,IN,N,VISIT,XBFLG,XBPAFN,XBS1,ZISHFL
+2 NEW RECORD,VDATE,XBE,XBF,ZTQUEUED,ERROR,ZISHC,ZISHDA1,BEGDT,ENDT,TMFRAME,CQN,DEN,NUM
+3 NEW EXC,MDATA,MS,MSNM,MSID,MSN,PRECORD,ALT,TIME,FLNM
+4 ;
+5 SET ZTQUEUED=1
+6 ;
+7 ;If export is turned off, quit
+8 IF $PIECE(^BQI(90508,1,0),U,7)=1
QUIT
+9 SET FLAG=$GET(FLAG,0)
+10 ;
+11 SET ASUN=$PIECE(^AUTTSITE(1,0),U)
SET ASUFAC=$PIECE($GET(^AUTTLOC(ASUN,0)),U,10)
SET ASUNM=$PIECE(^DIC(4,ASUN,0),U)
+12 ;
+13 KILL ^BQIDATA($JOB)
+14 SET IN=0
SET CT=0
SET DELIM="^"
+15 ;
+16 IF 'FLAG
Begin DoDot:1
+17 SET IEN=0
+18 FOR
SET IEN=$ORDER(^XTMP("BQIMUMON",IEN))
IF 'IEN
QUIT
Begin DoDot:2
+19 SET BEGDT=$PIECE(^XTMP("BQIMUMON",IEN),U,1)
SET ENDT=$PIECE(^XTMP("BQIMUMON",IEN),U,2)
+20 SET TMFRAME=$$FMTE^BQIUL1(BEGDT)_" - "_$$FMTE^BQIUL1(ENDT)
+21 ; ASUFAC
+22 SET RECORD=ASUFAC
+23 ; Unique Identifier
+24 SET $PIECE(RECORD,DELIM,2)=$$UID(IEN)
+25 ; Timeframe
+26 SET $PIECE(RECORD,DELIM,3)=TMFRAME
+27 ; Measures
+28 SET BQTDT=$EXTRACT(ENDT,1,5)_"00"
+29 SET CQN=$ORDER(^BQIPROV(IEN,50,"B",BQTDT,""))
IF CQN=""
QUIT
+30 SET MSN=0
+31 FOR
SET MSN=$ORDER(^BQIPROV(IEN,50,CQN,1,MSN))
IF 'MSN
QUIT
Begin DoDot:3
+32 SET PRECORD=RECORD
+33 SET MDATA=^BQIPROV(IEN,50,CQN,1,MSN,0)
+34 SET MSID=$PIECE(MDATA,U,1)
SET DEN=+$PIECE(MDATA,U,2)
SET NUM=+$PIECE(MDATA,U,3)
SET EXC=+$PIECE(MDATA,U,4)
+35 IF NUM>DEN
SET DEN=+$PIECE(MDATA,U,3)
SET NUM=+$PIECE(MDATA,U,2)
+36 SET MS=$ORDER(^BGPMUIND(90596.11,"C",MSID,""))
IF MS=""
QUIT
+37 SET MSNM=$PIECE($GET(^BGPMUIND(90596.11,MS,17)),U,3)
SET MN=$PIECE(^BGPMUIND(90596.11,MS,0),U,1)
+38 SET ALT=$GET(^BGPMUIND(90595.11,MN,18,1,0))
+39 ;
+40 SET $PIECE(PRECORD,DELIM,4)=ALT
+41 SET $PIECE(PRECORD,DELIM,5)=MSID
+42 SET $PIECE(PRECORD,DELIM,6)=MSNM
+43 SET $PIECE(PRECORD,DELIM,7)=DEN
+44 SET $PIECE(PRECORD,DELIM,8)=NUM
+45 SET $PIECE(PRECORD,DELIM,9)=EXC
+46 SET IN=IN+1
SET ^BQIDATA($JOB,IN)=PRECORD
End DoDot:3
End DoDot:2
+47 ;
+48 DO WRITE
+49 KILL ^XTMP("BQIMUMON")
End DoDot:1
+50 ;
+51 IF FLAG
Begin DoDot:1
+52 SET DN=0
+53 FOR
SET DN=$ORDER(^BQI(90508,1,19,DN))
IF 'DN
QUIT
Begin DoDot:2
+54 SET BEGDT=$PIECE(^BQI(90508,1,19,DN,0),U,2)
SET ENDT=$PIECE(^(0),U,3)
+55 SET TMFRAME=$$FMTE^BQIUL1(BEGDT)_" - "_$$FMTE^BQIUL1(ENDT)
+56 SET IEN=0
+57 FOR
SET IEN=$ORDER(^BQIPROV(IEN))
IF 'IEN
QUIT
Begin DoDot:3
+58 ; ASUFAC
+59 SET RECORD=ASUFAC
+60 ; Unique Identifier
+61 SET $PIECE(RECORD,DELIM,2)=$$UID(IEN)
+62 ; 90 Day Timeframe
+63 SET $PIECE(RECORD,DELIM,3)=TMFRAME
+64 ; Measures
+65 SET BQTDT=$EXTRACT(ENDT,1,5)_"00"
+66 SET CQN=$ORDER(^BQIPROV(IEN,50,"B",BQTDT,""))
IF CQN=""
QUIT
+67 SET MSN=0
+68 FOR
SET MSN=$ORDER(^BQIPROV(IEN,50,CQN,1,MSN))
IF 'MSN
QUIT
Begin DoDot:4
+69 SET PRECORD=RECORD
+70 SET MDATA=^BQIPROV(IEN,50,CQN,1,MSN,0)
+71 SET MSID=$PIECE(MDATA,U,1)
SET DEN=+$PIECE(MDATA,U,2)
SET NUM=+$PIECE(MDATA,U,3)
SET EXC=+$PIECE(MDATA,U,4)
+72 IF NUM>DEN
SET DEN=+$PIECE(MDATA,U,3)
SET NUM=+$PIECE(MDATA,U,2)
+73 SET MS=$ORDER(^BGPMUIND(90596.11,"C",MSID,""))
IF MS=""
QUIT
+74 SET MSNM=$PIECE($GET(^BGPMUIND(90596.11,MS,17)),U,3)
SET MN=$PIECE(^BGPMUIND(90596.11,MS,0),U,1)
+75 SET ALT=$GET(^BGPMUIND(90595.11,MN,18,1,0))
+76 ;
+77 SET $PIECE(PRECORD,DELIM,4)=ALT
+78 SET $PIECE(PRECORD,DELIM,5)=MSID
+79 SET $PIECE(PRECORD,DELIM,6)=MSNM
+80 SET $PIECE(PRECORD,DELIM,7)=DEN
+81 SET $PIECE(PRECORD,DELIM,8)=NUM
+82 SET $PIECE(PRECORD,DELIM,9)=EXC
+83 SET IN=IN+1
SET ^BQIDATA($JOB,IN)=PRECORD
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+84 ;
+85 DO WRITE
+86 QUIT
+87 ;
UID(BQIIEN) ;EP - Given IEN of provider return unique Provider record id.
+1 IF $PIECE($GET(^VA(200,BQIIEN,"NPI")),U,1)'=""
QUIT $PIECE($GET(^VA(200,BQIIEN,"NPI")),U,1)
+2 QUIT "Z"_$$GET1^DIQ(9999999.06,$PIECE(^AUTTSITE(1,0),U),.32)_$EXTRACT("0000000000",1,10-$LENGTH(BQIIEN))_BQIIEN
+3 ;
JDATE(DATE) ;EP - Format the date
+1 IF $GET(DATE)=""
QUIT ""
+2 NEW A
+3 SET A=$$FMTE^XLFDT(DATE)
+4 QUIT $EXTRACT(DATE,6,7)_$$UP^XLFSTR($PIECE(A," ",1))_(1700+$EXTRACT(DATE,1,3))
+5 ;
DATE(D) ;
+1 QUIT (1700+$EXTRACT(D,1,3))_$EXTRACT(D,4,5)_$EXTRACT(D,6,7)
+2 ;
TIME() ;
+1 SET TIME=$$NOW^XLFDT()
SET TIME=$PIECE(TIME,".",2)
+2 SET TIME=$EXTRACT(TIME,1,4)
+3 ;,TIME=TIME_$E("000",$L(TIME)+1,$L(TIME))
+4 QUIT TIME
+5 ;
+6 ;send file
WRITE ; use XBGSAVE to save the temp global (BQIDATA) to a file that is exported
+1 ;
+2 NEW XBGL,XBQ,XBQTO,XBNAR,XBMED,XBFLT,XBUF,XBFN,TIME
+3 SET XBMED="F"
SET XBQ="N"
SET XBFLT=1
SET XBF=$JOB
SET XBE=$JOB
+4 SET XBGL="BQIDATA"
+5 SET XBNAR="MU PROVIDER CLINICAL QUALITY EXPORT"
+6 ;asufac for file name
SET ASUFAC=$PIECE($GET(^AUTTLOC($PIECE(^AUTTSITE(1,0),U),0)),U,10)
+7 SET FLNM=$SELECT('$$PROD^XUPROD():"MUCQEPZ",1:"MUCQEP")
+8 SET XBFN=FLNM_"_"_ASUFAC_"_"_$$DATE(DT)_"_"_$$TIME()_".txt"
+9 ;S XBFN="MUCQPR_"_ASUFAC_"_"_$$DATE(DT)_".txt"
+10 SET XBS1="CANE SURVEILLANCE SEND"
+11 SET XBUF=$PIECE($GET(^AUTTSITE(1,1)),"^",2)
+12 IF XBUF=""
SET XBUF=$PIECE($GET(^XTV(8989.3,1,"DEV")),"^",1)
+13 ;
+14 DO ^XBGSAVE
+15 ;
+16 KILL ^BQIDATA($JOB)
+17 QUIT
+18 ;
HOS(FLAG) ;EP - Hospital Export
+1 NEW ASUFAC,ASUN,ASUNM,CT,DATE,DELIM,EXIEN,HDR,IEN,IN,N,VISIT,XBFLG,XBPAFN,XBS1,ZISHFL
+2 NEW RECORD,VDATE,XBE,XBF,ZTQUEUED,ERROR,ZISHC,ZISHDA1,BEGDT,ENDT,TMFRAME,CQN,DEN,NUM
+3 NEW EXC,MDATA,MS,MSNM,MSID,MSN,PRECORD,ALT,TIME,FLNM
+4 SET ZTQUEUED=1
+5 ;
+6 ;If export is turned off, quit
+7 IF $PIECE(^BQI(90508,1,0),U,7)=1
QUIT
+8 SET FLAG=$GET(FLAG,0)
+9 ;
+10 SET ASUN=$PIECE(^BQI(90508,1,0),U)
SET ASUFAC=$PIECE($GET(^AUTTLOC(ASUN,0)),U,10)
SET ASUNM=$PIECE(^DIC(4,ASUN,0),U)
+11 ;
+12 KILL ^BQIDATA($JOB)
+13 SET IN=0
SET CT=0
SET DELIM="^"
+14 ;
+15 IF 'FLAG
Begin DoDot:1
+16 SET BEGDT=$$GET1^DIQ(90508,"1,",12.08,"I")
SET ENDT=$$GET1^DIQ(90508,"1,",12.09,"I")
+17 SET TMFRAME=$$FMTE^BQIUL1(BEGDT)_" - "_$$FMTE^BQIUL1(ENDT)
+18 ;
+19 ; ASUFAC
+20 SET RECORD=ASUFAC
+21 ; Timeframe
+22 SET $PIECE(RECORD,DELIM,2)=TMFRAME
+23 ; Measures
+24 SET BQTDT=$EXTRACT(ENDT,1,5)_"00"
+25 SET CQN=$ORDER(^BQIFAC(ASUN,50,"B",BQTDT,""))
IF CQN=""
QUIT
+26 IF $PIECE($GET(^BQIFAC(ASUN,3)),U,1)=TMFRAME
QUIT
+27 SET MSN=0
+28 FOR
SET MSN=$ORDER(^BQIFAC(ASUN,50,CQN,1,MSN))
IF 'MSN
QUIT
Begin DoDot:2
+29 SET PRECORD=RECORD
+30 SET MDATA=^BQIFAC(ASUN,50,CQN,1,MSN,0)
+31 SET MSID=$PIECE(MDATA,U,1)
SET DEN=+$PIECE(MDATA,U,2)
SET NUM=+$PIECE(MDATA,U,3)
SET EXC=+$PIECE(MDATA,U,4)
+32 SET MS=$ORDER(^BGPMUIND(90596.11,"C",MSID,""))
IF MS=""
QUIT
+33 SET MSNM=$PIECE($GET(^BGPMUIND(90596.11,MS,17)),U,3)
SET MN=$PIECE(^BGPMUIND(90596.11,MS,0),U,1)
+34 SET ALT=$GET(^BGPMUIND(90595.11,MN,18,1,0))
+35 ;
+36 SET $PIECE(PRECORD,DELIM,3)=ALT
+37 SET $PIECE(PRECORD,DELIM,4)=MSID
+38 SET $PIECE(PRECORD,DELIM,5)=MSNM
+39 SET $PIECE(PRECORD,DELIM,6)=DEN
+40 SET $PIECE(PRECORD,DELIM,7)=NUM
+41 SET $PIECE(PRECORD,DELIM,8)=EXC
+42 SET IN=IN+1
SET ^BQIDATA($JOB,IN)=PRECORD
End DoDot:2
End DoDot:1
+43 ;
+44 IF FLAG
Begin DoDot:1
+45 SET DN=0
+46 FOR
SET DN=$ORDER(^BQI(90508,1,19,DN))
IF 'DN
QUIT
Begin DoDot:2
+47 SET BEGDT=$PIECE(^BQI(90508,1,19,DN,0),U,2)
SET ENDT=$PIECE(^(0),U,3)
+48 SET TMFRAME=$$FMTE^BQIUL1(BEGDT)_" - "_$$FMTE^BQIUL1(ENDT)
+49 ; ASUFAC
+50 SET RECORD=ASUFAC
+51 ; Timeframe
+52 SET $PIECE(RECORD,DELIM,2)=TMFRAME
+53 ; Measures
+54 SET BQTDT=$EXTRACT(ENDT,1,5)_"00"
+55 SET CQN=$ORDER(^BQIFAC(ASUN,50,"B",BQTDT,""))
IF CQN=""
QUIT
+56 IF $PIECE($GET(^BQIFAC(ASUN,3)),U,1)=TMFRAME
QUIT
+57 SET MSN=0
+58 FOR
SET MSN=$ORDER(^BQIFAC(ASUN,50,CQN,1,MSN))
IF 'MSN
QUIT
Begin DoDot:3
+59 SET PRECORD=RECORD
+60 SET MDATA=^BQIFAC(ASUN,50,CQN,1,MSN,0)
+61 SET MSID=$PIECE(MDATA,U,1)
SET DEN=+$PIECE(MDATA,U,2)
SET NUM=+$PIECE(MDATA,U,3)
SET EXC=+$PIECE(MDATA,U,4)
+62 IF NUM>DEN
SET DEN=+$PIECE(MDATA,U,3)
SET NUM=+$PIECE(MDATA,U,2)
+63 SET MS=$ORDER(^BGPMUIND(90596.11,"C",MSID,""))
IF MS=""
QUIT
+64 SET MSNM=$PIECE($GET(^BGPMUIND(90596.11,MS,17)),U,3)
SET MN=$PIECE(^BGPMUIND(90596.11,MS,0),U,1)
+65 SET ALT=$GET(^BGPMUIND(90595.11,MN,18,1,0))
+66 ;
+67 SET $PIECE(PRECORD,DELIM,3)=ALT
+68 SET $PIECE(PRECORD,DELIM,4)=MSID
+69 SET $PIECE(PRECORD,DELIM,5)=MSNM
+70 SET $PIECE(PRECORD,DELIM,6)=DEN
+71 SET $PIECE(PRECORD,DELIM,7)=NUM
+72 SET $PIECE(PRECORD,DELIM,8)=EXC
+73 SET IN=IN+1
SET ^BQIDATA($JOB,IN)=PRECORD
End DoDot:3
End DoDot:2
End DoDot:1
+74 ;
+75 NEW XBGL,XBQ,XBQTO,XBNAR,XBMED,XBFLT,XBUF,XBFN
+76 SET XBMED="F"
SET XBQ="N"
SET XBFLT=1
SET XBF=$JOB
SET XBE=$JOB
+77 SET XBGL="BQIDATA"
+78 SET XBNAR="MU HOSPITAL CLINICAL QUALITY EXPORT"
+79 ;asufac for file name
SET ASUFAC=$PIECE($GET(^AUTTLOC($PIECE(^AUTTSITE(1,0),U),0)),U,10)
+80 SET FLNM=$SELECT('$$PROD^XUPROD():"MUCQEHZ",1:"MUCQEH")
+81 SET XBFN=FLNM_"_"_ASUFAC_"_"_$$DATE(DT)_"_"_$$TIME()_".txt"
+82 SET XBS1="CANE SURVEILLANCE SEND"
+83 SET XBUF=$PIECE($GET(^AUTTSITE(1,1)),"^",2)
+84 IF XBUF=""
SET XBUF=$PIECE($GET(^XTV(8989.3,1,"DEV")),"^",1)
+85 ;
+86 DO ^XBGSAVE
+87 ;
+88 KILL ^BQIDATA($JOB)
+89 SET $PIECE(^BQIFAC(ASUN,3),U,1)=TMFRAME
+90 QUIT