PSDORD3 ;BIR/LTL - Reg 2 Nurse CS Order Request Entry (batch) ;6 Jan 95
;;3.0;CONTROLLED SUBSTANCES ;**79**;13 Feb 97;Build 20
QTY K ORD S (CNT,PSDOUT,PSDR(2))=0
;Dispensing Site's Maximum Quantity per Order
S PSDR(1)=$P($G(^PSD(58.8,+PSDS,1,+PSDR,0)),U,7)
;Ask Quantity
S DIR(0)="NA^1:999999:0"
S DIR("A")="QUANTITY ("_NBKU_"/"_NPKG_"): ",DIR("B")=NPKG
W:$P($G(^PSD(58.8,+NAOU,1,+PSDR,0)),U,3) !,"Stock Level: ",$P($G(^(0)),U,3)," ",NBKU,!
S:PSDR(1) DIR("A",1)="Maximum quantity per order: "_PSDR(1)_" "_NBKU,DIR("A",2)=""
S DIR("?",1)="Because "_NAOUN_" is keeping a perpetual inventory,"
S DIR("?",2)="Pharmacy Service has set "_$S(PSDR(1):"a maximum quantity of "_PSDR(1)_" "_NBKU_" per order",1:"no maximum order quantity")
S DIR("?")="for "_PSDRN_"."
S:PSDR(1) DIR("?")="If you request more than "_PSDR(1)_" "_NBKU_", multiple orders will be generated.",DIR("?",3)="for "_PSDRN_".",DIR("?",4)=""
D ^DIR K DIR G:Y<1 END S PSDQTY=Y
;Quantity ordered is equal to or less than max ord qty
NOMAX I '(Y#NPKG)&('PSDR(1)!(Y'>PSDR(1))) D DIE G:PSDOUT END G DRUG^PSDORD
;Quantity ordered is not divisible by package size
D:(Y#NPKG) G:$D(DIRUT) END G:Y<1 QTY I 'PSDR(1)!(Y<PSDR(1)) S Y=PSDQTY G NOMAX
.S PSDQTY=Y-(Y#NPKG)
.S DIR(0)="S^"_PSDQTY_":"_NBKU_";"_(PSDQTY+NPKG)_":"_NBKU_";*:New Quantity"
.S DIR("A",1)="Please order "_PSDRN,DIR("A",3)=""
.S DIR("A",2)="in multiples of "_NPKG_" "_NBKU_".",DIR("B")=PSDQTY
.S DIR("A")="QUANTITY ("_NBKU_"/"_NPKG_")"
.S DIR("?")="Enter an adjusted quantity or * to enter a new quantity" D ^DIR K DIR Q:Y<1 S PSDQTY=Y
S:(PSDQTY#PSDR(1)) CNT=1,PSDR(2)=(PSDQTY#PSDR(1))
;Number of orders to generate
S CNT=$G(CNT)+(PSDQTY\PSDR(1))
W !!,"This will be "_CNT_" separate order requests,"
W:PSDR(2) !!,"One order for ",PSDR(2)," ",NBKU,", and"
W !!,(PSDQTY\PSDR(1))," order"
W:CNT>2!('PSDR(2)&(CNT=2)) "s"
W " for ",PSDR(1)," ",NBKU,"."
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,"
S DIR("?")="Answer 'NO' to edit your comments or '^' to quit." D ^DIR K DIR G:$D(DIRUT) END
I 'Y W !,"No order request created. You must edit quantity.",! G QTY
I Y W !!,"The "_CNT_" requests are being created.",! S PSDQTY=$S(PSDR(2):PSDR(2),1:PSDR(1)) D S PSDR(2)=0
.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)),PSDQTY=PSDR(1)
G:'PSDOUT DRUG^PSDORD
END K %,%DT,%H,%I,CNT,CNT1,DA,DIC,DIE,DINUM,DIR,DIROUT,DIRUT,DIWF,DIWL,DIWR,DR,DTOUT,DUOUT,LN,MSG,MSG1
K NAOU,NAOUN,NBKU,NPKG,OK,OKTYP,ORD,PSDA,PSDOUT,PSDQTY,PSDRD,PSDR,PSDRN,PSDS,PSDT,PSDUZ,PSDUZN,REQD,TEXT,TYPE,WORD,X,Y
Q
DIE ;create the order request
F L +^PSD(58.8,NAOU,1,PSDR,0):$S($G(DILOCKTM)>0:DILOCKTM,1:3) I Q
S:'$D(^PSD(58.8,NAOU,1,PSDR,3,0)) ^(0)="^58.800118A^^"
DIE2 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 DIE2
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
D NOW^%DTC S PSDT=+$E(%,1,12) W ?10,!!,"processing now..."
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
S PSDA(+PSDR,+PSDA)=$G(^PSD(58.8,+NAOU,1,+PSDR,3,PSDA,0))
L -^PSD(58.8,NAOU,1,PSDR,0)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSDORD3 3561 printed Nov 22, 2024@16:57:42 Page 2
PSDORD3 ;BIR/LTL - Reg 2 Nurse CS Order Request Entry (batch) ;6 Jan 95
+1 ;;3.0;CONTROLLED SUBSTANCES ;**79**;13 Feb 97;Build 20
QTY KILL ORD
SET (CNT,PSDOUT,PSDR(2))=0
+1 ;Dispensing Site's Maximum Quantity per Order
+2 SET PSDR(1)=$PIECE($GET(^PSD(58.8,+PSDS,1,+PSDR,0)),U,7)
+3 ;Ask Quantity
+4 SET DIR(0)="NA^1:999999:0"
+5 SET DIR("A")="QUANTITY ("_NBKU_"/"_NPKG_"): "
SET DIR("B")=NPKG
+6 if $PIECE($GET(^PSD(58.8,+NAOU,1,+PSDR,0)),U,3)
WRITE !,"Stock Level: ",$PIECE($GET(^(0)),U,3)," ",NBKU,!
+7 if PSDR(1)
SET DIR("A",1)="Maximum quantity per order: "_PSDR(1)_" "_NBKU
SET DIR("A",2)=""
+8 SET DIR("?",1)="Because "_NAOUN_" is keeping a perpetual inventory,"
+9 SET DIR("?",2)="Pharmacy Service has set "_$SELECT(PSDR(1):"a maximum quantity of "_PSDR(1)_" "_NBKU_" per order",1:"no maximum order quantity")
+10 SET DIR("?")="for "_PSDRN_"."
+11 if PSDR(1)
SET DIR("?")="If you request more than "_PSDR(1)_" "_NBKU_", multiple orders will be generated."
SET DIR("?",3)="for "_PSDRN_"."
SET DIR("?",4)=""
+12 DO ^DIR
KILL DIR
if Y<1
GOTO END
SET PSDQTY=Y
+13 ;Quantity ordered is equal to or less than max ord qty
NOMAX IF '(Y#NPKG)&('PSDR(1)!(Y'>PSDR(1)))
DO DIE
if PSDOUT
GOTO END
GOTO DRUG^PSDORD
+1 ;Quantity ordered is not divisible by package size
+2 if (Y#NPKG)
Begin DoDot:1
+3 SET PSDQTY=Y-(Y#NPKG)
+4 SET DIR(0)="S^"_PSDQTY_":"_NBKU_";"_(PSDQTY+NPKG)_":"_NBKU_";*:New Quantity"
+5 SET DIR("A",1)="Please order "_PSDRN
SET DIR("A",3)=""
+6 SET DIR("A",2)="in multiples of "_NPKG_" "_NBKU_"."
SET DIR("B")=PSDQTY
+7 SET DIR("A")="QUANTITY ("_NBKU_"/"_NPKG_")"
+8 SET DIR("?")="Enter an adjusted quantity or * to enter a new quantity"
DO ^DIR
KILL DIR
if Y<1
QUIT
SET PSDQTY=Y
End DoDot:1
if $DATA(DIRUT)
GOTO END
if Y<1
GOTO QTY
IF 'PSDR(1)!(Y<PSDR(1))
SET Y=PSDQTY
GOTO NOMAX
+9 if (PSDQTY#PSDR(1))
SET CNT=1
SET PSDR(2)=(PSDQTY#PSDR(1))
+10 ;Number of orders to generate
+11 SET CNT=$GET(CNT)+(PSDQTY\PSDR(1))
+12 WRITE !!,"This will be "_CNT_" separate order requests,"
+13 if PSDR(2)
WRITE !!,"One order for ",PSDR(2)," ",NBKU,", and"
+14 WRITE !!,(PSDQTY\PSDR(1))," order"
+15 if CNT>2!('PSDR(2)&(CNT=2))
WRITE "s"
+16 WRITE " for ",PSDR(1)," ",NBKU,"."
+17 WRITE !
KILL DA,DIR,DIRUT
SET DIR(0)="Y"
SET DIR("A")="Do you want me to generate the "_CNT_" separate order requests"
SET DIR("B")="YES"
SET DIR("?",1)="Answer 'YES' to create the multiple order requests,"
+18 SET DIR("?")="Answer 'NO' to edit your comments or '^' to quit."
DO ^DIR
KILL DIR
if $DATA(DIRUT)
GOTO END
+19 IF 'Y
WRITE !,"No order request created. You must edit quantity.",!
GOTO QTY
+20 IF Y
WRITE !!,"The "_CNT_" requests are being created.",!
SET PSDQTY=$SELECT(PSDR(2):PSDR(2),1:PSDR(1))
Begin DoDot:1
+21 FOR ORD=1:1:CNT
WRITE !!,"Creating your order request # "_ORD_" of "_CNT_" for "_PSDRN
DO DIE
SET PSDA(+PSDR,PSDA)=$GET(^PSD(58.8,+NAOU,1,+PSDR,3,+PSDA,0))
SET PSDQTY=PSDR(1)
End DoDot:1
SET PSDR(2)=0
+22 if 'PSDOUT
GOTO DRUG^PSDORD
END KILL %,%DT,%H,%I,CNT,CNT1,DA,DIC,DIE,DINUM,DIR,DIROUT,DIRUT,DIWF,DIWL,DIWR,DR,DTOUT,DUOUT,LN,MSG,MSG1
+1 KILL NAOU,NAOUN,NBKU,NPKG,OK,OKTYP,ORD,PSDA,PSDOUT,PSDQTY,PSDRD,PSDR,PSDRN,PSDS,PSDT,PSDUZ,PSDUZN,REQD,TEXT,TYPE,WORD,X,Y
+2 QUIT
DIE ;create the order request
+1 FOR
LOCK +^PSD(58.8,NAOU,1,PSDR,0):$SELECT($GET(DILOCKTM)>0:DILOCKTM,1:3)
IF $TEST
QUIT
+2 if '$DATA(^PSD(58.8,NAOU,1,PSDR,3,0))
SET ^(0)="^58.800118A^^"
DIE2 SET PSDA=$PIECE(^PSD(58.8,NAOU,1,PSDR,3,0),"^",3)+1
IF $DATA(^PSD(58.8,NAOU,1,PSDR,3,PSDA))
SET $PIECE(^PSD(58.8,NAOU,1,PSDR,3,0),"^",3)=$PIECE(^PSD(58.8,NAOU,1,PSDR,3,0),"^",3)+1
GOTO DIE2
+1 KILL DA,DIC,DIE,DD,DR,DO
SET DIC(0)="L"
SET (DIC,DIE)="^PSD(58.8,"_NAOU_",1,"_PSDR_",3,"
SET DA(2)=NAOU
SET DA(1)=PSDR
SET (X,DINUM)=PSDA
DO FILE^DICN
KILL DIC
+2 DO NOW^%DTC
SET PSDT=+$EXTRACT(%,1,12)
WRITE ?10,!!,"processing now..."
+3 SET DA=PSDA
SET DA(1)=PSDR
SET DA(2)=NAOU
SET DR="1////"_PSDT_";2////"_+PSDS_";3////"_PSDUZ_";10////.5;5////"_PSDQTY_";13"
DO ^DIE
KILL DIE,DR
+4 SET PSDA(+PSDR,+PSDA)=$GET(^PSD(58.8,+NAOU,1,+PSDR,3,PSDA,0))
+5 LOCK -^PSD(58.8,NAOU,1,PSDR,0)
+6 QUIT