source: WorldVistAEHR/trunk/r/IFCAP-PRC-PRX--PRCA--PRCN/PRCV442A.m@ 1800

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

initial load of WorldVistAEHR

File size: 8.0 KB
Line 
1PRCV442A ;WOIFO/CC-GET PO VALUES TO SEND TO DYNAMED;1/29/05
2V ;;5.1;IFCAP;**81,86**;Oct 20, 2000
3 ;Per VHA Directive 10-93-142, this routine should not be modified.
4 Q
5 ;
6ITEM(POIEN,PRCVLINE,PRCVDATA,PRCVERR) ; Get Item data to send to DynaMed
7 ;
8 ; POIEN = the ien of the purchase order
9 ; PRCVLINE = the ien of the line item number in the purchase order
10 ; PRCVDATA = information from the PO level to keep for reference
11 ; 2237 number ^ expected delivery date
12 ; PRCVERR = flag to indicate if the item is not qualified for
13 ; transmission to DynaMed as it has no DM DOC ID or an
14 ; error occurred
15 ;
16 N PRCV,PRCVDD,PRCVL,PRCVI
17 S PRCVDD="",PRCVERR=0,PRCVI=PRCVLINE_","_POIEN_","
18 D GETS^DIQ(442.01,PRCVI,".01;1.5;2;3;3.1;2;5;10;48","IE","PRCVL")
19 I $D(^TMP("DIERR",$J)) S PRCVERR=3 Q ; item not on file in PO
20 S $P(PRCV,"^",1)=PRCVL(442.01,PRCVI,48,"I") ; DM Doc ID (#48 N2P15)
21 I $P(PRCV,"^",1)']"" S PRCVERR=1 Q ; this is not a DM item
22 S $P(PRCV,"^",2)=PRCVL(442.01,PRCVI,1.5,"I") ; Item IEN (#1.5 N0 P5))
23 S $P(PRCV,"^",8)=$$GET1^DIQ(441,(PRCVL(442.01,PRCVI,1.5,"I")),51) ; NIF
24 S $P(PRCV,"^",3)=PRCVL(442.01,PRCVI,.01,"E") ; line item# #.01 n0,p1
25 S $P(PRCV,"^",6)=PRCVL(442.01,PRCVI,2,"I") ; QTY ORDERED (#2 N0 P 2)
26 S $P(PRCV,"^",5)=PRCVL(442.01,PRCVI,3,"E") ; UOP (#3 N 0 P 3)
27 S $P(PRCV,"^",9)=PRCVL(442.01,PRCVI,"3.1","E") ; pkg multiple (#3.1 N0 P12)
28 S $P(PRCV,"^",7)=PRCVL(442.01,PRCVI,5,"I") ; unit price (#5 N0 P 9)
29 S $P(PRCV,"^",4)=PRCVL(442.01,PRCVI,10,"E") ; 2237 IEN (#10 N0 P10)
30 I $P(PRCV,"^",4)']"" S $P(PRCV,"^",4)=$P(PRCVDATA,"^",1)
31 D DD(POIEN,PRCVL(442.01,PRCVI,.01,"E"),.PRCVDD) ; delivery date
32 S $P(PRCV,"^",13)=PRCVDD I PRCVDD="" S $P(PRCV,"^",13)=$P(PRCVDATA,"^",2)
33 S ^TMP("PRCV442A",$J,POIEN,PRCVLINE)=PRCV
34 ;
35 Q
36 ;
37DD(POIEN,PRCVLINE,PRCVDD) ; get the earliest delivery date for the item
38 ;
39 ; POIEN = the ien of the purchase order
40 ; PRCVLINE = the ien of the line item number in the purchase order
41 ; PRCVDD = the purchase order's expected delivery date
42 ;
43 N PRCVDS,PRCVDZ
44 S PRCVDZ="",PRCVDS=0
45 F S PRCVDS=$O(^PRC(442.8,"AC",POIEN,PRCVLINE,PRCVDS)) Q:+PRCVDS'>0!(PRCVDS']"") D
46 . S PRCVDZ=$P($G(^PRC(442.8,PRCVDS,0)),"^",3) ; get date from delivery schedule for item
47 . I PRCVDZ<PRCVDD S PRCVDD=PRCVDZ
48 . I PRCVDD']"" S PRCVDD=PRCVDZ
49 . Q
50 Q
51 ;
52PO(POIEN,PRCVDATA,PRCVERR) ; get PO information, station, DUZ
53 ;
54 ; POIEN = the ien of the purchase order
55 ; PRCVDATA = information from the PO level to keep for reference
56 ; 2237 number ^ expected delivery date
57 ; PRCVERR = flag to indicate if the order is not a qualified DynaMed
58 ; PO. 1 - indicates MOP is not suitable for a DM order
59 ;
60 N PRCV,PRCVV,PRCVP,PRCVPO
61 S PRCVERR=0,PRCVPO=POIEN_","
62 D GETS^DIQ(442,PRCVPO,".01;.02;.07;5;7;17;62","IE","PRCVP")
63 I $D(^TMP("DIERR",$J)) S PRCVERR=2 Q ; PO not on file
64 I PRCVP(442,PRCVPO,.02,"I")'=1,PRCVP(442,PRCVPO,.02,"I")'=25 S PRCVERR=1 Q ; MOP (#.02 - n0,p2)
65 S $P(PRCV,"^",1)=PRCVP(442,PRCVPO,.01,"E") ; PO# (#.01 n0,p1)
66 S $P(PRCV,"^",4)=PRCVP(442,PRCVPO,5,"I") ; vendor IEN (#5 n1 p1)
67 ; get FMS vendor ID & alt addr code from file 440, #34&#35 - n3 p4&5
68 D GETS^DIQ(440,PRCVP(442,PRCVPO,5,"I")_",","34:35","E","PRCVV")
69 I $D(^TMP("DIERR",$J)) G PO1 ; vendor info not on file
70 S $P(PRCV,"^",5)=PRCVV(440,PRCVP(442,PRCVPO,5,"I")_",",34,"E") ; FMS vendor ID
71 S $P(PRCV,"^",6)=PRCVV(440,PRCVP(442,PRCVPO,5,"I")_",",35,"E") ; FMA alt add ind
72PO1 S $P(PRCV,"^",7)=PRCVP(442,PRCVPO,17,"I") ; date signed (un-amended POs) n12 p3
73 S PRCVDATA=PRCVP(442,PRCVPO,62,"E") ; for PC orders MOP=25, 2237 is in #62 N23,P23
74 I PRCVDATA']"" S PRCVDATA=PRCVP(442,PRCVPO,.07,"E") ; for inv/rec MOP=1, 2237 is in #.07 - n0,p12
75 S $P(PRCVDATA,"^",2)=PRCVP(442,PRCVPO,7,"I") ; delivery date (#7 n0p10)
76 ;
77 ; get Station Number, DUZ
78 S $P(PRCV,"^",8)=$$GET1^DIQ(4,$$KSP^XUPARAM("INST")_",",99)
79 S $P(PRCV,"^",3)=DUZ
80 ;
81 S ^TMP("PRCV442A",$J,POIEN)=PRCV
82 Q
83 ;
84RR(POIEN,PRCVLINE,PRCVRR,PRCVERR,ACTION) ; get receipt data for item
85 ;
86 ; POIEN = the ien of the purchase order
87 ; PRCVLINE = the ien of the line item number in the purchase order
88 ; PRCVRR = the ien of the receiving report of interest
89 ; PRCVERR = flag to indicate if the order does not qualify for
90 ; transmission to DynaMed or error occurred
91 ; ACTION = flag 1 - approved report ; 2- deleted report
92 ;
93 N PRCV,PRCVI,PRCVDEL,PRCVR
94 S PRCVI=PRCVRR_","_PRCVLINE_","_POIEN_","
95 D GETS^DIQ(442.08,PRCVI,"1;2;3;4","I","PRCVR")
96 I $D(^TMP("DIERR",$J)) S PRCVERR=4 G RR2 ; RR not on file
97 S PRCVDEL="" I ACTION=2 S PRCVDEL="-"
98 S PRCV=$G(^TMP("PRCV442A",$J,POIEN,PRCVLINE))
99 S $P(PRCV,"^",10)=PRCVDEL_PRCVR(442.08,PRCVI,1,"I") ; qty received (#1, NO P2)
100 S $P(PRCV,"^",11)=PRCVDEL_PRCVR(442.08,PRCVI,2,"I") ; total item cost (#2 NO P3)
101 S $P(PRCV,"^",12)=PRCVDEL_PRCVR(442.08,PRCVI,4,"I") ; total discount for item(#4, N0 P5)
102 S ^TMP("PRCV442A",$J,POIEN,PRCVLINE)=PRCV
103RR2 Q
104 ;
105UPD(POIEN) ; Update DynaMed of Approved POs with DynaMed items on them
106 ;
107 ; POIEN The IEN of the Purchase Order
108 ;
109 N PRCVDATA,PRCVERR,PRCVLINE
110 S PRCVERR=0
111 K ^TMP("PRCV442A",$J)
112 D PO(POIEN,.PRCVDATA,.PRCVERR)
113 I PRCVERR=1 Q ; not a DynaMed order
114 I PRCVERR>0 S PRCVERR=PRCVERR_"U" G TMPERR Q
115 S PRCVLINE=0
116 F S PRCVLINE=$O(^PRC(442,POIEN,2,PRCVLINE)) Q:+PRCVLINE'>0!(PRCVLINE']"") D
117 . D ITEM(POIEN,PRCVLINE,PRCVDATA,.PRCVERR)
118 . I PRCVERR=1 Q
119 . I PRCVERR>0 S PRCVERR=PRCVERR_"U" D TMPERR Q
120 I $O(^TMP("PRCV442A",$J,POIEN,""))]"" D
121 . S $P(^TMP("PRCV442A",$J,POIEN),"^",2)=1
122 I $O(^TMP("PRCV442A",$J,POIEN,""))']"" S PRCVERR=1 D Q Q ; no item detail
123 D EN^PRCVPOSD(POIEN)
124 Q
125 ;
126DEL(POIEN) ; Update DynaMed of DynaMed items on a cancelled PC order
127 ;
128 ; POIEN The IEN of the Purchase Order
129 ;
130 N PRCVDATA,PRCVDDAT,PRCVERR,PRCVLINE
131 S PRCVERR=0
132 K ^TMP("PRCV442A",$J)
133 D PO(POIEN,.PRCVDATA,.PRCVERR)
134 I PRCVERR=1 Q
135 I PRCVERR>0 S PRCVERR=PRCVERR_"D" G TMPERR Q
136 S PRCVDDAT=$$NOW^XLFDT
137 S $P(^TMP("PRCV442A",$J,POIEN),"^",7)=PRCVDDAT
138 S PRCVLINE=0
139 S $P(^TMP("PRCV442A",$J,POIEN),"^",2)=5
140 F S PRCVLINE=$O(^PRC(442,POIEN,2,PRCVLINE)) Q:+PRCVLINE'>0!(PRCVLINE']"") D
141 . D ITEM(POIEN,PRCVLINE,PRCVDATA,.PRCVERR)
142 . I PRCVERR=1 Q
143 . I PRCVERR>0 S PRCVERR=PRCVERR_"D" D TMPERR Q
144 . D DELAUD^PRCV442B($P(^TMP("PRCV442A",$J,POIEN,PRCVLINE),"^",1),PRCVDDAT,DUZ,POIEN,$P(^TMP("PRCV442A",$J,POIEN,PRCVLINE),"^",3),"") ; update DynaMed audit file
145 I $O(^TMP("PRCV442A",$J,POIEN,""))']"" S PRCVERR=1 D Q Q ; no item detail
146 D EN^PRCVPOSD(POIEN)
147 Q
148 ;
149REC(POIEN,PARTIAL,ACTION) ; Update DynaMed of Receiving Report activity
150 ;
151 ; POIEN The IEN of the Purchase Order
152 ; PARTIAL The number of the Receiving Report
153 ; ACTION 1-signed ; 2-deleted
154 ;
155 N PRCV,PRCVDAT,PRCVERR,PRCVLINE,PRCVRR,PRCVDATA,PRCVSIG
156 S PRCVSIG=$$GET1^DIQ(442.11,(PARTIAL_","_POIEN_","),10,"I") ;WH D/T signed (#10 n0p11)
157 I PRCVSIG']"" Q ; send only signed RR
158 ; Find all the items in the RR, get the fields needed
159 K ^TMP("PRCV442A",$J)
160 S PRCVERR=0
161 D PO(POIEN,.PRCVDATA,.PRCVERR)
162 I PRCVERR=1 D Q Q ; order has MOP not used for DynaMed items
163 I PRCVERR>0 S PRCVERR=PRCVERR_ACTION D TMPERR Q
164 S PRCVDAT=$$NOW^XLFDT ; use for deletions
165 S PRCVLINE=0
166 F S PRCVLINE=$O(^PRC(442,POIEN,2,PRCVLINE)) Q:+PRCVLINE'>0!(PRCVLINE']"") D
167 . S PRCVRR=0
168 . F S PRCVRR=$O(^PRC(442,POIEN,2,PRCVLINE,3,PRCVRR)) Q:+PRCVRR'>0!(PRCVRR']"") I $P(^PRC(442,POIEN,2,PRCVLINE,3,PRCVRR,0),"^",4)=PARTIAL D
169 . . D ITEM(POIEN,PRCVLINE,PRCVDATA,.PRCVERR)
170 . . I PRCVERR=1 Q ; this is not a DM item
171 . . I PRCVERR>0 S PRCVERR=PRCVERR_ACTION D TMPERR Q
172 . . D RR(POIEN,PRCVLINE,PRCVRR,.PRCVERR,ACTION)
173 . . I ACTION=2 S PRCV=$G(^TMP("PRCV442A",$J,POIEN,PRCVLINE)) D RRAUD^PRCV442B(POIEN,PRCV,PRCVSIG,PRCVDAT)
174 . . I PRCVERR>1 S PRCVERR=PRCVERR_ACTION D TMPERR ; sends blanks to DM?
175 I $O(^TMP("PRCV442A",$J,POIEN,""))]"" D
176 . S $P(^TMP("PRCV442A",$J,POIEN),"^",7)=$S(ACTION=2:PRCVDAT,1:PRCVSIG)
177 . S $P(^TMP("PRCV442A",$J,POIEN),"^",2)=$S(ACTION=2:4,1:3)
178 . D EN^PRCVPOSD(POIEN)
179 I $O(^TMP("PRCV442A",$J,POIEN,""))']"" S PRCVERR=1 D Q ; no item detail
180 Q
181 ;
182TMPERR ;
183 ; D TMPERR^PRCV442B
184 Q
185 ;
186Q I PRCVERR K ^TMP("PRCV442A",$J)
187 Q
Note: See TracBrowser for help on using the repository browser.