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