Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: RMPRPIUA

RMPRPIUA.m

Go to the documentation of this file.
  1. RMPRPIUA ;HINCIO/ODJ - APIs for file 661.7 ;3/8/01
  1. ;;3.0;PROSTHETICS;**61**;Feb 09, 1996
  1. Q
  1. ;
  1. ; SCAN - If scanned an item's barcode locate record from
  1. ; Prosthetic Current Stock file 661.7
  1. ;
  1. ; Inputs:
  1. ; RMPR7 - array containing...
  1. ; RMPR7("STATION") - Station ien
  1. ; RMPR7("HCPCS") - HCPCS code (contained in bar code)
  1. ; RMPR7("DATE&TIME") - Date&Time (contained in bar code)
  1. ;
  1. ; Outputs:
  1. ; RMPR7 - complete array for the 661.7 record read (if any)...
  1. ; RMPR7("IEN")
  1. ; RMPR7("STATION") - Station Name
  1. ; (nb will now be in external form)
  1. ; RMPR7("HCPCS") -
  1. ; RMPR7("SEQUENCE") -
  1. ; RMPR7("HCPCS ITEM") -
  1. ; RMPR7("LOCATION") -
  1. ; RMPR7("QUANTITY") -
  1. ; RMPR7("VALUE") -
  1. ; RMPR7("UNIT") -
  1. ;
  1. ; RMPREXC - exit condition
  1. ; 0 - normal, everything ok
  1. ; 1 - multi-instance but with station match (RMPR7 set)
  1. ; 2 - single instance but with
  1. ; station mis-match (RMPR7 set)
  1. ; 3 - multi-instance and station mis-match (RMPR7 not set)
  1. ; RMPRERR - error code returned by function
  1. ; 0 - no error
  1. ; 1 - null HCPCS input
  1. ; 2 - null Date&Time entered
  1. ; 3 - corrupt file (sequence but no ien)
  1. ; 4 - corrupt file (ien but no record)
  1. ; 5 - error reading 661.7
  1. ; 99 - no instances found for input HCPCS and Date&Time
  1. SCAN(RMPR7,RMPREXC) ;
  1. N RMPRERR,RMPRC,RMPRSEQ,RMPRIEN,RMPRS,RMPRIEN1,RMPRIEN2,RMPRDTTM
  1. S RMPRERR=0
  1. S RMPREXC=0
  1. S RMPR7("STATION")=$G(RMPR7("STATION"))
  1. I $G(RMPR7("HCPCS"))="" S RMPRERR=1 G SCANX
  1. I $G(RMPR7("DATE&TIME"))="" S RMPRERR=2 G SCANX
  1. S RMPRDTTM=RMPR7("DATE&TIME")
  1. S RMPRC=0,RMPRIEN1="",RMPRIEN2="",RMPR7("IEN")=""
  1. S RMPRSEQ=""
  1. ;
  1. ; Get ien for current stock record
  1. ; Record number of instances for same HCPCS and Date&Time in
  1. ; RMPRC (more than 1 should be very, very rare)
  1. ; RMPRIEN1 is IEN for first instance
  1. ; RMPRIEN2 is ien for any instance with station ien matching input
  1. L +^RMPR(661.7,"XHDS",RMPR7("HCPCS"),RMPRDTTM)
  1. F S RMPRSEQ=$O(^RMPR(661.7,"XHDS",RMPR7("HCPCS"),RMPRDTTM,RMPRSEQ)) Q:RMPRSEQ="" D Q:RMPRERR
  1. . S RMPRIEN=$O(^RMPR(661.7,"XHDS",RMPR7("HCPCS"),RMPRDTTM,RMPRSEQ,""))
  1. . I RMPRIEN="" S RMPRERR=3 Q
  1. . I '$D(^RMPR(661.7,RMPRIEN,0)) S RMPRERR=4 Q
  1. . S RMPRS=^RMPR(661.7,RMPRIEN,0)
  1. . S RMPRC=RMPRC+1
  1. . S RMPR7("UNIT")=$P(RMPRS,U,9)
  1. . I RMPR7("STATION")=$P(RMPRS,"^",5) S RMPRIEN2=RMPRIEN
  1. . I RMPRC=1 S RMPRIEN1=RMPRIEN
  1. . Q
  1. I RMPRERR G SCANU
  1. I 'RMPRC S RMPRERR=99 G SCANU
  1. ;
  1. ; Set exit condition
  1. I RMPRC>1 D
  1. . I RMPRIEN2'="" S RMPR7("IEN")=RMPRIEN2,RMPREXC=1
  1. . E S RMPREXC=3
  1. . Q
  1. E D
  1. . I RMPRIEN2="" S RMPREXC=2
  1. . S RMPR7("IEN")=RMPRIEN1
  1. . Q
  1. I RMPR7("IEN")'="" D
  1. . S RMPRERR=$$GET^RMPRPIX7(.RMPR7)
  1. . I RMPRERR S RMPRERR=5
  1. . Q
  1. SCANU L -^RMPR(661.7,"XHDS",RMPR7("HCPCS"),RMPRDTTM)
  1. SCANX Q RMPRERR
  1. ;
  1. ; STOCK - For an entered Station, Location, HCPCS and Item return
  1. ; total quantity on hand for that item, the average unit cost
  1. ; and the vendor. If more than one vendor, use the first one.
  1. ;
  1. ; Inputs:
  1. ; RMPR - an array with the following elements...
  1. ; RMPR("STATION IEN") - Station ien (ptr ^DIC(4,)
  1. ; RMPR("LOCATION IEN") - Location ien (ptr ^RMPR(661.5,)
  1. ; RMPR("HCPCS") - HCPCS code (eg E0111)
  1. ; RMPR("ITEM") - HCPCS Item number (eg 1)
  1. ;
  1. ; Outputs:
  1. ; RMPR - additional elements to the input RMPR array
  1. ; RMPR("QOH") - Quantity on hand
  1. ; RMPR("UNIT COST") - Unit cost per Item
  1. ; RMPR("VENDOR") - Vendor Name
  1. ; RMPR("VENDOR IEN") - Vendor ien
  1. ;
  1. ; RMPRERR - function return...
  1. ; 0 - no errors
  1. ; 1 - null Station ien input
  1. ; 2 - null Location ien input
  1. ; 3 - null HCPCS code input
  1. ; 4 - null Item input
  1. ; 5 - problem with 661.7 file
  1. ; 6 - problem with 661.6 file
  1. STOCK(RMPR) ;
  1. N RMPRERR,RMPRK,RMPROLD,RMPREOF,RMPR7,RMPR6,RMPRTCST
  1. S RMPRERR=0
  1. S RMPRTCST=0
  1. S RMPR("QOH")=0
  1. S RMPR("UNIT COST")=0
  1. S RMPR("VENDOR")=""
  1. S RMPR("VENDOR IEN")=""
  1. S RMPRK("STATION")=$G(RMPR("STATION IEN"))
  1. I RMPRK("STATION")="" S RMPRERR=1 G STOCKX
  1. S RMPRK("LOCATION")=$G(RMPR("LOCATION IEN"))
  1. I RMPRK("LOCATION")="" S RMPRERR=2 G STOCKX
  1. S RMPRK("HCPCS")=$G(RMPR("HCPCS"))
  1. I RMPRK("HCPCS")="" S RMPRERR=3 G STOCKX
  1. S RMPRK("ITEM")=$G(RMPR("ITEM"))
  1. I RMPRK("ITEM")="" S RMPRERR=4 G STOCKX
  1. L +^RMPR(661.7,"XSLHIDS",RMPR("STATION IEN"),RMPR("LOCATION IEN"),RMPR("HCPCS"),RMPR("ITEM"))
  1. ;
  1. ; Loop on all records for Stn, Loc, HCPCS and Item, and sum qty and cst
  1. STOCKA S RMPRERR=$$NEXT^RMPRPIXE(.RMPRK,"XSLHIDS","",1,.RMPROLD,.RMPREOF)
  1. I RMPRERR S RMPRERR=5 G STOCKU
  1. I RMPREOF G STOCKU
  1. I RMPRK("ITEM")'=RMPROLD("ITEM") G STOCKU
  1. I RMPRK("HCPCS")'=RMPROLD("HCPCS") G STOCKU
  1. I RMPRK("LOCATION")'=RMPROLD("LOCATION") G STOCKU
  1. I RMPRK("STATION")'=RMPROLD("STATION") G STOCKU
  1. K RMPR7 M RMPR7=RMPRK
  1. S RMPRERR=$$GET^RMPRPIX7(.RMPR7)
  1. I RMPRERR S RMPRERR=5 G STOCKU
  1. S RMPR("QOH")=RMPR7("QUANTITY")+RMPR("QOH")
  1. S RMPRTCST=RMPRTCST+RMPR7("VALUE")
  1. I RMPR("VENDOR IEN")="" D G:RMPRERR STOCKU
  1. . K RMPR6 M RMPR6=RMPRK S RMPR6("IEN")=""
  1. . S RMPRERR=$$GET^RMPRPIX6(.RMPR6)
  1. . I RMPRERR S RMPRERR=6 Q
  1. . S RMPRERR=$$VNDIEN^RMPRPIX6(.RMPR6)
  1. . I RMPRERR S RMPRERR=6 Q
  1. . S RMPR("VENDOR")=RMPR6("VENDOR")
  1. . S RMPR("VENDOR IEN")=RMPR6("VENDOR IEN")
  1. . Q
  1. G STOCKA
  1. STOCKU L -^RMPR(661.7,"XSLHIDS",RMPR("STATION IEN"),RMPR("LOCATION IEN"),RMPR("HCPCS"),RMPR("ITEM"))
  1. I RMPR("QOH") S RMPR("UNIT COST")=RMPRTCST/RMPR("QOH")
  1. STOCKX Q RMPRERR