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

BMCRLP.m

Go to the documentation of this file.
BMCRLP ; IHS/PHXAO/TMJ - PRINT REFERRAL REPORT ;   
 ;;4.0;REFERRED CARE INFO SYSTEM;;JAN 09, 2006
 ;IHS/ITSC/FCJ ADDED NUMERIC DATE FORMAT PRINT
 ;4.0 IHS/ITSC/FCJ MODIFIED "R" OPTION, ALL REF WERE NOT PRINTED
 ;4.0 IHS/ITSC/FCJ ADDED SUFFIX TO PRINT WITH REFERRAL #
 ;
START ;EP - Set up header line, dash line
 S X=0,BMCHEAD="" F  S X=$O(^BMCRTMP(BMCRPT,12,X)) Q:X'=+X  S BMCHDR=$P(^BMCTSORT($P(^BMCRTMP(BMCRPT,12,X,0),U),0),U,6),BMCLENG=$P(^BMCRTMP(BMCRPT,12,X,0),U,2),BMCHDR=$E(BMCHDR,1,BMCLENG) D
 .S J=$L(BMCHDR),BMCHEAD=BMCHEAD_BMCHDR,K=$P(^BMCRTMP(BMCRPT,12,X,0),U,2)+1 F I=J:1:K S BMCHEAD=BMCHEAD_" "
 S BMCDASH="",$P(BMCDASH,"-",BMCTCW)="-"
 D COVPAGE^BMCRLP1 ;print cover page - note: if user ^'s out of cover page, processing continues
PROC ;process printing of report
 S BMCPG=0
 I BMCCTYP="T" G DONE ;--- if displaying only total, that was done in the cover page - go to done
 I BMCCTYP="N" D N^BMCRLP2 G TOT
 I '$D(^XTMP("BMCRL",BMCJOB,BMCBTH)) G DONE
 S (BMCSRTV,BMCFRST)="" K BMCQUIT
 F  S BMCSRTV=$O(^XTMP("BMCRL",BMCJOB,BMCBTH,"DATA HITS",BMCSRTV)) Q:BMCSRTV=""!($D(BMCQUIT))  D V
 G:$D(BMCQUIT) DONE
TOT ;
 G:$G(BMCCTYP)="R" DONE
 I $Y>(IOSL-4) D HEAD G:$D(BMCQUIT) DONE
 I $D(BMCRCNT) W !!!,"Total ",$S(BMCPTVS="P":"Patients",1:"Referrals"),":  ",BMCRCNT
 I $G(BMCPTVS)="R" W !,"Total Patients:  ",BMCPTCT
DONE ;
 D DONE^BMCRLP2
 Q
V ;GETS DATA HITS
 S BMCSCNT=0
 ;get readable sort value
 ;2.17.05 IHS/ITSC/FCJ MODIFIED NEXT LINE, IT WAS NOT PICKING UP ALL REF
 ;S BMCSRTR="",BMCREF=$O(^XTMP("BMCRL",BMCJOB,BMCBTH,"DATA HITS",BMCSRTV,0)) I BMCREF]"" S BMCCRIT=BMCSORT D
 S BMCSRTR="",BMCREF="" F  S BMCREF=$O(^XTMP("BMCRL",BMCJOB,BMCBTH,"DATA HITS",BMCSRTV,BMCREF)) Q:BMCREF'?1N.N  I BMCREF]"" S BMCCRIT=BMCSORT D
 .I $G(BMCCTYP)="R" D R^BMCRLP2 Q  ;2.17.05 IHS/ITSC/FCJ ADDED $G
 .I BMCPTVS="R" S BMCRREC=^BMCREF(BMCREF,0),DFN=$P(BMCRREC,U,3) X:$D(^BMCTSORT(BMCSORT,3)) ^(3) S BMCSRTR=BMCPRNT
 .I BMCPTVS="P" S DFN=BMCREF X:$D(^BMCTSORT(BMCSORT,3)) ^(3) S BMCSRTR=BMCPRNT
 I $G(BMCSPAG)!($D(BMCFRST)) D HEAD Q:$D(BMCQUIT)
 K BMCFRST
 S BMCREF=0 F  S BMCREF=$O(^XTMP("BMCRL",BMCJOB,BMCBTH,"DATA HITS",BMCSRTV,BMCREF)) Q:BMCREF'=+BMCREF!($D(BMCQUIT))  D
 .I BMCPTVS="R" S BMCRREC=^BMCREF(BMCREF,0),DFN=$P(BMCRREC,U,3) D PRINT Q
 .S DFN=BMCREF D PRINT
 Q:$D(BMCQUIT)
 I $Y>(IOSL-3) D HEAD Q:$D(BMCQUIT)
 W:$G(BMCSPAG) !!,"SUB-TOTAL for ",BMCSORV," ",BMCSRTR,":  ",BMCSCNT
 W:$G(BMCCTYP)="S" !,?10,$E(BMCSRTR,1,30),?45,$J(BMCSCNT,8)  ;2.17.05 IHS/ITSC/FCJ ADDED $G
 Q
PRINT ;
 S BMCSCNT=BMCSCNT+1 Q:$G(BMCCTYP)="S"  ;2.17.05 IHS/ITSC/FCJ ADDED $G
 K ^XTMP("BMCLINE",$J) S ^XTMP("BMCLINE",$J,1)=""
 I $Y>(IOSL-5) D HEAD Q:$D(BMCQUIT)
 S BMCI=0 F  S BMCI=$O(^BMCRTMP(BMCRPT,12,BMCI)) Q:BMCI'=+BMCI!($D(BMCQUIT))  S BMCCRIT=$P(^BMCRTMP(BMCRPT,12,BMCI,0),U) D
 .I '$P(^BMCTSORT(BMCCRIT,0),U,8) D SINGLE Q
 .D MULT
 .Q
 S BMCX=0 F  S BMCX=$O(^XTMP("BMCLINE",$J,BMCX)) Q:BMCX'=+BMCX!($D(BMCQUIT))  D
 .I $Y>(IOSL-4) D HEAD Q:$D(BMCQUIT)
 .W !,^XTMP("BMCLINE",$J,BMCX)
 Q
SINGLE ;process single valued item
 K BMCPRNT
 S BMCX=0
 X:$D(^BMCTSORT(BMCCRIT,3)) ^(3)
 S BMCLENG=$P(^BMCRTMP(BMCRPT,12,BMCI,0),U,2),BMCPRNT=$E(BMCPRNT,1,BMCLENG) D
 .S J=$L(BMCPRNT),^XTMP("BMCLINE",$J,1)=^XTMP("BMCLINE",$J,1)_BMCPRNT,K=$P(^BMCRTMP(BMCRPT,12,BMCI,0),U,2)+1 F I=J:1:K S ^XTMP("BMCLINE",$J,1)=^XTMP("BMCLINE",$J,1)_" "
 .S X=1 F  S X=$O(^XTMP("BMCLINE",$J,X)) Q:X'=+X  I $L(^XTMP("BMCLINE",$J,X))<$L(^XTMP("BMCLINE",$J,1)) S K=$L(^XTMP("BMCLINE",$J,X))+1,J=$L(^XTMP("BMCLINE",$J,1)) F I=K:1:J S ^XTMP("BMCLINE",$J,X)=^XTMP("BMCLINE",$J,X)_" "
 Q
MULT ;
 K BMCPRNT,BMCPRNM S (BMCX,BMCPCNT)=0
 X:$D(^BMCTSORT(BMCCRIT,3)) ^(3)
 I '$D(BMCPRNM) S BMCPRNT="--" D
 .S BMCLENG=$P(^BMCRTMP(BMCRPT,12,BMCI,0),U,2),BMCPRNT=$E(BMCPRNT,1,BMCLENG) D
 ..S J=$L(BMCPRNT),^XTMP("BMCLINE",$J,1)=^XTMP("BMCLINE",$J,1)_BMCPRNT,K=$P(^BMCRTMP(BMCRPT,12,BMCI,0),U,2)+1 F I=J:1:K S ^XTMP("BMCLINE",$J,1)=^XTMP("BMCLINE",$J,1)_" "
 S X=0 F  S X=$O(BMCPRNM(X)) Q:X'=+X  D
 .I X=1 D  Q
 ..S BMCLENG=$P(^BMCRTMP(BMCRPT,12,BMCI,0),U,2),BMCPRNT=$E(BMCPRNM(1),1,BMCLENG) D
 ...S J=$L(BMCPRNT),^XTMP("BMCLINE",$J,1)=^XTMP("BMCLINE",$J,1)_BMCPRNT,K=$P(^BMCRTMP(BMCRPT,12,BMCI,0),U,2)+1 F I=J:1:K S ^XTMP("BMCLINE",$J,1)=^XTMP("BMCLINE",$J,1)_" "
 .S BMCLENG=$P(^BMCRTMP(BMCRPT,12,BMCI,0),U,2),BMCPRNT=$E(BMCPRNM(X),1,BMCLENG) D
 ..I '$D(^XTMP("BMCLINE",$J,X)) S ^XTMP("BMCLINE",$J,X)="",K=$P(^BMCRTMP(BMCRPT,12,BMCI,0),U,2)+1,$P(^XTMP("BMCLINE",$J,X)," ",($L(^XTMP("BMCLINE",$J,1))-K))=""
 ..S J=$L(BMCPRNT),^XTMP("BMCLINE",$J,X)=^XTMP("BMCLINE",$J,X)_BMCPRNT,K=$P(^BMCRTMP(BMCRPT,12,BMCI,0),U,2)+1 F I=J:1:K S ^XTMP("BMCLINE",$J,X)=^XTMP("BMCLINE",$J,X)_" "
 S X=1 F  S X=$O(^XTMP("BMCLINE",$J,X)) Q:X'=+X  I $L(^XTMP("BMCLINE",$J,X))<$L(^XTMP("BMCLINE",$J,1)) S K=$L(^XTMP("BMCLINE",$J,X))+1,J=$L(^XTMP("BMCLINE",$J,1)) F I=K:1:J S ^XTMP("BMCLINE",$J,X)=^XTMP("BMCLINE",$J,X)_" "
 Q
DIQ ;EP FROM REPORT LIST FILE
 K BMCPRNT,BMCFILE,BMCFIEL
 S BMCFILE=$P($P(^BMCTSORT(BMCCRIT,0),U,4),","),BMCFIEL=$P($P(^(0),U,4),",",2)
 S DIQ(0)="ENI",DIQ="BMCPRNT(",DIC=BMCFILE,DR=BMCFIEL D EN^DIQ1 K DIC,DR,DIQ
 I BMCFIEL=".02" S BMCPRNT=BMCPRNT(BMCFILE,DA,BMCFIEL,"E")_$P($G(^BMCREF(DA,1)),U),BMCPRNT(BMCFILE,DA,BMCFIEL,"E")=BMCPRNT Q
 I '$D(BMCPRNT(BMCFILE,DA,BMCFIEL,"E")) S (BMCPRNT,BMCPRNT(BMCFILE,DA,BMCFIEL,"E"))="--" Q
 I $P(^BMCTSORT(BMCCRIT,0),U)="Date of Birth" S Y=BMCPRNT(BMCFILE,DA,BMCFIEL,"I") D DT^BMCOSUT S BMCPRNT=Y Q
 I $P(^BMCTSORT(BMCCRIT,0),U,2)="D" S Y=BMCPRNT(BMCFILE,DA,BMCFIEL,"I") D DT1^BMCOSUT S BMCPRNT=Y Q
 S BMCPRNT=BMCPRNT(BMCFILE,DA,BMCFIEL,"E")
 Q
 D HEAD^BMCRLP2
 Q