source: FOIAVistA/trunk/r/CONTROLLED_SUBSTANCES-PSD/PSDPND.m@ 1397

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

initial load of FOIAVistA 6/30/08 version

File size: 4.1 KB
Line 
1PSDPND ;BIR/BJW-Pharm Dispensing Report ; 18 Jun 98
2 ;;3.0; CONTROLLED SUBSTANCES ;**8,10**;13 Feb 97
3 ;**Y2K compliance**,"P" added to date input string
4 ;mod.for nois:tua-0498-32173,start+19
5 I '$D(PSDSITE) D ^PSDSET Q:'$D(PSDSITE)
6 S OK=$S($D(^XUSEC("PSJ RPHARM",DUZ)):1,$D(^XUSEC("PSJ PHARM TECH",DUZ)):1,1:0)
7 I 'OK W $C(7),!!,?9,"** Please contact your Pharmacy Coordinator for access to",!,?12,"print CS reports.",!!,"PSJ RPHARM or PSJ PHARM TECH security key required.",! K OK Q
8ASKD ;ask disp loc
9 S PSDS=$P(PSDSITE,U,3),PSDSN=$P(PSDSITE,U,4)
10 G:$P(PSDSITE,U,5) DATE
11 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)"
12 S DIC("A")="Select Primary Dispensing Site: ",DIC("B")=$P(PSDSITE,U,4)
13 D ^DIC K DIC G:Y<0 END
14 S PSDS=+Y,PSDSN=$P(Y,"^",2),$P(PSDSITE,U,3)=+Y,$P(PSDSITE,U,4)=PSDSN
15DATE ;ask date range
16 W ! K %DT S %DT="AEPX",%DT("A")="Start with Date: " D ^%DT I Y<0 S PSDOUT=1 G END
17 S PSDSD=Y D D^DIQ S PSDATE=Y,%DT("A")="End with Date: " D ^%DT I Y<0 S PSDOUT=1 G END
18 I Y<PSDSD W !!,"The ending date of the range must be later than the starting date." G DATE
19 S PSDED=Y D D^DIQ S PSDATE=PSDATE_"^"_Y,PSDSD=PSDSD-.0001,PSDED=PSDED+.9999
20SUM ;if sum only
21 K DA,DIR,DIRUT S DIR(0)="Y",DIR("A")="Do you want to print the summary totals only",DIR("B")="NO"
22 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."
23 D ^DIR K DIR G:$D(DIRUT) END S SUM=Y
24DEV ;dev & queue info
25 W !!,"This report is designed for a 132 column format.",!,"You may queue this report to print at a later time.",!!
26 S Y=$P($G(^PSD(58.8,+PSDS,2)),"^",9),C=$P(^DD(58.8,24,0),"^",2) D Y^DIQ S PSDEV=Y
27 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
28 I $D(IO("Q")) K IO("Q"),ZTIO,ZTSAVE,ZTDTH,ZTSK S ZTRTN="START^PSDPND",ZTDESC="Pharm Narcotic Disp Report" D SAVE,^%ZTLOAD,HOME^%ZIS K ZTSK G END
29 U IO
30START ;compile data
31 K ^TMP("PSDND",$J),^TMP("PSDNDT",$J)
32 F PSD=PSDSD:0 S PSD=$O(^PSD(58.81,"AF",PSD)) Q:'PSD!(PSD>PSDED) F JJ=2,6,7 F PSDA=0:0 S PSDA=$O(^PSD(58.81,"AF",PSD,PSDS,JJ,PSDA)) Q:'PSDA I $D(^PSD(58.81,PSDA,0)) D
33 .S NODE=^PSD(58.81,PSDA,0),PSDPN=$S($P(NODE,"^",17)]"":$P(NODE,"^",17),1:"UNKNOWN")
34 .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,24)
35 .S DRUG=+$P(NODE,"^",5),DRUGN=$S($P($G(^PSDRUG(DRUG,0)),"^")]"":$P(^(0),"^"),1:"ZZ/"_DRUG)
36 .S QTY=$P(NODE,"^",6) I $D(^PSD(58.81,PSDA,4)),+$P(^(4),"^",3) S QTY=$P(^(4),"^",3)
37 .I JJ=7 S QTY=0 Q:PSDPN="UNKNOWN"
38 .I $D(^PSD(58.81,PSDA,5)),+^(5) S QTY=0,NAOUN="CANCELLED"
39 .S:'$D(^TMP("PSDNDT",$J,DRUGN)) ^TMP("PSDNDT",$J,DRUGN)=0
40 .S ^TMP("PSDNDT",$J,DRUGN)=^TMP("PSDNDT",$J,DRUGN)+QTY Q:SUM
41 .I 'PSDPN S PSDPN="W/O 2638",PHARM=+$P(NODE,"^",7)
42 .I $D(^PSD(58.81,PSDA,1)) S PHARM=+$P(^(1),"^")
43 .S PHARMN=$S($P($G(^VA(200,+PHARM,0)),"^")]"":$P(^(0),"^"),1:"UNKNOWN") I PHARMN'="UNKNOWN" S PHARMN=$P(PHARMN,",")_","_$E($P(PHARMN,",",2))
44 .S PSDST=$P(NODE,"^",4),PSDDT="" I PSDST S Y=$E(PSDST,1,7) X ^DD("DD") S PSDDT=Y
45 .I JJ=6,'$D(^PSD(58.81,PSDA,6)) Q
46 .I JJ=6 S PSRX=+$P(^PSD(58.81,PSDA,6),"^"),PSDPN=$S($P(^(6),"^",5)]"":$P(^(6),"^",5),$P($G(^PSRX(PSRX,0)),"^")]"":$P(^(0),"^"),1:"UNKNOWN") D
47 ..S PSRXP=+$P($G(^PSRX(PSRX,0)),"^",2)
48 ..K C S Y=PSRXP,C=$P(^DD(58.81,73,0),"^",2) D Y^DIQ K C
49 ..S PSDRXIN=PSRX D VER^PSDOPT
50 ..S NAOUN=$S('$O(^PSRX("B",PSDPN,0)):"RX DELETED",$G(PSDSTA)=13:"RX DELETED",PSRXP]"":Y,1:"UNKNOWN"),NAOUN=$E(NAOUN,1,24)
51 ..K PSDSTA,PSDRXIN,PSOVR
52 .S ^TMP("PSDND",$J,PSDPN,PSDA)=DRUGN_"^"_NAOUN_"^"_QTY_"^"_PSDDT_"^"_PHARMN
53PRT D PRINT^PSDPND1
54END ;
55 K %,%DT,%H,%I,%ZIS,C,DA,DIC,DIR,DIROUT,DIRUT,DTOUT,DRUG,DRUGN,DUOUT,JJ,LN,NAOU,NAOUN,NODE,NUM,OK
56 K PG,PHARM,PHARMN,POP,PSD,PSDA,PSDATE,PSDDT,PSDED,PSDEV,PSDOUT,PSDPN,PSRX,PSRXP,PSDS,PSDSD,PSDSN,PSDST,QTY,SUM,X,Y,ZTDESC,ZTDTH,ZTRTN,ZTSAVE,ZTSK
57 K ^TMP("PSDND",$J),^TMP("PSDNDT",$J) D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
58 Q
59SAVE S (ZTSAVE("SUM"),ZTSAVE("PSDSN"),ZTSAVE("PSDS"),ZTSAVE("PSDSD"),ZTSAVE("PSDED"),ZTSAVE("PSDATE"))=""
60 Q
Note: See TracBrowser for help on using the repository browser.