source: FOIAVistA/trunk/r/OUTPATIENT_PHARMACY-PSO-APSP-HUIP/PSOCSTD.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: 6.3 KB
Line 
1PSOCSTD ;BHAM ISC/SAB - daily rx cost compilation ;9/14/05 1:13pm
2 ;;7.0;OUTPATIENT PHARMACY;**4,17,28,89,198,212**;DEC 1997
3 ;External Ref to ^DPT DBIA# 10035
4 ;External Ref to ^PS(55 DBIA# 2228
5 ;External Ref to ^PSDRUG DBIA# 221
6 ;
7 ;PSO*198 correct For loops to begin on the previous day @ time 999999
8 ;PSO*212 quit if it is the 1st day & monthly compile is running
9 ;
10 I $E(DT,6,7)="01",$$MTHLCK^PSOCSTM(0) Q ;PSO*212
11 K BEGDATE,ENDDATE S %DT(0)=$E(DT,1,5)_"00"
12 W !!,"**** Date Range Selection ****" I '$O(^PS(59,0)) W $C(7),!,"PLEASE ENTER SITE PARAMETERS !!",!,$C(7) G EX
13BEG W ! S %DT="APE",%DT("A")=" Beginning DATE : " D ^%DT G:"^"[X EX G:Y<0 BEG S (%DT(0),BEGDATE)=Y
14EN W ! S %DT="APE",%DT("A")=" Ending DATE : " D ^%DT K %DT G:"^"[X EX G:Y<0 EN W ! S ENDDATE=Y
15 S ZTIO="",ZTRTN="START^PSOCSTD",ZTDESC="Rx Daily Cost Compile" F G="BEGDATE","ENDDATE" S:$D(@G) ZTSAVE(G)=""
16 D ^%ZTLOAD W:$D(ZTSK) !,"Task #"_ZTSK_" Queued !" K G,BEGDATE,ENDDATE,ZTSAVE,ZTIO,ZTSK,ZTRTN,ZTDESC Q
17START K ^TMP($J) G:$E(DT,6,7)="01" MTH
18 I '$D(BEGDATE)!('$D(ENDDATE)) S X1=DT,X2=-1 D C^%DTC S (BEGDATE,ENDDATE)=X
19 K BDT S PSG=0 F I=1:1 S X=$T(G+I) Q:$P(X,";",3)="" S PSOA(I)=$P(X,";",3),PSOB(I)=$P(X,";",4),PSG=PSG+1,PSOA1(I)=$P(X,";",5),PSOB1(I)=$P(X,";",6)
20 S PSD=0 F I=1:1 S X=$T(D+I) Q:X="" S PSOC(I)=$P(X,";",3),PSOD(I)=$P(X,";",4),PSD=PSD+1,PSOC1(I)=$P(X,";",5),PSOD1(I)=$P(X,";",6)
21 F PSDT=BEGDATE:1:ENDDATE K ^PSCST(PSDT),^PSCST("B",PSDT)
22 S (TNR,TNO,TNP)=0
23 ;PSO*198 fix begin value of $O loops
24SRCH S PSDT=BEGDATE-1+.999999 F S PSDT=$O(^PSRX("AL",PSDT)) Q:'PSDT!($E(PSDT,1,7)>ENDDATE) S (OR,RF)=0 D SRCH1 S:'$D(BDT) BDT=PSDT
25 S PSDT=BEGDATE-1+.999999 F S PSDT=$O(^PSRX("AM",PSDT)) Q:'PSDT!($E(PSDT,1,7)>ENDDATE) D SRCH2 S:'$D(BDT) BDT=PSDT
26 S PSOCNT=0 F PSDT=0:0 S PSDT=$O(^PSCST("B",PSDT)) Q:'PSDT S PSD=PSDT,PSOCNT=PSOCNT+1
27 S ^PSCST(0)="DRUG COST^50.9D^"_PSD_"^"_PSOCNT,EDT=ENDDATE
28 F PSDT=BEGDATE:1:ENDDATE F II=2:1:7 S:$D(^PSCST(PSDT,0)) $P(^PSCST(PSDT,0),"^",II)=0
29 S PSDT=BEGDATE-1 F S PSDT=$O(^PSCST(PSDT)) Q:'PSDT!(PSDT>ENDDATE) D
30 .S DRG=0 F S DRG=$O(^PSCST(PSDT,"D",DRG)) Q:'DRG S DRC=^PSCST(PSDT,"D",DRG,0) D
31 ..F II=2:1:7 S $P(^PSCST(PSDT,0),"^",II)=$P(^PSCST(PSDT,0),"^",II)+$P(DRC,"^",II)
32 S PSDT=0 F S PSDT=$O(^TMP($J,"PAT",PSDT)) Q:'PSDT D SDFN
33 D:$D(BDT) ZNODE^PSOCSTM
34EX K ^TMP($J),FL,%DT,A,B,BEGDATE,COST,DATA,DATA1,DATA2,DRUG,DFN,ENDDATE,I,II,ML,OR,PAST,PHYS,PSOCNT,DIV,PSD,PSDT,PSFILL,PSG,QTY,RF,RX0
35 K RXF,PAR,NDZ1,NDZ2,BDT,D,CLINIC,RX1,RX2,RXN,C,VALUE,VISITS,WD,X,X1,X2,Y,BDT,EDT,PSOA1,PSOB1,PSOC1,PSOD1,PSOC
36 K TDFN,TDIV S:$D(ZTQUEUED) ZTREQ="@"
37 L -^PSOCSTM ;PSO*212
38 Q
39SDFN S (TDFN,DIV)=0 F S DIV=$O(^TMP($J,"PAT",PSDT,DIV)) Q:'DIV D SDFN1
40 S ^PSCST(PSDT,1)=DT_"^"_TDFN Q
41SDFN1 S (DFN,TDIV)=0 F S DFN=$O(^TMP($J,"PAT",PSDT,DIV,DFN)) Q:'DFN S TDIV=TDIV+1,TDFN=TDFN+1
42 S $P(^PSCST(PSDT,"V",DIV,0),"^",8)=TDIV Q
43SRCH1 S RXF="" F RXN=0:0 S RXN=$O(^PSRX("AL",PSDT,RXN)) Q:'RXN F S RXF=$O(^PSRX("AL",PSDT,RXN,RXF)) Q:RXF="" S PAR=0 D CHK S (OR,RF)=0
44 Q
45SRCH2 S (RXN,RXF)=0 F S RXN=$O(^PSRX("AM",PSDT,RXN)) Q:'RXN F S RXF=$O(^PSRX("AM",PSDT,RXN,RXF)) Q:'RXF S PAR=1 D CHK S (OR,RF)=0
46 Q
47CHK Q:'$D(^PSRX(RXN,0)) I '$D(^PSRX(RXN,2)) Q
48 S RX0=^PSRX(RXN,0) S RX2=^PSRX(RXN,2)
49 S DFN=+$P(RX0,"^",2) Q:'$D(^DPT(DFN,0)) D:$P($G(^PS(55,DFN,0)),"^",6)'=2 EN^PSOHLUP(DFN)
50 S DRUG=+$P(RX0,"^",6) Q:'$D(^PSDRUG(DRUG,0))
51 ;S CLASS=+$P(^(0),"^",2) Q:'$D(^PS(50.605,CLASS,0))
52 S DIV=+$P(RX2,"^",9) Q:'$D(^PS(59,DIV,0))
53 S PHYS=+$P(RX0,"^",4) Q:'$D(^VA(200,PHYS,0)) S PAST=+$P(RX0,"^",3) Q:'$D(^PS(53,PAST,0))
54 S CLINIC=+$P(RX0,"^",5) K:'$D(^SC(CLINIC,0)) CLINIC
55 S COST=$S(+$P(RX0,"^",17):+$P(RX0,"^",17),$D(^PSDRUG(DRUG,660)):+$P(^(660),"^",6),1:0)
56 S QTY=+$P(RX0,"^",7),ML=$S($P(RX0,"^",11)="M":1,1:0),WD=$S($P(RX0,"^",11)="W":1,1:0)
57 I $G(PAR) D S PR=0 Q
58 .I '$D(^PSRX(RXN,"P",RXF,0)) K ^PSRX("AM",PSDT,RXN,RXF) Q
59 .I $P(^PSRX(RXN,"P",RXF,0),"^",19) S RF=0,RX1=^PSRX(RXN,"P",RXF,0),DIV=$S($P(RX1,"^",9):$P(RX1,"^",9),1:$P(RX2,"^",9)) D SET,REF S TNP=TNP+1
60 I $P(RX2,"^",13),'RXF S OR=OR+1,COST=QTY*COST D SET,SF S TNO=TNO+1 Q
61 D:RXF
62 .I '$D(^PSRX(RXN,1,RXF,0)) K ^PSRX("AL",PSDT,RXN,RXF) Q
63 .I $P(^PSRX(RXN,1,RXF,0),"^",18) S RF=0,RX1=^PSRX(RXN,1,RXF,0),DIV=$S($P(RX1,"^",9):$P(RX1,"^",9),1:$P(RX2,"^",9)) D SET,REF S TNR=TNR+1
64 Q
65SF S DATA="^"_OR_"^"_RF_"^"_COST_"^"_QTY_"^"_ML_"^"_WD
66 S:'$D(^TMP($J,"PAT",$P(PSDT,"."),DIV,DFN)) ^TMP($J,"PAT",$P(PSDT,"."),DIV,DFN)=""
67 F I=1:1:PSG Q:('$D(CLINIC))&(I=PSG) S DATA1=$S(($D(@(PSOA(I)))#2):^(0),1:@(PSOB(I))_"^0^0^0^0") S DATA2=+$P(DATA1,"^") D
68 .F II=2:1:7 S VALUE=$P(DATA,"^",II)+$P(DATA1,"^",II),DATA2=DATA2_"^"_VALUE S:II=7 @PSOA(I)=DATA2
69 .S:'$D(@PSOA1(I)) @PSOA1(I)=PSOB1(I) S $P(@PSOA1(I),"^",4)=+$P(@PSOA1(I),"^",4)+1,$P(@PSOA1(I),"^",3)=@PSOB(I)
70 F I=1:1:PSD S DATA1=$S(($D(@(PSOC(I)))#2):$G(^(0)),1:@(PSOD(I))_"^0^0^0^0") S DATA2=+$P(DATA1,"^") D
71 .F II=2:1:7 S VALUE=$P(DATA,"^",II)+$P(DATA1,"^",II),DATA2=DATA2_"^"_VALUE S:II=7 @PSOC(I)=DATA2 D
72 .S:'$D(@PSOC1(I)) @PSOC1(I)=PSOD1(I) S $P(@PSOC1(I),"^",4)=+$P(@PSOC1(I),"^",4)+1,$P(@PSOC1(I),"^",3)=@PSOD(I)
73 Q
74SET S ^PSCST($P(PSDT,"."),0)=$P(PSDT,"."),^PSCST("B",$P(PSDT,"."),$P(PSDT,"."))="" Q
75 ;
76MTH S X1=DT,X2=-1 D C^%DTC S (BDT,EDT)=$E(X,1,5)_"00"
77 F PSDT=(BDT+1):1:X K ^PSCST(PSDT),^PSCST("B",PSDT)
78 D START^PSOCSTM G EX
79 Q
80REF S OR=0,COST=$S(+$P(RX1,"^",11):+$P(RX1,"^",11),$D(^PSDRUG(DRUG,660)):+$P(^(660),"^",6),1:0)
81 S RF=RF+1,QTY=+$P(RX1,"^",4),ML=$S($P(RX1,"^",2)="M":1,1:0),WD=$S($P(RX1,"^",2)="W":1,1:0) S COST=QTY*COST
82 S PHYS=$S($P(RX1,"^",17):$P(RX1,"^",17),1:$P(RX0,"^",4)) D SF
83 Q
84 ;
85G ;;
86 ;;^PSCST($P(PSDT,"."),0);PSDT;^TMP($J,"A1");1
87 ;;^PSCST($P(PSDT,"."),"P",PHYS,0);PHYS;^PSCST($P(PSDT,"."),"P",0);^50.9001PA^^
88 ;;^PSCST($P(PSDT,"."),"P",PHYS,"D",DRUG,0);DRUG;^PSCST($P(PSDT,"."),"P",PHYS,"D",0);^50.9002PA^^
89 ;;^PSCST($P(PSDT,"."),"D",DRUG,0);DRUG;^PSCST($P(PSDT,"."),"D",0);^50.9003PA^^
90 ;;^PSCST($P(PSDT,"."),"D",DRUG,"P",PHYS,0);PHYS;^PSCST($P(PSDT,"."),"D",DRUG,"P",0);^50.9004PA^^
91 ;;^PSCST($P(PSDT,"."),"PS",PAST,0);PAST;^PSCST($P(PSDT,"."),"PS",0);^50.9005PA^^
92 ;;^PSCST($P(PSDT,"."),"S",CLINIC,0);CLINIC;^PSCST($P(PSDT,"."),"S",0);^50.9008PA^^
93 ;;
94D ;;
95 ;;^PSCST($P(PSDT,"."),"V",DIV,0);DIV;^PSCST($P(PSDT,"."),"V",0);^50.9006PA^^
96 ;;^PSCST($P(PSDT,"."),"V",DIV,"D",DRUG,0);DRUG;^PSCST($P(PSDT,"."),"V",DIV,"D",0);^50.9007PA^^
97 ;;^PSCST($P(PSDT,"."),"V",DIV,"P",PHYS,0);PHYS;^PSCST($P(PSDT,"."),"V",DIV,"P",0);^50.901PA^^
Note: See TracBrowser for help on using the repository browser.