source: WorldVistAEHR/trunk/r/PROSTHETICS-RMPR-RMPO-RMPS/RMPRPIUB.m@ 1520

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

initial load of WorldVistAEHR

File size: 3.0 KB
RevLine 
[613]1RMPRPIUB ;HINCIO/ODJ - APIs for file 661.7 ;3/8/01
2 ;;3.0;PROSTHETICS;**61**;Feb 09, 1996
3 Q
4 ;
5 ;
6 ; Inputs:
7 ; RMPR - an array with the following elements...
8 ; RMPR("STATION IEN") - Station ien (ptr ^DIC(4,)
9 ; RMPR("LOCATION IEN") - Location ien (ptr ^RMPR(661.5,)
10 ; RMPR("HCPCS") - HCPCS code (eg E0111)
11 ; RMPR("ITEM") - HCPCS Item number (eg 1)
12 ; RMPR("ISSUED QTY") - Quantity Issued
13 ; RMPR("ISSUED VALUE") - Issue Value
14 ;
15 ; RMPRERR - function return...
16 ; 0 - no errors
17 ; 1 - null Station ien input
18 ; 2 - null Location ien input
19 ; 3 - null HCPCS code input
20 ; 4 - null Item input
21 ; 5 - issued qty not greater than 0
22 ; 6 - problem with 661.7 file
23FIFO(RMPR) ;
24 N RMPRERR,RMPRK,RMPROLD,RMPREOF,RMPR7,RMPR7I,RMPRIBAL,RMPRVBAL
25 N RMPRUVAL
26 S RMPRERR=0
27 S RMPRK("STATION")=$G(RMPR("STATION IEN"))
28 I RMPRK("STATION")="" S RMPRERR=1 G FIFOX
29 S RMPRK("LOCATION")=$G(RMPR("LOCATION IEN"))
30 I RMPRK("LOCATION")="" S RMPRERR=2 G FIFOX
31 S RMPRK("HCPCS")=$G(RMPR("HCPCS"))
32 I RMPRK("HCPCS")="" S RMPRERR=3 G FIFOX
33 S RMPRK("ITEM")=$G(RMPR("ITEM"))
34 S RMPRK("IEN")=$G(RMPR("IEN"))
35 S RMPRK("DATE&TIME")=$G(RMPR("DATE&TIME"))
36 I RMPRK("ITEM")="" S RMPRERR=4 G FIFOX
37 I '+$G(RMPR("ISSUED QTY")) S RMPRERR=5 G FIFOX
38 S RMPRIBAL=RMPR("ISSUED QTY") ; init issued qty. balance
39 S RMPRVBAL=+$G(RMPR("ISSUED VALUE")) ; init issue value balance
40 S RMPRUVAL=RMPRVBAL/RMPRIBAL ; unit cost per issued item
41 L +^RMPR(661.7,"XSLHIDS",RMPR("STATION IEN"),RMPR("LOCATION IEN"),RMPR("HCPCS"),RMPR("ITEM"))
42 G PASS
43 ;
44 ; Loop on all records for Stn, Loc, HCPCS and Item until stock
45 ; depleted by the issued amount
46FIFOA S RMPRERR=$$NEXT^RMPRPIXE(.RMPRK,"XSLHIDS","",1,.RMPROLD,.RMPREOF)
47 I RMPRERR S RMPRERR=6 G FIFOU
48 I RMPREOF G FIFOU
49 I RMPRK("ITEM")'=RMPROLD("ITEM") G FIFOU
50 I RMPRK("HCPCS")'=RMPROLD("HCPCS") G FIFOU
51 I RMPRK("LOCATION")'=RMPROLD("LOCATION") G FIFOU
52 I RMPRK("STATION")'=RMPROLD("STATION") G FIFOU
53PASS K RMPR7 M RMPR7=RMPRK
54 S RMPRERR=$$GET^RMPRPIX7(.RMPR7) ; read in current stock rec.
55 I RMPRERR S RMPRERR=6 G FIFOU
56 K RMPR7I
57 S RMPR7I("IEN")=RMPR7("IEN")
58 S RMPR7I("QUANTITY")=RMPR7("QUANTITY")
59 S RMPR7I("VALUE")=RMPR7("VALUE")
60 ;
61 ; If issued balance less than on-hand quantity then update
62 ; the on-hand record
63 I RMPRIBAL<RMPR7I("QUANTITY") D
64 . S RMPR7I("QUANTITY")=RMPR7I("QUANTITY")-RMPRIBAL
65 . S RMPR7I("VALUE")=RMPR7I("VALUE")-RMPRVBAL
66 . S RMPRERR=$$UPD^RMPRPIX7(.RMPR7I,)
67 . S RMPRIBAL=0
68 . Q
69 ;
70 ; If issued balance not less than on-hand quantity the delete
71 ; the on-hand record
72 E D
73 . S RMPRIBAL=RMPRIBAL-RMPR7I("QUANTITY")
74 . S RMPRVBAL=RMPRVBAL-($J(RMPR7I("QUANTITY")*RMPRUVAL,0,2))
75 . S RMPRERR=$$DEL^RMPRPIX7(.RMPR7I)
76 . Q
77 I RMPRERR S RMPRERR=6 G FIFOU
78 G:RMPRIBAL FIFOA ; next stock rec. if still got issue balance
79 ;
80 ; exit points
81FIFOU L -^RMPR(661.7,"XSLHIDS",RMPR("STATION IEN"),RMPR("LOCATION IEN"),RMPR("HCPCS"),RMPR("ITEM"))
82FIFOX Q RMPRERR
Note: See TracBrowser for help on using the repository browser.