source: WorldVistAEHR/trunk/r/CONTROLLED_SUBSTANCES-PSD/PSDRFW.m@ 1608

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

initial load of WorldVistAEHR

File size: 5.5 KB
Line 
1PSDRFW ;BIR/JPW,LTL-Nurse RF Dispensing ; 8 Aug 94
2 ;;3.0; CONTROLLED SUBSTANCES ;**25,53,60**;13 Feb 97
3 ;Reference to $$WITNESS^XUVERIFY are covered by DBIA #1513
4 ;Reference to ^PSD(58.8 are covered by DBIA #2711
5 ;Reference to ^PSD(58.81 are covered by DBIA #2808
6 ;Reference to ^PSDRUG( are covered by DBIA #221
7 I '$D(PSDSITE) D ^PSDSET Q:'$D(PSDSITE)
8 ;S OK=$S($D(^XUSEC("PSJ RNURSE",DUZ)):1,1:0) I 'OK W $C(7),!!,?9,"** Please contact your Pharmacy Coordinator for access to order",!,?12,"narcotic supplies.",! K OK Q
9 I $P($G(^VA(200,DUZ,20)),U,4)']"" N XQH S XQH="PSD ESIG" D EN^XQH G END
10 S PSDUZ=DUZ,(MSG,MSG1)=0,Y=DT X ^DD("DD") S REQD=Y
11NURSE N X,X1 D SIG^XUSESIG I X1="" G END
12NAOU ;select NAOU to dispense from
13 I $G(NAOU) S PSDS=+$P(^PSD(58.8,NAOU,0),U,4) G PATIENT
14 W !!,"Please enter the ward from which the drug(s) will be signed out."
15 K DA,DIC S DIC=58.8,DIC(0)="QEA",DIC("A")="Select Ward: "
16 S DIC("S")="I $P(^(0),""^"",3)=+PSDSITE,$S('$D(^(""I"")):1,'^(""I""):1,+^(""I"")>DT:1,1:0),$P(^(0),""^"",2)=""N"",'$P(^(0),""^"",7)"
17 W ! D ^DIC K DIC G:Y<0 END S NAOU=+Y,NAOUN=$P(Y,"^",2)
18 I '$D(^PSD(58.8,NAOU,0)) S MSG=1 D MSG G END
19 I '$O(^PSD(58.8,NAOU,1,0)) S MSG=1,MSG1=2 D MSG G END
20 I '$P(^PSD(58.8,NAOU,0),U,4) S MSG=2 D MSG G END
21 S PSDS=+$P(^PSD(58.8,NAOU,0),"^",4),PSDS=PSDS_"^"_+$P(^PSD(58.8,+PSDS,0),"^",5) I '+PSDS S (MSG,MSG1)=1 D MSG G END
22 I '$D(^PSD(58.8,+PSDS,0)) S MSG=2 D MSG G END
23 I '$O(^PSD(58.8,+PSDS,1,0)) S MSG=2,MSG1=2 D MSG G END
24 ;S TYPE=$P(^PSD(58.8,+PSDS,0),"^",2),OKTYP=$S(TYPE="M":1,TYPE="S":1,1:0) I 'OKTYP W !!,"Contact your Pharmacy Coordinator.",!,"The Pharmacy Dispensing Site is invalid for this NAOU." G END
25PATIENT W !!,"Wastage can only be recorded within "
26 S NAOU(1)=$S($P($G(^PSD(58.8,NAOU,6)),U,2):$P(^(6),U,2),1:12)
27 W NAOU(1)," hours after signing out a dose.",!!
28 W "(except for PCA syringes and Infusions)"
29 N DIC,DTOUT,DUOUT,X,Y,PSDOUT S DIC="^DPT(",DIC(0)="AEMQ"
30 S DIC("A")="Scan/Enter Patient: "
31 W ! D ^DIC K DIC G:Y<1 END S PAT=+Y
32DRUG ;select drug
33 N DIR,PSD,PSDA,PSDR,PSDQ,PSDDT
34 S DIR(0)="FAO^1:40",DIR("A")="Scan Drug Label or Enter Label # or Drug: "
35 W ! D ^DIR K DIR G:$D(DIRUT) END
36 I $L(Y)=1,Y'=" " W $C(7),!!,"Please enter more than one character.",! G DRUG
37 I $O(^PSD(58.81,"D",Y,0)) D
38 .S PSD=0
39 .F S PSD=$O(^PSD(58.81,"D",Y,PSD)) Q:'PSD S PSD(1)=$G(^PSD(58.81,PSD,0)) I $P(PSD(1),U,11)>3,$P(PSD(1),U,18)=NAOU S PSDR=$P(PSD(1),U,5),PSDPN=$P(PSD(1),U,17),PSDTYP=17
40 I $D(PSDR),PSDR'=Y D
41 .I $D(^PSDRUG(Y)),$D(^PSD(58.8,NAOU,1,Y)) D
42 ..S PSDDT=$$FMDIFF^DILIBF(DT,$P(PSD(1),U,4),"")
43 ..I PSDDT>365 S PSDR=Y
44 .I '$D(^PSDRUG(Y)),$D(PSD(1)) D
45 ..S PSDDT=$$FMDIFF^DILIBF(DT,$P(PSD(1),U,4),"")
46 ..I PSDDT>365 K PSDR
47 .I '$D(^PSDRUG(Y)),'$D(^PSD(58.8,NAOU,1,Y)),'$D(PSDR) W $C(7),!!,"This is not a valid Pharmacy Dispensing number for this ward.",!! G END
48 D:'$G(PSDR) G:$D(DTOUT)!($D(DUOUT)) END G:Y<1 PATIENT
49 .S DIC="^PSD(58.8,NAOU,1,",DIC(0)="EMQSZ",DA(1)=NAOU
50 .W ! D ^DIC K DIC I $D(DTOUT)!($D(DUOUT))!(Y<1) W $C(7),!!,"This is not a valid Pharmacy Dispensing number for this ward.",!! Q
51 .S PSDR=+Y,PSDTYP=17
52 I '$G(PSDR) W $C(7),!!,"This is not a valid Pharmacy Dispensing number for this ward.",!! G END
53 W:$G(PSDR) !!,$P($G(^PSDRUG(PSDR,0)),U)
54BAL S PSDR(1)=$G(^PSD(58.8,NAOU,1,PSDR,0)),OQTY=$P(PSDR(1),U,4)
55 ;PSD*3*25 (DAVE B)
56 K PSDDAVE D ^PSDRFV I $G(PSDDAVE)=1 K PSDDAVE S PSDOUT=1 G END
57 I '$G(PSDA(1)) W !!,"No doses signed out",!! G END
58 S OQTY=$P($G(^PSD(58.81,PSDA(1),0)),U,6)
59 I $$FMADD^XLFDT(PSDA(3),"",NAOU(1))<$$NOW^XLFDT W !!,"The last dose was signed out at ",PSDA(2),", over ",NAOU(1)," hours ago.",!!,"It is too late to record wastage.",!! G END
60 I PSDA(4)'=DUZ W !!,"Sorry, only the person that signed out the dose can record delayed wastage.",!! G END
61 ;S DIR(0)="Y",DIR("A")="Starting Balance: "_OQTY_" "_$P(PSDR(1),U,8)_" Correct count"
62 ;S DIR("B")="Yes",NUR1=DUZ
63 ;S DIR("?")="Answer Yes if the amount on hand equals the starting balance."
64 ;W ! D ^DIR K DIR G:$D(DIRUT) END
65 ;I Y=0 D ^PSDRF2 G:$G(PSDOUT) END S $P(PSDR(1),U,4)=PSDQ(1),OQTY=PSDQ(1)
66QTY S DIR(0)="NA^0:"_OQTY_":2"
67 S DIR("A")="Amount actually given at "_PSDA(2)_": "
68 W ! D ^DIR K DIR I $D(DIRUT)!(Y=OQTY) S PSDOUT=1 G END
69 S PSDQ=Y
70WASTE I PSDQ'=OQTY D G:$G(PSDOUT) END
71 .I (OQTY-PSDQ)>1 D Q:$G(PSDOUT) G REA
72 ..S DIR(0)="N^1:"_(OQTY-PSDQ)_":2",DIR("A")="Amount wasted"
73 ..S DIR("B")=OQTY-PSDQ D ^DIR K DIR I $D(DIRUT) S PSDOUT=1 Q
74 ..S WQTY=Y S:OQTY-WQTY PSDQ(2)=OQTY-WQTY
75 .S WQTY=$S('$G(PSDQ(1)):OQTY-PSDQ,1:PSDQ)
76 .W ?55,"Amount wasted: ",WQTY,!
77REA .S DIR(0)="58.81,15" D ^DIR K DIR I $D(DIRUT) S PSDOUT=1 Q
78 .S PSDRE=Y
79WIT .W ! S NUR2=$$WITNESS^XUVERIFY("WITNESS")
80 .I NUR2=DUZ W !!,"Wait a minute, you can't witness yourself!",$C(7) G WIT
81 .I NUR2'>0 S PSDOUT=1 Q
82 .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))
83 ;VMP OIFO BAY PINES;VGF;PSD*3.0*53;REMOVED CALL TO WASTE^PSDRFR
84 D EDIT^PSDRFX
85END I $G(PSDQ(1)),$G(PSDOUT) S $P(^PSD(58.81,PSDA(1),0),U,6)=PSDQ
86 W:$G(PSDOUT) !!,"No wastage recorded.",$C(7),!! K %,%DT,%H,%I,CNT,CNT1,DA,DIC,DIE,DINUM,DIR,DIROUT,DIRUT,DIWF,DIWL,DIWR,DR,DTOUT,DUOUT,LN,MSG,MSG1,PSDTYP,NUR2
87 K NAOU,NAOUN,NBKU,NPKG,OK,OKTYP,ORD,PAT,PSDA,PSDEM,PSDOUT,PSDQTY,PSDRD,PSDR,PSDRE,PSDRN,PSDS,PSDT,PSDUZ,PSDUZN,PSDPN,REQD,TEXT,TYPE,WQTY,OQTY,PSDQ,WORD,NUR1,X,Y
88 Q
89MSG ;display error message
90 W $C(7),!!,?10,"Contact your Pharmacy Coordinator.",!,?10,"This "_$S(MSG=2:"Dispensing Site",MSG=1:"NAOU",1:"Drug")_" is missing "
91 W $S(MSG1=1:"Primary Disp. Site",MSG1=2:"stocked drugs",MSG1=3:"narcotic breakdown unit",MSG1=4:"narcotic package size",1:"data")_".",!
92 Q
Note: See TracBrowser for help on using the repository browser.