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

PSDEST.m

Go to the documentation of this file.
  1. PSDEST ;BIR/BJW - Destroy a Drug from the Holding file ;9 Feb 98
  1. ;;3.0;CONTROLLED SUBSTANCES ;**8,79**;13 Feb 97;Build 20
  1. ;**Y2K compliance**, "P" added to date input string
  1. I '$D(PSDSITE) D ^PSDSET Q:'$D(PSDSITE)
  1. I '$D(^XUSEC("PSDMGR",DUZ)) W !!,"Please contact your Pharmacy Coordinator for access to",!,"destroy Controlled Substances.",!!,"PSDMGR security key required.",! G END
  1. S PSDUZ=DUZ
  1. I PSDUZ S PSDUZAN=$P($G(^VA(200,+PSDUZ,0)),"^")
  1. SETDATE ;7/17/96,inital set to current date
  1. S PSDT=DT
  1. ASKD ;ask disp location
  1. S PSDS=$P(PSDSITE,U,3),PSDSN=$P(PSDSITE,U,4)
  1. G:$P(PSDSITE,U,5) ASKN
  1. K DIC,DA S DIC=58.8,DIC(0)="QEAZ",DIC("S")="I $P(^(0),""^"",3)=+PSDSITE,$S($P(^(0),""^"",2)[""M"":1,$P(^(0),""^"",2)[""S"":1,1:0)"
  1. S DIC("A")="Select Primary Dispensing Site: ",DIC("B")=PSDSN
  1. D ^DIC K DIC G:Y<0 END
  1. S PSDS=+Y,PSDSN=$P(Y,"^",2),$P(PSDSITE,U,3)=+Y,$P(PSDSITE,U,4)=PSDSN
  1. ASKN ;ask holding number
  1. W !!,?3,"**Searching for the next available drug awaiting destruction**",!
  1. K DIC,DA S DIC=58.86,DIC("A")="Select Destructions #: ",DIC(0)="QEAZ",DIC("S")="I $P(^(0),""^"",7)=PSDS"
  1. F PSD=0:0 S PSD=$O(^PSD(58.86,PSD)) Q:'PSD!($D(DIC("B"))) I $D(^PSD(58.86,PSD,0)),'+$P(^(0),"^",10),+$P(^(0),"^",7)=+PSDS S DIC("B")=PSD
  1. D ^DIC K DA,DIC G:Y<0 END S PSDA=+Y
  1. W !!,?3,"**You Must enter a DATE to destroy or cancel this Holding Num**"
  1. DISPLAY ;
  1. K LN S $P(LN,"-",30)="",PSDR=$P(Y(0),"^",2),PSDRN=$S($P($G(^PSD(58.86,PSDA,1)),"^")]"":$P($G(^PSD(58.86,PSDA,1)),"^"),1:$P($G(^PSDRUG(+PSDR,0)),"^")),NUM=$P(Y(0),"^"),QTY=$P(Y(0),"^",3)
  1. S PSDCT=$S($P(Y(0),"^",8)]"":$P(Y(0),"^",8),1:1),NBKU=$S($P(Y(0),"^",12)]"":$P(Y(0),"^",12),1:$P($G(^PSD(58.8,+PSDS,1,+PSDR,0)),"^",8))
  1. S PSDCAN=$P($G(^PSD(58.86,PSDA,3)),"^") I PSDCAN S Y=PSDCAN X ^DD("DD") S PSDCAN=Y D MSG2 G ASKN
  1. S PSDST=$P(Y(0),"^",11) I PSDST S Y=PSDST X ^DD("DD") S PSDST=Y D MSG1 G ASKN
  1. W @IOF,!,"HOLDING FOR DESTRUCTION",!,LN,!!,"Holding Number: ",NUM
  1. W !,"Drug: ",PSDRN,!,"Quantity "_$S($D(^PSD(58.8,+PSDR,0)):"("_NBKU_")",1:"")_": ",QTY,!
  1. OK ;ask ok
  1. K DA,DIR,DIRUT S DIR(0)="Y",DIR("B")="YES",DIR("A")="Do you want to destroy this Controlled Substances"
  1. S DIR("?",1)="Answer 'YES' if you are destroying this drug,",DIR("?")="answer 'NO' and this drug will remain pending destruction."
  1. D ^DIR K DIR I $D(DIRUT) D MSG G END
  1. S ANS=Y(0) I ANS="YES" D DATE G:'$D(PSDT) END G DIE
  1. I ANS="NO" G OK1 G:'$D(PSDT) END
  1. DATE ; ask date,7/17/96 added %DT("B")default date or user can enter new date
  1. K %DT W !
  1. S %DT="AEPTX",%DT(0)="-NOW",%DT("A")="DATE DESTROYED/CANCELLED: ",%DT("B")=$$FMTE^XLFDT(PSDT) D ^%DT G:Y<0 END S PSDT=Y W !
  1. Q
  1. OK1 ;ask if entry error
  1. K DA,DIR,DIRUT S DIR(0)="Y",DIR("B")="NO",DIR("A")="Was this a destruction holding number entry error"
  1. S DIR("?",1)="Answer 'NO' drug will be destroyed,",DIR("?")="answer 'YES' and this drug will not be destroyed."
  1. D ^DIR K DIR I $D(DIRUT) D MSG G END
  1. OK2 ;ask do you want to cancel holding #,E3R# 4990
  1. K DA,DIR,DIRUT S DIR(0)="Y",DIR("B")="NO",DIR("A")="Do you want to cancel this destruction holding number"
  1. S DIR("?",1)="Answer 'NO' if you do not want to cancel this destruction holding number,",DIR("?")="answer 'YES' and the destruction holding number will be cancelled."
  1. D ^DIR K DIR I $D(DIRUT) D MSG G END
  1. I 'Y DO MSG G ASKN
  1. DIRC ;enter reason,date and pharmacist cancelling holding #,E3R# 4990
  1. W !! D DATE G:'$D(PSDT) END
  1. COM ; enter free-text information(comments)
  1. K DA,DIR,DIRUT S DIR(0)="58.86,17" D ^DIR K DIR I $D(DIRUT) D MSG G END
  1. I Y[";" W !,"A semicolon is not allowed in the COMMENTS field. Please edit your entry.",$C(7) G COM
  1. S PSDCOM3=Y
  1. K DIRUT,DTOUT,DUOUT
  1. I PSDT S (Y,YYY)=PSDT X ^DD("DD") S PSDT=Y
  1. W !,"DATE/TIME CANCELLED: ",PSDT
  1. W !,"CANCELLED BY: ",PSDUZAN
  1. DIE1 ;update 58.86 for cancelling holding #,E3R# 4990
  1. ;The AC,AD X-ref's entries are built on the condition that data is in
  1. ;Field 10(date/time destroyed),11/29/95 added I $D(Y)
  1. K DA,DIE,DR S DA=PSDA,DIE=58.86,DR="9////"_PSDUZ_";10///"_PSDT_";15///"_PSDT_";16////"_PSDUZ_";17////"_PSDCOM3_";11///^S X=PSDCT;12///^S X=NBKU" D ^DIE K DA,DIE,DR I $D(Y) D MSG G END
  1. W !!,"Holding Number: ",NUM,?19," flagged as entry error"
  1. S PSDT=YYY G ASKN
  1. DIE ;update 58.86
  1. ;10/22/96 added / to fld#11,12 to remove prompt;11/29/95 added I $D(Y)
  1. W !,?3,"** Updating the record **",! K DA,DIE,DR S DA=PSDA,DIE=58.86,DR="9////"_PSDUZ_";10///"_PSDT_";11///^S X=PSDCT;12///^S X=NBKU" D ^DIE K DA,DIE,DR
  1. I $D(Y) D MSG G END
  1. W !!,?3,"=> Holding Number: ",NUM," has been destroyed.",!!
  1. G ASKN
  1. END K %,%DT,%H,%I,ANS,DA,DIC,DIE,DIR,DIROUT,DIRUT,DR,DTOUT,DUOUT,LN,NBKU,NUM
  1. K PSD,PSDA,PSDCAN,PSDCOM3,PSDR,PSDRN,PSDCT,PSDS,PSDSN,PSDT,PSDST,PSDUZ,PSDUZAN,QTY,X,Y,YYY
  1. Q
  1. MSG W !!,"No action taken",!!
  1. Q
  1. MSG1 ;msg when already destroyed
  1. W $C(7),!!,"Drug: ",PSDRN,!,"=> Destruction #: ",NUM," was destroyed on ",PSDST,".",!!
  1. Q
  1. MSG2 ;msg when cancelled,E3R# 4990
  1. W $C(7),!!,"Drug: ",PSDRN,!,"=> Destruction #: ",NUM," was cancelled on ",PSDCAN,".",!!
  1. Q