PSOCST8 ;BHAM ISC/SAB - DRUG COSTS BY DIVISION ; 08/19/92 9:03
;;7.0;OUTPATIENT PHARMACY;**31**;DEC 1997
;External Ref. to ^PS(59, is supp. by DBIA# 212
BEG S RP=8 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
D EX Q
DEV D DVC^PSOCSTX Q:$G(CTR)
K PSOION I $D(IO("Q")) S ZTDESC="DRUG COST BY DIVISION",ZTRTN="START^PSOCST8" 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:"PAT",1:"DIV")
D ZER^PSOCSTX S DIVX="" D HD I $O(^TMP($J,DIVX))']"" D HDN^PSOCSTX Q
F I=0:0 S DIVX=$O(^TMP($J,DIVX)) Q:DIVX="" D HD:($Y+4)>IOSL Q:$G(CTR) S Y=^TMP($J,DIVX),TTX=DIVX D PRT^PSOCSTX
I 'CTR,'IFN D HD:($Y+2)>IOSL D FTX^PSOCSTX
EX D EX^PSOCSTX Q
PAT F DIV=0:0 S DIV=$O(^PSCST(PSDT,"V",DIV)) Q:'DIV D DIV
Q
DIV I $D(^PSCST(PSDT,"V",DIV,0)) S X=^(0) D STORE
Q
STORE Q:'$D(^PS(59,DIV,0)) S DIVX=$P(^(0),"^") S:'$D(^TMP($J,DIVX)) ^TMP($J,DIVX)="^0^0^0"
S UTL=^TMP($J,DIVX),^TMP($J,DIVX)="^"_($P(UTL,"^",2)+$P(X,"^",2))_"^"_($P(UTL,"^",3)+$P(X,"^",3))_"^"_($P(UTL,"^",4)+$P(X,"^",4))
Q
HD D HD^PSOCSTX Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSOCST8 1235 printed Nov 22, 2024@17:36:17 Page 2
PSOCST8 ;BHAM ISC/SAB - DRUG COSTS BY DIVISION ; 08/19/92 9:03
+1 ;;7.0;OUTPATIENT PHARMACY;**31**;DEC 1997
+2 ;External Ref. to ^PS(59, is supp. by DBIA# 212
BEG SET RP=8
DO HDC^PSOCSTX
FOR
DO CDT^PSOCSTX
if $GET(CTR)
QUIT
DO DVS^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 COST BY DIVISION"
SET ZTRTN="START^PSOCST8"
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:"PAT",1:"DIV")
+1 DO ZER^PSOCSTX
SET DIVX=""
DO HD
IF $ORDER(^TMP($JOB,DIVX))']""
DO HDN^PSOCSTX
QUIT
+2 FOR I=0:0
SET DIVX=$ORDER(^TMP($JOB,DIVX))
if DIVX=""
QUIT
if ($Y+4)>IOSL
DO HD
if $GET(CTR)
QUIT
SET Y=^TMP($JOB,DIVX)
SET TTX=DIVX
DO PRT^PSOCSTX
+3 IF 'CTR
IF 'IFN
if ($Y+2)>IOSL
DO HD
DO FTX^PSOCSTX
EX DO EX^PSOCSTX
QUIT
PAT FOR DIV=0:0
SET DIV=$ORDER(^PSCST(PSDT,"V",DIV))
if 'DIV
QUIT
DO DIV
+1 QUIT
DIV IF $DATA(^PSCST(PSDT,"V",DIV,0))
SET X=^(0)
DO STORE
+1 QUIT
STORE if '$DATA(^PS(59,DIV,0))
QUIT
SET DIVX=$PIECE(^(0),"^")
if '$DATA(^TMP($JOB,DIVX))
SET ^TMP($JOB,DIVX)="^0^0^0"
+1 SET UTL=^TMP($JOB,DIVX)
SET ^TMP($JOB,DIVX)="^"_($PIECE(UTL,"^",2)+$PIECE(X,"^",2))_"^"_($PIECE(UTL,"^",3)+$PIECE(X,"^",3))_"^"_($PIECE(UTL,"^",4)+$PIECE(X,"^",4))
+2 QUIT
HD DO HD^PSOCSTX
QUIT