source: FOIAVistA/trunk/r/AUTO_REPLENISHMENT_WARD_STOCK-PSGW/PSGWWRD.m@ 1446

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

initial load of FOIAVistA 6/30/08 version

File size: 3.6 KB
Line 
1PSGWWRD ;BHAM ISC/CML-Add/Delete Ward (for Item) assignments ; 06 Aug 93 / 2:17 PM [ 09/28/95 11:59 AM ]
2 ;;2.3; Automatic Replenishment/Ward Stock ;**5**;4 JAN 94
3 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."
4ASK1 W !!,"Do you wish to (A)dd or (D)elete? (Enter 'A', 'D', or ""^"" to Exit): "
5 R ANS:DTIME S:'$T ANS="^" G:"^"[ANS QUIT I ANS'="A",ANS'="D" D HELP G ASK1
6 W:ANS="A" "DD" W:ANS="D" "ELETE" S ANSW=$S(ANS="A":"ADD",1:"DELETE")
7 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)
8 G:SEL="I" ASK3
9ASK2 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)=""
10 I '$D(AOULP)&(X'="^ALL") G QUIT
11 I X="^ALL" F AOU=0:0 S AOU=$O(^PSI(58.1,AOU)) Q:'AOU S AOULP(AOU)=""
12ASK3 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
13QUE 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"
14 G:%<0 QUIT S QUE=$S(%=1:1,1:0) I QUE W !!,"You will be notified by MailMan when the job is completed.",!
15 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)=""
16 I D ^%ZTLOAD,HOME^%ZIS K ZTSK G QUIT
17START ;
18 K ^TMP($J) S (ITMCNT,MRCNT,FLG)=0 D:ANS="A" ADD D:ANS="D" DEL D:QUE MAIL
19 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
20QUIT 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
21 S:$D(ZTQUEUED) ZTREQ="@" Q
22ADD ;
23 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
24 Q
25ADDWRD ;
26 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
27 K DD,DO D FILE^DICN K DIC S ITMCNT=ITMCNT+1,FLG=1 W:'QUE "."
28 Q
29DEL ;
30 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
31 Q
32DELWRD ;
33 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 "."
34 Q
35MAIL ;
36 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."
37 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")_":"
38 S ^TMP($J,"MSG",5,0)="Total AOU(s): "_MRCNT_" Total Stock Items: "_ITMCNT
39 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
40HELP ;
41 I ANS'?."?" W *7," ??"
42 W !!?5,"Enter: 'A' to Add a Ward (for Item)",!?12,"'D' to Delete a Ward (for Item)",!?12,"""^"" to Exit." Q
Note: See TracBrowser for help on using the repository browser.