1 | RMPRPIUH ;HINCIO/ODJ - CONVERT OLD PIP TO NEW PIP ;3/8/05 11:45
|
---|
2 | ;;3.0;PROSTHETICS;**61**;Feb 09, 1996
|
---|
3 | ; DBIA #10090 - Read Access to entire file #4.
|
---|
4 | Q
|
---|
5 | ;
|
---|
6 | ;***** CONV - Convert old PIP files to the new design
|
---|
7 | ; continued from RMPRPIUG
|
---|
8 | ; Create issue transactions
|
---|
9 | ;
|
---|
10 | ; Convert patient issues in 660 file
|
---|
11 | ;
|
---|
12 | ; Start loop at 1st date in 661.2
|
---|
13 | CONV N RMPRDT,RMPRIEN,RMPRR60,RMPR62P,RMPRREC,RMPR6,RMPR11,RMPR62R,RMPRITM
|
---|
14 | N RMPR63P,RMPR63R,RMPR5,RMPRHIEN,RMPRS,RMPRERR,RMPRTIME,RMPR60
|
---|
15 | I '$D(IO("Q")) D
|
---|
16 | . W !,"Creating patient issue transactions - file 661.6 "
|
---|
17 | . Q
|
---|
18 | K ^TMP($J,"ISS")
|
---|
19 | S RMPRDT=$O(^RMPR(661.2,"B",""))
|
---|
20 | I RMPRDT'="" S RMPRDT=RMPRDT-1
|
---|
21 | ;
|
---|
22 | ; Loop on ENTRY DATE ('B') x-ref in 660 file
|
---|
23 | CONV1 S RMPRDT=$O(^RMPR(660,"B",RMPRDT))
|
---|
24 | I '$D(IO("Q")) D
|
---|
25 | . W:$X=79 ! W "."
|
---|
26 | . Q
|
---|
27 | I RMPRDT="" G CONVX
|
---|
28 | S RMPRIEN=0
|
---|
29 | CONV2 S RMPRIEN=$O(^RMPR(660,"B",RMPRDT,RMPRIEN))
|
---|
30 | I '+RMPRIEN G CONV1
|
---|
31 | ;
|
---|
32 | ; read 660 recs and set up arrays
|
---|
33 | K RMPR60
|
---|
34 | S RMPR60("IEN")=RMPRIEN
|
---|
35 | S RMPRR60=$G(^RMPR(660,RMPRIEN,1))
|
---|
36 | S RMPR62P=$P(RMPRR60,"^",5) ;pointer to 661.2
|
---|
37 | I RMPR62P="" G CONV2 ;ignore if null ptr.
|
---|
38 | I '$D(^RMPR(661.2,RMPR62P)) G CONV2 ;ignore if invalid ptr.
|
---|
39 | S RMPRREC=$G(^RMPR(660,RMPRIEN,0))
|
---|
40 | K RMPR6
|
---|
41 | I RMPRDT'=$P(RMPRREC,"^",1) G CONV2 ;bad 'B' x-ref
|
---|
42 | S RMPR6("QUANTITY")=+$P(RMPRREC,"^",7)
|
---|
43 | I RMPR6("QUANTITY")=0 G CONV2 ;ignore if 0 qty
|
---|
44 | S RMPR6("VALUE")=$P(RMPRREC,"^",16)
|
---|
45 | S RMPR6("VENDOR")=$P(RMPRREC,"^",9)
|
---|
46 | I RMPR6("VENDOR")="" G CONV2 ;ignore if null vendor
|
---|
47 | S RMPR6("USER")=$P(RMPRREC,"^",27)
|
---|
48 | ;
|
---|
49 | ; Get HCPCS and HCPCS Item using file 661.2
|
---|
50 | S RMPR62R=$G(^RMPR(661.2,RMPR62P,0))
|
---|
51 | S RMPR60("661.2PTR")=RMPR62P
|
---|
52 | K RMPR11
|
---|
53 | S RMPR11("ITEM MASTER IEN")=$P(RMPRREC,"^",6)
|
---|
54 | S RMPR11("STATION")=$P(RMPR62R,"^",15)
|
---|
55 | I RMPR11("STATION")="" G CONV2 ;ignore if null station
|
---|
56 | I '$D(^DIC(4,RMPR11("STATION"),0)) G CONV2 ;ignore if bad ptr
|
---|
57 | S RMPR11("HCPCS")=$P($P(RMPR62R,"^",9),"-",1) ;HCPCS Code
|
---|
58 | I RMPR11("HCPCS")="" G CONV2 ;ignore if null HCPCS
|
---|
59 | S RMPRHIEN=$P(RMPR62R,"^",4) ;HCPCS ptr
|
---|
60 | I RMPRHIEN="" G CONV2 ;ignore if null HCPCS ptr
|
---|
61 | S RMPRITM=$P($P(RMPR62R,"^",9),"-",2) ;Item ptr
|
---|
62 | I RMPRITM="" G CONV2 ;ignore if null item
|
---|
63 | S RMPR11("SOURCE")=$P(RMPR62R,"^",3)
|
---|
64 | I RMPR11("SOURCE")'="V" S RMPR11("SOURCE")="C"
|
---|
65 | S RMPR11("UNIT")=$P(RMPR62R,"^",5)
|
---|
66 | D GETITM(.RMPR11,RMPRHIEN,RMPRITM)
|
---|
67 | ;
|
---|
68 | ; Get Location
|
---|
69 | K RMPR5
|
---|
70 | S RMPR63P=$P(RMPR62R,"^",16) ;ptr to location 661.3 file
|
---|
71 | S RMPR5("STATION")=RMPR11("STATION")
|
---|
72 | S RMPRERR=$$GETLCN(RMPR63P,.RMPR5) ; get location
|
---|
73 | I RMPRERR G CONV2 ;ignore if bad location
|
---|
74 | ;
|
---|
75 | ; If get here then enough to create a stock issue to patient
|
---|
76 | ; transaction...
|
---|
77 | S RMPR6("DATE&TIME")=""
|
---|
78 | F D Q:RMPR6("DATE&TIME")'=""
|
---|
79 | . D NOW^%DTC
|
---|
80 | . S RMPRTIME=RMPRDT_"."_$P(%,".",2)
|
---|
81 | . I $D(^RMPR(661.6,"XHDS",RMPR11("HCPCS"),RMPRTIME)) H (1+$R(3)) Q
|
---|
82 | . L +^RMPR(661.6,"XHDS",RMPR11("HCPCS"),RMPRTIME):0 E H (1+$R(3)) Q
|
---|
83 | . S RMPR6("DATE&TIME")=RMPRTIME
|
---|
84 | . Q
|
---|
85 | S RMPR6("LOCATION")=RMPR5("IEN")
|
---|
86 | S RMPRS=$G(^TMP($J,"ISS",RMPR11("STATION"),RMPR11("HCPCS"),RMPR11("ITEM"),RMPR6("LOCATION"),RMPR6("VENDOR")))
|
---|
87 | S $P(RMPRS,"^",1)=RMPR6("QUANTITY")+$P(RMPRS,"^",1)
|
---|
88 | S $P(RMPRS,"^",2)=RMPR6("VALUE")+$P(RMPRS,"^",2)
|
---|
89 | S ^TMP($J,"ISS",RMPR11("STATION"),RMPR11("HCPCS"),RMPR11("ITEM"),RMPR6("LOCATION"),RMPR6("VENDOR"))=RMPRS
|
---|
90 | S RMPR6("SEQUENCE")=1
|
---|
91 | S RMPR6("COMMENT")=""
|
---|
92 | S RMPR6("TRAN TYPE")=3
|
---|
93 | S RMPRERR=$$CRE^RMPRPIX6(.RMPR6,.RMPR11)
|
---|
94 | S $P(RMPRR60,"^",5)=RMPR6("IEN")
|
---|
95 | S ^RMPR(660,RMPRIEN,1)=RMPRR60
|
---|
96 | L -^RMPR(661.6,"XHDS",RMPR11("HCPCS"),RMPR6("DATE&TIME"))
|
---|
97 | ;
|
---|
98 | ; Create 661.63 Patient Issue transaction record
|
---|
99 | S RMPRERR=$$CRE^RMPRPIX3(.RMPR60,.RMPR6,.RMPR11)
|
---|
100 | ;
|
---|
101 | ; Next rec
|
---|
102 | G CONV2
|
---|
103 | ;
|
---|
104 | ; Exit
|
---|
105 | CONVX Q
|
---|
106 | ;
|
---|
107 | ; Get a Location from the pointer to file 661.3
|
---|
108 | ; RMPRPIUJ should have been already run to set up the new locations
|
---|
109 | ; file 661.5 and the temp map file.
|
---|
110 | ; If can't get a valid location default to the GENERIC location
|
---|
111 | GETLCN(RMPR63P,RMPR5) ;
|
---|
112 | N RMPRERR
|
---|
113 | S RMPRERR=0
|
---|
114 | I RMPR63P="" S RMPRERR=1 G GETLCNX
|
---|
115 | I '$D(^RMPR(661.5,"XSL",RMPR5("STATION"))) S RMPRERR=2 G GETLCNX
|
---|
116 | ;
|
---|
117 | ; if old (661.3) pointer mapped to new (661.5) pointer use it
|
---|
118 | I $D(^TMP($J,"LOCN",RMPR63P)) D G GETLCNX
|
---|
119 | . S RMPR5("IEN")=^TMP($J,"LOCN",RMPR63P)
|
---|
120 | . Q
|
---|
121 | ;
|
---|
122 | ; else use the 661.5 pointer for GENERIC location
|
---|
123 | E D
|
---|
124 | . S RMPR5("IEN")=$O(^RMPR(661.5,"XSL",RMPR5("STATION"),"GENERIC",""))
|
---|
125 | . Q
|
---|
126 | GETLCNX Q RMPRERR
|
---|
127 | ;
|
---|
128 | ; Get HCPCS Item
|
---|
129 | ; Commercial items should have already been set up by running
|
---|
130 | ; RMPRPIUI
|
---|
131 | ; VA items and those items in 661.2 which are no longer in the 661.3
|
---|
132 | ; file will be created together with a map of old to new iens.
|
---|
133 | GETITM(RMPR11,RMPRHIEN,RMPRITM) ;
|
---|
134 | N RMPRI,RMPRS,RMPRERR,RMPRIM,RMPR11U,RMPRGOT
|
---|
135 | S RMPR11("ITEM MASTER IEN")=$G(RMPR11("ITEM MASTER IEN"))
|
---|
136 | S RMPRIM=RMPR11("ITEM MASTER IEN")
|
---|
137 | S:RMPRIM="" RMPRIM="*"
|
---|
138 | ;
|
---|
139 | ; If item has new number from previous update then use the temp map
|
---|
140 | I $D(^TMP($J,"ITEM",RMPRHIEN,RMPRITM,RMPR11("SOURCE"),RMPRIM)) D G GETITMX
|
---|
141 | . S RMPRS=^TMP($J,"ITEM",RMPRHIEN,RMPRITM,RMPR11("SOURCE"),RMPRIM)
|
---|
142 | . S RMPR11("ITEM")=$P(RMPRS,"^",3)
|
---|
143 | . Q
|
---|
144 | ;
|
---|
145 | ; If item number not already in use then can use it to create a new
|
---|
146 | ; item in file 661.11
|
---|
147 | I '$D(^RMPR(661.11,"ASHI",RMPR11("STATION"),RMPR11("HCPCS"),RMPRITM)) S RMPR11("ITEM")=RMPRITM G GETITM1
|
---|
148 | ;
|
---|
149 | ; Ensure not duplicating Item number for different source
|
---|
150 | S RMPRGOT=0
|
---|
151 | S RMPRI=$O(^RMPR(661.11,"ASHI",RMPR11("STATION"),RMPR11("HCPCS"),RMPRITM,""))
|
---|
152 | S RMPRS=^RMPR(661.11,RMPRI,0)
|
---|
153 | I $P(RMPRS,"^",5)=RMPR11("SOURCE") D
|
---|
154 | . I $P(RMPRS,"^",8)=RMPR11("ITEM MASTER IEN") S RMPRGOT=1 Q
|
---|
155 | . I $P(RMPRS,"^",8)="" D
|
---|
156 | .. K RMPR11U
|
---|
157 | .. S RMPR11U("IEN")=RMPRI
|
---|
158 | .. S RMPR11U("ITEM MASTER IEN")=RMPR11("ITEM MASTER IEN")
|
---|
159 | .. S RMPRERR=$$UPD^RMPRPIX1(.RMPR11U)
|
---|
160 | .. S RMPRGOT=1
|
---|
161 | .. Q
|
---|
162 | . Q
|
---|
163 | I RMPRGOT S RMPR11("ITEM")=RMPRITM G GETITMX
|
---|
164 | S RMPR11("ITEM")="" ; ensure new item will be created
|
---|
165 | GETITM1 S RMPRS=$G(^RMPR(661.1,RMPRHIEN,3,RMPRITM,0))
|
---|
166 | S RMPR11("DESCRIPTION")=$P(RMPRS,"^",1)
|
---|
167 | S:RMPR11("DESCRIPTION")="" RMPR11("DESCRIPTION")="NO DESCRIPTION"
|
---|
168 | S RMPRERR=$$CRE^RMPRPIX1(.RMPR11)
|
---|
169 | ;
|
---|
170 | ; map new HCPCS Item in 661.11 to old iens in 661.1
|
---|
171 | S RMPRS=""
|
---|
172 | S $P(RMPRS,"^",1)=RMPR11("STATION")
|
---|
173 | S $P(RMPRS,"^",2)=RMPR11("HCPCS")
|
---|
174 | S $P(RMPRS,"^",3)=RMPR11("ITEM")
|
---|
175 | S $P(RMPRS,"^",4)=RMPR11("IEN")
|
---|
176 | S ^TMP($J,"ITEM",RMPRHIEN,RMPRITM,RMPR11("SOURCE"),RMPRIM)=RMPRS
|
---|
177 | GETITMX Q
|
---|