source: FOIAVistA/trunk/r/CONTROLLED_SUBSTANCES-PSD/PSDNRGS.m@ 1800

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

initial load of FOIAVistA 6/30/08 version

File size: 4.5 KB
Line 
1PSDNRGS ;BIR/JPW-Receive Green Sheet for NAOU ; 6 Jan 94
2 ;;3.0; CONTROLLED SUBSTANCES ;**56,66,65**;13 Feb 97;Build 5
3 I '$D(PSDSITE) D ^PSDSET Q:'$D(PSDSITE)
4 S OK=$S($D(^XUSEC("PSJ RNURSE",DUZ)):1,$D(^XUSEC("PSD NURSE",DUZ)):1,$D(^XUSEC("PSJ RPHARM",DUZ)):2,$D(^XUSEC("PSJ PHARM TECH",DUZ)):2,1:0)
5 I 'OK W $C(7),!!,?9,"** Please contact your Coordinator for access to complete",!,?12,"narcotic orders.",!!,"PSJ RNURSE, PSD NURSE, 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 W !!,"Receive Controlled Substances Orders and Green Sheet" S PSDUZ=DUZ,PSDUZN=$S($P($G(^VA(200,PSDUZ,0)),"^")]"":$P(^(0),"^"),1:"")
8 N X,X1 D SIG^XUSESIG Q:X1=""
9ASKN ;ask naou
10 W ! K DA,DIC S DIC=58.8,DIC(0)="QEAZ",DIC("A")="Select NAOU: "
11 S:OK=1 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)"
12 S:OK=2 DIC("S")="I $P(^(0),""^"",3)=+PSDSITE,$S('$D(^(""I"")):1,'^(""I""):1,+^(""I"")>DT:1,1:0),$P(^(0),""^"",2)=""N"""
13 D ^DIC K DIC G:Y<0 END S AOU=+Y,AOUN=$P(Y,"^",2)
14GS ;select green sheet #
15 W ! K DA,DIC S DIC("A")="Select the Green Sheet #: ",DIC=58.81,DIC(0)="QEASZ",D="D"
16 S DIC("S")="I $P(^(0),""^"",11),$P(^(0),""^"",11)<12"
17 D IX^DIC K DIC G:Y<0 ASKN S PSDA=+Y
18ORD S STAT=+$P(Y(0),"^",11),PSDPN=$P(Y(0),"^",17),STATN="" I STAT S STATN=$P($G(^PSD(58.82,STAT,0)),"^")
19 S ORD=+$P(Y(0),"^",20),NAOU=+$P(Y(0),"^",18),NAOUN=$P($G(^PSD(58.8,NAOU,0)),"^"),PSDR=+$P(Y(0),"^",5),PSDRN=$P($G(^PSDRUG(PSDR,0)),"^"),QTY=+$P(Y(0),"^",6)
20 ; >> RJS - *65
21 L +^PSD(58.81,PSDA):$S($G(DILOCKTM)>0:DILOCKTM,1:3)
22 I '$T W !,"The Green Sheet # ",PSDPN," is currently in use by another user",!,"Please select another Green Sheet.",! G GS
23 I $D(^PSD(58.81,PSDA,4)),+$P(^(4),"^",3) S QTY=$P(^(4),"^",3)
24 I AOU'=NAOU W $C(7),!!,"The Green Sheet # ",PSDPN," is assigned to ",NAOUN,".",!,"Please select another Green Sheet.",! L -^PSD(58.81,PSDA) G GS ; <RJS - *65
25 I '$D(^PSD(58.8,NAOU,1,PSDR,3,ORD,0)) W $C(7),!!,"There's no data on ",NAOUN," for Green Sheet # ",PSDPN,".",!,"Contact your Pharmacy Coordinator for assistance.",! L -^PSD(58.81,PSDA) G END ; <RJS - *65
26 I STAT'=3 W $C(7),!!,"This Green Sheet has a status of "_$S(STATN]"":STATN,1:"UNKNOWN")_".",!,"Please select another Green Sheet.",! L -^PSD(58.81,PSDA) G GS ; RJS - *65
27 D NOW^%DTC S (RECD,Y)=+$E(%,1,12) X ^DD("DD") S RECDT=Y
28REC ;receive at order level in 58.8
29 W !!,"Accessing ",PSDRN," information...",!!
30 K DA,DIR,DIRUT S DIR(0)="58.81,27",DIR("B")=QTY D ^DIR K DIR I $D(DIRUT) W !!,"Quantity not entered. No action taken.",!,"This order remains ",STATN,!! L -^PSD(58.81,PSDA) G END ; < RJS - *65
31 S RQTY=Y I RQTY'=QTY W $C(7),!!,"The quantity received does not match the quantity dispensed.",!,"This order must be returned to pharmacy for investigation.",!! L -^PSD(58.81,PSDA) G GS ;< RJS - *65
32 K DA,DIE,DR S DA=ORD,DA(1)=PSDR,DA(2)=NAOU
33 S DIE="^PSD(58.8,"_DA(2)_",1,"_DA(1)_",3,"
34 S DR=$S(OK=1:"6////"_PSDUZ,1:"6RECEIVED BY NURSE")_";20////"_QTY_";15////"_RECD_";10////4;22////"_$P($G(^PSD(58.8,NAOU,1,PSDR,0)),U,4)_";25////"_$P($G(^PSD(58.8,NAOU,1,PSDR,0)),U,4) D ^DIE K DA,DIE,DR
35 I ($D(Y))!($D(DTOUT)) W $C(7),!!,"*** THIS ORDER HAS NOT BEEN RECEIVED ***",!,"Receiving nurses name must be entered.",!!,"The status remains "_STATN,! L -^PSD(58.81,PSDA) G END ;< RJS - *65
36UPDATE ;update 58.8 and 58.81
37 ;updating drug balance in 58.8
38 F L +^PSD(58.8,NAOU,1,PSDR,0):$S($G(DILOCKTM)>0:DILOCKTM,1:3) I Q
39 ;PSD*3*56;REMOVED CHECK FOR PATIENT ID
40 S $P(^PSD(58.8,NAOU,1,PSDR,0),"^",4)=$P(^PSD(58.8,NAOU,1,PSDR,0),"^",4)+QTY
41 L -^PSD(58.8,NAOU,1,PSDR,0)
42 ;update transaction file (58.81)
43 S OREC=$P($G(^PSD(58.8,NAOU,1,PSDR,3,ORD,0)),"^",7)
44 K DA,DIE,DR S DA=PSDA,DIE=58.81
45 S DR="10////"_$S('$P($G(^PSD(58.8,NAOU,2)),U,5):4,$P($G(^PSD(58.81,PSDA,9)),U):4,1:13)_";20////"_OREC_";21////"_RECD_";27////"_QTY_";I OK=1 S Y=""@1"";15COMMENTS;@1"
46 D ^DIE K DA,DIE,DR
47 I OK=2 S $P(^PSD(58.81,PSDA,1),"^",11)=PSDUZ
48 W !!,"Updating your records now..."
49 ;update worksheet file (58.85) to be purged
50 S DA=+$O(^PSD(58.85,"AD",NAOU,PSDR,ORD,0)) I DA,$D(^PSD(58.85,DA,0)) K DIE,DR S DIE=58.85,DR="6////4" D ^DIE K DA,DIE,DR
51 W "done.",!!
52 S STAT=$P($G(^PSD(58.81,PSDA,0)),"^",11) W ?5,"*** Your Green Sheet #"_PSDPN_" is now "_$S($P($G(^PSD(58.82,STAT,0)),"^")]"":$P(^(0),"^"),1:"UNKNOWN")_" ***",!
53 L -^PSD(58.81,PSDA) ;< RJS - *65
54 G GS
55END K %,%DT,%H,%I,AOU,AOUN,D,DA,DIC,DIE,DR,DTOUT,DUOUT
56 K NAOU,NAOUN,OK,ORD,OREC,PSDPN,PSDR,PSDRN,PSDUZ,PSDUZN,QTY,RECD,RECDT,RQTY,STAT,STATN,SUB,PSDA,X,Y
57 Q
Note: See TracBrowser for help on using the repository browser.