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

PRCPHLP.m

Go to the documentation of this file.
PRCPHLP ;WISC/CC - PROCESS HL7 TXN ON REFILLS AND ORDER POSTING; 4/00
V ;;5.1;IFCAP;**1**;Oct 20, 2000
 ;Per VHA Directive 10-93-142, this routine should not be modified.
 ;
 N DIC,DIE,DR,ERR,I,J,X,XMB
 N NUMBER,ORDERDA,PRIM
 N PRCPAMT,PRCPHL,PRCPHLPO,PRCPITEM,PRCPLEFT,PRCPOC,PRCPORD
 N PRCPSEC,PRCPSECN,PRCPSET,PRCPSITE,PRCPTIME,PRCPUSER
 ;
 S I=1
 I HL("MTN")'="ORM" S ERR="1B" G ERR ; wrong message name
 X HLNEXT I HLQUIT'>0 S ERR="1A" G ERR ; missing segments
 S PRCPHL(1)=HLNODE,I=2
 ;
 X HLNEXT I HLQUIT'>0 S ERR="1A" G ERR ; missing segments
 S PRCPHL(I)=HLNODE,J=0,I=I+1
 I $$FLD^HLCSUTL(HLNODE,1)'="ORC" S ERR="1A" G ERR ; wrong segment name
 D ORC I $D(ERR) G ERR
 ;
 X HLNEXT I HLQUIT'>0,PRCPOC="OF" S ERR="1A" G ERR ; missing segments
 ; Order completion transactions will only have an ORC segment
 I HLQUIT'>0,PRCPOC="FU" G PROCESS
 S PRCPHL(I)=HLNODE,I=I+1,J=0
 I PRCPOC="FU" S ERR="1A" G ERR ; too many segments for order class code
 I $$FLD^HLCSUTL(HLNODE,1)'="RQD" S ERR="1A" G ERR ; wrong segment name
 ;
 ; RQD SEGMENT
RQD S PRCPITEM=$$FLD^HLCSUTL(HLNODE,5) ; ID~NAME
 S PRCPAMT=$$FLD^HLCSUTL(HLNODE,6) ; REFILL QTY - restock issue units
 ;
 ; check item info
 I +PRCPITEM'=$P(PRCPITEM,$E(HL("ECH"),1),1)!(+PRCPITEM=0) S ERR="6E" G ERR ; item number invalid
 I '$D(^PRCP(445.3,ORDERDA,1,$P(PRCPITEM,$E(HL("ECH"),1),1))) S ERR="6A" G ERR ; item not on order
 I '$D(^PRCP(445,$P(^PRCP(445.3,ORDERDA,0),"^",2),1,$P(PRCPITEM,$E(HL("ECH"),1),1))) S ERR="6B" G ERR ; item not in primary 
 I '$D(^PRCP(445,PRCPSECN,1,$P(PRCPITEM,$E(HL("ECH"),1),1))) S ERR="6C" G ERR
 I $P(^PRCP(445,PRCPSECN,1,$P(PRCPITEM,$E(HL("ECH"),1),1),0),"^",9)'>0 S ERR="6D" G ERR ; is item a supply station item
 I $P($G(^PRC(441,$P(PRCPITEM,$E(HL("ECH"),1)),0)),"^",6)="S" S ERR="6G" G ERR ; case cart/ik
 ;
 ; verify amount
 I +PRCPAMT'=PRCPAMT!(PRCPAMT>999999)!(PRCPAMT<-999999) S ERR=4 G ERR
 ;
 X HLNEXT I HLQUIT'>0 S ERR="1A" G ERR ; missing segments
 S PRCPHL(I)=HLNODE,J=0,I=I+1
 I $$FLD^HLCSUTL(HLNODE,1)'="NTE" S ERR="1A" G ERR ; wrong segment name
 ;
 ; READ NTE SEGMENT
NTE S PRCPLEFT=$$FLD^HLCSUTL(HLNODE,4)
 I +PRCPLEFT'=PRCPLEFT!(PRCPLEFT>999999)!(PRCPLEFT<-999999) S ERR=5 G ERR
 ;
 X HLNEXT I HLQUIT'>0 G PROCESS
 S PRCPHL(I)=HLNODE,I=I+1,J=0
 S ERR="1A" G ERR ; too many segments
 G Q
 ;
 ; ORC SEGMENT
ORC S PRCPOC=$$FLD^HLCSUTL(HLNODE,2)
 S PRCPSEC=$$FLD^HLCSUTL(HLNODE,5)
 S PRCPORD=$$FLD^HLCSUTL(HLNODE,3)
 ;
 I PRCPOC'="OF",PRCPOC'="FU" S ERR="1C" Q  ; order control wrong
 ;
 ; find site and IP ien
 S PRCPSEC=$P(PRCPSEC,$E(HL("ECH"),1),2)
 I PRCPSEC']"" S ERR="3E" G ERR
 S PRCPSITE=$P(PRCPSEC,"-",1)
 I PRCPSITE']"" S ERR="3E" Q  ; site missing
 I '$D(^PRC(411,PRCPSITE,0)) S ERR="3D" Q  ; wrong site
 S DIC="^PRCP(445,",DIC(0)="X",X=PRCPSEC,PRCPPRIV=1
 D ^DIC K DIC
 I Y=-1 S ERR="3A" Q  ; secondary not in GIP
 S PRCPSECN=$P(Y,"^",1)
 I $P(^PRCP(445,PRCPSECN,0),"^",3)'="S" S ERR="3B" Q  ; not a secondary
 ;
 S PRIM=$O(^PRCP(445,"AB",PRCPSECN,""))
 I PRIM']"" S ERR="2A" Q
 ; get internal order number
 I PRCPORD]"" D  I $D(ERR) Q
 . S DIC="^PRCP(445.3,",DIC(0)="X",X=PRCPORD,PRCPPRIV=1
 . S DIC("S")="I $P(^(0),U,2)="_PRIM
 . D ^DIC K DIC
 . I Y=-1 S ERR="2A" Q  ; order not in GIP
 . S ORDERDA=$P(Y,"^",1)
 . I $P(^PRCP(445.3,ORDERDA,0),"^",6)="P" S ERR="2B" Q  ; order is posted
 . I $P(^PRCP(445.3,ORDERDA,0),"^",10)']"" S ERR="2C" Q  ; order not to be completed by supply station
 . I $P(^PRCP(445.3,ORDERDA,0),"^",3)'=PRCPSECN S ERR="3C" Q  ; sec on order differs
 I HL("MTN")="ORM",PRCPORD']"" S ERR="2D" Q  ; order number missing
 ;
 S PRCPTIME=$$FLD^HLCSUTL(HLNODE,10)
 S PRCPTIME=$$FMDATE^HLFNC(PRCPTIME)
 S PRCPUSER=$$FLD^HLCSUTL(HLNODE,11)
 S PRCPUSER=$P(PRCPUSER,$E(HL("ECH"),1),2)
 S PRCPUSER=$$FMNAME^HLFNC(PRCPUSER,$E(HL("ECH"),1))
 Q
 ;
 ;
ERR S NUMBER=ERR
 I '$D(PRCPSECN) S PRCPSECN=0
 S PRCPHLPO("ORDER")="" I $D(PRCPORD) S PRCPHLPO("ORDER")=PRCPORD
 S PRCPHLPO("SIPNAME")="AN UNKNOWN INVENTORY POINT"
 I $D(PRCPSEC),PRCPSEC]"" S PRCPHLPO("SIPNAME")=PRCPSEC
 S PRCPHLPO("ITEM")=""
 I $D(PRCPITEM) S PRCPHLPO("ITEM")=$P(PRCPITEM,$E(HL("ECH"),1),1)
 S PRCPHLPO("NAME")=""
 I $D(PRCPITEM) S PRCPHLPO("NAME")=$P(PRCPITEM,$E(HL("ECH"),1),2)
 S PRCPHLPO("QTY")="" I $D(PRCPAMT) S PRCPHLPO("QTY")=PRCPAMT
 S PRCPHLPO("LEFT")="" I $D(PRCPLEFT) S PRCPHLPO("LEFT")=PRCPLEFT
 S PRCPHLPO("TYPE")=PRCPOC
 D ERR^PRCPHLM0(ERR,"PRCP_BAD_ORDER",PRCPSECN,.PRCPHLPO,HLMTIENS_"."_HLMTIEN,.PRCPHL)
 G UNLOCK
 ;
 ;
PROCESS N %,%H,%I,N,PRCPTXN,PRCPTXNT,PRCPMGTP,PRCPHL7,PRCPITNM,CNT,DA,DIC,DIE,DLAYGO,DR,T,X,Y
 S X="PRCPHL7TXN",CNT=0
PROCES0 I $D(^PRCS(410.1,"B",X)) D  I $D(ERR) S CNT=CNT+1 G PROCES0:CNT<10 S CNT=0 G ERR
 . S N="",N=$O(^PRCS(410.1,"B",X,N)),DA=N
 . L +^PRCS(410.1,DA):15 I $T=0 S ERR=198 Q
 . S T=$P(^PRCS(410.1,N,0),"^",2)+1 S:T<1 T=1
 . S $P(^PRCS(410.1,DA,0),"^",2)=+T
 . S $P(^PRCS(410.1,DA,0),"^",3)=DT
 . L -^PRCS(410.1,DA)
 I '$D(^PRCS(410.1,"B",X)) D  I $D(ERR) S CNT=CNT+1 G PROCES0:CNT<10 S CNT=0 G ERR
 . S T=1,DLAYGO=410.1,DIC="^PRCS(410.1,",DIC(0)="FLXZ"
 . D ^DIC K DLAYGO I Y<0 S ERR=199
 . S DA=+Y
 . L +^PRCS(410.1,DA):15 I $T=0 S ERR=198 Q
 . S $P(^PRCS(410.1,DA,0),"^",2)=+T
 . S $P(^PRCS(410.1,DA,0),"^",3)=DT
 . L -^PRCS(410.1,DA)
 ;
PROCES1 S CNT=0,X=T
 S DIC="^PRCP(447.1,"
 S DIC(0)="L"
 S DLAYGO=447.1
 D ^DIC K DIC
 I Y=-1 S ERR=100,CNT=CNT+1 G PROCES1:CNT<10,ERR
 I $P(Y,"^",3)'=1 S ERR=101 G ERR
 S (DA,PRCPTXN)=Y+0
 L +^PRCP(447.1,DA):3 I $T=0 S ERR=102 D UNLOCK G ERR
 S DIE="^PRCP(447.1,"
 S DA=PRCPTXN
 D NOW^%DTC
 S PRCPTXNT=%
 S PRCPHL7=HLMTIENS_"."_HLMTIEN
 S PRCPMGTP=HL("MTN")_HL("ETN")
 S DR="1///^S X=PRCPSITE;2///^S X=PRCPSECN;3///^S X=PRCPTXNT;4///^S X=PRCPMGTP;5///^S X=PRCPHL7;6////^S X=ORDERDA;8///^S X=PRCPTIME;10///^S X=PRCPUSER"
 I PRCPOC="FU" S DR=DR_";11///^S X=PRCPOC"
 D ^DIE
 K DIE,DR
 I PRCPOC="FU" G UNLOCK
 S DIC="^PRCP(447.1,"_PRCPTXN_",1,"
 S DA(1)=PRCPTXN
 S DIC(0)="L"
 S DLAYGO=447.1
 S DIC("P")=$P(^DD(447.1,7,0),"^",2)
 S X=$P(PRCPITEM,$E(HL("ECH"),1),1)
 S PRCPSET="I 1" ; over rides screen to omit finding case carts/IK's
 D ^DIC K DIC,DA,DLAYGO
 I Y=-1 S ERR=110 D UNLOCK G ERR
 I $P(Y,"^",3)'=1 S ERR=111 D UNLOCK G ERR
 S DIE="^PRCP(447.1,"_PRCPTXN_",1,"
 S DA=+Y
 S PRCPITNM=$P(PRCPITEM,$E(HL("ECH"),1),2)
 S DR="1///^S X=PRCPLEFT;2///^S X=PRCPAMT;3///^S X=PRCPITNM"
 D ^DIE K DIE,DIC,DR
UNLOCK I $D(ERR),$D(PRCPTXN),PRCPTXN>0 S DA=PRCPTXN,DIK="^PRCP(447.1," D ^DIK
 I $G(PRCPTXN) L -^PRCP(447.1,PRCPTXN)
Q Q