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

APCLBV1.m

Go to the documentation of this file.
APCLBV1 ; IHS/CMI/LAB - PRNT BILL VSTS ;
 ;;2.0;IHS PCC SUITE;**11**;MAY 14, 2009;Build 58
 ;
 ;cmi/anch/maw 9/10/2007 code set versioning in WPOV
 ;
START ;
 S APCL80E="==============================================================================="
 S APCL80D="-------------------------------------------------------------------------------"
 S (APCLPG,APCLPN)=0
 I '$D(^XTMP("APCLBV",APCLJOB,APCLBT)) D HEAD W !,"No visits to report",! G DONE
 G:$D(APCLPALL) ALL
 S APCLPN=0 K APCLQUIT
 D HEAD F  S APCLPN=$O(^XTMP("APCLBV",APCLJOB,APCLBT,APCLRNUM,APCLPN)) Q:APCLPN=""!($D(APCLQUIT))  D DFN
 I $Y>(IOSL-4) D HEAD G:$D(APCLQUIT) DONE
 I APCLRNUM=1 W !!,"Total Number of Visits for ",APCLNAR(APCLRNUM),":  ",APCLT1
 I APCLRNUM=2 W !!,"Total Number of Visits for ",APCLNAR(APCLRNUM),":  ",APCLT2
 I APCLRNUM=3 W !!,"Total Number of Visits for ",APCLNAR(APCLRNUM),":  ",APCLT3
 I APCLRNUM=4 W !!,"Total Number of Visits for ",APCLNAR(APCLRNUM),":  ",APCLT4
 I APCLRNUM=5 W !!,"Total Number of Visits for ",APCLNAR(APCLRNUM),":  ",APCLT5
 I APCLRNUM=6 W !!,"Total Number of Visits for ",APCLNAR(APCLRNUM),":  ",APCLT6
 W !
 D DONE
 Q
 ;
ALL ;print ALL coverage reports
 F APCLCNTR=1:1:6 Q:$D(APCLQUIT)  S (APCLPROC,APCLRNUM)=APCLCNTR D ALL1 Q:$D(APCLQUIT)  D PTN
 I $Y>(IOSL-4) D HEAD G:$D(APCLQUIT) DONE
 W !!,"Total Number of Visits:  ",APCLTOTV
 D DONE
 Q
ALL1 ;
 D HEAD Q:$D(APCLQUIT)
 I '$D(^XTMP("APCLBV",APCLJOB,APCLBT,APCLRNUM)) W !,"No visits to report",! S APCLPN=0 K APCLQUIT
 Q
DONE ;
 D DONE^APCLOSUT
 K ^XTMP("APCLBV",APCLJOB,APCLBT)
 Q
PTN ;process patient name level
 F  S APCLPN=$O(^XTMP("APCLBV",APCLJOB,APCLBT,APCLRNUM,APCLPN)) Q:APCLPN=""!(APCLPROC'=APCLRNUM)!($D(APCLQUIT))  D DFN
 ;write totals
 I $Y>(IOSL-4) D HEAD Q:$D(APCLQUIT)
 I APCLRNUM=1 W !!,"Total Number of Visits for ",APCLNAR(APCLRNUM),":  ",APCLT1
 I APCLRNUM=2 W !!,"Total Number of Visits for ",APCLNAR(APCLRNUM),":  ",APCLT2
 I APCLRNUM=3 W !!,"Total Number of Visits for ",APCLNAR(APCLRNUM),":  ",APCLT3
 I APCLRNUM=4 W !!,"Total Number of Visits for ",APCLNAR(APCLRNUM),":  ",APCLT4
 I APCLRNUM=5 W !!,"Total Number of Visits for ",APCLNAR(APCLRNUM),":  ",APCLT5
 I APCLRNUM=6 W !!,"Total Number of Visits for ",APCLNAR(APCLRNUM),":  ",APCLT6
 W !
 Q
DFN ;
 S DFN="" F  S DFN=$O(^XTMP("APCLBV",APCLJOB,APCLBT,APCLRNUM,APCLPN,DFN)) Q:DFN=""!($D(APCLQUIT))  D @APCLPROC
 Q
VISIT ;ENTRY POINT
 W !?8,"Visit Date",?21,"Category",?37,"PRV",?41,"ICD DX",?51,"PROVIDER NARRATIVE"
 W !?8 F I=1:1:71 W "-"
 S APCLVDFN=0 F  S APCLVDFN=$O(^XTMP("APCLBV",APCLJOB,APCLBT,APCLRNUM,APCLPN,DFN,APCLVDFN)) Q:APCLVDFN'=+APCLVDFN!($D(APCLQUIT))  S APCLVREC=^AUPNVSIT(APCLVDFN,0) D VWRT
 Q
VWRT ;
 I $Y>(IOSL-5) D HEAD Q:$D(APCLQUIT)
 S Y=$P(+APCLVREC,".") D DD^%DT S APCLDATE=Y
 K ^UTILITY("DIQ1",$J)
 K DIQ,DIC,DA,DR
 S DIC="^AUPNVSIT(",DR=".07",DA=APCLVDFN,DIQ(0)="E" D EN^DIQ1 K DIC,DA,DR,DIQ
 S APCLCAT=^UTILITY("DIQ1",$J,9000010,APCLVDFN,.07,"E")
 S (APCL1,APCL2)=0 F  S APCL2=$O(^AUPNVPRV("AD",APCLVDFN,APCL2)) Q:APCL2=""  I $P(^AUPNVPRV(APCL2,0),U,4)="P" S APCL1=APCL1+1,APCLAP=$P(^(0),U)
 I APCL1=0 Q
 S APCLDISC="" D CHKDISC
 W !?8,APCLDATE,?21,APCLCAT,?37,APCLDISC
 S (APCL1,APCL2)=0 F  S APCL1=$O(^AUPNVPOV("AD",APCLVDFN,APCL1)) Q:APCL1'=+APCL1!($D(APCLQUIT))  S APCLX=^AUPNVPOV(APCL1,0),APCL2=APCL2+1 D WPOV
 I $D(^AUPNVINP("AD",APCLVDFN)) S Y=$O(^AUPNVINP("AD",APCLVDFN,"")),Y=$P(^AUPNVINP(Y,0),U) D DD^%DT W !?8,"DISCHARGE DATE:  ",Y
 Q
WPOV ;
 I $Y>(IOSL-6),APCL2>1 D HEAD Q:$D(APCLQUIT)
 Q:$P(APCLX,U)=""
 Q:$P(APCLX,U,4)=""
 ;W:APCL2>1 ! W ?41,$P(^ICD9($P(APCLX,U),0),U),?49,$E($P(^AUTNPOV($P(APCLX,U,4),0),U),1,20)  ;cmi/anch/maw 9/10/2007 orig line
 W:APCL2>1 ! W ?41,$P($$ICDDX^ICDEX($P(APCLX,U)),U,2),?51,$E($$VAL^XBDIQ1(9000010.07,APCL1,.04),1,20)  ;cmi/anch/maw 9/10/2007 code set versioning
 Q
CHKDISC ;
 I $P(^DD(9000010.06,.01,0),U,2)[6 G CHKDISC6
 S APCLDISC=$$PROVCLSC^XBFUNC1(APCLAP)
 Q
CHKDISC6 ;
 Q:'$D(^DIC(6,APCLAP))
 S APCLY=$P(^DIC(6,APCLAP,0),U,4)
 Q:APCLY=""
 Q:'$D(^DIC(7,APCLY,9999999))
 S APCLDISC=$P(^DIC(7,APCLY,9999999),U)
 Q
HD ;ENTRY POINT
 S (DOB,Y)=$P(^DPT(DFN,0),U,3) I DOB]"" D DD^%DT S DOB=Y
 S APCLHRN=$P(^AUPNPAT(DFN,41,APCLSU,0),U,2)
 S SSN=$P(^DPT(DFN,0),U,9)
 W !!,APCLHRN,?8,APCLPN,?40,DOB,?60,SSN
 Q
1 ;Commissioned Officers/Dependents
 D 1^APCLBV11
 Q
2 ;Medicare Part A
 D 2^APCLBV11
 Q
3 ;Medicare Part B
 D 2^APCLBV11
 Q
5 ;Medicaid
 D 5^APCLBV11
 Q
4 ;Private Insurance
 D 4^APCLBV11
 Q
6 ;Non-Indians
 D 6^APCLBV11
 Q
 I 'APCLPG G HEAD1
 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 ?(80-$L($P(^DIC(4,APCLSU,0),U))/2),$P(^DIC(4,APCLSU,0),U),?72,"Page ",APCLPG,!
 S APCLLENG=32+$L(APCLNAR(APCLRNUM))
 W ?((80-APCLLENG)/2),"POTENTIALLY BILLABLE VISITS FOR:  ",APCLNAR(APCLRNUM),!
 W ?19,"Visit Dates:  ",APCLSDY," and ",APCLEDY,!
 S APCLLENG=$L(APCLSCP)+28 W ?((80-APCLLENG)/2),"SERVICE CATEGORY OF VISIT:  ",APCLSCP
 ;
 I APCLCLN W ! S APCLLENG=$L($P(^DIC(40.7,APCLCLN,0),U))+0 W ?((80-APCLLENG)/2),"CLINIC:  ",$P(^DIC(40.7,APCLCLN,0),U)
 W !!?2,"HRCN",?8,"Patient Name",?40,"Date of Birth",?60,"   SSN"
 W !,APCL80D
 Q