DGPTODA2 ;ALB/AS - PTF DRG ALOS REPORTS (CONT) ; 9/13/01 5:55pm
;;5.3;Registration;**375,1015**;Aug 13, 1993;Build 21
F DRG=0:0 S:DRG>0&('$D(^UTILITY($J,"DGTC",DRG))) ^UTILITY($J,"DGTC",DRG,DGPAG)="" S DRG=$O(^UTILITY($J,"DGPTFR","D",DRG)) Q:DRG'>0 S Z=^(DRG) D LN
D WM Q
LN I $Y>$S($D(IOSL):(IOSL-12),1:54) D HD^DGPTODA1
S (DGHI,DGLODC,DGLODAY,DG1DAY)=0,DGWU=$P(Z,"^",6),DGTD=$P(Z,"^",2),DGLOTRIM=$P(Z,"^",3),DGTL=$P(Z,"^"),DGTT(5)=DGTT(5)+DGTD,DGTT(6)=DGTT(6)+DGTL,(DGA,DGU)=""
W !,$J(DRG,3),$J(DGLOTRIM,5),$J($P(Z,"^",4),6),$J($P(Z,"^",5),9),$J(DGWU,9),$J($P(Z,"^",7),4) Q:DGRNO=3
S D5=0 I DGRNO=1 F D=0:0 S D5=$O(^UTILITY($J,"DGPTFR","D",DRG,D5)) Q:D5="" S %=^(D5) D AA:D5="AA",BA:D5="BA"
I $D(DGBNM) F D=0:0 S D5=$O(^UTILITY($J,"DGPTFR","SB",DGSV,DGBS,DRG,D5)) Q:D5="" S %=^(D5) D AA:D5="AA",BA:D5="BA"
WLN W ?37,"|" W:DGU="B" $J(DGDU,6),$J(DGLU,8),$J(DGLU/DGDU,7,1)," |" W:DGU'="B" ?43,"0 0 0 |" W:DGA="A" $J(DGDA,6),$J(DGLA,8),?70,$J(DGLA/DGDA,7,1) W:DGA'="A" ?66,"0 0 0"
W ?83,"|",$J(DGTD,6),$J(DGTL,9),$J(DGTL/DGTD,7,1),?107,"|"
S DGTWW=$J((DGTD-DGLODC*DGWU)+(DG1DAY*DG1DAWW)+(DGHI*DGHIWW)+($S(DGLODAY>0&(DGLOTRIM>0):(DGLODAY/DGLOTRIM*DGWU),1:0)),0,5),DGTWW=$S(DGTWW'>0:DGWU,1:DGTWW),DGTT(7)=DGTT(7)+DGTWW W $J(DGTWW,9,2) Q
;S X=DGTWW*DGWWCST,X2="2" D COMMA^%DTC W $J(X,13) Q
AA S DGA="A",DGLA=$P(%,"^"),DGDA=$P(%,"^",2),DGHI=$P(%,"^",3),DGTT(3)=DGTT(3)+DGDA,DGTT(4)=DGTT(4)+DGLA Q:DGRNO=1 I '$D(^UTILITY($J,"DGLOS",DGSV,DRG,"AA")) S ^UTILITY($J,"DGLOS",DGSV,DRG,"AA")=% Q
S $P(^UTILITY($J,"DGLOS",DGSV,DRG,"AA"),"^")=$P(^UTILITY($J,"DGLOS",DGSV,DRG,"AA"),"^")+DGLA,$P(^("AA"),"^",2)=$P(^("AA"),"^",2)+DGDA,$P(^("AA"),"^",3)=$P(^("AA"),"^",3)+DGHI Q
BA S DGU="B",DGLU=$P(%,"^"),DGDU=$P(%,"^",2),DG1DAY=DG1DAY+$P(%,"^",4),DGLODAY=$P(%,"^",5),DGLODC=$P(%,"^",6),DGTT(1)=DGTT(1)+DGDU,DGTT(2)=DGTT(2)+DGLU Q:DGRNO=1 I '$D(^UTILITY($J,"DGLOS",DGSV,DRG,"BA")) S ^UTILITY($J,"DGLOS",DGSV,DRG,"BA")=% Q
S $P(^UTILITY($J,"DGLOS",DGSV,DRG,"BA"),"^")=$P(^UTILITY($J,"DGLOS",DGSV,DRG,"BA"),"^")+DGLU,$P(^("BA"),"^",2)=$P(^("BA"),"^",2)+DGDU,$P(^("BA"),"^",4)=$P(^("BA"),"^",4)+DG1DAY
S $P(^UTILITY($J,"DGLOS",DGSV,DRG,"BA"),"^",5)=$P(^UTILITY($J,"DGLOS",DGSV,DRG,"BA"),"^",5)+DGLODAY,$P(^("BA"),"^",6)=$P(^("BA"),"^",6)+DGLODC Q
PG S %=$S($D(IOSL):(IOSL-11),1:55) F I=$Y:1:% W !
D DIS^DGPTOD1 W !!?64,"-",DGPAG,"-",! Q
SV F DGBS=0:0 D:DGBS>0 WB S DGBS=$O(^UTILITY($J,"DGPTFR","SB",DGSV,DGBS)) Q:DGBS'>0 S DGBNM=^(DGBS) D:$Y>$S($D(IOSL):(IOSL-14),1:52) HD^DGPTODA1 W !!,DGBNM F DRG=0:0 S DRG=$O(^UTILITY($J,"DGPTFR","SB",DGSV,DGBS,DRG)) Q:DRG'>0 S Z=^(DRG) D S,LN
Q
S S:'$D(^UTILITY($J,"DGTC",DGBNM)) ^(DGBNM,DGPAG)="" I '$D(^UTILITY($J,"DGLOS",DGSV,DRG)) S ^UTILITY($J,"DGLOS",DGSV,DRG)=Z Q
F %=1:1:2 S $P(^UTILITY($J,"DGLOS",DGSV,DRG),"^",%)=$P(^UTILITY($J,"DGLOS",DGSV,DRG),"^",%)+$P(Z,"^",%)
Q
WT W ?37,"|",$J(DGTT(1),6),$J(DGTT(2),8) S %=$S(DGTT(1)>0:(DGTT(2)/DGTT(1)),1:"") W $S(%]"":$J(%,7,1),1:" 0")," |"
W $J(DGTT(3),6),$J(DGTT(4),8) S %=$S(DGTT(3)>0:(DGTT(4)/DGTT(3)),1:"") W $S(%]"":$J(%,7,1),1:" 0")," |",$J(DGTT(5),6),$J(DGTT(6),9),$J(DGTT(6)/DGTT(5),7,1)," |",$J(DGTT(7),9,2),$J(DGTT(7)/DGTT(5),13,2) Q
WM W !,DGLN,!?3,"Totals for Medical Center:" D WT,PG,TP^DGUTL Q
WS F %=1:1:7 S:DGRNO=3 DGAMT(%)=DGAMT(%)+DGTT(%) I DGRNO=2 S DGTT(%)=DGAMT(%),DGMC(%)=DGMC(%)+DGAMT(%),DGAMT(%)=0
W !,DGLN,!?3,"Totals for Service:" D WT F %=1:1:7 S DGTT(%)=0
Q
WB W !,DGLN2,!?3,"Totals for Specialty:" D WT F %=1:1:7 S DGAMT(%)=DGAMT(%)+DGTT(%),DGTT(%)=0
Q
DGPTODA2 ;ALB/AS - PTF DRG ALOS REPORTS (CONT) ; 9/13/01 5:55pm
+1 ;;5.3;Registration;**375,1015**;Aug 13, 1993;Build 21
+2 FOR DRG=0:0
IF DRG>0&('$DATA(^UTILITY($JOB,"DGTC",DRG)))
SET ^UTILITY($JOB,"DGTC",DRG,DGPAG)=""
SET DRG=$ORDER(^UTILITY($JOB,"DGPTFR","D",DRG))
IF DRG'>0
QUIT
SET Z=^(DRG)
DO LN
+3 DO WM
QUIT
LN IF $Y>$SELECT($DATA(IOSL):(IOSL-12),1:54)
DO HD^DGPTODA1
+1 SET (DGHI,DGLODC,DGLODAY,DG1DAY)=0
SET DGWU=$PIECE(Z,"^",6)
SET DGTD=$PIECE(Z,"^",2)
SET DGLOTRIM=$PIECE(Z,"^",3)
SET DGTL=$PIECE(Z,"^")
SET DGTT(5)=DGTT(5)+DGTD
SET DGTT(6)=DGTT(6)+DGTL
SET (DGA,DGU)=""
+2 WRITE !,$JUSTIFY(DRG,3),$JUSTIFY(DGLOTRIM,5),$JUSTIFY($PIECE(Z,"^",4),6),$JUSTIFY($PIECE(Z,"^",5),9),$JUSTIFY(DGWU,9),$JUSTIFY($PIECE(Z,"^",7),4)
IF DGRNO=3
QUIT
+3 SET D5=0
IF DGRNO=1
FOR D=0:0
SET D5=$ORDER(^UTILITY($JOB,"DGPTFR","D",DRG,D5))
IF D5=""
QUIT
SET %=^(D5)
IF D5="AA"
DO AA
IF D5="BA"
DO BA
+4 IF $DATA(DGBNM)
FOR D=0:0
SET D5=$ORDER(^UTILITY($JOB,"DGPTFR","SB",DGSV,DGBS,DRG,D5))
IF D5=""
QUIT
SET %=^(D5)
IF D5="AA"
DO AA
IF D5="BA"
DO BA
WLN WRITE ?37,"|"
IF DGU="B"
WRITE $JUSTIFY(DGDU,6),$JUSTIFY(DGLU,8),$JUSTIFY(DGLU/DGDU,7,1)," |"
IF DGU'="B"
WRITE ?43,"0 0 0 |"
IF DGA="A"
WRITE $JUSTIFY(DGDA,6),$JUSTIFY(DGLA,8),?70,$JUSTIFY(DGLA/DGDA,7,1)
IF DGA'="A"
WRITE ?66,"0 0 0"
+1 WRITE ?83,"|",$JUSTIFY(DGTD,6),$JUSTIFY(DGTL,9),$JUSTIFY(DGTL/DGTD,7,1),?107,"|"
+2 SET DGTWW=$JUSTIFY((DGTD-DGLODC*DGWU)+(DG1DAY*DG1DAWW)+(DGHI*DGHIWW)+($SELECT(DGLODAY>0&(DGLOTRIM>0):(DGLODAY/DGLOTRIM*DGWU),1:0)),0,5)
SET DGTWW=$SELECT(DGTWW'>0:DGWU,1:DGTWW)
SET DGTT(7)=DGTT(7)+DGTWW
WRITE $JUSTIFY(DGTWW,9,2)
QUIT
+3 ;S X=DGTWW*DGWWCST,X2="2" D COMMA^%DTC W $J(X,13) Q
AA SET DGA="A"
SET DGLA=$PIECE(%,"^")
SET DGDA=$PIECE(%,"^",2)
SET DGHI=$PIECE(%,"^",3)
SET DGTT(3)=DGTT(3)+DGDA
SET DGTT(4)=DGTT(4)+DGLA
IF DGRNO=1
QUIT
IF '$DATA(^UTILITY($JOB,"DGLOS",DGSV,DRG,"AA"))
SET ^UTILITY($JOB,"DGLOS",DGSV,DRG,"AA")=%
QUIT
+1 SET $PIECE(^UTILITY($JOB,"DGLOS",DGSV,DRG,"AA"),"^")=$PIECE(^UTILITY($JOB,"DGLOS",DGSV,DRG,"AA"),"^")+DGLA
SET $PIECE(^("AA"),"^",2)=$PIECE(^("AA"),"^",2)+DGDA
SET $PIECE(^("AA"),"^",3)=$PIECE(^("AA"),"^",3)+DGHI
QUIT
BA SET DGU="B"
SET DGLU=$PIECE(%,"^")
SET DGDU=$PIECE(%,"^",2)
SET DG1DAY=DG1DAY+$PIECE(%,"^",4)
SET DGLODAY=$PIECE(%,"^",5)
SET DGLODC=$PIECE(%,"^",6)
SET DGTT(1)=DGTT(1)+DGDU
SET DGTT(2)=DGTT(2)+DGLU
IF DGRNO=1
QUIT
IF '$DATA(^UTILITY($JOB,"DGLOS",DGSV,DRG,"BA"))
SET ^UTILITY($JOB,"DGLOS",DGSV,DRG,"BA")=%
QUIT
+1 SET $PIECE(^UTILITY($JOB,"DGLOS",DGSV,DRG,"BA"),"^")=$PIECE(^UTILITY($JOB,"DGLOS",DGSV,DRG,"BA"),"^")+DGLU
SET $PIECE(^("BA"),"^",2)=$PIECE(^("BA"),"^",2)+DGDU
SET $PIECE(^("BA"),"^",4)=$PIECE(^("BA"),"^",4)+DG1DAY
+2 SET $PIECE(^UTILITY($JOB,"DGLOS",DGSV,DRG,"BA"),"^",5)=$PIECE(^UTILITY($JOB,"DGLOS",DGSV,DRG,"BA"),"^",5)+DGLODAY
SET $PIECE(^("BA"),"^",6)=$PIECE(^("BA"),"^",6)+DGLODC
QUIT
PG SET %=$SELECT($DATA(IOSL):(IOSL-11),1:55)
FOR I=$Y:1:%
WRITE !
+1 DO DIS^DGPTOD1
WRITE !!?64,"-",DGPAG,"-",!
QUIT
SV FOR DGBS=0:0
IF DGBS>0
DO WB
SET DGBS=$ORDER(^UTILITY($JOB,"DGPTFR","SB",DGSV,DGBS))
IF DGBS'>0
QUIT
SET DGBNM=^(DGBS)
IF $Y>$SELECT($DATA(IOSL)
DO HD^DGPTODA1
WRITE !!,DGBNM
FOR DRG=0:0
SET DRG=$ORDER(^UTILITY($JOB,"DGPTFR","SB",DGSV,DGBS,DRG))
IF DRG'>0
QUIT
SET Z=^(DRG)
DO S
DO LN
+1 QUIT
S IF '$DATA(^UTILITY($JOB,"DGTC",DGBNM))
SET ^(DGBNM,DGPAG)=""
IF '$DATA(^UTILITY($JOB,"DGLOS",DGSV,DRG))
SET ^UTILITY($JOB,"DGLOS",DGSV,DRG)=Z
QUIT
+1 FOR %=1:1:2
SET $PIECE(^UTILITY($JOB,"DGLOS",DGSV,DRG),"^",%)=$PIECE(^UTILITY($JOB,"DGLOS",DGSV,DRG),"^",%)+$PIECE(Z,"^",%)
+2 QUIT
WT WRITE ?37,"|",$JUSTIFY(DGTT(1),6),$JUSTIFY(DGTT(2),8)
SET %=$SELECT(DGTT(1)>0:(DGTT(2)/DGTT(1)),1:"")
WRITE $SELECT(%]"":$JUSTIFY(%,7,1),1:" 0")," |"
+1 WRITE $JUSTIFY(DGTT(3),6),$JUSTIFY(DGTT(4),8)
SET %=$SELECT(DGTT(3)>0:(DGTT(4)/DGTT(3)),1:"")
WRITE $SELECT(%]"":$JUSTIFY(%,7,1),1:" 0")," |",$JUSTIFY(DGTT(5),6),$JUSTIFY(DGTT(6),9),$JUSTIFY(DGTT(6)/DGTT(5),7,1)," |",$JUSTIFY(DGTT(7),9,2),$JUSTIFY(DGTT(7)/DGTT(5),13,2)
QUIT
WM WRITE !,DGLN,!?3,"Totals for Medical Center:"
DO WT
DO PG
DO TP^DGUTL
QUIT
WS FOR %=1:1:7
IF DGRNO=3
SET DGAMT(%)=DGAMT(%)+DGTT(%)
IF DGRNO=2
SET DGTT(%)=DGAMT(%)
SET DGMC(%)=DGMC(%)+DGAMT(%)
SET DGAMT(%)=0
+1 WRITE !,DGLN,!?3,"Totals for Service:"
DO WT
FOR %=1:1:7
SET DGTT(%)=0
+2 QUIT
WB WRITE !,DGLN2,!?3,"Totals for Specialty:"
DO WT
FOR %=1:1:7
SET DGAMT(%)=DGAMT(%)+DGTT(%)
SET DGTT(%)=0
+1 QUIT