Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: BNIGVLP8

BNIGVLP8.m

Go to the documentation of this file.
BNIGVLP8 ; IHS/CMI/LAB - print delimited ;
 ;;1.0;BNI CPHD ACTIVITY DATASYSTEM;;DEC 20, 2006
 ;IHS/TUCSON/LAB - added killing of BNIGPRNT to V subroutine 05/19/97
 ;IHS/TUCSON/LAB - modified subroutine FLAT - patch 1 - 05/27/97
DELIMIT ;EP - Set up header line, dash line
 S BNIGFCNT=0,BNIGUIC=1
 K ^TMP($J,"BNIGDELIMITED")
 S BNIGDELC=0,BNIGPIEC=0
 I BNIGPTVS="R" S BNIGHDR="RECORD IEN",BNIGPIEC=1
 S X=0,BNIGHEAD="" F  S X=$O(^BNIRTMP(BNIGRPT,12,X)) Q:X'=+X  D
 .S BNIGPIEC=BNIGPIEC+1
 .S H=$P(^BNIGRI($P(^BNIRTMP(BNIGRPT,12,X,0),U),0),U,6)
 .S $P(BNIGHDR,U,BNIGPIEC)=H
 .Q
 I '$G(BNIGUI) D COVPAGE^BNIGVLP1 ;print cover page - note: if user ^'s out of cover page, processing continues
 I $G(BNIGUI) D COVPAGE^BNIGVLP3
PROC ;process printing of report
 I $G(BNIGUI) S BNIGUIC=BNIC S ^BNIGUI(BNIIEN,12,BNIGUIC,0)=BNIGHDR G PROC1
 S Y=0 I BNIGDELT="F" D OPEN Q:Y=1
 W !,BNIGHDR,!
PROC1 ;
 I '$D(^XTMP("BNIGVL",BNIGJOB,BNIGBTH)) W !,"NO DATA TO REPORT" G DONE
 S (BNIGSRTV,BNIGFRST)="" K BNIGQUIT
 F  S BNIGSRTV=$O(^XTMP("BNIGVL",BNIGJOB,BNIGBTH,"DATA HITS",BNIGSRTV)) Q:BNIGSRTV=""!($D(BNIGQUIT))  D V
DONE ;
 ;write out delimited file
 I '$G(BNIGUI),BNIGDELT="F" D ^%ZISC
 K ^XTMP("BNIGVL",BNIGJOB,BNIGBT),^TMP($J,"BNIGDELIMITED")
 D DEL^BNIGVL
 K BNIGBD,BNIGSD,BNIGED,BNIGEDD,BNIGBDD,BNIGRPT,BNIGHEAD,BNIGLINE,BNIGL,BNIGRCNT,BNIGI,BNIGCRIT,BNIGVIEN,BNIGVREC,BNIGJOB,BNIGBT,BNIGBTH,BNIGQUIT,BNIGHDR,BNIGDASH,BNIGLENG,BNIGPCNT,BNIGTCW,BNIGODAT,BNIGPG,AUPNDAYS,AUPNPAT,AUPNDOD,AUPNDOB,AUPNSEX
 K BNIGSORT,BNIGSRT,BNIGSORX,BNIGFILE,BNIGFIEL,BNIGPRNT,BNIGX,BNIGTYPE,BNIGFOUN,D0,J,K,L,BNIGPRNM,BNIGTEST,BNIGSEAT,BNIGLHDR,BNIGFRST
 D EN^XBVK("BNIG")
 Q
V ;GETS DATA HITS
 S BNIGCNT=0
 ;get readable sort value
 K BNIGPRNT
 S BNIGSRTR="",BNIGVIEN=$O(^XTMP("BNIGVL",BNIGJOB,BNIGBTH,"DATA HITS",BNIGSRTV,0)) I BNIGVIEN]"" S BNIGCRIT=BNIGSORT D
 .I BNIGPTVS="R" S BNIGVREC=^BNIREC(BNIGVIEN,0) X:$D(^BNIGRI(BNIGSORT,3)) ^(3) S BNIGSRTR=BNIGPRNT
 K BNIGFRST
 S BNIGVIEN=0 F  S BNIGVIEN=$O(^XTMP("BNIGVL",BNIGJOB,BNIGBTH,"DATA HITS",BNIGSRTV,BNIGVIEN)) Q:BNIGVIEN'=+BNIGVIEN!($D(BNIGQUIT))  D
 .I BNIGPTVS="R" S BNIGVREC=^BNIREC(BNIGVIEN,0) D PRINT Q
 .Q
 Q
PRINT ;
 K ^XTMP("BNIGLINE",$J) S ^XTMP("BNIGLINE",$J,1)=""
 K BNIGDELD
 S BNIGPIEC=0,BNIGLINE=1,BNIGCNT=BNIGCNT+1
 I BNIGPTVS="R" S BNIGDELD(1,"S")=BNIGVIEN,BNIGPIEC=1
 S BNIGI=0 F  S BNIGI=$O(^BNIRTMP(BNIGRPT,12,BNIGI)) Q:BNIGI'=+BNIGI!($D(BNIGQUIT))  S BNIGCRIT=$P(^BNIRTMP(BNIGRPT,12,BNIGI,0),U) D
 .S BNIGPIEC=BNIGPIEC+1
 .I '$P(^BNIGRI(BNIGCRIT,0),U,8) D SINGLE Q
 .D MULT
 .Q
 K BNIGDELP
 F X=1:1:BNIGLINE D
 .S BNIGCNT=BNIGCNT+1
 .F P=1:1:BNIGPIEC D
 ..S V=$O(BNIGDELD(P,""))
 ..I V="S" S D=BNIGDELD(P,V),$P(BNIGDELP(BNIGCNT),U,P)=D
 ..I V="M" S D=$S($P(BNIGDELD(P,V),"|",X)]"":$P(BNIGDELD(P,V),"|",X),1:"--"),$P(BNIGDELP(BNIGCNT),U,P)=D
 I '$G(BNIGUI) S X=0 F  S X=$O(BNIGDELP(X)) Q:X'=+X  W BNIGDELP(X),!
 I $G(BNIGUI) D
 .S (C,X)=0 F  S X=$O(BNIGDELP(X)) Q:X'=+X  S BNIGUIC=BNIGUIC+1,^BNIGUI(BNIIEN,12,BNIGUIC,0)=BNIGDELP(X)
 .S ^BNIGUI(BNIIEN,12,0)="^90512.0812^"_BNIGUIC_"^"_BNIGUIC_"^"_DT
 Q
SINGLE ;process single valued item
 K BNIGPRNT
 S BNIGX=0
 X:$D(^BNIGRI(BNIGCRIT,3)) ^(3)
 I BNIGPRNT="" S BNIGPRNT="--"
 S BNIGDELD(BNIGPIEC,"S")=BNIGPRNT
 Q
MULT ;
 K BNIGPRNT,BNIGPRNM,BNIGY S (BNIGX,BNIGPCNT)=0
 X:$D(^BNIGRI(BNIGCRIT,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(^BNIRTMP(BNIGRPT,12,BNIGI,0),U,3) D
 .;does this one match selected ones?
 .S X=0 F  S X=$O(BNIGPRNM(X)) Q:X'=+X  D
 ..S Z=$G(BNIGPRNM(X,"I")) I Z="" K BNIGPRNM(X) Q
 ..I '$D(^BNIGRTMP(BNIGRPT,11,BNIGCRIT,11,"B",Z)) K BNIGPRNM(X)
 K Y S (X,C)=0 F  S X=$O(BNIGPRNM(X)) Q:X'=+X  S C=C+1,Y(C)=BNIGPRNM(X)
 I C>BNIGLINE S BNIGLINE=C
 K BNIGPRNM S X=0 F  S X=$O(Y(X)) Q:X'=+X  S BNIGPRNM(X)=Y(X)
 I '$D(BNIGPRNM) S BNIGPRNT="--" D
 .S BNIGDELD(BNIGPIEC,"M")=BNIGPRNT
 S X=0 F  S X=$O(BNIGPRNM(X)) Q:X'=+X  D
 .S $P(BNIGDELD(BNIGPIEC,"M"),"|",X)=BNIGPRNM(X)
 Q
DIQ ;
 K BNIGPRNT,BNIGFILE,BNIGFIEL
 S BNIGFILE=$P($P(^BNIGRI(BNIGCRIT,0),U,4),","),BNIGFIEL=$P($P(^(0),U,4),",",2)
 S DIQ(0)="EN",DIQ="BNIGPRNT(",DIC=BNIGFILE,DR=BNIGFIEL D EN^DIQ1 K DIC,DR,DIQ
 I '$D(BNIGPRNT(BNIGFILE,DA,BNIGFIEL,"E")) S BNIGPRNT(BNIGFILE,DA,BNIGFIEL,"E")="--"
 S BNIGPRNT=BNIGPRNT(BNIGFILE,DA,BNIGFIEL,"E")
 Q
OPEN ;write flat file from global
 ;if screen selected do screen
 ;USE GS FROM GPRA TO OPEN AND WRITE FILE
 ;I BNIGDELT="S" D SCREEN Q
 I $G(BNIGUI) Q
 S Y=$$OPEN^%ZISH(BNIGHDIR,BNIGDELF,"W")
 I Y=1 W:'$D(ZTQUEUED) !!,"Cannot open host file to write out DELIMITED data.  Notify programmer." Q
 U IO
 Q