ABMM2P10 ;IHS/SD/SDR - MU Patient Volume EP Report ;
;;2.6;IHS 3P BILLING SYSTEM;**15**;NOV 12, 2009;Build 251
;IHS/SD/SDR - 2.6*15 - HEAT161159 - Changed PT LST to sort differently so there won't be duplicate vsts on pt lst.
;IHS/SD/SDR - 2.6*15 - HEAT174501 - Added Provider NPI to host file
;IHS/SD/SDR - 2.6*15 - HEAT171490 - Added facility NPI and TIN to pt list host file
;IHS/SD/SDR - 2.6*15 - HEAT183289 - Added Tribal self-insured flag to output and summary total lines
;IHS/SD/SDR - 2.6*15 - HEAT188548- format visit time to 4 digits
;
PATIENT ;EP
I ABMY("RFMT")="P",$G(ABMFN)'="" D PTHSTFL Q
S ABM("PG")=1
S ABMSDT=$P($G(^XTMP("ABM-PVP2",$J,"PRV TOP")),U,2)
D HDR^ABMM2PV3
Q:ABMSDT=""
S ABMVLOC=0
F S ABMVLOC=$O(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC)) Q:'ABMVLOC D Q:(IOST["C")&((+$G(Y)=0)!($D(DIRUT)!$D(DIROUT)!$D(DTOUT)!$D(DUOUT)))
.D PTHDR^ABMM2PV3
.;start old abm*2.6*15 HEAT161159
.;S ABMITYP=""
.;F S ABMITYP=$O(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP)) Q:ABMITYP="" D Q:(IOST["C")&((+$G(Y)=0)!($D(DIRUT)!$D(DIROUT)!$D(DTOUT)!$D(DUOUT)))
.;.S ABMINS=""
.;.F S ABMINS=$O(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS)) Q:ABMINS="" D Q:(IOST["C")&((+$G(Y)=0)!($D(DIRUT)!$D(DIROUT)!$D(DTOUT)!$D(DUOUT)))
.;..S ABMPTL=""
.;..F S ABMPTL=$O(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS,ABMPTL)) Q:ABMPTL="" D Q:(IOST["C")&((+$G(Y)=0)!($D(DIRUT)!$D(DIROUT)!$D(DTOUT)!$D(DUOUT)))
.;...S ABMPTF=""
.;...F S ABMPTF=$O(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS,ABMPTL,ABMPTF)) Q:ABMPTF="" D Q:(IOST["C")&((+$G(Y)=0)!($D(DIRUT)!$D(DIROUT)!$D(DTOUT)!$D(DUOUT)))
.;....S ABMVDT=0
.;....F S ABMVDT=$O(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS,ABMPTL,ABMPTF,ABMVDT)) Q:'ABMVDT D Q:(IOST["C")&((+$G(Y)=0)!($D(DIRUT)!$D(DIROUT)!$D(DTOUT)!$D(DUOUT)))
.;.....S ABMVDFN=0
.;.....F S ABMVDFN=$O(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS,ABMPTL,ABMPTF,ABMVDT,ABMVDFN)) Q:'ABMVDFN D Q:(IOST["C")&((+$G(Y)=0)!($D(DIRUT)!$D(DIROUT)!$D(DTOUT)!$D(DUOUT)))
.;......S ABMPT=$P($G(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS,ABMPTL,ABMPTF,ABMVDT,ABMVDFN)),U,2)
.;......S ABMTRIEN=$P($G(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS,ABMPTL,ABMPTF,ABMVDT,ABMVDFN)),U,3)
.;......S IENS=ABMVLOC_","_ABMPT_","
.;......S ABMHRN=$$GET1^DIQ(9000001.41,IENS,.02)
.;......W !,$E(ABMPTL_", "_ABMPTF,1,16) ;pt name
.;......W ?18,ABMHRN ;HRN
.;......W ?25,$E($$GET1^DIQ(9000010,ABMVDFN,.07,"E"),1,3) ;Cat
.;......W ?29,$E($$GET1^DIQ(9000010,ABMVDFN,.08,"E"),1,8) ;clin
.;......W ?39,$S(ABMITYP="X":"",1:ABMITYP) ;itype
.;......W ?42,$S(ABMINS="NO BILL":"NOT BILLED",1:$E(ABMINS,1,10)) ;ins
.;......W ?53,$$CDT^ABMDUTL(ABMVDT) ;vst dt
.;......W ?70,$S(+ABMTRIEN:$$SDTO^ABMDUTL(ABMTRIEN),1:"") ;dt pd
.;......I $P($G(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS,ABMPTL,ABMPTF,ABMVDT,ABMVDFN)),U,4)'="" W ?79,$P(^(ABMVDFN),U,4)
.;......I $Y+5>IOSL D HD^ABMM2PV3,PTHDR^ABMM2PV3 Q:(IOST["C")&((+$G(Y)=0)!($D(DIRUT)!$D(DIROUT)!$D(DTOUT)!$D(DUOUT)))
.;end old start new HEAT161159
.S ABMVDT=0
.F S ABMVDT=$O(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMVDT)) Q:'ABMVDT D Q:(IOST["C")&((+$G(Y)=0)!($D(DIRUT)!$D(DIROUT)!$D(DTOUT)!$D(DUOUT)))
..S ABMVDFN=0
..F S ABMVDFN=$O(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMVDT,ABMVDFN)) Q:'ABMVDFN D Q:(IOST["C")&((+$G(Y)=0)!($D(DIRUT)!$D(DIROUT)!$D(DTOUT)!$D(DUOUT)))
...S ABMPT=$P($G(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMVDT,ABMVDFN)),U,2)
...S ABMTRIEN=$P($G(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMVDT,ABMVDFN)),U,3)
...S ABMPTL=$P($G(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMVDT,ABMVDFN)),U,10)
...S ABMPTF=$P($G(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMVDT,ABMVDFN)),U,11)
...S ABMITYP=$P($G(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMVDT,ABMVDFN)),U,8) ;abm*2.6*15
...S ABMINS=$P($G(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMVDT,ABMVDFN)),U,9) ;abm*2.6*15
...S IENS=ABMVLOC_","_ABMPT_","
...S ABMHRN=$$GET1^DIQ(9000001.41,IENS,.02)
...W !,$E(ABMPTL_", "_ABMPTF,1,16) ;pt name
...W ?18,ABMHRN ;HRN
...W ?25,$E($$GET1^DIQ(9000010,ABMVDFN,.07,"E"),1,3) ;Cat
...W ?29,$E($$GET1^DIQ(9000010,ABMVDFN,.08,"E"),1,8) ;clin
...W ?39,$S(ABMITYP="X":"",1:ABMITYP) ;itype
...W ?42,$S(ABMINS="NO BILL":"NOT BILLED",1:$E(ABMINS,1,10)) ;ins
...W ?53,$$CDT^ABMDUTL(ABMVDT) ;vst dt
...W ?70,$S(+ABMTRIEN:$$SDTO^ABMDUTL(ABMTRIEN),1:"") ;dt pd
...I $P($G(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMVDT,ABMVDFN)),U,4)'="" W ?79,$P(^(ABMVDFN),U,4)
...I $Y+5>IOSL D HD^ABMM2PV3,PTHDR^ABMM2PV3 Q:(IOST["C")&((+$G(Y)=0)!($D(DIRUT)!$D(DIROUT)!$D(DTOUT)!$D(DUOUT)))
;end new HEAT161159
Q
PTHSTFL ;EP
S ABMSDT=$P($G(^XTMP("ABM-PVP2",$J,"PRV TOP")),U,2)
K ABMDCNT
D OPEN^%ZISH("ABM",ABMPATH,ABMFN,"W")
Q:POP
U IO
S ABM("PG")=1
D HDR^ABMM2PV3
;W !,"Visit Location"_U_"Patient"_U_"Chart#"_U_"Policy Holder ID"_U_"Serv Cat"_U_"Clinic"_U_"InsType"_U_"BilledTo" ;abm*2.6*15 HEAT174501
W !,"Visit Location"_U_"Patient"_U_"Chart#"_U_"Policy Holder ID"_U_"Serv Cat"_U_"Clinic"_U_"Provider NPI"_U_"Provider"_U_"InsType"_U_"BilledTo" ;abm*2.6*15 HEAT174501
W U_"DateOfService"_U_"DatePaid"_U_"Medicaid/SchipPaid"_U_"Bill#"_U_"Payment"_U_"Primary POV"_U_"PRVT"_U_"MCR"_U_"MCD"_U_"CHIP"_U_"NEEDY INDIV"
W U_"Tribal self-insured" ;abm*2.6*15 HEAT183289
W U_"MCD ST" ;abm*2.6*15 HEAT164125
W U_"Facility NPI"_U_"Facility TIN"_U_"Record Indicator" ;abm*2.6*15 HEAT171490 and HEAT161159
Q:ABMSDT=""
S ABMVLOC=0
F S ABMVLOC=$O(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC)) Q:'ABMVLOC D
.;start old abm*2.6*16 HEAT161159
.;S ABMITYP=""
.;F S ABMITYP=$O(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP)) Q:ABMITYP="" D
.;.S ABMINS=""
.;.F S ABMINS=$O(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS)) Q:ABMINS="" D
.;..S ABMPTL=""
.;..F S ABMPTL=$O(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS,ABMPTL)) Q:ABMPTL="" D
.;...S ABMPTF=""
.;...F S ABMPTF=$O(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS,ABMPTL,ABMPTF)) Q:ABMPTF="" D
.;....S ABMVDT=0
.;....F S ABMVDT=$O(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS,ABMPTL,ABMPTF,ABMVDT)) Q:'ABMVDT D
.;.....S ABMP("VDT")=ABMVDT
.;.....S ABMVDFN=0
.;.....F S ABMVDFN=$O(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS,ABMPTL,ABMPTF,ABMVDT,ABMVDFN)) Q:'ABMVDFN D
.;......I +$G(^XTMP("ABM-PVP2",$J,"DUPS",ABMVDFN))=1 S ABMDCNT=+$G(ABMDCNT)+1
.;......S ^XTMP("ABM-PVP2",$J,"DUPS",ABMVDFN)=1
.;......S ABMPT=$P($G(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS,ABMPTL,ABMPTF,ABMVDT,ABMVDFN)),U,2)
.;......S ABMTRIEN=$P($G(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS,ABMPTL,ABMPTF,ABMVDT,ABMVDFN)),U,3)
.;......S IENS=ABMVLOC_","_ABMPT_","
.;......S ABMHRN=$$GET1^DIQ(9000001.41,IENS,.02)
.;......W !,$$GET1^DIQ(9999999.06,ABMVLOC,".02","E")
.;......W U_ABMPTL_", "_ABMPTF ;pt name
.;......W U_ABMHRN ;HRN
.;......K ABML
.;......D ELGCHK^ABMM2PV3
.;......S ABMMIEN=0
.;......K ABMMCDN
.;......I ($G(ABML("MCD"))!($G(ABML("CHIP")))) D
.;.......S ABMMIEN=+$G(ABMP("SAVE"))
.;.......I ABMMIEN D
.;........S ABMMCDN=$P($G(^AUPNMCD(ABMMIEN,0)),U,3)
.;.......I 'ABMMIEN D PRVTCHIP^ABMM2PV3
.;......I $G(ABMMCDN)'="" W U_ABMMCDN ;Medicaid # - policy holder ID
.;......I 'ABMMIEN W U
.;......W U_$$GET1^DIQ(9000010,ABMVDFN,.07,"E") ;Cat
.;......W U_$$GET1^DIQ(9000010,ABMVDFN,.08,"E") ;clin
.;......W U_$S(ABMITYP="X":"",1:ABMITYP) ;itype
.;......W U_$S(ABMINS="NO BILL":"NOT BILLED",1:$E(ABMINS,1,10)) ;insurer
.;......W U_$$CDT^ABMDUTL(ABMVDT) ;vst dt
.;......W U_$S(+ABMTRIEN:$$SDTO^ABMDUTL(ABMTRIEN),1:"") ;dt pd
.;......S ABMREC=$G(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS,ABMPTL,ABMPTF,ABMVDT,ABMVDFN))
.;......D ELGCHK^ABMM2PV3
.;......W U_$P($G(ABMREC),U,4)
.;......W U_$P($G(ABMREC),U,5)
.;......W U_$P($G(ABMREC),U,6)
.;......W U_$P($G(ABMREC),U,7)
.;......W U_ABMPI_U_ABMMCR_U_ABMMCD_U_ABMCHIP_U_ABMNI
.;end old start new HEAT161159
.S ABMVDT=0
.F S ABMVDT=$O(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMVDT)) Q:'ABMVDT D
..S ABMP("VDT")=ABMVDT
..S ABMVDFN=0
..F S ABMVDFN=$O(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMVDT,ABMVDFN)) Q:'ABMVDFN D
...I +$G(^XTMP("ABM-PVP2",$J,"DUPS",ABMVDFN))=1 S ABMDCNT=+$G(ABMDCNT)+1
...S ^XTMP("ABM-PVP2",$J,"DUPS",ABMVDFN)=1
...S ABMPT=$P($G(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMVDT,ABMVDFN)),U,2)
...S ABMTRIEN=$P($G(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMVDT,ABMVDFN)),U,3)
...S ABMREC=$G(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMVDT,ABMVDFN))
...S ABMPTL=$P(ABMREC,U,10)
...S ABMPTF=$P(ABMREC,U,11)
...S IENS=ABMVLOC_","_ABMPT_","
...S ABMHRN=$$GET1^DIQ(9000001.41,IENS,.02)
...W !,$$GET1^DIQ(9999999.06,ABMVLOC,".02","E")
...W U_ABMPTL_", "_ABMPTF ;pt name
...W U_ABMHRN ;HRN
...K ABML
...D ELGCHK^ABMM2PV3
...S ABMMIEN=0
...K ABMMCDN
...I ($G(ABML("MCD"))!($G(ABML("CHIP")))) D
....S ABMMIEN=+$G(ABMP("SAVE"))
....I ABMMIEN D
.....S ABMMCDN=$P($G(^AUPNMCD(ABMMIEN,0)),U,3)
....I 'ABMMIEN D PRVTCHIP^ABMM2PV3
...I $G(ABMMCDN)'="" W U_ABMMCDN ;Medicaid # - policy holder ID
...I 'ABMMIEN W U
...W U_$$GET1^DIQ(9000010,ABMVDFN,.07,"E") ;Cat
...W U_$$GET1^DIQ(9000010,ABMVDFN,.08,"E") ;clin
...W U_$P(ABMREC,U,12)_U_$P(ABMREC,U,13) ;abm*2.6*15 HEAT174501
...;start old abm*2.6*15
...;W U_$P(ABMREC,U,8) ;itype
...;W U_$P(ABMREC,U,9) ;insurer
...;end old start new
...W U_$S($P(ABMREC,U,8)="X":"",1:$P(ABMREC,U,8)) ;insurer type
...W U_$S($P(ABMREC,U,9)="NO BILL":"NOT BILLED",1:$P(ABMREC,U,9)) ;insurer
...;end new
...;W U_$$CDT^ABMDUTL(ABMVDT) ;vst dt ;abm*2.6*15 HEAT188548
...W U_$$BDT^ABMDUTL(ABMVDT) ;vst dt ;abm*2.6*15 HEAT188548
...W U_$S(+ABMTRIEN:$$SDTO^ABMDUTL(ABMTRIEN),1:"") ;dt pd
...D ELGCHK^ABMM2PV3
...W U_$P($G(ABMREC),U,4) ;Mcd/schip pd
...W U_$P($G(ABMREC),U,5) ;bill number
...W U_$P($G(ABMREC),U,6) ;pymt
...W U_$P($G(ABMREC),U,7) ;primary pov
...;W U_ABMPI_U_ABMMCR_U_ABMMCD_U_ABMCHIP_U_ABMNI ;abm*2.6*15 HEAT183289
...W U_ABMPI_U_ABMMCR_U_ABMMCD_U_ABMCHIP_U_ABMNI_U_$G(ABMTSI) ;abm*2.6*15 HEAT183289
...W U_$G(ABMP("STATE")) ;abm*2.6*15 HEAT164125
...W U_$P(ABMREC,U,15) ;visit location NPI abm*2.6*15 HEAT171490
...W U_$P(ABMREC,U,16) ;visit location TIN abm*2.6*15 HEAT171490
...W U_$P(ABMREC,U,17) ;record indicator abm*2.6*15 HEAT161159
...;start new abm*2.6*15 HEAT183289
...I +$G(ABMFQHC)=1 D
....I +$G(ABMICNT)=1&($G(ABMTSI)="Y") D
.....W "TSI" ;write TSI if pt has TSI insurer only
.....I +$P($G(ABMREC),U,6)'=0 W "-PD" ;if TSI insurer paid
....I $G(ABMNI)="Y" W "UNC" ;write UNC if pt is needy individual
...;end new HEAT183289
;end new HEAT161159
I +$G(ABMDCNT)>0 W !!,"Duplicate visits for this period: "_ABMDCNT
D CLOSE^%ZISH("ABM")
Q
ABMM2P10 ;IHS/SD/SDR - MU Patient Volume EP Report ;
+1 ;;2.6;IHS 3P BILLING SYSTEM;**15**;NOV 12, 2009;Build 251
+2 ;IHS/SD/SDR - 2.6*15 - HEAT161159 - Changed PT LST to sort differently so there won't be duplicate vsts on pt lst.
+3 ;IHS/SD/SDR - 2.6*15 - HEAT174501 - Added Provider NPI to host file
+4 ;IHS/SD/SDR - 2.6*15 - HEAT171490 - Added facility NPI and TIN to pt list host file
+5 ;IHS/SD/SDR - 2.6*15 - HEAT183289 - Added Tribal self-insured flag to output and summary total lines
+6 ;IHS/SD/SDR - 2.6*15 - HEAT188548- format visit time to 4 digits
+7 ;
PATIENT ;EP
+1 IF ABMY("RFMT")="P"
IF $GET(ABMFN)'=""
DO PTHSTFL
QUIT
+2 SET ABM("PG")=1
+3 SET ABMSDT=$PIECE($GET(^XTMP("ABM-PVP2",$JOB,"PRV TOP")),U,2)
+4 DO HDR^ABMM2PV3
+5 IF ABMSDT=""
QUIT
+6 SET ABMVLOC=0
+7 FOR
SET ABMVLOC=$ORDER(^XTMP("ABM-PVP2",$JOB,"PT LST",ABMSDT,ABMVLOC))
IF 'ABMVLOC
QUIT
Begin DoDot:1
+8 DO PTHDR^ABMM2PV3
+9 ;start old abm*2.6*15 HEAT161159
+10 ;S ABMITYP=""
+11 ;F S ABMITYP=$O(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP)) Q:ABMITYP="" D Q:(IOST["C")&((+$G(Y)=0)!($D(DIRUT)!$D(DIROUT)!$D(DTOUT)!$D(DUOUT)))
+12 ;.S ABMINS=""
+13 ;.F S ABMINS=$O(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS)) Q:ABMINS="" D Q:(IOST["C")&((+$G(Y)=0)!($D(DIRUT)!$D(DIROUT)!$D(DTOUT)!$D(DUOUT)))
+14 ;..S ABMPTL=""
+15 ;..F S ABMPTL=$O(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS,ABMPTL)) Q:ABMPTL="" D Q:(IOST["C")&((+$G(Y)=0)!($D(DIRUT)!$D(DIROUT)!$D(DTOUT)!$D(DUOUT)))
+16 ;...S ABMPTF=""
+17 ;...F S ABMPTF=$O(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS,ABMPTL,ABMPTF)) Q:ABMPTF="" D Q:(IOST["C")&((+$G(Y)=0)!($D(DIRUT)!$D(DIROUT)!$D(DTOUT)!$D(DUOUT)))
+18 ;....S ABMVDT=0
+19 ;....F S ABMVDT=$O(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS,ABMPTL,ABMPTF,ABMVDT)) Q:'ABMVDT D Q:(IOST["C")&((+$G(Y)=0)!($D(DIRUT)!$D(DIROUT)!$D(DTOUT)!$D(DUOUT)))
+20 ;.....S ABMVDFN=0
+21 ;.....F S ABMVDFN=$O(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS,ABMPTL,ABMPTF,ABMVDT,ABMVDFN)) Q:'ABMVDFN D Q:(IOST["C")&((+$G(Y)=0)!($D(DIRUT)!$D(DIROUT)!$D(DTOUT)!$D(DUOUT)))
+22 ;......S ABMPT=$P($G(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS,ABMPTL,ABMPTF,ABMVDT,ABMVDFN)),U,2)
+23 ;......S ABMTRIEN=$P($G(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS,ABMPTL,ABMPTF,ABMVDT,ABMVDFN)),U,3)
+24 ;......S IENS=ABMVLOC_","_ABMPT_","
+25 ;......S ABMHRN=$$GET1^DIQ(9000001.41,IENS,.02)
+26 ;......W !,$E(ABMPTL_", "_ABMPTF,1,16) ;pt name
+27 ;......W ?18,ABMHRN ;HRN
+28 ;......W ?25,$E($$GET1^DIQ(9000010,ABMVDFN,.07,"E"),1,3) ;Cat
+29 ;......W ?29,$E($$GET1^DIQ(9000010,ABMVDFN,.08,"E"),1,8) ;clin
+30 ;......W ?39,$S(ABMITYP="X":"",1:ABMITYP) ;itype
+31 ;......W ?42,$S(ABMINS="NO BILL":"NOT BILLED",1:$E(ABMINS,1,10)) ;ins
+32 ;......W ?53,$$CDT^ABMDUTL(ABMVDT) ;vst dt
+33 ;......W ?70,$S(+ABMTRIEN:$$SDTO^ABMDUTL(ABMTRIEN),1:"") ;dt pd
+34 ;......I $P($G(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS,ABMPTL,ABMPTF,ABMVDT,ABMVDFN)),U,4)'="" W ?79,$P(^(ABMVDFN),U,4)
+35 ;......I $Y+5>IOSL D HD^ABMM2PV3,PTHDR^ABMM2PV3 Q:(IOST["C")&((+$G(Y)=0)!($D(DIRUT)!$D(DIROUT)!$D(DTOUT)!$D(DUOUT)))
+36 ;end old start new HEAT161159
+37 SET ABMVDT=0
+38 FOR
SET ABMVDT=$ORDER(^XTMP("ABM-PVP2",$JOB,"PT LST",ABMSDT,ABMVLOC,ABMVDT))
IF 'ABMVDT
QUIT
Begin DoDot:2
+39 SET ABMVDFN=0
+40 FOR
SET ABMVDFN=$ORDER(^XTMP("ABM-PVP2",$JOB,"PT LST",ABMSDT,ABMVLOC,ABMVDT,ABMVDFN))
IF 'ABMVDFN
QUIT
Begin DoDot:3
+41 SET ABMPT=$PIECE($GET(^XTMP("ABM-PVP2",$JOB,"PT LST",ABMSDT,ABMVLOC,ABMVDT,ABMVDFN)),U,2)
+42 SET ABMTRIEN=$PIECE($GET(^XTMP("ABM-PVP2",$JOB,"PT LST",ABMSDT,ABMVLOC,ABMVDT,ABMVDFN)),U,3)
+43 SET ABMPTL=$PIECE($GET(^XTMP("ABM-PVP2",$JOB,"PT LST",ABMSDT,ABMVLOC,ABMVDT,ABMVDFN)),U,10)
+44 SET ABMPTF=$PIECE($GET(^XTMP("ABM-PVP2",$JOB,"PT LST",ABMSDT,ABMVLOC,ABMVDT,ABMVDFN)),U,11)
+45 ;abm*2.6*15
SET ABMITYP=$PIECE($GET(^XTMP("ABM-PVP2",$JOB,"PT LST",ABMSDT,ABMVLOC,ABMVDT,ABMVDFN)),U,8)
+46 ;abm*2.6*15
SET ABMINS=$PIECE($GET(^XTMP("ABM-PVP2",$JOB,"PT LST",ABMSDT,ABMVLOC,ABMVDT,ABMVDFN)),U,9)
+47 SET IENS=ABMVLOC_","_ABMPT_","
+48 SET ABMHRN=$$GET1^DIQ(9000001.41,IENS,.02)
+49 ;pt name
WRITE !,$EXTRACT(ABMPTL_", "_ABMPTF,1,16)
+50 ;HRN
WRITE ?18,ABMHRN
+51 ;Cat
WRITE ?25,$EXTRACT($$GET1^DIQ(9000010,ABMVDFN,.07,"E"),1,3)
+52 ;clin
WRITE ?29,$EXTRACT($$GET1^DIQ(9000010,ABMVDFN,.08,"E"),1,8)
+53 ;itype
WRITE ?39,$SELECT(ABMITYP="X":"",1:ABMITYP)
+54 ;ins
WRITE ?42,$SELECT(ABMINS="NO BILL":"NOT BILLED",1:$EXTRACT(ABMINS,1,10))
+55 ;vst dt
WRITE ?53,$$CDT^ABMDUTL(ABMVDT)
+56 ;dt pd
WRITE ?70,$SELECT(+ABMTRIEN:$$SDTO^ABMDUTL(ABMTRIEN),1:"")
+57 IF $PIECE($GET(^XTMP("ABM-PVP2",$JOB,"PT LST",ABMSDT,ABMVLOC,ABMVDT,ABMVDFN)),U,4)'=""
WRITE ?79,$PIECE(^(ABMVDFN),U,4)
+58 IF $Y+5>IOSL
DO HD^ABMM2PV3
DO PTHDR^ABMM2PV3
IF (IOST["C")&((+$GET(Y)=0)!($DATA(DIRUT)!$DATA(DIROUT)!$DATA(DTOUT)!$DATA(DUOUT)))
QUIT
End DoDot:3
IF (IOST["C")&((+$GET(Y)=0)!($DATA(DIRUT)!$DATA(DIROUT)!$DATA(DTOUT)!$DATA(DUOUT)))
QUIT
End DoDot:2
IF (IOST["C")&((+$GET(Y)=0)!($DATA(DIRUT)!$DATA(DIROUT)!$DATA(DTOUT)!$DATA(DUOUT)))
QUIT
End DoDot:1
IF (IOST["C")&((+$GET(Y)=0)!($DATA(DIRUT)!$DATA(DIROUT)!$DATA(DTOUT)!$DATA(DUOUT)))
QUIT
+59 ;end new HEAT161159
+60 QUIT
PTHSTFL ;EP
+1 SET ABMSDT=$PIECE($GET(^XTMP("ABM-PVP2",$JOB,"PRV TOP")),U,2)
+2 KILL ABMDCNT
+3 DO OPEN^%ZISH("ABM",ABMPATH,ABMFN,"W")
+4 IF POP
QUIT
+5 USE IO
+6 SET ABM("PG")=1
+7 DO HDR^ABMM2PV3
+8 ;W !,"Visit Location"_U_"Patient"_U_"Chart#"_U_"Policy Holder ID"_U_"Serv Cat"_U_"Clinic"_U_"InsType"_U_"BilledTo" ;abm*2.6*15 HEAT174501
+9 ;abm*2.6*15 HEAT174501
WRITE !,"Visit Location"_U_"Patient"_U_"Chart#"_U_"Policy Holder ID"_U_"Serv Cat"_U_"Clinic"_U_"Provider NPI"_U_"Provider"_U_"InsType"_U_"BilledTo"
+10 WRITE U_"DateOfService"_U_"DatePaid"_U_"Medicaid/SchipPaid"_U_"Bill#"_U_"Payment"_U_"Primary POV"_U_"PRVT"_U_"MCR"_U_"MCD"_U_"CHIP"_U_"NEEDY INDIV"
+11 ;abm*2.6*15 HEAT183289
WRITE U_"Tribal self-insured"
+12 ;abm*2.6*15 HEAT164125
WRITE U_"MCD ST"
+13 ;abm*2.6*15 HEAT171490 and HEAT161159
WRITE U_"Facility NPI"_U_"Facility TIN"_U_"Record Indicator"
+14 IF ABMSDT=""
QUIT
+15 SET ABMVLOC=0
+16 FOR
SET ABMVLOC=$ORDER(^XTMP("ABM-PVP2",$JOB,"PT LST",ABMSDT,ABMVLOC))
IF 'ABMVLOC
QUIT
Begin DoDot:1
+17 ;start old abm*2.6*16 HEAT161159
+18 ;S ABMITYP=""
+19 ;F S ABMITYP=$O(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP)) Q:ABMITYP="" D
+20 ;.S ABMINS=""
+21 ;.F S ABMINS=$O(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS)) Q:ABMINS="" D
+22 ;..S ABMPTL=""
+23 ;..F S ABMPTL=$O(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS,ABMPTL)) Q:ABMPTL="" D
+24 ;...S ABMPTF=""
+25 ;...F S ABMPTF=$O(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS,ABMPTL,ABMPTF)) Q:ABMPTF="" D
+26 ;....S ABMVDT=0
+27 ;....F S ABMVDT=$O(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS,ABMPTL,ABMPTF,ABMVDT)) Q:'ABMVDT D
+28 ;.....S ABMP("VDT")=ABMVDT
+29 ;.....S ABMVDFN=0
+30 ;.....F S ABMVDFN=$O(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS,ABMPTL,ABMPTF,ABMVDT,ABMVDFN)) Q:'ABMVDFN D
+31 ;......I +$G(^XTMP("ABM-PVP2",$J,"DUPS",ABMVDFN))=1 S ABMDCNT=+$G(ABMDCNT)+1
+32 ;......S ^XTMP("ABM-PVP2",$J,"DUPS",ABMVDFN)=1
+33 ;......S ABMPT=$P($G(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS,ABMPTL,ABMPTF,ABMVDT,ABMVDFN)),U,2)
+34 ;......S ABMTRIEN=$P($G(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS,ABMPTL,ABMPTF,ABMVDT,ABMVDFN)),U,3)
+35 ;......S IENS=ABMVLOC_","_ABMPT_","
+36 ;......S ABMHRN=$$GET1^DIQ(9000001.41,IENS,.02)
+37 ;......W !,$$GET1^DIQ(9999999.06,ABMVLOC,".02","E")
+38 ;......W U_ABMPTL_", "_ABMPTF ;pt name
+39 ;......W U_ABMHRN ;HRN
+40 ;......K ABML
+41 ;......D ELGCHK^ABMM2PV3
+42 ;......S ABMMIEN=0
+43 ;......K ABMMCDN
+44 ;......I ($G(ABML("MCD"))!($G(ABML("CHIP")))) D
+45 ;.......S ABMMIEN=+$G(ABMP("SAVE"))
+46 ;.......I ABMMIEN D
+47 ;........S ABMMCDN=$P($G(^AUPNMCD(ABMMIEN,0)),U,3)
+48 ;.......I 'ABMMIEN D PRVTCHIP^ABMM2PV3
+49 ;......I $G(ABMMCDN)'="" W U_ABMMCDN ;Medicaid # - policy holder ID
+50 ;......I 'ABMMIEN W U
+51 ;......W U_$$GET1^DIQ(9000010,ABMVDFN,.07,"E") ;Cat
+52 ;......W U_$$GET1^DIQ(9000010,ABMVDFN,.08,"E") ;clin
+53 ;......W U_$S(ABMITYP="X":"",1:ABMITYP) ;itype
+54 ;......W U_$S(ABMINS="NO BILL":"NOT BILLED",1:$E(ABMINS,1,10)) ;insurer
+55 ;......W U_$$CDT^ABMDUTL(ABMVDT) ;vst dt
+56 ;......W U_$S(+ABMTRIEN:$$SDTO^ABMDUTL(ABMTRIEN),1:"") ;dt pd
+57 ;......S ABMREC=$G(^XTMP("ABM-PVP2",$J,"PT LST",ABMSDT,ABMVLOC,ABMITYP,ABMINS,ABMPTL,ABMPTF,ABMVDT,ABMVDFN))
+58 ;......D ELGCHK^ABMM2PV3
+59 ;......W U_$P($G(ABMREC),U,4)
+60 ;......W U_$P($G(ABMREC),U,5)
+61 ;......W U_$P($G(ABMREC),U,6)
+62 ;......W U_$P($G(ABMREC),U,7)
+63 ;......W U_ABMPI_U_ABMMCR_U_ABMMCD_U_ABMCHIP_U_ABMNI
+64 ;end old start new HEAT161159
+65 SET ABMVDT=0
+66 FOR
SET ABMVDT=$ORDER(^XTMP("ABM-PVP2",$JOB,"PT LST",ABMSDT,ABMVLOC,ABMVDT))
IF 'ABMVDT
QUIT
Begin DoDot:2
+67 SET ABMP("VDT")=ABMVDT
+68 SET ABMVDFN=0
+69 FOR
SET ABMVDFN=$ORDER(^XTMP("ABM-PVP2",$JOB,"PT LST",ABMSDT,ABMVLOC,ABMVDT,ABMVDFN))
IF 'ABMVDFN
QUIT
Begin DoDot:3
+70 IF +$GET(^XTMP("ABM-PVP2",$JOB,"DUPS",ABMVDFN))=1
SET ABMDCNT=+$GET(ABMDCNT)+1
+71 SET ^XTMP("ABM-PVP2",$JOB,"DUPS",ABMVDFN)=1
+72 SET ABMPT=$PIECE($GET(^XTMP("ABM-PVP2",$JOB,"PT LST",ABMSDT,ABMVLOC,ABMVDT,ABMVDFN)),U,2)
+73 SET ABMTRIEN=$PIECE($GET(^XTMP("ABM-PVP2",$JOB,"PT LST",ABMSDT,ABMVLOC,ABMVDT,ABMVDFN)),U,3)
+74 SET ABMREC=$GET(^XTMP("ABM-PVP2",$JOB,"PT LST",ABMSDT,ABMVLOC,ABMVDT,ABMVDFN))
+75 SET ABMPTL=$PIECE(ABMREC,U,10)
+76 SET ABMPTF=$PIECE(ABMREC,U,11)
+77 SET IENS=ABMVLOC_","_ABMPT_","
+78 SET ABMHRN=$$GET1^DIQ(9000001.41,IENS,.02)
+79 WRITE !,$$GET1^DIQ(9999999.06,ABMVLOC,".02","E")
+80 ;pt name
WRITE U_ABMPTL_", "_ABMPTF
+81 ;HRN
WRITE U_ABMHRN
+82 KILL ABML
+83 DO ELGCHK^ABMM2PV3
+84 SET ABMMIEN=0
+85 KILL ABMMCDN
+86 IF ($GET(ABML("MCD"))!($GET(ABML("CHIP"))))
Begin DoDot:4
+87 SET ABMMIEN=+$GET(ABMP("SAVE"))
+88 IF ABMMIEN
Begin DoDot:5
+89 SET ABMMCDN=$PIECE($GET(^AUPNMCD(ABMMIEN,0)),U,3)
End DoDot:5
+90 IF 'ABMMIEN
DO PRVTCHIP^ABMM2PV3
End DoDot:4
+91 ;Medicaid # - policy holder ID
IF $GET(ABMMCDN)'=""
WRITE U_ABMMCDN
+92 IF 'ABMMIEN
WRITE U
+93 ;Cat
WRITE U_$$GET1^DIQ(9000010,ABMVDFN,.07,"E")
+94 ;clin
WRITE U_$$GET1^DIQ(9000010,ABMVDFN,.08,"E")
+95 ;abm*2.6*15 HEAT174501
WRITE U_$PIECE(ABMREC,U,12)_U_$PIECE(ABMREC,U,13)
+96 ;start old abm*2.6*15
+97 ;W U_$P(ABMREC,U,8) ;itype
+98 ;W U_$P(ABMREC,U,9) ;insurer
+99 ;end old start new
+100 ;insurer type
WRITE U_$SELECT($PIECE(ABMREC,U,8)="X":"",1:$PIECE(ABMREC,U,8))
+101 ;insurer
WRITE U_$SELECT($PIECE(ABMREC,U,9)="NO BILL":"NOT BILLED",1:$PIECE(ABMREC,U,9))
+102 ;end new
+103 ;W U_$$CDT^ABMDUTL(ABMVDT) ;vst dt ;abm*2.6*15 HEAT188548
+104 ;vst dt ;abm*2.6*15 HEAT188548
WRITE U_$$BDT^ABMDUTL(ABMVDT)
+105 ;dt pd
WRITE U_$SELECT(+ABMTRIEN:$$SDTO^ABMDUTL(ABMTRIEN),1:"")
+106 DO ELGCHK^ABMM2PV3
+107 ;Mcd/schip pd
WRITE U_$PIECE($GET(ABMREC),U,4)
+108 ;bill number
WRITE U_$PIECE($GET(ABMREC),U,5)
+109 ;pymt
WRITE U_$PIECE($GET(ABMREC),U,6)
+110 ;primary pov
WRITE U_$PIECE($GET(ABMREC),U,7)
+111 ;W U_ABMPI_U_ABMMCR_U_ABMMCD_U_ABMCHIP_U_ABMNI ;abm*2.6*15 HEAT183289
+112 ;abm*2.6*15 HEAT183289
WRITE U_ABMPI_U_ABMMCR_U_ABMMCD_U_ABMCHIP_U_ABMNI_U_$GET(ABMTSI)
+113 ;abm*2.6*15 HEAT164125
WRITE U_$GET(ABMP("STATE"))
+114 ;visit location NPI abm*2.6*15 HEAT171490
WRITE U_$PIECE(ABMREC,U,15)
+115 ;visit location TIN abm*2.6*15 HEAT171490
WRITE U_$PIECE(ABMREC,U,16)
+116 ;record indicator abm*2.6*15 HEAT161159
WRITE U_$PIECE(ABMREC,U,17)
+117 ;start new abm*2.6*15 HEAT183289
+118 IF +$GET(ABMFQHC)=1
Begin DoDot:4
+119 IF +$GET(ABMICNT)=1&($GET(ABMTSI)="Y")
Begin DoDot:5
+120 ;write TSI if pt has TSI insurer only
WRITE "TSI"
+121 ;if TSI insurer paid
IF +$PIECE($GET(ABMREC),U,6)'=0
WRITE "-PD"
End DoDot:5
+122 ;write UNC if pt is needy individual
IF $GET(ABMNI)="Y"
WRITE "UNC"
End DoDot:4
+123 ;end new HEAT183289
End DoDot:3
End DoDot:2
End DoDot:1
+124 ;end new HEAT161159
+125 IF +$GET(ABMDCNT)>0
WRITE !!,"Duplicate visits for this period: "_ABMDCNT
+126 DO CLOSE^%ZISH("ABM")
+127 QUIT