IBCNSMR ;ALB/AAS - MEDICARE BILLS ; 02-SEPT-97
;;2.0;INTEGRATED BILLING;**92,240**;21-MAR-94
;
% G RPRT^IBCNSMRA
;
DQ ; -- entry point from task manager
N I,J,X,Y,IBINSCO,INSCO,NODE,CNT,IBI,IBINSNM,IBNM
S IBQUIT=0
K ^TMP("IB-MRA",$J),^TMP("IB-MRA-CNT",$J)
;
S I=0
F S I=$O(^IBE(350.9,1,99,I)) Q:'I S INSCO(+$G(^IBE(350.9,1,99,I,0)))=""
;
S IBI=0
F S IBI=$O(^DGCR(399,IBI)) Q:'IBI!(IBQUIT) D
.S IBQUIT=$$STOP Q:IBQUIT
.S IBINSCO="" K NODE
.S NODE(0)=$G(^DGCR(399,IBI,0)) Q:NODE(0)=""
.S NODE("C")=$G(^DGCR(399,IBI,"C"))
.S NODE("M")=$G(^DGCR(399,IBI,"M")) Q:NODE("M")=""
.S NODE("U")=$G(^DGCR(399,IBI,"U")) Q:NODE("U")=""
.I $D(INSCO(+NODE("M"))) S IBINSCO=+NODE("M")
.I 'IBINSCO,$D(INSCO(+$P(NODE("M"),"^",2))) S IBINSCO=$P(NODE("M"),"^",2)
.I 'IBINSCO,$D(INSCO(+$P(NODE("M"),"^",3))) S IBINSCO=$P(NODE("M"),"^",3)
.I IBINSCO S IBINSNM=$P($G(^DIC(36,IBINSCO,0)),"^") D BLDDATA
;
I 'IBQUIT D PRINT^IBCNSMR0
G END^IBCNSMRA
END Q
;
BLDDATA ; -- for each bill sent to a selected ins. co. build temp node
N X,YEAR,TYPE,TYPENO,PROC,DIAG,ORGAMNT,BOTH,IBSTAT,DFN,ALIVE,ARSTAT,IBQUIT,RXBILL,PROSBILL,BILLNO,LOCCARE,RATETYP,RN,WHO,TIMEFRM,TOTPAID,REFGC,DATEPR
S IBQUIT=0
S BILLNO=$P(NODE(0),"^")
S YEAR=$E(+NODE("U"),2,3)
S TYPENO=$P(NODE(0),"^",5)
S TYPE=$S(TYPENO<3:"INPATIENT",1:"OUTPATIENT")
S PROC=$$PROC(IBI)
S DIAG=$$DIAG(IBI)
S IBSTAT=$P(NODE(0),"^",13)
S ARSTAT=$$STA^PRCAFN(IBI)
S DFN=$P(NODE(0),"^",2)
S ALIVE=$S(+$G(^DPT(DFN,.35)):"DEAD",1:"ALIVE")
S ORGAMNT=$$ORI^PRCAFN(IBI)
S LOCCARE=$P(NODE(0),"^",4)
S WHO=$P(NODE(0),"^",11)
S RATETYP=$P(NODE(0),"^",7)
S RN=$P($G(^DGCR(399.3,+RATETYP,0)),"^")
S TIMEFRM=$P(NODE(0),"^",6)
S TOTPAID=$$TPR^PRCAFN(IBI)
S REFGC=$P($G(^PRCA(430,IBI,6)),"^",4)'=""
S DATEPR=$P($G(^DGCR(399,IBI,"S")),"^",12)
S BOTH="NONE"
S RXBILL=0
S PROSBILL=0
I $O(^IBA(362.4,"AIFN"_IBI,"")) S RXBILL=1
I $O(^IBA(362.5,"AIFN"_IBI,"")) S PROSBILL=1
D COUNT
D:'IBQUIT SET
Q
;
COUNT ; -- set totals for all ins, and by ins co.
S CNT=$G(CNT)+1
S CNT(0)=$G(CNT(0))+ORGAMNT
S CNT(3,IBINSNM)=$G(CNT(3,IBINSNM))+1
S CNT(3,IBINSNM,0)=$G(CNT(3,IBINSNM,0))+ORGAMNT
I TYPE="INPATIENT" D
.S CNT("IN")=$G(CNT("IN"))+1
.S CNT("IN",0)=$G(CNT("IN",0))+ORGAMNT
.I TOTPAID>0 D
..S CNT("IN",1)=$G(CNT("IN",1))+1
..S CNT("IN",2)=$G(CNT("IN",2))+TOTPAID
I TYPE="OUTPATIENT" D
.S CNT("OP")=$G(CNT("OP"))+1
.S CNT("OP",0)=$G(CNT("OP",0))+ORGAMNT
.I TOTPAID>0 D
..S CNT("OP",1)=$G(CNT("OP",1))+1
..S CNT("OP",2)=$G(CNT("OP",2))+TOTPAID
I TOTPAID>0 D
.S CNT(1)=$G(CNT(1))+1
.S CNT(2)=$G(CNT(2))+TOTPAID
.S CNT(3,IBINSNM,1)=$G(CNT(3,IBINSNM,1))+1
.S CNT(3,IBINSNM,2)=$G(CNT(3,IBINSNM,2))+TOTPAID
;
;I ALIVE'="ALIVE" D ; decided to keep dead patients in the report 10/28/97
;.S CNT("A")=$G(CNT("A"))+1
;.S CNT("A",0)=$G(CNT("A",0))+ORGAMNT
;.;S IBQUIT=1
;.I TOTPAID>0 D
;..S CNT("A",1)=$G(CNT("A",1))+1
;..S CNT("A",2)=$G(CNT("A",2))+TOTPAID
;
I DIAG="YES"&(PROC="NO") D
.S BOTH="DIAG"
.S IBQUIT=1
.S CNT("D")=$G(CNT("D"))+1
.S CNT("D",0)=$G(CNT("D",0))+ORGAMNT
.I TOTPAID>0 D
..S CNT("D",1)=$G(CNT("D",1))+1
..S CNT("D",2)=$G(CNT("D",2))+TOTPAID
;
I PROC="YES"&(DIAG="NO") D
.S BOTH="PROC"
.S IBQUIT=1
.S CNT("P")=$G(CNT("P"))+1
.S CNT("P",0)=$G(CNT("P",0))+ORGAMNT
.I TOTPAID>0 D
..S CNT("P",1)=$G(CNT("P",1))+1
..S CNT("P",2)=$G(CNT("P",2))+TOTPAID
;
I PROC="YES"&(DIAG="YES") D
.S BOTH="BOTH"
.S CNT("B")=$G(CNT("B"))+1
.S CNT("B",0)=$G(CNT("B",0))+ORGAMNT
.I TOTPAID>0 D
..S CNT("B",1)=$G(CNT("B",1))+1
..S CNT("B",2)=$G(CNT("B",2))+TOTPAID
;
I BOTH="NONE" D
.S CNT("N")=$G(CNT("N"))+1
.S CNT("N",0)=$G(CNT("N",0))+ORGAMNT
.I TOTPAID>0 D
..S CNT("N",1)=$G(CNT("N",1))+1
..S CNT("N",2)=$G(CNT("N",2))+TOTPAID
;
I BOTH'="BOTH" S IBQUIT=1
;
I IBSTAT=7,+ARSTAT=210 D ;bill canceled before completion
.S CNT("C")=$G(CNT("C"))+1
.S CNT("C",0)=$G(CNT("C",0))+ORGAMNT
.S IBQUIT=1
.I TOTPAID>0 D
..S CNT("C",1)=$G(CNT("C",1))+1
..S CNT("C",2)=$G(CNT("C",2))+TOTPAID
;
I TYPENO=2!(TYPENO=4) D
.S CNT("T")=$G(CNT("T"))+1
.S CNT("T",0)=$G(CNT("T",0))+ORGAMNT
.S IBQUIT=1
.I TOTPAID>0 D
..S CNT("T",1)=$G(CNT("T",1))+1
..S CNT("T",2)=$G(CNT("T",2))+TOTPAID
;
I WHO'="i" D
.S CNT("W")=$G(CNT("W"))+1
.S CNT("W",0)=$G(CNT("W",0))+ORGAMNT
.S IBQUIT=1
.I TOTPAID>0 D
..S CNT("W",1)=$G(CNT("W",1))+1
..S CNT("W",2)=$G(CNT("W",2))+TOTPAID
;
I DATEPR="",IBSTAT<3 D
.S CNT("F")=$G(CNT("F"))+1
.S CNT("F",0)=$G(CNT("F",0))+ORGAMNT
.S IBQUIT=1
.I TOTPAID>0 D
..S CNT("F",1)=$G(CNT("F",1))+1
..S CNT("F",2)=$G(CNT("F",2))+TOTPAID
;
I $G(RXBILL) D
.S CNT("X")=$G(CNT("X"))+1
.S CNT("X",0)=$G(CNT("X",0))+ORGAMNT
.S IBQUIT=1
.I TOTPAID>0 D
..S CNT("X",1)=$G(CNT("X",1))+1
..S CNT("X",2)=$G(CNT("X",2))+TOTPAID
;
I $G(PROSBILL) D
.S CNT("Z")=$G(CNT("Z"))+1
.S CNT("Z",0)=$G(CNT("Z",0))+ORGAMNT
.S IBQUIT=1
.I TOTPAID>0 D
..S CNT("Z",1)=$G(CNT("Z",1))+1
..S CNT("Z",2)=$G(CNT("Z",2))+TOTPAID
;
I $S(RN["MEANS":1,RN["DENTAL":1,RN["TORT":1,RN["TRICARE":1,RN["CHAMPVA":1,RN["MEDICARE":1,RN["WORKERS":1,RN["CRIME":1,RN["SHARING":1,1:0) D
.S CNT("R")=$G(CNT("R"))+1
.S CNT("R",0)=$G(CNT("R",0))+ORGAMNT
.S IBQUIT=1
.I TOTPAID>0 D
..S CNT("R",1)=$G(CNT("R",1))+1
..S CNT("R",2)=$G(CNT("R",2))+TOTPAID
Q
;
PROC(IBI) ; -- does bill have any procedures
N PROC
S PROC="NO"
I $O(^DGCR(399,IBI,"CP",0)) S PROC="YES"
I +NODE("C")!($P(NODE("C"),"^",4))!($P(NODE("C"),"^",7)) S PROC="YES"
Q PROC
;
DIAG(IBI) ; -- does bill have any diagnosis
N DIAG
S DIAG="NO"
I $O(^IBA(362.3,"AIFN"_IBI,0)) S DIAG="YES"
I $P(NODE("C"),"^",10)!($P(NODE("C"),"^",14)) S DIAG="YES"
Q DIAG
;
SET ; -- set up tmp global
S CNT("M")=$G(CNT("M"))+1,CNT("M",0)=$G(CNT("M",0))+ORGAMNT
I REFGC D
.S CNT("M",4)=$G(CNT("M",4))+1
.S CNT("M",5)=$G(CNT("M",5))+ORGAMNT
.I TOTPAID>0 D
..S CNT("M",6)=$G(CNT("M",6))+1
..S CNT("M",7)=$G(CNT("M",7))+TOTPAID
I TOTPAID>0 D
.S CNT("M",1)=$G(CNT("M",1))+1
.S CNT("M",2)=$G(CNT("M",2))+TOTPAID
I TYPE="INPATIENT" D
.S CNT("M","IN")=$G(CNT("M","IN"))+1
.S CNT("M","IN",0)=$G(CNT("M","IN",0))+ORGAMNT
.I TOTPAID>0 D
..S CNT("M","IN",1)=$G(CNT("M","IN",1))+1
..S CNT("M","IN",2)=$G(CNT("M","IN",2))+TOTPAID
I TYPE="OUTPATIENT" D
.S CNT("M","OP")=$G(CNT("M","OP"))+1
.S CNT("M","OP",0)=$G(CNT("M","OP",0))+ORGAMNT
.I TOTPAID>0 D
..S CNT("M","OP",1)=$G(CNT("M","OP",1))+1
..S CNT("M","OP",2)=$G(CNT("M","OP",2))+TOTPAID
;
S ^TMP("IB-MRA",$J,+$G(IBINSCO),+$G(YEAR),$G(TYPE,"UNKNOWN"),BOTH,$G(ARSTAT,"UNKNOWN"),+$G(IBSTAT),IBI)=BILLNO_"^"_DFN
;
S ^TMP("IB-MRA-CNT",$J,IBINSCO,YEAR,TYPE,BOTH,ARSTAT,IBSTAT)=(+$G(^TMP("IB-MRA-CNT",$J,IBINSCO,YEAR,TYPE,BOTH,ARSTAT,IBSTAT))+1)
;
S ^TMP("IB-MRA-CNT",$J,IBINSCO,YEAR,TYPE,BOTH,ARSTAT,IBSTAT,0)=+$G(^TMP("IB-MRA-CNT",$J,IBINSCO,YEAR,TYPE,BOTH,ARSTAT,IBSTAT,0))+ORGAMNT
;
I TOTPAID>0 D
.S ^TMP("IB-MRA-CNT",$J,IBINSCO,YEAR,TYPE,BOTH,ARSTAT,IBSTAT,1)=+$G(^TMP("IB-MRA-CNT",$J,IBINSCO,YEAR,TYPE,BOTH,ARSTAT,IBSTAT,1))+1
.S ^TMP("IB-MRA-CNT",$J,IBINSCO,YEAR,TYPE,BOTH,ARSTAT,IBSTAT,2)=+$G(^TMP("IB-MRA-CNT",$J,IBINSCO,YEAR,TYPE,BOTH,ARSTAT,IBSTAT,2))+TOTPAID
Q
;
STOP() ; -- determine if user requested task to stop
I $D(ZTQUEUED),$$S^%ZTLOAD S ZTSTOP=1 K ZTREQ
Q +$G(ZTSTOP)
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HIBCNSMR 7443 printed Oct 16, 2024@18:18:18 Page 2
IBCNSMR ;ALB/AAS - MEDICARE BILLS ; 02-SEPT-97
+1 ;;2.0;INTEGRATED BILLING;**92,240**;21-MAR-94
+2 ;
% GOTO RPRT^IBCNSMRA
+1 ;
DQ ; -- entry point from task manager
+1 NEW I,J,X,Y,IBINSCO,INSCO,NODE,CNT,IBI,IBINSNM,IBNM
+2 SET IBQUIT=0
+3 KILL ^TMP("IB-MRA",$JOB),^TMP("IB-MRA-CNT",$JOB)
+4 ;
+5 SET I=0
+6 FOR
SET I=$ORDER(^IBE(350.9,1,99,I))
if 'I
QUIT
SET INSCO(+$GET(^IBE(350.9,1,99,I,0)))=""
+7 ;
+8 SET IBI=0
+9 FOR
SET IBI=$ORDER(^DGCR(399,IBI))
if 'IBI!(IBQUIT)
QUIT
Begin DoDot:1
+10 SET IBQUIT=$$STOP
if IBQUIT
QUIT
+11 SET IBINSCO=""
KILL NODE
+12 SET NODE(0)=$GET(^DGCR(399,IBI,0))
if NODE(0)=""
QUIT
+13 SET NODE("C")=$GET(^DGCR(399,IBI,"C"))
+14 SET NODE("M")=$GET(^DGCR(399,IBI,"M"))
if NODE("M")=""
QUIT
+15 SET NODE("U")=$GET(^DGCR(399,IBI,"U"))
if NODE("U")=""
QUIT
+16 IF $DATA(INSCO(+NODE("M")))
SET IBINSCO=+NODE("M")
+17 IF 'IBINSCO
IF $DATA(INSCO(+$PIECE(NODE("M"),"^",2)))
SET IBINSCO=$PIECE(NODE("M"),"^",2)
+18 IF 'IBINSCO
IF $DATA(INSCO(+$PIECE(NODE("M"),"^",3)))
SET IBINSCO=$PIECE(NODE("M"),"^",3)
+19 IF IBINSCO
SET IBINSNM=$PIECE($GET(^DIC(36,IBINSCO,0)),"^")
DO BLDDATA
End DoDot:1
+20 ;
+21 IF 'IBQUIT
DO PRINT^IBCNSMR0
+22 GOTO END^IBCNSMRA
END QUIT
+1 ;
BLDDATA ; -- for each bill sent to a selected ins. co. build temp node
+1 NEW X,YEAR,TYPE,TYPENO,PROC,DIAG,ORGAMNT,BOTH,IBSTAT,DFN,ALIVE,ARSTAT,IBQUIT,RXBILL,PROSBILL,BILLNO,LOCCARE,RATETYP,RN,WHO,TIMEFRM,TOTPAID,REFGC,DATEPR
+2 SET IBQUIT=0
+3 SET BILLNO=$PIECE(NODE(0),"^")
+4 SET YEAR=$EXTRACT(+NODE("U"),2,3)
+5 SET TYPENO=$PIECE(NODE(0),"^",5)
+6 SET TYPE=$SELECT(TYPENO<3:"INPATIENT",1:"OUTPATIENT")
+7 SET PROC=$$PROC(IBI)
+8 SET DIAG=$$DIAG(IBI)
+9 SET IBSTAT=$PIECE(NODE(0),"^",13)
+10 SET ARSTAT=$$STA^PRCAFN(IBI)
+11 SET DFN=$PIECE(NODE(0),"^",2)
+12 SET ALIVE=$SELECT(+$GET(^DPT(DFN,.35)):"DEAD",1:"ALIVE")
+13 SET ORGAMNT=$$ORI^PRCAFN(IBI)
+14 SET LOCCARE=$PIECE(NODE(0),"^",4)
+15 SET WHO=$PIECE(NODE(0),"^",11)
+16 SET RATETYP=$PIECE(NODE(0),"^",7)
+17 SET RN=$PIECE($GET(^DGCR(399.3,+RATETYP,0)),"^")
+18 SET TIMEFRM=$PIECE(NODE(0),"^",6)
+19 SET TOTPAID=$$TPR^PRCAFN(IBI)
+20 SET REFGC=$PIECE($GET(^PRCA(430,IBI,6)),"^",4)'=""
+21 SET DATEPR=$PIECE($GET(^DGCR(399,IBI,"S")),"^",12)
+22 SET BOTH="NONE"
+23 SET RXBILL=0
+24 SET PROSBILL=0
+25 IF $ORDER(^IBA(362.4,"AIFN"_IBI,""))
SET RXBILL=1
+26 IF $ORDER(^IBA(362.5,"AIFN"_IBI,""))
SET PROSBILL=1
+27 DO COUNT
+28 if 'IBQUIT
DO SET
+29 QUIT
+30 ;
COUNT ; -- set totals for all ins, and by ins co.
+1 SET CNT=$GET(CNT)+1
+2 SET CNT(0)=$GET(CNT(0))+ORGAMNT
+3 SET CNT(3,IBINSNM)=$GET(CNT(3,IBINSNM))+1
+4 SET CNT(3,IBINSNM,0)=$GET(CNT(3,IBINSNM,0))+ORGAMNT
+5 IF TYPE="INPATIENT"
Begin DoDot:1
+6 SET CNT("IN")=$GET(CNT("IN"))+1
+7 SET CNT("IN",0)=$GET(CNT("IN",0))+ORGAMNT
+8 IF TOTPAID>0
Begin DoDot:2
+9 SET CNT("IN",1)=$GET(CNT("IN",1))+1
+10 SET CNT("IN",2)=$GET(CNT("IN",2))+TOTPAID
End DoDot:2
End DoDot:1
+11 IF TYPE="OUTPATIENT"
Begin DoDot:1
+12 SET CNT("OP")=$GET(CNT("OP"))+1
+13 SET CNT("OP",0)=$GET(CNT("OP",0))+ORGAMNT
+14 IF TOTPAID>0
Begin DoDot:2
+15 SET CNT("OP",1)=$GET(CNT("OP",1))+1
+16 SET CNT("OP",2)=$GET(CNT("OP",2))+TOTPAID
End DoDot:2
End DoDot:1
+17 IF TOTPAID>0
Begin DoDot:1
+18 SET CNT(1)=$GET(CNT(1))+1
+19 SET CNT(2)=$GET(CNT(2))+TOTPAID
+20 SET CNT(3,IBINSNM,1)=$GET(CNT(3,IBINSNM,1))+1
+21 SET CNT(3,IBINSNM,2)=$GET(CNT(3,IBINSNM,2))+TOTPAID
End DoDot:1
+22 ;
+23 ;I ALIVE'="ALIVE" D ; decided to keep dead patients in the report 10/28/97
+24 ;.S CNT("A")=$G(CNT("A"))+1
+25 ;.S CNT("A",0)=$G(CNT("A",0))+ORGAMNT
+26 ;.;S IBQUIT=1
+27 ;.I TOTPAID>0 D
+28 ;..S CNT("A",1)=$G(CNT("A",1))+1
+29 ;..S CNT("A",2)=$G(CNT("A",2))+TOTPAID
+30 ;
+31 IF DIAG="YES"&(PROC="NO")
Begin DoDot:1
+32 SET BOTH="DIAG"
+33 SET IBQUIT=1
+34 SET CNT("D")=$GET(CNT("D"))+1
+35 SET CNT("D",0)=$GET(CNT("D",0))+ORGAMNT
+36 IF TOTPAID>0
Begin DoDot:2
+37 SET CNT("D",1)=$GET(CNT("D",1))+1
+38 SET CNT("D",2)=$GET(CNT("D",2))+TOTPAID
End DoDot:2
End DoDot:1
+39 ;
+40 IF PROC="YES"&(DIAG="NO")
Begin DoDot:1
+41 SET BOTH="PROC"
+42 SET IBQUIT=1
+43 SET CNT("P")=$GET(CNT("P"))+1
+44 SET CNT("P",0)=$GET(CNT("P",0))+ORGAMNT
+45 IF TOTPAID>0
Begin DoDot:2
+46 SET CNT("P",1)=$GET(CNT("P",1))+1
+47 SET CNT("P",2)=$GET(CNT("P",2))+TOTPAID
End DoDot:2
End DoDot:1
+48 ;
+49 IF PROC="YES"&(DIAG="YES")
Begin DoDot:1
+50 SET BOTH="BOTH"
+51 SET CNT("B")=$GET(CNT("B"))+1
+52 SET CNT("B",0)=$GET(CNT("B",0))+ORGAMNT
+53 IF TOTPAID>0
Begin DoDot:2
+54 SET CNT("B",1)=$GET(CNT("B",1))+1
+55 SET CNT("B",2)=$GET(CNT("B",2))+TOTPAID
End DoDot:2
End DoDot:1
+56 ;
+57 IF BOTH="NONE"
Begin DoDot:1
+58 SET CNT("N")=$GET(CNT("N"))+1
+59 SET CNT("N",0)=$GET(CNT("N",0))+ORGAMNT
+60 IF TOTPAID>0
Begin DoDot:2
+61 SET CNT("N",1)=$GET(CNT("N",1))+1
+62 SET CNT("N",2)=$GET(CNT("N",2))+TOTPAID
End DoDot:2
End DoDot:1
+63 ;
+64 IF BOTH'="BOTH"
SET IBQUIT=1
+65 ;
+66 ;bill canceled before completion
IF IBSTAT=7
IF +ARSTAT=210
Begin DoDot:1
+67 SET CNT("C")=$GET(CNT("C"))+1
+68 SET CNT("C",0)=$GET(CNT("C",0))+ORGAMNT
+69 SET IBQUIT=1
+70 IF TOTPAID>0
Begin DoDot:2
+71 SET CNT("C",1)=$GET(CNT("C",1))+1
+72 SET CNT("C",2)=$GET(CNT("C",2))+TOTPAID
End DoDot:2
End DoDot:1
+73 ;
+74 IF TYPENO=2!(TYPENO=4)
Begin DoDot:1
+75 SET CNT("T")=$GET(CNT("T"))+1
+76 SET CNT("T",0)=$GET(CNT("T",0))+ORGAMNT
+77 SET IBQUIT=1
+78 IF TOTPAID>0
Begin DoDot:2
+79 SET CNT("T",1)=$GET(CNT("T",1))+1
+80 SET CNT("T",2)=$GET(CNT("T",2))+TOTPAID
End DoDot:2
End DoDot:1
+81 ;
+82 IF WHO'="i"
Begin DoDot:1
+83 SET CNT("W")=$GET(CNT("W"))+1
+84 SET CNT("W",0)=$GET(CNT("W",0))+ORGAMNT
+85 SET IBQUIT=1
+86 IF TOTPAID>0
Begin DoDot:2
+87 SET CNT("W",1)=$GET(CNT("W",1))+1
+88 SET CNT("W",2)=$GET(CNT("W",2))+TOTPAID
End DoDot:2
End DoDot:1
+89 ;
+90 IF DATEPR=""
IF IBSTAT<3
Begin DoDot:1
+91 SET CNT("F")=$GET(CNT("F"))+1
+92 SET CNT("F",0)=$GET(CNT("F",0))+ORGAMNT
+93 SET IBQUIT=1
+94 IF TOTPAID>0
Begin DoDot:2
+95 SET CNT("F",1)=$GET(CNT("F",1))+1
+96 SET CNT("F",2)=$GET(CNT("F",2))+TOTPAID
End DoDot:2
End DoDot:1
+97 ;
+98 IF $GET(RXBILL)
Begin DoDot:1
+99 SET CNT("X")=$GET(CNT("X"))+1
+100 SET CNT("X",0)=$GET(CNT("X",0))+ORGAMNT
+101 SET IBQUIT=1
+102 IF TOTPAID>0
Begin DoDot:2
+103 SET CNT("X",1)=$GET(CNT("X",1))+1
+104 SET CNT("X",2)=$GET(CNT("X",2))+TOTPAID
End DoDot:2
End DoDot:1
+105 ;
+106 IF $GET(PROSBILL)
Begin DoDot:1
+107 SET CNT("Z")=$GET(CNT("Z"))+1
+108 SET CNT("Z",0)=$GET(CNT("Z",0))+ORGAMNT
+109 SET IBQUIT=1
+110 IF TOTPAID>0
Begin DoDot:2
+111 SET CNT("Z",1)=$GET(CNT("Z",1))+1
+112 SET CNT("Z",2)=$GET(CNT("Z",2))+TOTPAID
End DoDot:2
End DoDot:1
+113 ;
+114 IF $SELECT(RN["MEANS":1,RN["DENTAL":1,RN["TORT":1,RN["TRICARE":1,RN["CHAMPVA":1,RN["MEDICARE":1,RN["WORKERS":1,RN["CRIME":1,RN["SHARING":1,1:0)
Begin DoDot:1
+115 SET CNT("R")=$GET(CNT("R"))+1
+116 SET CNT("R",0)=$GET(CNT("R",0))+ORGAMNT
+117 SET IBQUIT=1
+118 IF TOTPAID>0
Begin DoDot:2
+119 SET CNT("R",1)=$GET(CNT("R",1))+1
+120 SET CNT("R",2)=$GET(CNT("R",2))+TOTPAID
End DoDot:2
End DoDot:1
+121 QUIT
+122 ;
PROC(IBI) ; -- does bill have any procedures
+1 NEW PROC
+2 SET PROC="NO"
+3 IF $ORDER(^DGCR(399,IBI,"CP",0))
SET PROC="YES"
+4 IF +NODE("C")!($PIECE(NODE("C"),"^",4))!($PIECE(NODE("C"),"^",7))
SET PROC="YES"
+5 QUIT PROC
+6 ;
DIAG(IBI) ; -- does bill have any diagnosis
+1 NEW DIAG
+2 SET DIAG="NO"
+3 IF $ORDER(^IBA(362.3,"AIFN"_IBI,0))
SET DIAG="YES"
+4 IF $PIECE(NODE("C"),"^",10)!($PIECE(NODE("C"),"^",14))
SET DIAG="YES"
+5 QUIT DIAG
+6 ;
SET ; -- set up tmp global
+1 SET CNT("M")=$GET(CNT("M"))+1
SET CNT("M",0)=$GET(CNT("M",0))+ORGAMNT
+2 IF REFGC
Begin DoDot:1
+3 SET CNT("M",4)=$GET(CNT("M",4))+1
+4 SET CNT("M",5)=$GET(CNT("M",5))+ORGAMNT
+5 IF TOTPAID>0
Begin DoDot:2
+6 SET CNT("M",6)=$GET(CNT("M",6))+1
+7 SET CNT("M",7)=$GET(CNT("M",7))+TOTPAID
End DoDot:2
End DoDot:1
+8 IF TOTPAID>0
Begin DoDot:1
+9 SET CNT("M",1)=$GET(CNT("M",1))+1
+10 SET CNT("M",2)=$GET(CNT("M",2))+TOTPAID
End DoDot:1
+11 IF TYPE="INPATIENT"
Begin DoDot:1
+12 SET CNT("M","IN")=$GET(CNT("M","IN"))+1
+13 SET CNT("M","IN",0)=$GET(CNT("M","IN",0))+ORGAMNT
+14 IF TOTPAID>0
Begin DoDot:2
+15 SET CNT("M","IN",1)=$GET(CNT("M","IN",1))+1
+16 SET CNT("M","IN",2)=$GET(CNT("M","IN",2))+TOTPAID
End DoDot:2
End DoDot:1
+17 IF TYPE="OUTPATIENT"
Begin DoDot:1
+18 SET CNT("M","OP")=$GET(CNT("M","OP"))+1
+19 SET CNT("M","OP",0)=$GET(CNT("M","OP",0))+ORGAMNT
+20 IF TOTPAID>0
Begin DoDot:2
+21 SET CNT("M","OP",1)=$GET(CNT("M","OP",1))+1
+22 SET CNT("M","OP",2)=$GET(CNT("M","OP",2))+TOTPAID
End DoDot:2
End DoDot:1
+23 ;
+24 SET ^TMP("IB-MRA",$JOB,+$GET(IBINSCO),+$GET(YEAR),$GET(TYPE,"UNKNOWN"),BOTH,$GET(ARSTAT,"UNKNOWN"),+$GET(IBSTAT),IBI)=BILLNO_"^"_DFN
+25 ;
+26 SET ^TMP("IB-MRA-CNT",$JOB,IBINSCO,YEAR,TYPE,BOTH,ARSTAT,IBSTAT)=(+$GET(^TMP("IB-MRA-CNT",$JOB,IBINSCO,YEAR,TYPE,BOTH,ARSTAT,IBSTAT))+1)
+27 ;
+28 SET ^TMP("IB-MRA-CNT",$JOB,IBINSCO,YEAR,TYPE,BOTH,ARSTAT,IBSTAT,0)=+$GET(^TMP("IB-MRA-CNT",$JOB,IBINSCO,YEAR,TYPE,BOTH,ARSTAT,IBSTAT,0))+ORGAMNT
+29 ;
+30 IF TOTPAID>0
Begin DoDot:1
+31 SET ^TMP("IB-MRA-CNT",$JOB,IBINSCO,YEAR,TYPE,BOTH,ARSTAT,IBSTAT,1)=+$GET(^TMP("IB-MRA-CNT",$JOB,IBINSCO,YEAR,TYPE,BOTH,ARSTAT,IBSTAT,1))+1
+32 SET ^TMP("IB-MRA-CNT",$JOB,IBINSCO,YEAR,TYPE,BOTH,ARSTAT,IBSTAT,2)=+$GET(^TMP("IB-MRA-CNT",$JOB,IBINSCO,YEAR,TYPE,BOTH,ARSTAT,IBSTAT,2))+TOTPAID
End DoDot:1
+33 QUIT
+34 ;
STOP() ; -- determine if user requested task to stop
+1 IF $DATA(ZTQUEUED)
IF $$S^%ZTLOAD
SET ZTSTOP=1
KILL ZTREQ
+2 QUIT +$GET(ZTSTOP)