PSOCST9 ;BHAM ISC/SAB - DIVISION BY PROVIDER COST ; 08/19/92 11:20
;;7.0;OUTPATIENT PHARMACY;**31**;DEC 1997
;External Ref. to ^PS(59, is supp. by DBIA# 212
BEG S RP=9 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="DIVISION BY PROVIDER COSTS",ZTRTN="START^PSOCST9" 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:"DIV",1:"PHY")
S DIVX="" I $O(^TMP($J,DIVX))']"" D HD,HDN^PSOCSTX Q
F S DIVX=$O(^TMP($J,DIVX)) Q:DIVX="" S PHYX="" F S PHYX=$O(^TMP($J,DIVX,PHYX)) Q:PHYX="" D STR
D ZER^PSOCSTX S DIVX="" F S DIVX=$O(^TMP($J,DIVX)) Q:DIVX="" S PHYX="" D HD Q:$G(CTR) F S PHYX=$O(^TMP($J,DIVX,PHYX)) D:PHYX="" SUB Q:PHYX="" D PRT3
I 'CTR,'IFN D HD:($Y+2)>IOSL D TOT^PSOCSTX
EX D EX^PSOCSTX Q
PRT3 D:($Y+4)>IOSL HD Q:$G(CTR) S Y=^TMP($J,DIVX,PHYX),TTX=PHYX D PRT^PSOCSTX
Q
DIV F DIV=0:0 S DIV=$O(^PSCST(PSDT,"V",DIV)) Q:'DIV D PHY
Q
PHY F PHY=0:0 S PHY=$O(^PSCST(PSDT,"V",DIV,"P",PHY)) Q:'PHY I $D(^(PHY,0)) S X=^(0) D STORE
Q
STORE S DIVX=$S($D(^PS(59,+DIV,0)):$P(^(0),"^"),1:"UNKNOWN")
S PHYX=$S($D(^VA(200,+PHY,0)):$P(^(0),"^"),1:"UNKNOWN")
S:'$D(^TMP($J,DIVX,PHYX)) ^TMP($J,DIVX,PHYX)="^0^0^0",^TMP($J,DIVX)="^0^0^0^0"
S UTL=^TMP($J,DIVX,PHYX),^TMP($J,DIVX,PHYX)="^"_($P(UTL,"^",2)+$P(X,"^",2))_"^"_($P(UTL,"^",3)+$P(X,"^",3))_"^"_($P(UTL,"^",4)+$P(X,"^",4))
Q
STR S $P(^TMP($J,DIVX),"^",2)=($P(^TMP($J,DIVX),"^",2)+$P(^TMP($J,DIVX,PHYX),"^",2)),$P(^TMP($J,DIVX),"^",3)=($P(^TMP($J,DIVX),"^",3)+$P(^TMP($J,DIVX,PHYX),"^",3))
S $P(^TMP($J,DIVX),"^",4)=($P(^TMP($J,DIVX),"^",4)+$P(^TMP($J,DIVX,PHYX),"^",4)),$P(^TMP($J,DIVX),"^",5)=($P(^TMP($J,DIVX),"^",5)+$P(^TMP($J,DIVX,PHYX),"^",2)+$P(^TMP($J,DIVX,PHYX),"^",3))
Q
HD D HD^PSOCSTX Q:$G(CTR)
W !,?5,"Division: ",DIVX
Q
SUB ;sub-totals per division
D HD:($Y+2)>IOSL D FTU^PSOCSTX W !,"Total for "_DIVX D FTT^PSOCSTX,FTU^PSOCSTX,SUB^PSOCSTX
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSOCST9 2141 printed Oct 16, 2024@18:26:57 Page 2
PSOCST9 ;BHAM ISC/SAB - DIVISION BY PROVIDER COST ; 08/19/92 11:20
+1 ;;7.0;OUTPATIENT PHARMACY;**31**;DEC 1997
+2 ;External Ref. to ^PS(59, is supp. by DBIA# 212
BEG SET RP=9
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="DIVISION BY PROVIDER COSTS"
SET ZTRTN="START^PSOCST9"
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:"DIV",1:"PHY")
+1 SET DIVX=""
IF $ORDER(^TMP($JOB,DIVX))']""
DO HD
DO HDN^PSOCSTX
QUIT
+2 FOR
SET DIVX=$ORDER(^TMP($JOB,DIVX))
if DIVX=""
QUIT
SET PHYX=""
FOR
SET PHYX=$ORDER(^TMP($JOB,DIVX,PHYX))
if PHYX=""
QUIT
DO STR
+3 DO ZER^PSOCSTX
SET DIVX=""
FOR
SET DIVX=$ORDER(^TMP($JOB,DIVX))
if DIVX=""
QUIT
SET PHYX=""
DO HD
if $GET(CTR)
QUIT
FOR
SET PHYX=$ORDER(^TMP($JOB,DIVX,PHYX))
if PHYX=""
DO SUB
if PHYX=""
QUIT
DO PRT3
+4 IF 'CTR
IF 'IFN
if ($Y+2)>IOSL
DO HD
DO TOT^PSOCSTX
EX DO EX^PSOCSTX
QUIT
PRT3 if ($Y+4)>IOSL
DO HD
if $GET(CTR)
QUIT
SET Y=^TMP($JOB,DIVX,PHYX)
SET TTX=PHYX
DO PRT^PSOCSTX
+1 QUIT
DIV FOR DIV=0:0
SET DIV=$ORDER(^PSCST(PSDT,"V",DIV))
if 'DIV
QUIT
DO PHY
+1 QUIT
PHY FOR PHY=0:0
SET PHY=$ORDER(^PSCST(PSDT,"V",DIV,"P",PHY))
if 'PHY
QUIT
IF $DATA(^(PHY,0))
SET X=^(0)
DO STORE
+1 QUIT
STORE SET DIVX=$SELECT($DATA(^PS(59,+DIV,0)):$PIECE(^(0),"^"),1:"UNKNOWN")
+1 SET PHYX=$SELECT($DATA(^VA(200,+PHY,0)):$PIECE(^(0),"^"),1:"UNKNOWN")
+2 if '$DATA(^TMP($JOB,DIVX,PHYX))
SET ^TMP($JOB,DIVX,PHYX)="^0^0^0"
SET ^TMP($JOB,DIVX)="^0^0^0^0"
+3 SET UTL=^TMP($JOB,DIVX,PHYX)
SET ^TMP($JOB,DIVX,PHYX)="^"_($PIECE(UTL,"^",2)+$PIECE(X,"^",2))_"^"_($PIECE(UTL,"^",3)+$PIECE(X,"^",3))_"^"_($PIECE(UTL,"^",4)+$PIECE(X,"^",4))
+4 QUIT
STR SET $PIECE(^TMP($JOB,DIVX),"^",2)=($PIECE(^TMP($JOB,DIVX),"^",2)+$PIECE(^TMP($JOB,DIVX,PHYX),"^",2))
SET $PIECE(^TMP($JOB,DIVX),"^",3)=($PIECE(^TMP($JOB,DIVX),"^",3)+$PIECE(^TMP($JOB,DIVX,PHYX),"^",3))
+1 SET $PIECE(^TMP($JOB,DIVX),"^",4)=($PIECE(^TMP($JOB,DIVX),"^",4)+$PIECE(^TMP($JOB,DIVX,PHYX),"^",4))
SET $PIECE(^TMP($JOB,DIVX),"^",5)=($PIECE(^TMP($JOB,DIVX),"^",5)+$PIECE(^TMP($JOB,DIVX,PHYX),"^",2)+$PIECE(^TMP($JOB,DIVX,PHYX),"^",3))
+2 QUIT
HD DO HD^PSOCSTX
if $GET(CTR)
QUIT
+1 WRITE !,?5,"Division: ",DIVX
+2 QUIT
SUB ;sub-totals per division
+1 if ($Y+2)>IOSL
DO HD
DO FTU^PSOCSTX
WRITE !,"Total for "_DIVX
DO FTT^PSOCSTX
DO FTU^PSOCSTX
DO SUB^PSOCSTX
+2 QUIT