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

APCLVLP.m

Go to the documentation of this file.
APCLVLP ; IHS/CMI/LAB - PRINT VISIT REPORT ;
 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
 ;IHS/TUCSON/LAB - added killing of APCLPRNT to V subroutine 05/19/97
 ;IHS/TUCSON/LAB - modified subroutine FLAT - patch 1 - 05/27/97
START ;EP - Set up header line, dash line
 I APCLCTYP="L" D DELIMIT^APCLVLP8 Q
 S APCLFCNT=0
 K ^XTMP($J,"APCLFLAT") ;just in case
 S X=0,APCLHEAD="" F  S X=$O(^APCLVRPT(APCLRPT,12,X)) Q:X'=+X  S APCLHDR=$P(^APCLVSTS($P(^APCLVRPT(APCLRPT,12,X,0),U),0),U,6),APCLLENG=$P(^APCLVRPT(APCLRPT,12,X,0),U,2),APCLHDR=$E(APCLHDR,1,APCLLENG) D
 .S J=$L(APCLHDR),APCLHEAD=APCLHEAD_APCLHDR,K=$P(^APCLVRPT(APCLRPT,12,X,0),U,2)+1 F I=J:1:K S APCLHEAD=APCLHEAD_" "
 .Q
 S APCLDASH="",$P(APCLDASH,"-",APCLTCW)="-"
 D COVPAGE^APCLVLP1 ;print cover page - note: if user ^'s out of cover page, processing continues
PROC ;process printing of report
 I APCLCTYP="T" G DONE ;--- if displaying only total, that was done in the cover page - go to done
 I APCLCTYP="C" G DONE ;--- if doing a template, that's already done so goto done
 I APCLCTYP="P" G DONE ; -- template
 S APCLPG=0 I '$D(^XTMP("APCLVL",APCLJOB,APCLBTH)) G DONE
 S (APCLSRTV,APCLFRST)="" K APCLQUIT
 F  S APCLSRTV=$O(^XTMP("APCLVL",APCLJOB,APCLBTH,"DATA HITS",APCLSRTV)) Q:APCLSRTV=""!($D(APCLQUIT))  D V
 G:$D(APCLQUIT) DONE
 I APCLCTYP="F" D  G DONE
 .D WRITEF
 .W:'$D(ZTQUEUED) !!,"Flat file ",APCLOUTF," has been created."
 .W:'$D(ZTQUEUED) !,"Total number of visits counted in selection process: ",APCLRCNT
 .W:'$D(ZTQUEUED) !,"Total number of visits that generated Area Database records: ",(APCLFCNT/3) ;IHS/TUCSON/LAB - PATCH 1 - 05/27/97 changed 2 to 3
 .W:'$D(ZTQUEUED) !!,"If there is a discrepency in the counts it is because some of the visits",!,"that met the selection criteria may have been incomplete, or ",!,"generated an error while the area database record was being created."
 .W:'$D(ZTQUEUED) !,"Errors that could occur would be similar to errors seen on the PCC Visit",!,"review reports.",!
 I $Y>(IOSL-4) D HEAD G:$D(APCLQUIT) DONE
 I $D(APCLRCNT) W !!!,"Total ",$S(APCLPTVS="P":"Patients",1:"Visits"),":  ",APCLRCNT
 I $G(APCLPTVS)="V" W !,"Total Patients:  ",APCLPTCT
DONE ;
 D DONE^APCLVLP2
 Q
V ;GETS DATA HITS
 S APCLSCNT=0
 ;get readable sort value
 K APCLPRNT ;IHS/TUCSON/LAB - added this kill to prevent wrong value patch 1 05/19/97
 S APCLSRTR="",APCLVIEN=$O(^XTMP("APCLVL",APCLJOB,APCLBTH,"DATA HITS",APCLSRTV,0)) I APCLVIEN]"" S APCLCRIT=APCLSORT D
 .I APCLPTVS="V" S APCLVREC=^AUPNVSIT(APCLVIEN,0),DFN=$P(APCLVREC,U,5) X:$D(^APCLVSTS(APCLSORT,3)) ^(3) S APCLSRTR=APCLPRNT
 .I APCLPTVS="P" S DFN=APCLVIEN X:$D(^APCLVSTS(APCLSORT,3)) ^(3) S APCLSRTR=APCLPRNT
 I $G(APCLSPAG)!($D(APCLFRST)) D HEAD Q:$D(APCLQUIT)
 K APCLFRST
 S APCLVIEN=0 F  S APCLVIEN=$O(^XTMP("APCLVL",APCLJOB,APCLBTH,"DATA HITS",APCLSRTV,APCLVIEN)) Q:APCLVIEN'=+APCLVIEN!($D(APCLQUIT))  D
 .I APCLPTVS="V" S APCLVREC=^AUPNVSIT(APCLVIEN,0),DFN=$P(APCLVREC,U,5) D PRINT Q
 .S DFN=APCLVIEN D PRINT
 .Q
 Q:$D(APCLQUIT)
 I $Y>(IOSL-3) D HEAD Q:$D(APCLQUIT)
 I $G(APCLSPAG) W !!,"SUB-TOTAL for ",APCLSORV," ",APCLSRTR,":  ",APCLSCNT I APCLPTVS="V" W "    # of PATIENTS:  ",$S($D(^XTMP("APCLVL",APCLJOB,APCLBTH,"SUB PAT COUNT",APCLSRTV)):^XTMP("APCLVL",APCLJOB,APCLBTH,"SUB PAT COUNT",APCLSRTV),1:0)
 I APCLCTYP="S",(APCLPTVS="V") W !,?10,$E(APCLSRTR,1,30),?45,$J(APCLSCNT,8)," (V)",?60,$S($D(^XTMP("APCLVL",APCLJOB,APCLBTH,"SUB PAT COUNT",APCLSRTV)):$J(^XTMP("APCLVL",APCLJOB,APCLBTH,"SUB PAT COUNT",APCLSRTV),8),1:0)," (P)"
 I APCLCTYP="S",(APCLPTVS="P") W !,?10,$E(APCLSRTR,1,30),?45,$J(APCLSCNT,8)
 Q
PRINT ;
 I APCLCTYP="F" D FLAT Q
 S APCLSCNT=APCLSCNT+1 Q:APCLCTYP="S"
 K ^XTMP("APCLLINE",$J) S ^XTMP("APCLLINE",$J,1)=""
 I $Y>(IOSL-5) D HEAD Q:$D(APCLQUIT)
 S APCLI=0 F  S APCLI=$O(^APCLVRPT(APCLRPT,12,APCLI)) Q:APCLI'=+APCLI!($D(APCLQUIT))  S APCLCRIT=$P(^APCLVRPT(APCLRPT,12,APCLI,0),U) D
 .I '$P(^APCLVSTS(APCLCRIT,0),U,8) D SINGLE Q
 .D MULT
 .Q
 S APCLX=0 F  S APCLX=$O(^XTMP("APCLLINE",$J,APCLX)) Q:APCLX'=+APCLX!($D(APCLQUIT))  D
 .I $Y>(IOSL-4) D HEAD Q:$D(APCLQUIT)
 .W !,^XTMP("APCLLINE",$J,APCLX)
 Q
SINGLE ;process single valued item
 K APCLPRNT
 S APCLX=0
 X:$D(^APCLVSTS(APCLCRIT,3)) ^(3)
 S APCLLENG=$P(^APCLVRPT(APCLRPT,12,APCLI,0),U,2),APCLPRNT=$E(APCLPRNT,1,APCLLENG) D
 .S J=$L(APCLPRNT),^XTMP("APCLLINE",$J,1)=^XTMP("APCLLINE",$J,1)_APCLPRNT,K=$P(^APCLVRPT(APCLRPT,12,APCLI,0),U,2)+1 F I=J:1:K S ^XTMP("APCLLINE",$J,1)=^XTMP("APCLLINE",$J,1)_" "
 .S X=1 F  S X=$O(^XTMP("APCLLINE",$J,X)) Q:X'=+X  I $L(^XTMP("APCLLINE",$J,X))<$L(^XTMP("APCLLINE",$J,1)) S K=$L(^XTMP("APCLLINE",$J,X))+1,J=$L(^XTMP("APCLLINE",$J,1)) F I=K:1:J S ^XTMP("APCLLINE",$J,X)=^XTMP("APCLLINE",$J,X)_" "
 Q
LABLOINC ;
 S X=0 F  S X=$O(APCLPRNM(X)) Q:X'=+X  S Y=$G(APCLPRNM(X,"I")) D
 .Q:Y=""
 .Q:'$D(^AUPNVLAB(Y,0))
 .S Z=$P(^AUPNVLAB(Y,0),U)
 .Q:$D(APCLLABT("LAB",Z))
 .S J=$P($G(^AUPNVLAB(Y,11)),U,13)
 .I J="" K APCLPRNM(X) Q
 .I $$LOINC^APCLVLU1(J) Q
 .K APCLPRNM(X)
 .Q
 Q
MULT ;
 K APCLPRNT,APCLPRNM,APCLY S (APCLX,APCLPCNT)=0
 X:$D(^APCLVSTS(APCLCRIT,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(^APCLVRPT(APCLRPT,12,APCLI,0),U,3) D
 .;does this one match selected ones?
 .I $P(^APCLVSTS(APCLCRIT,0),U,14) D LABLOINC G NEXT
 .S X=0 F  S X=$O(APCLPRNM(X)) Q:X'=+X  D
 ..S Z=$G(APCLPRNM(X,"I")) I Z="" K APCLPRNM(X) Q
 ..I '$D(^APCLVRPT(APCLRPT,11,APCLCRIT,11,"B",Z)) K APCLPRNM(X)
NEXT ; 
 K Y S (X,C)=0 F  S X=$O(APCLPRNM(X)) Q:X'=+X  S C=C+1,Y(C)=APCLPRNM(X)
 K APCLPRNM S X=0 F  S X=$O(Y(X)) Q:X'=+X  S APCLPRNM(X)=Y(X)
 I '$D(APCLPRNM) S APCLPRNT="--" D
 .S APCLLENG=$P(^APCLVRPT(APCLRPT,12,APCLI,0),U,2),APCLPRNT=$E(APCLPRNT,1,APCLLENG) D
 ..S J=$L(APCLPRNT),^XTMP("APCLLINE",$J,1)=^XTMP("APCLLINE",$J,1)_APCLPRNT,K=$P(^APCLVRPT(APCLRPT,12,APCLI,0),U,2)+1 F I=J:1:K S ^XTMP("APCLLINE",$J,1)=^XTMP("APCLLINE",$J,1)_" "
 S X=0 F  S X=$O(APCLPRNM(X)) Q:X'=+X  D
 .I X=1 D  Q
 ..S APCLLENG=$P(^APCLVRPT(APCLRPT,12,APCLI,0),U,2),APCLPRNT=$E(APCLPRNM(1),1,APCLLENG) D
 ...S J=$L(APCLPRNT),^XTMP("APCLLINE",$J,1)=^XTMP("APCLLINE",$J,1)_APCLPRNT,K=$P(^APCLVRPT(APCLRPT,12,APCLI,0),U,2)+1 F I=J:1:K S ^XTMP("APCLLINE",$J,1)=^XTMP("APCLLINE",$J,1)_" "
 .S APCLLENG=$P(^APCLVRPT(APCLRPT,12,APCLI,0),U,2),APCLPRNT=$E(APCLPRNM(X),1,APCLLENG) D
 ..I '$D(^XTMP("APCLLINE",$J,X)) S ^XTMP("APCLLINE",$J,X)="",K=$P(^APCLVRPT(APCLRPT,12,APCLI,0),U,2)+1,$P(^XTMP("APCLLINE",$J,X)," ",($L(^XTMP("APCLLINE",$J,1))-K))=""
 ..S J=$L(APCLPRNT),^XTMP("APCLLINE",$J,X)=^XTMP("APCLLINE",$J,X)_APCLPRNT,K=$P(^APCLVRPT(APCLRPT,12,APCLI,0),U,2)+1 F I=J:1:K S ^XTMP("APCLLINE",$J,X)=^XTMP("APCLLINE",$J,X)_" "
 S X=1 F  S X=$O(^XTMP("APCLLINE",$J,X)) Q:X'=+X  I $L(^XTMP("APCLLINE",$J,X))<$L(^XTMP("APCLLINE",$J,1)) S K=$L(^XTMP("APCLLINE",$J,X))+1,J=$L(^XTMP("APCLLINE",$J,1)) F I=K:1:J S ^XTMP("APCLLINE",$J,X)=^XTMP("APCLLINE",$J,X)_" "
 Q
DIQ ;
 K APCLPRNT,APCLFILE,APCLFIEL
 S APCLFILE=$P($P(^APCLVSTS(APCLCRIT,0),U,4),","),APCLFIEL=$P($P(^(0),U,4),",",2)
 S DIQ(0)="EN",DIQ="APCLPRNT(",DIC=APCLFILE,DR=APCLFIEL D EN^DIQ1 K DIC,DR,DIQ
 I '$D(APCLPRNT(APCLFILE,DA,APCLFIEL,"E")) S APCLPRNT(APCLFILE,DA,APCLFIEL,"E")="--"
 S APCLPRNT=APCLPRNT(APCLFILE,DA,APCLFIEL,"E")
 Q
FLAT ;
 ;IHS/TUCSON/LAB - modified this subroutine to add a third record patch 1 05/27/97
 K APCLX1,APCLX2,APCLX3 ;IHS/TUCSON/LAB - added kill of APCLX3
 S APCLX1=$$VREC^APCLVDR(APCLVIEN,"MEGA RECORD 1")
 Q:APCLX1=""
 Q:APCLX1=-1
 S APCLX2=$$VREC^APCLVDR(APCLVIEN,"MEGA RECORD 2")
 G:APCLX2="" FLATX
 G:APCLX2=-1 FLATX
 S APCLX3=$$VREC^APCLVDR(APCLVIEN,"MEGA RECORD 3")
 Q:APCLX3=""
 G:APCLX3=-1 FLATX
 S APCLFCNT=APCLFCNT+1,^XTMP($J,"APCLFLAT",APCLFCNT)=APCLX1
 S APCLFCNT=APCLFCNT+1,^XTMP($J,"APCLFLAT",APCLFCNT)=APCLX2
 S APCLFCNT=APCLFCNT+1,^XTMP($J,"APCLFLAT",APCLFCNT)=APCLX3
FLATX K APCLX1,APCLX2,APCLV0,APCLX3
 Q
 D HEAD^APCLVLP2
 Q
WRITEF ;write flat file from global
 D WRITEF^APCLVLP2
 Q