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

ABMDVCK0.m

Go to the documentation of this file.
  1. ABMDVCK0 ; IHS/ASDST/DMJ - PCC Visit Edits ;
  1. ;;2.6;IHS 3P BILLING SYSTEM;**11,19**;NOV 12, 2009;Build 300
  1. ;Original;TMD;08/19/96 4:49 PM
  1. ;Split off from ABMDVCK
  1. ;
  1. ; IHS/PIMC/JLG - 9/24/02 - V2.5 P2 - PAB-1001-90120
  1. ; Jim supplied code to fix 72-hour rule for Medicaid
  1. ;
  1. ; IHS/SD/SDR - 12/7/2004 - V2.5 P7 - An issue has arisen with the new
  1. ; version of Pharmacy (7). They send the clinic code of Pharmacy
  1. ; and TPB thinks it's unbillable if inpatient. Changing the clinic
  1. ; to general if inpatient and clinic is pharmacy.
  1. ;
  1. ; IHS/SD/SDR - v2.5 p12 - IM25368 - Changes so duplicate claims won't generate and claims
  1. ; will generate under correct DUZ(2).
  1. ;
  1. ;IHS/SD/SDR - 2.6*19 - HEAT109144 - Updated error 191 so it will check for visit 72 hours after
  1. ; discharge if visit being checked is inpatient. Also added check so it will see if outpt visit
  1. ; was within last 72 hours and give warning 255 if so.
  1. ;IHS/SD/SDR - 2.6*19 - HEAT251398 - Changed claim generator to allow service category TELEMEDICINE to
  1. ; generate claims.
  1. ;
  1. ; *********************************************************************
  1. ;
  1. VCHX(ABMVDFN) ;EP - CHECK EACH VISIT
  1. N ABMCHV0,ABMCHVDT,ABMV
  1. Q:'$D(^AUPNVSIT(ABMVDFN,0))
  1. S ABMCHV0=^AUPNVSIT(ABMVDFN,0)
  1. S ABMCHVDT=$P(ABMCHV0,U)\1
  1. S ABMP("LDFN")=$P(ABMCHV0,"^",6)
  1. ; The following are checks to see if a claim can be generated
  1. ; Reasons are put into field .04 of the visit file
  1. ;Codes 1, 2, 20, 22, 24, & 25 are not referred to in this section
  1. ;
  1. ;8= Location not specified for this visit
  1. I ABMP("LDFN")="" D Q
  1. .D PCFL^ABMDVCK2(8)
  1. .S ABMP("FLAG1")=1
  1. .S ^TMP($J,"PROC",ABMVDFN)=""
  1. ;
  1. ;10= Visit location not found in 3P site parameters file
  1. ;start old code abm*2.6*11 HEAT86425
  1. S ABMARPS=$P($G(^ABMDPARM(DUZ(2),1,4)),"^",9)
  1. I $O(^ABMDCLM(ABMP("LDFN"),"AV",ABMVDFN,"")) S ABMARPS=""
  1. I 'ABMARPS,'$D(^ABMDPARM(ABMP("LDFN"),0)) D Q
  1. .D PCFL^ABMDVCK2(10)
  1. .S ABMP("FLAG1")=1
  1. .S ^TMP($J,"PROC",ABMVDFN)=""
  1. I ABMARPS,'$D(^BAR(90052.05,DUZ(2),ABMP("LDFN"),0)) D Q
  1. .Q:$D(^BAR(90052.05,ABMP("LDFN"),ABMP("LDFN")))
  1. .Q:$D(^BAR(90052.05,ABMP("LDFN"),DUZ(2)))
  1. .D PCFL^ABMDVCK2(10)
  1. .S ABMP("FLAG1")=1
  1. .S ^TMP($J,"PROC",ABMVDFN)=""
  1. ;end old code start new code HEAT86425
  1. ;I $O(^ABMDCLM(DUZ(2),"AV",ABMVDFN,""))!($O(^ABMDCLM(ABMP("LDFN"),"AV",ABMVDFN,""))) Q
  1. ;I '$D(ABMARPS) D LOOP^ABMDVCK ;abm*2.6*11 so CG can be run manually for one VDFN
  1. ;I 'ABMARPS,'$D(^ABMDPARM(ABMP("LDFN"),0)) D Q
  1. ;.D PCFL^ABMDVCK2(10)
  1. ;.S ABMP("FLAG1")=1
  1. ;.S ^TMP($J,"PROC",ABMVDFN)=""
  1. ;I ABMARPS,'$D(^BAR(90052.05,DUZ(2),ABMP("LDFN"),0)) D Q
  1. ;.Q:$D(^BAR(90052.05,ABMP("LDFN"),ABMP("LDFN")))
  1. ;.Q:$D(^BAR(90052.05,ABMP("LDFN"),DUZ(2)))
  1. ;.D PCFL^ABMDVCK2(10)
  1. ;.S ABMP("FLAG1")=1
  1. ;.S ^TMP($J,"PROC",ABMVDFN)=""
  1. ;end new code HEAT86425
  1. I ABMP("LDFN")'=DUZ(2),'ABMARPS Q
  1. I ABMARPS,$P($G(^BAR(90052.05,DUZ(2),ABMP("LDFN"),0)),"^",3)'=DUZ(2) Q
  1. I ABMARPS,$P($G(^BAR(90052.05,DUZ(2),ABMP("LDFN"),0)),"^",6)>ABMP("VDT") D Q
  1. .D PCFL^ABMDVCK2(32)
  1. .S ABMP("FLAG1")=1
  1. .S ^TMP($J,"PROC",ABMVDFN)=""
  1. I ABMARPS,$P($G(^BAR(90052.05,DUZ(2),ABMP("LDFN"),0)),"^",7),$P(^(0),"^",7)<ABMP("VDT") D Q
  1. .D PCFL^ABMDVCK2(33)
  1. .S ABMP("FLAG1")=1
  1. .S ^TMP($J,"PROC",ABMVDFN)=""
  1. S ^TMP($J,"PROC",ABMVDFN)=""
  1. S ABMP("FLAG1")=1
  1. ;
  1. ;1= Claim manually purged
  1. I $P(ABMP("V0"),U,4)=1 D Q
  1. .Q:ABMP("V0")=ABMCHV0
  1. .D PCFL^ABMDVCK2($P(ABMP("V0"),U,4))
  1. .; give a status if a child visit
  1. ;
  1. ;23= Unknown status
  1. I $P(ABMCHV0,U,4)="" D PCFL^ABMDVCK2(23)
  1. ;
  1. ;3= PCC visit deleted
  1. I $P(ABMCHV0,U,11) D PCFL^ABMDVCK2(3) Q
  1. ;
  1. ;4= Contract type of visit
  1. I $P(ABMCHV0,"^",3)="C" D PCFL^ABMDVCK2(4) Q
  1. ;
  1. ;5= VA type of visit
  1. I $P(ABMCHV0,"^",3)="V" D PCFL^ABMDVCK2(5) Q
  1. ;
  1. ;6= Visit date prior to backbilling limit
  1. ;Use parent visit for this check
  1. I +$P($G(^ABMDPARM(DUZ(2),1,0)),U,16) D I +ABMP("V0")<X D PCFL^ABMDVCK2(6) Q
  1. .S X1=DT
  1. .S X2=0-($P(^ABMDPARM(DUZ(2),1,0),U,16)*30.417)
  1. .D C^%DTC
  1. S ABMP("PDFN")=$P(ABMP("V0"),U,5)
  1. S ABMP("CLN")=$P(ABMCHV0,U,8) ; Clinic
  1. I "IDH"[SERVCAT,(ABMP("CLN")=39) S ABMP("CLN")=1
  1. ;
  1. ;7= Patient not specified for this visit
  1. I ABMP("PDFN")="" D PCFL^ABMDVCK2(7) Q
  1. ;
  1. ;9= Entry found this patient date of service in file # 9002273.02
  1. I $D(^ABPVFAC("PC",ABMP("PDFN"),$P($P(ABMP("V0"),U),"."))) D PCFL^ABMDVCK2(9) Q
  1. ;
  1. ;11 is unbillable clinic
  1. I ABMP("CLN")]"",$D(^ABMDPARM(DUZ(2),1,15,ABMP("CLN"))) D PCFL^ABMDVCK2(11) Q
  1. ;
  1. ;21= PCC service category not amb, hosp, in hosp, observ, or day surg
  1. ;I "ADHOISRT"'[$P(ABMCHV0,U,7) D PCFL^ABMDVCK2(21) Q ;abm*2.6*19 IHS/SD/SDR HEAT251398
  1. I "ADHOISRTM"'[$P(ABMCHV0,U,7) D PCFL^ABMDVCK2(21) Q ;abm*2.6*19 IHS/SD/SDR HEAT251398
  1. I ABMP("CLN")="" S ABMP("CLN")=1
  1. ;
  1. ;12= Previous claim exists for this patient, visit date, and clinic
  1. ;13= Patient not found in file #2
  1. I '$D(^DPT(ABMP("PDFN"),0)) D PCFL^ABMDVCK2(13) Q
  1. ;
  1. ;14= Location not found in file #9999999.06
  1. I '$D(^AUTTLOC(DUZ(2),0)) D PCFL^ABMDVCK2(14) Q
  1. ;
  1. ;15= Clinic not found in file 40.07
  1. I '$D(^DIC(40.7,ABMP("CLN"),0)) D PCFL^ABMDVCK2(15) Q
  1. ;
  1. ;16= No V files pointing to this visit
  1. ;These are the local mods that are not likely to end up on the national release
  1. S ABMIPGMN=0
  1. I '$P(ABMCHV0,U,9) D Q:'ABMIPGMN
  1. .D PCFL^ABMDVCK2(16)
  1. .I $P($G(^ABMDPARM(DUZ(2),1,0)),U,18)'=2 Q
  1. .I "HID"'[SERVCAT Q
  1. .S IENS=ABMP("PDFN")_","
  1. .S X=$$GET1^DIQ(2,IENS,.105,"I")
  1. .K IENS
  1. .Q:'X ;If no current admission don't assume inpat status
  1. .S X1=DT
  1. .S X2=ABMCHVDT
  1. .D ^%DTC
  1. .I X<30 S ABMP("NOKILLABILL")=1 Q
  1. .S ABMIPGMN=1
  1. ;because there is no POV, need a flag!
  1. I '$P(ABMCHV0,U,9) D PCFL^ABMDVCK2(16) Q
  1. ;
  1. ;17= No data found in file #9000010.07 (V POV) for this visit
  1. N OK,ABMORLAG
  1. S ABMORLAG=$P($G(^ABMDPARM(DUZ(2),1,4)),U,8)
  1. S:'ABMORLAG ABMORLAG=45 ;Orphan lag time in days
  1. I ("ID"'[SERVCAT)!(("ID"[SERVCAT)&ABMPARNT=""),'$D(^AUPNVPOV("AD",ABMVDFN)) D Q:'OK
  1. .S X1=ABMP("VDT")
  1. .S X2=ABMORLAG
  1. .D C^%DTC
  1. .I X>DT D Q
  1. ..S ABMP("NOKILLABILL")=1
  1. ..D PCFL^ABMDVCK2(17)
  1. ..S OK=0
  1. .S OK=$$MISSPOV^ABMDVCK2(ABMVDFN)
  1. .I ABMIPGMN S OK=1 ;Code to create claim after 30D IP stay
  1. .I 'OK D PCFL^ABMDVCK2(17)
  1. ;If orphan & less than lag time days old, no claim & not kill ABILL
  1. Q:$G(ABMP("NOKILLABILL"))
  1. ;Look elswhere if no provider
  1. ;
  1. ;18= No data found in file #9000010.06 (V PROVIDER) for this visit
  1. I '$D(^AUPNVPRV("AD",ABMVDFN)) D Q:'OK&'ABMIPGMN
  1. .S X1=ABMP("VDT")
  1. .S X2=ABMORLAG
  1. .D C^%DTC
  1. .I X>DT S ABMP("NOKILLABILL")=1
  1. .S OK=$$ORPHAN^ABMDVCK2(ABMVDFN)
  1. .Q:OK
  1. .D PCFL^ABMDVCK2(18)
  1. Q:$G(ABMP("NOKILLABILL"))
  1. I ABMP("V0")=ABMCHV0 D ELG^ABMDLCK(ABMVDFN,.ABML,ABMP("PDFN"),ABMP("VDT"))
  1. ;
  1. ; 41 ; Visit date occurs after date of death
  1. I +$G(ABMNOELG)=41 D PCFL^ABMDVCK2(41) Q
  1. ;
  1. ;19= No eligibility found for this patient
  1. I $D(ABML)'=10 D PCFL^ABMDVCK2(19) Q
  1. ;
  1. ; 34-58 = No eligibility found for this patient (specific)
  1. I $O(ABML(""))=99 D Q
  1. .S ABMINS2=0
  1. .F S ABMINS2=$O(ABML(99,ABMINS2)) Q:'+ABMINS2 D
  1. ..S ABMNO=$P(ABML(99,ABMINS2),U,6)
  1. .I +$G(ABMNO) D PCFL^ABMDVCK2(ABMNO)
  1. .I '+$G(ABMNO) D PCFL^ABMDVCK2(19)
  1. .K ABMNO
  1. ;
  1. ; 29 ; Visit prior to billing start date
  1. I $O(ABML(""))=97 D PCFL^ABMDVCK2(29) Q
  1. N ABMPRIM,I,P
  1. N ABMPRIEN
  1. ;Check for pre-existing claim for visit.
  1. S Y=$O(^ABMDCLM(DUZ(2),"AV",ABMVDFN,""))
  1. I Y D
  1. .;Use its active insurer if it exists.
  1. .I $O(^ABMDCLM(DUZ(2),Y,13,0)) S I=$P(^ABMDCLM(DUZ(2),Y,0),U,8)
  1. .E Q
  1. .Q:'I
  1. .S P=0
  1. .F S P=$O(ABML(P)) Q:'P D Q:$D(ABMPRIM)
  1. ..I $D(ABML(P,I)) D
  1. ...S ABMPRIM=$P(ABML(P,I),U,3)
  1. ...S ABMPRIEN=I
  1. I '$D(ABMPRIM) D
  1. .S P=$O(ABML(""))
  1. .S I=$O(ABML(P,""))
  1. .S ABMPRIM=$P(ABML(P,I),U,3) ;Get primary insurance
  1. .S ABMPRIEN=I
  1. I ABMPRIM="" S ABMPRIM="UNK"
  1. N NOCLAIM
  1. I $D(ABMP("PRIMVSIT")),ABMP("PRIMVSIT")'=ABMVDFN K ABMP("PRIMVSIT")
  1. I "H"=SERVCAT K ABMP("OPONADMIT")
  1. ;Only make check if medicare, medicaid, or RR
  1. I "AS"[SERVCAT,"DMR"[ABMPRIM D ;Determine if there is an admit in 72 hrs
  1. .I "MR"[ABMPRIM,$P($G(^ABMNINS(DUZ(2),ABMPRIEN,0)),U,8)=0 Q
  1. .I "D"=ABMPRIM,$P($G(^ABMNINS(DUZ(2),ABMPRIEN,0)),U,8)'=1 Q
  1. .S ABM72=$$IN72HVIS(ABMVDFN)
  1. .I ABM72=2 D
  1. ..S ABMP("NOKILLABILL")=1
  1. ..D PCFL^ABMDVCK2(31)
  1. ..S NOCLAIM=1
  1. G QNOKILAB
  1. RULE72H ; Done if admission within 72 hours found.
  1. S ABMP("OPONADMIT")=""
  1. K ABMP("PRIMVSIT")
  1. K ABMP("NOKILLABILL")
  1. ;Check if claim already has billing pointer
  1. I $P(ABMCHV0,U,28)]"" S NOCLAIM=1 Q
  1. ;Check if claim already exists. If so add this A visit to claim
  1. S Y=$O(^ABMDCLM(DUZ(2),"AV",ABMV,""))
  1. I Y S ABMP("CDFN")=Y Q
  1. S DIE="^AUPNVSIT("
  1. S DA=ABMVDFN
  1. S DR=".28////"_ABMV
  1. D ^DIE
  1. ;To make this work, need to put value in parent field.
  1. S NOCLAIM=1
  1. Q
  1. QNOKILAB Q:$D(ABMP("NOKILLABILL"))
  1. Q:$D(NOCLAIM)=1&($D(ABMP("CDFN"))=0)
  1. N ABMIDONE
  1. S ABMIDONE=0
  1. ;ABMIDONE is used to end this loop once rtn ABMDVST is actually run
  1. K ABMP("DENTDONE"),ABMP("RXDONE"),ABMP("MEDSCHKD")
  1. S ABMP("PRI")=""
  1. F S ABMP("PRI")=$O(ABML(ABMP("PRI"))) Q:('ABMP("PRI")!(ABMP("PRI")>96)) D INS^ABMDVCK2 Q:$D(ABMP("NOKILLABILL"))!$D(ABMP("LOCKFAIL"))
  1. Q
  1. ;
  1. IN72H(ABMCLMNO) ;EP
  1. ;Extrinsic to tell if claim is inside 72 hour rule.
  1. I ABMCLMNO'=+ABMCLMNO Q "INVALID"
  1. S ABMVIEN=$O(^ABMDCLM(DUZ(2),ABMCLMNO,11,"AC","P",""))
  1. I 'ABMVIEN S ABMVIEN=$O(^ABMDCLM(DUZ(2),ABMCLMNO,11,""))
  1. I 'ABMVIEN Q "UNKNOWN"
  1. Q $$IN72HVIS(ABMVIEN)
  1. ;
  1. IN72HVIS(ABMVIEN) ;Extrinsic to tell if visit is inside 72 hour rule
  1. Q:$G(^AUPNVSIT(ABMVIEN,0))=""
  1. N ABMRDM3,W
  1. I '$D(ABMP("VDT")) D
  1. .S ABMP("VDT")=+^AUPNVSIT(ABMVIEN,0)
  1. .S ABMP("VDT")=ABMP("VDT")\1
  1. I '$D(ABMP("PDFN")) S ABMP("PDFN")=$P(^AUPNVSIT(ABMVIEN,0),U,5)
  1. S ABM72=0
  1. I $P(^AUPNVSIT(ABMVIEN,0),U,7)="H" D Q ABM72
  1. .S X1=ABMP("VDT")
  1. .S X2=-3
  1. .D C^%DTC
  1. .S ABMRDM3=9999999-X+.25
  1. .S W=9999999-ABMP("VDT")-.1
  1. .F S W=$O(^AUPNVSIT("AA",ABMP("PDFN"),W)) Q:'W!(W>ABMRDM3) D
  1. ..S ABMV=""
  1. ..F S ABMV=$O(^AUPNVSIT("AA",ABMP("PDFN"),W,ABMV)) Q:'ABMV D
  1. ...Q:ABMV=ABMVIEN
  1. ...S ABM72=1
  1. .;start new abm*2.6*19 IHS/SD/SDR HEAT109144
  1. .;check for outpt visit 72 hrs after discharge
  1. .S X1=ABMP("DDT")
  1. .S X2=3
  1. .D C^%DTC
  1. .S ABMRDM3=9999999-ABMP("VDT")+.25
  1. .S W=9999999-X
  1. .F S W=$O(^AUPNVSIT("AA",ABMP("PDFN"),W)) Q:'W!(W>ABMRDM3) D
  1. ..S ABMV=""
  1. ..F S ABMV=$O(^AUPNVSIT("AA",ABMP("PDFN"),W,ABMV)) Q:'ABMV D
  1. ...Q:ABMV=ABMVIEN
  1. ...S ABM72=1
  1. .;end new abm*2.6*19 IHS/SD/SDR HEAT109144
  1. .Q
  1. ;
  1. ;start new abm*2.6*19 IHS/SD/SDR HEAT109144
  1. ;check for inpt admit visit 72 hours before visit
  1. S X1=ABMP("VDT")
  1. S X2=-3
  1. D C^%DTC
  1. S ABMRDM3=9999999-X+.25
  1. S W=9999999-ABMP("VDT")-.1
  1. F S W=$O(^AUPNVSIT("AAH",ABMP("PDFN"),W)) Q:'W!(W>(ABMRDM3)) D
  1. .;AAH X-REF is only hospitalizations -- patient, inverse date, visit
  1. .S ABMV=""
  1. .F S ABMV=$O(^AUPNVSIT("AAH",ABMP("PDFN"),W,ABMV)) Q:'ABMV D
  1. ..S ABM72=1
  1. ;Check for inpt discharge 72 hrs before visit
  1. S W=9999999-ABMP("VDT")-.1
  1. F S W=$O(^AUPNVINP("AA",ABMP("PDFN"),W)) Q:'W!(W>(ABMRDM3)) D
  1. .S ABMV=""
  1. .F S ABMV=$O(^AUPNVINP("AA",ABMP("PDFN"),W,ABMV)) Q:'ABMV D
  1. ..S ABM72=1
  1. ;end new abm*2.6*19 HEAT109144
  1. S X1=ABMP("VDT")
  1. S X2=3
  1. D C^%DTC
  1. I X>DT Q 2 ;Visit date within 3 days of today.
  1. ;ABMRDM3 is an inverse date-3. W is start point
  1. S X1=ABMP("VDT")
  1. S X2=3
  1. D C^%DTC
  1. S ABMRDM3=9999999-ABMP("VDT")+.25
  1. S W=9999999-X
  1. F S W=$O(^AUPNVSIT("AAH",ABMP("PDFN"),W)) Q:'W!(W>(ABMRDM3)) D
  1. .;AAH X-REF is only hospitalizations -- patient, inverse date, visit
  1. .S ABMV=""
  1. .F S ABMV=$O(^AUPNVSIT("AAH",ABMP("PDFN"),W,ABMV)) Q:'ABMV D
  1. ..S ABM72=1
  1. Q ABM72