source: WorldVistAEHR/trunk/r/INTEGRATED_BILLING-IB-PRQ--IBD--IBQ--PRQS/IBCORC1.m@ 1261

Last change on this file since 1261 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 4.6 KB
RevLine 
[613]1IBCORC1 ;ALB/CPM - RANK INSURANCE CARRIERS (COMPILE/PRINT) ; 30-JUN-93
2 ;;2.0;INTEGRATED BILLING;**29,47,68,80**;21-MAR-94
3 ;
4DQ ; Tasked entry point to generate and print the rankings.
5 ;
6 ; - look at all insurance bills within date range and accumulate $$
7 K ^TMP("IBORIC",$J,"IC"),^("IC1"),^("AMT"),^("NUM")
8 S IBDT=$$START(IBABEG,-1)
9 F S IBDT=$O(^DGCR(399,"AP",IBDT)) Q:'IBDT!(IBDT>IBAEND) D
10 .S IBN=0 F S IBN=$O(^DGCR(399,"AP",IBDT,IBN)) Q:'IBN D EVAL
11 ;
12 ; - if executed by IRM, generate the formatted bulletin and quit
13 I $G(IBIRM) D BULL^IBCORC3 G ENQ
14 ;
15 ; - invert the list by carrier to rank by amount billed
16 S IBINS=0 F S IBINS=$O(^TMP("IBORIC",$J,"IC",IBINS)) Q:'IBINS S ^TMP("IBORIC",$J,"AMT",-$G(^(IBINS)),IBINS)=""
17 ;
18 ; - print out the ranking list
19 S IBAMT="",(IBQ,IBCNT,IBPAG,IBTAMT)=0 D HDR
20 F S IBAMT=$O(^TMP("IBORIC",$J,"AMT",IBAMT)) Q:IBAMT=""!(IBQ)!(IBCNT>IBNR) D
21 .S IBINS=0 F S IBINS=$O(^TMP("IBORIC",$J,"AMT",IBAMT,IBINS)) Q:'IBINS!(IBQ)!(IBCNT>IBNR) D
22 ..S IBCNT=IBCNT+1 Q:IBCNT>IBNR
23 ..S IBAMTP=-IBAMT,IBTAMT=IBTAMT+IBAMTP
24 ..S IBINS0=$G(^DIC(36,IBINS,0)),IBINSA=$G(^(.11))
25 ..I $Y>(IOSL-8) D PAUSE Q:IBQ D HDR
26 ..W !!,$J(IBCNT,4),"." W:$P(IBINS0,"^",5) ?16,"**"
27 ..W ?20,$S($P(IBINS0,"^")]"":$P(IBINS0,"^"),1:"CARRIER UNKNOWN")
28 ..S X=IBAMTP,X2="2$",X3=15 D COMMA^%DTC W ?55,X
29 ..D INSDIS(IBINSA)
30 G:IBQ ENQ
31 ;
32 ; - print a total
33 I $Y>(IOSL-4) D PAUSE G:IBQ ENQ D HDR
34 W !!,"Total Amount Billed to all Ranked Carriers:" S X=IBTAMT,X2="2$",X3=15 D COMMA^%DTC W ?55,X
35 D PAUSE
36 ;I IBFLG W !!,"Sending the report in a bulletin to the MCCR Program Office... " D BULL^IBCORC2 W "done."
37 ;
38ENQ K ^TMP("IBORIC",$J,"IC"),^("IC1"),^("AMT"),^("NUM")
39 I $D(ZTQUEUED) S ZTREQ="@" Q
40 D ^%ZISC
41 K DIR,DIRUT,DUOUT,DTOUT,DIROUT,IBAMT,IBAMTP,IBI,IBINS0,IBINSA
42 K IBQ,IBPAG,IBNR,IBCNT,IBDT,IBND,IBINS,IBN,IBTAMT,X,X1,X2,X3,Y
43ENQ1 Q
44 ;
45EVAL ; Accumulate amount billed for the carrier if the bill type is correct.
46 F IBI=0,"M","S","MP" S IBND(IBI)=$G(^DGCR(399,IBN,IBI))
47 I IBND(0)="" G EVALQ ; no zeroth node
48 I $P(IBND(0),"^",11)'="i" G EVALQ ; insurer not responsible
49 S IBINS=+IBND("MP") I 'IBINS G EVALQ ; no carrier associated with bill
50 I $P(IBND("S"),"^",16) G EVALQ ; bill has been cancelled
51 S IBAMT=+$$ORI^PRCAFN(IBN) I IBAMT'>0 G EVALQ ; no bill amount
52 S IBINS=$$INACT(IBINS) ; see if company has been repointed
53 S ^(IBINS)=$G(^TMP("IBORIC",$J,"IC",IBINS))+IBAMT
54 I $G(IBIRM) S ^(IBINS)=$G(^TMP("IBORIC",$J,"IC1",IBINS))+1
55EVALQ Q
56 ;
57PAUSE ; Pause for screen output.
58 Q:$E(IOST,1,2)'="C-"
59 N IBI,DIR,DIRUT,DIROUT,DUOUT,DTOUT
60 F IBI=$Y:1:(IOSL-3) W !
61 S DIR(0)="E" D ^DIR I $D(DIRUT)!($D(DUOUT)) S IBQ=1
62 Q
63 ;
64HDR ; Display report header.
65 N X,Y
66 S X="Ranking Of The Top "_IBNR_" Insurance Carriers By Total Amount Billed"
67 S Y=$$SITE^VASITE
68 I $E(IOST,1,2)="C-"!(IBPAG) W @IOF,*13
69 S IBPAG=IBPAG+1
70 W ?(80-$L(X)\2),X,!
71 W !," Facility: ",$P(Y,"^",2)," (",$P(Y,"^",3),")",?58,"Run Date: ",$$DAT1^IBOUTL(DT)
72 W !,"Date Range: ",$$DAT1^IBOUTL(IBABEG)," thru ",$$DAT1^IBOUTL(IBAEND),?62,"Page: ",IBPAG
73 W !?45,"** - denotes an inactive company"
74 W !,$$DASH,!?2,"Rank",?20,"Insurance Carrier",?55,"Total Amt Billed",!,$$DASH
75 Q
76 ;
77DASH() ; Write dashed line.
78 Q $TR($J("",79)," ","=")
79 ;
80INSDIS(X) ; Display Insurance Company name and address.
81 ; Input: X -- .11 node of ins company entry in file #36
82 W:$P(X,"^")]"" !?20,$P(X,"^")
83 W:$P(X,"^",2)]"" !?20,$P(X,"^",2)
84 W:$P(X,"^",3)]"" !?20,$P(X,"^",3)
85 W:$P(X,"^")]""!($P(X,"^",2)]"")!($P(X,"^",3)]"") !?20
86 W $P(X,"^",4) W:$P(X,"^",4)]""&($P(X,"^",5)]"") ", "
87 W $P($G(^DIC(5,+$P(X,"^",5),0)),"^")
88 W:$P(X,"^",6)]""&($P(X,"^",4)]""!($P(X,"^",5)]"")) " "
89 W $P(X,"^",6)
90 Q
91 ;
92START(X1,X2) ; Return the Start Date for the search, less one day.
93 N X,%H D C^%DTC
94 Q X
95 ;
96INACT(CN) ; Determine the repointed-to company for inactivated companies.
97 ; Input: CN -- Pointer to the ins company in file #36
98 ; Output: The repointed-to company, if inactivated (or the same)
99 N X,Y,Z S X=+$G(CN)
100 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)=""
101 Q X
102 ;
103DEL ; Delete "REPOINT PATIENTS TO" field
104 N C1,C2,DA,DIR
105 W !,"The routine will delete the REPOINT PATIENTS TO field of the entry"
106 W !,"in the INSURANCE COMPANY file (#36) if the field entry is pointing"
107 W !,"back to itself (same IEN).",!
108 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.",!
109 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
110 W !,*7,"Done...",C2," records changed." Q
Note: See TracBrowser for help on using the repository browser.