source: WorldVistAEHR/trunk/r/CONTROLLED_SUBSTANCES-PSD/PSDNU2.m@ 1271

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

initial load of WorldVistAEHR

File size: 4.0 KB
Line 
1PSDNU2 ;BIR/JPW-Print NAOU Usage Report by NAOU ; 2 Aug 94
2 ;;3.0; CONTROLLED SUBSTANCES ;;13 Feb 97
3START ;entry point for report
4 K ^TMP("PSDNU",$J),^TMP("PSDNUS",$J),^TMP("PSDNUT",$J),^TMP("PSDNUG",$J),^TMP("PSDNUQ",$J)
5 F JJ2=2,3,4,5 F JJ=PSDSD:0 S JJ=$O(^PSD(58.81,"ACT",JJ)) Q:'JJ!(JJ>PSDED) F JJ1=0:0 S JJ1=$O(^PSD(58.81,"ACT",JJ,JJ1)) Q:'JJ1 F PSDR=0:0 S PSDR=$O(^PSD(58.81,"ACT",JJ,JJ1,PSDR)) Q:'PSDR D
6 .F KK=0:0 S KK=$O(^PSD(58.81,"ACT",JJ,JJ1,PSDR,JJ2,KK)) Q:'KK D SET
7PRINT ;prints data for stock drugs
8 I SUM D ^PSDNU3 G DONE
9 K LN S $P(LN,"-",80)="",(PG,PSDOUT)=0,%DT="",X="T" D ^%DT X ^DD("DD") S RPDT=Y
10 I '$D(^TMP("PSDNU",$J)) D HDR W !!,?10,"***** NO DATA AVAILABLE FOR THIS REPORT *****" G DONE
11 S NAOU="" F S NAOU=$O(^TMP("PSDNU",$J,NAOU)) D:NAOU="" GTOT Q:NAOU=""!(PSDOUT) D HDR S PSDR="" F S PSDR=$O(^TMP("PSDNU",$J,NAOU,PSDR)) D:PSDR="" NTOT Q:PSDR=""!(PSDOUT) W !,?2,"=> ",PSDR,!! D
12 .S NUM="" F S NUM=$O(^TMP("PSDNU",$J,NAOU,PSDR,NUM)) D:NUM="" TOT Q:NUM=""!(PSDOUT) F JJ=0:0 S JJ=$O(^TMP("PSDNU",$J,NAOU,PSDR,NUM,JJ)) Q:'JJ!(PSDOUT) D
13 ..S NODE=^TMP("PSDNU",$J,NAOU,PSDR,NUM,JJ),DATE=$E(JJ,4,5)_"/"_$E(JJ,6,7)_"/"_$E(JJ,2,3)
14 ..I $Y+8>IOSL D HDR Q:PSDOUT W !,?2,"=> ",PSDR,!!
15 ..W NUM,?16,DATE,?25,$J($P(NODE,"^"),6),?37,$P(NODE,"^",2),?70,$P(NODE,"^",3),!
16DONE I $E(IOST)'="C" W @IOF
17 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
18END ;
19 K %,%DT,%H,%I,%ZIS,ALL,ANS,DA,DATE,DIR,DIROUT,DIRUT,DTOUT,DUOUT,IO("Q"),JJ,JJ1,JJ2,KK,LOC,LN
20 K NAOU,NAOUN,NODE,NUM,NURS,QTY,PG,POP,PSD,PSDATE,PSDED,PSDOK,PSDOUT,PSDPN,PSDR,PSDRN,PSDSD,PSDT,PSDTR,RPDT,SUM,X,Y
21 K ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
22 K ^TMP("PSDNU",$J),^TMP("PSDNUT",$J),^TMP("PSDNUG",$J),^TMP("PSDNUQ",$J),^TMP("PSDNUS",$J)
23 D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
24 Q
25SET ;sets data
26 Q:'$D(^PSD(58.81,KK,0)) S NODE=^PSD(58.81,KK,0),PSD=+$P(NODE,"^",18)
27 Q:'$D(LOC(PSD)) Q:+$P($G(^PSD(58.8,PSD,0)),"^",3)'=+PSDSITE S PSDOK=0
28 S PSDRN=$S($P($G(^PSDRUG(PSDR,0)),"^")]"":$P(^(0),"^"),1:"DRUG NAME MISSING")
29 S NAOUN=$S($P($G(^PSD(58.8,PSD,0)),"^")]"":$P(^(0),"^"),1:"NAOU NAME MISSING")
30 S PSDPN=$S($P(NODE,"^",17)]"":$P(NODE,"^",17),1:"DISP W/O GS"),QTY=+$P(NODE,"^",6)
31 S:+$P($G(^PSD(58.81,KK,4)),"^",3) QTY=+$P($G(^(4)),"^",3)
32 I JJ2=2,$D(^PSD(58.81,KK,7)),+$P(^(7),"^",3)'=PSD S QTY=QTY-(+$P(^(7),"^",7))
33 S QTY=$S(JJ2=3:-(+$P($G(^PSD(58.81,KK,3)),"^",2)),JJ2=4:-(+$P($G(^PSD(58.81,KK,3)),"^",5)),JJ2=14:+$P($G(^PSD(58.81,KK,4)),"^",3),1:QTY)
34 I JJ2=5 S PSDTR=+$P($G(^PSD(58.81,KK,7)),"^",6) D:PSDTR
35 .I +$P($G(^PSD(58.81,PSDTR,0)),"^",18)=PSD S PSDOK=1
36 S NURS=$S(+$P($G(^PSD(58.81,KK,1)),"^",7):+$P($G(^(1)),"^",7),1:+$P($G(^PSD(58.81,KK,1)),"^",3))
37 S NURS=$S($P($G(^VA(200,NURS,0)),"^")]"":$P(^(0),"^"),PSDPN="DISP W/O GS":"N/A",1:"UNKNOWN")
38 S ^TMP("PSDNU",$J,NAOUN,PSDRN,PSDPN,JJ)=QTY_"^"_NURS_"^"_$S(JJ2=2:"DISPENSE",JJ2=3:"RET/STK",JJ2=4:"DESTROY",JJ2=5:"TRANSFER",1:"N/A")
39 S:'$D(^TMP("PSDNUT",$J,NAOUN)) ^TMP("PSDNUT",$J,NAOUN)=0 S:'PSDOK ^TMP("PSDNUT",$J,NAOUN)=+^TMP("PSDNUT",$J,NAOUN)+1
40 S:'$D(^TMP("PSDNUS",$J,NAOUN,PSDRN)) ^TMP("PSDNUS",$J,NAOUN,PSDRN)=0 S:'PSDOK ^TMP("PSDNUS",$J,NAOUN,PSDRN)=+^TMP("PSDNUS",$J,NAOUN,PSDRN)+1
41 S:'$D(^TMP("PSDNUQ",$J,NAOUN,PSDRN)) ^TMP("PSDNUQ",$J,NAOUN,PSDRN)=0 S ^TMP("PSDNUQ",$J,NAOUN,PSDRN)=+^TMP("PSDNUQ",$J,NAOUN,PSDRN)+QTY
42 S:'$D(^TMP("PSDNUG",$J)) ^TMP("PSDNUG",$J)=0 S:'PSDOK ^TMP("PSDNUG",$J)=+^TMP("PSDNUG",$J)+1
43 S PSDOK=0
44 Q
45HDR ;lists header information
46 I $E(IOST,1,2)="C-",PG K DA,DIR S DIR(0)="E" D ^DIR K DIR I 'Y S PSDOUT=1 Q
47 W:$Y @IOF S PG=PG+1 W !,"NAOU/DRUG USAGE REPORT - DATE: "_RPDT,?70,"PAGE: ",PG,!
48 W:$D(NAOU) "NAOU: ",NAOU,!
49 W "From ",$P(PSDATE,"^")," to ",$P(PSDATE,"^",2),!!
50 W !,?2,"=> DRUG",!,?16,"DATE",!,"DISP #",?15,"FILLED",?25,"QUANTITY",?37,"ORDERED BY",?70,"TYPE",!,LN,!
51 Q
52TOT Q:PSDOUT W !,"---------",?25,"----------",!,?3,^TMP("PSDNUS",$J,NAOU,PSDR),?25,$J(^TMP("PSDNUQ",$J,NAOU,PSDR),6),?37,"Totals",!
53 Q
54NTOT Q:PSDOUT W !,"NAOU Subtotal # of Orders: ",^TMP("PSDNUT",$J,NAOU),!
55 Q
56GTOT ;grand total
57 Q:PSDOUT
58 W !,"Grand Total # of Orders: ",^TMP("PSDNUG",$J),!
59 Q
Note: See TracBrowser for help on using the repository browser.