source: FOIAVistA/trunk/r/CONTROLLED_SUBSTANCES-PSD/PSDERCP.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.5 KB
Line 
1PSDERCP ;BIR/BJW-CS Resolved Error Log Report ; 6 Feb 98
2 ;;3.0; CONTROLLED SUBSTANCES ;**8**;13 Feb 97
3 ;**Y2K compliance**,"P" added to date input string
4 I '$D(PSDSITE) D ^PSDSET Q:'$D(PSDSITE)
5 S OK=$S($D(^XUSEC("PSDMGR",DUZ)):1,$D(^XUSEC("PSD ERROR",DUZ)):2,1:0)
6 I 'OK W $C(7),!!,?9,"** Please contact your Pharmacy Coordinator for access to",!,?12,"the pending Controlled Substances error log.",!!,"PSDMGR or PSD ERROR security key required.",! K OK Q
7 S PSDS=$P(PSDSITE,U,3),PSDSN=$P(PSDSITE,U,4) G:$P(PSDSITE,U,5) DATE
8ASKD ;ask disp location
9 W !!,"You may select a Dispensing Site at the prompt.",!
10 W ! K DIC,DA S DIC=58.8,DIC(0)="QEAZ"
11 S 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 Dispensing Site: ",DIC("B")=PSDSN
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="AEP",%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
20DEV ;select device
21 W !!,"This report is designed for a 80 column format.",!,"You may queue this report to print at a later time.",!!
22 S Y=$P($G(^PSD(58.8,+PSDS,2)),"^",9),C=$P(^DD(58.8,24,0),"^",2) D Y^DIQ S PSDEV=Y
23 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
24 I $D(IO("Q")) K IO("Q"),ZTIO,ZTSAVE,ZTDTH,ZTSK S ZTRTN="START^PSDERCP",ZTDESC="CS Resolved Error Log Report" D SAVE,^%ZTLOAD,HOME^%ZIS K ZTSK G END
25 U IO
26START ;start looping
27 K ^TMP("PSDERCP",$J)
28 D NOW^%DTC S Y=X X ^DD("DD") S RPDT=Y
29 K LN S (COMM,CNT,PG,PSDOUT)=0,$P(LN,"-",80)=""
30 F PSD=PSDSD:0 S PSD=$O(^PSD(58.89,"AE",PSD)) Q:'PSD!(PSD>PSDED) F PSDA=0:0 S PSDA=$O(^PSD(58.89,"AE",PSD,PSDS,PSDA)) Q:'PSDA D
31 .Q:'$D(^PSD(58.89,+PSDA,0)) S NODE=^PSD(58.89,+PSDA,0)
32 .S PSDN=+$P(NODE,"^",2) Q:'$D(^PSD(58.81,+PSDN,0)) S NODE1=^PSD(58.81,+PSDN,0),PSDR=+$P(NODE1,"^",5)
33 .S NODE9=$G(^PSD(58.81,+PSDN,9)),PHARM=$S(+$P(NODE9,"^",2):+$P(NODE9,"^",2),+$P(NODE9,"^",8):+$P(NODE9,"^",8),1:"")
34 .S PHARM2=+$P(NODE,"^",4)
35 .S PSDRN=$S($P($G(^PSDRUG(+PSDR,0)),"^")]"":$P($G(^PSDRUG(+PSDR,0)),"^"),1:"#"_+PSDR_" DRUG NAME MISSING")
36 .S QTY=$P(NODE1,"^",6),PHARMN=$S($P($G(^VA(200,+PHARM,0)),"^")]"":$P(^(0),"^"),1:"UNKNOWN"),PHARMN2=$S($P($G(^VA(200,+PHARM2,0)),"^")]"":$P(^(0),"^"),1:"UNKNOWN")
37 .S PSDT=$E(PSD,4,5)_"/"_$E(PSD,6,7)_"/"_$E(PSD,2,3),TYP=+$P(NODE1,"^",2),TYP=$P($G(^PSD(58.84,+TYP,0)),"^")
38 .S COMM=$S($D(^PSD(58.89,PSDA,1,0)):1,1:0)
39 .S ^TMP("PSDERCP",$J,PSDRN,PSDA)=QTY_"^"_PHARMN_"^"_PHARMN2_"^"_PSDT_"^"_TYP_"^"_COMM,CNT=CNT+1
40 I CNT=0 D HDR W !!,?10,"*** NO CONTROLLED SUBSTANCES RESOLVED ERRORS/ADJUSTMENTS ***",!! G DONE
41PRINT ;prints data
42 S COMM=0 D HDR Q:PSDOUT
43 S PSDRN="" F S PSDRN=$O(^TMP("PSDERCP",$J,PSDRN)) Q:PSDRN="" D:$Y+4>IOSL HDR Q:PSDOUT W !,?2,"=> ",PSDRN,! F PSDA=0:0 S PSDA=$O(^TMP("PSDERCP",$J,PSDRN,PSDA)) Q:'PSDA D Q:PSDOUT
44 .I $Y+4>IOSL D HDR Q:PSDOUT W !,?2,"=> ",PSDRN,!
45 .S NODE=^TMP("PSDERCP",$J,PSDRN,PSDA) W !,PSDA,?10,$J($P(NODE,"^"),6),?20,$P(NODE,"^",4),?35,$P(NODE,"^",5),!,?5,$P(NODE,"^",2),?45,$P(NODE,"^",3),!
46 .I $P(NODE,"^",6) W ?5,"Resolution: " S COMM=1 K ^UTILITY($J,"W") F TEXT=0:0 S TEXT=$O(^PSD(58.89,PSDA,1,TEXT)) Q:'TEXT D:$Y+4>IOSL HDR Q:PSDOUT S X=$G(^PSD(58.89,PSDA,1,TEXT,0)),DIWL=10,DIWR=75,DIWF="W" D ^DIWP
47 .I COMM D ^DIWW S COMM=0 W !
48DONE I $E(IOST)'="C" W @IOF
49 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
50END ;
51 K %,%DT,%H,%I,%ZIS,C,COMM,CNT,DA,DIC,DIR,DIROUT,DIRUT,DIWF,DIWL,DIWR,DTOUT,DUOUT,LN,NODE,NODE1,NODE9,OK
52 K PG,PHARM,PHARM2,PHARMN,PHARMN2,POP,PSD,PSDA,PSDATE,PSDED,PSDEV,PSDN,PSDOUT,PSDR,PSDRG,PSDRN,PSDS,PSDSD,PSDSN,PSDT
53 K QTY,RPDT,TEXT,TYP,X,Y,ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
54 K ^TMP("PSDERCP",$J)
55 D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
56 Q
57HDR ;prints header information
58 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
59 S PG=PG+1 W:$Y @IOF W !,?15,"CS RESOLVED ERROR/ADJ LOG REPORT",?70,"PAGE: ",PG
60 W !,?15,"NAOU: ",PSDSN,!,?15,"Period From: ",$P(PSDATE,"^")," to: ",$P(PSDATE,"^",2),!,?15,"Run Date: ",RPDT
61 W !!,"LOG #",?10,"QUANTITY",?22,"DATE",?35,"ERR/ADJ TYPE",!,?5,"LOGGED BY",?45,"RESOLVED BY",!,LN,!
62 Q
63SAVE ;saves variables for queueing
64 S (ZTSAVE("PSDSD"),ZTSAVE("PSDED"),ZTSAVE("PSDATE"),ZTSAVE("PSDS"),ZTSAVE("PSDSN"))=""
65 Q
Note: See TracBrowser for help on using the repository browser.