ABMDVCK0 ; IHS/ASDST/DMJ - PCC Visit Edits ;
;;2.6;IHS 3P BILLING SYSTEM;**11,19**;NOV 12, 2009;Build 300
;Original;TMD;08/19/96 4:49 PM
;Split off from ABMDVCK
;
; IHS/PIMC/JLG - 9/24/02 - V2.5 P2 - PAB-1001-90120
; Jim supplied code to fix 72-hour rule for Medicaid
;
; IHS/SD/SDR - 12/7/2004 - V2.5 P7 - An issue has arisen with the new
; version of Pharmacy (7). They send the clinic code of Pharmacy
; and TPB thinks it's unbillable if inpatient. Changing the clinic
; to general if inpatient and clinic is pharmacy.
;
; IHS/SD/SDR - v2.5 p12 - IM25368 - Changes so duplicate claims won't generate and claims
; will generate under correct DUZ(2).
;
;IHS/SD/SDR - 2.6*19 - HEAT109144 - Updated error 191 so it will check for visit 72 hours after
; discharge if visit being checked is inpatient. Also added check so it will see if outpt visit
; was within last 72 hours and give warning 255 if so.
;IHS/SD/SDR - 2.6*19 - HEAT251398 - Changed claim generator to allow service category TELEMEDICINE to
; generate claims.
;
; *********************************************************************
;
VCHX(ABMVDFN) ;EP - CHECK EACH VISIT
N ABMCHV0,ABMCHVDT,ABMV
Q:'$D(^AUPNVSIT(ABMVDFN,0))
S ABMCHV0=^AUPNVSIT(ABMVDFN,0)
S ABMCHVDT=$P(ABMCHV0,U)\1
S ABMP("LDFN")=$P(ABMCHV0,"^",6)
; The following are checks to see if a claim can be generated
; Reasons are put into field .04 of the visit file
;Codes 1, 2, 20, 22, 24, & 25 are not referred to in this section
;
;8= Location not specified for this visit
I ABMP("LDFN")="" D Q
.D PCFL^ABMDVCK2(8)
.S ABMP("FLAG1")=1
.S ^TMP($J,"PROC",ABMVDFN)=""
;
;10= Visit location not found in 3P site parameters file
;start old code abm*2.6*11 HEAT86425
S ABMARPS=$P($G(^ABMDPARM(DUZ(2),1,4)),"^",9)
I $O(^ABMDCLM(ABMP("LDFN"),"AV",ABMVDFN,"")) S ABMARPS=""
I 'ABMARPS,'$D(^ABMDPARM(ABMP("LDFN"),0)) D Q
.D PCFL^ABMDVCK2(10)
.S ABMP("FLAG1")=1
.S ^TMP($J,"PROC",ABMVDFN)=""
I ABMARPS,'$D(^BAR(90052.05,DUZ(2),ABMP("LDFN"),0)) D Q
.Q:$D(^BAR(90052.05,ABMP("LDFN"),ABMP("LDFN")))
.Q:$D(^BAR(90052.05,ABMP("LDFN"),DUZ(2)))
.D PCFL^ABMDVCK2(10)
.S ABMP("FLAG1")=1
.S ^TMP($J,"PROC",ABMVDFN)=""
;end old code start new code HEAT86425
;I $O(^ABMDCLM(DUZ(2),"AV",ABMVDFN,""))!($O(^ABMDCLM(ABMP("LDFN"),"AV",ABMVDFN,""))) Q
;I '$D(ABMARPS) D LOOP^ABMDVCK ;abm*2.6*11 so CG can be run manually for one VDFN
;I 'ABMARPS,'$D(^ABMDPARM(ABMP("LDFN"),0)) D Q
;.D PCFL^ABMDVCK2(10)
;.S ABMP("FLAG1")=1
;.S ^TMP($J,"PROC",ABMVDFN)=""
;I ABMARPS,'$D(^BAR(90052.05,DUZ(2),ABMP("LDFN"),0)) D Q
;.Q:$D(^BAR(90052.05,ABMP("LDFN"),ABMP("LDFN")))
;.Q:$D(^BAR(90052.05,ABMP("LDFN"),DUZ(2)))
;.D PCFL^ABMDVCK2(10)
;.S ABMP("FLAG1")=1
;.S ^TMP($J,"PROC",ABMVDFN)=""
;end new code HEAT86425
I ABMP("LDFN")'=DUZ(2),'ABMARPS Q
I ABMARPS,$P($G(^BAR(90052.05,DUZ(2),ABMP("LDFN"),0)),"^",3)'=DUZ(2) Q
I ABMARPS,$P($G(^BAR(90052.05,DUZ(2),ABMP("LDFN"),0)),"^",6)>ABMP("VDT") D Q
.D PCFL^ABMDVCK2(32)
.S ABMP("FLAG1")=1
.S ^TMP($J,"PROC",ABMVDFN)=""
I ABMARPS,$P($G(^BAR(90052.05,DUZ(2),ABMP("LDFN"),0)),"^",7),$P(^(0),"^",7)<ABMP("VDT") D Q
.D PCFL^ABMDVCK2(33)
.S ABMP("FLAG1")=1
.S ^TMP($J,"PROC",ABMVDFN)=""
S ^TMP($J,"PROC",ABMVDFN)=""
S ABMP("FLAG1")=1
;
;1= Claim manually purged
I $P(ABMP("V0"),U,4)=1 D Q
.Q:ABMP("V0")=ABMCHV0
.D PCFL^ABMDVCK2($P(ABMP("V0"),U,4))
.; give a status if a child visit
;
;23= Unknown status
I $P(ABMCHV0,U,4)="" D PCFL^ABMDVCK2(23)
;
;3= PCC visit deleted
I $P(ABMCHV0,U,11) D PCFL^ABMDVCK2(3) Q
;
;4= Contract type of visit
I $P(ABMCHV0,"^",3)="C" D PCFL^ABMDVCK2(4) Q
;
;5= VA type of visit
I $P(ABMCHV0,"^",3)="V" D PCFL^ABMDVCK2(5) Q
;
;6= Visit date prior to backbilling limit
;Use parent visit for this check
I +$P($G(^ABMDPARM(DUZ(2),1,0)),U,16) D I +ABMP("V0")<X D PCFL^ABMDVCK2(6) Q
.S X1=DT
.S X2=0-($P(^ABMDPARM(DUZ(2),1,0),U,16)*30.417)
.D C^%DTC
S ABMP("PDFN")=$P(ABMP("V0"),U,5)
S ABMP("CLN")=$P(ABMCHV0,U,8) ; Clinic
I "IDH"[SERVCAT,(ABMP("CLN")=39) S ABMP("CLN")=1
;
;7= Patient not specified for this visit
I ABMP("PDFN")="" D PCFL^ABMDVCK2(7) Q
;
;9= Entry found this patient date of service in file # 9002273.02
I $D(^ABPVFAC("PC",ABMP("PDFN"),$P($P(ABMP("V0"),U),"."))) D PCFL^ABMDVCK2(9) Q
;
;11 is unbillable clinic
I ABMP("CLN")]"",$D(^ABMDPARM(DUZ(2),1,15,ABMP("CLN"))) D PCFL^ABMDVCK2(11) Q
;
;21= PCC service category not amb, hosp, in hosp, observ, or day surg
;I "ADHOISRT"'[$P(ABMCHV0,U,7) D PCFL^ABMDVCK2(21) Q ;abm*2.6*19 IHS/SD/SDR HEAT251398
I "ADHOISRTM"'[$P(ABMCHV0,U,7) D PCFL^ABMDVCK2(21) Q ;abm*2.6*19 IHS/SD/SDR HEAT251398
I ABMP("CLN")="" S ABMP("CLN")=1
;
;12= Previous claim exists for this patient, visit date, and clinic
;13= Patient not found in file #2
I '$D(^DPT(ABMP("PDFN"),0)) D PCFL^ABMDVCK2(13) Q
;
;14= Location not found in file #9999999.06
I '$D(^AUTTLOC(DUZ(2),0)) D PCFL^ABMDVCK2(14) Q
;
;15= Clinic not found in file 40.07
I '$D(^DIC(40.7,ABMP("CLN"),0)) D PCFL^ABMDVCK2(15) Q
;
;16= No V files pointing to this visit
;These are the local mods that are not likely to end up on the national release
S ABMIPGMN=0
I '$P(ABMCHV0,U,9) D Q:'ABMIPGMN
.D PCFL^ABMDVCK2(16)
.I $P($G(^ABMDPARM(DUZ(2),1,0)),U,18)'=2 Q
.I "HID"'[SERVCAT Q
.S IENS=ABMP("PDFN")_","
.S X=$$GET1^DIQ(2,IENS,.105,"I")
.K IENS
.Q:'X ;If no current admission don't assume inpat status
.S X1=DT
.S X2=ABMCHVDT
.D ^%DTC
.I X<30 S ABMP("NOKILLABILL")=1 Q
.S ABMIPGMN=1
;because there is no POV, need a flag!
I '$P(ABMCHV0,U,9) D PCFL^ABMDVCK2(16) Q
;
;17= No data found in file #9000010.07 (V POV) for this visit
N OK,ABMORLAG
S ABMORLAG=$P($G(^ABMDPARM(DUZ(2),1,4)),U,8)
S:'ABMORLAG ABMORLAG=45 ;Orphan lag time in days
I ("ID"'[SERVCAT)!(("ID"[SERVCAT)&ABMPARNT=""),'$D(^AUPNVPOV("AD",ABMVDFN)) D Q:'OK
.S X1=ABMP("VDT")
.S X2=ABMORLAG
.D C^%DTC
.I X>DT D Q
..S ABMP("NOKILLABILL")=1
..D PCFL^ABMDVCK2(17)
..S OK=0
.S OK=$$MISSPOV^ABMDVCK2(ABMVDFN)
.I ABMIPGMN S OK=1 ;Code to create claim after 30D IP stay
.I 'OK D PCFL^ABMDVCK2(17)
;If orphan & less than lag time days old, no claim & not kill ABILL
Q:$G(ABMP("NOKILLABILL"))
;Look elswhere if no provider
;
;18= No data found in file #9000010.06 (V PROVIDER) for this visit
I '$D(^AUPNVPRV("AD",ABMVDFN)) D Q:'OK&'ABMIPGMN
.S X1=ABMP("VDT")
.S X2=ABMORLAG
.D C^%DTC
.I X>DT S ABMP("NOKILLABILL")=1
.S OK=$$ORPHAN^ABMDVCK2(ABMVDFN)
.Q:OK
.D PCFL^ABMDVCK2(18)
Q:$G(ABMP("NOKILLABILL"))
I ABMP("V0")=ABMCHV0 D ELG^ABMDLCK(ABMVDFN,.ABML,ABMP("PDFN"),ABMP("VDT"))
;
; 41 ; Visit date occurs after date of death
I +$G(ABMNOELG)=41 D PCFL^ABMDVCK2(41) Q
;
;19= No eligibility found for this patient
I $D(ABML)'=10 D PCFL^ABMDVCK2(19) Q
;
; 34-58 = No eligibility found for this patient (specific)
I $O(ABML(""))=99 D Q
.S ABMINS2=0
.F S ABMINS2=$O(ABML(99,ABMINS2)) Q:'+ABMINS2 D
..S ABMNO=$P(ABML(99,ABMINS2),U,6)
.I +$G(ABMNO) D PCFL^ABMDVCK2(ABMNO)
.I '+$G(ABMNO) D PCFL^ABMDVCK2(19)
.K ABMNO
;
; 29 ; Visit prior to billing start date
I $O(ABML(""))=97 D PCFL^ABMDVCK2(29) Q
N ABMPRIM,I,P
N ABMPRIEN
;Check for pre-existing claim for visit.
S Y=$O(^ABMDCLM(DUZ(2),"AV",ABMVDFN,""))
I Y D
.;Use its active insurer if it exists.
.I $O(^ABMDCLM(DUZ(2),Y,13,0)) S I=$P(^ABMDCLM(DUZ(2),Y,0),U,8)
.E Q
.Q:'I
.S P=0
.F S P=$O(ABML(P)) Q:'P D Q:$D(ABMPRIM)
..I $D(ABML(P,I)) D
...S ABMPRIM=$P(ABML(P,I),U,3)
...S ABMPRIEN=I
I '$D(ABMPRIM) D
.S P=$O(ABML(""))
.S I=$O(ABML(P,""))
.S ABMPRIM=$P(ABML(P,I),U,3) ;Get primary insurance
.S ABMPRIEN=I
I ABMPRIM="" S ABMPRIM="UNK"
N NOCLAIM
I $D(ABMP("PRIMVSIT")),ABMP("PRIMVSIT")'=ABMVDFN K ABMP("PRIMVSIT")
I "H"=SERVCAT K ABMP("OPONADMIT")
;Only make check if medicare, medicaid, or RR
I "AS"[SERVCAT,"DMR"[ABMPRIM D ;Determine if there is an admit in 72 hrs
.I "MR"[ABMPRIM,$P($G(^ABMNINS(DUZ(2),ABMPRIEN,0)),U,8)=0 Q
.I "D"=ABMPRIM,$P($G(^ABMNINS(DUZ(2),ABMPRIEN,0)),U,8)'=1 Q
.S ABM72=$$IN72HVIS(ABMVDFN)
.I ABM72=2 D
..S ABMP("NOKILLABILL")=1
..D PCFL^ABMDVCK2(31)
..S NOCLAIM=1
G QNOKILAB
RULE72H ; Done if admission within 72 hours found.
S ABMP("OPONADMIT")=""
K ABMP("PRIMVSIT")
K ABMP("NOKILLABILL")
;Check if claim already has billing pointer
I $P(ABMCHV0,U,28)]"" S NOCLAIM=1 Q
;Check if claim already exists. If so add this A visit to claim
S Y=$O(^ABMDCLM(DUZ(2),"AV",ABMV,""))
I Y S ABMP("CDFN")=Y Q
S DIE="^AUPNVSIT("
S DA=ABMVDFN
S DR=".28////"_ABMV
D ^DIE
;To make this work, need to put value in parent field.
S NOCLAIM=1
Q
QNOKILAB Q:$D(ABMP("NOKILLABILL"))
Q:$D(NOCLAIM)=1&($D(ABMP("CDFN"))=0)
N ABMIDONE
S ABMIDONE=0
;ABMIDONE is used to end this loop once rtn ABMDVST is actually run
K ABMP("DENTDONE"),ABMP("RXDONE"),ABMP("MEDSCHKD")
S ABMP("PRI")=""
F S ABMP("PRI")=$O(ABML(ABMP("PRI"))) Q:('ABMP("PRI")!(ABMP("PRI")>96)) D INS^ABMDVCK2 Q:$D(ABMP("NOKILLABILL"))!$D(ABMP("LOCKFAIL"))
Q
;
IN72H(ABMCLMNO) ;EP
;Extrinsic to tell if claim is inside 72 hour rule.
I ABMCLMNO'=+ABMCLMNO Q "INVALID"
S ABMVIEN=$O(^ABMDCLM(DUZ(2),ABMCLMNO,11,"AC","P",""))
I 'ABMVIEN S ABMVIEN=$O(^ABMDCLM(DUZ(2),ABMCLMNO,11,""))
I 'ABMVIEN Q "UNKNOWN"
Q $$IN72HVIS(ABMVIEN)
;
IN72HVIS(ABMVIEN) ;Extrinsic to tell if visit is inside 72 hour rule
Q:$G(^AUPNVSIT(ABMVIEN,0))=""
N ABMRDM3,W
I '$D(ABMP("VDT")) D
.S ABMP("VDT")=+^AUPNVSIT(ABMVIEN,0)
.S ABMP("VDT")=ABMP("VDT")\1
I '$D(ABMP("PDFN")) S ABMP("PDFN")=$P(^AUPNVSIT(ABMVIEN,0),U,5)
S ABM72=0
I $P(^AUPNVSIT(ABMVIEN,0),U,7)="H" D Q ABM72
.S X1=ABMP("VDT")
.S X2=-3
.D C^%DTC
.S ABMRDM3=9999999-X+.25
.S W=9999999-ABMP("VDT")-.1
.F S W=$O(^AUPNVSIT("AA",ABMP("PDFN"),W)) Q:'W!(W>ABMRDM3) D
..S ABMV=""
..F S ABMV=$O(^AUPNVSIT("AA",ABMP("PDFN"),W,ABMV)) Q:'ABMV D
...Q:ABMV=ABMVIEN
...S ABM72=1
.;start new abm*2.6*19 IHS/SD/SDR HEAT109144
.;check for outpt visit 72 hrs after discharge
.S X1=ABMP("DDT")
.S X2=3
.D C^%DTC
.S ABMRDM3=9999999-ABMP("VDT")+.25
.S W=9999999-X
.F S W=$O(^AUPNVSIT("AA",ABMP("PDFN"),W)) Q:'W!(W>ABMRDM3) D
..S ABMV=""
..F S ABMV=$O(^AUPNVSIT("AA",ABMP("PDFN"),W,ABMV)) Q:'ABMV D
...Q:ABMV=ABMVIEN
...S ABM72=1
.;end new abm*2.6*19 IHS/SD/SDR HEAT109144
.Q
;
;start new abm*2.6*19 IHS/SD/SDR HEAT109144
;check for inpt admit visit 72 hours before visit
S X1=ABMP("VDT")
S X2=-3
D C^%DTC
S ABMRDM3=9999999-X+.25
S W=9999999-ABMP("VDT")-.1
F S W=$O(^AUPNVSIT("AAH",ABMP("PDFN"),W)) Q:'W!(W>(ABMRDM3)) D
.;AAH X-REF is only hospitalizations -- patient, inverse date, visit
.S ABMV=""
.F S ABMV=$O(^AUPNVSIT("AAH",ABMP("PDFN"),W,ABMV)) Q:'ABMV D
..S ABM72=1
;Check for inpt discharge 72 hrs before visit
S W=9999999-ABMP("VDT")-.1
F S W=$O(^AUPNVINP("AA",ABMP("PDFN"),W)) Q:'W!(W>(ABMRDM3)) D
.S ABMV=""
.F S ABMV=$O(^AUPNVINP("AA",ABMP("PDFN"),W,ABMV)) Q:'ABMV D
..S ABM72=1
;end new abm*2.6*19 HEAT109144
S X1=ABMP("VDT")
S X2=3
D C^%DTC
I X>DT Q 2 ;Visit date within 3 days of today.
;ABMRDM3 is an inverse date-3. W is start point
S X1=ABMP("VDT")
S X2=3
D C^%DTC
S ABMRDM3=9999999-ABMP("VDT")+.25
S W=9999999-X
F S W=$O(^AUPNVSIT("AAH",ABMP("PDFN"),W)) Q:'W!(W>(ABMRDM3)) D
.;AAH X-REF is only hospitalizations -- patient, inverse date, visit
.S ABMV=""
.F S ABMV=$O(^AUPNVSIT("AAH",ABMP("PDFN"),W,ABMV)) Q:'ABMV D
..S ABM72=1
Q ABM72
ABMDVCK0 ; IHS/ASDST/DMJ - PCC Visit Edits ;
+1 ;;2.6;IHS 3P BILLING SYSTEM;**11,19**;NOV 12, 2009;Build 300
+2 ;Original;TMD;08/19/96 4:49 PM
+3 ;Split off from ABMDVCK
+4 ;
+5 ; IHS/PIMC/JLG - 9/24/02 - V2.5 P2 - PAB-1001-90120
+6 ; Jim supplied code to fix 72-hour rule for Medicaid
+7 ;
+8 ; IHS/SD/SDR - 12/7/2004 - V2.5 P7 - An issue has arisen with the new
+9 ; version of Pharmacy (7). They send the clinic code of Pharmacy
+10 ; and TPB thinks it's unbillable if inpatient. Changing the clinic
+11 ; to general if inpatient and clinic is pharmacy.
+12 ;
+13 ; IHS/SD/SDR - v2.5 p12 - IM25368 - Changes so duplicate claims won't generate and claims
+14 ; will generate under correct DUZ(2).
+15 ;
+16 ;IHS/SD/SDR - 2.6*19 - HEAT109144 - Updated error 191 so it will check for visit 72 hours after
+17 ; discharge if visit being checked is inpatient. Also added check so it will see if outpt visit
+18 ; was within last 72 hours and give warning 255 if so.
+19 ;IHS/SD/SDR - 2.6*19 - HEAT251398 - Changed claim generator to allow service category TELEMEDICINE to
+20 ; generate claims.
+21 ;
+22 ; *********************************************************************
+23 ;
VCHX(ABMVDFN) ;EP - CHECK EACH VISIT
+1 NEW ABMCHV0,ABMCHVDT,ABMV
+2 IF '$DATA(^AUPNVSIT(ABMVDFN,0))
QUIT
+3 SET ABMCHV0=^AUPNVSIT(ABMVDFN,0)
+4 SET ABMCHVDT=$PIECE(ABMCHV0,U)\1
+5 SET ABMP("LDFN")=$PIECE(ABMCHV0,"^",6)
+6 ; The following are checks to see if a claim can be generated
+7 ; Reasons are put into field .04 of the visit file
+8 ;Codes 1, 2, 20, 22, 24, & 25 are not referred to in this section
+9 ;
+10 ;8= Location not specified for this visit
+11 IF ABMP("LDFN")=""
Begin DoDot:1
+12 DO PCFL^ABMDVCK2(8)
+13 SET ABMP("FLAG1")=1
+14 SET ^TMP($JOB,"PROC",ABMVDFN)=""
End DoDot:1
QUIT
+15 ;
+16 ;10= Visit location not found in 3P site parameters file
+17 ;start old code abm*2.6*11 HEAT86425
+18 SET ABMARPS=$PIECE($GET(^ABMDPARM(DUZ(2),1,4)),"^",9)
+19 IF $ORDER(^ABMDCLM(ABMP("LDFN"),"AV",ABMVDFN,""))
SET ABMARPS=""
+20 IF 'ABMARPS
IF '$DATA(^ABMDPARM(ABMP("LDFN"),0))
Begin DoDot:1
+21 DO PCFL^ABMDVCK2(10)
+22 SET ABMP("FLAG1")=1
+23 SET ^TMP($JOB,"PROC",ABMVDFN)=""
End DoDot:1
QUIT
+24 IF ABMARPS
IF '$DATA(^BAR(90052.05,DUZ(2),ABMP("LDFN"),0))
Begin DoDot:1
+25 IF $DATA(^BAR(90052.05,ABMP("LDFN"),ABMP("LDFN")))
QUIT
+26 IF $DATA(^BAR(90052.05,ABMP("LDFN"),DUZ(2)))
QUIT
+27 DO PCFL^ABMDVCK2(10)
+28 SET ABMP("FLAG1")=1
+29 SET ^TMP($JOB,"PROC",ABMVDFN)=""
End DoDot:1
QUIT
+30 ;end old code start new code HEAT86425
+31 ;I $O(^ABMDCLM(DUZ(2),"AV",ABMVDFN,""))!($O(^ABMDCLM(ABMP("LDFN"),"AV",ABMVDFN,""))) Q
+32 ;I '$D(ABMARPS) D LOOP^ABMDVCK ;abm*2.6*11 so CG can be run manually for one VDFN
+33 ;I 'ABMARPS,'$D(^ABMDPARM(ABMP("LDFN"),0)) D Q
+34 ;.D PCFL^ABMDVCK2(10)
+35 ;.S ABMP("FLAG1")=1
+36 ;.S ^TMP($J,"PROC",ABMVDFN)=""
+37 ;I ABMARPS,'$D(^BAR(90052.05,DUZ(2),ABMP("LDFN"),0)) D Q
+38 ;.Q:$D(^BAR(90052.05,ABMP("LDFN"),ABMP("LDFN")))
+39 ;.Q:$D(^BAR(90052.05,ABMP("LDFN"),DUZ(2)))
+40 ;.D PCFL^ABMDVCK2(10)
+41 ;.S ABMP("FLAG1")=1
+42 ;.S ^TMP($J,"PROC",ABMVDFN)=""
+43 ;end new code HEAT86425
+44 IF ABMP("LDFN")'=DUZ(2)
IF 'ABMARPS
QUIT
+45 IF ABMARPS
IF $PIECE($GET(^BAR(90052.05,DUZ(2),ABMP("LDFN"),0)),"^",3)'=DUZ(2)
QUIT
+46 IF ABMARPS
IF $PIECE($GET(^BAR(90052.05,DUZ(2),ABMP("LDFN"),0)),"^",6)>ABMP("VDT")
Begin DoDot:1
+47 DO PCFL^ABMDVCK2(32)
+48 SET ABMP("FLAG1")=1
+49 SET ^TMP($JOB,"PROC",ABMVDFN)=""
End DoDot:1
QUIT
+50 IF ABMARPS
IF $PIECE($GET(^BAR(90052.05,DUZ(2),ABMP("LDFN"),0)),"^",7)
IF $PIECE(^(0),"^",7)<ABMP("VDT")
Begin DoDot:1
+51 DO PCFL^ABMDVCK2(33)
+52 SET ABMP("FLAG1")=1
+53 SET ^TMP($JOB,"PROC",ABMVDFN)=""
End DoDot:1
QUIT
+54 SET ^TMP($JOB,"PROC",ABMVDFN)=""
+55 SET ABMP("FLAG1")=1
+56 ;
+57 ;1= Claim manually purged
+58 IF $PIECE(ABMP("V0"),U,4)=1
Begin DoDot:1
+59 IF ABMP("V0")=ABMCHV0
QUIT
+60 DO PCFL^ABMDVCK2($PIECE(ABMP("V0"),U,4))
+61 ; give a status if a child visit
End DoDot:1
QUIT
+62 ;
+63 ;23= Unknown status
+64 IF $PIECE(ABMCHV0,U,4)=""
DO PCFL^ABMDVCK2(23)
+65 ;
+66 ;3= PCC visit deleted
+67 IF $PIECE(ABMCHV0,U,11)
DO PCFL^ABMDVCK2(3)
QUIT
+68 ;
+69 ;4= Contract type of visit
+70 IF $PIECE(ABMCHV0,"^",3)="C"
DO PCFL^ABMDVCK2(4)
QUIT
+71 ;
+72 ;5= VA type of visit
+73 IF $PIECE(ABMCHV0,"^",3)="V"
DO PCFL^ABMDVCK2(5)
QUIT
+74 ;
+75 ;6= Visit date prior to backbilling limit
+76 ;Use parent visit for this check
+77 IF +$PIECE($GET(^ABMDPARM(DUZ(2),1,0)),U,16)
Begin DoDot:1
+78 SET X1=DT
+79 SET X2=0-($PIECE(^ABMDPARM(DUZ(2),1,0),U,16)*30.417)
+80 DO C^%DTC
End DoDot:1
IF +ABMP("V0")<X
DO PCFL^ABMDVCK2(6)
QUIT
+81 SET ABMP("PDFN")=$PIECE(ABMP("V0"),U,5)
+82 ; Clinic
SET ABMP("CLN")=$PIECE(ABMCHV0,U,8)
+83 IF "IDH"[SERVCAT
IF (ABMP("CLN")=39)
SET ABMP("CLN")=1
+84 ;
+85 ;7= Patient not specified for this visit
+86 IF ABMP("PDFN")=""
DO PCFL^ABMDVCK2(7)
QUIT
+87 ;
+88 ;9= Entry found this patient date of service in file # 9002273.02
+89 IF $DATA(^ABPVFAC("PC",ABMP("PDFN"),$PIECE($PIECE(ABMP("V0"),U),".")))
DO PCFL^ABMDVCK2(9)
QUIT
+90 ;
+91 ;11 is unbillable clinic
+92 IF ABMP("CLN")]""
IF $DATA(^ABMDPARM(DUZ(2),1,15,ABMP("CLN")))
DO PCFL^ABMDVCK2(11)
QUIT
+93 ;
+94 ;21= PCC service category not amb, hosp, in hosp, observ, or day surg
+95 ;I "ADHOISRT"'[$P(ABMCHV0,U,7) D PCFL^ABMDVCK2(21) Q ;abm*2.6*19 IHS/SD/SDR HEAT251398
+96 ;abm*2.6*19 IHS/SD/SDR HEAT251398
IF "ADHOISRTM"'[$PIECE(ABMCHV0,U,7)
DO PCFL^ABMDVCK2(21)
QUIT
+97 IF ABMP("CLN")=""
SET ABMP("CLN")=1
+98 ;
+99 ;12= Previous claim exists for this patient, visit date, and clinic
+100 ;13= Patient not found in file #2
+101 IF '$DATA(^DPT(ABMP("PDFN"),0))
DO PCFL^ABMDVCK2(13)
QUIT
+102 ;
+103 ;14= Location not found in file #9999999.06
+104 IF '$DATA(^AUTTLOC(DUZ(2),0))
DO PCFL^ABMDVCK2(14)
QUIT
+105 ;
+106 ;15= Clinic not found in file 40.07
+107 IF '$DATA(^DIC(40.7,ABMP("CLN"),0))
DO PCFL^ABMDVCK2(15)
QUIT
+108 ;
+109 ;16= No V files pointing to this visit
+110 ;These are the local mods that are not likely to end up on the national release
+111 SET ABMIPGMN=0
+112 IF '$PIECE(ABMCHV0,U,9)
Begin DoDot:1
+113 DO PCFL^ABMDVCK2(16)
+114 IF $PIECE($GET(^ABMDPARM(DUZ(2),1,0)),U,18)'=2
QUIT
+115 IF "HID"'[SERVCAT
QUIT
+116 SET IENS=ABMP("PDFN")_","
+117 SET X=$$GET1^DIQ(2,IENS,.105,"I")
+118 KILL IENS
+119 ;If no current admission don't assume inpat status
IF 'X
QUIT
+120 SET X1=DT
+121 SET X2=ABMCHVDT
+122 DO ^%DTC
+123 IF X<30
SET ABMP("NOKILLABILL")=1
QUIT
+124 SET ABMIPGMN=1
End DoDot:1
IF 'ABMIPGMN
QUIT
+125 ;because there is no POV, need a flag!
+126 IF '$PIECE(ABMCHV0,U,9)
DO PCFL^ABMDVCK2(16)
QUIT
+127 ;
+128 ;17= No data found in file #9000010.07 (V POV) for this visit
+129 NEW OK,ABMORLAG
+130 SET ABMORLAG=$PIECE($GET(^ABMDPARM(DUZ(2),1,4)),U,8)
+131 ;Orphan lag time in days
IF 'ABMORLAG
SET ABMORLAG=45
+132 IF ("ID"'[SERVCAT)!(("ID"[SERVCAT)&ABMPARNT="")
IF '$DATA(^AUPNVPOV("AD",ABMVDFN))
Begin DoDot:1
+133 SET X1=ABMP("VDT")
+134 SET X2=ABMORLAG
+135 DO C^%DTC
+136 IF X>DT
Begin DoDot:2
+137 SET ABMP("NOKILLABILL")=1
+138 DO PCFL^ABMDVCK2(17)
+139 SET OK=0
End DoDot:2
QUIT
+140 SET OK=$$MISSPOV^ABMDVCK2(ABMVDFN)
+141 ;Code to create claim after 30D IP stay
IF ABMIPGMN
SET OK=1
+142 IF 'OK
DO PCFL^ABMDVCK2(17)
End DoDot:1
IF 'OK
QUIT
+143 ;If orphan & less than lag time days old, no claim & not kill ABILL
+144 IF $GET(ABMP("NOKILLABILL"))
QUIT
+145 ;Look elswhere if no provider
+146 ;
+147 ;18= No data found in file #9000010.06 (V PROVIDER) for this visit
+148 IF '$DATA(^AUPNVPRV("AD",ABMVDFN))
Begin DoDot:1
+149 SET X1=ABMP("VDT")
+150 SET X2=ABMORLAG
+151 DO C^%DTC
+152 IF X>DT
SET ABMP("NOKILLABILL")=1
+153 SET OK=$$ORPHAN^ABMDVCK2(ABMVDFN)
+154 IF OK
QUIT
+155 DO PCFL^ABMDVCK2(18)
End DoDot:1
IF 'OK&'ABMIPGMN
QUIT
+156 IF $GET(ABMP("NOKILLABILL"))
QUIT
+157 IF ABMP("V0")=ABMCHV0
DO ELG^ABMDLCK(ABMVDFN,.ABML,ABMP("PDFN"),ABMP("VDT"))
+158 ;
+159 ; 41 ; Visit date occurs after date of death
+160 IF +$GET(ABMNOELG)=41
DO PCFL^ABMDVCK2(41)
QUIT
+161 ;
+162 ;19= No eligibility found for this patient
+163 IF $DATA(ABML)'=10
DO PCFL^ABMDVCK2(19)
QUIT
+164 ;
+165 ; 34-58 = No eligibility found for this patient (specific)
+166 IF $ORDER(ABML(""))=99
Begin DoDot:1
+167 SET ABMINS2=0
+168 FOR
SET ABMINS2=$ORDER(ABML(99,ABMINS2))
IF '+ABMINS2
QUIT
Begin DoDot:2
+169 SET ABMNO=$PIECE(ABML(99,ABMINS2),U,6)
End DoDot:2
+170 IF +$GET(ABMNO)
DO PCFL^ABMDVCK2(ABMNO)
+171 IF '+$GET(ABMNO)
DO PCFL^ABMDVCK2(19)
+172 KILL ABMNO
End DoDot:1
QUIT
+173 ;
+174 ; 29 ; Visit prior to billing start date
+175 IF $ORDER(ABML(""))=97
DO PCFL^ABMDVCK2(29)
QUIT
+176 NEW ABMPRIM,I,P
+177 NEW ABMPRIEN
+178 ;Check for pre-existing claim for visit.
+179 SET Y=$ORDER(^ABMDCLM(DUZ(2),"AV",ABMVDFN,""))
+180 IF Y
Begin DoDot:1
+181 ;Use its active insurer if it exists.
+182 IF $ORDER(^ABMDCLM(DUZ(2),Y,13,0))
SET I=$PIECE(^ABMDCLM(DUZ(2),Y,0),U,8)
+183 IF '$TEST
QUIT
+184 IF 'I
QUIT
+185 SET P=0
+186 FOR
SET P=$ORDER(ABML(P))
IF 'P
QUIT
Begin DoDot:2
+187 IF $DATA(ABML(P,I))
Begin DoDot:3
+188 SET ABMPRIM=$PIECE(ABML(P,I),U,3)
+189 SET ABMPRIEN=I
End DoDot:3
End DoDot:2
IF $DATA(ABMPRIM)
QUIT
End DoDot:1
+190 IF '$DATA(ABMPRIM)
Begin DoDot:1
+191 SET P=$ORDER(ABML(""))
+192 SET I=$ORDER(ABML(P,""))
+193 ;Get primary insurance
SET ABMPRIM=$PIECE(ABML(P,I),U,3)
+194 SET ABMPRIEN=I
End DoDot:1
+195 IF ABMPRIM=""
SET ABMPRIM="UNK"
+196 NEW NOCLAIM
+197 IF $DATA(ABMP("PRIMVSIT"))
IF ABMP("PRIMVSIT")'=ABMVDFN
KILL ABMP("PRIMVSIT")
+198 IF "H"=SERVCAT
KILL ABMP("OPONADMIT")
+199 ;Only make check if medicare, medicaid, or RR
+200 ;Determine if there is an admit in 72 hrs
IF "AS"[SERVCAT
IF "DMR"[ABMPRIM
Begin DoDot:1
+201 IF "MR"[ABMPRIM
IF $PIECE($GET(^ABMNINS(DUZ(2),ABMPRIEN,0)),U,8)=0
QUIT
+202 IF "D"=ABMPRIM
IF $PIECE($GET(^ABMNINS(DUZ(2),ABMPRIEN,0)),U,8)'=1
QUIT
+203 SET ABM72=$$IN72HVIS(ABMVDFN)
+204 IF ABM72=2
Begin DoDot:2
+205 SET ABMP("NOKILLABILL")=1
+206 DO PCFL^ABMDVCK2(31)
+207 SET NOCLAIM=1
End DoDot:2
End DoDot:1
+208 GOTO QNOKILAB
RULE72H ; Done if admission within 72 hours found.
+1 SET ABMP("OPONADMIT")=""
+2 KILL ABMP("PRIMVSIT")
+3 KILL ABMP("NOKILLABILL")
+4 ;Check if claim already has billing pointer
+5 IF $PIECE(ABMCHV0,U,28)]""
SET NOCLAIM=1
QUIT
+6 ;Check if claim already exists. If so add this A visit to claim
+7 SET Y=$ORDER(^ABMDCLM(DUZ(2),"AV",ABMV,""))
+8 IF Y
SET ABMP("CDFN")=Y
QUIT
+9 SET DIE="^AUPNVSIT("
+10 SET DA=ABMVDFN
+11 SET DR=".28////"_ABMV
+12 DO ^DIE
+13 ;To make this work, need to put value in parent field.
+14 SET NOCLAIM=1
+15 QUIT
QNOKILAB IF $DATA(ABMP("NOKILLABILL"))
QUIT
+1 IF $DATA(NOCLAIM)=1&($DATA(ABMP("CDFN"))=0)
QUIT
+2 NEW ABMIDONE
+3 SET ABMIDONE=0
+4 ;ABMIDONE is used to end this loop once rtn ABMDVST is actually run
+5 KILL ABMP("DENTDONE"),ABMP("RXDONE"),ABMP("MEDSCHKD")
+6 SET ABMP("PRI")=""
+7 FOR
SET ABMP("PRI")=$ORDER(ABML(ABMP("PRI")))
IF ('ABMP("PRI")!(ABMP("PRI")>96))
QUIT
DO INS^ABMDVCK2
IF $DATA(ABMP("NOKILLABILL"))!$DATA(ABMP("LOCKFAIL"))
QUIT
+8 QUIT
+9 ;
IN72H(ABMCLMNO) ;EP
+1 ;Extrinsic to tell if claim is inside 72 hour rule.
+2 IF ABMCLMNO'=+ABMCLMNO
QUIT "INVALID"
+3 SET ABMVIEN=$ORDER(^ABMDCLM(DUZ(2),ABMCLMNO,11,"AC","P",""))
+4 IF 'ABMVIEN
SET ABMVIEN=$ORDER(^ABMDCLM(DUZ(2),ABMCLMNO,11,""))
+5 IF 'ABMVIEN
QUIT "UNKNOWN"
+6 QUIT $$IN72HVIS(ABMVIEN)
+7 ;
IN72HVIS(ABMVIEN) ;Extrinsic to tell if visit is inside 72 hour rule
+1 IF $GET(^AUPNVSIT(ABMVIEN,0))=""
QUIT
+2 NEW ABMRDM3,W
+3 IF '$DATA(ABMP("VDT"))
Begin DoDot:1
+4 SET ABMP("VDT")=+^AUPNVSIT(ABMVIEN,0)
+5 SET ABMP("VDT")=ABMP("VDT")\1
End DoDot:1
+6 IF '$DATA(ABMP("PDFN"))
SET ABMP("PDFN")=$PIECE(^AUPNVSIT(ABMVIEN,0),U,5)
+7 SET ABM72=0
+8 IF $PIECE(^AUPNVSIT(ABMVIEN,0),U,7)="H"
Begin DoDot:1
+9 SET X1=ABMP("VDT")
+10 SET X2=-3
+11 DO C^%DTC
+12 SET ABMRDM3=9999999-X+.25
+13 SET W=9999999-ABMP("VDT")-.1
+14 FOR
SET W=$ORDER(^AUPNVSIT("AA",ABMP("PDFN"),W))
IF 'W!(W>ABMRDM3)
QUIT
Begin DoDot:2
+15 SET ABMV=""
+16 FOR
SET ABMV=$ORDER(^AUPNVSIT("AA",ABMP("PDFN"),W,ABMV))
IF 'ABMV
QUIT
Begin DoDot:3
+17 IF ABMV=ABMVIEN
QUIT
+18 SET ABM72=1
End DoDot:3
End DoDot:2
+19 ;start new abm*2.6*19 IHS/SD/SDR HEAT109144
+20 ;check for outpt visit 72 hrs after discharge
+21 SET X1=ABMP("DDT")
+22 SET X2=3
+23 DO C^%DTC
+24 SET ABMRDM3=9999999-ABMP("VDT")+.25
+25 SET W=9999999-X
+26 FOR
SET W=$ORDER(^AUPNVSIT("AA",ABMP("PDFN"),W))
IF 'W!(W>ABMRDM3)
QUIT
Begin DoDot:2
+27 SET ABMV=""
+28 FOR
SET ABMV=$ORDER(^AUPNVSIT("AA",ABMP("PDFN"),W,ABMV))
IF 'ABMV
QUIT
Begin DoDot:3
+29 IF ABMV=ABMVIEN
QUIT
+30 SET ABM72=1
End DoDot:3
End DoDot:2
+31 ;end new abm*2.6*19 IHS/SD/SDR HEAT109144
+32 QUIT
End DoDot:1
QUIT ABM72
+33 ;
+34 ;start new abm*2.6*19 IHS/SD/SDR HEAT109144
+35 ;check for inpt admit visit 72 hours before visit
+36 SET X1=ABMP("VDT")
+37 SET X2=-3
+38 DO C^%DTC
+39 SET ABMRDM3=9999999-X+.25
+40 SET W=9999999-ABMP("VDT")-.1
+41 FOR
SET W=$ORDER(^AUPNVSIT("AAH",ABMP("PDFN"),W))
IF 'W!(W>(ABMRDM3))
QUIT
Begin DoDot:1
+42 ;AAH X-REF is only hospitalizations -- patient, inverse date, visit
+43 SET ABMV=""
+44 FOR
SET ABMV=$ORDER(^AUPNVSIT("AAH",ABMP("PDFN"),W,ABMV))
IF 'ABMV
QUIT
Begin DoDot:2
+45 SET ABM72=1
End DoDot:2
End DoDot:1
+46 ;Check for inpt discharge 72 hrs before visit
+47 SET W=9999999-ABMP("VDT")-.1
+48 FOR
SET W=$ORDER(^AUPNVINP("AA",ABMP("PDFN"),W))
IF 'W!(W>(ABMRDM3))
QUIT
Begin DoDot:1
+49 SET ABMV=""
+50 FOR
SET ABMV=$ORDER(^AUPNVINP("AA",ABMP("PDFN"),W,ABMV))
IF 'ABMV
QUIT
Begin DoDot:2
+51 SET ABM72=1
End DoDot:2
End DoDot:1
+52 ;end new abm*2.6*19 HEAT109144
+53 SET X1=ABMP("VDT")
+54 SET X2=3
+55 DO C^%DTC
+56 ;Visit date within 3 days of today.
IF X>DT
QUIT 2
+57 ;ABMRDM3 is an inverse date-3. W is start point
+58 SET X1=ABMP("VDT")
+59 SET X2=3
+60 DO C^%DTC
+61 SET ABMRDM3=9999999-ABMP("VDT")+.25
+62 SET W=9999999-X
+63 FOR
SET W=$ORDER(^AUPNVSIT("AAH",ABMP("PDFN"),W))
IF 'W!(W>(ABMRDM3))
QUIT
Begin DoDot:1
+64 ;AAH X-REF is only hospitalizations -- patient, inverse date, visit
+65 SET ABMV=""
+66 FOR
SET ABMV=$ORDER(^AUPNVSIT("AAH",ABMP("PDFN"),W,ABMV))
IF 'ABMV
QUIT
Begin DoDot:2
+67 SET ABM72=1
End DoDot:2
End DoDot:1
+68 QUIT ABM72