PSGWWRD ;BHAM ISC/CML-Add/Delete Ward (for Item) assignments ; 06 Aug 93 / 2:17 PM [ 09/28/95 11:59 AM ]
;;2.3; Automatic Replenishment/Ward Stock ;**5**;4 JAN 94
W !!,"This option will allow you to add or delete a WARD (for Item) assignment for",!,"all stock items in one or more ACTIVE AOUs."
ASK1 W !!,"Do you wish to (A)dd or (D)elete? (Enter 'A', 'D', or ""^"" to Exit): "
R ANS:DTIME S:'$T ANS="^" G:"^"[ANS QUIT I ANS'="A",ANS'="D" D HELP G ASK1
W:ANS="A" "DD" W:ANS="D" "ELETE" S ANSW=$S(ANS="A":"ADD",1:"DELETE")
D SEL^PSGWUTL1 G:'$D(SEL) QUIT I SEL="I" F JJ=0:0 S J=$O(AOULP(JJ)) Q:'JJ I $S('$D(^PSI(58.1,JJ,"I")):0,'^("I"):0,^("I")>DT:0,1:1) K AOULP(JJ)
G:SEL="I" ASK3
ASK2 F JJ=0:0 S DIC="^PSI(58.1,",DIC(0)="QEAM",DIC("S")="I $S('$D(^(""I"")):1,'^(""I""):1,^(""I"")>DT:1,1:0)" D ^DIC K DIC Q:Y<0 S AOULP(+Y)=""
I '$D(AOULP)&(X'="^ALL") G QUIT
I X="^ALL" F AOU=0:0 S AOU=$O(^PSI(58.1,AOU)) Q:'AOU S AOULP(AOU)=""
ASK3 G:'$D(AOULP) QUIT W ! S DIC="^DIC(42,",DIC(0)="QEAM",DIC("A")="Select Ward (for Item) to "_ANSW_": " S:ANS="A" DIC("S")="I $S('$D(^(""I"")):1,^(""I"")="""":1,1:0)" D ^DIC K DIC G:Y<0 QUIT S WRD=+Y
QUE F JJ=0:0 W !!,"Do you want to queue this job" S %=1 D YN^DICN Q:% W !!,"If you want to queue this job to run at a later time, accept the",!,"default, otherwise enter 'N' to run it immediately or '^' to Exit"
G:%<0 QUIT S QUE=$S(%=1:1,1:0) I QUE W !!,"You will be notified by MailMan when the job is completed.",!
I %=1 S ZTIO="",ZTRTN="START^PSGWWRD",ZTDESC="AR/WS WARD (FOR ITEM) ADD/DELETE" S:$D(AOULP) ZTSAVE("AOULP(")="" F G="QUE","WRD","ANS" S:$D(@G) ZTSAVE(G)=""
I D ^%ZTLOAD,HOME^%ZIS K ZTSK G QUIT
START ;
K ^TMP($J) S (ITMCNT,MRCNT,FLG)=0 D:ANS="A" ADD D:ANS="D" DEL D:QUE MAIL
I 'QUE W *7,!!,"WARD (For Item) assignment of ",$P(^DIC(42,WRD,0),"^")," has been ",$S(ANS="A":"added to",1:"deleted from"),":",!,"Total AOU(s): ",MRCNT," Total Stock Items: ",ITMCNT
QUIT K %,%Y,%Z,ANS,ANSW,AOU,AOULP,DA,DIC,DIE,DIK,DR,FLG,G,ITM,ITMCNT,JJ,SEL,IGDA,MRCNT,QUE,RDT,WED,WRD,X,XMDUZ,XMSUB,XMTEXT,XMY,Y,ZTSK,^TMP($J),IO("Q") D ^%ZISC
S:$D(ZTQUEUED) ZTREQ="@" Q
ADD ;
F AOU=0:0 S AOU=$O(AOULP(AOU)) S:FLG MRCNT=MRCNT+1 Q:'AOU S FLG=0 I $S('$D(^PSI(58.1,AOU,"I")):1,'^("I"):1,^("I")>DT:1,1:0) F ITM=0:0 S ITM=$O(^PSI(58.1,AOU,1,ITM)) Q:'ITM I '$D(^PSI(58.1,AOU,1,ITM,4,WRD,0)) D ADDWRD
Q
ADDWRD ;
S DA(2)=AOU,DA(1)=ITM,DIC="^PSI(58.1,"_DA(2)_",1,"_DA(1)_",4,",DIC(0)="LM",DIC("P")=$P(^DD(58.11,5,0),"^",2),(DINUM,X)=WRD
K DD,DO D FILE^DICN K DIC S ITMCNT=ITMCNT+1,FLG=1 W:'QUE "."
Q
DEL ;
F AOU=0:0 S AOU=$O(AOULP(AOU)) S:FLG MRCNT=MRCNT+1 Q:'AOU S FLG=0 I $S('$D(^PSI(58.1,AOU,"I")):1,'^("I"):1,^("I")>DT:1,1:0) F ITM=0:0 S ITM=$O(^PSI(58.1,AOU,1,ITM)) Q:'ITM I $D(^PSI(58.1,AOU,1,ITM,4,WRD,0)) D DELWRD
Q
DELWRD ;
S DA(2)=AOU,DA(1)=ITM,DA=WRD,DIK="^PSI(58.1,"_DA(2)_",1,"_DA(1)_",4,",DR="5///@" D ^DIK K DIK S ITMCNT=ITMCNT+1,FLG=1 W:'QUE "."
Q
MAIL ;
K XMY D NOW^%DTC S Y=X X ^DD("DD") S RDT=Y S ^TMP($J,"MSG",1,0)="AR/WS WARD (For Item) "_$S(ANS="A":"ADDITION",1:"DELETION")_" Background job has run to completion."
S ^TMP($J,"MSG",2,0)="Run Date: "_RDT,^TMP($J,"MSG",3,0)="",^TMP($J,"MSG",4,0)="WARD (For Item) assignment of "_$P(^DIC(42,WRD,0),"^")_" has been "_$S(ANS="A":"Added to",1:"Deleted from")_":"
S ^TMP($J,"MSG",5,0)="Total AOU(s): "_MRCNT_" Total Stock Items: "_ITMCNT
S XMSUB="AR/WS WARD (FOR ITEM) "_$S(ANS="A":"ADDITION",1:"DELETION")_" SUMMARY",XMDUZ="INPATIENT PHARMACY AR/WS",XMTEXT="^TMP($J,""MSG"",",XMY(DUZ)="" S:'$D(XMY) XMY(.5)="" D ^XMD K XMY Q
HELP ;
I ANS'?."?" W *7," ??"
W !!?5,"Enter: 'A' to Add a Ward (for Item)",!?12,"'D' to Delete a Ward (for Item)",!?12,"""^"" to Exit." Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSGWWRD 3724 printed Dec 13, 2024@01:40:19 Page 2
PSGWWRD ;BHAM ISC/CML-Add/Delete Ward (for Item) assignments ; 06 Aug 93 / 2:17 PM [ 09/28/95 11:59 AM ]
+1 ;;2.3; Automatic Replenishment/Ward Stock ;**5**;4 JAN 94
+2 WRITE !!,"This option will allow you to add or delete a WARD (for Item) assignment for",!,"all stock items in one or more ACTIVE AOUs."
ASK1 WRITE !!,"Do you wish to (A)dd or (D)elete? (Enter 'A', 'D', or ""^"" to Exit): "
+1 READ ANS:DTIME
if '$TEST
SET ANS="^"
if "^"[ANS
GOTO QUIT
IF ANS'="A"
IF ANS'="D"
DO HELP
GOTO ASK1
+2 if ANS="A"
WRITE "DD"
if ANS="D"
WRITE "ELETE"
SET ANSW=$SELECT(ANS="A":"ADD",1:"DELETE")
+3 DO SEL^PSGWUTL1
if '$DATA(SEL)
GOTO QUIT
IF SEL="I"
FOR JJ=0:0
SET J=$ORDER(AOULP(JJ))
if 'JJ
QUIT
IF $SELECT('$DATA(^PSI(58.1,JJ,"I")):0,'^("I"):0,^("I")>DT:0,1:1)
KILL AOULP(JJ)
+4 if SEL="I"
GOTO ASK3
ASK2 FOR JJ=0:0
SET DIC="^PSI(58.1,"
SET DIC(0)="QEAM"
SET DIC("S")="I $S('$D(^(""I"")):1,'^(""I""):1,^(""I"")>DT:1,1:0)"
DO ^DIC
KILL DIC
if Y<0
QUIT
SET AOULP(+Y)=""
+1 IF '$DATA(AOULP)&(X'="^ALL")
GOTO QUIT
+2 IF X="^ALL"
FOR AOU=0:0
SET AOU=$ORDER(^PSI(58.1,AOU))
if 'AOU
QUIT
SET AOULP(AOU)=""
ASK3 if '$DATA(AOULP)
GOTO QUIT
WRITE !
SET DIC="^DIC(42,"
SET DIC(0)="QEAM"
SET DIC("A")="Select Ward (for Item) to "_ANSW_": "
if ANS="A"
SET DIC("S")="I $S('$D(^(""I"")):1,^(""I"")="""":1,1:0)"
DO ^DIC
KILL DIC
if Y<0
GOTO QUIT
SET WRD=+Y
QUE FOR JJ=0:0
WRITE !!,"Do you want to queue this job"
SET %=1
DO YN^DICN
if %
QUIT
WRITE !!,"If you want to queue this job to run at a later time, accept the",!,"default, otherwise enter 'N' to run it immediately or '^' to Exit"
+1 if %<0
GOTO QUIT
SET QUE=$SELECT(%=1:1,1:0)
IF QUE
WRITE !!,"You will be notified by MailMan when the job is completed.",!
+2 IF %=1
SET ZTIO=""
SET ZTRTN="START^PSGWWRD"
SET ZTDESC="AR/WS WARD (FOR ITEM) ADD/DELETE"
if $DATA(AOULP)
SET ZTSAVE("AOULP(")=""
FOR G="QUE","WRD","ANS"
if $DATA(@G)
SET ZTSAVE(G)=""
+3 IF $TEST
DO ^%ZTLOAD
DO HOME^%ZIS
KILL ZTSK
GOTO QUIT
START ;
+1 KILL ^TMP($JOB)
SET (ITMCNT,MRCNT,FLG)=0
if ANS="A"
DO ADD
if ANS="D"
DO DEL
if QUE
DO MAIL
+2 IF 'QUE
WRITE *7,!!,"WARD (For Item) assignment of ",$PIECE(^DIC(42,WRD,0),"^")," has been ",$SELECT(ANS="A":"added to",1:"deleted from"),":",!,"Total AOU(s): ",MRCNT," Total Stock Items: ",ITMCNT
QUIT KILL %,%Y,%Z,ANS,ANSW,AOU,AOULP,DA,DIC,DIE,DIK,DR,FLG,G,ITM,ITMCNT,JJ,SEL,IGDA,MRCNT,QUE,RDT,WED,WRD,X,XMDUZ,XMSUB,XMTEXT,XMY,Y,ZTSK,^TMP($JOB),IO("Q")
DO ^%ZISC
+1 if $DATA(ZTQUEUED)
SET ZTREQ="@"
QUIT
ADD ;
+1 FOR AOU=0:0
SET AOU=$ORDER(AOULP(AOU))
if FLG
SET MRCNT=MRCNT+1
if 'AOU
QUIT
SET FLG=0
IF $SELECT('$DATA(^PSI(58.1,AOU,"I")):1,'^("I"):1,^("I")>DT:1,1:0)
FOR ITM=0:0
SET ITM=$ORDER(^PSI(58.1,AOU,1,ITM))
if 'ITM
QUIT
IF '$DATA(^PSI(58.1,AOU,1,ITM,4,WRD,0))
DO ADDWRD
+2 QUIT
ADDWRD ;
+1 SET DA(2)=AOU
SET DA(1)=ITM
SET DIC="^PSI(58.1,"_DA(2)_",1,"_DA(1)_",4,"
SET DIC(0)="LM"
SET DIC("P")=$PIECE(^DD(58.11,5,0),"^",2)
SET (DINUM,X)=WRD
+2 KILL DD,DO
DO FILE^DICN
KILL DIC
SET ITMCNT=ITMCNT+1
SET FLG=1
if 'QUE
WRITE "."
+3 QUIT
DEL ;
+1 FOR AOU=0:0
SET AOU=$ORDER(AOULP(AOU))
if FLG
SET MRCNT=MRCNT+1
if 'AOU
QUIT
SET FLG=0
IF $SELECT('$DATA(^PSI(58.1,AOU,"I")):1,'^("I"):1,^("I")>DT:1,1:0)
FOR ITM=0:0
SET ITM=$ORDER(^PSI(58.1,AOU,1,ITM))
if 'ITM
QUIT
IF $DATA(^PSI(58.1,AOU,1,ITM,4,WRD,0))
DO DELWRD
+2 QUIT
DELWRD ;
+1 SET DA(2)=AOU
SET DA(1)=ITM
SET DA=WRD
SET DIK="^PSI(58.1,"_DA(2)_",1,"_DA(1)_",4,"
SET DR="5///@"
DO ^DIK
KILL DIK
SET ITMCNT=ITMCNT+1
SET FLG=1
if 'QUE
WRITE "."
+2 QUIT
MAIL ;
+1 KILL XMY
DO NOW^%DTC
SET Y=X
XECUTE ^DD("DD")
SET RDT=Y
SET ^TMP($JOB,"MSG",1,0)="AR/WS WARD (For Item) "_$SELECT(ANS="A":"ADDITION",1:"DELETION")_" Background job has run to completion."
+2 SET ^TMP($JOB,"MSG",2,0)="Run Date: "_RDT
SET ^TMP($JOB,"MSG",3,0)=""
SET ^TMP($JOB,"MSG",4,0)="WARD (For Item) assignment of "_$PIECE(^DIC(42,WRD,0),"^")_" has been "_$SELECT(ANS="A":"Added to",1:"Deleted from")_":"
+3 SET ^TMP($JOB,"MSG",5,0)="Total AOU(s): "_MRCNT_" Total Stock Items: "_ITMCNT
+4 SET XMSUB="AR/WS WARD (FOR ITEM) "_$SELECT(ANS="A":"ADDITION",1:"DELETION")_" SUMMARY"
SET XMDUZ="INPATIENT PHARMACY AR/WS"
SET XMTEXT="^TMP($J,""MSG"","
SET XMY(DUZ)=""
if '$DATA(XMY)
SET XMY(.5)=""
DO ^XMD
KILL XMY
QUIT
HELP ;
+1 IF ANS'?."?"
WRITE *7," ??"
+2 WRITE !!?5,"Enter: 'A' to Add a Ward (for Item)",!?12,"'D' to Delete a Ward (for Item)",!?12,"""^"" to Exit."
QUIT