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

ABMM2P10.m

Go to the documentation of this file.
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