- BRNRU3 ; IHS/OIT/LJF - MISC REPORT LOGIC
- ;;2.0;RELEASE OF INFO SYSTEM;*1*;APR 10, 2003
- ;IHS/OIT/LJF 10/25/2007 PATCH 1 Added routine
- ;
- ;
- TITLE ;EP; Custom Title for report
- NEW Y,LENGTH,TITLE,DIE,DA,DR
- Q:"FTCP"[BRNCTYP
- S Y=$$READ^BRNU("Y","Would you like a custom title for this report","NO") Q:Y=0
- I Y=U S BRNQUIT=1 Q
- S LENGTH=$S(BRNTCW:BRNTCW-8,1:60)
- S TITLE=$$READ^BRNU("F^3:"_LENGTH,"Enter custom title",," Enter from 3 to "_LENGTH_" characters")
- I (Y=U)!(Y="") D TITLE Q
- S DIE=90264.8,DA=BRNRPT,DR="1303///"_TITLE D ^DIE
- Q
- ;
- SAVE ;EP; Ask user to save report logic
- Q:$D(BRNCAND) ;--- don't ask if already a pre-defined rpt
- Q:BRNCTYP'="D" ;--- must be a detailed report to be saved
- Q:'$$READ^BRNU("Y","Do you wish to SAVE this SEARCH/PRINT/SORT logic for future use","NO")
- ;
- NEW NAME,DIE,DR,DA
- S NAME=$$READ^BRNU("90264.8,.03","Enter NAME for this REPORT DEFINITION") Q:$L(NAME)<3
- S DIE="^BRNRPT(",DA=BRNRPT,DR=".02////1;.03///"_NAME_";.05///"_BRNCTYP D ^DIE
- Q
- ;
- COUNT ;EP; Counts and Subcount logic
- W !!
- S DIR(0)="S^T:Total Count Only;S:Sub-counts and Total Count;D:Detailed Listing;L:Delimited Output File for use in Excel"
- S DIR("A")=" Choose Type of Report",DIR("B")="D" D ^DIR K DIR W !!
- S:$D(DUOUT) DIRUT=1
- I $D(DIRUT) S BRNQUIT=1 Q
- S BRNCTYP=Y
- I BRNCTYP="T" S $P(^BRNRPT(BRNRPT,0),U,5)="T" S BRNSORT=1,BRNSORV="Patient Name" Q
- I BRNCTYP="D" D PRINT Q:$D(BRNQUIT) D SORT Q
- I BRNCTYP="L" D Q
- .W !!,"You have selected to create a delimited output file, you will be"
- .W !,"asked to select the print items, the sort item and then to name the"
- .W !,"output file.",!!
- .K DIR S DIR(0)="Y",DIR("A")="Do you wish to continue",DIR("B")="Y" KILL DA D ^DIR KILL DIR
- .I $D(DIRUT) S BRNQUIT=1 Q
- .I 'Y S BRNQUIT=1 Q
- .D PRINT Q:$D(BRNQUIT) S $P(^BRNRPT(BRNRPT,0),U,5)="F" D Q:$D(BRNQUIT)
- .D SORT
- .D DELIMIT
- .I BRNDELT="" S BRNQUIT=1
- Q:$G(BRNQUIT)
- D SORT
- Q
- ;
- PRINT ;
- S BRNCNTL="P"
- D ^BRNRU2
- Q
- ;
- SORT ;EP
- K BRNSORT,BRNSORV,BRNQUIT
- I BRNCTYP="D"!(BRNCTYP="L"),'$D(^BRNRPT(BRNRPT,12)) W !!,"NO PRINT FIELDS SELECTED!!",$C(7),$C(7) S BRNQUIT=1 Q
- S BRNSORT=""
- D SHOWR^BRNRUS
- S BRNCNTL="R" D ^BRNRU2 K BRNCNTL
- I '$D(BRNSORV) S BRNQUIT=1 Q
- Q:BRNCTYP'="D"
- PAGE ;
- K BRNSPAG
- Q:BRNCTYP'="D"
- S DIR(0)="Y",DIR("A")="Do you want a separate page for each "_BRNSORV,DIR("B")="N" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
- I $D(DIRUT) G SORT
- S BRNSPAG=Y,DIE="^BRNRPT(",DA=BRNRPT,DR=".04///"_BRNSPAG D ^DIE K DA,DR,DIE
- Q
- ;
- DELIMIT ;get filename for delimited output
- K BRNQUIT
- S BRNDELF="",BRNDELT=""
- W !!,"You have selected to create a '^' delimited output file. You can have this"
- W !,"output file created as a text file in the pub directory, "
- W !,"OR you can have the delimited output display on your screen so that"
- W !,"you can do a file capture. Keep in mind that if you choose to"
- W !,"do a screen capture you CANNOT Queue your report to run in the background!!",!!
- S DIR(0)="S^S:SCREEN - delimited output will display on screen for capture;F:FILE - delimited output will be written to a file in pub"
- S DIR("A")="Select output type",DIR("B")="S" KILL DA
- D ^DIR KILL DIR
- I $D(DIRUT) S BRNDELT="" Q
- S BRNDELT=Y
- Q:BRNDELT="S"
- S DIR(0)="F^1:40" W !,"Enter a filename for the delimited output (no more than 40 characters)"
- S DIR("A")="Filename" KILL DA D ^DIR KILL DIR
- I $D(DIRUT) G DELIMIT
- S BRNDELF=Y
- S BRNHDIR=$S($P($G(^AUTTSITE(1,1)),U,2)]"":$P(^AUTTSITE(1,1),U,2),1:$G(^XTV(8989.3,1,"DEV")))
- I $G(BRNHDIR)="" S BRNHDIR="/usr/spool/uucppublic/"
- W !!,"When the report is finished your delimited output will be found in the",!,BRNHDIR," directory. The filename will be ",BRNDELF,".txt",!
- Q
- BRNRU3 ; IHS/OIT/LJF - MISC REPORT LOGIC
- +1 ;;2.0;RELEASE OF INFO SYSTEM;*1*;APR 10, 2003
- +2 ;IHS/OIT/LJF 10/25/2007 PATCH 1 Added routine
- +3 ;
- +4 ;
- TITLE ;EP; Custom Title for report
- +1 NEW Y,LENGTH,TITLE,DIE,DA,DR
- +2 IF "FTCP"[BRNCTYP
- QUIT
- +3 SET Y=$$READ^BRNU("Y","Would you like a custom title for this report","NO")
- IF Y=0
- QUIT
- +4 IF Y=U
- SET BRNQUIT=1
- QUIT
- +5 SET LENGTH=$SELECT(BRNTCW:BRNTCW-8,1:60)
- +6 SET TITLE=$$READ^BRNU("F^3:"_LENGTH,"Enter custom title",," Enter from 3 to "_LENGTH_" characters")
- +7 IF (Y=U)!(Y="")
- DO TITLE
- QUIT
- +8 SET DIE=90264.8
- SET DA=BRNRPT
- SET DR="1303///"_TITLE
- DO ^DIE
- +9 QUIT
- +10 ;
- SAVE ;EP; Ask user to save report logic
- +1 ;--- don't ask if already a pre-defined rpt
- IF $DATA(BRNCAND)
- QUIT
- +2 ;--- must be a detailed report to be saved
- IF BRNCTYP'="D"
- QUIT
- +3 IF '$$READ^BRNU("Y","Do you wish to SAVE this SEARCH/PRINT/SORT logic for future use","NO")
- QUIT
- +4 ;
- +5 NEW NAME,DIE,DR,DA
- +6 SET NAME=$$READ^BRNU("90264.8,.03","Enter NAME for this REPORT DEFINITION")
- IF $LENGTH(NAME)<3
- QUIT
- +7 SET DIE="^BRNRPT("
- SET DA=BRNRPT
- SET DR=".02////1;.03///"_NAME_";.05///"_BRNCTYP
- DO ^DIE
- +8 QUIT
- +9 ;
- COUNT ;EP; Counts and Subcount logic
- +1 WRITE !!
- +2 SET DIR(0)="S^T:Total Count Only;S:Sub-counts and Total Count;D:Detailed Listing;L:Delimited Output File for use in Excel"
- +3 SET DIR("A")=" Choose Type of Report"
- SET DIR("B")="D"
- DO ^DIR
- KILL DIR
- WRITE !!
- +4 IF $DATA(DUOUT)
- SET DIRUT=1
- +5 IF $DATA(DIRUT)
- SET BRNQUIT=1
- QUIT
- +6 SET BRNCTYP=Y
- +7 IF BRNCTYP="T"
- SET $PIECE(^BRNRPT(BRNRPT,0),U,5)="T"
- SET BRNSORT=1
- SET BRNSORV="Patient Name"
- QUIT
- +8 IF BRNCTYP="D"
- DO PRINT
- IF $DATA(BRNQUIT)
- QUIT
- DO SORT
- QUIT
- +9 IF BRNCTYP="L"
- Begin DoDot:1
- +10 WRITE !!,"You have selected to create a delimited output file, you will be"
- +11 WRITE !,"asked to select the print items, the sort item and then to name the"
- +12 WRITE !,"output file.",!!
- +13 KILL DIR
- SET DIR(0)="Y"
- SET DIR("A")="Do you wish to continue"
- SET DIR("B")="Y"
- KILL DA
- DO ^DIR
- KILL DIR
- +14 IF $DATA(DIRUT)
- SET BRNQUIT=1
- QUIT
- +15 IF 'Y
- SET BRNQUIT=1
- QUIT
- +16 DO PRINT
- IF $DATA(BRNQUIT)
- QUIT
- SET $PIECE(^BRNRPT(BRNRPT,0),U,5)="F"
- Begin DoDot:2
- End DoDot:2
- IF $DATA(BRNQUIT)
- QUIT
- +17 DO SORT
- +18 DO DELIMIT
- +19 IF BRNDELT=""
- SET BRNQUIT=1
- End DoDot:1
- QUIT
- +20 IF $GET(BRNQUIT)
- QUIT
- +21 DO SORT
- +22 QUIT
- +23 ;
- PRINT ;
- +1 SET BRNCNTL="P"
- +2 DO ^BRNRU2
- +3 QUIT
- +4 ;
- SORT ;EP
- +1 KILL BRNSORT,BRNSORV,BRNQUIT
- +2 IF BRNCTYP="D"!(BRNCTYP="L")
- IF '$DATA(^BRNRPT(BRNRPT,12))
- WRITE !!,"NO PRINT FIELDS SELECTED!!",$CHAR(7),$CHAR(7)
- SET BRNQUIT=1
- QUIT
- +3 SET BRNSORT=""
- +4 DO SHOWR^BRNRUS
- +5 SET BRNCNTL="R"
- DO ^BRNRU2
- KILL BRNCNTL
- +6 IF '$DATA(BRNSORV)
- SET BRNQUIT=1
- QUIT
- +7 IF BRNCTYP'="D"
- QUIT
- PAGE ;
- +1 KILL BRNSPAG
- +2 IF BRNCTYP'="D"
- QUIT
- +3 SET DIR(0)="Y"
- SET DIR("A")="Do you want a separate page for each "_BRNSORV
- SET DIR("B")="N"
- DO ^DIR
- KILL DIR
- IF $DATA(DUOUT)
- SET DIRUT=1
- +4 IF $DATA(DIRUT)
- GOTO SORT
- +5 SET BRNSPAG=Y
- SET DIE="^BRNRPT("
- SET DA=BRNRPT
- SET DR=".04///"_BRNSPAG
- DO ^DIE
- KILL DA,DR,DIE
- +6 QUIT
- +7 ;
- DELIMIT ;get filename for delimited output
- +1 KILL BRNQUIT
- +2 SET BRNDELF=""
- SET BRNDELT=""
- +3 WRITE !!,"You have selected to create a '^' delimited output file. You can have this"
- +4 WRITE !,"output file created as a text file in the pub directory, "
- +5 WRITE !,"OR you can have the delimited output display on your screen so that"
- +6 WRITE !,"you can do a file capture. Keep in mind that if you choose to"
- +7 WRITE !,"do a screen capture you CANNOT Queue your report to run in the background!!",!!
- +8 SET DIR(0)="S^S:SCREEN - delimited output will display on screen for capture;F:FILE - delimited output will be written to a file in pub"
- +9 SET DIR("A")="Select output type"
- SET DIR("B")="S"
- KILL DA
- +10 DO ^DIR
- KILL DIR
- +11 IF $DATA(DIRUT)
- SET BRNDELT=""
- QUIT
- +12 SET BRNDELT=Y
- +13 IF BRNDELT="S"
- QUIT
- +14 SET DIR(0)="F^1:40"
- WRITE !,"Enter a filename for the delimited output (no more than 40 characters)"
- +15 SET DIR("A")="Filename"
- KILL DA
- DO ^DIR
- KILL DIR
- +16 IF $DATA(DIRUT)
- GOTO DELIMIT
- +17 SET BRNDELF=Y
- +18 SET BRNHDIR=$SELECT($PIECE($GET(^AUTTSITE(1,1)),U,2)]"":$PIECE(^AUTTSITE(1,1),U,2),1:$GET(^XTV(8989.3,1,"DEV")))
- +19 IF $GET(BRNHDIR)=""
- SET BRNHDIR="/usr/spool/uucppublic/"
- +20 WRITE !!,"When the report is finished your delimited output will be found in the",!,BRNHDIR," directory. The filename will be ",BRNDELF,".txt",!
- +21 QUIT