source: FOIAVistA/trunk/r/E_CLAIMS_MGMT_ENGINE-BPS/BPSOSCD.m@ 1397

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

initial load of FOIAVistA 6/30/08 version

File size: 7.0 KB
Line 
1BPSOSCD ;BHAM ISC/FCS/DRS/DLF - Set BPS() "RX" nodes for current medication ;06/01/2004
2 ;;1.0;E CLAIMS MGMT ENGINE;**1,3,2,5**;JUN 2004;Build 45
3 ;;Per VHA Directive 2004-038, this routine should not be modified.
4 ;
5 Q
6 ;----------------------------------------------------------------------
7 ;Set BPS() "RX" nodes for current medication:
8 ;
9 ;Parameters: IEN59 - Pointer to BPS Transactions
10 ; IEN5902 - IEN for Insurance multiple of BPS Transactions
11 ; MEDN - Index number indicating what medication is
12 ; being processed
13 ;
14 ; Note that the BPS array is shared by all of the BPSOSC* routines and
15 ; is newed by BPSOSCA
16 ; Note that VAINFO is newed/set in BPSOSCB
17 ;----------------------------------------------------------------------
18 ; Called from BPSOSCA for every prescription in the multiple
19MEDINFO(IEN59,IEN5902,MEDN) ;
20 ; Verify Parameters
21 I $G(IEN59)="" Q
22 I $G(IEN5902)="" Q
23 I $G(MEDN)="" Q
24 ;
25 ; New variables and basic setup
26 N RXIEN,RXRFIEN,IENS,DRUGIEN,PROVIEN,RXI,FILLDT,NDC,NPI
27 S RXIEN=$P(IEN59,".",1)
28 S RXRFIEN=+$E($P(IEN59,".",2),1,4)
29 S IENS=IEN5902_","_IEN59_","
30 ;
31 ; Get any user-entered overrides stored in BPS NCPDP OVERRIDES
32 D OVERRIDE(IEN59,MEDN)
33 ;
34 ; Retrieve DUR values
35 D DURVALUE(IEN59,MEDN)
36 ;
37 ; Get Drug and Prescriber IEN
38 S DRUGIEN=$$RXAPI1^BPSUTIL1(RXIEN,6,"I")
39 S PROVIEN=$$RXAPI1^BPSUTIL1(RXIEN,4,"I")
40 ;
41 ; Basic RX info
42 S BPS("RX",MEDN,"IEN59")=IEN59
43 S BPS("RX",MEDN,"RX IEN")=RXIEN
44 S BPS("RX",MEDN,"RX Number")=RXIEN
45 S BPS("RX",MEDN,"Date Written")=$$RXAPI1^BPSUTIL1(RXIEN,1,"I")
46 S BPS("RX",MEDN,"New/Refill")=$S(RXRFIEN="":"N",1:"R")
47 ;
48 ; Get/format the Service Date - It should be in BPS Transaction. If not,
49 ; use the established algorithm, which is $$DOSDATE^BPSSCRRS
50 S FILLDT=$P($G(^BPST(IEN59,12)),U,2)
51 I FILLDT="" S FILLDT=$$DOSDATE^BPSSCRRS(RXIEN,RXRFIEN) D LOG^BPSOSL(IEN59,$T(+0)_"-Fill Date sent as "_FILLDT)
52 S BPS("RX",MEDN,"Date Filled")=$$FMTHL7^XLFDT(FILLDT)
53 ;
54 ; PreAuth and Prior Auth (use same fields)
55 S BPS("RX",MEDN,"Preauth #")=$P(^BPST(IEN59,1),U,15)_$P(^BPST(IEN59,1),U,9)
56 S BPS("Claim",MEDN,"Prior Auth Type")=$P(^BPST(IEN59,1),U,15)
57 S BPS("Claim",MEDN,"Prior Auth Num Sub")=$P(^BPST(IEN59,1),U,9)
58 ;
59 ; NDC - Get from transaction first. If not there (which should not happen),
60 ; get it from the RX/Fill
61 S NDC=$P(^BPST(IEN59,1),U,2)
62 I NDC="" S NDC=$$GETNDC^PSONDCUT(RXIEN,RXRFIEN) D LOG^BPSOSL(IEN59,$T(+0)_"-NDC sent as "_NDC)
63 S BPS("RX",MEDN,"NDC")=NDC
64 ;
65 ; Prescription Data
66 S BPS("RX",MEDN,"# Refills")=$$RXAPI1^BPSUTIL1(RXIEN,9,"I")
67 S BPS("RX",MEDN,"Refill #")=+RXRFIEN
68 ;
69 ; Prescription Data dependent on original vs. refill
70 I 'RXRFIEN D ; first fill
71 . S BPS("RX",MEDN,"Days Supply")=$$RXAPI1^BPSUTIL1(RXIEN,8,"I")
72 . S BPS("RX",MEDN,"DAW")=$$RXAPI1^BPSUTIL1(RXIEN,81,"I")
73 E D ; refill
74 . S BPS("RX",MEDN,"Days Supply")=$$RXSUBF1^BPSUTIL1(RXIEN,52,52.1,+RXRFIEN,1.1,"I")
75 . S BPS("RX",MEDN,"DAW")=$$RXSUBF1^BPSUTIL1(RXIEN,52,52.1,+RXRFIEN,81,"I")
76 ;
77 ; Provider Info
78 S BPS("RX",MEDN,"Prescriber IEN")=+PROVIEN
79 I PROVIEN'="" D
80 . S BPS("RX",MEDN,"Prescriber Name")=$$GET1^DIQ(200,+PROVIEN,.01)
81 . S BPS("RX",MEDN,"Prescriber Phone #")=$$GET1^DIQ(200,+PROVIEN,.131)
82 . I ^BPS(9002313.99,1,"CERTIFIER")=DUZ S BPS("RX",MEDN,"Prescriber DEA #")=$G(BPS("RX",1,"Provider ID"))
83 . S BPS("RX",MEDN,"Prescriber DEA #")=$$GET1^DIQ(200,+PROVIEN,53.2)
84 . S BPS("RX",MEDN,"Prescriber CAID #")=""
85 . S BPS("RX",MEDN,"Prescriber UPIN #")=""
86 . S BPS("RX",MEDN,"Prescriber Billing Location")=""
87 . S NPI=$$NPI^BPSNPI("Individual_ID",+PROVIEN)
88 . I +NPI=-1 S NPI=""
89 . S BPS("RX",MEDN,"Prescriber NPI")=$P(NPI,U,1)
90 . S BPS("RX",MEDN,"Primary Care Provider NPI")=$P(NPI,U,1)
91 . S BPS("RX",MEDN,"Provider NPI")=$P(NPI,U,1)
92 ;
93 ; Set Prescriber ID field to individual DEA if it exists, else default DEA
94 N %
95 S %=$G(BPS("RX",MEDN,"Prescriber DEA #"))
96 I %="" S %=$G(BPS("Site","Default DEA #"))
97 S BPS("RX",MEDN,"Prescriber ID")=%
98 ;
99 ; Get State IDs for providers
100 D STLIC^BPSJPAY(MEDN,PROVIEN,BPS("RX",MEDN,"Date Filled"))
101 ;
102 ; Origin Code
103 N VANATURE,VAOIEN
104 S (VANATURE,VAOIEN)="",VAOIEN=+$$RXAPI1^BPSUTIL1(RXIEN,39.3,"I"),VANATURE=$$GET1^DIQ(100.008,"1,"_VAOIEN_",","12")
105 S BPS("RX",MEDN,"Origin Code")=$S(VANATURE="AUTO":2,VANATURE["ELECTRONIC":3,VANATURE="DUPLICATE":0,VANATURE["TELEPHONE":2,1:1)
106 ;
107 ;Submission Clarification Code
108 S BPS("RX",MEDN,"Clarification")=$P($G(^BPST(IEN59,12)),U,3)
109 ;
110 ; Drug Info
111 I DRUGIEN'="" D
112 . S BPS("RX",MEDN,"Drug IEN")=DRUGIEN
113 . S BPS("RX",MEDN,"Drug Name")=$$DRUGDIE^BPSUTIL1(DRUGIEN,.01,"E")
114 ;
115 ; Pricing Info
116 S BPS("RX",MEDN,"Alt. Product Type")="03"
117 S BPS("RX",MEDN,"Gross Amount Due")=$G(VAINFO(9002313.59902,IENS,902.15,"I"))
118 S BPS("RX",MEDN,"Usual & Customary")=$G(VAINFO(9002313.59902,IENS,902.14,"I"))
119 S BPS("RX",MEDN,"Basis of Cost Determination")=$G(VAINFO(9002313.59902,IENS,902.13,"I"))
120 ;
121 ; More pricing info
122 N PRICING
123 S PRICING=^BPST(IEN59,5)
124 S BPS("RX",MEDN,"Quantity")=$P(PRICING,U) ; 01/31/2001
125 S BPS("RX",MEDN,"Unit Price")=$P(PRICING,U,2)
126 S BPS("RX",MEDN,"Ingredient Cost")=$J($P(PRICING,U,2),0,2)
127 S BPS("RX",MEDN,"Dispensing Fee")=$J($P(PRICING,U,4),0,2)
128 S BPS("Site","Dispensing Fee")=BPS("RX",MEDN,"Dispensing Fee")
129 S BPS("RX",MEDN,"Usual & Customary")=$J($P(PRICING,U,5),0,2)
130 S BPS("RX",MEDN,"Unit of Measure")=$P(PRICING,U,8)
131 I $G(BPS("NCPDP","Add Disp. Fee to Ingr. Cost")) D
132 . S BPS("RX",MEDN,"Ingredient Cost")=BPS("RX",MEDN,"Ingredient Cost")+BPS("RX",MEDN,"Dispensing Fee")
133 Q
134 ;
135 ; OVERRIDE - Retrieve OVERRIDE nodes and put into BPS array
136 ; They will be fetched from BPS("OVERRIDE"
137 ; during low-level construction of the actual encoded claim packet.
138 ; BPS("OVERRIDE",field)=value for fields 101-401
139 ; BPS("OVERRIDE","RX",MEDN,field) for med #N, fields 402+
140 ; Note that if you have multiple prescriptions bundled, the
141 ; union of overrides from 101-401 apply to all; and if there's a
142 ; conflict, the last one overwrites the previous ones.
143OVERRIDE(IEN59,MEDN) ;
144 N IEN511 S IEN511=$P(^BPST(IEN59,1),U,13) Q:'IEN511
145 N RETVAL S RETVAL=$$GET511^BPSOSO2(IEN511,"BPS(""OVERRIDE"")","BPS(""OVERRIDE"",""RX"","_MEDN_")")
146 Q
147 ;
148 ; DURVALUE - Will read in the DUR data from the DUR multiple
149 ; in BPS Transactions and store the values into BPS("RX",MEDN,DUR,....)
150 ; NOTE - unlike most values, these fields are stored by their
151 ; field number. Since they are repeating, it will ease the
152 ; retrieval of them, when we populate the claim.
153DURVALUE(IEN59,MEDN) ;
154 N DUR,DCNT,DURREC
155 ;
156 S (DUR,DCNT)=0
157 F S DCNT=$O(^BPST(IEN59,13,DCNT)) Q:'+DCNT D
158 . S DURREC=$G(^BPST(IEN59,13,DCNT,0))
159 . I DURREC="" Q
160 . S DUR=DUR+1
161 . S BPS("RX",MEDN,"DUR",DUR,473)=DUR ;dur/pps cntr
162 . S BPS("RX",MEDN,"DUR",DUR,439)=$P(DURREC,U,3) ;Reason Srv Cd
163 . S BPS("RX",MEDN,"DUR",DUR,440)=$P(DURREC,U,2) ;Prof Srv Cd
164 . S BPS("RX",MEDN,"DUR",DUR,441)=$P(DURREC,U,4) ;Result Src Cd
165 . S BPS("RX",MEDN,"DUR",DUR,474)="" ;Level of Effort
166 . S BPS("RX",MEDN,"DUR",DUR,475)="" ;Co-agent Qual
167 . S BPS("RX",MEDN,"DUR",DUR,476)="" ;Co-agent ID
168 Q
Note: See TracBrowser for help on using the repository browser.