source: WorldVistAEHR/trunk/r/CONTROLLED_SUBSTANCES-PSD/PSDNSCG.m@ 1608

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

initial load of WorldVistAEHR

File size: 3.4 KB
RevLine 
[613]1PSDNSCG ;BIR/JPW-Nurse Shift Check Log GS perpetual; 2 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 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 shift check log.",!!,"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)"
9 D ^DIC K DIC G:Y<0 END S NAOU=+Y,NAOUN=$P(Y,"^",2)
10DEV ;ask device and queue info
11 W !!,"You may queue this report to print at a later time.",!!
12 K %ZIS,IOP,IO("Q"),POP S %ZIS="QM",%ZIS("B")="" D ^%ZIS I POP W !,"NO DEVICE SELECTED OR REPORT PRINTED!" G END
13 I $D(IO("Q")) K IO("Q"),ZTIO,ZTSAVE,ZTDTH,ZTSK S ZTRTN="START^PSDNSCL",ZTDESC="CS Nursing Shift Check Log",(ZTSAVE("NAOU"),ZTSAVE("NAOUN"))="" D ^%ZTLOAD,HOME^%ZIS K ZTSK G END
14 U IO
15START ;loops thru active orders
16 K ^TMP("PSDNSCL",$J) D NOW^%DTC S Y=+$E(%,1,12) X ^DD("DD") S RPDT=Y
17 F STAT=2.99:0 S STAT=$O(^PSD(58.8,"AC",STAT)) Q:('STAT)!(STAT>4) D LOOP
18 S STAT=10 F PSD=0:0 S PSD=$O(^PSD(58.8,"AC",STAT,PSD)) Q:'PSD D LOOP
19PRINT ;prints the report
20 S (PG,PSDOUT)=0
21 K LN S $P(LN,"-",80)="" I '$D(^TMP("PSDNSCL",$J)) D HDR W !!,?10,"**** NO ACTIVE ORDERS TO REPORT ****",! G DONE
22 D HDR
23 S DRUG="" F S DRUG=$O(^TMP("PSDNSCL",$J,DRUG)) Q:DRUG=""!(PSDOUT) W !!,?2,"=> ",DRUG,! S NUM="" F S NUM=$O(^TMP("PSDNSCL",$J,DRUG,NUM)) Q:NUM=""!(PSDOUT) D
24 .I $Y+8>IOSL D HDR Q:PSDOUT W !!,?2,"=> ",DRUG,!
25 .S NODE=^TMP("PSDNSCL",$J,DRUG,NUM) W !,NUM,?12,$P(NODE,"^",3),?34,$J($P(NODE,"^",2),6),?45,$P(NODE,"^",4),?55,$P($P(NODE,"^")," ")
26 .W ! W:$P($G(^DPT(+$P($G(^PSD(58.81,+$O(^PSD(58.81,"D",NUM,0)),9)),U),0)),U)]"" $P($G(^(0)),U)
27 .W ?50,$S($P(NODE,"^",5)="*":$P($P(NODE,"^")," ",2,99),1:$P($P(NODE,"^"),"-",2)),!
28DONE I $E(IOST)'="C" W @IOF
29 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
30END K %,%H,%I,%ZIS,ALL,DA,DIC,DIR,DIROUT,DIRUT,DRUG,DRUGN,DTOUT,DUOUT,LN,NAOU,NAOUN,NODE,NUM,OK,ORD
31 K PG,POP,PSD,PSDOUT,PSDPN,PSDST,PSDT,PSDTR,QTY,REC,REQ,RPDT,RQTY,STAT,STATN,X,Y,ZTDESC,ZTDTH,ZTRTN,ZTSAVE,ZTSK
32 K ^TMP("PSDNSCL",$J) D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
33 Q
34LOOP ;drug loop
35 F DRUG=0:0 S DRUG=$O(^PSD(58.8,"AC",STAT,NAOU,DRUG)) Q:'DRUG F ORD=0:0 S ORD=$O(^PSD(58.8,"AC",STAT,NAOU,DRUG,ORD)) Q:'ORD D
36 .Q:'$D(^PSD(58.8,NAOU,1,DRUG,3,ORD,0)) S NODE=^(0),DRUGN=$S($P($G(^PSDRUG(DRUG,0)),"^")]"":$P(^(0),"^"),1:"DRUG NAME MISSING")
37 .S PSDTR=$P(NODE,"^",17) I STAT=10 Q:$D(^PSD(58.81,"AE",PSDTR))
38 .S STATN=$P($G(^PSD(58.82,STAT,0)),"^"),RQTY=$P(NODE,"^",20),PSDPN=$S($P(NODE,"^",16)]"":$P(NODE,"^",16),1:"UNKNOWN")
39 .Q:'$P($G(^PSD(58.81,+$O(^PSD(58.81,"D",+PSDPN,0)),"CS")),U,4)
40 .S REQ=$P(NODE,"^",15) I REQ S Y=REQ X ^DD("DD") S REQ=Y
41 .S REC=$P(NODE,"^",7),REC=$P($G(^VA(200,+REC,0)),"^"),REC=$E($P(REC,",",2))_$E(REC)
42 .S ^TMP("PSDNSCL",$J,DRUGN,PSDPN)=STATN_"^"_RQTY_"^"_REQ_"^"_REC_"^"_$S(STAT=10:"*",1:"")
43 Q
44HDR ;header for log
45 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
46 S PG=PG+1 W:$Y @IOF W !,?15,"Nursing Shift Check Log for ",NAOUN,?70,"Page: ",PG,!,?20,RPDT,!
47 W !,?2,"=> DRUG",!,?18,"DATE",?44,"RECD"
48 W !,"DISP #",?18,"RECD",?37,"QTY",?45,"BY",?54,"ORDER STATUS"
49 W !,LN,!
50 Q
Note: See TracBrowser for help on using the repository browser.