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

APCLVPVC.m

Go to the documentation of this file.
APCLVPVC ; IHS/CMI/LAB - APC visit counts by selected vars ;
 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
 ;
START ; 
 I '$G(DUZ(2)) W $C(7),$C(7),!!,"SITE NOT SET IN DUZ(2) - NOTIFY SITE MANAGER!!",!! Q
 S APCLSITE=DUZ(2)
 S APCLJOB=$J,APCLBTH=$H
 D INFORM
 S DIC("S")="I $P(^(0),U,4)=2!($P(^(0),U,4)=9000001)" S DIC="^DIBT(",DIC("A")="Enter SEARCH TEMPLATE name: ",DIC(0)="AEMQ" D ^DIC K DIC,DA,DR,DICR
 I Y=-1 G XIT
 S APCLSEAT=+Y
 ;
CP ;
 S APCLCP=""
 S DIR(0)="S^P:Provider;C:Clinic",DIR("A")="Tally which of the above",DIR("B")="P" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
 I $D(DIRUT) G XIT
 S APCLCP=Y
GETDATES ;
BD ;get beginning date
 W ! S DIR(0)="D^:DT:EP",DIR("A")="Enter beginning Visit Date for Search" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
 I $D(DIRUT) G CP
 S APCLBD=Y
ED ;get ending date
 W ! S DIR(0)="DA^"_APCLBD_":DT:EP",DIR("A")="Enter ending Visit Date for Search:  " S Y=APCLBD D DD^%DT S Y="" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
 I $D(DIRUT) G BD
 S APCLED=Y
 S X1=APCLBD,X2=-1 D C^%DTC S APCLSD=X
 ;
ZIS ;call to XBDBQUE
 S XBRP="PRINT^APCLVPVC",XBRC="PROCESS^APCLVPVC",XBRX="XIT^APCLVPVC",XBNS="APCL"
 D ^XBDBQUE
 D XIT
 Q
XIT ;
 K APCLDX,APCLCP,APCLLOW,APCLICD,APCLDA1,APCLDA2,APCLY,APCLTITL,APCL80S,APCLEDD,APCLHD1,APCLHD2,APCLLENG,APCLLOCT,APCLPG,APCLSRT2,APCLTOT,APCLBDD,APCLPROV,APCLSEC,APCLZ,APCLADIS,APCLQUIT,APCLLOCC,APCLBT,APCLBTH,APCLCLN,APCLCLNC
 K APCLDT,APCLPDFN,APCLPRNT,APCLSEAT,APCLSITE,APCLSORT,C,D,E,F,A,B,Z,X,I,J
 K APCLJOB,APCLRXCL,APCLOTHC
 K X,X1,X2,IO("Q"),%,Y,POP,DIRUT,ZTSK,ZTQUEUED,H,S,TS,M
 Q
INFORM ;
 W:$D(IOF) @IOF
 W !!,?10,"****PROVIDER OR CLINIC VISIT COUNTS FROM A TEMPLATE OF PATIENTS****",!!
 W !!,"This report will tally the number of times a certain pre-defined set of ",!,"patients (within a Template) were seen by various providers",!,"or went to various clinics.",!!
 W "The Template of Patients must first be created prior to running this report!",!!
 Q
PROCESS ;
 S APCLBT=$H
 K ^TMP("APCLVPVC",APCLJOB,APCLBTH)
 D XTMP^APCLOSUT("APCLVPVC","PCC REPORT OF VISITS")
 ;
 ;
S ;
 S DFN=0 F  S DFN=$O(^DIBT(APCLSEAT,1,DFN)) Q:DFN'=+DFN  D @APCLCP
END ;
 S APCLET=$H
 D EOJ
 Q
C ;clinic
 S APCLPDFN=0 F  S APCLPDFN=$O(^AUPNVSIT("AC",DFN,APCLPDFN)) Q:APCLPDFN'=+APCLPDFN  I $P(^AUPNVSIT(APCLPDFN,0),U,8)]"" D C1
 Q
C1 ;
 S D=$P($P(^AUPNVSIT(APCLPDFN,0),U),".")
 Q:D<APCLBD
 Q:D>APCLED
 S APCLCLN=$P(^DIC(40.7,$P(^AUPNVSIT(APCLPDFN,0),U,8),0),U)
 S APCLCLNC=$S($P(^DIC(40.7,$P(^AUPNVSIT(APCLPDFN,0),U,8),0),U,2)]"":$P(^DIC(40.7,$P(^AUPNVSIT(APCLPDFN,0),U,8),0),U,2),1:"???")
 S ^(APCLCLNC)=$S($D(^TMP("APCLVPVC",APCLJOB,APCLBTH,APCLCLN,APCLCLNC)):^(APCLCLNC)+1,1:1)
 Q
P ;
 S APCLPDFN="" F  S APCLPDFN=$O(^AUPNVPRV("AC",DFN,APCLPDFN)) Q:APCLPDFN'=+APCLPDFN  I $D(^AUPNVPRV(APCLPDFN,0)) S APCLVREC=^(0) D P1,EOJ
 Q
P1 ;
 S D=$P(^AUPNVPRV(APCLPDFN,0),U,3)
 Q:D=""
 Q:'$D(^AUPNVSIT(D,0))
 S D=$P($P(^AUPNVSIT(D,0),U),".")
 Q:D<APCLBD
 Q:D>APCLED
 S APCLAP=$P(APCLVREC,U),APCLNAME=$S($P(^DD(9000010.06,.01,0),U,2)[200:$P(^VA(200,APCLAP,0),U),1:$P(^DIC(16,APCLAP,0),U))
 S APCLDISC="" D CHKDISC
 Q:$D(APCLSKIP)
 S ^(APCLDISC)=$S($D(^TMP("APCLVPVC",APCLJOB,APCLBTH,APCLNAME,APCLDISC)):^(APCLDISC)+1,1:1)
 Q
EOJ K APCLVLOC,APCLVREC,APCLCLIN,APCLSKIP,APCL1,APCL2,APCLAP,APCLDISC,APCLPPOV,APCLX,APCLHIGH,APCLDX,APCLLOW,APCLICD,APCLDA1,APCLDA2,APCLY,APCLSRT2,APCLDATE,APCLPROV,APCLSEC,APCLZ,APCLLOCC
 Q
 ;
CHKDISC ;
 I $P(^DD(9000010.06,.01,0),U,2)[200 D CHKDISC2 Q  ;FILE 200 CONV
 S APCLY=$P(^DIC(6,APCLAP,0),U,4)
 I APCLY="" S APCLDISC="??" Q
 S APCLDISC=$P(^DIC(7,APCLY,0),U) I APCLDISC="" S APCLDISC="??" Q
 Q
 ;
 ;
CHKDISC2 ;CHECK DISC IF CONVERTED TO FILE 200
 I '$D(^VA(200,APCLAP)) S APCLSKIP=1 Q
 S APCLDPTR=$$PROVCLS^XBFUNC1(APCLAP,"I") I APCLDPTR=""!(APCLDPTR="UNKNOWN") S APCLDISC="???" Q
 S APCLDISC=$$PROVCLSC^XBFUNC1(APCLAP) I APCLDISC="" S APCLDISC="UNKNOWN"
 Q
 ;
PRINT ;
 S APCL80S="*******************************************************************************"
 S APCLDT=$$FMTE^XLFDT(DT)
 S (APCLTOT,APCLPG)=0 D HEAD
 S APCLSORT=0 K APCLQUIT
 F I=0:0 S APCLSORT=$O(^TMP("APCLVPVC",APCLJOB,APCLBTH,APCLSORT)) Q:APCLSORT=""!($D(APCLQUIT))  D PRINT1
 G:$D(APCLQUIT) DONE
 I $Y>(IOSL-5) D HEAD G:$D(APCLQUIT) DONE
 W !?61,"-------",!
 W ?52,"Total:",?60,$J(APCLTOT,8),!
DONE ;
 D DONE^APCLOSUT
 K ^TMP("APCLVPVC",APCLJOB,APCLBTH)
 Q
PRINT1 ;
 I $Y>(IOSL-5) D HEAD Q:$D(APCLQUIT)
 S APCLSRT2=$O(^TMP("APCLVPVC",APCLJOB,APCLBTH,APCLSORT,""))
 S APCLPRNT=APCLSORT
 W !?5,$E(APCLPRNT,1,25),?35,$E(APCLSRT2,1,20),?60,$J(^TMP("APCLVPVC",APCLJOB,APCLBTH,APCLSORT,APCLSRT2),8)
 S APCLTOT=APCLTOT+^TMP("APCLVPVC",APCLJOB,APCLBTH,APCLSORT,APCLSRT2)
 Q
 I $E(IOST)="C",IO=IO(0) W ! S DIR(0)="EO" D ^DIR K DIR I Y=0!(Y="^")!($D(DTOUT)) S APCLQUIT="" Q
HEAD1 ;
 W:$D(IOF) @IOF S APCLPG=APCLPG+1
 W APCL80S,!
 W "*",?3,$P(^DIC(4,APCLSITE,0),U),?58,APCLDT,?72,"Page ",APCLPG,?78,"*",!
 W "*",?78,"*",!
 S APCLLENG=26
 W "*",?((80-APCLLENG)/2),"NUMBER OF VISITS BY PROVIDER",?78,"*",!
 W "*",?26,"SEARCH TEMPLATE: ",$P(^DIBT(APCLSEAT,0),U),?78,"*",!
 W APCL80S,!
 W !!
 W ?5,"PROVIDER",?35,"CLASS",?60,"# VISITS",!
 Q