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

ACDRLP.m

Go to the documentation of this file.
ACDRLP ;IHS/ADC/EDE/KML - PRINT CDMIS RECORD REPORT;
 ;;4.1;CHEMICAL DEPENDENCY MIS;;MAY 11, 1998
START ;EP - Set up header line, dash line
 K ^TMP("ACDFLAT",$J) ;just in case
 S X=0,ACDHEAD="" F  S X=$O(^ACDRPTD(ACDRPT,12,X)) Q:X'=+X  S ACDHDR=$P(^ACDTITEM($P(^ACDRPTD(ACDRPT,12,X,0),U),0),U,6),ACDLENG=$P(^ACDRPTD(ACDRPT,12,X,0),U,2),ACDHDR=$E(ACDHDR,1,ACDLENG) D
 .S J=$L(ACDHDR),ACDHEAD=ACDHEAD_ACDHDR,K=$P(^ACDRPTD(ACDRPT,12,X,0),U,2)+1 F I=J:1:K S ACDHEAD=ACDHEAD_" "
 .Q
 S ACDDASH="",$P(ACDDASH,"-",ACDTCW)="-"
 D COVPAGE^ACDRLP1 ;print cover page - note: if user ^'s out of cover page, processing continues
PROC ;process printing of report
 I ACDCTYP="T" G DONE ;--- if displaying only total, that was done in the cover page - go to done
 S ACDPG=0 I '$D(^TMP("ACDRL",ACDJOB,ACDBTH)) G DONE
 S (ACDSRTV,ACDFRST)="" K ACDQUIT
 F  S ACDSRTV=$O(^TMP("ACDRL",ACDJOB,ACDBTH,"DATA HITS",ACDSRTV)) Q:ACDSRTV=""!($D(ACDQUIT))  D V
 G:$D(ACDQUIT) DONE
 I ACDCTYP="F" D WRITEF G DONE
 I $Y>(IOSL-4) D HEAD G:$D(ACDQUIT) DONE
 I $D(ACDRCNT),ACDPTVS="V" W !!!,"Total ",$S(ACDPTVS="P":"Patients",1:"Records"),":  ",ACDRCNT
 W !!,"Total Patients:  ",ACDPTCT
DONE ;
 D DONE^ACDRLP2
 Q
V ;GETS DATA HITS
 S ACDSCNT=0
 ;get readable sort value
 K ACDPRNT S ACDSRTR="",ACDR=$O(^TMP("ACDRL",ACDJOB,ACDBTH,"DATA HITS",ACDSRTV,"")) I ACDR]"" S ACDCRIT=ACDSORT D
 .I ACDPTVS="V" S ACDR0=^ACDVIS(ACDR,0),DFN=$P(ACDR0,U,5) X:$D(^ACDTITEM(ACDSORT,3)) ^(3) S ACDSRTR=$S($G(ACDPRNT)]"":ACDPRNT,1:"--")
 .I ACDPTVS="P" S DFN=ACDR X:$D(^ACDTITEM(ACDSORT,3)) ^(3) S ACDSRTR=$S($G(ACDPRNT)]"":ACDPRNT,1:"--")
 I $G(ACDSPAG)!($D(ACDFRST)) D HEAD Q:$D(ACDQUIT)
 K ACDFRST
 S ACDR=0 F  S ACDR=$O(^TMP("ACDRL",ACDJOB,ACDBTH,"DATA HITS",ACDSRTV,ACDR)) Q:ACDR'=+ACDR!($D(ACDQUIT))  D
 .I ACDPTVS="V" S ACDR0=^ACDVIS(ACDR,0),DFN=$P(ACDR0,U,5) D PRINT Q
 .S DFN=ACDR D PRINT
 .Q
 Q:$D(ACDQUIT)
 I $Y>(IOSL-3) D HEAD Q:$D(ACDQUIT)
 W:$G(ACDSPAG) !!,"SUB-TOTAL for ",ACDSORV," ",ACDSRTR,":  ",ACDSCNT
 W:ACDCTYP="S" !?10,$E(ACDSRTR,1,30),?45,$J(ACDSCNT,8)
 Q
PRINT ;
 I ACDCTYP="F" D FLAT Q
 S ACDSCNT=ACDSCNT+1 Q:ACDCTYP="S"
 K ^TMP("ACDLINE",$J) S ^TMP("ACDLINE",$J,1)=""
 I $Y>(IOSL-5) D HEAD Q:$D(ACDQUIT)
 S ACDI=0 F  S ACDI=$O(^ACDRPTD(ACDRPT,12,ACDI)) Q:ACDI'=+ACDI!($D(ACDQUIT))  S ACDCRIT=$P(^ACDRPTD(ACDRPT,12,ACDI,0),U) D
 .I '$P(^ACDTITEM(ACDCRIT,0),U,8) D SINGLE Q
 .D MULT
 .Q
 S ACDX=0 F  S ACDX=$O(^TMP("ACDLINE",$J,ACDX)) Q:ACDX'=+ACDX!($D(ACDQUIT))  D
 .I $Y>(IOSL-4) D HEAD Q:$D(ACDQUIT)
 .W !,^TMP("ACDLINE",$J,ACDX)
 Q
SINGLE ;process single valued item
 K ACDPRNT
 S ACDX=0
 X:$D(^ACDTITEM(ACDCRIT,3)) ^(3)
 I $G(ACDPRNT)="" S ACDPRNT="--"
 S ACDLENG=$P(^ACDRPTD(ACDRPT,12,ACDI,0),U,2),ACDPRNT=$E($G(ACDPRNT),1,ACDLENG) D
 .S J=$L(ACDPRNT),^TMP("ACDLINE",$J,1)=^TMP("ACDLINE",$J,1)_ACDPRNT,K=$P(^ACDRPTD(ACDRPT,12,ACDI,0),U,2)+1 F I=J:1:K S ^TMP("ACDLINE",$J,1)=^TMP("ACDLINE",$J,1)_" "
 .S X=1 F  S X=$O(^TMP("ACDLINE",$J,X)) Q:X'=+X  I $L(^TMP("ACDLINE",$J,X))<$L(^TMP("ACDLINE",$J,1)) S K=$L(^TMP("ACDLINE",$J,X))+1,J=$L(^TMP("ACDLINE",$J,1)) F I=K:1:J S ^TMP("ACDLINE",$J,X)=^TMP("ACDLINE",$J,X)_" "
 Q
MULT ;
 K ACDPRNT,ACDPRNM S (ACDX,ACDPCNT)=0
 X:$D(^ACDTITEM(ACDCRIT,3)) ^(3)
 I '$D(ACDPRNM) S ACDPRNT="--" D
 .S ACDLENG=$P(^ACDRPTD(ACDRPT,12,ACDI,0),U,2),ACDPRNT=$E(ACDPRNT,1,ACDLENG) D
 ..S J=$L(ACDPRNT),^TMP("ACDLINE",$J,1)=^TMP("ACDLINE",$J,1)_ACDPRNT,K=$P(^ACDRPTD(ACDRPT,12,ACDI,0),U,2)+1 F I=J:1:K S ^TMP("ACDLINE",$J,1)=^TMP("ACDLINE",$J,1)_" "
 S X=0 F  S X=$O(ACDPRNM(X)) Q:X'=+X  D
 .I X=1 D  Q
 ..S ACDLENG=$P(^ACDRPTD(ACDRPT,12,ACDI,0),U,2),ACDPRNT=$E(ACDPRNM(1),1,ACDLENG) D
 ...S J=$L(ACDPRNT),^TMP("ACDLINE",$J,1)=^TMP("ACDLINE",$J,1)_ACDPRNT,K=$P(^ACDRPTD(ACDRPT,12,ACDI,0),U,2)+1 F I=J:1:K S ^TMP("ACDLINE",$J,1)=^TMP("ACDLINE",$J,1)_" "
 .S ACDLENG=$P(^ACDRPTD(ACDRPT,12,ACDI,0),U,2),ACDPRNT=$E(ACDPRNM(X),1,ACDLENG) D
 ..I '$D(^TMP("ACDLINE",$J,X)) S ^TMP("ACDLINE",$J,X)="",K=$P(^ACDRPTD(ACDRPT,12,ACDI,0),U,2)+1,$P(^TMP("ACDLINE",$J,X)," ",($L(^TMP("ACDLINE",$J,1))-K))=""
 ..S J=$L(ACDPRNT),^TMP("ACDLINE",$J,X)=^TMP("ACDLINE",$J,X)_ACDPRNT,K=$P(^ACDRPTD(ACDRPT,12,ACDI,0),U,2)+1 F I=J:1:K S ^TMP("ACDLINE",$J,X)=^TMP("ACDLINE",$J,X)_" "
 S X=1 F  S X=$O(^TMP("ACDLINE",$J,X)) Q:X'=+X  I $L(^TMP("ACDLINE",$J,X))<$L(^TMP("ACDLINE",$J,1)) S K=$L(^TMP("ACDLINE",$J,X))+1,J=$L(^TMP("ACDLINE",$J,1)) F I=K:1:J S ^TMP("ACDLINE",$J,X)=^TMP("ACDLINE",$J,X)_" "
 Q
DIQ ;
 K ACDPRNT,ACDFILE,ACDFIEL
 S ACDFILE=$P($P(^ACDTITEM(ACDCRIT,0),U,4),","),ACDFIEL=$P($P(^(0),U,4),",",2)
 S DIQ(0)="EN",DIQ="ACDPRNT(",DIC=ACDFILE,DR=ACDFIEL D EN^DIQ1 K DIC,DR,DIQ
 I '$D(ACDPRNT(ACDFILE,DA,ACDFIEL,"E")) S ACDPRNT(ACDFILE,DA,ACDFIEL,"E")="--"
 S ACDPRNT=ACDPRNT(ACDFILE,DA,ACDFIEL,"E")
 Q
FLAT ;
 S E=$$FLAT^ACDFLAT2(ACDR,.ACDREC)
 I E S X=0 F  S X=$O(ACDREC(X)) Q:X'=+X  S ^TMP($J,"ACDFLAT",ACDR)=ACDREC(X)
 K ACDTX,ACDREC,X
 Q
 Q:ACDCTYP="F"
 D HEAD^ACDRLP2
 Q
WRITEF ;write flat file from global
 D WRITEF^ACDRLP2
 Q