source: FOIAVistA/trunk/r/CONTROLLED_SUBSTANCES-PSD/PSDDWK.m@ 631

Last change on this file since 631 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 4.8 KB
Line 
1PSDDWK ;BIR/JPW-Pharm Dispensing Worksheet ;6 July 94
2 ;;3.0; CONTROLLED SUBSTANCES ;**59**;13 Feb 97;Build 1
3 I '$D(PSDSITE) D ^PSDSET Q:'$D(PSDSITE)
4 S OK=$S($D(^XUSEC("PSJ RPHARM",DUZ)):1,$D(^XUSEC("PSJ PHARM TECH",DUZ)):1,1:0)
5 I 'OK W $C(7),!!,?9,"** Please contact your Pharmacy Coordinator for access to",!,?12,"process/dispense narcotic supplies.",!!,"PSJ RPHARM or PSJ PHARM TECH security key required.",! K OK Q
6 I $P($G(^VA(200,DUZ,20)),U,4)']"" N XQH S XQH="PSD ESIG" D EN^XQH Q
7 I '$O(^PSD(58.85,0)) W $C(7),!!,"There are no pending request orders.",!! Q
8 S (PSDNO,NOFLAG)=0
9ASKD ;ask dispensing location
10 S PSDS=$P(PSDSITE,U,3),PSDSN=$P(PSDSITE,U,4)
11 I $P(PSDSITE,U,5) S OKD=1,NODED=^PSD(58.8,+PSDS,0) G SETD
12 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)"
13 S DIC("A")="Select Primary Dispensing Site: ",DIC("B")=PSDSN
14 D ^DIC K DIC G:Y<0 END
15 ;set PSDS=disp.site,PSDM=ask mfg/lot#/exp.date,SITE=inpat.site,PSDAG=auto gen.disp.#s,PSDRG=using form 10-179,PSDGS=print green sheet
16 S PSDS=+Y,PSDSN=$P(Y,"^",2),NODED=Y(0)
17 S $P(PSDSITE,U,3)=+Y,$P(PSDSITE,U,4)=PSDSN
18SETD S PSDM=+$P(NODED,"^",5),PSDAG=+$P($G(^PSD(58.8,+PSDS,2)),"^")
19 S PSDRG=+$P($G(^PSD(58.8,+PSDS,2)),"^",5),PSDGS=+$P($G(^PSD(58.8,+PSDS,2)),"^",6)
20 I '$D(^PSD(58.85,"AW",+PSDS)) D MSG G END
21ASKM ;ask method of dispensing - by worksheet or individual request
22 K DA,DIR,DIRUT S DIR(0)="SOB^W:Worksheet;R:Individual Request",DIR("A")="Dispensing Method"
23 S DIR("?",1)="Enter 'W' to dispense by last worksheet printed, enter 'R' to",DIR("?")="dispense by individual request, or '^' to quit"
24 D ^DIR K DIR G:$D(DIRUT) END S ANS=Y
25 S PSDOUT=0 N X,X1 D SIG^XUSESIG G:X1="" END D:ANS="R" REQ D:ANS="W" WK
26 I 'NOFLAG D MSG
27END K %,%H,%I,%ZIS,ACT,ALL,ANS,BAL,CNT,COMM,DA,DIC,DIE,DIR,DIROUT,DIRUT,DIWF,DIWL,DIWR,DR,DTOUT,DUOUT,EXP,EXPD,FLAG
28 K LN,LOOP,LOT,MFG,MSG,NAOU,NAOUN,NBKU,NEW,NODE,NODED,NOFLAG,NPKG,NSITE,OK,OKD,ORD,ORDN,ORDS,ORDSN,PAT,PSDLCK
29 K PRT,PSD,PSDAG,PSDAGN,PSDBY,PSDBYN,PSDDT,PSDG,PSDGS,PSDGSN,PSDIO,PSDLES,PSDM,PSDMN,PSDN,PSDNA,PSDNO,PSDOUT,PSDPN
30 K PSDR,PSDRN,PSDREC,PSDRG,PSDRGN,PSDRN,PSDS,PSDSN,PSDT,PSDUZA,QTY,REQ,REQD,REQDT,SITE,STAT,TECH,TEXT,WORD,X,Y
31 Q
32WK ;compile worksheet dispensing data
33 W !!,"Accessing worksheet information..."
34 F PSD=0:0 S PSD=$O(^PSD(58.85,"AW",+PSDS,PSD)) Q:('PSD)!(PSDOUT) D
35 .F PSDN=0:0 S PSDN=$O(^PSD(58.85,"AW",+PSDS,PSD,PSDN)) Q:('PSDN)!(PSDOUT) I $D(^PSD(58.85,PSDN,0)) D SET Q:PSDLCK D:STAT<3&($D(^PSD(58.8,+$G(ORDS),1,+$G(PSDR)))) ^PSDDWK1,PSDLCK Q:PSDOUT ;; PSD*3*59 ADDED PSDLCK
36 Q
37REQ ;dispense by individual request
38 W !!,"Accessing worksheet information..."
39 F PSD=0:0 S PSD=$O(^PSD(58.85,"AW",+PSDS,PSD)) Q:'PSD F PSDN=0:0 S PSDN=$O(^PSD(58.85,"AW",+PSDS,PSD,PSDN)) Q:'PSDN I $D(^PSD(58.85,PSDN,0)),$P(^(0),"^",7)<3 S NOFLAG=1
40 Q:'NOFLAG
41 K DA,DIC W ! S DIC=58.85,DIC(0)="QEA",DIC("A")="Select Request #: ",DIC("S")="I $P(^(0),""^"",2)=+PSDS,$P(^(0),""^"",7)<3" D ^DIC K DIC Q:Y<0 S PSDN=+Y D SET
42 I PSDLCK W !!,"This request is currently being processed by ",$P(^VA(200,$P(^XTMP("PSDLCK",PSDN,0),"^",3),0),"^") G REQ ;; PSD*3*59 LOCK MESSAGE
43 I STAT>2 W !!,"The status of this request is "_$P($G(^PSD(58.82,STAT,0)),"^")_".",!,"You cannot edit this request using this option.",! G REQ
44 D ^PSDDWK1,PSDLCK Q:PSDOUT ;; PSD*3*59 ADDED PSDLCK
45 G REQ
46SET ;sets data for display/editing
47 Q:'$D(^PSD(58.85,PSDN,0)) S NODE=^(0),(NSITE,PSDMN,PSDAGN,PSDRGN,PSDGSN)=0
48 ;; PSD*3*59 LOCK RECORD
49 S PSDLCK=0
50 S STAT=+$P(NODE,"^",7) Q:STAT>2 S PSDRN=+$P(NODE,"^",5)
51 L +^PSD(58.85,PSDN):0
52 S:'$T PSDLCK=1 Q:PSDLCK
53 S ^XTMP("PSDLCK",PSDN,0)=$$FMADD^XLFDT(DT,1,0,0,0)_"^"_DT_"^"_DUZ ;; END PSD*3*59
54 S NAOU=+$P(NODE,"^",3),NAOUN=$S($P($G(^PSD(58.8,NAOU,0)),"^")]"":$P(^(0),"^"),1:"ZZ/"_NAOU)
55 S PSDR=+$P(NODE,"^",4),PSDRN=$S($P($G(^PSDRUG(PSDR,0)),"^")]"":$P(^(0),"^"),1:"ZZ/"_PSDR)
56 S ORDS=+$P(NODE,"^",2),ORDSN=$P($G(^PSD(58.8,+ORDS,0)),"^")
57 S PSDUZA=+$P(NODE,"^",19)
58 S REQ=+$P(NODE,"^",5),REQDT=$P(NODE,"^",18) I REQDT S Y=$E(REQDT,1,7) X ^DD("DD") S REQD=Y
59 S QTY=$S($P(NODE,"^",17):$P(NODE,"^",17),1:$P(NODE,"^",6)),PSDPN=$P(NODE,"^",15),PSDT=$P(NODE,"^",14) I PSDT S Y=$E(PSDT,1,7) X ^DD("DD") S PSDDT=Y
60 S ORD=+$P(NODE,"^",12),ORDN=$P($G(^VA(200,+ORD,0)),"^"),PSDBY=+$P(NODE,"^",13),PSDBYN="" I PSDBY S PSDBYN=$P($G(^VA(200,PSDBY,0)),"^")
61 S PAT=$P($G(^PSD(58.85,PSDN,2)),U,3)
62 I $D(^XUSEC("PSJ RPHARM",DUZ)),'PSDBY S PSDBY=DUZ,PSDBYN=$P($G(^VA(200,PSDBY,0)),"^")
63 S (MFG,LOT,EXP,EXPD,NBKU,NPKG)=""
64 I $D(^PSD(58.8,+ORDS,1,PSDR,0)) S MFG=$P(^(0),"^",10),LOT=$P(^(0),"^",11),EXP=$P(^(0),"^",12),NBKU=$P(^(0),"^",8),NPKG=+$P(^(0),"^",9) I EXP S Y=EXP X ^DD("DD") S EXPD=Y
65 Q
66MSG W $C(7),!!,"There are no pending CS requests for ",PSDSN,".",!
67 W !,"Press <RET> to return to the menu" R X:DTIME W !!
68 Q
69PSDLCK ;; PSD*3*59 CLEAR LOCKS FOR THIS ORDER
70 L -^PSD(58.85,PSDN)
71 K ^XTMP("PSDLCK",PSDN),STAT
72 Q
Note: See TracBrowser for help on using the repository browser.