IBCNSMR0 ;ALB/AAS - MEDICARE BILLS ; 02-SEPT-97
;;2.0; INTEGRATED BILLING ;**92**; 21-MAR-94
;
% G RPRT^IBCNSMRA
Q
;
PRINT ;
N IBQUIT,IBPAG,IBHDT
S IBQUIT=0,IBPAG=0,IBHDT=$$HTE^XLFDT($H)
I IBPRNT="D" U IO D HDR(0),TOTALS Q:IBQUIT D HDR(1),SORT Q:IBQUIT D HDR(2),DETAIL Q:IBQUIT
I IBPRNT="S" U IO D HDR(0),TOTALS Q:IBQUIT D HDR(1),SORT
I IBSNDRPT D BULL^IBCNSMR1
Q
;
TOTALS ; -- prepare report
W !!," Bills Found for Selected Ins. Co.: "_$J(+$G(CNT),6)_$$FORMAT(+$G(CNT(0)),"2$",17)_$J(+$G(CNT(1)),6)_$$FORMAT(+$G(CNT(2)),"2$",14)
W !," Bills for Outpatient Visits: "_$J(+$G(CNT("OP")),6)_$$FORMAT(+$G(CNT("OP",0)),"2$",17)_$J(+$G(CNT("OP",1)),6)_$$FORMAT(+$G(CNT("OP",2)),"2$",14)
W !," Bills for Inpatient Visits: "_$J(+$G(CNT("IN")),6)_$$FORMAT(+$G(CNT("IN",0)),"2$",17)_$J(+$G(CNT("IN",1)),6)_$$FORMAT(+$G(CNT("IN",2)),"2$",14)
;
W !!," Subtotals by Selected Ins. Co.: "
S IBNM=""
F S IBNM=$O(CNT(3,IBNM)) Q:IBNM="" D
.W !,?(35-$L(IBNM)),IBNM_": "_$J(+$G(CNT(3,IBNM)),6)_$$FORMAT(+$G(CNT(3,IBNM,0)),"2$",17)_$J(+$G(CNT(3,IBNM,1)),6)_$$FORMAT(+$G(CNT(3,IBNM,2)),"2$",14)
;
W !!,"Bills with Procedures and Diagnosis: "_$J(+$G(CNT("B")),6)_$$FORMAT(+$G(CNT("B",0)),"2$",17)_$J(+$G(CNT("B",1)),6)_$$FORMAT(+$G(CNT("B",2)),"2$",14)
W !," Bills with Diagnosis Codes Only: "_$J(+$G(CNT("D")),6)_$$FORMAT(+$G(CNT("D",0)),"2$",17)_$J(+$G(CNT("D",1)),6)_$$FORMAT(+$G(CNT("D",2)),"2$",14)
W !," Bills with Procedure Codes Only: "_$J(+$G(CNT("P")),6)_$$FORMAT(+$G(CNT("P",0)),"2$",17)_$J(+$G(CNT("P",1)),6)_$$FORMAT(+$G(CNT("P",2)),"2$",14)
W !," Bills with No Proc. or Diag. Codes: "_$J(+$G(CNT("N")),6)_$$FORMAT(+$G(CNT("N",0)),"2$",17)_$J(+$G(CNT("N",1)),6)_$$FORMAT(+$G(CNT("N",2)),"2$",14)
;
W !!," Bills Canceled before Completion: "_$J(+$G(CNT("C")),6)_$$FORMAT(+$G(CNT("C",0)),"2$",17)_$J(+$G(CNT("C",1)),6)_$$FORMAT(+$G(CNT("C",2)),"2$",14)
W !," Bills Never Printed: "_$J(+$G(CNT("F")),6)_$$FORMAT(+$G(CNT("F",0)),"2$",17)_$J(+$G(CNT("F",1)),6)_$$FORMAT(+$G(CNT("F",2)),"2$",14)
W !," Bills with wrong Rate Type: "_$J(+$G(CNT("R")),6)_$$FORMAT(+$G(CNT("R",0)),"2$",17)_$J(+$G(CNT("R",1)),6)_$$FORMAT(+$G(CNT("R",2)),"2$",14)
W !," Bills with wrong Who's Responsible: "_$J(+$G(CNT("W")),6)_$$FORMAT(+$G(CNT("W",0)),"2$",17)_$J(+$G(CNT("W",1)),6)_$$FORMAT(+$G(CNT("W",2)),"2$",14)
W !," Bills w/ wrong Bill Classification: "_$J(+$G(CNT("T")),6)_$$FORMAT(+$G(CNT("T",0)),"2$",17)_$J(+$G(CNT("T",1)),6)_$$FORMAT(+$G(CNT("T",2)),"2$",14)
W !," Bills for Prescriptions: "_$J(+$G(CNT("X")),6)_$$FORMAT(+$G(CNT("X",0)),"2$",17)_$J(+$G(CNT("X",1)),6)_$$FORMAT(+$G(CNT("X",2)),"2$",14)
W !," Bills for Prosthetics: "_$J(+$G(CNT("Z")),6)_$$FORMAT(+$G(CNT("Z",0)),"2$",17)_$J(+$G(CNT("Z",1)),6)_$$FORMAT(+$G(CNT("Z",2)),"2$",14)
;W !," Bills with Patients Not Alive: "_$J(+$G(CNT("A")),6)_$$FORMAT(+$G(CNT("A",0)),"2$",17)_$J(+$G(CNT("A",1)),6)_$$FORMAT(+$G(CNT("A",2)),"2$",14)
;
W !!," Bills Meeting Criteria for MRA: "_$J(+$G(CNT("M")),6)_$$FORMAT(+$G(CNT("M",0)),"2$",17)_$J(+$G(CNT("M",1)),6)_$$FORMAT(+$G(CNT("M",2)),"2$",14)
W !," Outpatient Bills Meeting Criteria: "_$J(+$G(CNT("M","OP")),6)_$$FORMAT(+$G(CNT("M","OP",0)),"2$",17)_$J(+$G(CNT("M","OP",1)),6)_$$FORMAT(+$G(CNT("M","OP",2)),"2$",14)
W !," Inpatient Bills Meeting Criteria: "_$J(+$G(CNT("M","IN")),6)_$$FORMAT(+$G(CNT("M","IN",0)),"2$",17)_$J(+$G(CNT("M","IN",1)),6)_$$FORMAT(+$G(CNT("M","IN",2)),"2$",14)
W !," Bill Meeting Criteria and Referred: "_$J(+$G(CNT("M",4)),6)_$$FORMAT(+$G(CNT("M",5)),"2$",17)_$J(+$G(CNT("M",6)),6)_$$FORMAT(+$G(CNT("M",7)),"2$",14)
;
Q
;
SORT ; -- Run through list by insurance company
N I,J,K,L,M,N,P,X,Y,Z,ZZ
;
I '$D(^TMP("IB-MRA-CNT",$J)) W !!,"There are no summary records to print.",! G SORTQ
;
S I=0
F S I=$O(^TMP("IB-MRA-CNT",$J,I)) Q:I=""!(IBQUIT) D ;insur. co
.S J=0
.F S J=$O(^TMP("IB-MRA-CNT",$J,I,J)) Q:J=""!(IBQUIT) D ;year
..S IBQUIT=$$STOP^IBCNSMR Q:IBQUIT
..S K=""
..F S K=$O(^TMP("IB-MRA-CNT",$J,I,J,K)) Q:K=""!(IBQUIT) D ;bill type
...D SUBHDR
...S L=0
...F S L=$O(^TMP("IB-MRA-CNT",$J,I,J,K,L)) Q:L=""!(IBQUIT) D ;proc
....S M=0
....F S M=$O(^TMP("IB-MRA-CNT",$J,I,J,K,L,M)) Q:M=""!(IBQUIT) D ;ar status
.....S N=0
.....F S N=$O(^TMP("IB-MRA-CNT",$J,I,J,K,L,M,N)) Q:N=""!(IBQUIT) S X=+$G(^(N)),Y=+$G(^(N,0)),Z=+$G(^(1)),ZZ=+$G(^(2)) D LINE ;ibstatus
;
;......;S P=0 ;alive
;......;F S P=$O(^TMP("IB-MRA-CNT",$J,I,J,K,L,M,N,P)) Q:P=""!(IBQUIT) S X=+$G(^(P)),Y=+$G(^(P,0)),Z=+$G(^(1)),ZZ=+$G(^(2)) D LINE
;
SORTQ I 'IBQUIT,$E(IOST,1,2)="C-",IBPRNT="S" W ! D PAUSE^VALM1 I $D(DIRUT) S IBQUIT=1
Q
;
SUBHDR ; -- print out sub headers
Q:$G(K)=""
I IOSL<($Y+6) D HDR(1) Q:IBQUIT
W !!,?10,"Insurance Company: ",$P($G(^DIC(36,+I,0)),"^")
W !,?15,"Calendar Year of Bill: ",J
W !,?20,"Type of Bill: ",K
Q
;
LINE ; -- Write one summary line
I IOSL<($Y+5) D HDR(1) Q:IBQUIT
W !,$E($P(M,"^",2),1,21),?23,$E($$EXTERNAL^DILFD(399,.13,"",N),1,14),?37,$J(+X,6),$$FORMAT(Y,"2$",17),$J(+Z,6),$$FORMAT(ZZ,"2$",14)
;
Q
;
ARSTAT(M) ; convert code to ar status
N IEN
S IEN=+$O(^PRCA(430.3,"AC",+M,0))
Q $P($G(^PRCA(430.3,IEN,0)),"^")
;
DETAIL ; -- do detail report
N I,J,K,L,M,N,P,IBIFN,IBXX
;
I '$D(^TMP("IB-MRA",$J)) W !!,"There are no detail records to print.",! G DETQ
;
S I=""
F S I=$O(^TMP("IB-MRA",$J,I)) Q:I=""!(IBQUIT) D ; ins. co.
.S J=""
.F S J=$O(^TMP("IB-MRA",$J,I,J)) Q:J=""!(IBQUIT) D ;year
..S K=""
..F S K=$O(^TMP("IB-MRA",$J,I,J,K)) Q:K=""!(IBQUIT) D ;type of bill
...D SUBHDR
...S L=""
...F S L=$O(^TMP("IB-MRA",$J,I,J,K,L)) Q:L=""!(IBQUIT) D ;proc
....S M=0
....F S M=$O(^TMP("IB-MRA",$J,I,J,K,L,M)) Q:M=""!(IBQUIT) D ;ar status
.....S N=0
.....F S N=$O(^TMP("IB-MRA",$J,I,J,K,L,M,N)) Q:N=""!(IBQUIT) D ;ibstatus
......;S P=0 ;alive
......;F S P=$O(^TMP("IB-MRA",$J,I,J,K,L,M,N,P)) Q:P=""!(IBQUIT) D
......S IBIFN=""
......F S IBIFN=$O(^TMP("IB-MRA",$J,I,J,K,L,M,N,IBIFN)) Q:IBIFN=""!(IBQUIT) S IBXX=^(IBIFN) D DLINE
;
DETQ I 'IBQUIT,$E(IOST,1,2)="C-" W ! D PAUSE^VALM1 I $D(DIRUT) S IBQUIT=1
Q
;
DLINE ; -- print one detail line
N I,J,K,L,M,N,DFN,ORGAMNT,TOTPAID,FROM,TO
I IOSL<($Y+5) D HDR(2) Q:IBQUIT
S DFN=+$P(IBXX,"^",2)
D DEM^VADPT
S ORGAMNT=+$G(^DGCR(399,IBIFN,"U1"))
S TOTPAID=$$TPR^PRCAFN(IBIFN)
W !,$P(IBXX,"^"),?12,$E(VADM(1),1,20),?34,VA("BID"),?42,VADM(4)
W ?48,$$FMTE^XLFDT(+$G(^DGCR(399,IBIFN,"U")),2)," - ",$$FMTE^XLFDT($P($G(^("U")),"^",2),2)
W ?70,$$FMTE^XLFDT($P($G(^DGCR(399,IBIFN,"S")),"^",12))
W ?82,$$FORMAT(ORGAMNT,"2$",17),$$FORMAT(TOTPAID,"2$",17)
K VA,VADM,VAERR
Q
;
HDR(L1) ; -- line item header
N X,Y,I,J,K,L,M,N,P,DIR,DIRUT,Z,ZZ
Q:$G(IBQUIT)
I $E(IOST,1,2)="C-",IBPAG D PAUSE^VALM1 I $D(DIRUT) S IBQUIT=1 Q
I $E(IOST,1,2)="C-"!(IBPAG) W @IOF
S IBPAG=IBPAG+1
W !,"Possible Medicare Remittance Advice Claims",?(IOM-33),"Page ",IBPAG," ",IBHDT
W !,$S(L1=2:"Detail Report",L1=1:"Summary Report",1:"Totals Report")
W:L1=2 !,"Bill No.",?12,"Patient Name",?34,"PT ID",?42,"Age",?48,"Bill From-To",?70,"Date Printed",?85,"Amount Billed",?100,"Amount Collected"
W:L1=1 !,?38,"Total",?53,"Amount",?62,"No.",?70,"Amount"
W:L1=1 !,"AR Status",?25,"IB Status",?38,"Number",?53,"Billed",?62,"Coll",?70,"Collected"
W:'L1 !,?38,"Total Amount No. Amount"
W:'L1 !,?38,"Number Billed Coll Collected"
W !,$TR($J(" ",IOM)," ","-")
Q
;
FORMAT(X,X2,X3) ; -- convert number to formatted number
; -- input x = number to be converted
; x2 = format characters (see doc for comma^%dtc)
; x3 = lenght of formated output (optional)
; output = formated character string
;
D COMMA^%DTC
Q X
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HIBCNSMR0 7873 printed Oct 16, 2024@18:18:19 Page 2
IBCNSMR0 ;ALB/AAS - MEDICARE BILLS ; 02-SEPT-97
+1 ;;2.0; INTEGRATED BILLING ;**92**; 21-MAR-94
+2 ;
% GOTO RPRT^IBCNSMRA
+1 QUIT
+2 ;
PRINT ;
+1 NEW IBQUIT,IBPAG,IBHDT
+2 SET IBQUIT=0
SET IBPAG=0
SET IBHDT=$$HTE^XLFDT($HOROLOG)
+3 IF IBPRNT="D"
USE IO
DO HDR(0)
DO TOTALS
if IBQUIT
QUIT
DO HDR(1)
DO SORT
if IBQUIT
QUIT
DO HDR(2)
DO DETAIL
if IBQUIT
QUIT
+4 IF IBPRNT="S"
USE IO
DO HDR(0)
DO TOTALS
if IBQUIT
QUIT
DO HDR(1)
DO SORT
+5 IF IBSNDRPT
DO BULL^IBCNSMR1
+6 QUIT
+7 ;
TOTALS ; -- prepare report
+1 WRITE !!," Bills Found for Selected Ins. Co.: "_$JUSTIFY(+$GET(CNT),6)_$$FORMAT(+$GET(CNT(0)),"2$",17)_$JUSTIFY(+$GET(CNT(1)),6)_$$FORMAT(+$GET(CNT(2)),"2$",14)
+2 WRITE !," Bills for Outpatient Visits: "_$JUSTIFY(+$GET(CNT("OP")),6)_$$FORMAT(+$GET(CNT("OP",0)),"2$",17)_$JUSTIFY(+$GET(CNT("OP",1)),6)_$$FORMAT(+$GET(CNT("OP",2)),"2$",14)
+3 WRITE !," Bills for Inpatient Visits: "_$JUSTIFY(+$GET(CNT("IN")),6)_$$FORMAT(+$GET(CNT("IN",0)),"2$",17)_$JUSTIFY(+$GET(CNT("IN",1)),6)_$$FORMAT(+$GET(CNT("IN",2)),"2$",14)
+4 ;
+5 WRITE !!," Subtotals by Selected Ins. Co.: "
+6 SET IBNM=""
+7 FOR
SET IBNM=$ORDER(CNT(3,IBNM))
if IBNM=""
QUIT
Begin DoDot:1
+8 WRITE !,?(35-$LENGTH(IBNM)),IBNM_": "_$JUSTIFY(+$GET(CNT(3,IBNM)),6)_$$FORMAT(+$GET(CNT(3,IBNM,0)),"2$",17)_$JUSTIFY(+$GET(CNT(3,IBNM,1)),6)_$$FORMAT(+$GET(CNT(3,IBNM,2)),"2$",14)
End DoDot:1
+9 ;
+10 WRITE !!,"Bills with Procedures and Diagnosis: "_$JUSTIFY(+$GET(CNT("B")),6)_$$FORMAT(+$GET(CNT("B",0)),"2$",17)_$JUSTIFY(+$GET(CNT("B",1)),6)_$$FORMAT(+$GET(CNT("B",2)),"2$",14)
+11 WRITE !," Bills with Diagnosis Codes Only: "_$JUSTIFY(+$GET(CNT("D")),6)_$$FORMAT(+$GET(CNT("D",0)),"2$",17)_$JUSTIFY(+$GET(CNT("D",1)),6)_$$FORMAT(+$GET(CNT("D",2)),"2$",14)
+12 WRITE !," Bills with Procedure Codes Only: "_$JUSTIFY(+$GET(CNT("P")),6)_$$FORMAT(+$GET(CNT("P",0)),"2$",17)_$JUSTIFY(+$GET(CNT("P",1)),6)_$$FORMAT(+$GET(CNT("P",2)),"2$",14)
+13 WRITE !," Bills with No Proc. or Diag. Codes: "_$JUSTIFY(+$GET(CNT("N")),6)_$$FORMAT(+$GET(CNT("N",0)),"2$",17)_$JUSTIFY(+$GET(CNT("N",1)),6)_$$FORMAT(+$GET(CNT("N",2)),"2$",14)
+14 ;
+15 WRITE !!," Bills Canceled before Completion: "_$JUSTIFY(+$GET(CNT("C")),6)_$$FORMAT(+$GET(CNT("C",0)),"2$",17)_$JUSTIFY(+$GET(CNT("C",1)),6)_$$FORMAT(+$GET(CNT("C",2)),"2$",14)
+16 WRITE !," Bills Never Printed: "_$JUSTIFY(+$GET(CNT("F")),6)_$$FORMAT(+$GET(CNT("F",0)),"2$",17)_$JUSTIFY(+$GET(CNT("F",1)),6)_$$FORMAT(+$GET(CNT("F",2)),"2$",14)
+17 WRITE !," Bills with wrong Rate Type: "_$JUSTIFY(+$GET(CNT("R")),6)_$$FORMAT(+$GET(CNT("R",0)),"2$",17)_$JUSTIFY(+$GET(CNT("R",1)),6)_$$FORMAT(+$GET(CNT("R",2)),"2$",14)
+18 WRITE !," Bills with wrong Who's Responsible: "_$JUSTIFY(+$GET(CNT("W")),6)_$$FORMAT(+$GET(CNT("W",0)),"2$",17)_$JUSTIFY(+$GET(CNT("W",1)),6)_$$FORMAT(+$GET(CNT("W",2)),"2$",14)
+19 WRITE !," Bills w/ wrong Bill Classification: "_$JUSTIFY(+$GET(CNT("T")),6)_$$FORMAT(+$GET(CNT("T",0)),"2$",17)_$JUSTIFY(+$GET(CNT("T",1)),6)_$$FORMAT(+$GET(CNT("T",2)),"2$",14)
+20 WRITE !," Bills for Prescriptions: "_$JUSTIFY(+$GET(CNT("X")),6)_$$FORMAT(+$GET(CNT("X",0)),"2$",17)_$JUSTIFY(+$GET(CNT("X",1)),6)_$$FORMAT(+$GET(CNT("X",2)),"2$",14)
+21 WRITE !," Bills for Prosthetics: "_$JUSTIFY(+$GET(CNT("Z")),6)_$$FORMAT(+$GET(CNT("Z",0)),"2$",17)_$JUSTIFY(+$GET(CNT("Z",1)),6)_$$FORMAT(+$GET(CNT("Z",2)),"2$",14)
+22 ;W !," Bills with Patients Not Alive: "_$J(+$G(CNT("A")),6)_$$FORMAT(+$G(CNT("A",0)),"2$",17)_$J(+$G(CNT("A",1)),6)_$$FORMAT(+$G(CNT("A",2)),"2$",14)
+23 ;
+24 WRITE !!," Bills Meeting Criteria for MRA: "_$JUSTIFY(+$GET(CNT("M")),6)_$$FORMAT(+$GET(CNT("M",0)),"2$",17)_$JUSTIFY(+$GET(CNT("M",1)),6)_$$FORMAT(+$GET(CNT("M",2)),"2$",14)
+25 WRITE !," Outpatient Bills Meeting Criteria: "_$JUSTIFY(+$GET(CNT("M","OP")),6)_$$FORMAT(+$GET(CNT("M","OP",0)),"2$",17)_$JUSTIFY(+$GET(CNT("M","OP",1)),6)_$$FORMAT(+$GET(CNT("M","OP",2)),"2$",14)
+26 WRITE !," Inpatient Bills Meeting Criteria: "_$JUSTIFY(+$GET(CNT("M","IN")),6)_$$FORMAT(+$GET(CNT("M","IN",0)),"2$",17)_$JUSTIFY(+$GET(CNT("M","IN",1)),6)_$$FORMAT(+$GET(CNT("M","IN",2)),"2$",14)
+27 WRITE !," Bill Meeting Criteria and Referred: "_$JUSTIFY(+$GET(CNT("M",4)),6)_$$FORMAT(+$GET(CNT("M",5)),"2$",17)_$JUSTIFY(+$GET(CNT("M",6)),6)_$$FORMAT(+$GET(CNT("M",7)),"2$",14)
+28 ;
+29 QUIT
+30 ;
SORT ; -- Run through list by insurance company
+1 NEW I,J,K,L,M,N,P,X,Y,Z,ZZ
+2 ;
+3 IF '$DATA(^TMP("IB-MRA-CNT",$JOB))
WRITE !!,"There are no summary records to print.",!
GOTO SORTQ
+4 ;
+5 SET I=0
+6 ;insur. co
FOR
SET I=$ORDER(^TMP("IB-MRA-CNT",$JOB,I))
if I=""!(IBQUIT)
QUIT
Begin DoDot:1
+7 SET J=0
+8 ;year
FOR
SET J=$ORDER(^TMP("IB-MRA-CNT",$JOB,I,J))
if J=""!(IBQUIT)
QUIT
Begin DoDot:2
+9 SET IBQUIT=$$STOP^IBCNSMR
if IBQUIT
QUIT
+10 SET K=""
+11 ;bill type
FOR
SET K=$ORDER(^TMP("IB-MRA-CNT",$JOB,I,J,K))
if K=""!(IBQUIT)
QUIT
Begin DoDot:3
+12 DO SUBHDR
+13 SET L=0
+14 ;proc
FOR
SET L=$ORDER(^TMP("IB-MRA-CNT",$JOB,I,J,K,L))
if L=""!(IBQUIT)
QUIT
Begin DoDot:4
+15 SET M=0
+16 ;ar status
FOR
SET M=$ORDER(^TMP("IB-MRA-CNT",$JOB,I,J,K,L,M))
if M=""!(IBQUIT)
QUIT
Begin DoDot:5
+17 SET N=0
+18 ;ibstatus
FOR
SET N=$ORDER(^TMP("IB-MRA-CNT",$JOB,I,J,K,L,M,N))
if N=""!(IBQUIT)
QUIT
SET X=+$GET(^(N))
SET Y=+$GET(^(N,0))
SET Z=+$GET(^(1))
SET ZZ=+$GET(^(2))
DO LINE
End DoDot:5
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+19 ;
+20 ;......;S P=0 ;alive
+21 ;......;F S P=$O(^TMP("IB-MRA-CNT",$J,I,J,K,L,M,N,P)) Q:P=""!(IBQUIT) S X=+$G(^(P)),Y=+$G(^(P,0)),Z=+$G(^(1)),ZZ=+$G(^(2)) D LINE
+22 ;
SORTQ IF 'IBQUIT
IF $EXTRACT(IOST,1,2)="C-"
IF IBPRNT="S"
WRITE !
DO PAUSE^VALM1
IF $DATA(DIRUT)
SET IBQUIT=1
+1 QUIT
+2 ;
SUBHDR ; -- print out sub headers
+1 if $GET(K)=""
QUIT
+2 IF IOSL<($Y+6)
DO HDR(1)
if IBQUIT
QUIT
+3 WRITE !!,?10,"Insurance Company: ",$PIECE($GET(^DIC(36,+I,0)),"^")
+4 WRITE !,?15,"Calendar Year of Bill: ",J
+5 WRITE !,?20,"Type of Bill: ",K
+6 QUIT
+7 ;
LINE ; -- Write one summary line
+1 IF IOSL<($Y+5)
DO HDR(1)
if IBQUIT
QUIT
+2 WRITE !,$EXTRACT($PIECE(M,"^",2),1,21),?23,$EXTRACT($$EXTERNAL^DILFD(399,.13,"",N),1,14),?37,$JUSTIFY(+X,6),$$FORMAT(Y,"2$",17),$JUSTIFY(+Z,6),$$FORMAT(ZZ,"2$",14)
+3 ;
+4 QUIT
+5 ;
ARSTAT(M) ; convert code to ar status
+1 NEW IEN
+2 SET IEN=+$ORDER(^PRCA(430.3,"AC",+M,0))
+3 QUIT $PIECE($GET(^PRCA(430.3,IEN,0)),"^")
+4 ;
DETAIL ; -- do detail report
+1 NEW I,J,K,L,M,N,P,IBIFN,IBXX
+2 ;
+3 IF '$DATA(^TMP("IB-MRA",$JOB))
WRITE !!,"There are no detail records to print.",!
GOTO DETQ
+4 ;
+5 SET I=""
+6 ; ins. co.
FOR
SET I=$ORDER(^TMP("IB-MRA",$JOB,I))
if I=""!(IBQUIT)
QUIT
Begin DoDot:1
+7 SET J=""
+8 ;year
FOR
SET J=$ORDER(^TMP("IB-MRA",$JOB,I,J))
if J=""!(IBQUIT)
QUIT
Begin DoDot:2
+9 SET K=""
+10 ;type of bill
FOR
SET K=$ORDER(^TMP("IB-MRA",$JOB,I,J,K))
if K=""!(IBQUIT)
QUIT
Begin DoDot:3
+11 DO SUBHDR
+12 SET L=""
+13 ;proc
FOR
SET L=$ORDER(^TMP("IB-MRA",$JOB,I,J,K,L))
if L=""!(IBQUIT)
QUIT
Begin DoDot:4
+14 SET M=0
+15 ;ar status
FOR
SET M=$ORDER(^TMP("IB-MRA",$JOB,I,J,K,L,M))
if M=""!(IBQUIT)
QUIT
Begin DoDot:5
+16 SET N=0
+17 ;ibstatus
FOR
SET N=$ORDER(^TMP("IB-MRA",$JOB,I,J,K,L,M,N))
if N=""!(IBQUIT)
QUIT
Begin DoDot:6
+18 ;S P=0 ;alive
+19 ;F S P=$O(^TMP("IB-MRA",$J,I,J,K,L,M,N,P)) Q:P=""!(IBQUIT) D
+20 SET IBIFN=""
+21 FOR
SET IBIFN=$ORDER(^TMP("IB-MRA",$JOB,I,J,K,L,M,N,IBIFN))
if IBIFN=""!(IBQUIT)
QUIT
SET IBXX=^(IBIFN)
DO DLINE
End DoDot:6
End DoDot:5
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+22 ;
DETQ IF 'IBQUIT
IF $EXTRACT(IOST,1,2)="C-"
WRITE !
DO PAUSE^VALM1
IF $DATA(DIRUT)
SET IBQUIT=1
+1 QUIT
+2 ;
DLINE ; -- print one detail line
+1 NEW I,J,K,L,M,N,DFN,ORGAMNT,TOTPAID,FROM,TO
+2 IF IOSL<($Y+5)
DO HDR(2)
if IBQUIT
QUIT
+3 SET DFN=+$PIECE(IBXX,"^",2)
+4 DO DEM^VADPT
+5 SET ORGAMNT=+$GET(^DGCR(399,IBIFN,"U1"))
+6 SET TOTPAID=$$TPR^PRCAFN(IBIFN)
+7 WRITE !,$PIECE(IBXX,"^"),?12,$EXTRACT(VADM(1),1,20),?34,VA("BID"),?42,VADM(4)
+8 WRITE ?48,$$FMTE^XLFDT(+$GET(^DGCR(399,IBIFN,"U")),2)," - ",$$FMTE^XLFDT($PIECE($GET(^("U")),"^",2),2)
+9 WRITE ?70,$$FMTE^XLFDT($PIECE($GET(^DGCR(399,IBIFN,"S")),"^",12))
+10 WRITE ?82,$$FORMAT(ORGAMNT,"2$",17),$$FORMAT(TOTPAID,"2$",17)
+11 KILL VA,VADM,VAERR
+12 QUIT
+13 ;
HDR(L1) ; -- line item header
+1 NEW X,Y,I,J,K,L,M,N,P,DIR,DIRUT,Z,ZZ
+2 if $GET(IBQUIT)
QUIT
+3 IF $EXTRACT(IOST,1,2)="C-"
IF IBPAG
DO PAUSE^VALM1
IF $DATA(DIRUT)
SET IBQUIT=1
QUIT
+4 IF $EXTRACT(IOST,1,2)="C-"!(IBPAG)
WRITE @IOF
+5 SET IBPAG=IBPAG+1
+6 WRITE !,"Possible Medicare Remittance Advice Claims",?(IOM-33),"Page ",IBPAG," ",IBHDT
+7 WRITE !,$SELECT(L1=2:"Detail Report",L1=1:"Summary Report",1:"Totals Report")
+8 if L1=2
WRITE !,"Bill No.",?12,"Patient Name",?34,"PT ID",?42,"Age",?48,"Bill From-To",?70,"Date Printed",?85,"Amount Billed",?100,"Amount Collected"
+9 if L1=1
WRITE !,?38,"Total",?53,"Amount",?62,"No.",?70,"Amount"
+10 if L1=1
WRITE !,"AR Status",?25,"IB Status",?38,"Number",?53,"Billed",?62,"Coll",?70,"Collected"
+11 if 'L1
WRITE !,?38,"Total Amount No. Amount"
+12 if 'L1
WRITE !,?38,"Number Billed Coll Collected"
+13 WRITE !,$TRANSLATE($JUSTIFY(" ",IOM)," ","-")
+14 QUIT
+15 ;
FORMAT(X,X2,X3) ; -- convert number to formatted number
+1 ; -- input x = number to be converted
+2 ; x2 = format characters (see doc for comma^%dtc)
+3 ; x3 = lenght of formated output (optional)
+4 ; output = formated character string
+5 ;
+6 DO COMMA^%DTC
+7 QUIT X