PSAGIP ;BIR/LTL,JMB-DA receiving from GIP ;7/23/97
;;3.0; DRUG ACCOUNTABILITY/INVENTORY INTERFACE;**8,64**; 10/24/97;Build 4
Q
EN(PSAGIP,PSAITEM,PSAQTY,PSAISS,PSAEX,PSATR,PSACOST,PSANDC) ; GIP passes recing data
;PSAGIP=D0 from #445, PSAITEM=D0 from #441,
;PSAQTY=qty rec'd converted to dispensing unit, PSAISS=D0 from #410,
;PSAEX=external form of D0 from either #410 or #442,
;PSATR=D0 from #445.2, PSACOST=total cost of receipt,
;PSANDC=NDC with dashes
Q:'$G(PSAQTY)
Q:'$O(^PSD(58.8,"P",+$G(PSAGIP),"")) ; GIP not linked to DA location
;check item linked to drug, drug stocked by DA loc, rec fail flag
N PSALOC S PSALOC=$O(^PSD(58.8,"P",+$G(PSAGIP),0)),PSADRUG=+$O(^PSDRUG("AB",+$G(PSAITEM),0))
S ^TMP("PSAC",$J,+PSALOC)=$G(PSAGIP)_U_$G(PSAEX)
I 'PSADRUG,$P($G(^PSD(58.8,+PSALOC,4,+$G(PSAGIP),0)),U,2) S ^TMP("PSAB",$J,+$G(PSAITEM))="#"+$G(PSAITEM)_" "_$$DESCR^PRCPUX1($G(PSAGIP),$G(PSAITEM))_" NOT LINKED." Q
I '$D(^PSD(58.8,+PSALOC,1,PSADRUG,0)),$P($G(^PSD(58.8,+PSALOC,4,+$G(PSAGIP),0)),U,2) S ^TMP("PSAB",$J,+$G(PSAITEM))="#"_$G(PSAITEM)_" "_$$DESCR^PRCPUX1($G(PSAGIP),$G(PSAITEM))_" NOT STOCKED." Q
Q:'$D(^PSD(58.8,+PSALOC,1,$G(PSADRUG),0))
S ^TMP("PSA",$J,$G(PSADRUG))=$G(PSAQTY)_U_$G(PSAISS)_U_$G(PSAEX)_U_$G(PSATR)_U_$G(PSACOST)_U_$G(PSAITEM)_U_$G(PSANDC)
Q
EX N ZTDESC,ZTIO,ZTRTN,ZTSAVE,ZTDTH,ZTSK,PSALOC,PSADAT,PSAB,PSAT,PSAGIP
Q:'$O(^TMP("PSAC",$J,0))
Q:'$O(^TMP("PSA",$J,0))&('$O(^TMP("PSAB",$J,0)))
S PSALOC=$O(^TMP("PSAC",$J,0)),PSAGIP=$P($G(^TMP("PSAC",$J,+PSALOC)),U)
S ZTDTH=$H,ZTIO="",ZTRTN="TSK^PSAGIP",ZTDESC="GIP/DA Receiving"
S ZTSAVE("PSALOC")="",ZTSAVE("PSAGIP")=""
S:$O(^TMP("PSA",$J,0)) ZTSAVE("^TMP(""PSA"",$J,")=""
S:$O(^TMP("PSAB",$J,0)) ZTSAVE("^TMP(""PSAB"",$J,")=""
S ZTSAVE("^TMP(""PSAC"",$J,")=""
D ^%ZTLOAD,HOME^%ZIS
K IO("Q"),^TMP("PSA",$J),^TMP("PSAB",$J),^TMP("PSAC",$J)
Q
TSK N PSAM
S:$P($G(^PSD(58.8,+PSALOC,0)),U,2)="M" PSAM=1
F PSADRUG=0:0 S PSADRUG=$O(^TMP("PSA",$J,PSADRUG)) Q:'PSADRUG S PSAQTY=$P($G(^TMP("PSA",$J,PSADRUG)),U),PSAISS=$P($G(^(PSADRUG)),U,2),PSAP=$P($G(^(PSADRUG)),U,3),PSATR=$P($G(^(PSADRUG)),U,4),PSACOST=$P($G(^(PSADRUG)),U,5) D
.S PSANDC=$P($G(^TMP("PSA",$J,PSADRUG)),U,7) D ^PSAGIP1
.S:'$P(PSAP,"-",3) PSAPO=PSAP
.L +^PSD(58.8,+PSALOC,1,+PSADRUG):5
.D NOW^%DTC S PSADAT=+$E(%,1,12) K %
.S PSAB=$P($G(^PSD(58.8,+PSALOC,1,+PSADRUG,0)),U,4)
.S $P(^PSD(58.8,+PSALOC,1,+PSADRUG,0),U,4)=$G(PSAQTY)+PSAB
.L -^PSD(58.8,+PSALOC,1,+PSADRUG)
MON .S:'$D(^PSD(58.8,+PSALOC,1,+PSADRUG,5,0)) ^(0)="^58.801A^^"
.I '$D(^PSD(58.8,+PSALOC,1,+PSADRUG,5,$E(DT,1,5)*100,0)) S DIC="^PSD(58.8,+PSALOC,1,+PSADRUG,5,",DIC(0)="LM",DIC("DR")="1////^S X=$G(PSAB)" D
..S (X,DINUM)=$E(DT,1,5)*100,DA(2)=PSALOC,DA(1)=PSADRUG,DLAYGO=58.8 D ^DIC K DIC,DINUM,DLAYGO,X
..S X="T-1M" D ^%DT S DIC="^PSD(58.8,+PSALOC,1,+PSADRUG,5,",DIC(0)="L",(X,DINUM)=$E(Y,1,5)*100,DA(2)=PSALOC,DA(1)=PSADRUG,DLAYGO=58.8 D ^DIC K DIC,DINUM,DLAYGO,X S DA=+Y K Y
..S DIE="^PSD(58.8,+PSALOC,1,+PSADRUG,5,",DA(2)=PSALOC,DA(1)=PSADRUG
..S DR="3////^S X=$G(PSAB)" D ^DIE K DIE,DR
.S DIE="^PSD(58.8,+PSALOC,1,+PSADRUG,5,",DA(2)=PSALOC,DA(1)=PSADRUG,DA=$E(DT,1,5)*100,DR="5////^S X=$P($G(^(0)),U,3)+$G(PSAQTY)" D ^DIE K DIE,DR
TR .F L +^PSD(58.81,0):$S($G(DILOCKTM)>0:DILOCKTM,1:3) I Q
FIND .D FIND1 S DIC="^PSD(58.81,",DIC(0)="L",DLAYGO=58.81,(DINUM,X)=PSAT D ^DIC K DIC,DINUM,DLAYGO L -^PSD(58.81,0)
.S DIE="^PSD(58.81,",DA=PSAT
.S DR="1////^S X=$S($E($G(PSATR))=""R"":1,1:9);2////^S X=$G(PSALOC);3////^S X=PSADAT;4////^S X=$G(PSADRUG);5////^S X=$G(PSAQTY);6////^S X=DUZ;7////^S X=$G(PSAISS);8///^S X=$G(PSAPO);9////^S X=PSAB;100////^S X=$G(PSAM)"
.D ^DIE K DIE,DR
.S:'$D(^PSD(58.8,+PSALOC,1,+PSADRUG,4,0)) ^(0)="^58.800119PA^^"
.S DIC="^PSD(58.8,+PSALOC,1,+PSADRUG,4,",DIC(0)="L",(X,DINUM)=PSAT
.S DA(2)=PSALOC,DA(1)=PSADRUG,DLAYGO=58.8 D ^DIC K DA,DIC,DLAYGO,DINUM,PSAB,PSAISS,PSANDC,PSAPO,PSAQTY,PSATR
K ^TMP("PSA",$J)
Q:'$O(^TMP("PSAB",$J,0))
S:'$G(PSAP) PSAP=$P($G(^TMP("PSAC",$J,PSALOC)),U,2)
S XMDUZ="Failed Receipt Notifier",XMSUB="Failed DA/GIP Receipts - "_PSAP
S XMY(DUZ)=""
I $P($G(^PSD(58.8,+PSALOC,4,+$G(PSAGIP),0)),U,3)'="" S XX=$P(^(0),"^",3),XXX="G."_XX,XMY(XXX)="" K XX,XXX
S XMTEXT="^TMP(""PSAB"",$J,"
G:'$D(XMY) QUIT1 D ^XMD
QUIT1 K XMDUZ,XMSUB,XMTEXT,XMY
S:$D(ZTQUEUED) ZTREQ="@" K ^TMP("PSAB",$J)
QUIT Q
FIND1 S PSAT=$P(^PSD(58.81,0),U,3)+1 I $D(^PSD(58.81,PSAT)) S $P(^PSD(58.81,0),U,3)=$P(^PSD(58.81,0),U,3)+1 G FIND1
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSAGIP 4490 printed Dec 13, 2024@01:49:19 Page 2
PSAGIP ;BIR/LTL,JMB-DA receiving from GIP ;7/23/97
+1 ;;3.0; DRUG ACCOUNTABILITY/INVENTORY INTERFACE;**8,64**; 10/24/97;Build 4
+2 QUIT
EN(PSAGIP,PSAITEM,PSAQTY,PSAISS,PSAEX,PSATR,PSACOST,PSANDC) ; GIP passes recing data
+1 ;PSAGIP=D0 from #445, PSAITEM=D0 from #441,
+2 ;PSAQTY=qty rec'd converted to dispensing unit, PSAISS=D0 from #410,
+3 ;PSAEX=external form of D0 from either #410 or #442,
+4 ;PSATR=D0 from #445.2, PSACOST=total cost of receipt,
+5 ;PSANDC=NDC with dashes
+6 if '$GET(PSAQTY)
QUIT
+7 ; GIP not linked to DA location
if '$ORDER(^PSD(58.8,"P",+$GET(PSAGIP),""))
QUIT
+8 ;check item linked to drug, drug stocked by DA loc, rec fail flag
+9 NEW PSALOC
SET PSALOC=$ORDER(^PSD(58.8,"P",+$GET(PSAGIP),0))
SET PSADRUG=+$ORDER(^PSDRUG("AB",+$GET(PSAITEM),0))
+10 SET ^TMP("PSAC",$JOB,+PSALOC)=$GET(PSAGIP)_U_$GET(PSAEX)
+11 IF 'PSADRUG
IF $PIECE($GET(^PSD(58.8,+PSALOC,4,+$GET(PSAGIP),0)),U,2)
SET ^TMP("PSAB",$JOB,+$GET(PSAITEM))="#"+$GET(PSAITEM)_" "_$$DESCR^PRCPUX1($GET(PSAGIP),$GET(PSAITEM))_" NOT LINKED."
QUIT
+12 IF '$DATA(^PSD(58.8,+PSALOC,1,PSADRUG,0))
IF $PIECE($GET(^PSD(58.8,+PSALOC,4,+$GET(PSAGIP),0)),U,2)
SET ^TMP("PSAB",$JOB,+$GET(PSAITEM))="#"_$GET(PSAITEM)_" "_$$DESCR^PRCPUX1($GET(PSAGIP),$GET(PSAITEM))_" NOT STOCKED."
QUIT
+13 if '$DATA(^PSD(58.8,+PSALOC,1,$GET(PSADRUG),0))
QUIT
+14 SET ^TMP("PSA",$JOB,$GET(PSADRUG))=$GET(PSAQTY)_U_$GET(PSAISS)_U_$GET(PSAEX)_U_$GET(PSATR)_U_$GET(PSACOST)_U_$GET(PSAITEM)_U_$GET(PSANDC)
+15 QUIT
EX NEW ZTDESC,ZTIO,ZTRTN,ZTSAVE,ZTDTH,ZTSK,PSALOC,PSADAT,PSAB,PSAT,PSAGIP
+1 if '$ORDER(^TMP("PSAC",$JOB,0))
QUIT
+2 if '$ORDER(^TMP("PSA",$JOB,0))&('$ORDER(^TMP("PSAB",$JOB,0)))
QUIT
+3 SET PSALOC=$ORDER(^TMP("PSAC",$JOB,0))
SET PSAGIP=$PIECE($GET(^TMP("PSAC",$JOB,+PSALOC)),U)
+4 SET ZTDTH=$HOROLOG
SET ZTIO=""
SET ZTRTN="TSK^PSAGIP"
SET ZTDESC="GIP/DA Receiving"
+5 SET ZTSAVE("PSALOC")=""
SET ZTSAVE("PSAGIP")=""
+6 if $ORDER(^TMP("PSA",$JOB,0))
SET ZTSAVE("^TMP(""PSA"",$J,")=""
+7 if $ORDER(^TMP("PSAB",$JOB,0))
SET ZTSAVE("^TMP(""PSAB"",$J,")=""
+8 SET ZTSAVE("^TMP(""PSAC"",$J,")=""
+9 DO ^%ZTLOAD
DO HOME^%ZIS
+10 KILL IO("Q"),^TMP("PSA",$JOB),^TMP("PSAB",$JOB),^TMP("PSAC",$JOB)
+11 QUIT
TSK NEW PSAM
+1 if $PIECE($GET(^PSD(58.8,+PSALOC,0)),U,2)="M"
SET PSAM=1
+2 FOR PSADRUG=0:0
SET PSADRUG=$ORDER(^TMP("PSA",$JOB,PSADRUG))
if 'PSADRUG
QUIT
SET PSAQTY=$PIECE($GET(^TMP("PSA",$JOB,PSADRUG)),U)
SET PSAISS=$PIECE($GET(^(PSADRUG)),U,2)
SET PSAP=$PIECE($GET(^(PSADRUG)),U,3)
SET PSATR=$PIECE($GET(^(PSADRUG)),U,4)
SET PSACOST=$PIECE($GET(^(PSADRUG)),U,5)
Begin DoDot:1
+3 SET PSANDC=$PIECE($GET(^TMP("PSA",$JOB,PSADRUG)),U,7)
DO ^PSAGIP1
+4 if '$PIECE(PSAP,"-",3)
SET PSAPO=PSAP
+5 LOCK +^PSD(58.8,+PSALOC,1,+PSADRUG):5
+6 DO NOW^%DTC
SET PSADAT=+$EXTRACT(%,1,12)
KILL %
+7 SET PSAB=$PIECE($GET(^PSD(58.8,+PSALOC,1,+PSADRUG,0)),U,4)
+8 SET $PIECE(^PSD(58.8,+PSALOC,1,+PSADRUG,0),U,4)=$GET(PSAQTY)+PSAB
+9 LOCK -^PSD(58.8,+PSALOC,1,+PSADRUG)
MON if '$DATA(^PSD(58.8,+PSALOC,1,+PSADRUG,5,0))
SET ^(0)="^58.801A^^"
+1 IF '$DATA(^PSD(58.8,+PSALOC,1,+PSADRUG,5,$EXTRACT(DT,1,5)*100,0))
SET DIC="^PSD(58.8,+PSALOC,1,+PSADRUG,5,"
SET DIC(0)="LM"
SET DIC("DR")="1////^S X=$G(PSAB)"
Begin DoDot:2
+2 SET (X,DINUM)=$EXTRACT(DT,1,5)*100
SET DA(2)=PSALOC
SET DA(1)=PSADRUG
SET DLAYGO=58.8
DO ^DIC
KILL DIC,DINUM,DLAYGO,X
+3 SET X="T-1M"
DO ^%DT
SET DIC="^PSD(58.8,+PSALOC,1,+PSADRUG,5,"
SET DIC(0)="L"
SET (X,DINUM)=$EXTRACT(Y,1,5)*100
SET DA(2)=PSALOC
SET DA(1)=PSADRUG
SET DLAYGO=58.8
DO ^DIC
KILL DIC,DINUM,DLAYGO,X
SET DA=+Y
KILL Y
+4 SET DIE="^PSD(58.8,+PSALOC,1,+PSADRUG,5,"
SET DA(2)=PSALOC
SET DA(1)=PSADRUG
+5 SET DR="3////^S X=$G(PSAB)"
DO ^DIE
KILL DIE,DR
End DoDot:2
+6 SET DIE="^PSD(58.8,+PSALOC,1,+PSADRUG,5,"
SET DA(2)=PSALOC
SET DA(1)=PSADRUG
SET DA=$EXTRACT(DT,1,5)*100
SET DR="5////^S X=$P($G(^(0)),U,3)+$G(PSAQTY)"
DO ^DIE
KILL DIE,DR
TR FOR
LOCK +^PSD(58.81,0):$SELECT($GET(DILOCKTM)>0:DILOCKTM,1:3)
IF $TEST
QUIT
FIND DO FIND1
SET DIC="^PSD(58.81,"
SET DIC(0)="L"
SET DLAYGO=58.81
SET (DINUM,X)=PSAT
DO ^DIC
KILL DIC,DINUM,DLAYGO
LOCK -^PSD(58.81,0)
+1 SET DIE="^PSD(58.81,"
SET DA=PSAT
+2 SET DR="1////^S X=$S($E($G(PSATR))=""R"":1,1:9);2////^S X=$G(PSALOC);3////^S X=PSADAT;4////^S X=$G(PSADRUG);5////^S X=$G(PSAQTY);6////^S X=DUZ;7////^S X=$G(PSAISS);8///^S X=$G(PSAPO);9////^S X=PSAB;100////^S X=$G(PSAM)"
+3 DO ^DIE
KILL DIE,DR
+4 if '$DATA(^PSD(58.8,+PSALOC,1,+PSADRUG,4,0))
SET ^(0)="^58.800119PA^^"
+5 SET DIC="^PSD(58.8,+PSALOC,1,+PSADRUG,4,"
SET DIC(0)="L"
SET (X,DINUM)=PSAT
+6 SET DA(2)=PSALOC
SET DA(1)=PSADRUG
SET DLAYGO=58.8
DO ^DIC
KILL DA,DIC,DLAYGO,DINUM,PSAB,PSAISS,PSANDC,PSAPO,PSAQTY,PSATR
End DoDot:1
+7 KILL ^TMP("PSA",$JOB)
+8 if '$ORDER(^TMP("PSAB",$JOB,0))
QUIT
+9 if '$GET(PSAP)
SET PSAP=$PIECE($GET(^TMP("PSAC",$JOB,PSALOC)),U,2)
+10 SET XMDUZ="Failed Receipt Notifier"
SET XMSUB="Failed DA/GIP Receipts - "_PSAP
+11 SET XMY(DUZ)=""
+12 IF $PIECE($GET(^PSD(58.8,+PSALOC,4,+$GET(PSAGIP),0)),U,3)'=""
SET XX=$PIECE(^(0),"^",3)
SET XXX="G."_XX
SET XMY(XXX)=""
KILL XX,XXX
+13 SET XMTEXT="^TMP(""PSAB"",$J,"
+14 if '$DATA(XMY)
GOTO QUIT1
DO ^XMD
QUIT1 KILL XMDUZ,XMSUB,XMTEXT,XMY
+1 if $DATA(ZTQUEUED)
SET ZTREQ="@"
KILL ^TMP("PSAB",$JOB)
QUIT QUIT
FIND1 SET PSAT=$PIECE(^PSD(58.81,0),U,3)+1
IF $DATA(^PSD(58.81,PSAT))
SET $PIECE(^PSD(58.81,0),U,3)=$PIECE(^PSD(58.81,0),U,3)+1
GOTO FIND1
+1 QUIT