source: WorldVistAEHR/trunk/r/CONTROLLED_SUBSTANCES-PSD/PSDORP.m@ 949

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

initial load of WorldVistAEHR

File size: 4.7 KB
RevLine 
[613]1PSDORP ;BIR/JPW-Pharm CS Order Request Entry ; 8 Aug 94
2 ;;3.0; CONTROLLED SUBSTANCES ;**58,62**;13 Feb 97;Build 3
3 W !!,"Controlled Substances Order Entry",!! S PSDUZ=DUZ,PSDUZN=$P($G(^VA(200,PSDUZ,0)),"^"),(MSG,MSG1)=0,Y=DT X ^DD("DD") S REQD=Y
4NAOU ;select NAOU to order supplies for
5 K ^UTILITY($J,"W")
6 N X,DIWL,DIWR,DIWF,PSD S PSD=0,DIWL=1,DIWR=80,DIWF="W"
7 F S PSD=$O(^PSD(58.8,+$P(PSDSITE,U,3),5,PSD)) Q:'PSD S X=$G(^PSD(58.8,+$P(PSDSITE,U,3),5,PSD,0)) D ^DIWP
8 D ^DIWW
9 ;; RJS - PSD*3.0*58
10 K DA,DIC S DIC=58.8,DIC(0)="QEA",DIC("A")="Select Ordering NAOU: "
11 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)"
12 D ^DIC K DIC G:Y<0 END S NAOU=+Y,NAOUN=$P(Y,"^",2)
13 I '$D(^PSD(58.8,NAOU,0)) S MSG=1 D MSG G END
14 I '$O(^PSD(58.8,NAOU,1,0)) S MSG=1,MSG1=2 D MSG G END
15 S PSDS=+$P(^PSD(58.8,NAOU,0),"^",4) I '+PSDS S (MSG,MSG1)=1 D MSG G END
16 I '$D(^PSD(58.8,+PSDS,0)) S MSG=2 D MSG G END
17 I '$O(^PSD(58.8,+PSDS,1,0)) S MSG=2,MSG1=2 D MSG G END
18 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
19DRUG ;select drug
20 K DA,DIC S DIC("W")="W:$P(^PSDRUG(Y,0),""^"",9) "" N/F"" I $P(^PSD(58.8,NAOU,1,Y,0),""^"",14)]"""",$P(^(0),""^"",14)'>DT W $C(7),"" *** INACTIVE ***"""
21 S DIC("S")="I '$P($G(^(7)),U,2),$S('$P(^(0),""^"",14):1,+$P(^(0),""^"",14)>DT:1,1:0)"
22 ;; JD *62 ->
23 S DA(1)=+PSDS,DIC(0)="QEAM",DIC="^PSD(58.8,"_+PSDS_",1,"
24 ;one time requests not allowed by dispensing site
25 D:'$P($G(^PSD(58.8,+PSDS,0)),U,13)
26 .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 ***"""
27 .S DIC("S")="I $S('$P(^(0),U,14):1,+$P(^(0),U,14)>DT:1,1:0)"
28 .S DA(1)=+NAOU,DIC(0)="QEAM",DIC="^PSD(58.8,"_NAOU_",1,"
29 D ^DIC K DIC G:Y<0 NAOU S PSDR=+Y,PSDRN=$S($P(^PSDRUG(PSDR,0),"^")]"":$P(^(0),"^"),1:"DRUG NAME MISSING") ; <- JD *62
30 I '$D(^PSD(58.8,NAOU,1,PSDR,0)) D MSG G END
31 I '$D(^PSD(58.8,+PSDS,1,PSDR,0)) S MSG=2 D MSG G END
32 S NBKU=$P(^PSD(58.8,+PSDS,1,PSDR,0),"^",8),NPKG=+$P(^(0),"^",9)
33 I NBKU']"" S MSG1=3 D MSG G END
34 I 'NPKG S MSG1=4 D MSG G END
35 D LIST^PSDORL
36 ;NAOU using perpetual?
37 G:$P($G(^PSD(58.8,+NAOU,2)),U,5) ^PSDORP2
38QTY K ORD S (CNT,PSDR(2),PSDOUT)=0
39 ;DISPLAY STOCK LEVEL
40 W:$P($G(^PSD(58.8,+NAOU,1,+PSDR,0)),U,3) !,"Stock Level: ",$P($G(^(0)),U,3)," ",NBKU,!
41 ;ASK QUANTITY
42 S DIR(0)="NA^1:999999:0"
43 S DIR("A")="QUANTITY ("_NBKU_"/"_NPKG_"): ",DIR("B")=NPKG
44 D ^DIR K DIR G:Y<1 END S PSDQTY=Y
45 I Y=NPKG S PSDQTY=NPKG,CNT=0 D DIE,ASK^PSDORP1 G:PSDOUT END G DRUG
46 ;QUANTITY EXCEEDS PACKAGE SIZE, MULTIPLE ORDERS
47 S:(PSDQTY#NPKG) CNT=1,PSDR(2)=(PSDQTY#NPKG)
48 S CNT=$G(CNT)+(Y\NPKG)
49 W !!,"This will be "_CNT_" separate order requests,"
50 W:PSDR(2) !!,"One order for ",PSDR(2)," ",NBKU,", and"
51 W !!,(PSDQTY\NPKG)," order"
52 W:CNT>2!('PSDR(2)&(CNT=2)) "s"
53 W " for ",NPKG," ",NBKU,"."
54 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,"
55 S DIR("?")="Answer 'NO' to edit your quantity or '^' to quit." D ^DIR K DIR G:$D(DIRUT) END
56 I 'Y W !,"No order request created. You must edit quantity.",! G QTY
57 I Y W !!,"The "_CNT_" requests are being created. You must review every request.",! S PSDQTY=$S(PSDR(2):PSDR(2),1:NPKG) D D ^PSDORP1 S PSDQTY=NPKG
58 .F ORD=1:1:CNT W !!,"Creating your order request # "_ORD_" of "_CNT_" for "_PSDRN D DIE S ORD(ORD)=PSDA
59 G:'PSDOUT DRUG
60END K %,%DT,%H,%I,CNT,CNT1,DA,DIC,DIE,DINUM,DIR,DIROUT,DIRUT,DIWF,DIWL,DIWR,DR,DTOUT,DUOUT,LN,MSG,MSG1
61 K NAOU,NAOUN,NBKU,NPKG,OK,OKTYP,ORD,PSDA,PSDOUT,PSDQTY,PSDRD,PSDR,PSDRN,PSDS,PSDT,PSDUZ,PSDUZA,PSDUZN,REQD,TEXT,TYPE,WORD,X,Y
62 Q
63DIE ;create the order request
64 S:'$D(^PSD(58.8,NAOU,1,PSDR,3,0)) ^(0)="^58.800118A^^"
65 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
66 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
67 D NOW^%DTC S PSDT=+$E(%,1,12) W ?10,!!,"processing now..."
68 S DA=PSDA,DA(1)=PSDR,DA(2)=NAOU,DR="1////"_PSDT_";2////"_PSDS_";10////1;5////"_PSDQTY_";13;3//^S X=PSDUZN" D ^DIE K DIE,DR
69 S PSDUZA=+$P($G(^PSD(58.8,NAOU,1,PSDR,3,PSDA,0)),"^",4)
70 Q
71MSG ;display error message
72 W $C(7),!!,?10,"Contact your Pharmacy Coordinator.",!,?10,"This "_$S(MSG=2:"Dispensing Site",MSG=1:"NAOU",1:"PSDR")_" is missing "
73 W $S(MSG1=1:"Primary Disp. Site",MSG1=2:"stocked drugs",MSG1=3:"narcotic breakdown unit",MSG1=4:"narcotic package size",1:"data")_".",!
74 Q
Note: See TracBrowser for help on using the repository browser.