source: FOIAVistA/trunk/r/E_CLAIMS_MGMT_ENGINE-BPS/BPSOSH2.m@ 1582

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

initial load of FOIAVistA 6/30/08 version

File size: 6.2 KB
Line 
1BPSOSH2 ;BHAM ISC/SD/lwj/DLF - Assemble formatted claim for 5.1 ;06/01/2004
2 ;;1.0;E CLAIMS MGMT ENGINE;**1,5**;JUN 2004;Build 45
3 ;;Per VHA Directive 2004-038, this routine should not be modified.
4 ;----------------------------------------------------------------------
5 ; Changes for NCPDP 5.1
6 ; 5.1 has 14 claim segments (header, patient, insurance, claim
7 ; pharmacy provider, prescriber,
8 ; COB, workers comp, DUR, Pricing,
9 ; coupon, compound, prior auth,
10 ; clinical)
11 ; 5.1 requires field identifiers and separators on all fields
12 ; other than the header
13 ; 5.1 segment separators are required prior to each segment
14 ; following the header
15 ; 5.1 Group separators appear at the end of each
16 ; transaction (prescription)
17 ; 5.1 we only want to send segments that have data - a new
18 ; segment record will hold the data until we are sure
19 ; we have something to send
20 ;
21 ;
22 ;----------------------------------------------------------------------
23 ;Put together ascii formatted record via NCPDP Record definition
24 ;
25 ;Input Variables: NODES - (100^110^120 or
26 ; 130^140^150^160^170^180^190^
27 ; 200^210^220^230)
28 ; .IEN - Internal Entry Number array
29 ; .BPS - Formatted Data Array with claim and
30 ; prescription data
31 ; .REC - Formatted Ascii record (result)
32 ;----------------------------------------------------------------------
33XLOOP(NODES,IEN,BPS,REC) ;EP - from BPSECA1
34 ;
35 ; Manage local variables
36 N ORDER,RECMIEN,MDATA,FLDIEN,PMODE,FLAG,NODE,FDATA,FLDNUM,FLDDATA
37 N INDEX,FLDID
38 N SEGREC,DATAFND,FDATA5
39 ;
40 ;Loop through the NODES defined in NODES variable parsed by U
41 F INDEX=1:1:$L(NODES,U) D
42 . S NODE=$P(NODES,U,INDEX)
43 . Q:NODE=""
44 . ;
45 . ; VA does not support these nodes
46 . Q:",230,220,210,200,170,160,"[NODE
47 . ;
48 . ; Quit if the payer sheet does not have the node
49 . Q:'$D(^BPSF(9002313.92,+IEN(9002313.92),NODE,0))
50 . ;
51 . ; Per NCPDP standard, reversals do not support segments listed below - DMB 5/2/2005
52 . I $G(BPS(9002313.02,+$G(IEN(9002313.02)),103,"I"))="B2",",230,220,210,200,170,160,150,140,"[NODE Q
53 . ;
54 . S DATAFND=0 ;indicates if data is on the segment for us to send
55 . S SEGREC="" ;holds the segment's information
56 . ;
57 . D:NODE=180 PROCDUR
58 . ;
59 . S ORDER=""
60 . F D Q:'ORDER
61 .. ;
62 .. Q:NODE=180 ;already had to process the DUR/PPS section (repeating)
63 .. S ORDER=$O(^BPSF(9002313.92,+IEN(9002313.92),NODE,"B",ORDER))
64 .. Q:'ORDER
65 .. S RECMIEN=""
66 .. S RECMIEN=$O(^BPSF(9002313.92,+IEN(9002313.92),NODE,"B",ORDER,RECMIEN))
67 .. Q:RECMIEN=""
68 .. ;
69 .. S MDATA=$G(^BPSF(9002313.92,+IEN(9002313.92),NODE,RECMIEN,0))
70 .. Q:MDATA=""
71 .. ;
72 .. S FLDIEN=$P(MDATA,U,2)
73 .. Q:FLDIEN=""
74 .. ;
75 .. S FDATA=$G(^BPSF(9002313.91,FLDIEN,0))
76 .. Q:FDATA=""
77 .. S FLDNUM=$P(FDATA,U,1)
78 .. Q:FLDNUM=""
79 .. ;
80 .. S FDATA5=$G(^BPSF(9002313.91,FLDIEN,5)) ;5.1 id and length
81 .. S FLDID=$P(FDATA5,U,1) ;5.1 ID
82 .. ;
83 .. ;header data
84 .. S:NODE<130 FLDDATA=$G(BPS(9002313.02,IEN(9002313.02),FLDNUM,"I"))
85 .. ;
86 .. ;transaction data
87 .. S:NODE>120 FLDDATA=$G(BPS(9002313.0201,IEN(9002313.01),FLDNUM,"I"))
88 .. ;
89 .. I FLDID'=$TR(FLDDATA,"0 {}") S DATAFND=1 ;fld chk-is the field empty?
90 .. ;
91 .. ;check if this is the seg id - call this after fld chk since
92 .. ;we don't want to send the segment if this is all there is
93 .. I (NODE>100)&(FLDNUM=111) S FLDDATA=$$SEGID(NODE)
94 .. ;
95 .. Q:FLDDATA="" ;lje;7/23/03; don't want extra field separators when field is blank for testing for WebMD.
96 .. ;
97 .. S:NODE=100 SEGREC=SEGREC_FLDDATA ;no FS on the header rec
98 .. S:NODE>100 SEGREC=SEGREC_$C(28)_FLDDATA ;FS always proceeds fld
99 .. ;
100 . ;
101 . I (DATAFND)&(NODE=100) S REC(NODE)=SEGREC ;no SS when it's the header
102 . I (DATAFND)&(NODE>100) D
103 .. I '$D(REC(NODE)) S REC(NODE)=REC I REC[$C(29) S REC=""
104 .. S REC(NODE)=REC(NODE)_$C(30)_SEGREC ;SS before the seg
105 ;
106 Q
107 ;
108SEGID(ND) ; Field 111 is the Segment Identifier - for each segment, other than
109 ; the header, a pre-defined, unique value must be sent in this field
110 ; to identify which segment is being sent. This value is not stored
111 ; in the claim - as it changes with each of the 13 segments. The
112 ; field does appear as part of the NCPCP Format, put is simply not
113 ; stored.
114 ; 01 = Patient 02 = Pharmacy Provider 03 = Prescriber
115 ; 04 = Insurance 05 = COB/Other Payment 06 = Workers Comp
116 ; 07 = Claim 08 = DUR/PPS 09 = Coupon
117 ; 10 = Compound 11 = Pricing 12 = Prior Auth
118 ; 13 = Clinical
119 ;
120 N FLD
121 ;
122 S FLD=$S(ND=110:"01",ND=120:"04",ND=130:"07",ND=140:"02",ND=150:"03",ND=160:"05",ND=170:"06",ND=180:"08",ND=190:11,ND=200:"09",ND=210:10,ND=220:12,ND=230:13,1:"00")
123 S FLD="AM"_$$NFF^BPSECFM(FLD,2)
124 ;
125 Q FLD
126 ;
127PROCDUR ;NCPDP 5.1 - The DUR/PPS segment can repeat itself for any given
128 ; transaction within a claim. This means we have to have special
129 ; programming to handle the repeating fields.
130 ;
131 ; Note that BPS array is set in BPSOSC* routines
132 ;
133 N FIELD,DUR,FLD,ORD
134 ;
135 ; If there isn't any data in this segment, then lets quit
136 Q:'$D(BPS(9002313.1001))
137 ;
138 ; Second thing - create the 111 field entry as it is not repeating
139 S FLDDATA=$$SEGID(NODE)
140 S SEGREC=SEGREC_$C(28)_FLDDATA ;FS always proceeds fld
141 ;
142 ; Next- let's look to the format to see which DUR/PPS fields are
143 ; needed (remember - ALL fields on the DUR/PPS segment are optional)
144 D GETFLDS^BPSOSHF(+IEN(9002313.92),NODE,.FIELD)
145 ;
146 ; Finally -loop through and process the fields for as many times
147 ; as they appear
148 S DUR=0
149 F S DUR=$O(BPS(9002313.1001,DUR)) Q:DUR="" D
150 . S ORD=0
151 . F S ORD=$O(FIELD(ORD)) Q:ORD="" D
152 .. S FLDIEN=$P(FIELD(ORD),U)
153 .. S FLD=$P(FIELD(ORD),U,2)
154 .. S:FLD=473 FLD=.01 ;473 value stored in the .01 field
155 .. S FDATA5=$G(^BPSF(9002313.91,FLDIEN,5)) ;5.1 id and length
156 .. S FLDID=$P(FDATA5,U,1) ;5.1 ID
157 .. ;
158 .. ; Transaction data
159 .. S FLDDATA=$G(BPS(9002313.1001,DUR,FLD,"I"))
160 .. ;
161 .. I FLDID'=$TR(FLDDATA,"0 {}") S DATAFND=1 ;fld chk-is the fld empty?
162 .. ;
163 .. S SEGREC=SEGREC_$C(28)_FLDDATA ;FS always proceeds fld
164 Q
Note: See TracBrowser for help on using the repository browser.