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

PRCPOPP.m

Go to the documentation of this file.
  1. PRCPOPP ;WISC/RFJ-post distribution order; ; 8/4/99 1:05pm
  1. V ;;5.1;IFCAP;**1,41**;Oct 20, 2000
  1. ;Per VHA Directive 10-93-142, this routine should not be modified.
  1. Q
  1. ;
  1. PRCPSS(ORDERDA,PRCPSECO,PRCPPRIM,PRCPSS) ; entry point for supply station
  1. ; ORDERDA order to be posted
  1. ; PRCPSECO secondary inventory point
  1. ; PRCPPRIM primary inventory point
  1. ; PRCPSS flag to designate supply station posting (value = 1)
  1. G PRCPSS0
  1. ;
  1. POST ; post order
  1. ; orderda=order number
  1. S VALMBCK="R"
  1. N PRCPSS S PRCPSS=0 ; posting is done at GIP
  1. ;
  1. PRCPSS0 N %,CONVFACT,DATA,ITEMDA,ITEMDATA,ORDRDATA,PRCPFLAG,PRCPID,PRCPOH,PRCPOPP,PRCPPORD,PRCPPTDA,PRCPSORD,QTYDUE,QUANTITY,TOTCOST,UNITCOST,XORDERDA,XDT
  1. ;
  1. ; Check for old orders
  1. S XORDERDA=0 F S XORDERDA=$O(^PRCP(445.3,XORDERDA)) Q:'XORDERDA Q:XORDERDA]"A" D
  1. . S XDT=$P($G(^PRCP(445.3,XORDERDA,0)),"^",9)
  1. . Q:'XDT
  1. . I XDT+2<DT D DELORDER^PRCPOPD(XORDERDA)
  1. . Q
  1. ;
  1. I PRCPSS G PRCPSS1 ; checks not valid for supply station posting
  1. ;
  1. W !!,"CHECKING ITEMS ON ORDER..."
  1. S (ITEMDA,PRCPFLAG)=0 F S ITEMDA=$O(^PRCP(445.3,ORDERDA,1,ITEMDA)) Q:'ITEMDA S QUANTITY=$P($G(^(ITEMDA,0)),"^",2) I QUANTITY D I PRCPFLAG Q
  1. . I $$ITEMCHK^PRCPOPER(PRCPPRIM,PRCPSECO,ITEMDA)'="" S PRCPFLAG=1 Q
  1. I PRCPFLAG S VALMSG="ORDER CANNOT BE POSTED - FIX ALL ERRORS FIRST" D CHECKORD^PRCPOPER Q
  1. W " NO ERRORS FOUND !",!
  1. ;
  1. I $P($G(^PRCP(445.3,ORDERDA,0)),"^",7)="" D Q:$G(PRCPFLAG)
  1. . S XP="Do you want to print the picking ticket before posting",XH="Enter YES to print the picking ticket, NO to skip printing it, or ^ to exit."
  1. . S %=$$YN^PRCPUYN(1) I %<1 S PRCPFLAG=1 Q
  1. . I %'=1 Q
  1. . D PICKLM^PRCPOPT
  1. ;
  1. S XP="Are you sure you want to POST this order to "_$$INVNAME^PRCPUX1(+$P($G(^PRCP(445.3,+ORDERDA,0)),"^",3)),XH="Enter 'YES' to start posting the order to the secondary inventory point",XH(1)="Enter 'NO' or '^' to exit."
  1. W ! I $$YN^PRCPUYN(1)'=1 Q
  1. ;
  1. L +^PRCP(445,PRCPPRIM,1):5
  1. I '$T D SHOWWHO^PRCPULOC(445,PRCPPRIM_"-1",0) Q
  1. L +^PRCP(445,PRCPSECO,1):5 I '$T D Q
  1. . L -^PRCP(445,PRCPPRIM,1)
  1. . D SHOWWHO^PRCPULOC(445,PRCPSECO_"-1",0)
  1. D ADD^PRCPULOC(445,PRCPPRIM_"-1",0,"Distribution Order Processing")
  1. D ADD^PRCPULOC(445,PRCPSECO_"-1",0,"Distribution Order Processing")
  1. ;
  1. W !,"POSTING DISTRIBUTION ORDER ..."
  1. ;
  1. ; if patient is on order, add entry
  1. PRCPSS1 ; use the same transaction register numbers fr the entire order
  1. S PRCPPORD=$$ORDERNO^PRCPUTRX(PRCPPRIM)
  1. S PRCPSORD=$$ORDERNO^PRCPUTRX(PRCPSECO)
  1. ;
  1. I $P($G(^PRCP(445.3,ORDERDA,2)),"^") S DATA=^(2) D
  1. . S PRCPPTDA=+$P(DATA,"^",3) I $D(^PRCP(446.1,PRCPPTDA,0)) Q
  1. . S PRCPPTDA=$$PATIENT^PRCPUPAT(+$P(DATA,"^"),+$P(DATA,"^",2))
  1. . I 'PRCPPTDA Q
  1. . S $P(^PRCP(445.3,ORDERDA,2),"^",3)=PRCPPTDA
  1. . S $P(^PRCP(446.1,PRCPPTDA,0),"^",6)=PRCPSECO
  1. ;
  1. ; store case carts and instrument kits in
  1. ; ^tmp($j,"prcpopccik",itemda)=qty for cc/ik item posting
  1. K ^TMP($J,"PRCPOPCCIK")
  1. ;
  1. ; post order
  1. S ITEMDA=0 F S ITEMDA=$O(^PRCP(445.3,ORDERDA,1,ITEMDA)) Q:'ITEMDA S ORDRDATA=$G(^(ITEMDA,0)) D
  1. . S (QTYDUE,QUANTITY)=$P(ORDRDATA,"^",2)
  1. . S PRCPOH=$P($G(^PRCP(445,PRCPPRIM,1,ITEMDA,0)),"^",7)
  1. . I PRCPOH+0=0 S PRCPOH=0
  1. . I QUANTITY>PRCPOH S QUANTITY=PRCPOH
  1. . I PRCPOH<0 S QUANTITY=0
  1. . I PRCPSS S QUANTITY=$P(ORDRDATA,"^",7) ; use qty that was stocked
  1. . ;
  1. . ; if case cart or instrument kit, set tmp global
  1. . I $D(^PRCP(445.7,ITEMDA,0))!($D(^PRCP(445.8,ITEMDA,0))) S:QUANTITY>0 ^TMP($J,"PRCPOPCCIK",ITEMDA)=QUANTITY Q
  1. . ;
  1. . S ITEMDATA=^PRCP(445,PRCPPRIM,1,ITEMDA,0)
  1. . S UNITCOST=+$P(ITEMDATA,"^",22) I 'UNITCOST S UNITCOST=+$P(ITEMDATA,"^",15)
  1. . I 'UNITCOST S UNITCOST=+$P(ORDRDATA,"^",3)
  1. . S TOTCOST=$J(QUANTITY*UNITCOST,0,2)
  1. . ;
  1. . ;
  1. . I QTYDUE'=0 D
  1. . . I 'PRCPSS!(PRCPSS&$D(^PRCP(445,PRCPPRIM,1,ITEMDA))) D
  1. . . . ; sell from primary
  1. . . . K PRCPOPP
  1. . . . S PRCPOPP("QTY")=-QUANTITY,PRCPOPP("DUEOUT")=-QTYDUE,PRCPOPP("INVVAL")=-TOTCOST,PRCPOPP("OTHERPT")=PRCPSECO,PRCPOPP("ORDERDA")=ORDERDA
  1. . . . D SALE^PRCPOPPP(PRCPPRIM,ITEMDA,PRCPPORD,.PRCPOPP)
  1. . . ;
  1. . . I 'PRCPSS!(PRCPSS&$D(^PRCP(445,PRCPSECO,1,ITEMDA))) D
  1. . . . ; receipt in secondary
  1. . . . S CONVFACT=$P($$GETVEN^PRCPUVEN(PRCPSECO,ITEMDA,PRCPPRIM_";PRCP(445,",1),"^",4)
  1. . . . K PRCPOPP
  1. . . . S PRCPOPP("QTY")=QUANTITY*CONVFACT,PRCPOPP("DUEIN")=-QTYDUE*CONVFACT,PRCPOPP("INVVAL")=TOTCOST,PRCPOPP("OTHERPT")=PRCPPRIM
  1. . . . ; if patient, distribute from secondary to patient
  1. . . . I $G(PRCPPTDA) S PRCPOPP("PRCPPTDA")=PRCPPTDA
  1. . . . D RECEIPT^PRCPOPPP(PRCPSECO,ITEMDA,PRCPSORD,.PRCPOPP)
  1. . . . Q
  1. . ;
  1. . ; Set quantity posted into item multiple
  1. . I 'PRCPSS S $P(^PRCP(445.3,ORDERDA,1,ITEMDA,0),"^",7)=QUANTITY
  1. ;
  1. ; Set up posted status
  1. S $P(^PRCP(445.3,ORDERDA,0),"^",6)="P",$P(^(0),"^",9)=DT
  1. ;
  1. ; if an item is a cc or ik
  1. I $O(^TMP($J,"PRCPOPCCIK",0)) D
  1. . ; if interactive, display screen to post items in cc and iks
  1. . I 'PRCPSS D EN^VALM("PRCP DIST ORDER CC/IK POSTING")
  1. . I PRCPSS D ; mark amount rec'd as 0, so user gets message
  1. . . N PRCPAMT
  1. . . S DIE="^PRCP(445.3,"_ORDERDA_",1,"
  1. . . S DA=PRCPITEM
  1. . . S PRCPAMT="@" ; delete entry to invoke bulletin to user
  1. . . S DR="6///^S X=PRCPAMT"
  1. . . D ^DIE K DIE
  1. . . Q
  1. . Q
  1. ;
  1. I 'PRCPSS D
  1. . D CLEAR^PRCPULOC(445,PRCPPRIM_"-1",0),CLEAR^PRCPULOC(445,PRCPSECO_"-1",0)
  1. . L -^PRCP(445,PRCPPRIM,1),-^PRCP(445,PRCPSECO,1)
  1. ;
  1. Q