ABMDF51 ;IHS/DSD/DMJ/LSL - Set UB92 Print Array ;
;;2.6;IHS 3P BILLING SYSTEM;;NOV 12, 2009
;Original;TMD;12/15/95 2:39 PM
;
;IHS/DSD/DMJ - 5/7/1999 - NOIS XAA-0599-200017 Patch 1
; Itemized bills printing flat rate at line FRATE+5
;
;IHS/SD/SDR - v2.5 p9 - IM10266
; Fix so export mode will be Medi-Cal in 3P Tx Status file
;
; IHS/SD/SDR - v2.5 p9 - IM17398
; Changed export mode to 51 from 11
;
; INPUT: ABMY(active insurer IEN, 3P BILL IEN)="" ;
K ABMP
S U="^"
S ABMP("XMIT")=0 ; initialize transmittal flag
S ABMP("EXP")=51 ; set mode of export to 11 (UB-92)
S ABMY("TOT")="0^0^0" ; # bills ^ $ amt ^ # insurers
S ABMP("NOFMT")=1 ; format flag used for EMC
;
BDFN ;
; Loop ABMY array to print bills grouped by insurer
S ABMY("N")=0 ; initialize active insurer
F S ABMY("N")=$O(ABMY(ABMY("N"))) Q:'ABMY("N") D
.S ABMP("BDFN")=0 ; initialize 3P BILL IEN
.F S ABMP("BDFN")=$O(ABMY(ABMY("N"),ABMP("BDFN"))) Q:'ABMP("BDFN") D
..Q:'$D(^ABMDBILL(DUZ(2),ABMP("BDFN"),0)) ; Quit if no bill data
..D ENT ; gather data print form
..S $P(ABMY("TOT"),U)=$P(ABMY("TOT"),U)+1 ; increment bill count
..I ABMP("XMIT")=0 D ; if no previous transmittal do...
...S ABM("XM")=""
...F S ABM("XM")=$O(^ABMDTXST(DUZ(2),"B",DT,ABM("XM"))) Q:'ABM("XM") D Q:ABMP("XMIT")
....Q:'$D(^ABMDTXST(DUZ(2),ABM("XM"),0)) ; Quit if no data
....Q:$P(^ABMDTXST(DUZ(2),ABM("XM"),0),U,2)'=ABMP("EXP") ; Quit if wrong export mode
....I $D(ABMY("TYP")),$P(^ABMDTXST(DUZ(2),ABM("XM"),0),U,3)=ABMY("TYP") S ABMP("XMIT")=ABM("XM") ;Ins type
....I $D(ABMY("INS")),$P(^ABMDTXST(DUZ(2),ABM("XM"),0),U,4)=ABMY("INS") S ABMP("XMIT")=ABM("XM") ;Insurer
....Q
...Q
..; Create entry in 3P TX STATUS
..I '+ABMP("XMIT") D
...S DIC="^ABMDTXST(DUZ(2),"
...S DIC(0)="L"
...S X=DT
...S DIC("DR")=".02////51;.07////1;.08////1;"_$S($D(ABMY("TYP")):".03////"_ABMY("TYP"),$D(ABMY("INS")):".04////"_$P(ABMY("INS"),U),1:".03////A")_";.05////"_DUZ
...K DD,DO,DINUM D FILE^DICN
...S ABMP("XMIT")=+Y
...Q
..S DIE="^ABMDBILL(DUZ(2),"
..S DA=ABMP("BDFN")
..S DR=".04////B;.16////A;.17////"_ABMP("XMIT")
..D ^ABMDDIE
..Q:$D(ABM("DIE-FAIL"))
..K ^ABMDBILL(DUZ(2),"AS",+^ABMDBILL(DUZ(2),ABMP("BDFN"),0),"A",ABMP("BDFN"))
..S ABM=ABMP("BDFN")
..S ABM("L")=ABMP("XMIT")
..K ABMP
..S ABMP("XMIT")=ABM("L")
..S ABMP("BDFN")=ABM
K ABM,ABMF
Q
;
ENT ;EP for setting up export array and printing form
K ABMF,ABM,ABMU,ABMR,ABMS,ABME
S ABMP("B0")=^ABMDBILL(DUZ(2),ABMP("BDFN"),0) ; 3P BILL 0 node
S ABMP("INS")=$P(ABMP("B0"),U,8) ; Active insurer
Q:'ABMP("INS") ; Q:no active insurer
S ABMP("ITYPE")=$P($G(^AUTNINS(ABMP("INS"),2)),U) ; type of insur
S ABMP("PDFN")=$P(ABMP("B0"),U,5) ; IEN to patient
S ABMP("CDFN")=+$P(ABMP("B0"),U) ; IEN to 3P CLAIM
S ABMP("LDFN")=$P(ABMP("B0"),U,3) ; IEN to location (visit location)
S ABMP("VTYP")=$P(ABMP("B0"),U,7) ; Visit type
Q:'ABMP("PDFN")!('+ABMP("LDFN")) ; Q: no patient or location
S ABMP("VDT")=$P(^ABMDBILL(DUZ(2),ABMP("BDFN"),7),U) ; Serv. date from
S ABMP("BTYP")=$P(ABMP("B0"),U,2) ; Bill type
S ABMP("EXP")=$P(ABMP("B0"),U,6) S:ABMP("EXP")="" ABMP("EXP")=11 ;Export mode w/default set to 11
D EXP^ABMDEVAR ; set export array ABMP("EXP",IEN to 3P EXPORT MODE)
D ISET^ABMERUTL ; set export array ABMP("VTYP",IEN to VISIT)=IEN to 3P EXPORT MODE
S $P(ABMY("TOT"),"^",2)=$P(ABMY("TOT"),"^",2)+$P(^ABMDBILL(DUZ(2),ABMP("BDFN"),2),U) ; increment total bill amount
I '$D(ABMY("TINS",ABMP("INS"))) D
.S ABMY("TINS",ABMP("INS"))=""
.S $P(ABMY("TOT"),"^",3)=$P(ABMY("TOT"),"^",3)+1 ; increment total number of insurers
.Q
D FRATE ; Build flat rate
D ^ABMDF51X ; Gather data and print bill
Q
;
FRATE ; EP
; BUILD FLAT RATE VARIABLE
; ABMP("FLAT")="Flat rate of visit ^ Revenue Code ^ # days covered"
; if date in Visit file is in specified range for specified visit type
K ABMP("FLAT")
I $O(^ABMNINS(DUZ(2),ABMP("INS"),1,ABMP("VTYP"),11,0)) D
.I ABMP("BTYP")=121 S ABMP("VTYP")=121 ; Ancillary
.S ABMP("FLAT")=$$FLAT^ABMDUTL(ABMP("INS"),ABMP("VTYP"),ABMP("VDT")) ; Rate of visit
.I '+ABMP("FLAT") K ABMP("FLAT") Q
.S $P(ABMP("FLAT"),"^",2)=$P(^ABMNINS(DUZ(2),ABMP("INS"),1,ABMP("VTYP"),0),"^",3) ; Revenue code
.I ABMP("BTYP")=121 S ABMP("VTYP")=111
.I $P(ABMP("FLAT"),"^",2)="" D ; if no revenue code
..I ABMP("VTYP")'=111 S $P(ABMP("FLAT"),"^",2)=510 Q ; and not inpatient
..I ABMP("BTYP")=121 S $P(ABMP("FLAT"),"^",2)=240 Q ; and inpatient
..S $P(ABMP("FLAT"),"^",2)=100 Q ; else
..Q
.S $P(ABMP("FLAT"),"^",3)=$S(ABMP("VTYP")=111:$P($G(^ABMDBILL(DUZ(2),ABMP("BDFN"),7)),"^",3),1:1) ; number of days covered
.S:$P(ABMP("FLAT"),"^",3)=0 $P(ABMP("FLAT"),"^",3)=1
.Q
K ABM
Q
ABMDF51 ;IHS/DSD/DMJ/LSL - Set UB92 Print Array ;
+1 ;;2.6;IHS 3P BILLING SYSTEM;;NOV 12, 2009
+2 ;Original;TMD;12/15/95 2:39 PM
+3 ;
+4 ;IHS/DSD/DMJ - 5/7/1999 - NOIS XAA-0599-200017 Patch 1
+5 ; Itemized bills printing flat rate at line FRATE+5
+6 ;
+7 ;IHS/SD/SDR - v2.5 p9 - IM10266
+8 ; Fix so export mode will be Medi-Cal in 3P Tx Status file
+9 ;
+10 ; IHS/SD/SDR - v2.5 p9 - IM17398
+11 ; Changed export mode to 51 from 11
+12 ;
+13 ; INPUT: ABMY(active insurer IEN, 3P BILL IEN)="" ;
+14 KILL ABMP
+15 SET U="^"
+16 ; initialize transmittal flag
SET ABMP("XMIT")=0
+17 ; set mode of export to 11 (UB-92)
SET ABMP("EXP")=51
+18 ; # bills ^ $ amt ^ # insurers
SET ABMY("TOT")="0^0^0"
+19 ; format flag used for EMC
SET ABMP("NOFMT")=1
+20 ;
BDFN ;
+1 ; Loop ABMY array to print bills grouped by insurer
+2 ; initialize active insurer
SET ABMY("N")=0
+3 FOR
SET ABMY("N")=$ORDER(ABMY(ABMY("N")))
IF 'ABMY("N")
QUIT
Begin DoDot:1
+4 ; initialize 3P BILL IEN
SET ABMP("BDFN")=0
+5 FOR
SET ABMP("BDFN")=$ORDER(ABMY(ABMY("N"),ABMP("BDFN")))
IF 'ABMP("BDFN")
QUIT
Begin DoDot:2
+6 ; Quit if no bill data
IF '$DATA(^ABMDBILL(DUZ(2),ABMP("BDFN"),0))
QUIT
+7 ; gather data print form
DO ENT
+8 ; increment bill count
SET $PIECE(ABMY("TOT"),U)=$PIECE(ABMY("TOT"),U)+1
+9 ; if no previous transmittal do...
IF ABMP("XMIT")=0
Begin DoDot:3
+10 SET ABM("XM")=""
+11 FOR
SET ABM("XM")=$ORDER(^ABMDTXST(DUZ(2),"B",DT,ABM("XM")))
IF 'ABM("XM")
QUIT
Begin DoDot:4
+12 ; Quit if no data
IF '$DATA(^ABMDTXST(DUZ(2),ABM("XM"),0))
QUIT
+13 ; Quit if wrong export mode
IF $PIECE(^ABMDTXST(DUZ(2),ABM("XM"),0),U,2)'=ABMP("EXP")
QUIT
+14 ;Ins type
IF $DATA(ABMY("TYP"))
IF $PIECE(^ABMDTXST(DUZ(2),ABM("XM"),0),U,3)=ABMY("TYP")
SET ABMP("XMIT")=ABM("XM")
+15 ;Insurer
IF $DATA(ABMY("INS"))
IF $PIECE(^ABMDTXST(DUZ(2),ABM("XM"),0),U,4)=ABMY("INS")
SET ABMP("XMIT")=ABM("XM")
+16 QUIT
End DoDot:4
IF ABMP("XMIT")
QUIT
+17 QUIT
End DoDot:3
+18 ; Create entry in 3P TX STATUS
+19 IF '+ABMP("XMIT")
Begin DoDot:3
+20 SET DIC="^ABMDTXST(DUZ(2),"
+21 SET DIC(0)="L"
+22 SET X=DT
+23 SET DIC("DR")=".02////51;.07////1;.08////1;"_$SELECT($DATA(ABMY("TYP")):".03////"_ABMY("TYP"),$DATA(ABMY("INS")):".04////"_$PIECE(ABMY("INS"),U),1:".03////A")_";.05////"_DUZ
+24 KILL DD,DO,DINUM
DO FILE^DICN
+25 SET ABMP("XMIT")=+Y
+26 QUIT
End DoDot:3
+27 SET DIE="^ABMDBILL(DUZ(2),"
+28 SET DA=ABMP("BDFN")
+29 SET DR=".04////B;.16////A;.17////"_ABMP("XMIT")
+30 DO ^ABMDDIE
+31 IF $DATA(ABM("DIE-FAIL"))
QUIT
+32 KILL ^ABMDBILL(DUZ(2),"AS",+^ABMDBILL(DUZ(2),ABMP("BDFN"),0),"A",ABMP("BDFN"))
+33 SET ABM=ABMP("BDFN")
+34 SET ABM("L")=ABMP("XMIT")
+35 KILL ABMP
+36 SET ABMP("XMIT")=ABM("L")
+37 SET ABMP("BDFN")=ABM
End DoDot:2
End DoDot:1
+38 KILL ABM,ABMF
+39 QUIT
+40 ;
ENT ;EP for setting up export array and printing form
+1 KILL ABMF,ABM,ABMU,ABMR,ABMS,ABME
+2 ; 3P BILL 0 node
SET ABMP("B0")=^ABMDBILL(DUZ(2),ABMP("BDFN"),0)
+3 ; Active insurer
SET ABMP("INS")=$PIECE(ABMP("B0"),U,8)
+4 ; Q:no active insurer
IF 'ABMP("INS")
QUIT
+5 ; type of insur
SET ABMP("ITYPE")=$PIECE($GET(^AUTNINS(ABMP("INS"),2)),U)
+6 ; IEN to patient
SET ABMP("PDFN")=$PIECE(ABMP("B0"),U,5)
+7 ; IEN to 3P CLAIM
SET ABMP("CDFN")=+$PIECE(ABMP("B0"),U)
+8 ; IEN to location (visit location)
SET ABMP("LDFN")=$PIECE(ABMP("B0"),U,3)
+9 ; Visit type
SET ABMP("VTYP")=$PIECE(ABMP("B0"),U,7)
+10 ; Q: no patient or location
IF 'ABMP("PDFN")!('+ABMP("LDFN"))
QUIT
+11 ; Serv. date from
SET ABMP("VDT")=$PIECE(^ABMDBILL(DUZ(2),ABMP("BDFN"),7),U)
+12 ; Bill type
SET ABMP("BTYP")=$PIECE(ABMP("B0"),U,2)
+13 ;Export mode w/default set to 11
SET ABMP("EXP")=$PIECE(ABMP("B0"),U,6)
IF ABMP("EXP")=""
SET ABMP("EXP")=11
+14 ; set export array ABMP("EXP",IEN to 3P EXPORT MODE)
DO EXP^ABMDEVAR
+15 ; set export array ABMP("VTYP",IEN to VISIT)=IEN to 3P EXPORT MODE
DO ISET^ABMERUTL
+16 ; increment total bill amount
SET $PIECE(ABMY("TOT"),"^",2)=$PIECE(ABMY("TOT"),"^",2)+$PIECE(^ABMDBILL(DUZ(2),ABMP("BDFN"),2),U)
+17 IF '$DATA(ABMY("TINS",ABMP("INS")))
Begin DoDot:1
+18 SET ABMY("TINS",ABMP("INS"))=""
+19 ; increment total number of insurers
SET $PIECE(ABMY("TOT"),"^",3)=$PIECE(ABMY("TOT"),"^",3)+1
+20 QUIT
End DoDot:1
+21 ; Build flat rate
DO FRATE
+22 ; Gather data and print bill
DO ^ABMDF51X
+23 QUIT
+24 ;
FRATE ; EP
+1 ; BUILD FLAT RATE VARIABLE
+2 ; ABMP("FLAT")="Flat rate of visit ^ Revenue Code ^ # days covered"
+3 ; if date in Visit file is in specified range for specified visit type
+4 KILL ABMP("FLAT")
+5 IF $ORDER(^ABMNINS(DUZ(2),ABMP("INS"),1,ABMP("VTYP"),11,0))
Begin DoDot:1
+6 ; Ancillary
IF ABMP("BTYP")=121
SET ABMP("VTYP")=121
+7 ; Rate of visit
SET ABMP("FLAT")=$$FLAT^ABMDUTL(ABMP("INS"),ABMP("VTYP"),ABMP("VDT"))
+8 IF '+ABMP("FLAT")
KILL ABMP("FLAT")
QUIT
+9 ; Revenue code
SET $PIECE(ABMP("FLAT"),"^",2)=$PIECE(^ABMNINS(DUZ(2),ABMP("INS"),1,ABMP("VTYP"),0),"^",3)
+10 IF ABMP("BTYP")=121
SET ABMP("VTYP")=111
+11 ; if no revenue code
IF $PIECE(ABMP("FLAT"),"^",2)=""
Begin DoDot:2
+12 ; and not inpatient
IF ABMP("VTYP")'=111
SET $PIECE(ABMP("FLAT"),"^",2)=510
QUIT
+13 ; and inpatient
IF ABMP("BTYP")=121
SET $PIECE(ABMP("FLAT"),"^",2)=240
QUIT
+14 ; else
SET $PIECE(ABMP("FLAT"),"^",2)=100
QUIT
+15 QUIT
End DoDot:2
+16 ; number of days covered
SET $PIECE(ABMP("FLAT"),"^",3)=$SELECT(ABMP("VTYP")=111:$PIECE($GET(^ABMDBILL(DUZ(2),ABMP("BDFN"),7)),"^",3),1:1)
+17 IF $PIECE(ABMP("FLAT"),"^",3)=0
SET $PIECE(ABMP("FLAT"),"^",3)=1
+18 QUIT
End DoDot:1
+19 KILL ABM
+20 QUIT