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

ABMDLCK1.m

Go to the documentation of this file.
  1. ABMDLCK1 ; IHS/ASDST/DMJ - check visit for elig - CONT'D ;
  1. ;;2.6;IHS 3P BILLING SYSTEM;**11,21**;NOV 12, 2009;Build 379
  1. ;;Y2K/OK - IHS/ADC/JLG 12-18-97
  1. ;Original;TMD;
  1. ; Code has been added to use the billing limit from the parameters file
  1. ; if no back billing limit has been set for the insurer. ;JLG 4/8/98
  1. ;
  1. ; IHS/DSD/JLG - 6/29/1999 - NOIS HQW-0798-100082 Patch 3 #4
  1. ; Modified to capture reason for ineligibility, for programmers use
  1. ;
  1. ; IHS/DSD/MRS - 8/27/1999 - NOIS XAA-0899-200058 Patch 3 #13
  1. ; Modified to prevent generating out-patient claims for Medicare
  1. ; with Part A only
  1. ;
  1. ; IHS/ASDS/LSL - 06/26/2001 - V2.4 Patch 9 - NOIS HQW-0798-100082
  1. ; Modified to expand no eligibility found. Reasons 42-58 can be
  1. ; found in this routine. Changes are not documented inside routine.
  1. ; I will take responsibility for the entire routine for patch 9.
  1. ;
  1. ; IHS/SD/SDR - v2.5 p10 - IM19802 - Fixed check for error 56 (user would get error if any provider met criteria
  1. ; IHS/SD/SDR - v2.5 p10 - IM20771 - Added check for outpatient visit and patient has MCR Part A only
  1. ;
  1. ;IHS/SD/SDR - 2.6*21 - HEAT127079 - Made change to show error 58 for POV correctly
  1. ;
  1. ; *********************************************************************
  1. ;
  1. CHK ;EP for setting elig hit
  1. N V,X,X1,X2,ABMNON,INSM
  1. ; If node 2 in the insurer file is missing no entry in ABML
  1. INS2 ;
  1. S ABM("INS2")=$G(^AUTNINS(ABM("INS"),2))
  1. I ABM("INS2")="" D Q
  1. .S $P(ABML(99,ABM("INS")),U,6)=42
  1. .S ABM("XIT")=1
  1. ;
  1. ; This is checking for insurer merged to another. It keeps looping
  1. ; until if finds an insurer that has not been merged to another. If it
  1. ; ever finds the "merged to" insurer is one that was previously found
  1. ; as "merged from" it quits and there is no entry in ABML.
  1. ;
  1. Q:$D(INSM(ABM("INS")))
  1. S INSM(ABM("INS"))=""
  1. I $P(ABM("INS2"),U,7)]"" D G INS2
  1. .S ABM("INS")=$P(ABM("INS2"),U,7)
  1. Q:$D(ABMLX(ABM("INS")))
  1. ; Piece 7 is the status field. No entry in ABML if status unbillable
  1. ; 43 ; Insurer designated as unbillable
  1. I $P($G(^AUTNINS(ABM("INS"),1)),U,7)=4 S $P(ABML(99,ABM("INS")),U,6)=43 Q
  1. ;
  1. ; Check both the default in the parameter file & in the insurer file
  1. ; for backbill limit. Use the one from the insurer file if it exists.
  1. ;
  1. N ABMDBBL,ABMBBL
  1. S ABMDBBL=$P(^ABMDPARM(DUZ(2),1,0),U,16)
  1. S ABMBBL=$S($P(ABM("INS2"),U,4):$P(ABM("INS2"),U,4),1:ABMDBBL)
  1. I ABMBBL>0 D I ABMVDT<X S ABMNON="B-BBL" G CHK2
  1. .S X1=DT
  1. .S X2=0-(ABMBBL*30.417)
  1. .D C^%DTC
  1. S:'$D(ABMVT) ABMVT=$$VTYP^ABMDVCK1(ABMVDFN,$G(SERVCAT),ABM("INS"),$G(ABMCLN))
  1. ;S V=$G(^ABMNINS(DUZ(2),ABM("INS"),1,+ABMVT,0)) ;abm*2.6*11 HEAT100200
  1. ;start new code abm*2.6*11 HEAT100200
  1. I $G(ABMP("LDFN"))="" D
  1. .I $G(ABMVDFN) S ABMP("LDFN")=$P($G(^AUPNVSIT(ABMVDFN,0)),U,6)
  1. .I $G(ABMP("CDFN")) S ABMP("LDFN")=$P($G(^ABMDCLM(DUZ(2),ABMP("CDFN"),0)),U,3)
  1. I $G(ABMP("LDFN"))'="" S V=$G(^ABMNINS(ABMP("LDFN"),ABM("INS"),1,+ABMVT,0))
  1. I $G(ABMP("LDFN"))="" S V=$G(^ABMNINS(DUZ(2),ABM("INS"),1,+ABMVT,0))
  1. ;end new code HEAT100200
  1. ;
  1. ; V is the Visit type multiple of the insurer file, p 7 billable
  1. ; If not billable set ABMNON
  1. ;
  1. I ABMVT,$P(V,U,7)="N" S ABMNON="UB-VT"
  1. I ABMVT,$P(V,U,14)>ABMVDT D
  1. .S ABMNON="BF-SD"
  1. .I '$O(ABML(ABM("PRI")),-1) S ABM("BEFSD")=1
  1. ;
  1. ; billing start date later than visit date & this insurer is primary
  1. G CHK2:'$G(ABMCLN) ;Jmp to CHK2 if no clinic
  1. I $P(ABM("INS2"),U,5)="O",$P(^DIC(40.7,ABMCLN,0),U,2)'=56 S ABMNON="OD-ND"
  1. ;
  1. ; ABM("INS2") is node 2 of insurer file. Checking dental billing status
  1. ; In piece 5 O means only dental billable, U means dental unbillable
  1. ; Clinic stop 56 is dental, 39 is pharmacy
  1. E I $P(^DIC(40.7,ABMCLN,0),U,2)=56,$P(ABM("INS2"),U,5)="U" S ABMNON="UB-D"
  1. E I $P(^DIC(40.7,ABMCLN,0),U,2)=39,$P(ABM("INS2"),U,3)="U" S ABMNON="UB-P"
  1. S ABM=0
  1. F S ABM=$O(^AUTNINS(ABM("INS"),17,ABM)) Q:'ABM D Q:$D(ABMNON)
  1. .I +^AUTNINS(ABM("INS"),17,ABM,0)=ABMCLN S ABMNON="UB-CL"
  1. CHK2 ;
  1. ;
  1. N T,P,SDT,EDT
  1. S (SDT,EDT)=""
  1. I ABM("TYP")?1(1"M",1"R"),$D(ABM("REC")) D
  1. .;check if patient only has part A; mark as unbillable if outpatient
  1. .S ABMCB="M"
  1. .S:$$PARTB^ABMDSPLB(DFN,ABMVDT) ABMCB=1
  1. .I $G(ABMCB)="M",($G(ABMP("VTYP"))'=111)&($G(ABMVT)'=111) S ABMNON="UB-PA"
  1. .Q:ABM("REC")<ABMVDT&((ABMDISDT<$P(ABM("REC"),U,2))!'$P(ABM("REC"),U,2))
  1. .S SDT=$S(ABMVDT<ABM("REC"):+ABM("REC"),1:"")
  1. .S EDT=$S($P(ABM("REC"),U,2)<ABMDISDT:$P(ABM("REC"),U,2),1:"")
  1. E I ABM("TYP")="D" D
  1. .Q:ABM("NDFN")=""
  1. .Q:ABM("NDFN")<ABMVDT&((ABMDISDT<$P(ABM("SUB"),U,2))!'$P(ABM("SUB"),U,2))
  1. .S SDT=$S(ABMVDT<ABM("NDFN"):ABM("NDFN"),1:"")
  1. .S EDT=$S($P(ABM("SUB"),U,2)<ABMDISDT:$P(ABM("SUB"),U,2),1:"")
  1. S T=$S(ABM("TYP")'="P":ABM("TYP"),$$ACCREL^ABMDLCK(ABM("MDFN")):"A",1:"P")
  1. I ABM("PRIMARY")=ABM("INS"),$P($G(ABML(1,+$O(ABML(1,"")))),U,3)'?1(1"W",1"A") S ABM("PRI")=1
  1. E I ABM("PRIMARY")=ABM("INS"),T="A" S ABM("PRI")=1
  1. N UBILL
  1. I $D(ABMNON) D
  1. .I ABMNON="UB-VT" S UBILL=44 Q ;Unbillable visit type
  1. .I ABMNON="B-BBL" S UBILL=45 Q ;Before back billing limit
  1. .I ABMNON="OD-ND" S UBILL=46 Q ;Non dental visit for dental ins.
  1. .I ABMNON="BF-SD" S UBILL=47 Q ;Before billing start date
  1. .I ABMNON="UB-D" S UBILL=48 Q ;Dental not billable
  1. .I ABMNON="UB-P" S UBILL=49 Q ;Pharmacy not billable
  1. .I ABMNON="UB-CL" S UBILL=50 Q ;Clinic not billable
  1. .I ABMNON="UB-PA" S UBILL=28 Q ;outpatient with MCR part A only
  1. I +$G(UBILL) D
  1. .S $P(ABML(99,ABM("INS")),"^",6)=UBILL
  1. .S ABM("XIT")=1
  1. S ABML(ABM("PRI"),ABM("INS"))=$S(T="D":ABM("MDFN"),1:"")_U_$S(T="D":ABM("NDFN"),T="W"&($G(ABMWCIEN)):ABMWCIEN,1:ABM("MDFN"))_U_T_U_SDT_U_EDT_U_$G(UBILL)
  1. I ABMVDFN D
  1. .S ABM=""
  1. .F S ABM=$O(^AUPNVPRV("AD",ABMVDFN,ABM)) Q:'ABM D Q:$$PRVX^ABMDLCK3(P)
  1. ..S P=+^AUPNVPRV(ABM,0)
  1. .I '$G(ABM("PRV")) D Q:'ABM("ORDPRV")
  1. ..S:'$D(ABM("ORDPRV")) ABM("ORDPRV")=$$ORPHAN^ABMDVCK2(ABMVDFN)
  1. ..S:'ABM("ORDPRV") ABMNON="NO-VP",$P(ABML(99,ABM("INS")),U,6)=56
  1. ; 56 ; Missing provider not allowed
  1. I $D(ABMNON) S ABM("XIT")=1 Q
  1. Q:'ABM("COV")
  1. S ABM("CV")=$O(ABML(ABM("PRI"),ABM("INS"),"COV",""))
  1. S:ABM("CV")="" ABM("CV")=$O(ABML(99,ABM("INS"),"COV",""))
  1. S ABML(ABM("PRI"),ABM("INS"),"COV",ABM("COV"))=$G(COV)
  1. Q:'$G(ABMVDFN)!'$G(ABMCLN)
  1. ;
  1. ; The code below here is checking to see if this visit is not
  1. ; covered. If not priority is changed to 99.
  1. ;
  1. Q:$G(ABM("EMPL REL"))=1 ;This is for workmans comp
  1. S:'$D(ABMVT) ABMVT=$$VTYP^ABMDVCK1(ABMVDFN,$G(SERVCAT),ABM("INS"),$G(ABMCLN))
  1. Q:ABMVT=111 ;If hospitalization
  1. Q:'$D(^AUTTPIC(ABM("COV")))
  1. Q:$G(COV)="A"
  1. ;
  1. ; This is checking to see if provider class is not covered
  1. ; Loops thru until it finds a provider not in the unbillable list
  1. ; or to the end of list.
  1. ; ABM("FLG") is set to 1 if provider not covered
  1. ; Provider not in coverage file means billable
  1. ; If BUB=B
  1. ; CPT code in one range is billable and done
  1. ; CPT code not in all ranges is billable
  1. ; If BUB=U
  1. ; all CPT codes in a range unbillable
  1. ; one CPT codes out of all ranges is billable
  1. ;
  1. N BUB,INRANGE,OUTOFRNG
  1. S ABM("PRV")=0
  1. S ABM=""
  1. F S ABM=$O(^AUPNVPRV("AD",ABMVDFN,ABM)) Q:'ABM D Q:'ABM("FLG")
  1. .S P=$P(^AUPNVPRV(ABM,0),U)
  1. .I $$PRVX^ABMDLCK3(P) D
  1. ..I $D(^AUTTPIC(ABM("COV"),15,ABM("PRV"))) D
  1. ...S BUB=$P(^AUTTPIC(ABM("COV"),15,ABM("PRV"),0),U,2)
  1. ...I BUB="" S ABM("FLG")=1,$P(ABML(99,ABM("INS")),U,6)=55 Q
  1. ...S ABM("FLG")=$$PROVSPEC^ABMDLCK3(ABM("COV"),ABM("PRV"),BUB)
  1. ...I ABM("FLG")=1 S $P(ABML(99,ABM("INS")),U,6)=51 Q
  1. ..E D
  1. ...I $P($G(ABML(99,ABM("INS"))),U,6)=51!($P($G(ABML(99,ABM("INS"))),U,6)=56) K ABML(99,ABM("INS"))
  1. ...S ABM("FLG")=0 ; Set to zero if not in list
  1. .E S ABM("FLG")=1,$P(ABML(99,ABM("INS")),U,6)=56 ;Set if default non covered provider
  1. ; If there are not entries in the V prov file same as flagging all
  1. ; providers unbillable
  1. I $G(ABM("FLG"),1),'$$ORPHAN^ABMDVCK2(ABMVDFN) D Q
  1. .S ABM("XIT")=1
  1. I $D(^AUTTPIC(ABM("COV"),11,ABMCLN,0)) D Q
  1. .S ABM("XIT")=1
  1. .S $P(ABML(99,ABM("INS")),U,6)=57
  1. S ABM("POV")=0,ABM("FLG")=0
  1. ;
  1. ; This code is checking to see if the coverage type represented by
  1. ; the ien ABM("COV") covers the POV for this visit. If it is not
  1. ; covered ABM("FLG") is set and UNCHK is run.
  1. ;
  1. S ABM=""
  1. F S ABM=$O(^AUPNVPOV("AD",ABMVDFN,ABM)) Q:'ABM D Q:'ABM("FLG")
  1. .S ABM("POV")=$P(^AUPNVPOV(ABM,0),U)
  1. .; Code to handle messed up .01 field in V POV file
  1. .I 'ABM("POV") S:ABM("FLG")=0 ABM("FLG")=-1 Q
  1. .I $D(^AUTTPIC(ABM("COV"),13,ABM("POV"))) S ABM("FLG")=1 Q
  1. .E S ABM("FLG")=0 ;Set to 0 if not in list
  1. Q:ABM("FLG")<1
  1. I ABM("FLG") D
  1. .S ABM("XIT")=11
  1. .S $P(ABML(99,ABM("INS")),U,6)=58
  1. I $G(ABM("XIT")) D UNCHK^ABMDLCK2 ;abm*2.6*21 IHS/SD/SDR HEAT127079
  1. Q
  1. ; ABM("XIT") serves as a flag that the priority needs to be 99