source: WorldVistAEHR/trunk/r/CONTROLLED_SUBSTANCES-PSD/PSDORD.m@ 1093

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

initial load of WorldVistAEHR

File size: 3.9 KB
Line 
1PSDORD ;BIR/JPW,LTL - Nurse CS Order Request Entry DIR style; 8 Aug 94
2 ;;3.0; CONTROLLED SUBSTANCES ;**51**;13 Feb 97
3 ;Any requests not ordered?
4 K PSD,PSDA,PSDB S PSD=0
5 W !,"Searching for ",$P($G(^VA(200,DUZ,.1)),U,4),"'s pending requests."
6 F S PSD=$O(^PSD(58.8,"AC",.5,+NAOU,PSD)) Q:'PSD D
7 .S PSD(1)=0 F S PSD(1)=$O(^PSD(58.8,"AC",.5,+NAOU,PSD,PSD(1))) Q:'PSD(1) W "." S:$P($G(^PSD(58.8,+NAOU,1,+PSD,3,PSD(1),0)),U,4)=DUZ PSDA(PSD,PSD(1))=$G(^(0))
8 I $O(PSDA(0)) D ^PSDORD1 G:$G(PSDOUT) END
9 W:'$O(PSDA(0)) " No pending requests.",!
10DRUG ;select drug
11 S MSG=0 ;; PSD*3*51 - RJS
12 K DA,DIC,PSDR S DIC("W")="W:$P(^PSDRUG(Y,0),""^"",9) "" N/F"" W $S('$G(^PSD(58.8,NAOU,1,Y,0)):"" NOT STOCKED BY ""_NAOUN,$P(^(0),U,14)&($P(^(0),U,14)'>DT):"" INACTIVE on ""_NAOUN,1:"""")"
13 S DIC("S")="I '$P($G(^(7)),U,2),$S('$P(^(0),""^"",14):1,+$P(^(0),""^"",14)>DT:1,1:0)"
14 S DA(1)=+PSDS,DIC(0)="QEAM",DIC="^PSD(58.8,"_+PSDS_",1,"
15 ;one time requests not allowed by dispensing site
16 D:'$P($G(^PSD(58.8,+PSDS,0)),U,13)
17 .S DIC("W")="W:$P(^PSDRUG(Y,0),U,9) "" N/F"" I $P(^PSD(58.8,NAOU,1,Y,0),U,14)]"""",$P(^(0),U,14)'>DT W $C(7),"" *** INACTIVE ***"""
18 .S DIC("S")="I $S('$P(^(0),U,14):1,+$P(^(0),U,14)>DT:1,1:0)"
19 .S DA(1)=+NAOU,DIC="^PSD(58.8,"_NAOU_",1,"
20 D ^DIC K DIC G:$D(DTOUT)!($D(DUOUT)) END G:Y<1&($O(PSDA(0))) ^PSDORD1 G:Y<1 END S PSDR=+Y,PSDRN=$S($P(^PSDRUG(PSDR,0),"^")]"":$P(^(0),"^"),1:"DRUG NAME MISSING")
21 I $S('$D(^PSD(58.8,NAOU,1,PSDR,0)):1,$P(^(0),U,14)&($P(^(0),U,14)'>DT):1,1:0) D ^PSDORD4 G:$D(DIRUT) END G DRUG
22 I '$D(^PSD(58.8,NAOU,1,PSDR,0)) D MSG G END
23 I '$D(^PSD(58.8,+PSDS,1,PSDR,0)) S MSG=2 D MSG G END
24 S NBKU=$P(^PSD(58.8,+PSDS,1,PSDR,0),"^",8),NPKG=+$P(^(0),"^",9)
25 I NBKU']"" S MSG1=3 D MSG G END
26 I 'NPKG S MSG1=4 D MSG G END
27 D LIST^PSDORL
28 ;Perpetual?
29 G:$P($G(^PSD(58.8,+NAOU,2)),U,5) ^PSDORD3
30QTY K ORD S PSDOUT=0 S DIR(0)="58.800118,5A"
31 S DIR("A")="QUANTITY ("_NBKU_"/"_NPKG_"): ",DIR("B")=NPKG
32 D ^DIR K DIR G:$D(DIRUT) END G:Y<1 DRUG
33 I Y=NPKG S PSDQTY=Y D DIE W ! G DRUG
34 I X["?"!(X'?1.N)!(X#NPKG)!('X) W !!,"Quantity must be "_NPKG_" or a multiple of "_NPKG,! G QTY
35 S CNT=X/NPKG W !!,"This will be "_CNT_" separate order requests. The quantity is "_NPKG_" per request."
36 W ! K DA,DIR,DIRUT S DIR(0)="Y",DIR("A")="Do you want me to generate the "_CNT_" separate order requests",DIR("B")="YES",DIR("?",1)="Answer 'YES' to create the multiple order requests,"
37 S DIR("?")="Answer 'NO' to edit your comments or '^' to quit." D ^DIR K DIR G:$D(DIRUT) END
38 I 'Y W !,"No order request created. You must edit quantity.",! G QTY
39 I Y W !!,"The "_CNT_" requests are being created.",! S PSDQTY=NPKG D W ! G DRUG
40 .F ORD=1:1:CNT W !!,"Creating your order request # "_ORD_" of "_CNT_" for "_PSDRN D DIE S PSDA(+PSDR,PSDA)=$G(^PSD(58.8,+NAOU,1,+PSDR,3,+PSDA,0))
41 I '$G(PSDOUT) W ! G DRUG
42END K %,%DT,%H,%I,CNT,CNT1,DA,DIC,DIE,DINUM,DIR,DIROUT,DIRUT,DIWF,DIWL,DIWR,DR,DTOUT,DUOUT,LN,MSG,MSG1
43 K NAOU,NAOUN,NBKU,NPKG,OK,OKTYP,ORD,PSD,PSDA,PSDB,PSDOUT,PSDQTY,PSDRD,PSDR,PSDRN,PSDS,PSDT,PSDUZ,PSDUZN,REQD,TEXT,TYPE,WORD,X,Y
44 Q
45DIE ;create the order request
46 S:'$D(^PSD(58.8,NAOU,1,PSDR,3,0)) ^(0)="^58.800118A^^"
47 S PSDA=$P(^PSD(58.8,NAOU,1,PSDR,3,0),"^",3)+1 I $D(^PSD(58.8,NAOU,1,PSDR,3,PSDA)) S $P(^PSD(58.8,NAOU,1,PSDR,3,0),"^",3)=$P(^PSD(58.8,NAOU,1,PSDR,3,0),"^",3)+1 G DIE
48 K DA,DIC,DIE,DD,DR,DO S DIC(0)="L",(DIC,DIE)="^PSD(58.8,"_NAOU_",1,"_PSDR_",3,",DA(2)=NAOU,DA(1)=PSDR,(X,DINUM)=PSDA D FILE^DICN K DIC
49 D NOW^%DTC S PSDT=+$E(%,1,12) W ?10,!!,"processing now..."
50 S DA=PSDA,DA(1)=PSDR,DA(2)=NAOU,DR="1////"_PSDT_";2////"_+PSDS_";3////"_PSDUZ_";10////.5;5////"_PSDQTY_";13" D ^DIE K DIE,DR
51 S PSDA(+PSDR,+PSDA)=$G(^PSD(58.8,+NAOU,1,+PSDR,3,PSDA,0))
52 Q
53MSG ;display error message
54 W $C(7),!!,?10,"Contact your Pharmacy Coordinator.",!,?10,"This "_$S(MSG=2:"Dispensing Site",MSG=1:"NAOU",1:"Drug")_" is missing "
55 W $S(MSG1=1:"Primary Disp. Site",MSG1=2:"stocked drugs",MSG1=3:"narcotic breakdown unit",MSG1=4:"narcotic package size",1:"data")_".",!
56 Q
Note: See TracBrowser for help on using the repository browser.