source: WorldVistAEHR/trunk/r/CONTROLLED_SUBSTANCES-PSD/PSDFND.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: 4.3 KB
Line 
1PSDFND ;BIR/JPW-Pharm Filled Not Delivered Report ; 29 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 RNURSE",DUZ)):2,$D(^XUSEC("PSJ PHARM TECH",DUZ)):1,1:0)
5 I 'OK W $C(7),!!,?9,"** Please contact your Coordinator for access to",!,?12,"review this narcotics report.",!!,"PSJ RPHARM, PSJ RNURSE, or PSJ PHARM TECH security key required.",! K OK Q
6ASKD ;ask dispensing location
7 S PSDS=$P(PSDSITE,U,3),PSDSN=$P(PSDSITE,U,4)
8 G:$P(PSDSITE,U,5) SUM
9 K DIC,DA S DIC=58.8,DIC(0)="QEAZ",DIC("S")="I $P(^(0),""^"",3)=+PSDSITE,$S($P(^(0),""^"",2)[""M"":1,$P(^(0),""^"",2)[""S"":1,1:0)"
10 S DIC("A")="Select Primary Dispensing Site: ",DIC("B")=PSDSN
11 D ^DIC K DIC G:Y<0 END
12 S PSDS=+Y,PSDSN=$P(Y,"^",2),$P(PSDSITE,U,3)=+Y,$P(PSDSITE,U,4)=PSDSN
13SUM ;if summary only
14 K DA,DIR,DIRUT S DIR(0)="Y",DIR("A")="Do you want to print the summary totals only",DIR("B")="NO"
15 S DIR("?",1)="Answer 'YES' to print only the summary totals for this report,",DIR("?")="answer 'NO' to print the report and the summary totals."
16 D ^DIR K DIR G:$D(DIRUT) END S SUM=Y
17DEV ;ask device and queue info
18 W !!,"This report is designed for a 132 column format.",!,"You may queue this report to print at a later time.",!!
19 S Y=$P($G(^PSD(58.8,+PSDS,2)),"^",9),C=$P(^DD(58.8,24,0),"^",2) D Y^DIQ S PSDEV=$S($G(OK)=2:"",1:Y)
20 K %ZIS,IOP,IO("Q"),POP S %ZIS="QM",%ZIS("B")=PSDEV 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^PSDFND",ZTDESC="CS Filled Not Delivered Report" S (ZTSAVE("SUM"),ZTSAVE("PSDS"),ZTSAVE("PSDSN"))="" D ^%ZTLOAD,HOME^%ZIS K ZTSK G END
22 U IO
23START ;compile data
24 K ^TMP("PSDFND",$J),^TMP("PSDFNDT",$J)
25 F PSD=0:0 S PSD=$O(^PSD(58.81,"AD",3,PSD)) Q:'PSD F PSDA=0:0 S PSDA=$O(^PSD(58.81,"AD",3,PSD,PSDA)) Q:'PSDA I $D(^PSD(58.81,PSDA,0)),$P(^(0),"^",3)=+PSDS D
26 .I $D(^PSD(58.81,PSDA,5)),+^(5) Q
27 .S NODE=^PSD(58.81,PSDA,0),PSDPN=$S($P(NODE,"^",17)]"":$P(NODE,"^",17),1:"UNKNOWN")
28 .S NAOU=+$P(NODE,"^",18),NAOUN=$S($P($G(^PSD(58.8,NAOU,0)),"^")]"":$P(^(0),"^"),1:"ZZ/"_NAOU) I NAOUN'="UNKNOWN" S NAOUN=$E(NAOUN,1,10)
29 .S DRUG=+$P(NODE,"^",5),DRUGN=$S($P($G(^PSDRUG(DRUG,0)),"^")]"":$P(^(0),"^"),1:"ZZ/"_DRUG)
30 .S QTY=$P(NODE,"^",6) I $D(^PSD(58.81,PSDA,4)),+$P(^(4),"^",3) S QTY=$P(^(4),"^",3)
31 .S:'$D(^TMP("PSDFNDT",$J,DRUGN)) ^TMP("PSDFNDT",$J,DRUGN)=0
32 .S ^TMP("PSDFNDT",$J,DRUGN)=^TMP("PSDFNDT",$J,DRUGN)+QTY Q:SUM
33 .S PHARM=$P($G(^PSD(58.81,PSDA,1)),"^"),PHARMN=$S($P($G(^VA(200,+PHARM,0)),"^")]"":$P(^(0),"^"),1:"UNKNOWN") I PHARMN'="UNKNOWN" S PHARMN=$P(PHARMN,",")_","_$E($P(PHARMN,",",2))
34 .S PSDST=$P(NODE,"^",4),PSDDT="" I PSDST S Y=$E(PSDST,1,7) X ^DD("DD") S PSDDT=Y
35 .S ^TMP("PSDFND",$J,PSDPN,PSDA)=DRUGN_"^"_NAOUN_"^"_QTY_"^"_PSDDT_"^"_PHARMN
36PRINT ;print filled not delivered log
37 D NOW^%DTC S Y=X X ^DD("DD") S RPDT=Y
38 I SUM D ^PSDFND1 G DONE
39 S (PG,PSDOUT)=0
40 K LN S $P(LN,"-",132)="" I '$D(^TMP("PSDFND",$J)) D HDR W !!,?40,"**** NO PENDING DELIVERIES FOR THIS DISPENSING LOCATION ****",! G DONE
41 D HDR S NUM="" F S NUM=$O(^TMP("PSDFND",$J,NUM)) Q:NUM=""!(PSDOUT) D:$Y+4>IOSL HDR Q:PSDOUT D
42 .F PSD=0:0 S PSD=$O(^TMP("PSDFND",$J,NUM,PSD)) Q:'PSD!(PSDOUT) D:$Y+4>IOSL HDR Q:PSDOUT S NODE=^TMP("PSDFND",$J,NUM,PSD) W !,NUM,?15,$P(NODE,"^"),?65,$J($P(NODE,"^",3),6),?80,$P(NODE,"^",4),?95,$P(NODE,"^",2),?112,$P(NODE,"^",5)
43 I $E(IOST,1,2)="C-",'PSDOUT W ! K DIR S DIR(0)="EA",DIR("A")="Press <RET> to return to display the summary totals" D ^DIR K DIR I 'Y S PSDOUT=1 G DONE
44 D:'PSDOUT ^PSDFND1
45DONE I $E(IOST)'="C" W @IOF
46 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
47END ;
48 K %,%DT,%H,%I,%ZIS,C,DA,DIC,DIR,DIROUT,DIRUT,DTOUT,DRUG,DRUGN,DUOUT,LN,NAOU,NAOUN,NODE,NUM
49 K OK,PG,PHARM,PHARMN,POP,PSD,PSDA,PSDDT,PSDEV,PSDOUT,PSDPN,PSDS,PSDSN,PSDST,QTY,RPDT,SUM,X,Y,ZTDESC,ZTDTH,ZTRTN,ZTSAVE,ZTSK
50 K ^TMP("PSDFND",$J),^TMP("PSDFNDT",$J) D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
51 Q
52HDR ;header for log
53 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
54 S PG=PG+1 W:$Y @IOF W !,?45,"Narcotics Filled Not Delivered Report",?115,"Page: ",PG,!,?45,"Dispensing Vault: "_PSDSN,!,?56,RPDT,!
55 W !!,?65,"QUANTITY",?82,"DATE",?97,"NAOU"
56 W !,"DISP #",?15,"DRUG",?65,"DISPENSED",?80,"DISPENSED",?94,"DISPENSED TO",?112,"DISPENSED BY"
57 W !,LN,!
58 Q
Note: See TracBrowser for help on using the repository browser.