IBTUBAV ;ALB/AAS - UNBILLED AMOUNTS - AVERAGE BILL AMOUNT LOGIC ; 29-SEP-94 ;;2.0;INTEGRATED BILLING;**19,123**;21-MAR-94 ;;Per VHA Directive 10-93-142, this routine should not be modified. ; % ; - Entry point for manual option. I '$D(DT) D DT^DICRW W ! ; DATE ; - Select date. W ! D DT2^IBTUBOU("Average Bill Amounts") G:IBTIMON="^" END ; DEV ; - Select device. W !!,"This will automatically be tasked to run and needs no device." W !!,"A mail Message will be sent when the process completes." W !,"Use the option View Unbilled Amounts to see cumulative totals.",!! S ZTRTN="DQ^IBTUBAV",ZTSAVE("IB*")="",ZTIO="" S ZTDESC="IB - Generate Avg. Bill Amounts for a Month" D ^%ZTLOAD K IO("Q"),ZTSK D HOME^%ZIS G END ; AUTO ; - Entry point for scheduled option (update monthly number of bills ; and prior 12 months fields). ; S IBCOMP=1 ; This will cause the mail msg to be sent to all the users ; on the Unbilled Amounts mail group (see SEND^IBTUBUL). ; DQ ; - Entry point for user options when queued. K ^TMP($J,"IBTUBAV"),^TMP($J,"IBTUBAV1") ; ; - If no IBTIMON or in the future, sets it with current Month I '$G(IBTIMON)!($G(IBTIMON)>(DT\100*100)) S IBTIMON=DT\100*100 ; ; - Sets IBGMON with the 1st month 1 year prior to IBTIMON S IBGMON=IBTIMON-10000 ; ; AUG/1993 should be the first month in the Unbilled Amounts File I IBGMON>2930800,'$D(^IBE(356.19,2930800,0)) D . S IBGMON=2930800 ; ; - Calculate/Store the Unbilled Amounts Data for the past 12 months ; (Prior to IBTIMON, does NOT include IBTIMON) F Q:IBGMON'QUIT I '$G(IBOVRW),$P($G(^IBE(356.19,IBYRMO,1)),"^",13)'="" Q ; S BGDT=IBYRMO+1,ENDT=IBYRMO+32 ; ; - Initialize the IBAVG array (set at line tag INPT) F X="I","P" S (IBAVG("$AMNT-"_X),IBAVG("BILLS-"_X),IBAVG("EPISD-"_X))=0 ; ; - Loop through date entered x-ref starting a year prior to the period S IBDT=BGDT-10000 F S IBDT=$O(^DGCR(399,"APD",IBDT)) Q:'IBDT!(IBDT>ENDT) D . S IBDA=0 F S IBDA=$O(^DGCR(399,"APD",IBDT,IBDA)) Q:'IBDA D . . S IBNOD=$G(^DGCR(399,+IBDA,0)) . . I $P(IBNOD,U,11)'="i" Q ; Not reimbursable insurance bill . . S X=$P(IBNOD,U,13) Q:X<3!(X>6) ; Status not authorized or printed . . S X=$P($G(^DGCR(399,+IBDA,"S")),U,10) . . I X=""!(XENDT) Q ; Date authorized must be in period . . I $P(IBNOD,U,5)<3 D INPT ; ; - Updates file #356.19 with MONTHLY totals (Inpatient) S IBAVG("$AMNT-I")=$J(IBAVG("$AMNT-I"),0,2) S IBAVG("$AMNT-P")=$J(IBAVG("$AMNT-P"),0,2) D LD^IBTUBOU(1,IBYRMO) S ^TMP($J,"IBTUBAV",IBYRMO)="" ; K ^TMP($J,"IBTUBAV2") Q ; INPT ; - For inpatient bills (add count of bills/total dollars). S IBDFN=$P(IBNOD,U,2,3),IBAMT=+$G(^DGCR(399,IBDA,"U1")) I $P(IBNOD,U,27)=1!($P(IBNOD,U,19)=3) D G INP1 . S IBAVG("BILLS-I")=IBAVG("BILLS-I")+1 . S IBAVG("$AMNT-I")=IBAVG("$AMNT-I")+IBAMT . S IBDFN=IBDFN_"^I" ; I $P(IBNOD,U,27)=2!($P(IBNOD,U,19)=2) D G INP1 . S IBAVG("BILLS-P")=IBAVG("BILLS-P")+1 . S IBAVG("$AMNT-P")=IBAVG("$AMNT-P")+IBAMT . S IBDFN=IBDFN_"^P" ; G INPQ ; INP1 ; - Add number of inpatient episodes. I '$D(^TMP($J,"IBTUBAV2",IBDFN)) D . S Y=$P(IBDFN,U,3),IBAVG("EPISD-"_Y)=IBAVG("EPISD-"_Y)+1 . S ^TMP($J,"IBTUBAV2",IBDFN)="" ; INPQ Q ; YEAR(IBYRMO,IBOVRW) ; - Calculate YEARLY totals, and store if necessary ; - Input: IBYRMO - YEAR/MONTH (YYYMM00) being calculated/updated ; IBOVRW - Overwrite the data currently on file? (1-YES/0-NO) ; N IBAVG,IBTMON,IBGMON,IBTNMON,DA,DIC,DIE,DR,SUBCNT,I,X I IBYRMO>(DT\100*100) G YEARQ ; Don't compile for future months. ; ; - If YEARLY Average has already been calculated -> QUIT I '$G(IBOVRW),$P($G(^IBE(356.19,IBYRMO,1)),"^",14)'="" Q ; ; - Initialize the array IBAVG for Institutional and Professional F X="I","P" D . S (IBAVG("$AMNT-"_X),IBAVG("BILLS-"_X),IBAVG("EPISD-"_X))=0 ; ; Sets IBGMON with the 1st day of month 1 year prior to IBYRMO S IBGMON=IBYRMO-9999,SUBCNT=0 F I=1:1:12 S IBTMON=IBGMON\100*100 Q:IBTMON'0 S IBADD=1 L -^IBE(356.19,IBYRMO) ; ADDQ Q IBADD