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

AMHRBV1.m

Go to the documentation of this file.
AMHRBV1 ; IHS/CMI/LAB - PRNT BILL VSTS ;
 ;;4.0;IHS BEHAVIORAL HEALTH;**5**;JUN 02, 2010;Build 18
START ;
 S AMH80E="==============================================================================="
 S AMH80D="-------------------------------------------------------------------------------"
 S AMHPG=0 D HEAD I '$D(^XTMP("AMHRBV",AMHJOB,AMHBT)) W !,"No visits to report",! G DONE
 S AMHPN=0 K AMHQUIT
 F  S AMHPN=$O(^XTMP("AMHRBV",AMHJOB,AMHBT,AMHPN)) Q:AMHPN=""!($D(AMHQUIT))  D DFN
 G:$D(AMHQUIT) DONE
 I $Y>(IOSL-6) D HEAD G:$D(AMHQUIT) DONE
DONE ;
 D DONE^AMHLEIN,^AMHEKL
 K ^XTMP("AMHRBV",AMHJOB,AMHBT)
 Q
DFN ;
 S DFN="" F  S DFN=$O(^XTMP("AMHRBV",AMHJOB,AMHBT,AMHPN,DFN)) Q:DFN=""!($D(AMHQUIT))  D @AMHPROC
 Q
VISIT ;ENTRY POINT
 W !?8," DATE",?16,"VISIT",?24,"PD",?27,"PRV",?31,"ACT",?35,"MIN",?40,"DSM/PC",?47,"BH PROVIDER NARRATIVE",?73,"ICD DX"
 W !?7 F I=1:1:72 W "-"
 S AMHRDFN=0 F  S AMHRDFN=$O(^XTMP("AMHRBV",AMHJOB,AMHBT,AMHPN,DFN,AMHRDFN)) Q:AMHRDFN'=+AMHRDFN!($D(AMHQUIT))  S AMHREC=^AMHREC(AMHRDFN,0) D VWRT
 Q
VWRT ;
 I $Y>(IOSL-5) D HEAD Q:$D(AMHQUIT)
 S Y=$P(+AMHREC,".") S AMHDATE=$E(Y,4,5)_"/"_$E(Y,6,7)_"/"_$E(Y,2,3)
 K ^UTILITY("DIQ1",$J)
 K DIQ,DIC,DA,DR
 S DIC="^AMHREC(",DR=".07",DA=AMHRDFN,DIQ(0)="E" D EN^DIQ1 K DIC,DA,DR,DIQ
 S AMHCAT=$E(^UTILITY("DIQ1",$J,9002011,AMHRDFN,.07,"E"),1,7)
 K ^UTILITY("DIQ1",$J)
 K DIQ,DIC,DA,DR
 S DIC="^AMHREC(",DR=".06",DA=AMHRDFN,DIQ(0)="E" D EN^DIQ1 K DIC,DA,DR,DIQ
 S AMHACT=$E(^UTILITY("DIQ1",$J,9002011,AMHRDFN,.06,"E"),1,2)
 S AMHMIN=$P(AMHREC,U,12)
 K ^UTILITY("DIQ1",$J)
 S (AMH1,AMH2)=0 F  S AMH2=$O(^AMHRPROV("AD",AMHRDFN,AMH2)) Q:AMH2=""  I $P(^AMHRPROV(AMH2,0),U,4)="P" S AMH1=AMH1+1,AMHAP=$P(^(0),U)
 I AMH1=0 Q
 S AMHDISC="",AMHINI="" D CHKDISC
 W !?7,AMHDATE,?16,AMHCAT,?24,AMHDISC,?27,AMHINI,?31,AMHACT,?35,AMHMIN
 S (AMH1,AMH2)=0 F  S AMH1=$O(^AMHRPRO("AD",AMHRDFN,AMH1)) Q:AMH1'=+AMH1!($D(AMHQUIT))  S AMHX=^AMHRPRO(AMH1,0),AMH2=AMH2+1 D WPOV
 I $P(AMHREC,U,29) W !,?7,"Evaluation & Management: ",$$VAL^XBDIQ1(9002011,AMHRDFN,.29)
CPTS ;display cpt codes
 S (AMH1,AMH2)=0 F  S AMH1=$O(^AMHRPROC("AD",AMHRDFN,AMH1)) Q:AMH1'=+AMH1!($D(AMHQUIT))  S AMHX=^AMHRPROC(AMH1,0),AMH2=AMH2+1 D WCPT
 Q
WPOV ;
 I $Y>(IOSL-6),AMH2>1 D HEAD Q:$D(AMHQUIT)
 Q:$P(AMHX,U)=""
 ;W:AMH2>1 ! 
 W ?40,$P(^AMHPROB($P(AMHX,U),0),U) W ?47,$E($$GET1^DIQ(9002011.01,AMHX,.04),1,25),?73,$P(^AMHPROB($P(AMHX,U),0),U,5)
 W !
 Q
WCPT ;
 I $Y>(IOSL-6),AMH2>1 D HEAD Q:$D(AMHQUIT)
 Q:$P(AMHX,U)=""
 W:AMH2>1 ! W ?40,$P($$CPT^ICPTCOD($P(AMHX,U),$P($P(^AMHREC(AMHRDFN,0),U),".")),U,2),"  ",$E($P($$CPT^ICPTCOD($P(AMHX,U),$P($P(^AMHREC(AMHRDFN,0),U),".")),U,3),1,25)
 Q
CHKDISC ;
 Q:'$D(^VA(200,AMHAP))
 S AMHDISC=$$PPCLSC^AMHUTIL(AMHRDFN)
 S AMHINI=$$PPINI^AMHUTIL(AMHRDFN)
 Q
1 ;
 I $Y>(IOSL-9) D HEAD Q:$D(AMHQUIT)
 S AMHCHMP=$O(^AUTNINS("B","CHAMPUS",0))
 D HD
 Q:'$D(^AUPNPAT(DFN,11))
 S X=$P(^AUPNPAT(DFN,11),U,11)
 W !?8,AMHCOPN(X)
 I ($P(^AUTTBEN(X,0),U,2)="04"!($P(^AUTTBEN(X,0),U,2)="31")),AMHCHMP]"" D PRVT1
 D VISIT
 Q
PRVT1 ;
 Q:AMHCHMP=""
 S Y=$O(^AUPNPRVT("AB",AMHCHMP,DFN,0)) Q:Y=""
 S AMHX=^AUPNPRVT(DFN,11,Y,0) W ?40,"Sponsor: ",$P(AMHX,U,4),?65,"SSN: " S X=$P(AMHX,U,2) W $E(X,1,3),"-",$E(X,4,5),"-",$E(X,6,9)
 Q
HD ;ENTRY POINT
 S (DOB,Y)=$P(^DPT(DFN,0),U,3) I DOB]"" D DD^%DT S DOB=Y
 S AMHHRN=$P(^AUPNPAT(DFN,41,AMHSU,0),U,2)
 S ABHN=$P(^DPT(DFN,0),U,9)
 W !!,AMHHRN,?8,AMHPN,?40,DOB,?60,ABHN
 Q
2 ;
 I $Y>(IOSL-9) D HEAD Q:$D(AMHQUIT)
 D HD
 S AMHMN=$S($D(^AUPNMCR(DFN,21)):$P(^AUPNMCR(DFN,21),U),1:"")
 S AMHMDOB=$S($D(^AUPNMCR(DFN,21)):$P(^AUPNMCR(DFN,21),U,2),1:"") I AMHMDOB]"" S Y=AMHMDOB D DD^%DT S AMHMDOB=Y
 S AMHMEDN=$P(^AUPNMCR(DFN,0),U,3)_$S($P(^(0),U,4)]"":$P(^AUTTMCS($P(^(0),U,4),0),U),1:"")
 W !?8,"Medicare Name: ",AMHMN,?56,"DOB: ",DOB
 S AMHMDFN=0 F  S AMHMDFN=$O(^AUPNMCR(DFN,11,AMHMDFN)) Q:AMHMDFN'=+AMHMDFN!($D(AMHQUIT))  I $D(^AUPNMCR(DFN,11,AMHMDFN,0)) S AMHREC=^(0) D 22
 D VISIT
 Q
22 ;
 Q:AMHVAL'[$P(^AUPNMCR(DFN,11,AMHMDFN,0),U,3)
 Q:$P(^AUPNMCR(DFN,11,AMHMDFN,0),U)>AMHED
 I $P(^AUPNMCR(DFN,11,AMHMDFN,0),U,2)]"",$P(^(0),U,2)<AMHSD Q
 I $Y>(IOSL-5) D HEAD Q:$D(AMHQUIT)
 W !?8,"Coverage:",?19,$P(AMHREC,U,3) S Y=$P(AMHREC,U) D:Y]"" DD^%DT W ?23,"Beg. Date: ",?34,Y S Y=$P(AMHREC,U,2) D:Y]"" DD^%DT W ?49,"End. Date: ",?61,Y,!?8,"Medicare #: ",AMHMEDN,!
 Q
5 ;
 D 5^AMHRBV11
 Q
4 ;
 D 4^AMHRBV11
 Q
6 ;
 D 6^AMHRBV11
 Q
 I 'AMHPG 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 AMHQUIT="" Q
HEAD1 ;
 W:$D(IOF) @IOF S AMHPG=AMHPG+1
 W !?13,"********** CONFIDENTIAL PATIENT INFORMATION **********"
 W !?(80-$L($P(^DIC(4,AMHSU,0),U))/2),$P(^DIC(4,AMHSU,0),U),?72,"Page ",AMHPG,!
 S AMHLENG=64+$L(AMHNAR)
 W ?((80-AMHLENG)/2),"POTENTIALLY BILLABLE BEHAVIORAL HEALTH VISITS FOR ",AMHNAR,!
 W ?19,"Visit Dates:  ",AMHSDY," and ",AMHEDY,!
 W !!?2,"HRCN",?8,"Patient Name",?40,"Date of Birth",?60,"      SSN"
 W !,AMH80D
 Q