source: WorldVistAEHR/trunk/r/CONTROLLED_SUBSTANCES-PSD/PSDCOSN.m@ 1154

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

initial load of WorldVistAEHR

File size: 4.8 KB
Line 
1PSDCOSN ;BIR/LTL-Cost Report by NAOUs, PSDCOST (cont'd) ; 2 Aug 94
2 ;;3.0; CONTROLLED SUBSTANCES ;**63**;13 Feb 97;Build 1
3 N PSDN,LN,PG,X2 S PSDSD(1)=PSDSD S:$D(ZTQUEUED) ZTREQ="@"
4 F S PSDSD=$O(^PSD(58.81,"ACT",PSDSD)) W:$E(IOST)="C" "." Q:'PSDSD!(PSDSD>PSDED) S PSDN=$O(^PSD(58.81,"ACT",PSDSD,0)) D:$P($G(^PSD(58.8,+PSDN,0)),U,3)=+PSDSITE
5 .S PSDN(1)=$O(^PSD(58.81,"ACT",PSDSD,PSDN,0))
6 .S PSDN(2)=$O(^PSD(58.81,"ACT",PSDSD,PSDN,PSDN(1),0))
7 .Q:PSDN(2)<2!(PSDN(2)>5)&(PSDN(2)'=9)
8 .S PSDN(3)=$P($G(^PSDRUG(+PSDN(1),0)),U)
9 .S PSDN(4)=$O(^PSD(58.81,"ACT",PSDSD,PSDN,PSDN(1),PSDN(2),0))
10 .S PSDN(8)=$G(^PSD(58.81,+PSDN(4),0))
11 .Q:'$D(LOC(+$P(PSDN(8),U,18)))&(PSDN(2)'=9)!('$D(LOC(+PSDN))&(PSDN(2)=9))
12 .;get NAOU for everything including adjustments
13 .S PSDN(9)=$S(PSDN(2)=9:PSDN,1:$P(PSDN(8),U,18))
14 .;qty rec'd by NAOU w/green sheet
15 .S PSDN(5)=$P($G(^PSD(58.81,+PSDN(4),1)),U,8)
16 .S PSDN(11)=$P($G(^PSDRUG(PSDN(1),660)),U,6)
17 .I $D(PSDN) I 'PSDN(11) D GETDTA
18 .;qty dispensed by Master Vault w/o green sheet
19 .S:$P(PSDN(8),U,17)']"" PSDN(5)=$P(PSDN(8),U,6)
20 .;Returned to Stock
21 .S:PSDN(2)=3 PSDN(5)=-$P($G(^PSD(58.81,+PSDN(4),3)),U,2)
22 .;Destroyed
23 .S:PSDN(2)=4 PSDN(5)=-$P($G(^PSD(58.81,+PSDN(4),3)),U,5)
24 .;include transfer ins with dispensed
25 .S:PSDN(2)=5 PSDN(2)=2
26 .;Check for transfers
27 .S PSDN(6)=$G(^PSD(58.81,+PSDN(4),7))
28 .D:$P(PSDN(6),U)>PSDSD(1)&($P(PSDN(6),U)<PSDED)
29 ..S PSDN(5)=PSDN(5)-$P(PSDN(6),U,7),PSDN(2)=5
30 .S PSDN(7)=$G(^TMP("PSD",$J,PSDN(9),PSDN(3)))
31 .;total dispensed
32 .S $P(^TMP("PSD",$J,PSDN(9),PSDN(3)),U)=$P(PSDN(7),U)+PSDN(5)
33 .;DA for drug
34 .S:'$P(PSDN(7),U,2) $P(^TMP("PSD",$J,PSDN(9),PSDN(3)),U,2)=PSDN(1)
35 .;total returned to stock
36 .S:PSDN(2)=3 $P(^TMP("PSD",$J,PSDN(9),PSDN(3)),U,3)=PSDN(5)+$P(PSDN(7),U,3)
37 .;total destroyed
38 .S:PSDN(2)=4 $P(^TMP("PSD",$J,PSDN(9),PSDN(3)),U,4)=PSDN(5)+$P(PSDN(7),U,4)
39 .;total transferred
40 .S:PSDN(2)=5 $P(^TMP("PSD",$J,PSDN(9),PSDN(3)),U,5)=-$P(PSDN(6),U,7)+$P(PSDN(7),U,5)
41 .;total adjusted by NAOU
42 .S:PSDN(2)=9 $P(^TMP("PSD",$J,PSDN(9),PSDN(3)),U,6)=PSDN(5)+$P(PSDN(7),U,6)
43 .K PSDN
44 ;
45PRTQUE ;queues print after data is compiled
46 I $D(ZTQUEUED) K ZTSAVE,ZTSK S ZTIO=PSDIO,ZTDESC="CS Cost Report by NAOU",ZTRTN="START^PSDCOSN",ZTSAVE("PSD*")="",ZTSAVE("^TMP(""PSD"",$J,")="",ZTSAVE("SUM")="",ZTDTH=$H D ^%ZTLOAD,HOME^%ZIS G QUIT
47START S (PG,PSDN)=0 D HEADER
48 F S PSDN=$O(^TMP("PSD",$J,PSDN)) Q:'PSDN D:$Y+6>IOSL HEADER G:$G(PSDOUT) END S PSDN(8)=$G(PSDN(8))+1 K PG(PSDN) D G:$G(PSDOUT) END
49 .W ?8,"NAOU ==> ",$P($G(^PSD(58.8,+PSDN,0)),U),!! S PSDN(1)=0
50 .F S PSDN(1)=$O(^TMP("PSD",$J,PSDN,PSDN(1))) Q:PSDN(1)']"" D:$Y+6>IOSL HEADER Q:$G(PSDOUT) S PSDN(9)=$G(PSDN(9))+1 D
51 ..I $D(PG(PSDN)) W ?8,"NAOU ==> ",$P($G(^PSD(58.8,+PSDN,0)),U)," (continued)",!! K PG(PSDN)
52 ..W:'$G(SUM) $E(PSDN(1),1,34),?36
53 ..S PSDN(2)=$G(^TMP("PSD",$J,PSDN,PSDN(1))),PSDN(3)=$G(PSDN(3))+PSDN(2)
54 ..W:'$G(SUM) $J($P(PSDN(2),U),10),?62
55 ..S PSDN(11)=$P($G(^PSDRUG(+$P(PSDN(2),U,2),660)),U,6)
56 ..S (X,PSDN(4))=$P(PSDN(2),U)*PSDN(11),X2="2$",PSDN(5)=$G(PSDN(5))+PSDN(4) D COMMA^%DTC W:'$G(SUM) X,!!
57 ..S PSDN(10)=" (Subtracted from total)"
58 ..W:'$G(SUM)&($P(PSDN(2),U,3)) "Doses Returned to Stock: ",$P(PSDN(2),U,3),PSDN(10),!!
59 ..W:'$G(SUM)&($P(PSDN(2),U,4)) "Doses Destroyed: ",$P(PSDN(2),U,4),PSDN(10),!!
60 ..W:'$G(SUM)&($P(PSDN(2),U,5)) "Doses Transferred: ",$P(PSDN(2),U,5),PSDN(10),!!
61 ..W:'$G(SUM)&($P(PSDN(2),U,6)) "Doses Adjusted by NAOU: ",$P(PSDN(2),U,6)," (Not affecting total)",!!
62 ..;S:'PSDN(11) ^TMP("PSDM",$J,PSDN(1))=""
63 .Q:$G(PSDOUT) W LN,!?28,"Total: ",$J($G(PSDN(3)),10),?62
64 .S X=$G(PSDN(5)) D COMMA^%DTC W X,!! S PSDN(6)=$G(PSDN(6))+PSDN(3)
65 .S PSDN(7)=$G(PSDN(7))+PSDN(5) K PSDN(3),PSDN(5),PSDN(9)
66 I $G(PSDN(8))>1 W LN,!?14,"Total for all NAOUs: ",$J($G(PSDN(6)),10) S X=$G(PSDN(7)) D COMMA^%DTC W ?62,X,!!
67 ;I DUZ=33238 I $D(^TMP("PSDM")) D ^PSDCOSM
68 I $D(^TMP("PSDM",$J)) S ZTRTN="^PSDCOSM",ZTIO="",ZTDTH=$H,ZTDESC="Mailman notification of 0 DRUG file cost",ZTSAVE("PSD*")="",ZTSAVE("^TMP(""PSDM"",$J,")="" D ^%ZTLOAD
69 W:'$O(^TMP("PSD",$J,0)) !!,"Sorry, nothing to report for selected NAOU(s).",!!
70END W:$E(IOST)'="C" @IOF
71 I $E(IOST)="C",'$G(PSDOUT) W !! S DIR(0)="EA",DIR("A")="END OF REPORT! Press <RET> to return to the menu." D ^DIR
72 D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
73QUIT K ^TMP("PSD",$J),^TMP("PSDM",$J),IO("Q") Q
74HEADER ;prints header info
75 I $E(IOST,1,2)'="P-",PG S DIR(0)="E" D ^DIR K DIR I 'Y S PSDOUT=1 Q
76 I $$S^%ZTLOAD W !!,"Task #",$G(ZTSK),", ",$G(ZTDESC)," was stopped by ",$P($G(^VA(200,+$G(DUZ),0)),U),"." S PSDOUT=1
77 W:$Y @IOF S $P(LN,"-",80)="",PG=PG+1,PG(PSDN)="" W !?2,PSDCHO(1)," From "
78 W $P(PSDATE,U)," To ",$P(PSDATE,U,2),?72,"Page ",PG,!!
79 W ?45,"Report Date: ",PSDT(1),!!?40,"Quantity",!,"Drug",?40,"Dispensed"
80 W ?70,"Cost",!,LN,!!
81 Q
82GETDTA ;
83 N DTE
84 Q:'$D(PSDN)
85 S DTE=$P(PSDN(8),U,4)
86 S ^TMP("PSDM",$J,PSDN(1),DTE)=PSDN(4)_"^"_PSDN(11)_"^"_PSDN(5)
87 Q
88 ;
Note: See TracBrowser for help on using the repository browser.