PSGWTR1 ;BHAM ISC/PTD,CML-Transfer Stock Entries from One AOU to Another - CONTINUED ; 29 Dec 93 / 9:18 AM
;;2.3; Automatic Replenishment/Ward Stock ;;4 JAN 94
;AOUF - AOU INTERNAL, ENTRIES TRANSFER FROM THIS AOU
;AOUT - STRING OF AOU INTERNALS, ENTRIES TRANSFERRED INTO THESE AOUS
;TR=1 TRANSFER ONLY DRUG NAME, TR=2 TRANSFER DRUG NAME, STOCK LEVEL & LOCATION, TR=3 TRANSFER DRUG NAME, STOCK LEVEL, LOCATION, & TYPES
;PSGWDUZ - USER TO WHOM MM MESSAGE WILL BE SENT
;
;REINDEX THE B CROSS REFERENCE OF ALL AOUS INVOLVED
BXREF S AOU=AOUF D REINDEX F J=1:1:($L(AOUT,",")-1) S AOU=$P(AOUT,",",J) D REINDEX
;
AOUTO F J=1:1:($L(AOUT,",")-1) S AOU=$P(AOUT,",",J) D AOUFR
MSG S XMDUZ="INPATIENT PHARMACY AR/WS",XMY(PSGWDUZ)="",XMSUB="AR/WS AOU ENTRY TRANSFER COMPLETED",^TMP("PSGWMSG",$J,1,0)="Stock items from "_$P(^PSI(58.1,AOUF,0),"^")_" have been transferred into:"
F J=1:1:($L(AOUT,",")-1) S AOU=$P(AOUT,",",J),^TMP("PSGWMSG",$J,(J+1),0)=$P(^PSI(58.1,AOU,0),"^")
S XMTEXT="^TMP(""PSGWMSG"",$J," D ^XMD
END K AOU,AOUF,JJ,K,AOUT,DRGDA,DR,TRDRG,STLEV,LOC,TR,TYP,ITMDA,XMDUZ,XMY(PSGWDUZ),PSGWDUZ,XMSUB,XMTEXT,DA,ZTIO,LL,X,Y,XMZ,XCNP,DIC,DIE,J,^TMP("PSGWMSG",$J),ZTSK
Q
;
AOUFR S DRGDA=0 I '$O(^PSI(58.1,AOU,0)) S ^PSI(58.1,AOU,1,0)="^58.11IP^^"
TRANS S DRGDA=$O(^PSI(58.1,AOUF,1,DRGDA)) Q:'DRGDA S TRDRG=$P(^(DRGDA,0),"^")
I $P(^PSI(58.1,AOUF,1,DRGDA,0),"^",10)="Y",$P(^(0),"^",3)="" S $P(^(0),"^",10)=""
I $P(^PSI(58.1,AOUF,1,DRGDA,0),"^",3)'="" G TRANS
I $D(^PSI(58.1,AOU,1,"B",TRDRG)) G TRANS
;IF IT GETS THIS FAR, WE HAVE A GOOD DRUG THAT SHOULD BE TRANSFERRED
I '$D(^PSI(58.1,AOU,1,0)) S $P(^(0),"^",2)="58.11IP"
DIC S (DIC,DIE)="^PSI(58.1,AOU,1,",DA(1)=AOU,DIC(0)="LM",X="`"_TRDRG D ^DIC K DIC G:Y<0 TRANS I TR'=1 S STLEV=$P(^PSI(58.1,AOUF,1,DRGDA,0),"^",2),LOC=$P(^(0),"^",8),(DA,ITMDA)=+Y,DA(1)=AOU,DR="1///"_STLEV_";10///"_LOC D ^DIE K DIE
I TR=3,'$D(^PSI(58.1,AOU,1,ITMDA,2,0)) S $P(^(0),"^",2)="58.13PA"
I TR=3 S TYP=0 K DD,DO D TYPLP
G TRANS
;
REINDEX L +^PSI(58.1,AOU,1) K ^PSI(58.1,AOU,1,"B") F K=0:0 S K=$O(^PSI(58.1,AOU,1,K)) Q:'K I $D(^(K,0)) S ^PSI(58.1,AOU,1,"B",+^(0),K)=""
L -^PSI(58.1,AOU,1)
Q
;
TYPLP F JJ=0:1 S TYP=$O(^PSI(58.1,AOUF,1,DRGDA,2,TYP)) Q:'TYP S LL=TYP,DIC="^PSI(58.1,"_AOU_",1,"_ITMDA_",2,",DIC(0)="L",(X,DINUM)=TYP,DLAYGO=58.1 K DD,DO D FILE^DICN K DLAYGO
S:JJ $P(^PSI(58.1,AOU,1,ITMDA,2,0),"^",3,4)=LL_"^"_JJ
K DD,DO Q
;
PSGWTR1 ;BHAM ISC/PTD,CML-Transfer Stock Entries from One AOU to Another - CONTINUED ; 29 Dec 93 / 9:18 AM
+1 ;;2.3; Automatic Replenishment/Ward Stock ;;4 JAN 94
+2 ;AOUF - AOU INTERNAL, ENTRIES TRANSFER FROM THIS AOU
+3 ;AOUT - STRING OF AOU INTERNALS, ENTRIES TRANSFERRED INTO THESE AOUS
+4 ;TR=1 TRANSFER ONLY DRUG NAME, TR=2 TRANSFER DRUG NAME, STOCK LEVEL & LOCATION, TR=3 TRANSFER DRUG NAME, STOCK LEVEL, LOCATION, & TYPES
+5 ;PSGWDUZ - USER TO WHOM MM MESSAGE WILL BE SENT
+6 ;
+7 ;REINDEX THE B CROSS REFERENCE OF ALL AOUS INVOLVED
BXREF SET AOU=AOUF
DO REINDEX
FOR J=1:1:($LENGTH(AOUT,",")-1)
SET AOU=$PIECE(AOUT,",",J)
DO REINDEX
+1 ;
AOUTO FOR J=1:1:($LENGTH(AOUT,",")-1)
SET AOU=$PIECE(AOUT,",",J)
DO AOUFR
MSG SET XMDUZ="INPATIENT PHARMACY AR/WS"
SET XMY(PSGWDUZ)=""
SET XMSUB="AR/WS AOU ENTRY TRANSFER COMPLETED"
SET ^TMP("PSGWMSG",$JOB,1,0)="Stock items from "_$PIECE(^PSI(58.1,AOUF,0),"^")_" have been transferred into:"
+1 FOR J=1:1:($LENGTH(AOUT,",")-1)
SET AOU=$PIECE(AOUT,",",J)
SET ^TMP("PSGWMSG",$JOB,(J+1),0)=$PIECE(^PSI(58.1,AOU,0),"^")
+2 SET XMTEXT="^TMP(""PSGWMSG"",$J,"
DO ^XMD
END KILL AOU,AOUF,JJ,K,AOUT,DRGDA,DR,TRDRG,STLEV,LOC,TR,TYP,ITMDA,XMDUZ,XMY(PSGWDUZ),PSGWDUZ,XMSUB,XMTEXT,DA,ZTIO,LL,X,Y,XMZ,XCNP,DIC,DIE,J,^TMP("PSGWMSG",$JOB),ZTSK
+1 QUIT
+2 ;
AOUFR SET DRGDA=0
IF '$ORDER(^PSI(58.1,AOU,0))
SET ^PSI(58.1,AOU,1,0)="^58.11IP^^"
TRANS SET DRGDA=$ORDER(^PSI(58.1,AOUF,1,DRGDA))
IF 'DRGDA
QUIT
SET TRDRG=$PIECE(^(DRGDA,0),"^")
+1 IF $PIECE(^PSI(58.1,AOUF,1,DRGDA,0),"^",10)="Y"
IF $PIECE(^(0),"^",3)=""
SET $PIECE(^(0),"^",10)=""
+2 IF $PIECE(^PSI(58.1,AOUF,1,DRGDA,0),"^",3)'=""
GOTO TRANS
+3 IF $DATA(^PSI(58.1,AOU,1,"B",TRDRG))
GOTO TRANS
+4 ;IF IT GETS THIS FAR, WE HAVE A GOOD DRUG THAT SHOULD BE TRANSFERRED
+5 IF '$DATA(^PSI(58.1,AOU,1,0))
SET $PIECE(^(0),"^",2)="58.11IP"
DIC SET (DIC,DIE)="^PSI(58.1,AOU,1,"
SET DA(1)=AOU
SET DIC(0)="LM"
SET X="`"_TRDRG
DO ^DIC
KILL DIC
IF Y<0
GOTO TRANS
IF TR'=1
SET STLEV=$PIECE(^PSI(58.1,AOUF,1,DRGDA,0),"^",2)
SET LOC=$PIECE(^(0),"^",8)
SET (DA,ITMDA)=+Y
SET DA(1)=AOU
SET DR="1///"_STLEV_";10///"_LOC
DO ^DIE
KILL DIE
+1 IF TR=3
IF '$DATA(^PSI(58.1,AOU,1,ITMDA,2,0))
SET $PIECE(^(0),"^",2)="58.13PA"
+2 IF TR=3
SET TYP=0
KILL DD,DO
DO TYPLP
+3 GOTO TRANS
+4 ;
REINDEX LOCK +^PSI(58.1,AOU,1)
KILL ^PSI(58.1,AOU,1,"B")
FOR K=0:0
SET K=$ORDER(^PSI(58.1,AOU,1,K))
IF 'K
QUIT
IF $DATA(^(K,0))
SET ^PSI(58.1,AOU,1,"B",+^(0),K)=""
+1 LOCK -^PSI(58.1,AOU,1)
+2 QUIT
+3 ;
TYPLP FOR JJ=0:1
SET TYP=$ORDER(^PSI(58.1,AOUF,1,DRGDA,2,TYP))
IF 'TYP
QUIT
SET LL=TYP
SET DIC="^PSI(58.1,"_AOU_",1,"_ITMDA_",2,"
SET DIC(0)="L"
SET (X,DINUM)=TYP
SET DLAYGO=58.1
KILL DD,DO
DO FILE^DICN
KILL DLAYGO
+1 IF JJ
SET $PIECE(^PSI(58.1,AOU,1,ITMDA,2,0),"^",3,4)=LL_"^"_JJ
+2 KILL DD,DO
QUIT
+3 ;