ANSQSP1 ;IHS/OIRM/DSD/CSC - PRINT NURSE STAFFING STATS; [ 02/25/98 10:32 AM ]
;;3.0;NURSING PATIENT ACUITY;;APR 01, 1996
;;PRINT NURSE STAFFING STATS
EN ;CHECK THROUGH EACH DAY OF THE REPORT GLOBAL
S ANSD=0
F S ANSD=$O(^TMP("ANS",$J,ANSD)) Q:'ANSD!$D(DTOUT)!$D(DUOUT) D EN1
I ANSD<1 D C1 Q
I ANSPO="D" D B1 Q
Q
EN1 ;PROCESS INFO FOR EACH DAY
I ANSPO="D" D B1 Q
I ANSIOT,$Y>$S(ANSPO="S":18,1:23) D
.D PAUSE^ANSDIC
.W:$D(IOF) @IOF
.D HEAD^ANSQSP
I $Y>54 D
.D HEAD^ANSQSP
S ANSSH=0
F S ANSSH=$O(^TMP("ANS",$J,ANSD,ANSSH)) Q:'ANSSH!$D(DTOUT)!$D(DUOUT) D
.F I="A","O","H" S @I=$G(^TMP("ANS",$J,ANSD,ANSSH,I))
.S L="",T=0
.F I=1:1:6 S Y=$P(O,U,I) I Y S T=T+Y,$P(L,U,I+4)=Y
.S $P(L,U,4)=$P(O,U,7)
.S N=0
.F I=1:1:6 S Y=$P(A,U,I) I Y S N=N+Y
.S $P(L,U)=T,$P(L,U,2)=T,$P(L,U,3)=N,X=$P(H,U)-$P(H,U,2),Y=$P(H,U,3),E=""
.I X S E=Y/X
.S $P(L,U,11)=Y,$P(L,U,12)=X,$P(L,U,13)=E*100
.S ANSWX=$E(ANSD,4,7)
.D SBW
I ANSSH<1 D B1 Q
Q
B1 ;PRINT THE DAILY SUMMARY
S L="",ANSPTC=ANSPTC+1
I $D(^TMP("ANS",$J,ANSD,"T")) S L=^("T"),X=$P(L,U,11),Y=$P(L,U,12),E="" I Y S E=X/Y*100,$P(L,U,13)=E
D:ANSPO="S" H9^ANSQSP
S ANSWX=$S(ANSPO="S":"Daily",1:$E(ANSD,4,7))
D SBW
F I=1,3:1:13 S N=$P(L,U,I) S A(I)=$G(A(I))+N
S N=$P(L,U,2)
I N>$G(A(2)) S A(2)=N
W:ANSPO="S" !
Q
C1 ;PRINT OUT THE SUMMARY TOTALS FOR ALL DAYS SELECTED
D H9^ANSQSP
S L=""
F I=1:1:12 S $P(L,U,I)=$G(A(I))
S X=$P(L,U,11),Y=$P(L,U,12)
I Y S E=X/Y*100,$P(L,U,13)=E
S ANSWX="Total"
D SBW
Q
SBW ;WRITE OUT INFO FOR EACH SHIFT AND DAILY SUMMARY
W !,ANSWX," "
I $D(ANSSH),ANSSH S X=$T(@ANSNS) W $P(X,";;",ANSSH+1)
F I=1:1:13 S N=$P(L,U,I) D
.S N=$J(N,1,1),D=$P(N,".",2),N=$P(N,".",1)
.D WRT
Q
WRT ;WRITE EACH COLUMN OF EACH LINE OF THE REPORT
S T=$P(ANSTAB,";;",I+1),W=$P(ANSWTH,";;",I+1)
W ?T,"|",$J(N,W)
I D W ".",D
I I=13,'D W ".0"
Q
2 ;;D;;N
3 ;;D;;E;;N
ANSQSP1 ;IHS/OIRM/DSD/CSC - PRINT NURSE STAFFING STATS; [ 02/25/98 10:32 AM ]
+1 ;;3.0;NURSING PATIENT ACUITY;;APR 01, 1996
+2 ;;PRINT NURSE STAFFING STATS
EN ;CHECK THROUGH EACH DAY OF THE REPORT GLOBAL
+1 SET ANSD=0
+2 FOR
SET ANSD=$ORDER(^TMP("ANS",$JOB,ANSD))
IF 'ANSD!$DATA(DTOUT)!$DATA(DUOUT)
QUIT
DO EN1
+3 IF ANSD<1
DO C1
QUIT
+4 IF ANSPO="D"
DO B1
QUIT
+5 QUIT
EN1 ;PROCESS INFO FOR EACH DAY
+1 IF ANSPO="D"
DO B1
QUIT
+2 IF ANSIOT
IF $Y>$SELECT(ANSPO="S":18,1:23)
Begin DoDot:1
+3 DO PAUSE^ANSDIC
+4 IF $DATA(IOF)
WRITE @IOF
+5 DO HEAD^ANSQSP
End DoDot:1
+6 IF $Y>54
Begin DoDot:1
+7 DO HEAD^ANSQSP
End DoDot:1
+8 SET ANSSH=0
+9 FOR
SET ANSSH=$ORDER(^TMP("ANS",$JOB,ANSD,ANSSH))
IF 'ANSSH!$DATA(DTOUT)!$DATA(DUOUT)
QUIT
Begin DoDot:1
+10 FOR I="A","O","H"
SET @I=$GET(^TMP("ANS",$JOB,ANSD,ANSSH,I))
+11 SET L=""
SET T=0
+12 FOR I=1:1:6
SET Y=$PIECE(O,U,I)
IF Y
SET T=T+Y
SET $PIECE(L,U,I+4)=Y
+13 SET $PIECE(L,U,4)=$PIECE(O,U,7)
+14 SET N=0
+15 FOR I=1:1:6
SET Y=$PIECE(A,U,I)
IF Y
SET N=N+Y
+16 SET $PIECE(L,U)=T
SET $PIECE(L,U,2)=T
SET $PIECE(L,U,3)=N
SET X=$PIECE(H,U)-$PIECE(H,U,2)
SET Y=$PIECE(H,U,3)
SET E=""
+17 IF X
SET E=Y/X
+18 SET $PIECE(L,U,11)=Y
SET $PIECE(L,U,12)=X
SET $PIECE(L,U,13)=E*100
+19 SET ANSWX=$EXTRACT(ANSD,4,7)
+20 DO SBW
End DoDot:1
+21 IF ANSSH<1
DO B1
QUIT
+22 QUIT
B1 ;PRINT THE DAILY SUMMARY
+1 SET L=""
SET ANSPTC=ANSPTC+1
+2 IF $DATA(^TMP("ANS",$JOB,ANSD,"T"))
SET L=^("T")
SET X=$PIECE(L,U,11)
SET Y=$PIECE(L,U,12)
SET E=""
IF Y
SET E=X/Y*100
SET $PIECE(L,U,13)=E
+3 IF ANSPO="S"
DO H9^ANSQSP
+4 SET ANSWX=$SELECT(ANSPO="S":"Daily",1:$EXTRACT(ANSD,4,7))
+5 DO SBW
+6 FOR I=1,3:1:13
SET N=$PIECE(L,U,I)
SET A(I)=$GET(A(I))+N
+7 SET N=$PIECE(L,U,2)
+8 IF N>$GET(A(2))
SET A(2)=N
+9 IF ANSPO="S"
WRITE !
+10 QUIT
C1 ;PRINT OUT THE SUMMARY TOTALS FOR ALL DAYS SELECTED
+1 DO H9^ANSQSP
+2 SET L=""
+3 FOR I=1:1:12
SET $PIECE(L,U,I)=$GET(A(I))
+4 SET X=$PIECE(L,U,11)
SET Y=$PIECE(L,U,12)
+5 IF Y
SET E=X/Y*100
SET $PIECE(L,U,13)=E
+6 SET ANSWX="Total"
+7 DO SBW
+8 QUIT
SBW ;WRITE OUT INFO FOR EACH SHIFT AND DAILY SUMMARY
+1 WRITE !,ANSWX," "
+2 IF $DATA(ANSSH)
IF ANSSH
SET X=$TEXT(@ANSNS)
WRITE $PIECE(X,";;",ANSSH+1)
+3 FOR I=1:1:13
SET N=$PIECE(L,U,I)
Begin DoDot:1
+4 SET N=$JUSTIFY(N,1,1)
SET D=$PIECE(N,".",2)
SET N=$PIECE(N,".",1)
+5 DO WRT
End DoDot:1
+6 QUIT
WRT ;WRITE EACH COLUMN OF EACH LINE OF THE REPORT
+1 SET T=$PIECE(ANSTAB,";;",I+1)
SET W=$PIECE(ANSWTH,";;",I+1)
+2 WRITE ?T,"|",$JUSTIFY(N,W)
+3 IF D
WRITE ".",D
+4 IF I=13
IF 'D
WRITE ".0"
+5 QUIT
2 ;;D;;N
3 ;;D;;E;;N