source: FOIAVistA/trunk/r/OUTPATIENT_PHARMACY-PSO-APSP-HUIP/PSOCST12.m@ 794

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

initial load of FOIAVistA 6/30/08 version

File size: 3.1 KB
Line 
1PSOCST12 ;BHAM ISC/SAB - DIVISION BY DRUG COST ; 08/19/92 8:37
2 ;;7.0;OUTPATIENT PHARMACY;**31**;DEC 1997
3 ;External Ref. to ^PS(59, is supp. by DBIA# 212
4 ;External Ref. to ^PSDRUG( is supp. by DBIA# 221
5BEG S RP=12 D HDC^PSOCSTX F D CDT^PSOCSTX Q:$G(CTR) D DVS^PSOCSTX Q:$G(CTR) S RP=0 D CTP^PSOCSTX Q:$G(CTR) I RP=0 D DEV Q
6 D EX Q
7DEV D DVC^PSOCSTX Q:$G(CTR)
8 K PSOION I $D(IO("Q")) S ZTDESC="DRUG COSTS BY DIVISION BY DRUG",ZTRTN="START^PSOCST12" D PAS^PSOCSTX
9 I K IO("Q") D ^%ZTLOAD W:$D(ZTSK) !,"REPORT QUEUED TO PRINT !!",! D EX Q
10START U IO K ^TMP($J) F PSDT=(BEGDATE-1):0:ENDDATE S PSDT=$O(^PSCST(PSDT)) Q:'PSDT!(PSDT>ENDDATE) D @$S('IFN:"DIV",1:"DRUG")
11 S DIVX="" F S DIVX=$O(^TMP($J,DIVX)) Q:DIVX="" S DRUGX="" F S DRUGX=$O(^TMP($J,DIVX,DRUGX)) Q:DRUGX="" D STR
12 S (QTY,CNT,CNTO,CNTR,COST)=0,DIVX="" I $O(^TMP($J,DIVX))']"" D HD,HDN^PSOCSTX Q
13 F S DIVX=$O(^TMP($J,DIVX)) Q:DIVX=""!($G(CTR)) S DRUGX="" D HD Q:$G(CTR) F S DRUGX=$O(^TMP($J,DIVX,DRUGX)) D:DRUGX="" SUB Q:DRUGX="" D PRT3 Q:$G(CTR)
14 I 'CTR,'IFN D HD:($Y+4)>IOSL W !! D PUL W !,"Total for all divisions ",?50,$J(CNTO,6),?57,$J(CNTR,6),?66,$J(CNT,6),?77,$J(QTY,8,2),?88,$J(COST,10,2),?104 S AVG=$S('CNT:0,1:(COST/CNT)) W $J(AVG,10,2) D PUL W !
15EX D EX^PSOCSTX K QTY Q
16HD D HD0^PSOCSTX Q:$G(CTR)
17 W !,?50,"Orgin",?68,"Total",?77,"Total",?90,"Total",?105,"Avg Cost",!,"Drug",?50,"Fills",?57,"Refills",?68,"Fills",?77,"Qty",?90,"Cost",?105,"per Fill"
18 W ! F I=1:1:130 W "-"
19 W:DIVX]"" !,?5,"Division: ",DIVX
20 Q
21PUL W !,?50,"------",?57,"------",?66,"------",?77,"--------",?88,"----------",?104,"----------"
22 Q
23PRT3 D HD:($Y+4)>IOSL Q:$G(CTR) S Y=^TMP($J,DIVX,DRUGX),FILLS=($P(Y,"^",2)+$P(Y,"^",3)),CNT=CNT+FILLS,CNTO=CNTO+$P(Y,"^",2),CNTR=CNTR+$P(Y,"^",3),COST=COST+$P(Y,"^",4),QTY=QTY+$P(Y,"^",5)
24 W !,DRUGX,?50,$J($P(Y,"^",2),6),?57,$J($P(Y,"^",3),6),?66,$J(FILLS,6),?77,$J($P(Y,"^",5),8,2),?88,$J($P(Y,"^",4),10,2),?104 S AVG=$S('FILLS:0,1:($P(Y,"^",4)/FILLS)) W $J(AVG,10,2)
25 Q
26DIV F DIV=0:0 S DIV=$O(^PSCST(PSDT,"V",DIV)) Q:'DIV D DRUG
27 Q
28DRUG F DRUG=0:0 S DRUG=$O(^PSCST(PSDT,"V",DIV,"D",DRUG)) Q:'DRUG I $D(^(DRUG,0)) S X=^(0) D STORE
29 Q
30STORE S DIVX=$S($D(^PS(59,+DIV,0)):$P(^(0),"^"),1:"UNKNOWN")
31 Q:'$D(^PSDRUG(DRUG,0)) S DRUGX=$P(^(0),"^") S:'$D(^TMP($J,DIVX,DRUGX)) ^TMP($J,DIVX,DRUGX)="^0^0^0^0",^TMP($J,DIVX)="^0^0^0^0^0"
32 S UTL=^TMP($J,DIVX,DRUGX),^TMP($J,DIVX,DRUGX)="^"_($P(UTL,"^",2)+$P(X,"^",2))_"^"_($P(UTL,"^",3)+$P(X,"^",3))_"^"_($P(UTL,"^",4)+$P(X,"^",4))_"^"_($P(UTL,"^",5)+$P(X,"^",5))
33 Q
34STR S $P(^TMP($J,DIVX),"^",2)=($P(^TMP($J,DIVX),"^",2)+$P(^TMP($J,DIVX,DRUGX),"^",2)),$P(^TMP($J,DIVX),"^",3)=($P(^TMP($J,DIVX),"^",3)+$P(^TMP($J,DIVX,DRUGX),"^",3))
35 S $P(^TMP($J,DIVX),"^",4)=($P(^TMP($J,DIVX),"^",4)+$P(^TMP($J,DIVX,DRUGX),"^",4)),$P(^TMP($J,DIVX),"^",5)=($P(^TMP($J,DIVX),"^",5)+$P(^TMP($J,DIVX,DRUGX),"^",2)+$P(^TMP($J,DIVX,DRUGX),"^",3))
36 S $P(^TMP($J,DIVX),"^",6)=($P(^TMP($J,DIVX),"^",6)+$P(^TMP($J,DIVX,DRUGX),"^",5))
37 Q
38SUB ;sub-totals per division
39 D PUL
40 W !,"Total for "_DIVX,?50,$J($P(^TMP($J,DIVX),"^",2),6),?57,$J($P(^(DIVX),"^",3),6),?66,$J($P(^(DIVX),"^",5),6),?77,$J($P(^(DIVX),"^",6),8,2),?88,$J($P(^(DIVX),"^",4),10,2),?104,$J($P(^(DIVX),"^",4)/$P(^(DIVX),"^",5),10,2)
41 D PUL Q
Note: See TracBrowser for help on using the repository browser.