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

APCL2AP.m

Go to the documentation of this file.
APCL2AP ; IHS/CMI/LAB - print apc report 1A ;
 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
 ;CMI/TUCSON/LAB - patch 3
START ;
 S APCL132="__________________________________________________________________________________________________________________________________"
 S APCLMOL="OCT.,NOV.,DEC.,JAN.,FEB.,MAR.,APR.,MAY ,JUNE,JULY,AUG.,SEPT"
 ;beginning Y2K
 ;S Y=$E(APCLFYE,1,3)_"0000" D DD^%DT S APCLFYD=Y S Y=DT D DD^%DT S APCLDT=Y ;Y2000
 S APCLFYD=APCL("FY") S Y=DT D DD^%DT S APCLDT=Y ;Y2000
 ;end Y2K
 D START1
 Q:$D(APCLQUIT)
 D DONE
 Q
START1 ;
 S APCLLOC=0 F  S APCLLOC=$O(APCLLOCS(APCLLOC)) Q:APCLLOC'=+APCLLOC!($D(APCLQUIT))  D
 .S APCLLOCC=$P(^AUTTLOC(APCLLOC,0),U,10),APCLLOCP=$P(^DIC(4,APCLLOC,0),U)
 .S APCLAREA=$P(^AUTTLOC(APCLLOC,0),U,4) I APCLAREA="" S (APCLAREA,APCLAREC)="???" G SU
 .I '$D(^AUTTAREA(APCLAREA,0)) S (APCLAREA,APCLAREC)="???" G SU
 .S APCLAREC=$P(^AUTTAREA(APCLAREA,0),U,2),APCLAREA=$P(^AUTTAREA(APCLAREA,0),U)
 .D SU
 .Q
 Q
SU ;
 S APCLSU=$P(^AUTTLOC(APCLLOC,0),U,5) I APCLSU="" S (APCLSU,APCLSUC)="???" G START2
 I '$D(^AUTTSU(APCLSU,0)) S (APCLSU,APCLSUC)="999" G START2
 S APCLSUC=$P(^AUTTSU(APCLSU,0),U,3),APCLSU=$P(^AUTTSU(APCLSU,0),U)
START2 ;
 S (APCLPG,APCLDISC,APCLPRIT)=0,APCLPDC="" D HEAD
 K APCLQUIT
 I APCLGRAN(APCLLOC)=0 W !!,"NO VISITS FOR THIS FISCAL YEAR",! G DONE
 F  S APCLPDC=$O(^XTMP("APCL2A",APCLJOB,APCLBT,APCLLOC,"MODISC",APCLPDC)) Q:APCLPDC=""!($D(APCLQUIT))  D P
 G:$D(APCLQUIT) DONE
 I $Y>(IOSL-8) D HEAD G:$D(APCLQUIT) DONE
 W !!," T O T A L",?21,$J(APCLGRAN(APCLLOC),7),?30,"100.0"
 S APCLMON="",APCLTAB=36 F APCLJ=10,11,12,1,2,3,4,5,6,7,8,9 S APCLMON=$S($D(^XTMP("APCL2A",APCLJOB,APCLBT,APCLLOC,"MONTOTALL",APCLJ)):^(APCLJ),1:0) W ?APCLTAB,$J(APCLMON,6) S APCLTAB=APCLTAB+8
 W !!,"*TOTAL PRIMARY PVDR",?21,$J(APCLPRIT,7) S APCLP=(((APCLPRIT/APCLGRAN(APCLLOC))*100.00)+.05),APCLP=$P(APCLP,".")_"."_$E($P(APCLP,".",2))
 W ?30,$J(APCLP,5) S APCLMON="",APCLTAB=36 F APCLJ=10,11,12,1,2,3,4,5,6,7,8,9 S APCLMON=$S($D(^XTMP("APCL2A",APCLJOB,APCLBT,APCLLOC,"MONTOTPCP",APCLJ)):^(APCLJ),1:0) W ?APCLTAB,$J(APCLMON,6) S APCLTAB=APCLTAB+8
 I $D(^XTMP("APCL2A",APCLJOB,APCLBT,APCLLOC,"NO EXPORT")) D  I 1
 .I $D(^XTMP("APCL2A",APCLJOB,APCLBT,APCLLOC,"IN XREF")) W !!!,^("IN XREF")," visits were not exported to the National Data Warehouse because they ",!,"were posted or modified after the last NDW export was generated.",!
 .W !,($S($D(^XTMP("APCL2A",APCLJOB,APCLBT,APCLLOC,"NO EXPORT")):^("NO EXPORT"),1:0)-$S($D(^XTMP("APCL2A",APCLJOB,APCLBT,APCLLOC,"IN XREF")):^("IN XREF"),1:0))
 .W " visits were not exported because of missing or invalid data.  To see a list"
 .W !,"of these visits so that they may be resubmitted use the option ",!,"called 'List APC-1A Visits Not Exported.",!
 ;I $D(^XTMP("APCL2A",APCLJOB,APCLBT,APCLLOC,"DUPLICATE")) D  I 1
 ;.W !,"There were ",^XTMP("APCL2A",APCLJOB,APCLBT,APCLLOC,"DUPLICATE")," instances of 2 or more visits"
 ;.W " by a patient to the same clinic, same provider in the same day.  These ",^XTMP("APCL2A",APCLJOB,APCLBT,APCLLOC,"DUPLICATE")," will not be",!,"counted in the report produced at the Data Center, but are counted in the report above.",!
 ;I $D(^XTMP("APCL2A",APCLJOB,APCLBT,APCLLOC,"DUPLICATE"))!($D(^XTMP("APCL2A",APCLJOB,APCLBT,APCLLOC,"NO EXPORT"))) D  I 1
 ;.W !,"This accounts for a total of ",($S($D(^XTMP("APCL2A",APCLJOB,APCLBT,APCLLOC,"NO EXPORT")):^("NO EXPORT"),1:0)+$S($D(^XTMP("APCL2A",APCLJOB,APCLBT,APCLLOC,"DUPLICATE")):^("DUPLICATE"),1:0))
 ;W " visits that will be counted in this report but not in the 1A report from the Data Center.",!
 W !
 Q
DONE D DONE^APCLOSUT
 K ^XTMP("APCL2A",APCLJOB,APCLBT)
 Q
P ;
 S APCLDISC="" F  S APCLDISC=$O(^XTMP("APCL2A",APCLJOB,APCLBT,APCLLOC,"MODISC",APCLPDC,APCLDISC)) Q:APCLDISC=""!($D(APCLQUIT))  D P1
 Q
 ;
P1 ;
 I $Y>(IOSL-5) D HEAD Q:$D(APCLQUIT)
 S (APCLP,APCLT)=^XTMP("APCL2A",APCLJOB,APCLBT,APCLLOC,"DISCTOT",APCLPDC,APCLDISC),APCLP=(((APCLP/APCLGRAN(APCLLOC))*100.00)+.05),APCLP=$P(APCLP,".")_"."_$E($P(APCLP,".",2))
 I APCLDISC="??" S APCLDISN="NO PROVIDER CLASS" G W
 S APCLDISN=$P($G(^DIC(7,APCLDISC,9999999)),U)_" "_$E($P(^DIC(7,APCLDISC,0),U),1,17) K APCLPRIM D CHKPRIM I $D(APCLPRIM) S APCLDISN=$E(APCLDISN,1,19)_"*"
W W !,APCLDISN,?22,$J(APCLT,6),?30,$J(APCLP,5)
 S APCLMON="",APCLTAB=36 F APCLJ=10,11,12,1,2,3,4,5,6,7,8,9 S APCLMON=$S($D(^XTMP("APCL2A",APCLJOB,APCLBT,APCLLOC,"MODISC",APCLPDC,APCLDISC,APCLJ)):^(APCLJ),1:0) W ?APCLTAB,$J(APCLMON,6) S APCLTAB=APCLTAB+8 D MONTOT
 Q
 ;
MONTOT ;set up month totals for all visits and pcp visits
 S ^(APCLJ)=$S($D(^XTMP("APCL2A",APCLJOB,APCLBT,APCLLOC,"MONTOTALL",APCLJ)):^(APCLJ)+APCLMON,1:APCLMON)
 I $D(APCLPRIM) S ^(APCLJ)=$S($D(^XTMP("APCL2A",APCLJOB,APCLBT,APCLLOC,"MONTOTPCP",APCLJ)):^(APCLJ)+APCLMON,1:APCLMON)
 Q
CHKPRIM ;
 ;I $D(^APCLCNTL(1,11,"B",$P(^DIC(7,APCLDISC,9999999),U))) S APCLPRIM=1,APCLPRIT=APCLPRIT+APCLT
 I $P($G(^DIC(7,APCLDISC,9999999)),U,3)="Y" S APCLPRIM=1,APCLPRIT=APCLPRIT+APCLT
 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 APCL132,!
 W !?5,"AREA:  ",APCLAREC,"      ",APCLAREA,?50,"PCC-AMBULATORY PATIENT CARE REPORT 1A",?95,APCLDT,?110,"Page ",APCLPG
 W !?5,"S.U.:  ",APCLSUC,"      ",APCLSU,?58,"FISCAL YEAR ",APCLFYD
 W !?5,"FAC.:  ",APCLLOCC,"  ",APCLLOCP
 W !?24,"AMBULATORY CARE VISITS TO SERVICE LOCATION BY PRIMARY PROVIDER AND MONTH OF SERVICE",!
 W APCL132,!
 W "PRIMARY PROVIDER",?23,"YR-TO",?30,"% OF"
 W !,"   OF SERVICE",?23,"DATE",?30,"TOTAL"
 S APCLTAB=38 F APCLX=1:1:12 W ?APCLTAB,$P(APCLMOL,",",APCLX) S APCLTAB=APCLTAB+8
 W !,APCL132
 Q
 ;