BNIGVL ; IHS/CMI/LAB - bni general retrieval ;
;;1.0;BNI CPHD ACTIVITY DATASYSTEM;;DEC 20, 2006
;visit general retrieval
START ;
K BNIGQUIT,BNIGDTR
D XIT
D INFORM
S BNIGPTVS="R"
TYPE ;--- get type of report
S (BNIGPCNT,BNIGPTCT)=0
K BNIGTYPE ;--- just in case variable left around
S BNIGTYPE="RS"
D @BNIGTYPE,XIT
Q
RS ;
S BNIIOSL=$S($G(BNIGUI):55,1:$G(IOSL))
GETDATES ;
S BNIGLHDR="DATE RANGE SELECTION" W !!?((80-$L(BNIGLHDR))/2),BNIGLHDR
GETDATE1 ;
BD ;get beginning date
W !
S BNIGBD=""
S DIR(0)="FO^6:7",DIR("A")="Enter Beginning Month (e.g. 01/2006)",DIR("?")="Enter a month and 4 digit year in the following format: 1/1999, 01/2000. The slash is required between the month and year. Date must be in the past."
KILL DA D ^DIR KILL DIR
Q:$D(DIRUT)
Q:X=""
I Y'?1.2N1"/"4N W !,"Enter the month/4 digit year in the format 03/2005. Slash is required and ",!,"4 digit year is required.",! G BD
K %DT S X=Y,%DT="EP" D ^%DT
I Y=-1 W !!,"Enter a month and 4 digit year. Date must be in the past. E.g. 04/2005 or 01/2000." G BD
I Y>DT W !!,"No future dates allowed!",! G BD
S BNIGBD=Y
ED ;get ending date
W !
S BNIGED=""
S DIR(0)="FO^6:7",DIR("A")="Enter Ending Month (e.g. 01/2006)",DIR("?")="Enter a month and 4 digit year in the following format: 1/1999, 01/2000. The slash is required between the month and year. Date must be in the past."
KILL DA D ^DIR KILL DIR
Q:$D(DIRUT)
Q:X=""
I Y'?1.2N1"/"4N W !,"Enter the month/4 digit year in the format 03/2005. Slash is required and ",!,"4 digit year is required.",! G ED
K %DT S X=Y,%DT="EP" D ^%DT
I Y=-1 W !!,"Enter a month and 4 digit year. Date must be in the past. E.g. 04/2005 or 01/2000." G ED
I Y>DT W !!,"No future dates allowed!",! G ED
S BNIGED=Y
S BNIGBDD=$$FMTE^XLFDT(BNIGBD),BNIGEDD=$$FMTE^XLFDT(BNIGED)
Q:$D(BNIGDTR)
D ADD I $D(BNIGQUIT) D DEL K BNIGQUIT G RS
I '$D(BNIGCAND) D D1 Q
D TITLE I $D(BNIGQUIT) K BNIGQUIT G TYPE
D ZIS
Q
D1 ;if visit, no prev defined report used
D11 K ^BNIRTMP(BNIGRPT,11) D SCREEN I $D(BNIGQUIT) K BNIGQUIT D DEL G RS
D12 K ^BNIRTMP(BNIGRPT,12) S BNIGTCW=0 D COUNT I $D(BNIGQUIT) K BNIGQUIT G D11
D13 D TITLE I $D(BNIGQUIT) K BNIGQUIT G D12
D SAVE,ZIS
Q
SCREEN ;
S BNIGCNTL="S"
D ^BNIGVL4
Q
COUNT ;count only or detailed report
BN D COUNT^BNIGVL3
Q
TITLE ;
D TITLE^BNIGVL3
Q
SAVE ;
D SAVE^BNIGVL3
Q
ZIS ;call to XBDBQUE
K BNIGOPT
I 'BNIGTCW S BNIGTCW=IOM
S BNIGDONE=""
D SHOW^BNIGVLS,SHOWP^BNIGVLS,SHOWR^BNIGVLS
D XIT1
I BNIGCTYP="D"!(BNIGCTYP="S") D
.S DIR(0)="S^P:PRINT Output;B:BROWSE Output on Screen",DIR("A")="Do you wish to ",DIR("B")="P" K DA D ^DIR K DIR
.I $D(DIRUT) S BNIGQUIT="" Q
.S BNIGOPT=Y
G:$G(BNIGQUIT) SAVE
I $G(BNIGOPT)="B" D BROWSE,XIT Q
S XBRP="^BNIGVLP",XBRC="^BNIGVL1",XBRX="XIT^BNIGVL",XBNS="BNIG"
D ^XBDBQUE
D XIT
Q
DEL ;EP DELETE LOG ENTRY IF ONE EXISTS AND USER "^" OUT
I $G(BNIGRPT),$D(^BNIRTMP(BNIGRPT,0)),'$P(^BNIRTMP(BNIGRPT,0),U,2) S DIK="^BNIRTMP(",DA=BNIGRPT D ^DIK K DIK,DA,DIC
Q
BROWSE ;
S XBRP="VIEWR^XBLM(""^BNIGVLP"")"
S XBRC="^BNIGVL1",XBRX="XIT^BNIGVL",XBIOP=0 D ^XBDBQUE
Q
XIT ;
D XIT^BNIGVL1
XIT1 ;
D XIT1^BNIGVL1
Q
ADD ;EP
K BNIGCAND
W !!
I $D(BNIGNCAN) G ADD1
I $D(BNIGSEAT),'$D(BNIGEP1) G ADD1
S DIR(0)="Y",DIR("A")="Do you want to use a PREVIOUSLY DEFINED REPORT",DIR("B")="N" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
I $D(DIRUT) S BNIGQUIT=1 Q
I 'Y G ADD1
S DIC="^BNIRTMP(",DIC("S")="I $P(^(0),U,2)&($P(^(0),U,6)=BNIGPTVS)" S:$D(BNIGEP1) DIC("S")=DIC("S")_"&($P(^(0),U,9)=BNIGPACK)" S DIC(0)="AEQ",DIC("A")="REPORT NAME: ",D="C" D IX^DIC K DIC,DA,DR
I Y=-1 S BNIGQUIT=1 Q
S BNIGRPT=+Y,BNIGCAND=1
;--- set up sorting and report control variables
S BNIGSORT=$P(^BNIRTMP(BNIGRPT,0),U,7),BNIGSORV=$P(^(0),U,8),BNIGSPAG=$P(^(0),U,4),BNIGCTYP=$P(^(0),U,5)
S X=0 F S X=$O(^BNIRTMP(BNIGRPT,12,X)) Q:X'=+X S BNIGTCW=BNIGTCW+$P(^BNIRTMP(BNIGRPT,12,X,0),U,2)+2
Q
ADD1 ;
;CREATE REPORT ENTRY IN FILEMAN FILE
S %H=$H D YX^%DTC S X=$P(^VA(200,DUZ,0),U)_"-"_Y,DIC(0)="L",DIC="^BNIRTMP(",DLAYGO=90512.88,DIADD=1,DIC("DR")=".13////"_DUZ D ^DIC K DIC,DA,DR,DIADD,DLAYGO I Y=-1 W !!,"UNABLE TO CREATE REPORT ENTRY - NOTIFY SITE MANAGER!" S BNIGQUIT=1 Q
S BNIGRPT=+Y
K DIC,DIADD,DLAYGO,DR,DA,DD,X,Y,DINUM
;DELETE ALL 11 MULTIPLE HERE
K ^BNIRTMP(BNIGRPT,11)
Q
INFORM ;EP
S BNIGTCW=0
W:$D(IOF) @IOF
W !,$$CTR($$LOC(),80),!
W $$CTR($$USR(),80)
W !!,$$CTR("CPHAD GENERAL RETRIEVAL PROGRAM",80),!
S T="INTRO" F J=1:1 S X=$T(@T+J),X=$P(X,";;",2) Q:X="END" W !,X
K J,X,T
Q
;
INTRO ;
;;This is the general retrieval program for the Computerized Public
;;Health Activity Data System (CPHAD).
;;END
Q
PAUSE ;EP
Q:$E(IOST)'="C"!(IO'=IO(0))
W ! S DIR(0)="EO",DIR("A")="Hit return to continue...." D ^DIR K DIR S:$D(DUOUT) DIRUT=1
Q
;
CTR(X,Y) ;EP - Center X in a field Y wide.
Q $J("",$S($D(Y):Y,1:IOM)-$L(X)\2)_X
;----------
EOP ;EP - End of page.
Q:$E(IOST)'="C"
Q:$D(ZTQUEUED)!'(IOT="TRM")!$D(IO("S"))
NEW DIR
K DIRUT,DFOUT,DLOUT,DTOUT,DUOUT
S DIR(0)="E" D ^DIR
Q
;----------
USR() ;EP - Return name of current user from ^VA(200.
Q $S($G(DUZ):$S($D(^VA(200,DUZ,0)):$P(^(0),U),1:"UNKNOWN"),1:"DUZ UNDEFINED OR 0")
;----------
LOC() ;EP - Return location name from file 4 based on DUZ(2).
Q $S($G(DUZ(2)):$S($D(^DIC(4,DUZ(2),0)):$P(^(0),U),1:"UNKNOWN"),1:"DUZ(2) UNDEFINED OR 0")
;----------
;
TEST ;
D BDMG(3030101,3060601,17)
Q
BDMG(BNIGBD,BNIGED,BNIGRPT,BNIGTITL) ;PEP - gui call
I $G(BNIGBD)="" S BNIIEN=-1 Q
I $G(BNIGED)="" S BNIIEN=-1 Q
I $G(BNIGRPT)="" S BNIIEN=-1 Q
S BNIGTITL=$G(BNIGTITL)
;create entry in fileman file to hold output
S BNIGUI=1
N BNIOPT ;maw
S BNIOPT="CPHAD GENERAL RETRIEVAL"
S BNIGPTVS="R"
S (BNIGPCNT,BNIGPTCT)=0
K BNIGTYPE ;--- just in case variable left around
S BNIGTYPE="RS"
S BNIGBDD=$$FMTE^XLFDT(BNIGBD),BNIGEDD=$$FMTE^XLFDT(BNIGED)
S BNIGSORT=$P(^BNIRTMP(BNIGRPT,0),U,7),BNIGSORV=$P(^(0),U,8),BNIGSPAG=$P(^(0),U,4),BNIGCTYP=$P(^(0),U,5)
I BNIGCTYP="T" S BNIGSORT=1,BNIGSORV="Activity Date"
S X=0,BNIGTCW=0 F S X=$O(^BNIRTMP(BNIGRPT,12,X)) Q:X'=+X S BNIGTCW=BNIGTCW+$P(^BNIRTMP(BNIGRPT,12,X,0),U,2)+2
D NOW^%DTC
S BNINOW=$G(%)
K DD,D0,DIC,DIR
S X=$J_"."_$H
S DIC("DR")=".02////"_DUZ_";.03////"_BNINOW_";.05////"_BNIOPT_";.06///R;.07///"_$S(BNIGCTYP="L":"D",1:"P")
S DIC="^BNIGUI(",DIC(0)="L",DIADD=1,DLAYGO=90512.08
D FILE^DICN
K DIADD,DLAYGO,DIC,DA
I Y=-1 S BNIIEN=-1 Q
S BNIIEN=+Y
S BDMGIEN=BNIIEN ;cmi/maw added
D ^XBFMK
K ZTSAVE S ZTSAVE("*")=""
;D GUIEP ;for interactive testing
S ZTIO="",ZTDTH=$$NOW^XLFDT,ZTRTN="GUIEP^BNIGVL",ZTDESC="GUI CPHAD GEN RETRIEVAL" D ^%ZTLOAD
D XIT
Q
GUIEP ;EP - called from taskman
D ^BNIGVL1
K ^TMP($J,"BNIGVL")
S IOM=80 ;cmi/maw added
D GUIR^XBLM("^BNIGVLP","^TMP($J,""BNIGVL"",")
Q:$G(BNIDSP) ;quit if to screen
S X=0,C=0 F S X=$O(^TMP($J,"BNIGVL",X)) Q:X'=+X D
.S BNIDATA=^TMP($J,"BNIGVL",X)
.I BNIDATA="ZZZZZZZ" S BNIDATA=$C(12)
.S ^BNIGUI(BNIIEN,11,X,0)=BNIDATA,C=C+1
S ^BNIGUI(BNIIEN,11,0)="^^"_C_"^"_C_"^"_DT_"^"
S DA=BNIIEN,DIK="^BNIGUI(" D IX1^DIK
D ENDLOG
K ^TMP($J,"BNIGVL")
S ZTREQ="@"
Q
;
ENDLOG ;-- write the end of the log
D NOW^%DTC
S BNINOW=$G(%)
S DIE="^BNIGUI(",DA=BNIIEN,DR=".04////"_BNINOW_";.06////C"
D ^DIE
K DIE,DR,DA
Q
;
BNIGVL ; IHS/CMI/LAB - bni general retrieval ;
+1 ;;1.0;BNI CPHD ACTIVITY DATASYSTEM;;DEC 20, 2006
+2 ;visit general retrieval
START ;
+1 KILL BNIGQUIT,BNIGDTR
+2 DO XIT
+3 DO INFORM
+4 SET BNIGPTVS="R"
TYPE ;--- get type of report
+1 SET (BNIGPCNT,BNIGPTCT)=0
+2 ;--- just in case variable left around
KILL BNIGTYPE
+3 SET BNIGTYPE="RS"
+4 DO @BNIGTYPE
DO XIT
+5 QUIT
RS ;
+1 SET BNIIOSL=$SELECT($GET(BNIGUI):55,1:$GET(IOSL))
GETDATES ;
+1 SET BNIGLHDR="DATE RANGE SELECTION"
WRITE !!?((80-$LENGTH(BNIGLHDR))/2),BNIGLHDR
GETDATE1 ;
BD ;get beginning date
+1 WRITE !
+2 SET BNIGBD=""
+3 SET DIR(0)="FO^6:7"
SET DIR("A")="Enter Beginning Month (e.g. 01/2006)"
SET DIR("?")="Enter a month and 4 digit year in the following format: 1/1999, 01/2000. The slash is required between the month and year. Date must be in the past."
+4 KILL DA
DO ^DIR
KILL DIR
+5 IF $DATA(DIRUT)
QUIT
+6 IF X=""
QUIT
+7 IF Y'?1.2N1"/"4N
WRITE !,"Enter the month/4 digit year in the format 03/2005. Slash is required and ",!,"4 digit year is required.",!
GOTO BD
+8 KILL %DT
SET X=Y
SET %DT="EP"
DO ^%DT
+9 IF Y=-1
WRITE !!,"Enter a month and 4 digit year. Date must be in the past. E.g. 04/2005 or 01/2000."
GOTO BD
+10 IF Y>DT
WRITE !!,"No future dates allowed!",!
GOTO BD
+11 SET BNIGBD=Y
ED ;get ending date
+1 WRITE !
+2 SET BNIGED=""
+3 SET DIR(0)="FO^6:7"
SET DIR("A")="Enter Ending Month (e.g. 01/2006)"
SET DIR("?")="Enter a month and 4 digit year in the following format: 1/1999, 01/2000. The slash is required between the month and year. Date must be in the past."
+4 KILL DA
DO ^DIR
KILL DIR
+5 IF $DATA(DIRUT)
QUIT
+6 IF X=""
QUIT
+7 IF Y'?1.2N1"/"4N
WRITE !,"Enter the month/4 digit year in the format 03/2005. Slash is required and ",!,"4 digit year is required.",!
GOTO ED
+8 KILL %DT
SET X=Y
SET %DT="EP"
DO ^%DT
+9 IF Y=-1
WRITE !!,"Enter a month and 4 digit year. Date must be in the past. E.g. 04/2005 or 01/2000."
GOTO ED
+10 IF Y>DT
WRITE !!,"No future dates allowed!",!
GOTO ED
+11 SET BNIGED=Y
+12 SET BNIGBDD=$$FMTE^XLFDT(BNIGBD)
SET BNIGEDD=$$FMTE^XLFDT(BNIGED)
+13 IF $DATA(BNIGDTR)
QUIT
+14 DO ADD
IF $DATA(BNIGQUIT)
DO DEL
KILL BNIGQUIT
GOTO RS
+15 IF '$DATA(BNIGCAND)
DO D1
QUIT
+16 DO TITLE
IF $DATA(BNIGQUIT)
KILL BNIGQUIT
GOTO TYPE
+17 DO ZIS
+18 QUIT
D1 ;if visit, no prev defined report used
D11 KILL ^BNIRTMP(BNIGRPT,11)
DO SCREEN
IF $DATA(BNIGQUIT)
KILL BNIGQUIT
DO DEL
GOTO RS
D12 KILL ^BNIRTMP(BNIGRPT,12)
SET BNIGTCW=0
DO COUNT
IF $DATA(BNIGQUIT)
KILL BNIGQUIT
GOTO D11
D13 DO TITLE
IF $DATA(BNIGQUIT)
KILL BNIGQUIT
GOTO D12
+1 DO SAVE
DO ZIS
+2 QUIT
SCREEN ;
+1 SET BNIGCNTL="S"
+2 DO ^BNIGVL4
+3 QUIT
COUNT ;count only or detailed report
BN DO COUNT^BNIGVL3
+1 QUIT
TITLE ;
+1 DO TITLE^BNIGVL3
+2 QUIT
SAVE ;
+1 DO SAVE^BNIGVL3
+2 QUIT
ZIS ;call to XBDBQUE
+1 KILL BNIGOPT
+2 IF 'BNIGTCW
SET BNIGTCW=IOM
+3 SET BNIGDONE=""
+4 DO SHOW^BNIGVLS
DO SHOWP^BNIGVLS
DO SHOWR^BNIGVLS
+5 DO XIT1
+6 IF BNIGCTYP="D"!(BNIGCTYP="S")
Begin DoDot:1
+7 SET DIR(0)="S^P:PRINT Output;B:BROWSE Output on Screen"
SET DIR("A")="Do you wish to "
SET DIR("B")="P"
KILL DA
DO ^DIR
KILL DIR
+8 IF $DATA(DIRUT)
SET BNIGQUIT=""
QUIT
+9 SET BNIGOPT=Y
End DoDot:1
+10 IF $GET(BNIGQUIT)
GOTO SAVE
+11 IF $GET(BNIGOPT)="B"
DO BROWSE
DO XIT
QUIT
+12 SET XBRP="^BNIGVLP"
SET XBRC="^BNIGVL1"
SET XBRX="XIT^BNIGVL"
SET XBNS="BNIG"
+13 DO ^XBDBQUE
+14 DO XIT
+15 QUIT
DEL ;EP DELETE LOG ENTRY IF ONE EXISTS AND USER "^" OUT
+1 IF $GET(BNIGRPT)
IF $DATA(^BNIRTMP(BNIGRPT,0))
IF '$PIECE(^BNIRTMP(BNIGRPT,0),U,2)
SET DIK="^BNIRTMP("
SET DA=BNIGRPT
DO ^DIK
KILL DIK,DA,DIC
+2 QUIT
BROWSE ;
+1 SET XBRP="VIEWR^XBLM(""^BNIGVLP"")"
+2 SET XBRC="^BNIGVL1"
SET XBRX="XIT^BNIGVL"
SET XBIOP=0
DO ^XBDBQUE
+3 QUIT
XIT ;
+1 DO XIT^BNIGVL1
XIT1 ;
+1 DO XIT1^BNIGVL1
+2 QUIT
ADD ;EP
+1 KILL BNIGCAND
+2 WRITE !!
+3 IF $DATA(BNIGNCAN)
GOTO ADD1
+4 IF $DATA(BNIGSEAT)
IF '$DATA(BNIGEP1)
GOTO ADD1
+5 SET DIR(0)="Y"
SET DIR("A")="Do you want to use a PREVIOUSLY DEFINED REPORT"
SET DIR("B")="N"
DO ^DIR
KILL DIR
IF $DATA(DUOUT)
SET DIRUT=1
+6 IF $DATA(DIRUT)
SET BNIGQUIT=1
QUIT
+7 IF 'Y
GOTO ADD1
+8 SET DIC="^BNIRTMP("
SET DIC("S")="I $P(^(0),U,2)&($P(^(0),U,6)=BNIGPTVS)"
IF $DATA(BNIGEP1)
SET DIC("S")=DIC("S")_"&($P(^(0),U,9)=BNIGPACK)"
SET DIC(0)="AEQ"
SET DIC("A")="REPORT NAME: "
SET D="C"
DO IX^DIC
KILL DIC,DA,DR
+9 IF Y=-1
SET BNIGQUIT=1
QUIT
+10 SET BNIGRPT=+Y
SET BNIGCAND=1
+11 ;--- set up sorting and report control variables
+12 SET BNIGSORT=$PIECE(^BNIRTMP(BNIGRPT,0),U,7)
SET BNIGSORV=$PIECE(^(0),U,8)
SET BNIGSPAG=$PIECE(^(0),U,4)
SET BNIGCTYP=$PIECE(^(0),U,5)
+13 SET X=0
FOR
SET X=$ORDER(^BNIRTMP(BNIGRPT,12,X))
IF X'=+X
QUIT
SET BNIGTCW=BNIGTCW+$PIECE(^BNIRTMP(BNIGRPT,12,X,0),U,2)+2
+14 QUIT
ADD1 ;
+1 ;CREATE REPORT ENTRY IN FILEMAN FILE
+2 SET %H=$HOROLOG
DO YX^%DTC
SET X=$PIECE(^VA(200,DUZ,0),U)_"-"_Y
SET DIC(0)="L"
SET DIC="^BNIRTMP("
SET DLAYGO=90512.88
SET DIADD=1
SET DIC("DR")=".13////"_DUZ
DO ^DIC
KILL DIC,DA,DR,DIADD,DLAYGO
IF Y=-1
WRITE !!,"UNABLE TO CREATE REPORT ENTRY - NOTIFY SITE MANAGER!"
SET BNIGQUIT=1
QUIT
+3 SET BNIGRPT=+Y
+4 KILL DIC,DIADD,DLAYGO,DR,DA,DD,X,Y,DINUM
+5 ;DELETE ALL 11 MULTIPLE HERE
+6 KILL ^BNIRTMP(BNIGRPT,11)
+7 QUIT
INFORM ;EP
+1 SET BNIGTCW=0
+2 IF $DATA(IOF)
WRITE @IOF
+3 WRITE !,$$CTR($$LOC(),80),!
+4 WRITE $$CTR($$USR(),80)
+5 WRITE !!,$$CTR("CPHAD GENERAL RETRIEVAL PROGRAM",80),!
+6 SET T="INTRO"
FOR J=1:1
SET X=$TEXT(@T+J)
SET X=$PIECE(X,";;",2)
IF X="END"
QUIT
WRITE !,X
+7 KILL J,X,T
+8 QUIT
+9 ;
INTRO ;
+1 ;;This is the general retrieval program for the Computerized Public
+2 ;;Health Activity Data System (CPHAD).
+3 ;;END
+4 QUIT
PAUSE ;EP
+1 IF $EXTRACT(IOST)'="C"!(IO'=IO(0))
QUIT
+2 WRITE !
SET DIR(0)="EO"
SET DIR("A")="Hit return to continue...."
DO ^DIR
KILL DIR
IF $DATA(DUOUT)
SET DIRUT=1
+3 QUIT
+4 ;
CTR(X,Y) ;EP - Center X in a field Y wide.
+1 QUIT $JUSTIFY("",$SELECT($DATA(Y):Y,1:IOM)-$LENGTH(X)\2)_X
+2 ;----------
EOP ;EP - End of page.
+1 IF $EXTRACT(IOST)'="C"
QUIT
+2 IF $DATA(ZTQUEUED)!'(IOT="TRM")!$DATA(IO("S"))
QUIT
+3 NEW DIR
+4 KILL DIRUT,DFOUT,DLOUT,DTOUT,DUOUT
+5 SET DIR(0)="E"
DO ^DIR
+6 QUIT
+7 ;----------
USR() ;EP - Return name of current user from ^VA(200.
+1 QUIT $SELECT($GET(DUZ):$SELECT($DATA(^VA(200,DUZ,0)):$PIECE(^(0),U),1:"UNKNOWN"),1:"DUZ UNDEFINED OR 0")
+2 ;----------
LOC() ;EP - Return location name from file 4 based on DUZ(2).
+1 QUIT $SELECT($GET(DUZ(2)):$SELECT($DATA(^DIC(4,DUZ(2),0)):$PIECE(^(0),U),1:"UNKNOWN"),1:"DUZ(2) UNDEFINED OR 0")
+2 ;----------
+3 ;
TEST ;
+1 DO BDMG(3030101,3060601,17)
+2 QUIT
BDMG(BNIGBD,BNIGED,BNIGRPT,BNIGTITL) ;PEP - gui call
+1 IF $GET(BNIGBD)=""
SET BNIIEN=-1
QUIT
+2 IF $GET(BNIGED)=""
SET BNIIEN=-1
QUIT
+3 IF $GET(BNIGRPT)=""
SET BNIIEN=-1
QUIT
+4 SET BNIGTITL=$GET(BNIGTITL)
+5 ;create entry in fileman file to hold output
+6 SET BNIGUI=1
+7 ;maw
NEW BNIOPT
+8 SET BNIOPT="CPHAD GENERAL RETRIEVAL"
+9 SET BNIGPTVS="R"
+10 SET (BNIGPCNT,BNIGPTCT)=0
+11 ;--- just in case variable left around
KILL BNIGTYPE
+12 SET BNIGTYPE="RS"
+13 SET BNIGBDD=$$FMTE^XLFDT(BNIGBD)
SET BNIGEDD=$$FMTE^XLFDT(BNIGED)
+14 SET BNIGSORT=$PIECE(^BNIRTMP(BNIGRPT,0),U,7)
SET BNIGSORV=$PIECE(^(0),U,8)
SET BNIGSPAG=$PIECE(^(0),U,4)
SET BNIGCTYP=$PIECE(^(0),U,5)
+15 IF BNIGCTYP="T"
SET BNIGSORT=1
SET BNIGSORV="Activity Date"
+16 SET X=0
SET BNIGTCW=0
FOR
SET X=$ORDER(^BNIRTMP(BNIGRPT,12,X))
IF X'=+X
QUIT
SET BNIGTCW=BNIGTCW+$PIECE(^BNIRTMP(BNIGRPT,12,X,0),U,2)+2
+17 DO NOW^%DTC
+18 SET BNINOW=$GET(%)
+19 KILL DD,D0,DIC,DIR
+20 SET X=$JOB_"."_$HOROLOG
+21 SET DIC("DR")=".02////"_DUZ_";.03////"_BNINOW_";.05////"_BNIOPT_";.06///R;.07///"_$SELECT(BNIGCTYP="L":"D",1:"P")
+22 SET DIC="^BNIGUI("
SET DIC(0)="L"
SET DIADD=1
SET DLAYGO=90512.08
+23 DO FILE^DICN
+24 KILL DIADD,DLAYGO,DIC,DA
+25 IF Y=-1
SET BNIIEN=-1
QUIT
+26 SET BNIIEN=+Y
+27 ;cmi/maw added
SET BDMGIEN=BNIIEN
+28 DO ^XBFMK
+29 KILL ZTSAVE
SET ZTSAVE("*")=""
+30 ;D GUIEP ;for interactive testing
+31 SET ZTIO=""
SET ZTDTH=$$NOW^XLFDT
SET ZTRTN="GUIEP^BNIGVL"
SET ZTDESC="GUI CPHAD GEN RETRIEVAL"
DO ^%ZTLOAD
+32 DO XIT
+33 QUIT
GUIEP ;EP - called from taskman
+1 DO ^BNIGVL1
+2 KILL ^TMP($JOB,"BNIGVL")
+3 ;cmi/maw added
SET IOM=80
+4 DO GUIR^XBLM("^BNIGVLP","^TMP($J,""BNIGVL"",")
+5 ;quit if to screen
IF $GET(BNIDSP)
QUIT
+6 SET X=0
SET C=0
FOR
SET X=$ORDER(^TMP($JOB,"BNIGVL",X))
IF X'=+X
QUIT
Begin DoDot:1
+7 SET BNIDATA=^TMP($JOB,"BNIGVL",X)
+8 IF BNIDATA="ZZZZZZZ"
SET BNIDATA=$CHAR(12)
+9 SET ^BNIGUI(BNIIEN,11,X,0)=BNIDATA
SET C=C+1
End DoDot:1
+10 SET ^BNIGUI(BNIIEN,11,0)="^^"_C_"^"_C_"^"_DT_"^"
+11 SET DA=BNIIEN
SET DIK="^BNIGUI("
DO IX1^DIK
+12 DO ENDLOG
+13 KILL ^TMP($JOB,"BNIGVL")
+14 SET ZTREQ="@"
+15 QUIT
+16 ;
ENDLOG ;-- write the end of the log
+1 DO NOW^%DTC
+2 SET BNINOW=$GET(%)
+3 SET DIE="^BNIGUI("
SET DA=BNIIEN
SET DR=".04////"_BNINOW_";.06////C"
+4 DO ^DIE
+5 KILL DIE,DR,DA
+6 QUIT
+7 ;