PSDADJC ;B'ham ISC/LTL,JPW - Balance Shift Checker for NAOU ; 16 Feb 94
;;3.0; CONTROLLED SUBSTANCES ;**53,66**;13 Feb 97;Build 3
I '$D(PSDSITE) D ^PSDSET G:'$D(PSDSITE) QUIT
N D1,D2,DIC,DIE,DINUM,D0,D1,DLAYGO,DR,DIR,DIRUT,DTOUT,DUOUT,NODE,PSAC,PSDAT,PSDLOC,PSDOUT,PSDLOCN,DA,PSDRUG,PSDRUGN,PSDS,PSDPKG,PSDBKU,PSAQ,PSDR,PSDREC,PSDT,X,Y,%,%H,%I
LOOK S DIC="^PSD(58.8,",DIC(0)="AEMQZ",DIC("A")="Select NAOU: ",DIC("S")="I $P($G(^(0)),U,3)=+PSDSITE,$P($G(^(0)),U,2)[""N"",'$P(^(0),""^"",7),$S('$D(^(""I"")):1,+^(""I"")>DT:1,'^(""I""):1,1:0)"
W ! D ^DIC K DIC G:$D(DTOUT)!($D(DUOUT))!(Y<1) QUIT
;VMP OIFO BAY PINES;VGF;PSD*3.0*53;ADDED SET OF VARIABLE NAOU
S (NAOU,PSDLOC)=+Y,(NAOUN,PSDLOCN)=$P(Y,U,2),PSDS=+$P(Y(0),"^",4)
I '+$P($G(^PSD(58.8,PSDLOC,2)),"^",5) W !!,"This NAOU does not maintain a perpetual inventory balance to check.",!! K PSDLOC,PSDLOCN,PSDS G LOOK
CHKD I '$O(^PSD(58.8,PSDLOC,1,0)) W !!,"There are no drugs in ",PSDLOCN G QUIT
WIT W ! S NUR2=$$WITNESS^XUVERIFY("WITNESS")
I NUR2=DUZ W !!,"Wait a second, you can't witness yourself!",$C(7) G WIT
G:NUR2'>0 QUIT
W !!,"Thank you, ",$S($P($G(^VA(200,NUR2,.1)),U,4)]"":$P($G(^(.1)),U,4),1:$P($G(^VA(200,NUR2,0)),U))
W !!,"Give me a second to alphabetize.",!
S PSDRUG=0,PSDRUGN=""
F S PSDRUG=$O(^PSD(58.8,PSDLOC,1,PSDRUG)) Q:'PSDRUG D
.Q:'$D(^PSD(58.8,+PSDLOC,1,+PSDRUG,0))!($P($G(^PSDRUG(+PSDRUG,0)),"^")']"")!('$P($G(^PSD(58.8,+PSDLOC,1,PSDRUG,0)),U,4))
.S PSDPKG=$P($G(^PSD(58.8,+PSDS,1,+PSDRUG,0)),"^",9),PSDBKU=$P($G(^(0)),"^",8)
.S ^TMP("PSDB",$J,$P($G(^PSDRUG(+PSDRUG,0)),U),PSDRUG)=PSDPKG_"^"_PSDBKU K Y
W @IOF S (PSDRUG,PSDRUGN)=0
F S PSDRUGN=$O(^TMP("PSDB",$J,PSDRUGN)) Q:PSDRUGN']"" F S PSDRUG=$O(^TMP("PSDB",$J,PSDRUGN,PSDRUG)) Q:'PSDRUG D G:$D(DIRUT)!($G(PSDOUT)) QUIT
.Q:'$G(^PSD(58.8,PSDLOC,1,PSDRUG,0))
.S NODE=$G(^TMP("PSDB",$J,PSDRUGN,PSDRUG))
BAL .W !!,PSDRUGN,!!,"Balance: "
.S (PSDREC,PSDREC(1),PSDREC(2))=$P($G(^PSD(58.8,PSDLOC,1,PSDRUG,0)),U,4)
.W PSDREC," ",$P(NODE,U,2)
.S DIR(0)="Y",DIR("A")="Count Correct",DIR("B")="Yes"
.W ! D ^DIR K DIR Q:$D(DIRUT)
.G:Y=1 INV
.F L +^PSD(58.8,+PSDLOC,1,+PSDRUG,0):$S($G(DILOCKTM)>0:DILOCKTM,1:3) I Q
.S PSDREC(1)=$P($G(^PSD(58.8,PSDLOC,1,PSDRUG,0)),U,4)
.D NOW^%DTC S PSDAT=+%
.W !!,"Package Size: ",$P($G(NODE),"^")," Breakdown Unit: ",$P($G(NODE),"^",2),!
.S DIR(0)="NA^0:999999:2",DIR("A")="Correct Count: "
.S DIR("B")=PSDREC D ^DIR K DIR Q:$D(DIRUT) S PSDREC(1)=Y
.I Y=PSDREC W !!,"That's no change." G INV
.I Y>PSDREC S NAOU(1)=0 D ^PSDORSU G:$G(NAOU(1)) BAL I $G(PSDOUT) L -^PSD(58.8,+PSDLOC,1,+PSDRUG,0) Q
.S DIR(0)="58.81,15" W ! D ^DIR K DIR Q:$D(DIRUT) S PSDRE=Y
.S DIE="^PSD(58.8,+PSDLOC,1,",DA(1)=PSDLOC,DA=PSDRUG
.S DR="3////"_$G(PSDREC(1)) D ^DIE
.S $P(^PSD(58.8,PSDLOC,1,PSDRUG,0),"^",17)=1
.L -^PSD(58.8,+PSDLOC,1,+PSDRUG,0)
INV .I '$G(PSDAT) D NOW^%DTC S PSDAT=%
.S PSDREC=$G(PSDREC(1))-PSDREC G:'PSDREC TRA
MON .S:'$D(^PSD(58.8,+PSDLOC,1,+PSDRUG,5,0)) ^(0)="^58.801A^^"
.I '$D(^PSD(58.8,+PSDLOC,1,+PSDRUG,5,$E(DT,1,5)*100,0)) S DIC="^PSD(58.8,+PSDLOC,1,+PSDRUG,5,",DIC(0)="LM",DLAYGO=58.8,(X,DINUM)=$E(DT,1,5)*100,DA(2)=PSDLOC,DA(1)=PSDRUG D ^DIC K DIC,DLAYGO
.S DIE="^PSD(58.8,+PSDLOC,1,+PSDRUG,5,",DA(2)=PSDLOC,DA(1)=PSDRUG,DA=$E(DT,1,5)*100,DR="1////0;7////^S X=PSDREC" D ^DIE
TRA .W !!,"Recording ",$S(PSDREC:"adjustment",1:"inventory")," in transaction history.",!
TR .F L +^PSD(58.81,0):$S($G(DILOCKTM)>0:DILOCKTM,1:3) I Q
FIND .S PSDT=$P(^PSD(58.81,0),U,3)+1 I $D(^PSD(58.81,PSDT)) S $P(^PSD(58.81,0),U,3)=$P(^PSD(58.81,0),U,3)+1 G FIND
.S DIC="^PSD(58.81,",DIC(0)="L",DLAYGO=58.81,(DINUM,X)=PSDT D ^DIC K DIC,DLAYGO L -^PSD(58.81,0)
.S DIE="^PSD(58.81,",DA=PSDT,DR="1////"_$S(PSDREC:9,1:23)_";2////"_PSDLOC_";3////"_PSDAT_";4////"_PSDRUG_";5////"_PSDREC_";6////"_DUZ_";9////"_PSDREC(2)_";15////"_$G(PSDRE)_";74////"_DUZ_";78////"_NUR2_";100////1" D ^DIE K DIE
.S:'$D(^PSD(58.8,+PSDLOC,1,+PSDRUG,4,0)) ^(0)="^58.800119PA^^"
.S DIC="^PSD(58.8,+PSDLOC,1,+PSDRUG,4,",DIC(0)="L",DLAYGO=58.8
.S (X,DINUM)=PSDT,DA(2)=PSDLOC,DA(1)=PSDRUG D ^DIC K DIC,DA,DLAYGO,Y
.S NAOU=PSDLOC,NAOUN=PSDLOCN
MM .I PSDREC S PHARM1=DUZ,PSDT=PSDAT,PSDR=PSDRUG,PSDRE=$G(PSDRE),QTY=-PSDREC D ^PSDRFM
REP S DIR(0)="Y",DIR("A")="Would you like a report of current balances"
S DIR("B")="No" D ^DIR K DIR D:Y=1 DEV^PSDBAN
QUIT K ^TMP("PSDB",$J) Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSDADJC 4388 printed Dec 13, 2024@01:44:51 Page 2
PSDADJC ;B'ham ISC/LTL,JPW - Balance Shift Checker for NAOU ; 16 Feb 94
+1 ;;3.0; CONTROLLED SUBSTANCES ;**53,66**;13 Feb 97;Build 3
+2 IF '$DATA(PSDSITE)
DO ^PSDSET
if '$DATA(PSDSITE)
GOTO QUIT
+3 NEW D1,D2,DIC,DIE,DINUM,D0,D1,DLAYGO,DR,DIR,DIRUT,DTOUT,DUOUT,NODE,PSAC,PSDAT,PSDLOC,PSDOUT,PSDLOCN,DA,PSDRUG,PSDRUGN,PSDS,PSDPKG,PSDBKU,PSAQ,PSDR,PSDREC,PSDT,X,Y,%,%H,%I
LOOK SET DIC="^PSD(58.8,"
SET DIC(0)="AEMQZ"
SET DIC("A")="Select NAOU: "
SET DIC("S")="I $P($G(^(0)),U,3)=+PSDSITE,$P($G(^(0)),U,2)[""N"",'$P(^(0),""^"",7),$S('$D(^(""I"")):1,+^(""I"")>DT:1,'^(""I""):1,1:0)"
+1 WRITE !
DO ^DIC
KILL DIC
if $DATA(DTOUT)!($DATA(DUOUT))!(Y<1)
GOTO QUIT
+2 ;VMP OIFO BAY PINES;VGF;PSD*3.0*53;ADDED SET OF VARIABLE NAOU
+3 SET (NAOU,PSDLOC)=+Y
SET (NAOUN,PSDLOCN)=$PIECE(Y,U,2)
SET PSDS=+$PIECE(Y(0),"^",4)
+4 IF '+$PIECE($GET(^PSD(58.8,PSDLOC,2)),"^",5)
WRITE !!,"This NAOU does not maintain a perpetual inventory balance to check.",!!
KILL PSDLOC,PSDLOCN,PSDS
GOTO LOOK
CHKD IF '$ORDER(^PSD(58.8,PSDLOC,1,0))
WRITE !!,"There are no drugs in ",PSDLOCN
GOTO QUIT
WIT WRITE !
SET NUR2=$$WITNESS^XUVERIFY("WITNESS")
+1 IF NUR2=DUZ
WRITE !!,"Wait a second, you can't witness yourself!",$CHAR(7)
GOTO WIT
+2 if NUR2'>0
GOTO QUIT
+3 WRITE !!,"Thank you, ",$SELECT($PIECE($GET(^VA(200,NUR2,.1)),U,4)]"":$PIECE($GET(^(.1)),U,4),1:$PIECE($GET(^VA(200,NUR2,0)),U))
+4 WRITE !!,"Give me a second to alphabetize.",!
+5 SET PSDRUG=0
SET PSDRUGN=""
+6 FOR
SET PSDRUG=$ORDER(^PSD(58.8,PSDLOC,1,PSDRUG))
if 'PSDRUG
QUIT
Begin DoDot:1
+7 if '$DATA(^PSD(58.8,+PSDLOC,1,+PSDRUG,0))!($PIECE($GET(^PSDRUG(+PSDRUG,0)),"^")']"")!('$PIECE($GET(^PSD(58.8,+PSDLOC,1,PSDRUG,0)),U,4))
QUIT
+8 SET PSDPKG=$PIECE($GET(^PSD(58.8,+PSDS,1,+PSDRUG,0)),"^",9)
SET PSDBKU=$PIECE($GET(^(0)),"^",8)
+9 SET ^TMP("PSDB",$JOB,$PIECE($GET(^PSDRUG(+PSDRUG,0)),U),PSDRUG)=PSDPKG_"^"_PSDBKU
KILL Y
End DoDot:1
+10 WRITE @IOF
SET (PSDRUG,PSDRUGN)=0
+11 FOR
SET PSDRUGN=$ORDER(^TMP("PSDB",$JOB,PSDRUGN))
if PSDRUGN']""
QUIT
FOR
SET PSDRUG=$ORDER(^TMP("PSDB",$JOB,PSDRUGN,PSDRUG))
if 'PSDRUG
QUIT
Begin DoDot:1
+12 if '$GET(^PSD(58.8,PSDLOC,1,PSDRUG,0))
QUIT
+13 SET NODE=$GET(^TMP("PSDB",$JOB,PSDRUGN,PSDRUG))
BAL WRITE !!,PSDRUGN,!!,"Balance: "
+1 SET (PSDREC,PSDREC(1),PSDREC(2))=$PIECE($GET(^PSD(58.8,PSDLOC,1,PSDRUG,0)),U,4)
+2 WRITE PSDREC," ",$PIECE(NODE,U,2)
+3 SET DIR(0)="Y"
SET DIR("A")="Count Correct"
SET DIR("B")="Yes"
+4 WRITE !
DO ^DIR
KILL DIR
if $DATA(DIRUT)
QUIT
+5 if Y=1
GOTO INV
+6 FOR
LOCK +^PSD(58.8,+PSDLOC,1,+PSDRUG,0):$SELECT($GET(DILOCKTM)>0:DILOCKTM,1:3)
IF $TEST
QUIT
+7 SET PSDREC(1)=$PIECE($GET(^PSD(58.8,PSDLOC,1,PSDRUG,0)),U,4)
+8 DO NOW^%DTC
SET PSDAT=+%
+9 WRITE !!,"Package Size: ",$PIECE($GET(NODE),"^")," Breakdown Unit: ",$PIECE($GET(NODE),"^",2),!
+10 SET DIR(0)="NA^0:999999:2"
SET DIR("A")="Correct Count: "
+11 SET DIR("B")=PSDREC
DO ^DIR
KILL DIR
if $DATA(DIRUT)
QUIT
SET PSDREC(1)=Y
+12 IF Y=PSDREC
WRITE !!,"That's no change."
GOTO INV
+13 IF Y>PSDREC
SET NAOU(1)=0
DO ^PSDORSU
if $GET(NAOU(1))
GOTO BAL
IF $GET(PSDOUT)
LOCK -^PSD(58.8,+PSDLOC,1,+PSDRUG,0)
QUIT
+14 SET DIR(0)="58.81,15"
WRITE !
DO ^DIR
KILL DIR
if $DATA(DIRUT)
QUIT
SET PSDRE=Y
+15 SET DIE="^PSD(58.8,+PSDLOC,1,"
SET DA(1)=PSDLOC
SET DA=PSDRUG
+16 SET DR="3////"_$GET(PSDREC(1))
DO ^DIE
+17 SET $PIECE(^PSD(58.8,PSDLOC,1,PSDRUG,0),"^",17)=1
+18 LOCK -^PSD(58.8,+PSDLOC,1,+PSDRUG,0)
INV IF '$GET(PSDAT)
DO NOW^%DTC
SET PSDAT=%
+1 SET PSDREC=$GET(PSDREC(1))-PSDREC
if 'PSDREC
GOTO TRA
MON if '$DATA(^PSD(58.8,+PSDLOC,1,+PSDRUG,5,0))
SET ^(0)="^58.801A^^"
+1 IF '$DATA(^PSD(58.8,+PSDLOC,1,+PSDRUG,5,$EXTRACT(DT,1,5)*100,0))
SET DIC="^PSD(58.8,+PSDLOC,1,+PSDRUG,5,"
SET DIC(0)="LM"
SET DLAYGO=58.8
SET (X,DINUM)=$EXTRACT(DT,1,5)*100
SET DA(2)=PSDLOC
SET DA(1)=PSDRUG
DO ^DIC
KILL DIC,DLAYGO
+2 SET DIE="^PSD(58.8,+PSDLOC,1,+PSDRUG,5,"
SET DA(2)=PSDLOC
SET DA(1)=PSDRUG
SET DA=$EXTRACT(DT,1,5)*100
SET DR="1////0;7////^S X=PSDREC"
DO ^DIE
TRA WRITE !!,"Recording ",$SELECT(PSDREC:"adjustment",1:"inventory")," in transaction history.",!
TR FOR
LOCK +^PSD(58.81,0):$SELECT($GET(DILOCKTM)>0:DILOCKTM,1:3)
IF $TEST
QUIT
FIND SET PSDT=$PIECE(^PSD(58.81,0),U,3)+1
IF $DATA(^PSD(58.81,PSDT))
SET $PIECE(^PSD(58.81,0),U,3)=$PIECE(^PSD(58.81,0),U,3)+1
GOTO FIND
+1 SET DIC="^PSD(58.81,"
SET DIC(0)="L"
SET DLAYGO=58.81
SET (DINUM,X)=PSDT
DO ^DIC
KILL DIC,DLAYGO
LOCK -^PSD(58.81,0)
+2 SET DIE="^PSD(58.81,"
SET DA=PSDT
SET DR="1////"_$SELECT(PSDREC:9,1:23)_";2////"_PSDLOC_";3////"_PSDAT_";4////"_PSDRUG_";5////"_PSDREC_";6////"_DUZ_";9////"_PSDREC(2)_";15////"_$GET(PSDRE)_";74////"_DUZ_";78////"_NUR2_";100////1"
DO ^DIE
KILL DIE
+3 if '$DATA(^PSD(58.8,+PSDLOC,1,+PSDRUG,4,0))
SET ^(0)="^58.800119PA^^"
+4 SET DIC="^PSD(58.8,+PSDLOC,1,+PSDRUG,4,"
SET DIC(0)="L"
SET DLAYGO=58.8
+5 SET (X,DINUM)=PSDT
SET DA(2)=PSDLOC
SET DA(1)=PSDRUG
DO ^DIC
KILL DIC,DA,DLAYGO,Y
+6 SET NAOU=PSDLOC
SET NAOUN=PSDLOCN
MM IF PSDREC
SET PHARM1=DUZ
SET PSDT=PSDAT
SET PSDR=PSDRUG
SET PSDRE=$GET(PSDRE)
SET QTY=-PSDREC
DO ^PSDRFM
End DoDot:1
if $DATA(DIRUT)!($GET(PSDOUT))
GOTO QUIT
REP SET DIR(0)="Y"
SET DIR("A")="Would you like a report of current balances"
+1 SET DIR("B")="No"
DO ^DIR
KILL DIR
if Y=1
DO DEV^PSDBAN
QUIT KILL ^TMP("PSDB",$JOB)
QUIT