CIMGAGPF ; CMI/TUCSON/LAB - aberdeen gpra print ; [ 03/14/00 9:47 AM ]
;;1.0;ABERDEEN GPRA REPORT;;JAN 22, 2000
;
;
INJ ;tally injuries
D TALLY
D PRINTJ
Q
TALLY ;
D HEADER Q:CIMQUIT
K ^TMP($J,"INJ")
S CIMBLTOT=0
S CIMRPTOT=0
S CIMXX=0 F S CIMXX=$O(CIMSUL(CIMXX)) Q:CIMXX'=+CIMXX D
.S CIMBLTOT=CIMBLTOT+$P($G(^CIMAGP(CIMXX,23)),U,11),T=$P($G(^CIMAGP(CIMXX,23)),U,11)
.I T S X=0 F S X=$O(^CIMAGP(CIMXX,25,X)) Q:X'=+X S I=$P(^CIMAGP(CIMXX,25,X,0),U),J="Z"_I,C=$P(^(0),U,2),D=$P(^(0),U,3),$P(^TMP($J,"INJ",J),U)=D,$P(^(J),U,2)=$P(^(J),U,2)+C,$P(^(J),U,3)=(($P(^(J),U,2)/CIMBLTOT)*100) D
..F Y=5:1:9 S A=$P(^CIMAGP(CIMXX,25,X,0),U,Y) S P=$S(Y=5:6,Y=6:8,Y=7:10,Y=8:12,Y=9:14),P1=$S(Y=5:7,Y=6:9,Y=7:11,Y=8:13,Y=9:15) D
...S $P(^TMP($J,"INJ",J),U,P)=$P(^TMP($J,"INJ",J),U,P)+A,$P(^TMP($J,"INJ",J),U,P1)=(($P(^(J),U,P)/$P(^TMP($J,"INJ",J),U,2)*100))
..S Y=0 F S Y=$O(^CIMAGP(CIMXX,25,X,25,Y)) Q:Y'=+Y S E=$P(^CIMAGP(CIMXX,25,X,25,Y,0),U),Z=$P(^(0),U,2),D=$P(^(0),U,3) D
...S $P(^TMP($J,"INJ",J,E),U)=D,$P(^TMP($J,"INJ",J,E),U,2)=$P(^TMP($J,"INJ",J,E),U,2)+Z,$P(^TMP($J,"INJ",J,E),U,3)=(($P(^TMP($J,"INJ",J,E),U,2)/$P(^TMP($J,"INJ",J),U,2)*100))
.S T=$P($G(^CIMAGP(CIMXX,22)),U,11),CIMRPTOT=CIMRPTOT+T
.I T S X=0 F S X=$O(^CIMAGP(CIMXX,24,X)) Q:X'=+X S I=$P(^CIMAGP(CIMXX,24,X,0),U),J="Z"_I,C=$P(^(0),U,2),D=$P(^(0),U,3),$P(^TMP($J,"INJ",J),U)=D,$P(^(J),U,4)=$P(^(J),U,4)+C,$P(^(J),U,5)=(($P(^(J),U,4)/CIMRPTOT)*100) D
..F Y=5:1:9 S A=$P(^CIMAGP(CIMXX,24,X,0),U,Y) S P=$S(Y=5:16,Y=6:18,Y=7:20,Y=8:22,Y=9:24),P1=$S(Y=5:17,Y=6:19,Y=7:21,Y=8:23,Y=9:25) D
...S $P(^TMP($J,"INJ",J),U,P)=$P(^TMP($J,"INJ",J),U,P)+A,$P(^TMP($J,"INJ",J),U,P1)=(($P(^(J),U,P)/$P(^TMP($J,"INJ",J),U,4)*100))
..S Y=0 F S Y=$O(^CIMAGP(CIMXX,24,X,24,Y)) Q:Y'=+Y S E=$P(^CIMAGP(CIMXX,24,X,24,Y,0),U),Z=$P(^(0),U,2),D=$P(^(0),U,3) D
...S $P(^TMP($J,"INJ",J,E),U)=D,$P(^TMP($J,"INJ",J,E),U,4)=$P(^TMP($J,"INJ",J,E),U,4)+Z,$P(^TMP($J,"INJ",J,E),U,5)=(($P(^TMP($J,"INJ",J,E),U,4)/$P(^TMP($J,"INJ",J),U,4)*100))
Q
PRINTJ ;
S CIMX=0 F S CIMX=$O(^TMP($J,"INJ",CIMX)) Q:CIMX=""!(CIMQUIT) D
.S D=^TMP($J,"INJ",CIMX)
.I $Y>(IOSL-5) D HEADER Q:CIMQUIT
.W !!?1,$E(CIMX,2,99),?8,$E($P(D,U),1,28)
.W ?36,$$C($P(D,U,2),0,9),?44,$J($P(D,U,3),6,1),?54,$$C($P(D,U,4),0,9),?62,$J($P(D,U,5),6,1)
.W ?72,$J($$CALC($P(D,U,5),$P(D,U,3)),7)
.W !?5,"# Direct Inpatient",?36,$$C($P(D,U,6),0,9),?44,$J($P(D,U,7),6,1),?54,$$C($P(D,U,16),0,9),?62,$J($P(D,U,17),6,1),?72,$J($$CALC($P(D,U,17),$P(D,U,7)),7)
.W !?5,"# Direct Outpatient",?36,$$C($P(D,U,8),0,9),?44,$J($P(D,U,9),6,1),?54,$$C($P(D,U,18),0,9),?62,$J($P(D,U,19),6,1),?72,$J($$CALC($P(D,U,19),$P(D,U,9)),7)
.W !?5,"# Contract Inpatient",?36,$$C($P(D,U,10),0,9),?44,$J($P(D,U,11),6,1),?54,$$C($P(D,U,20),0,9),?62,$J($P(D,U,21),6,1),?72,$J($$CALC($P(D,U,21),$P(D,U,11)),7)
.W !?5,"# Contract Outpatient",?36,$$C($P(D,U,12),0,9),?44,$J($P(D,U,13),6,1),?54,$$C($P(D,U,22),0,9),?62,$J($P(D,U,23),6,1),?72,$J($$CALC($P(D,U,23),$P(D,U,13)),7)
.W !?5,"Alcohol Related",?36,$$C($P(D,U,14),0,9),?44,$J($P(D,U,15),6,1),?54,$$C($P(D,U,24),0,9),?62,$J($P(D,U,25),6,1),?72,$J($$CALC($P(D,U,25),$P(D,U,15)),7)
.;ecode tally
.S CIMY="" F S CIMY=$O(^TMP($J,"INJ",CIMX,CIMY)) Q:CIMY=""!(CIMQUIT) D
..S CIMD=^TMP($J,"INJ",CIMX,CIMY)
..W !?5,CIMY,?12,$E($P(CIMD,U),1,24)
..W ?36,$$C($P(CIMD,U,2),0,9),?44,$J($P(CIMD,U,3),6,1),?54,$$C($P(CIMD,U,4),0,9),?62,$J($P(CIMD,U,5),6,1)
..W ?72,$J($$CALC($P(CIMD,U,5),$P(CIMD,U,3)),7)
..Q
Q
CALC(N,O) ;ENTRY POINT
;N is new
;O is old
NEW Z
I O=0!(N=0)!(O="")!(N="") Q "**"
NEW X,X2,X3
S X=N,X2=1,X3=0 D COMMA^%DTC S N=X
S X=O,X2=1,X3=0 D COMMA^%DTC S O=X
I +O=0 Q "**"
S Z=(((N-O)/O)*100),Z=$FN(Z,"+,",1)
Q Z
G:'CIMGPG HEADER1
K DIR I $E(IOST)="C",IO=IO(0),'$D(ZTQUEUED) W ! S DIR(0)="EO" D ^DIR K DIR I Y=0!(Y="^")!($D(DTOUT)) S CIMQUIT=1 Q
W:$D(IOF) @IOF S CIMGPG=CIMGPG+1
W !?3,$P(^VA(200,DUZ,0),U,2),?35,$$FMTE^XLFDT(DT),?70,"Page ",CIMGPG,!
W !,$$CTR("*** ABERDEEN AREA GPRA INDICATORS ***",80),!
W $S(CIMSUCNT=1:$$CTR(CIMSUNM),1:$$CTR("AREA AGGREGATE")),!
S X="Reporting Period: "_$$FMTE^XLFDT(CIMBD)_" to "_$$FMTE^XLFDT(CIMED) W $$CTR(X,80),!
S X="Baseline Period: "_$$FMTE^XLFDT(CIM98B)_" to "_$$FMTE^XLFDT(CIM98E) W $$CTR(X,80),!
W !,$TR($J("",80)," ","-")
W !?38,"BASELINE",?45," %",?56,"REPORT",?64," %",?71,"% CHANGE",!?38,"PERIOD",?56,"PERIOD"
W !,"Injury Diagnoses and E Codes"
Q
C(X,X2,X3) ;
D COMMA^%DTC
Q X
CTR(X,Y) ;EP - Center X in a field Y wide.
Q $J("",$S($D(Y):Y,1:IOM)-$L(X)\2)_X
;----------
USR() ;EP - Return name of current user from ^VA(200.
Q $S($G(DUZ):$S($D(^VA(200,DUZ,0)):$P(^(0),U),1:"UNKNOWN"),1:"DUZ UNDEFINED OR 0")
;----------
LOC() ;EP - Return location name from file 4 based on DUZ(2).
Q $S($G(DUZ(2)):$S($D(^DIC(4,DUZ(2),0)):$P(^(0),U),1:"UNKNOWN"),1:"DUZ(2) UNDEFINED OR 0")
;----------
CIMGAGPF ; CMI/TUCSON/LAB - aberdeen gpra print ; [ 03/14/00 9:47 AM ]
+1 ;;1.0;ABERDEEN GPRA REPORT;;JAN 22, 2000
+2 ;
+3 ;
INJ ;tally injuries
+1 DO TALLY
+2 DO PRINTJ
+3 QUIT
TALLY ;
+1 DO HEADER
IF CIMQUIT
QUIT
+2 KILL ^TMP($JOB,"INJ")
+3 SET CIMBLTOT=0
+4 SET CIMRPTOT=0
+5 SET CIMXX=0
FOR
SET CIMXX=$ORDER(CIMSUL(CIMXX))
IF CIMXX'=+CIMXX
QUIT
Begin DoDot:1
+6 SET CIMBLTOT=CIMBLTOT+$PIECE($GET(^CIMAGP(CIMXX,23)),U,11)
SET T=$PIECE($GET(^CIMAGP(CIMXX,23)),U,11)
+7 IF T
SET X=0
FOR
SET X=$ORDER(^CIMAGP(CIMXX,25,X))
IF X'=+X
QUIT
SET I=$PIECE(^CIMAGP(CIMXX,25,X,0),U)
SET J="Z"_I
SET C=$PIECE(^(0),U,2)
SET D=$PIECE(^(0),U,3)
SET $PIECE(^TMP($JOB,"INJ",J),U)=D
SET $PIECE(^(J),U,2)=$PIECE(^(J),U,2)+C
SET $PIECE(^(J),U,3)=(($PIECE(^(J),U,2)/CIMBLTOT)*100)
Begin DoDot:2
+8 FOR Y=5:1:9
SET A=$PIECE(^CIMAGP(CIMXX,25,X,0),U,Y)
SET P=$SELECT(Y=5:6,Y=6:8,Y=7:10,Y=8:12,Y=9:14)
SET P1=$SELECT(Y=5:7,Y=6:9,Y=7:11,Y=8:13,Y=9:15)
Begin DoDot:3
+9 SET $PIECE(^TMP($JOB,"INJ",J),U,P)=$PIECE(^TMP($JOB,"INJ",J),U,P)+A
SET $PIECE(^TMP($JOB,"INJ",J),U,P1)=(($PIECE(^(J),U,P)/$PIECE(^TMP($JOB,"INJ",J),U,2)*100))
End DoDot:3
+10 SET Y=0
FOR
SET Y=$ORDER(^CIMAGP(CIMXX,25,X,25,Y))
IF Y'=+Y
QUIT
SET E=$PIECE(^CIMAGP(CIMXX,25,X,25,Y,0),U)
SET Z=$PIECE(^(0),U,2)
SET D=$PIECE(^(0),U,3)
Begin DoDot:3
+11 SET $PIECE(^TMP($JOB,"INJ",J,E),U)=D
SET $PIECE(^TMP($JOB,"INJ",J,E),U,2)=$PIECE(^TMP($JOB,"INJ",J,E),U,2)+Z
SET $PIECE(^TMP($JOB,"INJ",J,E),U,3)=(($PIECE(^TMP($JOB,"INJ",J,E),U,2)/$PIECE(^TMP($JOB,"INJ",J),U,2)*100))
End DoDot:3
End DoDot:2
+12 SET T=$PIECE($GET(^CIMAGP(CIMXX,22)),U,11)
SET CIMRPTOT=CIMRPTOT+T
+13 IF T
SET X=0
FOR
SET X=$ORDER(^CIMAGP(CIMXX,24,X))
IF X'=+X
QUIT
SET I=$PIECE(^CIMAGP(CIMXX,24,X,0),U)
SET J="Z"_I
SET C=$PIECE(^(0),U,2)
SET D=$PIECE(^(0),U,3)
SET $PIECE(^TMP($JOB,"INJ",J),U)=D
SET $PIECE(^(J),U,4)=$PIECE(^(J),U,4)+C
SET $PIECE(^(J),U,5)=(($PIECE(^(J),U,4)/CIMRPTOT)*100)
Begin DoDot:2
+14 FOR Y=5:1:9
SET A=$PIECE(^CIMAGP(CIMXX,24,X,0),U,Y)
SET P=$SELECT(Y=5:16,Y=6:18,Y=7:20,Y=8:22,Y=9:24)
SET P1=$SELECT(Y=5:17,Y=6:19,Y=7:21,Y=8:23,Y=9:25)
Begin DoDot:3
+15 SET $PIECE(^TMP($JOB,"INJ",J),U,P)=$PIECE(^TMP($JOB,"INJ",J),U,P)+A
SET $PIECE(^TMP($JOB,"INJ",J),U,P1)=(($PIECE(^(J),U,P)/$PIECE(^TMP($JOB,"INJ",J),U,4)*100))
End DoDot:3
+16 SET Y=0
FOR
SET Y=$ORDER(^CIMAGP(CIMXX,24,X,24,Y))
IF Y'=+Y
QUIT
SET E=$PIECE(^CIMAGP(CIMXX,24,X,24,Y,0),U)
SET Z=$PIECE(^(0),U,2)
SET D=$PIECE(^(0),U,3)
Begin DoDot:3
+17 SET $PIECE(^TMP($JOB,"INJ",J,E),U)=D
SET $PIECE(^TMP($JOB,"INJ",J,E),U,4)=$PIECE(^TMP($JOB,"INJ",J,E),U,4)+Z
SET $PIECE(^TMP($JOB,"INJ",J,E),U,5)=(($PIECE(^TMP($JOB,"INJ",J,E),U,4)/$PIECE(^TMP($JOB,"INJ",J),U,4)*100))
End DoDot:3
End DoDot:2
End DoDot:1
+18 QUIT
PRINTJ ;
+1 SET CIMX=0
FOR
SET CIMX=$ORDER(^TMP($JOB,"INJ",CIMX))
IF CIMX=""!(CIMQUIT)
QUIT
Begin DoDot:1
+2 SET D=^TMP($JOB,"INJ",CIMX)
+3 IF $Y>(IOSL-5)
DO HEADER
IF CIMQUIT
QUIT
+4 WRITE !!?1,$EXTRACT(CIMX,2,99),?8,$EXTRACT($PIECE(D,U),1,28)
+5 WRITE ?36,$$C($PIECE(D,U,2),0,9),?44,$JUSTIFY($PIECE(D,U,3),6,1),?54,$$C($PIECE(D,U,4),0,9),?62,$JUSTIFY($PIECE(D,U,5),6,1)
+6 WRITE ?72,$JUSTIFY($$CALC($PIECE(D,U,5),$PIECE(D,U,3)),7)
+7 WRITE !?5,"# Direct Inpatient",?36,$$C($PIECE(D,U,6),0,9),?44,$JUSTIFY($PIECE(D,U,7),6,1),?54,$$C($PIECE(D,U,16),0,9),?62,$JUSTIFY($PIECE(D,U,17),6,1),?72,$JUSTIFY($$CALC($PIECE(D,U,17),$PIECE(D,U,7)),7)
+8 WRITE !?5,"# Direct Outpatient",?36,$$C($PIECE(D,U,8),0,9),?44,$JUSTIFY($PIECE(D,U,9),6,1),?54,$$C($PIECE(D,U,18),0,9),?62,$JUSTIFY($PIECE(D,U,19),6,1),?72,$JUSTIFY($$CALC($PIECE(D,U,19),$PIECE(D,U,9)),7)
+9 WRITE !?5,"# Contract Inpatient",?36,$$C($PIECE(D,U,10),0,9),?44,$JUSTIFY($PIECE(D,U,11),6,1),?54,$$C($PIECE(D,U,20),0,9),?62,$JUSTIFY($PIECE(D,U,21),6,1),?72,$JUSTIFY($$CALC($PIECE(D,U,21),$PIECE(D,U,11)),7)
+10 WRITE !?5,"# Contract Outpatient",?36,$$C($PIECE(D,U,12),0,9),?44,$JUSTIFY($PIECE(D,U,13),6,1),?54,$$C($PIECE(D,U,22),0,9),?62,$JUSTIFY($PIECE(D,U,23),6,1),?72,$JUSTIFY($$CALC($PIECE(D,U,23),$PIECE(D,U,13)),7)
+11 WRITE !?5,"Alcohol Related",?36,$$C($PIECE(D,U,14),0,9),?44,$JUSTIFY($PIECE(D,U,15),6,1),?54,$$C($PIECE(D,U,24),0,9),?62,$JUSTIFY($PIECE(D,U,25),6,1),?72,$JUSTIFY($$CALC($PIECE(D,U,25),$PIECE(D,U,15)),7)
+12 ;ecode tally
+13 SET CIMY=""
FOR
SET CIMY=$ORDER(^TMP($JOB,"INJ",CIMX,CIMY))
IF CIMY=""!(CIMQUIT)
QUIT
Begin DoDot:2
+14 SET CIMD=^TMP($JOB,"INJ",CIMX,CIMY)
+15 WRITE !?5,CIMY,?12,$EXTRACT($PIECE(CIMD,U),1,24)
+16 WRITE ?36,$$C($PIECE(CIMD,U,2),0,9),?44,$JUSTIFY($PIECE(CIMD,U,3),6,1),?54,$$C($PIECE(CIMD,U,4),0,9),?62,$JUSTIFY($PIECE(CIMD,U,5),6,1)
+17 WRITE ?72,$JUSTIFY($$CALC($PIECE(CIMD,U,5),$PIECE(CIMD,U,3)),7)
+18 QUIT
End DoDot:2
End DoDot:1
+19 QUIT
CALC(N,O) ;ENTRY POINT
+1 ;N is new
+2 ;O is old
+3 NEW Z
+4 IF O=0!(N=0)!(O="")!(N="")
QUIT "**"
+5 NEW X,X2,X3
+6 SET X=N
SET X2=1
SET X3=0
DO COMMA^%DTC
SET N=X
+7 SET X=O
SET X2=1
SET X3=0
DO COMMA^%DTC
SET O=X
+8 IF +O=0
QUIT "**"
+9 SET Z=(((N-O)/O)*100)
SET Z=$FNUMBER(Z,"+,",1)
+10 QUIT Z
+1 IF 'CIMGPG
GOTO HEADER1
+2 KILL DIR
IF $EXTRACT(IOST)="C"
IF IO=IO(0)
IF '$DATA(ZTQUEUED)
WRITE !
SET DIR(0)="EO"
DO ^DIR
KILL DIR
IF Y=0!(Y="^")!($DATA(DTOUT))
SET CIMQUIT=1
QUIT
+1 IF $DATA(IOF)
WRITE @IOF
SET CIMGPG=CIMGPG+1
+2 WRITE !?3,$PIECE(^VA(200,DUZ,0),U,2),?35,$$FMTE^XLFDT(DT),?70,"Page ",CIMGPG,!
+3 WRITE !,$$CTR("*** ABERDEEN AREA GPRA INDICATORS ***",80),!
+4 WRITE $SELECT(CIMSUCNT=1:$$CTR(CIMSUNM),1:$$CTR("AREA AGGREGATE")),!
+5 SET X="Reporting Period: "_$$FMTE^XLFDT(CIMBD)_" to "_$$FMTE^XLFDT(CIMED)
WRITE $$CTR(X,80),!
+6 SET X="Baseline Period: "_$$FMTE^XLFDT(CIM98B)_" to "_$$FMTE^XLFDT(CIM98E)
WRITE $$CTR(X,80),!
+7 WRITE !,$TRANSLATE($JUSTIFY("",80)," ","-")
+8 WRITE !?38,"BASELINE",?45," %",?56,"REPORT",?64," %",?71,"% CHANGE",!?38,"PERIOD",?56,"PERIOD"
+9 WRITE !,"Injury Diagnoses and E Codes"
+10 QUIT
C(X,X2,X3) ;
+1 DO COMMA^%DTC
+2 QUIT X
CTR(X,Y) ;EP - Center X in a field Y wide.
+1 QUIT $JUSTIFY("",$SELECT($DATA(Y):Y,1:IOM)-$LENGTH(X)\2)_X
+2 ;----------
USR() ;EP - Return name of current user from ^VA(200.
+1 QUIT $SELECT($GET(DUZ):$SELECT($DATA(^VA(200,DUZ,0)):$PIECE(^(0),U),1:"UNKNOWN"),1:"DUZ UNDEFINED OR 0")
+2 ;----------
LOC() ;EP - Return location name from file 4 based on DUZ(2).
+1 QUIT $SELECT($GET(DUZ(2)):$SELECT($DATA(^DIC(4,DUZ(2),0)):$PIECE(^(0),U),1:"UNKNOWN"),1:"DUZ(2) UNDEFINED OR 0")
+2 ;----------