Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: IBCORC1

IBCORC1.m

Go to the documentation of this file.
  1. IBCORC1 ;ALB/CPM - RANK INSURANCE CARRIERS (COMPILE/PRINT) ; 30-JUN-93
  1. ;;2.0;INTEGRATED BILLING;**29,47,68,80**;21-MAR-94
  1. ;
  1. DQ ; Tasked entry point to generate and print the rankings.
  1. ;
  1. ; - look at all insurance bills within date range and accumulate $$
  1. K ^TMP("IBORIC",$J,"IC"),^("IC1"),^("AMT"),^("NUM")
  1. S IBDT=$$START(IBABEG,-1)
  1. F S IBDT=$O(^DGCR(399,"AP",IBDT)) Q:'IBDT!(IBDT>IBAEND) D
  1. .S IBN=0 F S IBN=$O(^DGCR(399,"AP",IBDT,IBN)) Q:'IBN D EVAL
  1. ;
  1. ; - if executed by IRM, generate the formatted bulletin and quit
  1. I $G(IBIRM) D BULL^IBCORC3 G ENQ
  1. ;
  1. ; - invert the list by carrier to rank by amount billed
  1. S IBINS=0 F S IBINS=$O(^TMP("IBORIC",$J,"IC",IBINS)) Q:'IBINS S ^TMP("IBORIC",$J,"AMT",-$G(^(IBINS)),IBINS)=""
  1. ;
  1. ; - print out the ranking list
  1. S IBAMT="",(IBQ,IBCNT,IBPAG,IBTAMT)=0 D HDR
  1. F S IBAMT=$O(^TMP("IBORIC",$J,"AMT",IBAMT)) Q:IBAMT=""!(IBQ)!(IBCNT>IBNR) D
  1. .S IBINS=0 F S IBINS=$O(^TMP("IBORIC",$J,"AMT",IBAMT,IBINS)) Q:'IBINS!(IBQ)!(IBCNT>IBNR) D
  1. ..S IBCNT=IBCNT+1 Q:IBCNT>IBNR
  1. ..S IBAMTP=-IBAMT,IBTAMT=IBTAMT+IBAMTP
  1. ..S IBINS0=$G(^DIC(36,IBINS,0)),IBINSA=$G(^(.11))
  1. ..I $Y>(IOSL-8) D PAUSE Q:IBQ D HDR
  1. ..W !!,$J(IBCNT,4),"." W:$P(IBINS0,"^",5) ?16,"**"
  1. ..W ?20,$S($P(IBINS0,"^")]"":$P(IBINS0,"^"),1:"CARRIER UNKNOWN")
  1. ..S X=IBAMTP,X2="2$",X3=15 D COMMA^%DTC W ?55,X
  1. ..D INSDIS(IBINSA)
  1. G:IBQ ENQ
  1. ;
  1. ; - print a total
  1. I $Y>(IOSL-4) D PAUSE G:IBQ ENQ D HDR
  1. W !!,"Total Amount Billed to all Ranked Carriers:" S X=IBTAMT,X2="2$",X3=15 D COMMA^%DTC W ?55,X
  1. D PAUSE
  1. ;I IBFLG W !!,"Sending the report in a bulletin to the MCCR Program Office... " D BULL^IBCORC2 W "done."
  1. ;
  1. ENQ K ^TMP("IBORIC",$J,"IC"),^("IC1"),^("AMT"),^("NUM")
  1. I $D(ZTQUEUED) S ZTREQ="@" Q
  1. D ^%ZISC
  1. K DIR,DIRUT,DUOUT,DTOUT,DIROUT,IBAMT,IBAMTP,IBI,IBINS0,IBINSA
  1. K IBQ,IBPAG,IBNR,IBCNT,IBDT,IBND,IBINS,IBN,IBTAMT,X,X1,X2,X3,Y
  1. ENQ1 Q
  1. ;
  1. EVAL ; Accumulate amount billed for the carrier if the bill type is correct.
  1. F IBI=0,"M","S","MP" S IBND(IBI)=$G(^DGCR(399,IBN,IBI))
  1. I IBND(0)="" G EVALQ ; no zeroth node
  1. I $P(IBND(0),"^",11)'="i" G EVALQ ; insurer not responsible
  1. S IBINS=+IBND("MP") I 'IBINS G EVALQ ; no carrier associated with bill
  1. I $P(IBND("S"),"^",16) G EVALQ ; bill has been cancelled
  1. S IBAMT=+$$ORI^PRCAFN(IBN) I IBAMT'>0 G EVALQ ; no bill amount
  1. S IBINS=$$INACT(IBINS) ; see if company has been repointed
  1. S ^(IBINS)=$G(^TMP("IBORIC",$J,"IC",IBINS))+IBAMT
  1. I $G(IBIRM) S ^(IBINS)=$G(^TMP("IBORIC",$J,"IC1",IBINS))+1
  1. EVALQ Q
  1. ;
  1. PAUSE ; Pause for screen output.
  1. Q:$E(IOST,1,2)'="C-"
  1. N IBI,DIR,DIRUT,DIROUT,DUOUT,DTOUT
  1. F IBI=$Y:1:(IOSL-3) W !
  1. S DIR(0)="E" D ^DIR I $D(DIRUT)!($D(DUOUT)) S IBQ=1
  1. Q
  1. ;
  1. HDR ; Display report header.
  1. N X,Y
  1. S X="Ranking Of The Top "_IBNR_" Insurance Carriers By Total Amount Billed"
  1. S Y=$$SITE^VASITE
  1. I $E(IOST,1,2)="C-"!(IBPAG) W @IOF,*13
  1. S IBPAG=IBPAG+1
  1. W ?(80-$L(X)\2),X,!
  1. W !," Facility: ",$P(Y,"^",2)," (",$P(Y,"^",3),")",?58,"Run Date: ",$$DAT1^IBOUTL(DT)
  1. W !,"Date Range: ",$$DAT1^IBOUTL(IBABEG)," thru ",$$DAT1^IBOUTL(IBAEND),?62,"Page: ",IBPAG
  1. W !?45,"** - denotes an inactive company"
  1. W !,$$DASH,!?2,"Rank",?20,"Insurance Carrier",?55,"Total Amt Billed",!,$$DASH
  1. Q
  1. ;
  1. DASH() ; Write dashed line.
  1. Q $TR($J("",79)," ","=")
  1. ;
  1. INSDIS(X) ; Display Insurance Company name and address.
  1. ; Input: X -- .11 node of ins company entry in file #36
  1. W:$P(X,"^")]"" !?20,$P(X,"^")
  1. W:$P(X,"^",2)]"" !?20,$P(X,"^",2)
  1. W:$P(X,"^",3)]"" !?20,$P(X,"^",3)
  1. W:$P(X,"^")]""!($P(X,"^",2)]"")!($P(X,"^",3)]"") !?20
  1. W $P(X,"^",4) W:$P(X,"^",4)]""&($P(X,"^",5)]"") ", "
  1. W $P($G(^DIC(5,+$P(X,"^",5),0)),"^")
  1. W:$P(X,"^",6)]""&($P(X,"^",4)]""!($P(X,"^",5)]"")) " "
  1. W $P(X,"^",6)
  1. Q
  1. ;
  1. START(X1,X2) ; Return the Start Date for the search, less one day.
  1. N X,%H D C^%DTC
  1. Q X
  1. ;
  1. INACT(CN) ; Determine the repointed-to company for inactivated companies.
  1. ; Input: CN -- Pointer to the ins company in file #36
  1. ; Output: The repointed-to company, if inactivated (or the same)
  1. N X,Y,Z S X=+$G(CN)
  1. F S Y=$G(^DIC(36,X,0)) Q:'$P(Y,"^",5)!('$P(Y,"^",16))!($P(Y,"^",16)=X)!($D(Z(+$P(Y,"^",16)))) S X=$P(Y,"^",16),Z(X)=""
  1. Q X
  1. ;
  1. DEL ; Delete "REPOINT PATIENTS TO" field
  1. N C1,C2,DA,DIR
  1. W !,"The routine will delete the REPOINT PATIENTS TO field of the entry"
  1. W !,"in the INSURANCE COMPANY file (#36) if the field entry is pointing"
  1. W !,"back to itself (same IEN).",!
  1. S DIR(0)="YO",DIR("A")="Are you sure you want to do this",DIR("B")="NO" D ^DIR Q:+Y=0 W !!,"A dot (.) will appear for every 50 records processed.",!
  1. S (C1,C2,DA)=0 F S DA=$O(^DIC(36,DA)) Q:+DA=0 I $P($G(^DIC(36,DA,0)),U,16)=DA S $P(^DIC(36,DA,0),U,16)="",C1=C1+1,C2=C2+1 I C1=50 W "." S C1=0
  1. W !,*7,"Done...",C2," records changed." Q