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

PRCPHLPO.m

Go to the documentation of this file.
  1. PRCPHLPO ;WISC/CC-REFILL AND POST ORDER FROM 447.1 ENTRY ;4/00
  1. V ;;5.1;IFCAP;**1,24**;Oct 20, 2000
  1. ;Per VHA Directive 10-93-142, this routine should not be modified.
  1. ;
  1. PROCESS(PRCPDA,PRCPDONE) ;
  1. N CONV,DIE,DR,ERR,I,ITEM,LOCKORD,LOCKPRIM,ORDERDA,X,PRCPITDA,PRIM
  1. N PRCPAMT,PRCPDATA,PRCPHL7,PRCPITEM,PRCPITNM,PRCPLEFT,PRCPNOIT
  1. N PRCPORD,PRCPPOST,PRCPPRIM,PRCPSECO,PRCPSS,PRCPSSFL,PRCPTIME,PRCPUSER
  1. ;
  1. S PRCPDONE=0,LOCKORD=0,LOCKPRIM=0,ERR=0
  1. S PRCPDATA=^PRCP(447.1,PRCPDA,0)
  1. S PRCPHL7=$P(PRCPDATA,"^",6)_".447.1"
  1. S ORDERDA=$P(PRCPDATA,"^",7)
  1. S PRCPSECO=$P(PRCPDATA,"^",3)
  1. S PRCPTIME=$P(PRCPDATA,"^",8)
  1. S PRCPUSER=$P(PRCPDATA,"^",10)
  1. S PRCPPOST=$P(PRCPDATA,"^",11)
  1. ;
  1. L +^PRCP(445.3,ORDERDA):3 I $T=0 S PRCPDONE=0 Q
  1. D ADD^PRCPULOC(445.3,ORDERDA_"-1",0,"HL7 Distribution Order Processing")
  1. S LOCKORD=1
  1. ;
  1. I PRCPPOST'="FU" D I $D(ERR),+ERR>0 G ERR
  1. . S PRCPITDA=0
  1. . S PRCPITDA=$O(^PRCP(447.1,PRCPDA,1,PRCPITDA))
  1. . I '+PRCPITDA S ERR="6F" Q ; no item in transaction
  1. . S PRCPDATA=^PRCP(447.1,PRCPDA,1,PRCPITDA,0)
  1. . S PRCPITEM=$P(PRCPDATA,"^",1)
  1. . S PRCPAMT=$P(PRCPDATA,"^",3) ; REFILL QTY - restock issue units
  1. . S PRCPLEFT=$P(PRCPDATA,"^",2)
  1. . S PRCPITNM=$P(PRCPDATA,"^",4)
  1. ;
  1. I '$D(^PRCP(445.3,ORDERDA)) S ERR="2A" G ERR ; order not in GIP
  1. S PRCPPRIM=$P(^PRCP(445.3,ORDERDA,0),"^",2)
  1. I $P(^PRCP(445.3,ORDERDA,0),"^",6)="P" S ERR="2B" G ERR ; order is posted
  1. I $P(^PRCP(445.3,ORDERDA,0),"^",10)']"" S ERR="2C" G ERR ; order not to be completed by supply station
  1. I '$D(^PRCP(445,PRCPSECO)) S ERR="3A" G ERR ; secondary not in GIP
  1. I $P(^PRCP(445,PRCPSECO,0),"^",3)'="S" S ERR="3B" G ERR ; not a secondary
  1. I PRCPPOST="FU" D G:ERR>0 ERR G UPDATE
  1. . I $P($G(^PRCP(445,PRCPSECO,5)),"^",1)']"" S ERR="3F" ; not a supply station secondary
  1. ;
  1. I PRCPITDA']"" S ERR="6F" G ERR ; no item information
  1. I '$D(^PRCP(445.3,ORDERDA,1,PRCPITEM)) S ERR="6A" G ERR ; not on the GIP order"
  1. I '$D(^PRCP(445,PRCPSECO,1,PRCPITEM)) S ERR="6C" G ERR ; "Not in this inventory point"
  1. I $P(^PRCP(445,PRCPSECO,1,PRCPITEM,0),"^",9)'>0 S ERR="6D" G ERR ; not flagged as a supply station item"
  1. I '$D(^PRCP(445,PRCPPRIM,1,PRCPITEM)) S ERR="6B" G ERR ; not in the primary"
  1. I $P($G(^PRCP(445,PRCPSECO,5)),"^",1)']"" S ERR="3F" G ERR ; not a supply station secondary
  1. I $P($G(^PRC(441,PRCPITEM,0)),"^",6)="S" S ERR="6G" G ERR ; case cart/ik
  1. ; compare name in 445 with name sent, notify user if mismatch, CONTINUE
  1. S PRCPSSFL=$P(^PRCP(445.5,$P(^PRCP(445,PRCPSECO,5),"^",1),0),"^",2)
  1. ; if item name on supply station comes from item master
  1. I PRCPSSFL="O",$P(^PRC(441,PRCPITEM,0),"^",2)'=PRCPITNM D NAME^PRCPHL70(PRCPSECO,PRCPITEM,PRCPITNM,PRCPSSFL,PRCPHL7)
  1. ; if item name on supply station is from the secondary
  1. I PRCPSSFL="S",$G(^PRCP(445,PRCPSECO,1,PRCPITEM,6))'=PRCPITNM D NAME^PRCPHL70(PRCPSECO,PRCPITEM,PRCPITNM,PRCPSSFL,PRCPHL7)
  1. ;
  1. UPDATE I $P(^PRCP(445.3,ORDERDA,0),"^",6)="P" S ERR="2B" G ERR ; order is posted
  1. I PRCPPOST'="FU",'$D(^PRCP(445.3,ORDERDA,1,PRCPITEM)) S ERR="6D" G ERR ; item not on order
  1. I PRCPPOST'="FU" D G Q ; add amount received to order
  1. . S DIE="^PRCP(445.3,"_ORDERDA_",1,"
  1. . S DA=PRCPITEM
  1. . ; the following lines handle the case on an item in multiple bins
  1. . ; The user receiving an item in multiple bins will generate one
  1. . ; transaction per bin.
  1. . S X=$P($G(^PRCP(445.3,ORDERDA,1,DA,0)),"^",7)+0 ; amt refilled so far
  1. . S PRCPAMT=PRCPAMT+X
  1. . S DR="6///^S X=PRCPAMT"
  1. . D ^DIE K DIE
  1. . S PRCPDONE=1
  1. . ;
  1. . S ^PRCP(445,PRCPSECO,1,PRCPITEM,9)=PRCPLEFT_"^"_PRCPTIME
  1. ;
  1. I PRCPPOST="FU" D G Q
  1. . S PRCPSS=1
  1. . L +^PRCP(445,PRCPPRIM,1):3 I $T=0 S PRCPDONE=0 Q
  1. . S LOCKPRIM=1
  1. . D ADD^PRCPULOC(445,PRCPPRIM_"-1",0,"HL7 Distribution Order Processing")
  1. . D PRCPSS^PRCPOPP(ORDERDA,PRCPSECO,PRCPPRIM,PRCPSS)
  1. . S PRCPDONE=1
  1. . ; verify each item has refill amount
  1. . S ITEM=0
  1. . F S ITEM=$O(^PRCP(445.3,ORDERDA,1,ITEM)) Q:'ITEM D
  1. . . S X=$P($G(^PRCP(445.3,ORDERDA,1,ITEM,0)),"^",7)
  1. . . I X']"" S PRCPNOIT(ITEM)=1
  1. . I $D(PRCPNOIT) D ; send message for items not refilled
  1. . . N ITEMNM,LN,PRCPXMY,TYPE,XMB,XMDUZ,XMTEXT,XMY
  1. . . K ^TMP($J,"PRCPHL7")
  1. . . S ITEM=0,LN=0
  1. . . F S ITEM=$O(PRCPNOIT(ITEM)) Q:'ITEM D
  1. . . . S LN=LN+1
  1. . . . S ITEMNM=$P($G(^PRCP(445,PRCPSECO,1,ITEM,6)),"^",1)
  1. . . . I ITEMNM']"" S TYPE=$P(^PRCP(445.5,$P(^PRCP(445,PRCPSECO,5),"^",1),0),"^",2) D
  1. . . . . I TYPE="S" S ITEMNM=$P($G(^PRCP(445,PRCPPRIM,1,ITEM,6)),"^",1)
  1. . . . . I TYPE="O" S ITEMNM=$P($G(^PRC(441,ITEM,0)),"^",2)
  1. . . . S ^TMP($J,"PRCPHL7",1,LN,0)=$E(" ",$L(ITEM),7)_ITEM_" "_ITEMNM
  1. . . S ^TMP($J,"PRCPHL7",1,0)=LN
  1. . . D GETUSER^PRCPXTRM(PRCPPRIM) Q:'$O(PRCPXMY("")) ; find primary inventory point users
  1. . . S ITEM=0
  1. . . ; restrict message to inventory point managers
  1. . . F S ITEM=$O(PRCPXMY(ITEM)) Q:ITEM'>0 I PRCPXMY(ITEM)=1 S XMY(ITEM)=""
  1. . . S XMTEXT="^TMP($J,""PRCPHL7"",1,"
  1. . . S XMB(1)=$P(^PRCP(445.3,ORDERDA,0),"^",1)
  1. . . S XMB(3)=$$INVNAME^PRCPUX1(PRCPSECO)
  1. . . S XMB(2)=$P(^PRCP(445,$P(^PRCP(445.3,ORDERDA,0),"^",2),0),"^",1)
  1. . . S XMB="PRCP_NO_REFILL"
  1. . . S XMDUZ="SUPPLY STATION INTERFACE"
  1. . . D EN^XMB
  1. . . K ^TMP($J,"PRCPHL7")
  1. ;
  1. ERR ;
  1. N NUMBER,PRCPHLPO
  1. S NUMBER=ERR
  1. S PRCPHLPO("ORDER")=$P($G(^PRCP(445.3,ORDERDA,0)),"^",1)
  1. S PRCPHLPO("SIPNAME")="" I $D(^PRCP(445,PRCPSECO)) S PRCPHLPO("SIPNAME")=$$INVNAME^PRCPUX1(PRCPSECO)
  1. S PRCPHLPO("ITEM")="" I $D(PRCPITEM) S PRCPHLPO("ITEM")=PRCPITEM
  1. S PRCPHLPO("NAME")="" I $D(PRCPITNM) S PRCPHLPO("NAME")=PRCPITNM
  1. S PRCPHLPO("QTY")="" I $D(PRCPAMT) S PRCPHLPO("QTY")=PRCPAMT
  1. S PRCPHLPO("LEFT")="" I $D(PRCPLEFT) S PRCPHLPO("LEFT")=PRCPLEFT
  1. S PRCPHLPO("TYPE")="" I $D(PRCPPOST) S PRCPHLPO("TYPE")=PRCPPOST
  1. D ERR^PRCPHLM0(ERR,"PRCP_BAD_ORDER",PRCPSECO,.PRCPHLPO,PRCPHL7)
  1. S PRCPDONE=1
  1. ;
  1. Q I LOCKORD L -^PRCP(445.3,ORDERDA) D CLEAR^PRCPULOC(445.3,ORDERDA_"-1",0)
  1. I LOCKPRIM L -^PRCP(445,PRCPPRIM,1) D CLEAR^PRCPULOC(445,PRCPPRIM_"-1",0)
  1. Q