source: FOIAVistA/tag/r/PROSTHETICS-RMPR-RMPO-RMPS/RMPRPIU8.m@ 949

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

initial load of FOIAVistA 6/30/08 version

File size: 5.1 KB
Line 
1RMPRPIU8 ;HINCIO/ODJ - PIP STOCK RECEIPT UPDATE UTILITY ;3/8/01
2 ;;3.0;PROSTHETICS;**61**;Feb 09, 1996
3 Q
4 ;
5 ;***** REC - Create a Stock Receipt Transaction for existing item
6 ; Implements business rules for creating a receipt
7 ; of an existing PIP HCPCS Item.
8 ; called by RMPRPIYG,RMPRPIY6
9 ;
10 ; Inputs:
11 ; RMPR6 - Transaction (661.6) array elements
12 ; RMPR6("VENDOR") - Vendor ien
13 ; RMPR6("QUANTITY") - Receipt Quantity
14 ; RMPR6("VALUE") - Total $ value of received qty.
15 ; RMPR6("COMMENT") - (optional) comment
16 ;
17 ; RMPR11 - HCPCS Item (661.11) array elements
18 ; RMPR11("STATION") - Station ien
19 ; RMPR11("HCPCS") - HCPCS code
20 ; RMPR11("ITEM") - HCPCS Item number
21 ;
22 ; RMPR5 - Location (661.5) array elements...
23 ; RMPR5("IEN") - Location ien (ptr ^RMPR(661.5,)
24 ;
25 ; RMPRUPO - flag true=> update, false=> dont update orders
26 ; RMPR41 - array for orders
27 ;
28 ; Outputs:
29 ; RMPRERR - returned by function
30 ; 0 - no errors
31 ; 19 - problem creating 661.6 rec.
32 ; 29 - problem creating 661.7 rec.
33 ; 39 - problem creating 661.9 rec.
34 ; 49 - problem updating 661.41 orders
35 ;
36REC(RMPR6,RMPR11,RMPR5,RMPRUPO,RMPR41) ;
37 N RMPRERR,RMPR6I,RMPRDIEN,RMPR7,RMPR9,RMPR41N,RMPRTOD,X
38 S RMPRERR=0
39 D NOW^%DTC S RMPRTOD=X ;today's date
40 ;
41 ; Lock current stock to prevent simultaneous access at HCPCS Item level
42 L +^RMPR(661.7,"XSHIDS",RMPR11("STATION"),RMPR11("HCPCS"),RMPR11("ITEM"))
43 ;
44 ; init. data elements for 661.6 transaction rec.
45 S RMPR6("COMMENT")=$G(RMPR6("COMMENT"))
46 S RMPR6("SEQUENCE")=1
47 S RMPR6("TRAN TYPE")=1 ;receipt
48 S RMPR6("LOCATION")=RMPR5("IEN")
49 S RMPR6("USER")=$G(DUZ)
50 S RMPR6("DATE&TIME")=""
51 I RMPR6("QUANTITY")=0 G RECU
52 ;
53 ; Create 661.6 transaction rec.
54 S RMPRERR=$$CRE^RMPRPIX6(.RMPR6,.RMPR11)
55 I RMPRERR S RMPRERR=19 G RECU ;error 19 problem with 661.6
56 ;
57 ; Update 661.7 current stock rec.
58 S RMPR7("DATE&TIME")=RMPR6("DATE&TIME")
59 S RMPR7("SEQUENCE")=RMPR6("SEQUENCE")
60 S RMPR7("QUANTITY")=RMPR6("QUANTITY")
61 S RMPR7("VALUE")=RMPR6("VALUE")
62 S RMPR7("UNIT")=RMPR6("UNIT")
63 S RMPR7("LOCATION")=RMPR6("LOCATION")
64 S RMPRERR=$$CRE^RMPRPIX7(.RMPR7,.RMPR11)
65 I RMPRERR S RMPRERR=29 G RECU ;error 29 problem with 661.7 create
66 ;
67 ; Update 661.9 daily running balance record
68 S RMPR9("STA")=RMPR11("STATION")
69 S RMPR9("HCP")=RMPR11("HCPCS")
70 S RMPR9("ITE")=RMPR11("ITEM")
71 S RMPR9("RDT")=$P(RMPR6("DATE&TIME"),".",1)
72 S RMPR9("TQTY")=RMPR6("QUANTITY")
73 S RMPR9("TCST")=RMPR6("VALUE")
74 S RMPRERR=$$UPCR^RMPRPIXJ(.RMPR9)
75 I RMPRERR S RMPRERR=39 G RECU ;error 39 problem with 661.9
76 ;
77 ; Update the orders file
78 I RMPRUPO,+$G(RMPR41("IEN")) D
79 . I RMPR6("QUANTITY")'<RMPR41("BALANCE QTY") D
80 .. S RMPR41N("RECEIVE QTY")=RMPR41("ORDER QTY")
81 .. Q
82 . E D
83 .. S RMPR41N("RECEIVE QTY")=RMPR41("RECEIVE QTY")+RMPR6("QUANTITY")
84 .. Q
85 . S RMPR41N("STATUS")="R"
86 . S RMPR41N("ORDER QTY")=RMPR41("ORDER QTY")
87 . S RMPR41N("DATE RECEIVE")=RMPRTOD
88 . S RMPR41N("VENDOR")=RMPR41("VENDOR IEN")
89 . S RMPR41N("IEN")=RMPR41("IEN")
90 . S RMPRERR=$$UPD^RMPRPIXN(.RMPR41N,)
91 . Q
92 I RMPRERR S RMPRERR=49 G RECU ;error 49 problem updating 661.41 orders
93 ;
94 ; Exit points
95RECU L -^RMPR(661.7,"XSHIDS",RMPR11("STATION"),RMPR11("HCPCS"),RMPR11("ITEM"))
96RECX Q RMPRERR
97 ;
98 ;***** UPORD - Update Orders file for receipted item
99 ; reduce outstanding balance starting with earliest,
100 ; if outstanding balance reduced to 0 change status to R
101 ;
102 ; Inputs:
103 ; RMPRS - Station ien
104 ; RMPRH - HCPCS code
105 ; RMPRI - HCPCS Item number
106 ; RMPRQ - Received Quantity
107 ; RMPRV - Vendor ien
108 ;
109 ; Outputs:
110 ; RMPRERR - returned by function
111 ; 0 - no problems
112 ; 99 - problem with update
113 ;
114UPORD(RMPRS,RMPRH,RMPRI,RMPRQ,RMPRV) ;
115 N RMPRERR,RMPRD,RMPR41U,RMPR41,X,Y,RMPRTOD,RMPRX
116 S RMPRERR=0
117 D NOW^%DTC S RMPRTOD=X ;today's date
118 ;
119 ; loop on Order dates in chronologial order until receipt balance=0
120 ; process Open orders only and only those which match Vendor
121 S RMPRD=""
122 F S RMPRD=$O(^RMPR(661.41,"ASSHID",RMPRS,"O",RMPRH,RMPRI,RMPRD)) Q:RMPRD="" D Q:RMPRERR!(RMPRQ=0)
123 . S RMPRX=""
124 . F S RMPRX=$O(^RMPR(661.41,"ASSHID",RMPRS,"O",RMPRH,RMPRI,RMPRD,RMPRX)) Q:RMPRX="" D Q:RMPRERR!(RMPRQ=0)
125 .. S RMPR41("IEN")=RMPRX
126 .. S RMPRERR=$$GETI^RMPRPIXN(.RMPR41,)
127 .. Q:RMPR41("VENDOR")'=RMPRV
128 .. ;
129 .. ; balance less than or equal to received qty. so order completely
130 .. ; received
131 .. I RMPR41("BALANCE QTY")'>RMPRQ D
132 ... S RMPR41U("IEN")=RMPR41("IEN")
133 ... S RMPR41U("RECEIVE QTY")=RMPR41("ORDER QTY")
134 ... S RMPR41U("STATUS")="R" ;set status to received
135 ... S RMPR41U("DATE RECEIVE")=RMPRTOD ;set receive date to today
136 ... S RMPRQ=RMPRQ-RMPR41("BALANCE QTY")
137 ... S RMPRERR=$$UPD^RMPRPIXN(.RMPR41U,) ;update order
138 ... Q
139 .. ;
140 .. ; balance more than receipt balance so just add to received qty.
141 .. E D
142 ... S RMPR41U("IEN")=RMPR41("IEN")
143 ... S RMPR41U("RECEIVE QTY")=RMPR41("RECEIVE QTY")+RMPRQ
144 ... S RMPR41U("DATE RECEIVE")=RMPRTOD ;set receive date to today
145 ... S RMPRERR=$$UPD^RMPRPIXN(.RMPR41U,) ;update order
146 ... S RMPRQ=0
147 ... Q
148 .. Q
149 . Q
150 I RMPRERR S RMPRERR=99 ; problem occurred
151UPORDX Q RMPRERR
Note: See TracBrowser for help on using the repository browser.