source: WorldVistAEHR/trunk/r/CONTROLLED_SUBSTANCES-PSD/PSDWADD.m@ 1211

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

initial load of WorldVistAEHR

File size: 4.1 KB
Line 
1PSDWADD ;BIR/JPW-Add/Delete Ward (for Drug) ; 6 July 94
2 ;;3.0; CONTROLLED SUBSTANCES ;;13 Feb 97
3 I '$D(PSDSITE) D ^PSDSET Q:'$D(PSDSITE)
4 S PSDUZ=DUZ
5 W !!,"This option will allow you to add or delete a Ward (for Drug) assignment for",!,"all stock drugs in one or more ACTIVE NAOUs."
6ASKAD ;ask for 'Add' or 'Delete'
7 K DA,DIR,DIRUT S DIR(0)="SBO^A:ADD;D:DELETE",DIR("A")="Do you wish to ADD or DELETE?"
8 S DIR("?",1)="Enter 'A' to ADD a Ward (for Drug), 'D' to DELETE a Ward (for Drug),",DIR("?")="or '^' to quit" D ^DIR K DIR G:$D(DIRUT) END S ANS=Y
9 W !!,?5,"You may select a single NAOU, several NAOUs, or enter ^ALL to select all NAOUs.",!
10NAOU ;ask NAOU
11 K DA,DIC
12 F S DIC=58.8,DIC("A")="Select NAOU: ",DIC(0)="QEA",DIC("S")="I $S('$D(^(""I"")):1,'^(""I""):1,^(""I"")>DT:1,1:0),$P(^(0),""^"",2)=""N"",$P(^(0),""^"",3)=+PSDSITE" D ^DIC K DIC Q:Y<0 S NAOU(+Y)=""
13 I '$D(NAOU)&(X'="^ALL") G END
14 I X="^ALL" F PSD=0:0 S PSD=$O(^PSD(58.8,PSD)) Q:'PSD I $S('$D(^PSD(58.8,PSD,"I")):1,'^("I"):1,^("I")>DT:1,1:0),$P($G(^(0)),"^",2)="N",$P($G(^(0)),"^",3)=+PSDSITE S NAOU(PSD)=""
15 G:'$D(NAOU) END
16WARD ;ask ward
17 W ! S DIC=42,DIC(0)="QEAM",DIC("A")="Select WARD (for Drug) to "_$S(ANS="A":"add",1:"delete")_": " D ^DIC K DIC G:Y<0 END S PSDW=+Y,PSDWN=$P(Y,"^",2)
18QUE ;asks queueing information
19 S QUE=0 W !! K DA,DIR,DIRUT S DIR(0)="Y",DIR("B")="YES",DIR("A")="Do you want to queue this job",DIR("?",1)="To queue this job to run at a later time and free up your terminal now,"
20 S DIR("?")="accept the default, enter 'N' to run immediately or '^' to quit." D ^DIR K DIR I $D(DIRUT) W ! G END
21 I 'Y W !!,"Starting the WARD (for Drug) "_$S(ANS="A":"additions",ANS="D":"deletions")_"." G START
22 S QUE=1 W !!,"You will be notified by MailMan when the job is completed.",!!
23 S ZTIO="",ZTRTN="START^PSDWADD",ZTDESC="CS PHARM WARD (for Drug) ADD/DELETE" S (ZTSAVE("QUE"),ZTSAVE("PSDW"),ZTSAVE("ANS"),ZTSAVE("PSDWN"),ZTSAVE("PSDUZ"))=""
24 S:$D(NAOU) ZTSAVE("NAOU(")="" D ^%ZTLOAD K ZTSK G END
25START ;add or delete ward (for drug) data
26 K ^TMP("PSDWADD",$J) S (CNTD,CNTN,OK)=0 D:ANS="A" ADD D:ANS="D" DEL D:QUE MSG
27 I 'QUE W $C(7),!!,"WARD (for Drug) assignment of "_PSDWN_" has been ",$S(ANS="A":"added to",1:"deleted from"),":",!," => Total NAOU(s): "_CNTN_" => Total Stock Drugs: "_CNTD
28END K %,%H,%I,ANS,CNTD,CNTN,DA,DIC,DIE,DIK,DINUM,DIR,DIRUT,DR,PSDRG,DTOUT,DUOUT,PSDL,NAOU,OK,PSD,PSDUZ,QUE,RDT,PSDW,PSDWN
29 K X,XMDUZ,XMSUB,XMTEXT,XMY,Y,ZTDESC,ZTIO,ZTRTN,ZTSAVE,ZTSK S:$D(ZTQUEUED) ZTREQ="@"
30 Q
31ADD ;add ward (for drug)
32 F PSDL=0:0 S PSDL=$O(NAOU(PSDL)) S:OK CNTN=CNTN+1 Q:'PSDL S OK=0 I $S('$D(^PSD(58.8,PSDL,"I")):1,'^("I"):1,^("I")>DT:1,1:0),$S($P($G(^(0)),"^",2)'="P":1,1:0) D
33 .F PSDRG=0:0 S PSDRG=$O(^PSD(58.8,PSDL,1,PSDRG)) Q:'PSDRG I '$D(^PSD(58.8,PSDL,1,PSDRG,1,PSDW,0)) D
34 ..I '$D(^PSD(58.8,PSDL,1,PSDRG,1,0)) S ^(0)="^58.800115PA^^"
35 ..K DA,DIC S (DA,DINUM)=PSDW,X="`"_PSDW,DA(1)=PSDRG,DA(2)=PSDL,DIC="^PSD(58.8,"_PSDL_",1,"_PSDRG_",1,",DIC(0)="LNX",DLAYGO=58.8 D ^DIC K DIC,DLAYGO S CNTD=CNTD+1,OK=1 W:'QUE "."
36 Q
37DEL ;delete ward (for drug)
38 F PSDL=0:0 S PSDL=$O(NAOU(PSDL)) S:OK CNTN=CNTN+1 Q:'PSDL S OK=0 I $S('$D(^PSD(58.8,PSDL,"I")):1,'^("I"):1,^("I")>DT:1,1:0),$S($P($G(^(0)),"^",2)'="P":1,1:0) D
39 .F PSDRG=0:0 S PSDRG=$O(^PSD(58.8,PSDL,1,PSDRG)) Q:'PSDRG I $D(^PSD(58.8,PSDL,1,PSDRG,1,PSDW,0)) D
40 ..K DA,DIK,DR S DA(2)=PSDL,DA(1)=PSDRG,DA=PSDW,DIK="^PSD(58.8,"_DA(2)_",1,"_PSDRG_",1,",DR="15///@" D ^DIK K DIK S CNTD=CNTD+1,OK=1 W:'QUE "."
41 Q
42MSG ;send mailman message with completed info
43 K XMY,^TMP("PSDWAMSG",$J) D NOW^%DTC S Y=X X ^DD("DD") S RDT=Y S ^TMP("PSDWAMSG",$J,1,0)="CS PHARM WARD (for Drug) "_$S(ANS="A":"ADDITION",1:"DELETION")_" background job has run to completion."
44 S ^TMP("PSDWAMSG",$J,2,0)="Run Date: "_RDT,^TMP("PSDWAMSG",$J,3,0)=""
45 S ^TMP("PSDWAMSG",$J,4,0)="WARD (for Drug) assignment of "_PSDWN_" has been "_$S(ANS="A":"Added to",1:"Deleted from")_":"
46 S ^TMP("PSDWAMSG",$J,5,0)="=> Total NAOU(s): "_CNTN_" => Total Stock Drugs: "_CNTD
47 S XMSUB="CS PHARM MASS WARD (for Drug) "_$S(ANS="A":"ADDITION",1:"DELETION")_" SUMMARY",XMTEXT="^TMP(""PSDWAMSG"",$J,",XMDUZ="CONTROLLED SUBSTANCES PHARMACY",XMY(PSDUZ)=""
48 S:'$D(XMY) XMY(.5)="" D ^XMD K XMY,^TMP("PSDWAMSG",$J)
49 Q
Note: See TracBrowser for help on using the repository browser.