ABMDVCK1 ; IHS/ASDST/DMJ - PCC VISIT CHECK - PART 2 ;
;;2.6;IHS Third Party Billing System;**2**;NOV 12, 2009
;Original;TMD;
;
; IHS/SD/SDR - v2.6 CSV
; IHS/SD/SDR - abm*2.6*2 - 3PMS10003A - modified to call ABMFEAPI
;
; *********************************************************************
;
VTYP(ABMVDFN,SERVCAT,ABMINS,ABMCLN) ;EP - to get visit type
;This is an extrinsic function
N VTYP
I 'ABMVDFN Q ""
;If visit in dental file type=998, other wise 131
;
VAR ;
S VTYP=$S($D(^AUPNVDEN("AD",ABMVDFN)):998,1:131)
S ABM("LOCK")=0
;If the visit is in the V hospitalization file set type to 111
I +$O(^AUPNVINP("AD",ABMVDFN,"")),$D(^AUPNVINP($O(^AUPNVINP("AD",ABMVDFN,"")),0)) S VTYP=111
;Begin mods for inpat lt 30 days
I VTYP=131,SERVCAT="H" S VTYP=111
;End mods
;If not in hosp file go thru insurance file
N QUIT
E I SERVCAT'="S" D
.;Note that the visit type must be in the insurer file for this to set
.;the visit type.
.S QUIT=0
.S ABM=0
.F S ABM=$O(^ABMNINS(DUZ(2),ABMINS,1,ABM)) Q:'ABM D Q:QUIT
..I ABM=131 Q
..Q:'ABMCLN
..S D1=0
..F S D1=$O(^ABMDVTYP(ABM,1,D1)) Q:'D1 D Q:QUIT
...I +^ABMDVTYP(ABM,1,D1,0)=ABMCLN D
....S VTYP=ABM
....S QUIT=1
I SERVCAT="S" S VTYP=831
;If type is still 131 check to see if it is surgery
I "A"[SERVCAT,VTYP=131 D OPCK
I $P($G(^AUTNINS(+ABMINS,2)),U)="R" D
.S ABMLOC=$P($G(^AUPNVSIT(ABMVDFN,0)),"^",6)
.Q:$P($G(^ABMDPARM(+ABMLOC,1,5)),U)'=1
.S VTYP=999
.K ABMLOC
Q VTYP
;
; *********************************************************************
;This code is only reached if VTYP=131
OPCK ;EP for checking if ambulatory surgery
N C,ASC
D SURGTAB
S ABM=0
F S ABM=$O(^AUPNVPRC("AD",ABMVDFN,ABM)) Q:'ABM D Q:VTYP'=131
.;What we need to find is if from the ICD code we can determine visit
.;type.
.;From the CPT code we should be able to tell if it is surgery
.;If one of the ASC codes from 1 - 8 exists it should be amb surg
.;CPT from 10000-70000 is surgery.
.Q:'$D(^AUPNVPRC(ABM,0))
.S ABM("CPT")=$O(^ICPT("I",+^AUPNVPRC(ABM,0),""))
.Q:'ABM("CPT")
.S ASC=$P($$IHSCPT^ABMCVAPI(ABM("CPT"),ABMP("VDT")),U,6) ;CSV-c
.I ASC>0,ASC<9 D OPSURG
.Q
Q
;
; *********************************************************************
OPSURG ;
;I $D(^ABMNINS(DUZ(2),ABMINS,1,831,0)),+$P(^(0),U,5),'+$P($G(^ABMDFEE($P(^(0),U,5),11,ABM("CPT"),0)),U,2) Q ;abm*2.6*2 3PMS10003A
I $D(^ABMNINS(DUZ(2),ABMINS,1,831,0)),+$P(^(0),U,5),'+$P($$ONE^ABMFEAPI($P(^(0),U,5),11,ABM("CPT"),ABMP("VDT")),U) Q ;abm*2.6*2 3PMS10003A
S VTYP=831
Q
;
; *********************************************************************
SURGTAB ;EP - Create CPT table if needed
I '$D(ABMCPTTB("SURGERY")) D
.S ABM=$O(^ABMDCPT("D","SURGERY",""))
.S Y=^ABMDCPT(ABM,0)
.S ABMCPTTB("SURGERY","L")=$P(Y,U,4)
.S ABMCPTTB("SURGERY","H")=$P(Y,U,5)
K Y
Q
ABMDVCK1 ; IHS/ASDST/DMJ - PCC VISIT CHECK - PART 2 ;
+1 ;;2.6;IHS Third Party Billing System;**2**;NOV 12, 2009
+2 ;Original;TMD;
+3 ;
+4 ; IHS/SD/SDR - v2.6 CSV
+5 ; IHS/SD/SDR - abm*2.6*2 - 3PMS10003A - modified to call ABMFEAPI
+6 ;
+7 ; *********************************************************************
+8 ;
VTYP(ABMVDFN,SERVCAT,ABMINS,ABMCLN) ;EP - to get visit type
+1 ;This is an extrinsic function
+2 NEW VTYP
+3 IF 'ABMVDFN
QUIT ""
+4 ;If visit in dental file type=998, other wise 131
+5 ;
VAR ;
+1 SET VTYP=$SELECT($DATA(^AUPNVDEN("AD",ABMVDFN)):998,1:131)
+2 SET ABM("LOCK")=0
+3 ;If the visit is in the V hospitalization file set type to 111
+4 IF +$ORDER(^AUPNVINP("AD",ABMVDFN,""))
IF $DATA(^AUPNVINP($ORDER(^AUPNVINP("AD",ABMVDFN,"")),0))
SET VTYP=111
+5 ;Begin mods for inpat lt 30 days
+6 IF VTYP=131
IF SERVCAT="H"
SET VTYP=111
+7 ;End mods
+8 ;If not in hosp file go thru insurance file
+9 NEW QUIT
+10 IF '$TEST
IF SERVCAT'="S"
Begin DoDot:1
+11 ;Note that the visit type must be in the insurer file for this to set
+12 ;the visit type.
+13 SET QUIT=0
+14 SET ABM=0
+15 FOR
SET ABM=$ORDER(^ABMNINS(DUZ(2),ABMINS,1,ABM))
IF 'ABM
QUIT
Begin DoDot:2
+16 IF ABM=131
QUIT
+17 IF 'ABMCLN
QUIT
+18 SET D1=0
+19 FOR
SET D1=$ORDER(^ABMDVTYP(ABM,1,D1))
IF 'D1
QUIT
Begin DoDot:3
+20 IF +^ABMDVTYP(ABM,1,D1,0)=ABMCLN
Begin DoDot:4
+21 SET VTYP=ABM
+22 SET QUIT=1
End DoDot:4
End DoDot:3
IF QUIT
QUIT
End DoDot:2
IF QUIT
QUIT
End DoDot:1
+23 IF SERVCAT="S"
SET VTYP=831
+24 ;If type is still 131 check to see if it is surgery
+25 IF "A"[SERVCAT
IF VTYP=131
DO OPCK
+26 IF $PIECE($GET(^AUTNINS(+ABMINS,2)),U)="R"
Begin DoDot:1
+27 SET ABMLOC=$PIECE($GET(^AUPNVSIT(ABMVDFN,0)),"^",6)
+28 IF $PIECE($GET(^ABMDPARM(+ABMLOC,1,5)),U)'=1
QUIT
+29 SET VTYP=999
+30 KILL ABMLOC
End DoDot:1
+31 QUIT VTYP
+32 ;
+33 ; *********************************************************************
+34 ;This code is only reached if VTYP=131
OPCK ;EP for checking if ambulatory surgery
+1 NEW C,ASC
+2 DO SURGTAB
+3 SET ABM=0
+4 FOR
SET ABM=$ORDER(^AUPNVPRC("AD",ABMVDFN,ABM))
IF 'ABM
QUIT
Begin DoDot:1
+5 ;What we need to find is if from the ICD code we can determine visit
+6 ;type.
+7 ;From the CPT code we should be able to tell if it is surgery
+8 ;If one of the ASC codes from 1 - 8 exists it should be amb surg
+9 ;CPT from 10000-70000 is surgery.
+10 IF '$DATA(^AUPNVPRC(ABM,0))
QUIT
+11 SET ABM("CPT")=$ORDER(^ICPT("I",+^AUPNVPRC(ABM,0),""))
+12 IF 'ABM("CPT")
QUIT
+13 ;CSV-c
SET ASC=$PIECE($$IHSCPT^ABMCVAPI(ABM("CPT"),ABMP("VDT")),U,6)
+14 IF ASC>0
IF ASC<9
DO OPSURG
+15 QUIT
End DoDot:1
IF VTYP'=131
QUIT
+16 QUIT
+17 ;
+18 ; *********************************************************************
OPSURG ;
+1 ;I $D(^ABMNINS(DUZ(2),ABMINS,1,831,0)),+$P(^(0),U,5),'+$P($G(^ABMDFEE($P(^(0),U,5),11,ABM("CPT"),0)),U,2) Q ;abm*2.6*2 3PMS10003A
+2 ;abm*2.6*2 3PMS10003A
IF $DATA(^ABMNINS(DUZ(2),ABMINS,1,831,0))
IF +$PIECE(^(0),U,5)
IF '+$PIECE($$ONE^ABMFEAPI($PIECE(^(0),U,5),11,ABM("CPT"),ABMP("VDT")),U)
QUIT
+3 SET VTYP=831
+4 QUIT
+5 ;
+6 ; *********************************************************************
SURGTAB ;EP - Create CPT table if needed
+1 IF '$DATA(ABMCPTTB("SURGERY"))
Begin DoDot:1
+2 SET ABM=$ORDER(^ABMDCPT("D","SURGERY",""))
+3 SET Y=^ABMDCPT(ABM,0)
+4 SET ABMCPTTB("SURGERY","L")=$PIECE(Y,U,4)
+5 SET ABMCPTTB("SURGERY","H")=$PIECE(Y,U,5)
End DoDot:1
+6 KILL Y
+7 QUIT