source: FOIAVistA/trunk/r/INTEGRATED_BILLING-IB-PRQ--IBD--IBQ--PRQS/IBCNS2.m@ 1751

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

initial load of FOIAVistA 6/30/08 version

File size: 4.0 KB
Line 
1IBCNS2 ;ALB/AAS - INSURANCE POLICY CALLS FROM FILE 399 DD ;22-JULY-91
2 ;;2.0;INTEGRATED BILLING;**28,43,80,51,137,155**;21-MAR-94
3 ;;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;
5 Q
6DD(IBX,IBDA,LEVEL) ; - called from input transform for field 111,112,113
7 ; -- input ibx = x from input transform
8 ; ibda = internal entry in 399
9 ; level = 1=primary, 2=secondary, 3=tertiary
10 ; -- output returns x=internal entry in 2.3121 (ins. Mult.) if valid
11 ;
12 N DFN,ACTIVE,INSDT
13 D VAR
14 S X=$$SEL(IBX,DFN,INSDT,ACTIVE)
15 I +X<1 K X
16DDQ Q
17 ;
18VAR S DFN=$P(^DGCR(399,IBDA,0),"^",2),ACTIVE=1,INSDT=$S(+$G(^DGCR(399,IBDA,"U")):+$G(^("U")),1:DT)
19 Q
20 ;
21SEL(IBX,DFN,INSDT,ACTIVE) ; -- Select insurance policy
22 ; -- Input IBX = x from input transform
23 ; DFN = patient
24 ; INSDT = (optional) Active date of ins. (default = dt)
25 ; ACTIVE = (optional) 1 if want active (default)
26 ; = 2 if want all ins returned
27 ;
28 ; -- Output = pointer to 36 ^ pointer to 2.3121 ^ pointer to 355.3
29 ;
30 N I,J,Y,DA,DE,DQ,DR,DIC,DIE,DIR,DIV,IBSEL,IBDD,IBD
31 S IBSEL=1,Y=""
32 I '$G(ACTIVE) S ACTIVE=1
33 S:'$G(INSDT) INSDT=DT
34 I '$G(DFN) G SELQ
35 D BLD
36 ;
37 ; -- call DIC to choose from list
38 S X=IBX
39 S DIC="^DPT("_DFN_",.312,",DIC(0)="EQMN"
40 S DIC("S")="I $D(IBDD(+Y))" ; add not other selection
41 S DIC("W")="W $P(^DIC(36,+^(0),0),U)_"" Group: ""_$$GRP^IBCNS($P(^DPT(DFN,.312,+Y,0),U,18))"
42 D ^DIC
43SELQ Q +Y
44 ;
45BLD K IBD,IBDD
46 S (IBDD,IBCDFN)=0 F S IBCDFN=$O(^DPT(DFN,.312,IBCDFN)) Q:'IBCDFN I $D(^DPT(DFN,.312,IBCDFN,0)) D CHK(IBCDFN,ACTIVE,INSDT)
47 Q
48 ;
49CHK(IBCDFN,ACTIVE,INSDT) ; -- see if active
50 N X,X1
51 S X=$G(^DPT(DFN,.312,IBCDFN,0))
52 S IBDD(IBCDFN)=+X_"^"_IBCDFN_"^"_$P(X,"^",18)
53 I ACTIVE=2 G CHKQ
54 S X1=$G(^DIC(36,+X,0)) I X1="" G CQ ;ins co entry doesn't exist
55 I $P(X,"^",8) G:INSDT<$P(X,"^",8) CQ ;effective date later than care
56 I $P(X,"^",4) G:INSDT>$P(X,"^",4) CQ ;care after expiration date
57 I $P($G(^IBA(355.3,+$P(X,"^",18),0)),"^",11) G CQ ;plan is inactive
58 G:$P(X1,"^",5) CQ ; ;ins company inactive
59 ;G:$P(X1,"^",2)="N" CQ ; ;ins company will not reimburse
60 G CHKQ
61CQ K IBDD(IBCDFN)
62CHKQ S:$D(IBDD(IBCDFN)) IBDD=IBDD+1,IBD(IBDD)=IBCDFN
63 Q
64 ;
65 ;
66DDHELP(IBDA,LEVEL) ; -- Executable help
67 ; -- write out list to choose from
68 N DFN,ACTIVE,INSDT,I,IBINS
69 D VAR,BLD
70 ;
71 I $G(IBDD)=0 W !,"No Insurance Policies to Select From" G DDHQ
72 ;
73 I '$D(IOM) D HOME^%ZIS
74 N IBDTIN
75 S IBDTIN=$G(INSDT)
76 W ! D HDR^IBCNS
77 S I=0 F S I=$O(IBD(I)) Q:'I D
78 .S IBINS=$G(^DPT(DFN,.312,$G(IBD(I)),0))
79 .D D1^IBCNS
80DDHQ Q
81 ;
82TRANS(IBDA,Y) ; -- output transform
83 N DFN,ACTIVE,INSDT
84 D VAR
85 S Y=$P($G(^DIC(36,+$P($G(^DPT(DFN,.312,+$G(Y),0)),U),0)),U)
86 Q Y
87 ;
88INSCO(IBDA,IBCDFN) ; -- return pointer value of 36 from pt. file
89 N DFN,ACTIVE,INSDT
90 D VAR
91 S Y=+$G(^DPT(DFN,.312,IBCDFN,0))
92 Q Y_$S(Y>0:"^"_$P($G(^DIC(36,+Y,0)),"^"),1:"")
93 ;
94IX(DA,XREF) ; -- create i1, aic xrefs for fields 112, 113, 114
95 ;
96 S ^DGCR(399,DA,XREF)=$$ZND^IBCNS1($P($G(^DGCR(399,DA,0)),"^",2),X)
97 S ^DGCR(399,DA,"AIC",+$G(^DPT($P($G(^DGCR(399,DA,0)),"^",2),.312,+X,0)))=""
98 Q
99 ;
100KIX(DA,XREF) ; -- kill logic for above xref
101 K ^DGCR(399,DA,XREF)
102 K ^DGCR(399,DA,"AIC",+$G(^DPT($P($G(^DGCR(399,DA,0)),"^",2),.312,+X,0)))
103 Q
104 ;
105BPP(IBDA,IBMCR) ; Find Bill Payer Policy based on Payer Sequence and the P/S/T payers assigned to the bill,Ins Co must reimburse
106 ; IBMCR = flag that says include MEDICARE WNR
107 ; returns - Bill Payer Policy (ifn of policy entry in patient file)
108 ; - null if either no Payer Sequence or there is no policy defined for the payer sequence
109 ; or the policy defined by the payer sequence Will Not Reimburse and is not MEDICARE
110 ;
111 N IBI,IBX,IBY,IBP,IBC,IBM0 S IBX="",(IBP,IBC)=0
112 S IBMCR=+$G(IBMCR)
113 S IBY=$$COBN^IBCEF(+IBDA) I IBY S IBY=IBY+11
114 I IBY S IBM0=$G(^DGCR(399,+IBDA,"M")),IBP=$P(IBM0,U,IBY)
115 I IBP S IBY=IBY-11,(IBI,IBY)=$P(IBM0,U,IBY) I +IBY S IBC=$P($G(^DIC(36,+IBY,0)),U,2)
116 I IBP,IBI,$S(IBC'="N":1,'IBMCR:0,1:$$MCRWNR^IBEFUNC(+IBY)) S IBX=IBP
117 Q IBX
Note: See TracBrowser for help on using the repository browser.