- BRNRU ; IHS/OIT/LJF - ROI REPORTING UTILITY DRIVER
- ;;2.0;RELEASE OF INFO SYSTEM;*1*;APR 10, 2003
- ;IHS/OIT/LJF 10/19/2007 PATCH 1 Added this routine series and function to patch 1
- ; Main logic and code borrowed from PCC VGEN
- ;
- NEW BRNBD,BRNED,BRNBDD,BRNEDD,BRNQUIT,BRNPCNT,BRNDCNT,BRNPREV,BRNRPT,BRNSORT,X
- NEW BRNSORV,BRNSPAG,BRNCTYP,BRNTCW,BRNCNTL
- S (BRNPTCT,BRNPCNT,BRNRCNT)=0 ;BRNPCCT = # of patients; BRNRCNT = # of disclosures
- ;
- ;date range selection
- S X="DATE RANGE SELECTION" W !!?((80-$L(X))/2),X,!!
- BD ;get beginning date
- S BRNBD=$$READ^BRNU("D^:DT:DP","Enter Beginning Request Date for search") Q:BRNBD<1
- ;get ending date
- S BRNED=$$READ^BRNU("D^:DT:DP","Enter Ending Request Date for search") I BRNED<1 D BD Q
- S BRNED=BRNED_.2359
- S BRNBDD=$$FMTE^XLFDT(BRNBD,"D"),BRNEDD=$$FMTE^XLFDT(BRNED,"D") ;external format for dates
- ;
- ; use previous report or not
- S BRNPREV=0 D PREV ;check if a previous report will be used, if not create a temporary shell
- I $D(BRNQUIT) D DEL Q ;if user quit, delete any shell that was created
- I BRNPREV=0 D NEW Q ;if new, build report, select title and print device then quit
- ;
- D TITLE^BRNRU3 I $D(BRNQUIT) Q ;otherwise, update title for previously used report
- D ZIS ;call print device
- Q
- ;
- NEW ; prev defined report not used; build new one
- N1 K ^BRNRPT(BRNRPT,11) S BRNCNTL="S" D ^BRNRU2 I $D(BRNQUIT) D DEL Q ;ask screening questions
- N2 K ^BRNRPT(BRNRPT,12) S BRNTCW=0 D COUNT^BRNRU3 I $D(BRNQUIT) K BRNQUIT G N1 ;ask for type of report
- D TITLE^BRNRU3 I $D(BRNQUIT) K BRNQUIT G N2 ;select title for report
- D SAVE^BRNRU3,ZIS ;ask to save report and select print device
- Q
- ;
- PREV ;called to selelct previous report or create a new temporary one
- W !!
- S Y=$$READ^BRNU("Y","Do you want to use a PREVIOUSLY DEFINED REPORT","NO") I Y=0 D BUILD Q
- I Y'=1 S BRNQUIT=1 Q
- S DIC="^BRNRPT(",DIC("S")="I $P(^(0),U,2)",DIC(0)="AEQ",DIC("A")="REPORT NAME: ",D="C" D IX^DIC K DIC,DA,DR
- I Y=-1 S BRNQUIT=1 Q
- S BRNRPT=+Y,BRNPREV=1,BRNTCW=0
- ;--- set up sorting and report control variables
- S BRNSORT=$P(^BRNRPT(BRNRPT,0),U,7) ;sort item
- S BRNSORV=$P(^BRNRPT(BRNRPT,0),U,8) ;sort text
- S BRNSPAG=$P(^BRNRPT(BRNRPT,0),U,4) ;use separate pages?
- S BRNCTYP=$P(^BRNRPT(BRNRPT,0),U,5) ;report type (totals, subcounts, details)
- S $P(^BRNRPT(BRNRPT,13),U)=$G(BRNBD) ;reset beginning date
- S $P(^BRNRPT(BRNRPT,13),U,2)=$G(BRNED) ;reset ending date
- S X=0 F S X=$O(^BRNRPT(BRNRPT,12,X)) Q:X'=+X S BRNTCW=BRNTCW+$P(^BRNRPT(BRNRPT,12,X,0),U,2)+2 ;set right margin
- Q
- ;
- BUILD ;create new report entry
- S %H=$H D YX^%DTC S X=$P(^VA(200,DUZ,0),U)_"-"_Y
- S DIC(0)="L",DIC="^BRNRPT(",DLAYGO=90264.8,DIADD=1,DIC("DR")=".13////"_DUZ
- D ^DIC K DIC,DA,DR,DIADD,DLAYGO,DINUM
- I Y=-1 W !!,"UNABLE TO CREATE REPORT FILE ENTRY - NOTIFY SITE MANAGER!" S BRNQUIT=1 Q
- S BRNRPT=+Y
- K ^BRNRPT(BRNRPT,11) ;make sure 11 multiple is clean
- Q
- ;
- ZIS ;call to XBDBQUE to select print device
- K BRNOPT
- I 'BRNTCW S BRNTCW=IOM
- S BRNDONE=""
- D SHOW^BRNRUS,SHOWP^BRNRUS,SHOWR^BRNRUS ;show report summary
- D CLEAN ;clean up variables before continuing
- I $G(BRNBQC)=1 Q
- I BRNCTYP="D"!(BRNCTYP="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 BRNQUIT="" Q
- . S BRNOPT=Y
- G:$G(BRNQUIT) SAVE^BRNRU3
- I $G(BRNOPT)="B" D BROWSE,XIT Q
- S XBRP="^BRNRUP",XBRC="^BRNRU11",XBRX="XIT^BRNRU",XBNS="BRN"
- D ^XBDBQUE
- D XIT
- Q
- ;
- DEL ;EP Delete log entry inf one exists and user "^" out
- I $G(BRNRPT),$D(^BRNRPT(BRNRPT,0)),'$P(^BRNRPT(BRNRPT,0),U,2) S DIK="^BRNRPT(",DA=BRNRPT D ^DIK K DIK,DA,DIC
- Q
- ADD ;
- D ADD^BRNRU1
- Q
- ;
- BROWSE ;
- S XBRP="VIEWR^XBLM(""^BRNRUP"")"
- S XBRC="^BRNRU11",XBRX="XIT^BRNRU",XBIOP=0 D ^XBDBQUE
- Q
- ;
- XIT ;EP; called by XBDBQUE
- D EN^XBVK("BRN")
- K C,D,D0,DA,DIC,DD,DFN,DIADD,DLAYGO,DICR,DIE,DIK,DINUM,DIQ,DIR,DIRUT,DUOUT,DTOUT,DR,J,I,J,K,M,S,TS,X,Y,DIG,DIH,DIV,DQ,DDH
- ;
- CLEAN ; clean up variables not to be sent to XBDBQUE
- K BRNPREV
- Q
- BRNRU ; IHS/OIT/LJF - ROI REPORTING UTILITY DRIVER
- +1 ;;2.0;RELEASE OF INFO SYSTEM;*1*;APR 10, 2003
- +2 ;IHS/OIT/LJF 10/19/2007 PATCH 1 Added this routine series and function to patch 1
- +3 ; Main logic and code borrowed from PCC VGEN
- +4 ;
- +5 NEW BRNBD,BRNED,BRNBDD,BRNEDD,BRNQUIT,BRNPCNT,BRNDCNT,BRNPREV,BRNRPT,BRNSORT,X
- +6 NEW BRNSORV,BRNSPAG,BRNCTYP,BRNTCW,BRNCNTL
- +7 ;BRNPCCT = # of patients; BRNRCNT = # of disclosures
- SET (BRNPTCT,BRNPCNT,BRNRCNT)=0
- +8 ;
- +9 ;date range selection
- +10 SET X="DATE RANGE SELECTION"
- WRITE !!?((80-$LENGTH(X))/2),X,!!
- BD ;get beginning date
- +1 SET BRNBD=$$READ^BRNU("D^:DT:DP","Enter Beginning Request Date for search")
- IF BRNBD<1
- QUIT
- +2 ;get ending date
- +3 SET BRNED=$$READ^BRNU("D^:DT:DP","Enter Ending Request Date for search")
- IF BRNED<1
- DO BD
- QUIT
- +4 SET BRNED=BRNED_.2359
- +5 ;external format for dates
- SET BRNBDD=$$FMTE^XLFDT(BRNBD,"D")
- SET BRNEDD=$$FMTE^XLFDT(BRNED,"D")
- +6 ;
- +7 ; use previous report or not
- +8 ;check if a previous report will be used, if not create a temporary shell
- SET BRNPREV=0
- DO PREV
- +9 ;if user quit, delete any shell that was created
- IF $DATA(BRNQUIT)
- DO DEL
- QUIT
- +10 ;if new, build report, select title and print device then quit
- IF BRNPREV=0
- DO NEW
- QUIT
- +11 ;
- +12 ;otherwise, update title for previously used report
- DO TITLE^BRNRU3
- IF $DATA(BRNQUIT)
- QUIT
- +13 ;call print device
- DO ZIS
- +14 QUIT
- +15 ;
- NEW ; prev defined report not used; build new one
- N1 ;ask screening questions
- KILL ^BRNRPT(BRNRPT,11)
- SET BRNCNTL="S"
- DO ^BRNRU2
- IF $DATA(BRNQUIT)
- DO DEL
- QUIT
- N2 ;ask for type of report
- KILL ^BRNRPT(BRNRPT,12)
- SET BRNTCW=0
- DO COUNT^BRNRU3
- IF $DATA(BRNQUIT)
- KILL BRNQUIT
- GOTO N1
- +1 ;select title for report
- DO TITLE^BRNRU3
- IF $DATA(BRNQUIT)
- KILL BRNQUIT
- GOTO N2
- +2 ;ask to save report and select print device
- DO SAVE^BRNRU3
- DO ZIS
- +3 QUIT
- +4 ;
- PREV ;called to selelct previous report or create a new temporary one
- +1 WRITE !!
- +2 SET Y=$$READ^BRNU("Y","Do you want to use a PREVIOUSLY DEFINED REPORT","NO")
- IF Y=0
- DO BUILD
- QUIT
- +3 IF Y'=1
- SET BRNQUIT=1
- QUIT
- +4 SET DIC="^BRNRPT("
- SET DIC("S")="I $P(^(0),U,2)"
- SET DIC(0)="AEQ"
- SET DIC("A")="REPORT NAME: "
- SET D="C"
- DO IX^DIC
- KILL DIC,DA,DR
- +5 IF Y=-1
- SET BRNQUIT=1
- QUIT
- +6 SET BRNRPT=+Y
- SET BRNPREV=1
- SET BRNTCW=0
- +7 ;--- set up sorting and report control variables
- +8 ;sort item
- SET BRNSORT=$PIECE(^BRNRPT(BRNRPT,0),U,7)
- +9 ;sort text
- SET BRNSORV=$PIECE(^BRNRPT(BRNRPT,0),U,8)
- +10 ;use separate pages?
- SET BRNSPAG=$PIECE(^BRNRPT(BRNRPT,0),U,4)
- +11 ;report type (totals, subcounts, details)
- SET BRNCTYP=$PIECE(^BRNRPT(BRNRPT,0),U,5)
- +12 ;reset beginning date
- SET $PIECE(^BRNRPT(BRNRPT,13),U)=$GET(BRNBD)
- +13 ;reset ending date
- SET $PIECE(^BRNRPT(BRNRPT,13),U,2)=$GET(BRNED)
- +14 ;set right margin
- SET X=0
- FOR
- SET X=$ORDER(^BRNRPT(BRNRPT,12,X))
- IF X'=+X
- QUIT
- SET BRNTCW=BRNTCW+$PIECE(^BRNRPT(BRNRPT,12,X,0),U,2)+2
- +15 QUIT
- +16 ;
- BUILD ;create new report entry
- +1 SET %H=$HOROLOG
- DO YX^%DTC
- SET X=$PIECE(^VA(200,DUZ,0),U)_"-"_Y
- +2 SET DIC(0)="L"
- SET DIC="^BRNRPT("
- SET DLAYGO=90264.8
- SET DIADD=1
- SET DIC("DR")=".13////"_DUZ
- +3 DO ^DIC
- KILL DIC,DA,DR,DIADD,DLAYGO,DINUM
- +4 IF Y=-1
- WRITE !!,"UNABLE TO CREATE REPORT FILE ENTRY - NOTIFY SITE MANAGER!"
- SET BRNQUIT=1
- QUIT
- +5 SET BRNRPT=+Y
- +6 ;make sure 11 multiple is clean
- KILL ^BRNRPT(BRNRPT,11)
- +7 QUIT
- +8 ;
- ZIS ;call to XBDBQUE to select print device
- +1 KILL BRNOPT
- +2 IF 'BRNTCW
- SET BRNTCW=IOM
- +3 SET BRNDONE=""
- +4 ;show report summary
- DO SHOW^BRNRUS
- DO SHOWP^BRNRUS
- DO SHOWR^BRNRUS
- +5 ;clean up variables before continuing
- DO CLEAN
- +6 IF $GET(BRNBQC)=1
- QUIT
- +7 IF BRNCTYP="D"!(BRNCTYP="S")
- Begin DoDot:1
- +8 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
- +9 IF $DATA(DIRUT)
- SET BRNQUIT=""
- QUIT
- +10 SET BRNOPT=Y
- End DoDot:1
- +11 IF $GET(BRNQUIT)
- GOTO SAVE^BRNRU3
- +12 IF $GET(BRNOPT)="B"
- DO BROWSE
- DO XIT
- QUIT
- +13 SET XBRP="^BRNRUP"
- SET XBRC="^BRNRU11"
- SET XBRX="XIT^BRNRU"
- SET XBNS="BRN"
- +14 DO ^XBDBQUE
- +15 DO XIT
- +16 QUIT
- +17 ;
- DEL ;EP Delete log entry inf one exists and user "^" out
- +1 IF $GET(BRNRPT)
- IF $DATA(^BRNRPT(BRNRPT,0))
- IF '$PIECE(^BRNRPT(BRNRPT,0),U,2)
- SET DIK="^BRNRPT("
- SET DA=BRNRPT
- DO ^DIK
- KILL DIK,DA,DIC
- +2 QUIT
- ADD ;
- +1 DO ADD^BRNRU1
- +2 QUIT
- +3 ;
- BROWSE ;
- +1 SET XBRP="VIEWR^XBLM(""^BRNRUP"")"
- +2 SET XBRC="^BRNRU11"
- SET XBRX="XIT^BRNRU"
- SET XBIOP=0
- DO ^XBDBQUE
- +3 QUIT
- +4 ;
- XIT ;EP; called by XBDBQUE
- +1 DO EN^XBVK("BRN")
- +2 KILL C,D,D0,DA,DIC,DD,DFN,DIADD,DLAYGO,DICR,DIE,DIK,DINUM,DIQ,DIR,DIRUT,DUOUT,DTOUT,DR,J,I,J,K,M,S,TS,X,Y,DIG,DIH,DIV,DQ,DDH
- +3 ;
- CLEAN ; clean up variables not to be sent to XBDBQUE
- +1 KILL BRNPREV
- +2 QUIT