source: WorldVistAEHR/trunk/r/CONTROLLED_SUBSTANCES-PSD/PSDORSN.m@ 1154

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

initial load of WorldVistAEHR

File size: 3.9 KB
Line 
1PSDORSN ;BIR/JPW-Nurse Order Stats Report ; 8 Aug 94
2 ;;3.0; CONTROLLED SUBSTANCES ;;13 Feb 97
3 I '$D(PSDSITE) D ^PSDSET Q:'$D(PSDSITE)
4 S OK=$S($D(^XUSEC("PSJ RPHARM",DUZ)):1,$D(^XUSEC("PSJ PHARM TECH",DUZ)):1,$D(^XUSEC("PSJ RNURSE",DUZ)):1,$D(^XUSEC("PSD NURSE",DUZ)):1,1:0)
5 I 'OK W $C(7),!!,?9,"** Please contact your Coordinator for access to",!,?12,"print this report.",!!,"PSJ RPHARM, PSJ PHARM TECH, PSJ RNURSE, or PSD NURSE security key required.",! K OK Q
6ASKN ;ask naou
7 K DA,DIC S DIC=58.8,DIC(0)="QEA",DIC("A")="Select NAOU: "
8 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)" D ^DIC K DIC G:Y<0 END
9 S NAOU=+Y,NAOUN=$P(Y,"^",2)
10ALL ;asks for all orders
11 W ! K DA,DIR,DIRUT S DIR(0)="Y",DIR("A")="Do you want to print this report for all drugs",DIR("B")="NO"
12 S DIR("?",1)="Answer 'YES' to list all pending orders for this NAOU,",DIR("?")="answer 'NO' to list orders for a specific drug or '^' to quit."
13 D ^DIR K DIR G:$D(DIRUT) END S ALL=+Y
14 G:ALL DEV
15DRUG ;select drugs
16 W ! 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 ***"""
17 S DA(1)=+NAOU,DIC(0)="QEAM",DIC="^PSD(58.8,"_NAOU_",1," D ^DIC K DIC G:Y<0 END S PSDR=+Y
18DEV ;ask device and queue info
19 W !!,"You may queue this report to print at a later time.",!!
20 K %ZIS,IOP,IO("Q"),POP S %ZIS="QM",%ZIS("B")="HOME" D ^%ZIS I POP W !,"NO DEVICE SELECTED OR REPORT PRINTED!" G END
21 I $D(IO("Q")) K IO("Q"),ZTIO,ZTSAVE,ZTDTH,ZTSK S ZTRTN="START^PSDORSN",ZTDESC="Status of Pending Narcotic Orders" D SAVE,^%ZTLOAD,HOME^%ZIS K ZTSK G END
22 U IO
23START ;loops thru pending orders and orders cancelled in the past 3 days
24 K ^TMP("PSDNST",$J)
25 D NOW^%DTC S (PSDT,X1)=X,X2=-3 D C^%DTC S PSDST=X
26 I ALL F STAT=.5:0 S STAT=$O(^PSD(58.8,"AC",STAT)) Q:'STAT!(STAT>3) D LOOP
27 I ALL S STAT=9 D:$D(^PSD(58.8,"AC",STAT)) LOOP G PRINT
28 F STAT=.5:0 S STAT=$O(^PSD(58.8,"AC",STAT)) Q:'STAT!(STAT>3) D ORD
29 S STAT=9 D:$D(^PSD(58.8,"AC",STAT,NAOU,PSDR)) ORD
30PRINT ;prints the report
31 S (PG,PSDOUT)=0,Y=PSDT X ^DD("DD") S RPDT=Y
32 K LN S $P(LN,"-",80)="" D HDR I '$D(^TMP("PSDNST",$J)) W !!,?10,"**** NO PENDING ORDERS TO REPORT ****" G END
33 S PSDR="" F S PSDR=$O(^TMP("PSDNST",$J,PSDR)) Q:PSDR=""!(PSDOUT) W !!,?2,"=> ",PSDR,! D Q:PSDOUT
34 .F ORD=0:0 S ORD=$O(^TMP("PSDNST",$J,PSDR,ORD)) Q:'ORD!(PSDOUT) D:$Y+4>IOSL HDR Q:PSDOUT D
35 ..S NODE=^TMP("PSDNST",$J,PSDR,ORD) W !,$P(NODE,"^",4),?11,$P(NODE,"^",3),?33,$J($P(NODE,"^",2),6),?42,$P(NODE,"^")
36DONE I $E(IOST)'="C" W @IOF
37 I $E(IOST,1,2)="C-",'PSDOUT W ! K DIR,DIRUT S DIR(0)="EA",DIR("A")="END OF REPORT! Press <RET> to return to the menu" D ^DIR K DIR
38END K %,%H,%I,%ZIS,ALL,DA,DIC,DIR,DIROUT,DIRUT,DTOUT,DUOUT,LN,NAOU,NAOUN,NODE,OK,ORD
39 K PG,POP,PSDOUT,PSDPN,PSDR,PSDRN,PSDST,PSDT,QTY,REQ,RPDT,STAT,STATN,X,X1,X2,Y,ZTDESC,ZTDTH,ZTRTN,ZTSAVE,ZTSK
40 K ^TMP("PSDNST",$J) D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
41 Q
42LOOP ;starts drug loop for all orders
43 F PSDR=0:0 S PSDR=$O(^PSD(58.8,"AC",STAT,NAOU,PSDR)) Q:'PSDR D ORD
44 Q
45ORD ;order loop
46 F ORD=0:0 S ORD=$O(^PSD(58.8,"AC",STAT,NAOU,PSDR,ORD)) Q:'ORD D SET
47 Q
48SET ;sets data for printing
49 Q:'$D(^PSD(58.8,NAOU,1,PSDR,3,ORD,0)) S NODE=^(0),PSDRN=$S($P($G(^PSDRUG(PSDR,0)),"^")]"":$P(^(0),"^"),1:"DRUG NAME MISSING")
50 I STAT=9,$P(NODE,"^",2)<PSDST Q
51 S STATN=$P($G(^PSD(58.82,STAT,0)),"^"),STATN=$E(STATN,1,30),QTY=$P(NODE,"^",6),PSDPN=$P(NODE,"^",16),REQ=$P(NODE,"^",2) I REQ S Y=REQ X ^DD("DD") S REQ=Y
52 S ^TMP("PSDNST",$J,PSDRN,ORD)=STATN_"^"_QTY_"^"_REQ_"^"_PSDPN
53 Q
54HDR ;header for log
55 I $E(IOST,1,2)="C-",PG W ! K DA,DIR S DIR(0)="E" D ^DIR K DIR I 'Y S PSDOUT=1 Q
56 S PG=PG+1 W:$Y @IOF W !,?25,"Status of Pending Narcotic Orders",?70,"Page: ",PG,!,?35,NAOUN,!,?35,RPDT,!
57 W !,?2,"=> DRUG",!,?13,"DATE",?33,"QUANTITY",!,"DISP #",?12,"ORDERED",?33,"ORDERED",?48,"ORDER STATUS"
58 W !,LN,!
59 Q
60SAVE S (ZTSAVE("ALL"),ZTSAVE("NAOU"),ZTSAVE("NAOUN"))="" S:$D(PSDR) ZTSAVE("PSDR")=""
61 Q
Note: See TracBrowser for help on using the repository browser.