BRNRUP3 ; IHS/OIT/LJF - CONTINUED REPORT UTILITY PRINT LOGIC
;;2.0;RELEASE OF INFO SYSTEM;*1*;APR 10, 2003
;IHS/OIT/LJF 10/25/2007 PATCH 1 Added this routine
;
DELIMIT ;EP - Set up header line, dash line for delimited output
S BRNFCNT=0
K ^TMP($J,"BRNDELIMITED")
S BRNDELC=0,BRNPIEC=0
S BRNHDR="PATIENT IEN"_U_"REQUEST IEN",BRNPIEC=2
S X=0,BRNHEAD="" F S X=$O(^BRNRPT(BRNRPT,12,X)) Q:X'=+X D
. S BRNPIEC=BRNPIEC+1
. S H=$P(^BRNSORT($P(^BRNRPT(BRNRPT,12,X,0),U),0),U,6)
. S $P(BRNHDR,U,BRNPIEC)=H
;
D COVPAGE^BRNRUP1 ;print cover page - note: if user ^'s out of cover page, processing continues
;
PROC ;process printing of report
I BRNDELT="F" D OPEN Q:Y=1
W !,BRNHDR,!
I '$D(^XTMP("BRNVL",BRNJOB,BRNBTH)) W !,"NO DATA TO REPORT" G DONE
S (BRNSRTV,BRNFRST)="" K BRNQUIT
F S BRNSRTV=$O(^XTMP("BRNVL",BRNJOB,BRNBTH,"DATA HITS",BRNSRTV)) Q:BRNSRTV=""!($D(BRNQUIT)) D V
DONE ;
;write out delimited file
I BRNDELT="F" D ^%ZISC
K ^XTMP("BRNVL",BRNJOB,BRNBT),^XTMP("BRNFLAT",$J),^TMP($J,"BRNDELIMITED")
D DEL^BRNRU
D EN^XBVK("BRN"),EN^XBVK("VALM")
Q
V ;GETS DATA HITS
S BRNCNT=0
;get readable sort value
K BRNPRNT
S BRNSRTR="",BRNVIEN=$O(^XTMP("BRNVL",BRNJOB,BRNBTH,"DATA HITS",BRNSRTV,0)) I BRNVIEN]"" S BRNCRIT=BRNSORT D
. S BRNVREC=^BRNREC(BRNVIEN,0),DFN=$P(BRNVREC,U,3) X:$D(^BRNSORT(BRNSORT,3)) ^(3) S BRNSRTR=BRNPRNT
K BRNFRST
S BRNVIEN=0 F S BRNVIEN=$O(^XTMP("BRNVL",BRNJOB,BRNBTH,"DATA HITS",BRNSRTV,BRNVIEN)) Q:BRNVIEN'=+BRNVIEN!($D(BRNQUIT)) D
. S BRNVREC=^BRNREC(BRNVIEN,0),DFN=$P(BRNVREC,U,3) D PRINT Q
;
Q
PRINT ;
K ^XTMP("BRNLINE",$J) S ^XTMP("BRNLINE",$J,1)=""
K BRNDELD
S BRNPIEC=0,BRNLINE=1,BRNCNT=BRNCNT+1
S BRNDELD(1,"S")=DFN,BRNDELD(2,"S")=BRNVIEN,BRNPIEC=2
S BRNI=0 F S BRNI=$O(^BRNRPT(BRNRPT,12,BRNI)) Q:BRNI'=+BRNI!($D(BRNQUIT)) S BRNCRIT=$P(^BRNRPT(BRNRPT,12,BRNI,0),U) D
. S BRNPIEC=BRNPIEC+1
. I '$P(^BRNSORT(BRNCRIT,0),U,8) D SINGLE Q
. D MULT
;
K BRNDELP
F X=1:1:BRNLINE D
. S BRNCNT=BRNCNT+1
. F P=1:1:BRNPIEC D
. . S V=$O(BRNDELD(P,""))
. . I V="S" S D=BRNDELD(P,V),$P(BRNDELP(BRNCNT),U,P)=D
. . I V="M" S D=$S($P(BRNDELD(P,V),"|",X)]"":$P(BRNDELD(P,V),"|",X),1:"--"),$P(BRNDELP(BRNCNT),U,P)=D
S X=0 F S X=$O(BRNDELP(X)) Q:X'=+X W BRNDELP(X),!
Q
;
SINGLE ;process single valued item
K BRNPRNT
S BRNX=0
X:$D(^BRNSORT(BRNCRIT,3)) ^(3)
I BRNPRNT="" S BRNPRNT="--"
S BRNDELD(BRNPIEC,"S")=BRNPRNT
Q
;
MULT ;process multiple valued item
K BRNPRNT,BRNPRNM,BRNY S (BRNX,BRNPCNT)=0
X:$D(^BRNSORT(BRNCRIT,3)) ^(3)
;if 13th, then $o through delete bad ones and then reorder/number
;new logic here to screen if user wants to screen
I $P(^BRNRPT(BRNRPT,12,BRNI,0),U,3) D
.;does this one match selected ones?
. S X=0 F S X=$O(BRNPRNM(X)) Q:X'=+X D
. . S Z=$G(BRNPRNM(X,"I")) I Z="" K BRNPRNM(X) Q
. . I '$D(^BRNRPT(BRNRPT,11,BRNCRIT,11,"B",Z)) K BRNPRNM(X)
K Y S (X,C)=0 F S X=$O(BRNPRNM(X)) Q:X'=+X S C=C+1,Y(C)=BRNPRNM(X)
I C>BRNLINE S BRNLINE=C
K BRNPRNM S X=0 F S X=$O(Y(X)) Q:X'=+X S BRNPRNM(X)=Y(X)
I '$D(BRNPRNM) S BRNPRNT="--" D
. S BRNDELD(BRNPIEC,"M")=BRNPRNT
S X=0 F S X=$O(BRNPRNM(X)) Q:X'=+X D
. S $P(BRNDELD(BRNPIEC,"M"),"|",X)=BRNPRNM(X)
Q
;
DIQ ;
K BRNPRNT,BRNFILE,BRNFIEL
S BRNFILE=$P($P(^BRNSORT(BRNCRIT,0),U,4),","),BRNFIEL=$P($P(^(0),U,4),",",2)
S DIQ(0)="EN",DIQ="BRNPRNT(",DIC=BRNFILE,DR=BRNFIEL D EN^DIQ1 K DIC,DR,DIQ
I '$D(BRNPRNT(BRNFILE,DA,BRNFIEL,"E")) S BRNPRNT(BRNFILE,DA,BRNFIEL,"E")="--"
S BRNPRNT=BRNPRNT(BRNFILE,DA,BRNFIEL,"E")
Q
OPEN ;write flat file from global
;if screen selected do screen
;USE GS FROM GPRA TO OPEN AND WRITE FILE
S Y=$$OPEN^%ZISH(BRNHDIR,BRNDELF,"W")
I Y=1 W:'$D(ZTQUEUED) !!,"Cannot open host file to write out DELIMITED data. Notify programmer." Q
U IO
Q
BRNRUP3 ; IHS/OIT/LJF - CONTINUED REPORT UTILITY PRINT LOGIC
+1 ;;2.0;RELEASE OF INFO SYSTEM;*1*;APR 10, 2003
+2 ;IHS/OIT/LJF 10/25/2007 PATCH 1 Added this routine
+3 ;
DELIMIT ;EP - Set up header line, dash line for delimited output
+1 SET BRNFCNT=0
+2 KILL ^TMP($JOB,"BRNDELIMITED")
+3 SET BRNDELC=0
SET BRNPIEC=0
+4 SET BRNHDR="PATIENT IEN"_U_"REQUEST IEN"
SET BRNPIEC=2
+5 SET X=0
SET BRNHEAD=""
FOR
SET X=$ORDER(^BRNRPT(BRNRPT,12,X))
IF X'=+X
QUIT
Begin DoDot:1
+6 SET BRNPIEC=BRNPIEC+1
+7 SET H=$PIECE(^BRNSORT($PIECE(^BRNRPT(BRNRPT,12,X,0),U),0),U,6)
+8 SET $PIECE(BRNHDR,U,BRNPIEC)=H
End DoDot:1
+9 ;
+10 ;print cover page - note: if user ^'s out of cover page, processing continues
DO COVPAGE^BRNRUP1
+11 ;
PROC ;process printing of report
+1 IF BRNDELT="F"
DO OPEN
IF Y=1
QUIT
+2 WRITE !,BRNHDR,!
+3 IF '$DATA(^XTMP("BRNVL",BRNJOB,BRNBTH))
WRITE !,"NO DATA TO REPORT"
GOTO DONE
+4 SET (BRNSRTV,BRNFRST)=""
KILL BRNQUIT
+5 FOR
SET BRNSRTV=$ORDER(^XTMP("BRNVL",BRNJOB,BRNBTH,"DATA HITS",BRNSRTV))
IF BRNSRTV=""!($DATA(BRNQUIT))
QUIT
DO V
DONE ;
+1 ;write out delimited file
+2 IF BRNDELT="F"
DO ^%ZISC
+3 KILL ^XTMP("BRNVL",BRNJOB,BRNBT),^XTMP("BRNFLAT",$JOB),^TMP($JOB,"BRNDELIMITED")
+4 DO DEL^BRNRU
+5 DO EN^XBVK("BRN")
DO EN^XBVK("VALM")
+6 QUIT
V ;GETS DATA HITS
+1 SET BRNCNT=0
+2 ;get readable sort value
+3 KILL BRNPRNT
+4 SET BRNSRTR=""
SET BRNVIEN=$ORDER(^XTMP("BRNVL",BRNJOB,BRNBTH,"DATA HITS",BRNSRTV,0))
IF BRNVIEN]""
SET BRNCRIT=BRNSORT
Begin DoDot:1
+5 SET BRNVREC=^BRNREC(BRNVIEN,0)
SET DFN=$PIECE(BRNVREC,U,3)
IF $DATA(^BRNSORT(BRNSORT,3))
XECUTE ^(3)
SET BRNSRTR=BRNPRNT
End DoDot:1
+6 KILL BRNFRST
+7 SET BRNVIEN=0
FOR
SET BRNVIEN=$ORDER(^XTMP("BRNVL",BRNJOB,BRNBTH,"DATA HITS",BRNSRTV,BRNVIEN))
IF BRNVIEN'=+BRNVIEN!($DATA(BRNQUIT))
QUIT
Begin DoDot:1
+8 SET BRNVREC=^BRNREC(BRNVIEN,0)
SET DFN=$PIECE(BRNVREC,U,3)
DO PRINT
QUIT
End DoDot:1
+9 ;
+10 QUIT
PRINT ;
+1 KILL ^XTMP("BRNLINE",$JOB)
SET ^XTMP("BRNLINE",$JOB,1)=""
+2 KILL BRNDELD
+3 SET BRNPIEC=0
SET BRNLINE=1
SET BRNCNT=BRNCNT+1
+4 SET BRNDELD(1,"S")=DFN
SET BRNDELD(2,"S")=BRNVIEN
SET BRNPIEC=2
+5 SET BRNI=0
FOR
SET BRNI=$ORDER(^BRNRPT(BRNRPT,12,BRNI))
IF BRNI'=+BRNI!($DATA(BRNQUIT))
QUIT
SET BRNCRIT=$PIECE(^BRNRPT(BRNRPT,12,BRNI,0),U)
Begin DoDot:1
+6 SET BRNPIEC=BRNPIEC+1
+7 IF '$PIECE(^BRNSORT(BRNCRIT,0),U,8)
DO SINGLE
QUIT
+8 DO MULT
End DoDot:1
+9 ;
+10 KILL BRNDELP
+11 FOR X=1:1:BRNLINE
Begin DoDot:1
+12 SET BRNCNT=BRNCNT+1
+13 FOR P=1:1:BRNPIEC
Begin DoDot:2
+14 SET V=$ORDER(BRNDELD(P,""))
+15 IF V="S"
SET D=BRNDELD(P,V)
SET $PIECE(BRNDELP(BRNCNT),U,P)=D
+16 IF V="M"
SET D=$SELECT($PIECE(BRNDELD(P,V),"|",X)]"":$PIECE(BRNDELD(P,V),"|",X),1:"--")
SET $PIECE(BRNDELP(BRNCNT),U,P)=D
End DoDot:2
End DoDot:1
+17 SET X=0
FOR
SET X=$ORDER(BRNDELP(X))
IF X'=+X
QUIT
WRITE BRNDELP(X),!
+18 QUIT
+19 ;
SINGLE ;process single valued item
+1 KILL BRNPRNT
+2 SET BRNX=0
+3 IF $DATA(^BRNSORT(BRNCRIT,3))
XECUTE ^(3)
+4 IF BRNPRNT=""
SET BRNPRNT="--"
+5 SET BRNDELD(BRNPIEC,"S")=BRNPRNT
+6 QUIT
+7 ;
MULT ;process multiple valued item
+1 KILL BRNPRNT,BRNPRNM,BRNY
SET (BRNX,BRNPCNT)=0
+2 IF $DATA(^BRNSORT(BRNCRIT,3))
XECUTE ^(3)
+3 ;if 13th, then $o through delete bad ones and then reorder/number
+4 ;new logic here to screen if user wants to screen
+5 IF $PIECE(^BRNRPT(BRNRPT,12,BRNI,0),U,3)
Begin DoDot:1
+6 ;does this one match selected ones?
+7 SET X=0
FOR
SET X=$ORDER(BRNPRNM(X))
IF X'=+X
QUIT
Begin DoDot:2
+8 SET Z=$GET(BRNPRNM(X,"I"))
IF Z=""
KILL BRNPRNM(X)
QUIT
+9 IF '$DATA(^BRNRPT(BRNRPT,11,BRNCRIT,11,"B",Z))
KILL BRNPRNM(X)
End DoDot:2
End DoDot:1
+10 KILL Y
SET (X,C)=0
FOR
SET X=$ORDER(BRNPRNM(X))
IF X'=+X
QUIT
SET C=C+1
SET Y(C)=BRNPRNM(X)
+11 IF C>BRNLINE
SET BRNLINE=C
+12 KILL BRNPRNM
SET X=0
FOR
SET X=$ORDER(Y(X))
IF X'=+X
QUIT
SET BRNPRNM(X)=Y(X)
+13 IF '$DATA(BRNPRNM)
SET BRNPRNT="--"
Begin DoDot:1
+14 SET BRNDELD(BRNPIEC,"M")=BRNPRNT
End DoDot:1
+15 SET X=0
FOR
SET X=$ORDER(BRNPRNM(X))
IF X'=+X
QUIT
Begin DoDot:1
+16 SET $PIECE(BRNDELD(BRNPIEC,"M"),"|",X)=BRNPRNM(X)
End DoDot:1
+17 QUIT
+18 ;
DIQ ;
+1 KILL BRNPRNT,BRNFILE,BRNFIEL
+2 SET BRNFILE=$PIECE($PIECE(^BRNSORT(BRNCRIT,0),U,4),",")
SET BRNFIEL=$PIECE($PIECE(^(0),U,4),",",2)
+3 SET DIQ(0)="EN"
SET DIQ="BRNPRNT("
SET DIC=BRNFILE
SET DR=BRNFIEL
DO EN^DIQ1
KILL DIC,DR,DIQ
+4 IF '$DATA(BRNPRNT(BRNFILE,DA,BRNFIEL,"E"))
SET BRNPRNT(BRNFILE,DA,BRNFIEL,"E")="--"
+5 SET BRNPRNT=BRNPRNT(BRNFILE,DA,BRNFIEL,"E")
+6 QUIT
OPEN ;write flat file from global
+1 ;if screen selected do screen
+2 ;USE GS FROM GPRA TO OPEN AND WRITE FILE
+3 SET Y=$$OPEN^%ZISH(BRNHDIR,BRNDELF,"W")
+4 IF Y=1
IF '$DATA(ZTQUEUED)
WRITE !!,"Cannot open host file to write out DELIMITED data. Notify programmer."
QUIT
+5 USE IO
+6 QUIT