IBCNSMRA ;ALB/AAS - MEDICARE BILLS ; 02-SEPT-97
 ;;2.0; INTEGRATED BILLING ;**92**; 21-MAR-94
 ;
RPRT ; -- Create list of all bills for an insurance company
 ;    by year, by inpatient/outpatient, by w/wo procs and dia, 
 ;    by IB Status, by leaving and dead patients.
 ;
 ;    store in ^tmp("ib-mra",$j, ins co, calendar year of care, inpt/opt,
 ;                  w/wo proc and diag, ar status, ib status, 
 ;                  leaving/dead,entry in 399) := bill no ^ dfn ^
 ;
 ; -- cnt      := no. bills checked
 ;    ;cnt("a") := no. patients alive ; Not used per group
 ;    cnt("b") := no. bills with both procedure and diagnosis
 ;    cnt("c") := no. bills canceled before completion
 ;    cnt("d") := no. bills w/ diagnosis
 ;    cnt("f") := no. bills never printed
 ;    cnt("p") := no. bills w/ procedures
 ;    cnt("m") := no. bills meeting criteria
 ;    cnt("n") := no. bills w/ no diag no proc (neither)
 ;    cnt("r") := no. bills w/ rate type not billable to medicare
 ;    cnt("t") := no. bills w/ bill class. (type of bill) = 2 or 4
 ;    cnt("w") := no. bills who's responsible not = "i"
 ;    cnt("x") := no. bills for RX
 ;    cnt("z") := no. bills for prosthetics
 ;    cnt( ,0) := total dollar amount of bills
 ;    cnt( ,1) := no. bills with paid principal
 ;    cnt( ,2) := Total dollar amount of payments received
 ;    cnt(m,4) := no. bills meeting criteria and referred to dc
 ;    cnt(m,5) := Total $$ of bills criteria and referred to dc
 ;    cnt(m,6) := no. bills meeting criteria with $$ and referred to dc
 ;    cnt(m,7) := Total payment $$ bills meeting criteria and refer to dc
 ;    cnt(3,   := insurance company specific data, follows above format
 ;    cnt("in" := totals for inpatients
 ;    cnt("op" := totals for outpatients
 ;
 D HOME^%ZIS
 I '$D(DT) D DT^DICRW
 S IBQUIT=0
 ;
 W !!,"Build statistics on Insurance Companies that are withholding Medicare",!,"Supplemental Policy Payments.",!!
 ;
 I '$O(^IBE(350.9,1,99,0)) W !!,"You must enter the list of Insurance Companies Withholding Supplimental Payments first",!! D BLD1^IBCNSMRE
 I '$O(^IBE(350.9,1,99,0)) G END
 ;
 D ASKRPRT I IBQUIT G END
 D ASKPRNT I IBQUIT G END
 I IBPRNT="N",IBSNDRPT=0 W !!,"You didn't select anything to do!  Try again.",!! G END
 ;
QUE ; -- que compilation to run
 I IBPRNT="N",IBSNDRPT D  G Q
 .W !!,"This will automatically be tasked to run.  A mail message containing",!,"the data will be sent to you.",!
 .S ZTIO="",IO("Q")=1
 ;
Q I $D(IO("Q")) D
 .S ZTDESC="IB-Compile MRA statistics",ZTRTN="DQ^IBCNSMR",ZTSAVE("IB*")=""
 .D ^%ZTLOAD
 I '$D(ZTSK) D DQ^IBCNSMR
 K ZTSK,ZTIO,ZTDESC,ZTRTN,ZTSAVE,IO("Q")
 G END
 Q
 ;
END ; -- end of program
 K ^TMP("IB-MRA",$J),^TMP("IB-MRA-CNT",$J)
 I $D(ZTQUEUED),'IBQUIT S ZTREQ="@"
 Q:$D(ZTQUEUED)
 K C,I,J,POP,X,Y,ZTSK,ZTSAVE,ZTDESC,ZTRTN,IBPRNT,IBSNDRPT,IBQUIT
 D ^%ZISC
 Q
 ;
ASKPRNT ; -- should a report be printed, summary, detail, none
 N %ZIS,DIR,DIRUT,DUOUT,DTOUT,X,Y
 W !
 S DIR("A")="Print Report, [S]ummary, [D]etail, [None]: "
 S DIR("?")="Select whether you want to print a summary report, a detail report, or No report.  A detail report will list every claim.  No report will automatically send data for national rollup."
 S DIR(0)="SMA^S:Summary;D:Detail;N:None"
 S DIR("B")="Summary"
 D ^DIR
 S IBPRNT=Y
 I $D(DIRUT) S IBQUIT=1 Q
 I IBPRNT'="N" D
 .S %ZIS="QM" D ^%ZIS I POP S IBQUIT=1
 Q
 ;
ASKRPRT ; -- should a report be sent to the ISC
 N DIR,DIRUT,DUOUT,DTOUT,X,Y
 S DIR("A")="Send Data for National Rollup"
 S DIR("?")="Answer 'Yes' if you wish to send a report for national rollup purposes or answer 'No' if you just want to print a report."
 S DIR(0)="Y"
 S DIR("B")="NO"
 D ^DIR
 I $D(DIRUT) S IBQUIT=1
 S IBSNDRPT=Y
 Q
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HIBCNSMRA   3804     printed  Sep 23, 2025@19:53:59                                                                                                                                                                                                    Page 2
IBCNSMRA  ;ALB/AAS - MEDICARE BILLS ; 02-SEPT-97
 +1       ;;2.0; INTEGRATED BILLING ;**92**; 21-MAR-94
 +2       ;
RPRT      ; -- Create list of all bills for an insurance company
 +1       ;    by year, by inpatient/outpatient, by w/wo procs and dia, 
 +2       ;    by IB Status, by leaving and dead patients.
 +3       ;
 +4       ;    store in ^tmp("ib-mra",$j, ins co, calendar year of care, inpt/opt,
 +5       ;                  w/wo proc and diag, ar status, ib status, 
 +6       ;                  leaving/dead,entry in 399) := bill no ^ dfn ^
 +7       ;
 +8       ; -- cnt      := no. bills checked
 +9       ;    ;cnt("a") := no. patients alive ; Not used per group
 +10      ;    cnt("b") := no. bills with both procedure and diagnosis
 +11      ;    cnt("c") := no. bills canceled before completion
 +12      ;    cnt("d") := no. bills w/ diagnosis
 +13      ;    cnt("f") := no. bills never printed
 +14      ;    cnt("p") := no. bills w/ procedures
 +15      ;    cnt("m") := no. bills meeting criteria
 +16      ;    cnt("n") := no. bills w/ no diag no proc (neither)
 +17      ;    cnt("r") := no. bills w/ rate type not billable to medicare
 +18      ;    cnt("t") := no. bills w/ bill class. (type of bill) = 2 or 4
 +19      ;    cnt("w") := no. bills who's responsible not = "i"
 +20      ;    cnt("x") := no. bills for RX
 +21      ;    cnt("z") := no. bills for prosthetics
 +22      ;    cnt( ,0) := total dollar amount of bills
 +23      ;    cnt( ,1) := no. bills with paid principal
 +24      ;    cnt( ,2) := Total dollar amount of payments received
 +25      ;    cnt(m,4) := no. bills meeting criteria and referred to dc
 +26      ;    cnt(m,5) := Total $$ of bills criteria and referred to dc
 +27      ;    cnt(m,6) := no. bills meeting criteria with $$ and referred to dc
 +28      ;    cnt(m,7) := Total payment $$ bills meeting criteria and refer to dc
 +29      ;    cnt(3,   := insurance company specific data, follows above format
 +30      ;    cnt("in" := totals for inpatients
 +31      ;    cnt("op" := totals for outpatients
 +32      ;
 +33       DO HOME^%ZIS
 +34       IF '$DATA(DT)
               DO DT^DICRW
 +35       SET IBQUIT=0
 +36      ;
 +37       WRITE !!,"Build statistics on Insurance Companies that are withholding Medicare",!,"Supplemental Policy Payments.",!!
 +38      ;
 +39       IF '$ORDER(^IBE(350.9,1,99,0))
               WRITE !!,"You must enter the list of Insurance Companies Withholding Supplimental Payments first",!!
               DO BLD1^IBCNSMRE
 +40       IF '$ORDER(^IBE(350.9,1,99,0))
               GOTO END
 +41      ;
 +42       DO ASKRPRT
           IF IBQUIT
               GOTO END
 +43       DO ASKPRNT
           IF IBQUIT
               GOTO END
 +44       IF IBPRNT="N"
               IF IBSNDRPT=0
                   WRITE !!,"You didn't select anything to do!  Try again.",!!
                   GOTO END
 +45      ;
QUE       ; -- que compilation to run
 +1        IF IBPRNT="N"
               IF IBSNDRPT
                   Begin DoDot:1
 +2                    WRITE !!,"This will automatically be tasked to run.  A mail message containing",!,"the data will be sent to you.",!
 +3                    SET ZTIO=""
                       SET IO("Q")=1
                   End DoDot:1
                   GOTO Q
 +4       ;
Q          IF $DATA(IO("Q"))
               Begin DoDot:1
 +1                SET ZTDESC="IB-Compile MRA statistics"
                   SET ZTRTN="DQ^IBCNSMR"
                   SET ZTSAVE("IB*")=""
 +2                DO ^%ZTLOAD
               End DoDot:1
 +3        IF '$DATA(ZTSK)
               DO DQ^IBCNSMR
 +4        KILL ZTSK,ZTIO,ZTDESC,ZTRTN,ZTSAVE,IO("Q")
 +5        GOTO END
 +6        QUIT 
 +7       ;
END       ; -- end of program
 +1        KILL ^TMP("IB-MRA",$JOB),^TMP("IB-MRA-CNT",$JOB)
 +2        IF $DATA(ZTQUEUED)
               IF 'IBQUIT
                   SET ZTREQ="@"
 +3        if $DATA(ZTQUEUED)
               QUIT 
 +4        KILL C,I,J,POP,X,Y,ZTSK,ZTSAVE,ZTDESC,ZTRTN,IBPRNT,IBSNDRPT,IBQUIT
 +5        DO ^%ZISC
 +6        QUIT 
 +7       ;
ASKPRNT   ; -- should a report be printed, summary, detail, none
 +1        NEW %ZIS,DIR,DIRUT,DUOUT,DTOUT,X,Y
 +2        WRITE !
 +3        SET DIR("A")="Print Report, [S]ummary, [D]etail, [None]: "
 +4        SET DIR("?")="Select whether you want to print a summary report, a detail report, or No report.  A detail report will list every claim.  No report will automatically send data for national rollup."
 +5        SET DIR(0)="SMA^S:Summary;D:Detail;N:None"
 +6        SET DIR("B")="Summary"
 +7        DO ^DIR
 +8        SET IBPRNT=Y
 +9        IF $DATA(DIRUT)
               SET IBQUIT=1
               QUIT 
 +10       IF IBPRNT'="N"
               Begin DoDot:1
 +11               SET %ZIS="QM"
                   DO ^%ZIS
                   IF POP
                       SET IBQUIT=1
               End DoDot:1
 +12       QUIT 
 +13      ;
ASKRPRT   ; -- should a report be sent to the ISC
 +1        NEW DIR,DIRUT,DUOUT,DTOUT,X,Y
 +2        SET DIR("A")="Send Data for National Rollup"
 +3        SET DIR("?")="Answer 'Yes' if you wish to send a report for national rollup purposes or answer 'No' if you just want to print a report."
 +4        SET DIR(0)="Y"
 +5        SET DIR("B")="NO"
 +6        DO ^DIR
 +7        IF $DATA(DIRUT)
               SET IBQUIT=1
 +8        SET IBSNDRPT=Y
 +9        QUIT