PSOCST3 ;BHAM ISC/SAB - DRUG BY PROVIDER COST ; 10/01/92 16:30
;;7.0;OUTPATIENT PHARMACY;**31**;DEC 1997
;External Ref. to ^PSDRUG is supp. by DBIA# 221
BEG S RP=3 D HDC^PSOCSTX F D CDT^PSOCSTX Q:$G(CTR) D DRS^PSOCSTX Q:$G(CTR) S RP=0 D CTP^PSOCSTX Q:$G(CTR) I RP=0 D DEV Q
D EX Q
DEV D DVC^PSOCSTX Q:$G(CTR)
K PSOION I $D(IO("Q")) S ZTDESC="DRUG COSTS BY PROVIDER",ZTRTN="START^PSOCST3" D PAS^PSOCSTX
I K IO("Q") D ^%ZTLOAD W:$D(ZTSK) !,"REPORT QUEUED TO PRINT !!",! D EX Q
START U IO K ^TMP($J) F PSDT=(BEGDATE-1):0:ENDDATE S PSDT=$O(^PSCST(PSDT)) Q:'PSDT!(PSDT>ENDDATE) D @$S('IFN:"DRUG",1:"PHY")
D ZER^PSOCSTX S DRUGX="" D HD I $O(^TMP($J,DRUGX))']"" D HDN^PSOCSTX Q
F S DRUGX=$O(^TMP($J,DRUGX)) Q:DRUGX="" D:($Y+7)>IOSL HD Q:$G(CTR) W !,?5,"DRUG: "_DRUGX D
.S PHYX="" D:($Y+4)>IOSL HD Q:$G(CTR) F S PHYX=$O(^TMP($J,DRUGX,PHYX)) D:PHYX="" SUB Q:PHYX="" D PRT3
I 'IFN,'CTR D TOT^PSOCSTX
EX D EX^PSOCSTX Q
PRT3 D HD:($Y+4)>IOSL Q:$G(CTR)
S Y=^TMP($J,DRUGX,PHYX),TTX=PHYX D PRT^PSOCSTX Q
DRUG F DRUG=0:0 S DRUG=$O(^PSCST(PSDT,"D",DRUG)) Q:'DRUG D PHY
Q
PHY F PHY=0:0 S PHY=$O(^PSCST(PSDT,"D",DRUG,"P",PHY)) Q:'PHY I $D(^(PHY,0)) S X=^(0) D STORE
Q
STORE S PHYX=$S($D(^VA(200,+PHY,0)):$P(^(0),"^"),1:"UNKNOWN")
Q:'$D(^PSDRUG(DRUG,0)) S DRUGX=$P(^(0),"^") S:'$D(^TMP($J,DRUGX,PHYX)) ^TMP($J,DRUGX,PHYX)="^0^0^0"
S UTL=^TMP($J,DRUGX,PHYX),^TMP($J,DRUGX,PHYX)="^"_($P(UTL,"^",2)+$P(X,"^",2))_"^"_($P(UTL,"^",3)+$P(X,"^",3))_"^"_($P(UTL,"^",4)+$P(X,"^",4))
Q
HD D HD^PSOCSTX Q
SUB D HD:($Y+2)>IOSL D FTU^PSOCSTX W !,"Total for ",$E(DRUGX,1,23) D FTT^PSOCSTX,FTU^PSOCSTX,SUB^PSOCSTX
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSOCST3 1638 printed Nov 22, 2024@17:36:12 Page 2
PSOCST3 ;BHAM ISC/SAB - DRUG BY PROVIDER COST ; 10/01/92 16:30
+1 ;;7.0;OUTPATIENT PHARMACY;**31**;DEC 1997
+2 ;External Ref. to ^PSDRUG is supp. by DBIA# 221
BEG SET RP=3
DO HDC^PSOCSTX
FOR
DO CDT^PSOCSTX
if $GET(CTR)
QUIT
DO DRS^PSOCSTX
if $GET(CTR)
QUIT
SET RP=0
DO CTP^PSOCSTX
if $GET(CTR)
QUIT
IF RP=0
DO DEV
QUIT
+1 DO EX
QUIT
DEV DO DVC^PSOCSTX
if $GET(CTR)
QUIT
+1 KILL PSOION
IF $DATA(IO("Q"))
SET ZTDESC="DRUG COSTS BY PROVIDER"
SET ZTRTN="START^PSOCST3"
DO PAS^PSOCSTX
+2 IF $TEST
KILL IO("Q")
DO ^%ZTLOAD
if $DATA(ZTSK)
WRITE !,"REPORT QUEUED TO PRINT !!",!
DO EX
QUIT
START USE IO
KILL ^TMP($JOB)
FOR PSDT=(BEGDATE-1):0:ENDDATE
SET PSDT=$ORDER(^PSCST(PSDT))
if 'PSDT!(PSDT>ENDDATE)
QUIT
DO @$SELECT('IFN:"DRUG",1:"PHY")
+1 DO ZER^PSOCSTX
SET DRUGX=""
DO HD
IF $ORDER(^TMP($JOB,DRUGX))']""
DO HDN^PSOCSTX
QUIT
+2 FOR
SET DRUGX=$ORDER(^TMP($JOB,DRUGX))
if DRUGX=""
QUIT
if ($Y+7)>IOSL
DO HD
if $GET(CTR)
QUIT
WRITE !,?5,"DRUG: "_DRUGX
Begin DoDot:1
+3 SET PHYX=""
if ($Y+4)>IOSL
DO HD
if $GET(CTR)
QUIT
FOR
SET PHYX=$ORDER(^TMP($JOB,DRUGX,PHYX))
if PHYX=""
DO SUB
if PHYX=""
QUIT
DO PRT3
End DoDot:1
+4 IF 'IFN
IF 'CTR
DO TOT^PSOCSTX
EX DO EX^PSOCSTX
QUIT
PRT3 if ($Y+4)>IOSL
DO HD
if $GET(CTR)
QUIT
+1 SET Y=^TMP($JOB,DRUGX,PHYX)
SET TTX=PHYX
DO PRT^PSOCSTX
QUIT
DRUG FOR DRUG=0:0
SET DRUG=$ORDER(^PSCST(PSDT,"D",DRUG))
if 'DRUG
QUIT
DO PHY
+1 QUIT
PHY FOR PHY=0:0
SET PHY=$ORDER(^PSCST(PSDT,"D",DRUG,"P",PHY))
if 'PHY
QUIT
IF $DATA(^(PHY,0))
SET X=^(0)
DO STORE
+1 QUIT
STORE SET PHYX=$SELECT($DATA(^VA(200,+PHY,0)):$PIECE(^(0),"^"),1:"UNKNOWN")
+1 if '$DATA(^PSDRUG(DRUG,0))
QUIT
SET DRUGX=$PIECE(^(0),"^")
if '$DATA(^TMP($JOB,DRUGX,PHYX))
SET ^TMP($JOB,DRUGX,PHYX)="^0^0^0"
+2 SET UTL=^TMP($JOB,DRUGX,PHYX)
SET ^TMP($JOB,DRUGX,PHYX)="^"_($PIECE(UTL,"^",2)+$PIECE(X,"^",2))_"^"_($PIECE(UTL,"^",3)+$PIECE(X,"^",3))_"^"_($PIECE(UTL,"^",4)+$PIECE(X,"^",4))
+3 QUIT
HD DO HD^PSOCSTX
QUIT
SUB if ($Y+2)>IOSL
DO HD
DO FTU^PSOCSTX
WRITE !,"Total for ",$EXTRACT(DRUGX,1,23)
DO FTT^PSOCSTX
DO FTU^PSOCSTX
DO SUB^PSOCSTX
+1 QUIT