source: WorldVistAEHR/trunk/r/E_CLAIMS_MGMT_ENGINE-BPS/BPSOSIY.m@ 701

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

initial load of WorldVistAEHR

File size: 8.1 KB
Line 
1BPSOSIY ;BHAM ISC/FCS/DRS/DLF - Updating BPS Transaction record ;06/01/2004
2 ;;1.0;E CLAIMS MGMT ENGINE;**1,3,5**;JUN 2004;Build 45
3 ;;Per VHA Directive 2004-038, this routine should not be modified.
4 Q
5 ;
6 ; INIT - Update BPS Transaction
7 ; Input
8 ; IEN59 - BPS Transaction
9 ; MOREDATA is not passed but assumed to exist
10 ; Returns
11 ; ERROR - 0 or error number
12INIT(IEN59) ;EP - from BPSOSIZ
13 ;
14 ; Initialize variables
15 N FDA,MSG,FN,IENS,REC,B1,X1,X2,X3,ERROR,SEQ
16 N RXI,RXR,DIV
17 S FN=9002313.59,REC=IEN59_",",ERROR=0
18 S RXI=$P(IEN59,".",1),RXR=+$E($P(IEN59,".",2),1,4)
19 I RXI="" Q 11
20 ;
21 ; Change status to 0% (Waiting to Start), which will reset START TIME,
22 ; and then to 10% (Building transaction)
23 D SETSTAT^BPSOSU(IEN59,0)
24 D SETSTAT^BPSOSU(IEN59,10)
25 ;
26 ; Get the Outpatient Site
27 S DIV=$$GETDIV^BPSOSQC(RXI,RXR)
28 ;
29 ; If there are Prior Auth or Sub Clar Code override, create override
30 ; record. Note that setting of MOREDATA("BPOVRIEN") in this routine
31 ; will not conflict with prior setting of this value of BPOVRIEN
32 ; since BPOVRIEN and BPSAUTH/BPSCLARF are mutually exclusive
33 I $G(MOREDATA("BPSAUTH"))]""!($G(MOREDATA("BPSCLARF"))]"") S MOREDATA("BPOVRIEN")=$$OVERRIDE(IEN59)
34 ;
35 ; Set BPSDATA into local variable
36 S B1=$G(MOREDATA("BPSDATA",1))
37 ;
38 ; Get first record from MOREDATA("IBDATA") as there are some
39 ; non-multiple fields that need it
40 S X2="",SEQ=$O(MOREDATA("IBDATA",""))
41 I SEQ S X2=$G(MOREDATA("IBDATA",SEQ,2))
42 ;
43 ; Set non-multiple fields
44 S FDA(FN,REC,1.07)=$$GETPHARM^BPSUTIL(DIV) ;BPS Pharmacy
45 S FDA(FN,REC,1.08)=1 ;PINS piece
46 S FDA(FN,REC,1.11)=RXI ;Prescription
47 I $P($G(^BPST(IEN59,1)),U,12)=1 S FDA(FN,REC,1.12)=2 ;Resubmit after reversal
48 S FDA(FN,REC,1.13)=$G(MOREDATA("BPOVRIEN")) ;NCPDP Overrides
49 S FDA(FN,REC,5)=$$RXAPI1^BPSUTIL1(RXI,2,"I") ;Patient
50 I '$P($G(^BPST(IEN59,1)),U,12) S FDA(FN,REC,6)=$G(MOREDATA("SUBMIT TIME")) ;Submit Date/Time
51 S FDA(FN,REC,9)=RXR ;Refill
52 S FDA(FN,REC,10)=$P(B1,U,3) ;NDC
53 S FDA(FN,REC,11)=DIV ;Outpatient Site
54 S FDA(FN,REC,13)=$G(MOREDATA("USER")) ;User
55 S FDA(FN,REC,501)=$P(B1,U,1) ;Drug Quanity
56 S FDA(FN,REC,502)=$P(B1,U,2) ;Ingredient Cost
57 S FDA(FN,REC,504)=$P(X2,U,1) ;Dispense Fee
58 S FDA(FN,REC,505)=$P(X2,U,3) ;Total Price
59 S FDA(FN,REC,507)=$P(X2,U,5) ;Administrative Fee
60 S FDA(FN,REC,508)=$E($P(B1,U,7),1,2) ;Dispense Unit
61 S FDA(FN,REC,901)=1 ;Current VA Insurer
62 S FDA(FN,REC,1201)=$G(MOREDATA("RX ACTION")) ;RX Action
63 S FDA(FN,REC,1202)=$G(MOREDATA("DATE OF SERVICE")) ;Date of Service
64 ;
65 ; File non-multiple fields - Record is already defined
66 D FILE^DIE("","FDA","MSG")
67 I $D(MSG) D Q ERROR
68 . S ERROR=12
69 . D LOG^BPSOSL(IEN59,$T(+0)_"-Non-multiple fields did not file")
70 . D LOG^BPSOSL(IEN59,"MSG Array:")
71 . D LOGARRAY^BPSOSL(IEN59,"MSG")
72 . D LOG^BPSOSL(IEN59,"FDA Array:")
73 . D LOGARRAY^BPSOSL(IEN59,"FDA")
74 ;
75 ; Build Multiple
76 S SEQ=""
77 F S SEQ=$O(MOREDATA("IBDATA",SEQ)) Q:SEQ="" D I ERROR Q
78 . K FDA,MSG,IENS
79 . S FN=9002313.59902,IENS="+1,"_REC,IENS(1)=SEQ
80 . S X1=$G(MOREDATA("IBDATA",SEQ,1)),X2=$G(MOREDATA("IBDATA",SEQ,2)),X3=$G(MOREDATA("IBDATA",SEQ,3))
81 . ;
82 . ; Update fields
83 . S FDA(FN,IENS,.01)=$P(X1,U,1) ;Plan ID
84 . S FDA(FN,IENS,902.03)=$P(X1,U,2) ;BIN
85 . S FDA(FN,IENS,902.04)=$P(X1,U,3) ;PCN
86 . S FDA(FN,IENS,902.05)=$P(X1,U,5) ;Group ID
87 . S FDA(FN,IENS,902.06)=$P(X1,U,6) ;Cardholder ID
88 . S FDA(FN,IENS,902.07)=$S(+$P(X1,U,7)>4:4,1:+$P(X1,U,7)) ;Patient Relationship Code
89 . S FDA(FN,IENS,902.08)=$P($P(X1,U,8)," ") ;Cardholder First Name
90 . S FDA(FN,IENS,902.09)=$P(X1,U,9) ;Cardholder Last Name
91 . S FDA(FN,IENS,902.11)=$P(X1,U,10) ;Home Plan State
92 . S FDA(FN,IENS,902.12)=$P(X2,U,1) ;Dispense Fee
93 . S FDA(FN,IENS,902.13)=$P(X2,U,2) ;Basis of Cost Determination
94 . S FDA(FN,IENS,902.14)=$P(X2,U,3) ;Usual & Customary Charge
95 . S FDA(FN,IENS,902.15)=$P(X2,U,4) ;Gross Amt Due
96 . S FDA(FN,IENS,902.16)=$P(X2,U,5) ;Administrative Fee
97 . S FDA(FN,IENS,902.17)=$P(B1,U,4) ;VA Fill Number
98 . S FDA(FN,IENS,902.18)=$P(X1,U,13) ;Software/Vendor Cert ID
99 . S FDA(FN,IENS,902.22)=$P(B1,U,5) ;Certify Mode
100 . S FDA(FN,IENS,902.23)=$P(B1,U,6) ;Certification IEN
101 . S FDA(FN,IENS,902.24)=$P(X1,U,14) ;Plan Name
102 . S FDA(FN,IENS,902.25)=$P(X3,U,1) ;Group Name
103 . S FDA(FN,IENS,902.26)=$P(X3,U,2) ;Insurance Co Phone #
104 . S FDA(FN,IENS,902.27)=$P(X3,U,3) ;Pharmacy Plan ID
105 . ;
106 . ; File the data
107 . D UPDATE^DIE("","FDA","IENS","MSG")
108 . I $D(MSG) D
109 .. S ERROR=13
110 .. D LOG^BPSOSL(IEN59,$T(+0)_"-Multiple fields did not file, SEQ="_SEQ)
111 .. D LOG^BPSOSL(IEN59,"MSG Array:")
112 .. D LOGARRAY^BPSOSL(IEN59,"MSG")
113 .. D LOG^BPSOSL(IEN59,"IENS Array:")
114 .. D LOGARRAY^BPSOSL(IEN59,"IENS")
115 .. D LOG^BPSOSL(IEN59,"FDA Array:")
116 .. D LOGARRAY^BPSOSL(IEN59,"FDA")
117 . ;
118 . ; Payer sheets are in external format
119 . K FDA,MSG
120 . S FN=9002313.59902,IENS=IENS(1)_","_REC
121 . S FDA(FN,IENS,902.02)=$P(X1,U,4) ;Payer Sheet IEN
122 . S FDA(FN,IENS,902.19)=$P(X1,U,11) ;B2 Payer Sheet (Reversal)
123 . S FDA(FN,IENS,902.21)=$P(X1,U,12) ;B3 Payer Sheet (Rebill)
124 . D FILE^DIE("E","FDA","MSG")
125 . I $D(MSG) D
126 .. S ERROR=14
127 .. D LOG^BPSOSL(IEN59,$T(+0)_"-Payer sheets did not file, SEQ="_SEQ)
128 .. D LOG^BPSOSL(IEN59,"MSG Array:")
129 .. D LOGARRAY^BPSOSL(IEN59,"MSG")
130 .. D LOG^BPSOSL(IEN59,"FDA Array:")
131 .. D LOGARRAY^BPSOSL(IEN59,"FDA")
132 ;
133 ; Store DUR multiple if it exists
134 N DUR,DURREC
135 S FN=9002313.5913,DUR=0
136 F S DUR=$O(MOREDATA("DUR",DUR)) Q:DUR="" D I ERROR Q
137 . K FDA,MSG,IENS
138 . S DURREC=$G(MOREDATA("DUR",DUR,0))
139 . S IENS="+1,"_REC,IENS(1)=DUR
140 . S FDA(FN,IENS,.01)=DUR ; DUR Counter
141 . S FDA(FN,IENS,1)=$P(DURREC,U,1) ; DUR Professional Service Code
142 . S FDA(FN,IENS,2)=$P(DURREC,U,2) ; DUR Reason for Service Code
143 . S FDA(FN,IENS,3)=$P(DURREC,U,3) ; DUR Result of Service Code
144 . D UPDATE^DIE("","FDA","IENS","MSG")
145 . I $D(MSG) D
146 .. S ERROR=15
147 .. D LOG^BPSOSL(IEN59,$T(+0)_"-DUR fields did not file, DUR="_DUR)
148 .. D LOG^BPSOSL(IEN59,"DURREC="_DURREC)
149 .. D LOG^BPSOSL(IEN59,"MSG Array:")
150 .. D LOGARRAY^BPSOSL(IEN59,"MSG")
151 .. D LOG^BPSOSL(IEN59,"IENS Array:")
152 .. D LOGARRAY^BPSOSL(IEN59,"IENS")
153 .. D LOG^BPSOSL(IEN59,"FDA Array:")
154 .. D LOGARRAY^BPSOSL(IEN59,"FDA")
155 ;
156 Q ERROR
157 ;
158 ; OVERRIDE - Function to create override record
159OVERRIDE(IEN59) ;
160 ;Save values into BPS NCPDP OVERRIDES (#9002313.511)
161 N BPSFDA,BPSFLD,BPOVRIEN,BPSMSG,BPSQ
162 ;
163 ; Set Name (.01) to transaction number
164 S BPSFDA(9002313.511,"+1,",.01)=IEN59
165 ;
166 ; Set Created On (.02) to current date/time
167 S BPSFDA(9002313.511,"+1,",.02)=$$NOW^BPSOSRX()
168 ;
169 ; Submission Clarification Code
170 I $G(MOREDATA("BPSCLARF"))]"" D
171 . S BPSFLD=$O(^BPSF(9002313.91,"B",420,""))
172 . I BPSFLD]"" S BPSFDA(9002313.5111,"+2,+1,",.01)=BPSFLD,BPSFDA(9002313.5111,"+2,+1,",.02)=$E(MOREDATA("BPSCLARF"),1,2)
173 ;
174 ; Prior Auth Fields (Code and Number)
175 I $G(MOREDATA("BPSAUTH"))]"" D
176 . S BPSFLD=$O(^BPSF(9002313.91,"B",461,""))
177 . I BPSFLD]"" S BPSFDA(9002313.5111,"+3,+1,",.01)=BPSFLD,BPSFDA(9002313.5111,"+3,+1,",.02)=$E($P(MOREDATA("BPSAUTH"),U,1),1,2)
178 . S BPSFLD=$O(^BPSF(9002313.91,"B",462,""))
179 . I BPSFLD]"" S BPSFDA(9002313.5111,"+4,+1,",.01)=BPSFLD,BPSFDA(9002313.5111,"+4,+1,",.02)=$E($P(MOREDATA("BPSAUTH"),U,2),1,11)
180 ;
181 ; Create the record
182 D UPDATE^DIE("","BPSFDA","BPOVRIEN","BPMSG")
183 ;
184 I $G(BPOVRIEN(1))]"" S BPSQ=BPOVRIEN(1)
185 E S BPSQ=""
186 Q BPSQ
187 ;
188 ; RXPAID - Check for status of previous claim
189 ; INPUT
190 ; IEN59 - BPS Transaction
191 ; Return
192 ; 0 - OK
193 ; 1 - Payable
194 ; 2 - Reversal not accepted
195 ; 3 - Duplicate
196RXPAID(IEN59) ;EP - from BPSOSIZ
197 N N57
198 S N57=$$RXPREV(IEN59)
199 I 'N57 Q "" ; no ECME record of this
200 ; If it's a reversal, then our result depends on the reversal:
201 ; Was the reversal accepted? If so, then No, not paid.
202 ; Was the reversal rejected? Assume Paid, since we try to
203 ; allow reversals only in the case of a paid original.
204 I $$ISREVERS^BPSOS57(N57) Q $S($$REVACC^BPSOS57(N57):0,1:2)
205 ;
206 ; Not a reversal:
207 N X S X=$$CATEG^BPSOSUC(N57)
208 Q $S(X="E PAYABLE":1,X="E DUPLICATE":3,1:0)
209 ;
210 ; RXPREV - Has this item previously been through ECME?
211 ; Return false if not
212 ; Return pointer to BPS Log of Transactions if true
213RXPREV(IEN59) ;
214 N RXI,RXR
215 S RXI=$P(IEN59,".",1),RXR=+$E($P(IEN59,".",2),1,4)
216 Q $O(^BPSTL("NON-FILEMAN","RXIRXR",RXI,RXR,""),-1)
Note: See TracBrowser for help on using the repository browser.