ANSQSS1 ;IHS/OIRM/DSD/CSC - CALCULATE NURSE STAFFING STATS; [ 02/25/98 10:32 AM ]
;;3.0;NURSING PATIENT ACUITY;;APR 01, 1996
;;CALCULATE NURSE STAFFING TOTALS FOR EACH DAY
;;"A" NODE OF GLOBAL IS INFO ON EACH ADMISSION
;;"O" NODE IS INFOR ON EACH OBSERVATION
EN I '$D(ANSPAR) S ANSPAR=^ANSD(51,1,0)
D PERCENT
S ANSD=0
F S ANSD=$O(^TMP("ANS",$J,ANSD)) Q:'ANSD D
.S ANSSH=0,(ANSTOT,ANSMAX)=""
.F S ANSSH=$O(^TMP("ANS",$J,ANSD,ANSSH)) Q:'ANSSH D
..S (ANSAS,ANSCL,ANSRT)=""
..S:$D(^TMP("ANS",$J,ANSD,ANSSH,"A")) ANSAS=^("A")
..S:$D(^TMP("ANS",$J,ANSD,ANSSH,"O")) ANSCL=^("O")
..S T=0
..F L=1:1:6 S N=$P(ANSCL,U,L) D:N
...D:$D(ANSP(ANSSH)) SBRTL
...S $P(ANSTOT,U,L+4)=$P(ANSTOT,U,L+4)+N,T=T+N
..I T>ANSMAX S ANSMAX=T
..S N=$P(ANSCL,U,5)
..I N S ANSRT=ANSRT+(N*.5),$P(ANSTOT,U,4)=$P(ANSTOT,U,4)+N
..S T=0
..F L=1:1:6 S N=$P(ANSAS,U,L) I N D SBRTA S T=T+N
..S A=ANSRT,S="H",P=3 D SBADD
..S $P(ANSTOT,U,3)=$P(ANSTOT,U,3)+T,$P(ANSTOT,U,11)=$P(ANSTOT,U,11)+ANSRT
.D B1
D C1
Q
B1 ;SET DAILY TOTAL AND SET GLOBAL NODE WITH TOTAL SUMMARY FOR THE DAY
S $P(ANSTOT,U,2)=ANSMAX,T=0
F I=5:1:10 S T=T+$P(ANSTOT,U,I),$P(ANSTOT,U,I)=$P(ANSTOT,U,I)/ANSNS
S $P(ANSTOT,U)=T/ANSNS,T=0
F I=1:1:3 I $D(^TMP("ANS",$J,ANSD,I,"H")) S T=T+$P(^("H"),U)-$P(^("H"),U,2)
S $P(ANSTOT,U,12)=T,^TMP("ANS",$J,ANSD,"T")=ANSTOT
Q
C1 D ^ANSQSP
Q
SBRTL ;CALCULATE THE REQUIRED NURSING TIME FOR EACH LEVEL OF CARE
;ANSP(ANSSH) = PERCENT OF CARE REQUIRED FOR THE SHIFT
;ANSH(L) = HOURS OF CARE REQUIRED BY LEVEL OF CARE FOR THE DAY
;N = NUMBER OF PATIENTS AT THE CARE LEVEL
S H=ANSP(ANSSH)*ANSH(L)*N,ANSRT=ANSRT+H
Q
SBRTA ;CALCULATE THE NUMBER OF HOURS OF NURSING TIME REQUIRED FOR ADMISSIONS
;ANSA(L) = HOURS REQUIRED FOR ADMISSION FOR EACH CARE LEVEL
;N = NUMBER OF PATIENTS AT THE CARE LEVEL
S H=ANSA(L)*N,ANSRT=ANSRT+H
Q
SBADD ;SET TEMP GLOBAL NODES FOR PRINTOUT
I '$D(^TMP("ANS",$J,ANSD,ANSSH,S)) S ^TMP("ANS",$J,ANSD,ANSSH,S)=""
S $P(^TMP("ANS",$J,ANSD,ANSSH,S),U,P)=$P(^TMP("ANS",$J,ANSD,ANSSH,S),U,P)+A,ANSRT=$P(^(S),U,P)
Q
PERCENT ;CALCULATE THE PERCENT OF TIME REQUIRED PER SHIFT
;ANSNS = NUMBER OF SHIFTS
K ANSP
S ANSNS=$P(ANSPAR,U,5),X=""
S X=$G(^ANSD(51.1,ANSNS,1))
F I=1:1:ANSNS S ANSP(I)=$P(X,U,I)/100
Q
ANSQSS1 ;IHS/OIRM/DSD/CSC - CALCULATE NURSE STAFFING STATS; [ 02/25/98 10:32 AM ]
+1 ;;3.0;NURSING PATIENT ACUITY;;APR 01, 1996
+2 ;;CALCULATE NURSE STAFFING TOTALS FOR EACH DAY
+3 ;;"A" NODE OF GLOBAL IS INFO ON EACH ADMISSION
+4 ;;"O" NODE IS INFOR ON EACH OBSERVATION
EN IF '$DATA(ANSPAR)
SET ANSPAR=^ANSD(51,1,0)
+1 DO PERCENT
+2 SET ANSD=0
+3 FOR
SET ANSD=$ORDER(^TMP("ANS",$JOB,ANSD))
IF 'ANSD
QUIT
Begin DoDot:1
+4 SET ANSSH=0
SET (ANSTOT,ANSMAX)=""
+5 FOR
SET ANSSH=$ORDER(^TMP("ANS",$JOB,ANSD,ANSSH))
IF 'ANSSH
QUIT
Begin DoDot:2
+6 SET (ANSAS,ANSCL,ANSRT)=""
+7 IF $DATA(^TMP("ANS",$JOB,ANSD,ANSSH,"A"))
SET ANSAS=^("A")
+8 IF $DATA(^TMP("ANS",$JOB,ANSD,ANSSH,"O"))
SET ANSCL=^("O")
+9 SET T=0
+10 FOR L=1:1:6
SET N=$PIECE(ANSCL,U,L)
IF N
Begin DoDot:3
+11 IF $DATA(ANSP(ANSSH))
DO SBRTL
+12 SET $PIECE(ANSTOT,U,L+4)=$PIECE(ANSTOT,U,L+4)+N
SET T=T+N
End DoDot:3
+13 IF T>ANSMAX
SET ANSMAX=T
+14 SET N=$PIECE(ANSCL,U,5)
+15 IF N
SET ANSRT=ANSRT+(N*.5)
SET $PIECE(ANSTOT,U,4)=$PIECE(ANSTOT,U,4)+N
+16 SET T=0
+17 FOR L=1:1:6
SET N=$PIECE(ANSAS,U,L)
IF N
DO SBRTA
SET T=T+N
+18 SET A=ANSRT
SET S="H"
SET P=3
DO SBADD
+19 SET $PIECE(ANSTOT,U,3)=$PIECE(ANSTOT,U,3)+T
SET $PIECE(ANSTOT,U,11)=$PIECE(ANSTOT,U,11)+ANSRT
End DoDot:2
+20 DO B1
End DoDot:1
+21 DO C1
+22 QUIT
B1 ;SET DAILY TOTAL AND SET GLOBAL NODE WITH TOTAL SUMMARY FOR THE DAY
+1 SET $PIECE(ANSTOT,U,2)=ANSMAX
SET T=0
+2 FOR I=5:1:10
SET T=T+$PIECE(ANSTOT,U,I)
SET $PIECE(ANSTOT,U,I)=$PIECE(ANSTOT,U,I)/ANSNS
+3 SET $PIECE(ANSTOT,U)=T/ANSNS
SET T=0
+4 FOR I=1:1:3
IF $DATA(^TMP("ANS",$JOB,ANSD,I,"H"))
SET T=T+$PIECE(^("H"),U)-$PIECE(^("H"),U,2)
+5 SET $PIECE(ANSTOT,U,12)=T
SET ^TMP("ANS",$JOB,ANSD,"T")=ANSTOT
+6 QUIT
C1 DO ^ANSQSP
+1 QUIT
SBRTL ;CALCULATE THE REQUIRED NURSING TIME FOR EACH LEVEL OF CARE
+1 ;ANSP(ANSSH) = PERCENT OF CARE REQUIRED FOR THE SHIFT
+2 ;ANSH(L) = HOURS OF CARE REQUIRED BY LEVEL OF CARE FOR THE DAY
+3 ;N = NUMBER OF PATIENTS AT THE CARE LEVEL
+4 SET H=ANSP(ANSSH)*ANSH(L)*N
SET ANSRT=ANSRT+H
+5 QUIT
SBRTA ;CALCULATE THE NUMBER OF HOURS OF NURSING TIME REQUIRED FOR ADMISSIONS
+1 ;ANSA(L) = HOURS REQUIRED FOR ADMISSION FOR EACH CARE LEVEL
+2 ;N = NUMBER OF PATIENTS AT THE CARE LEVEL
+3 SET H=ANSA(L)*N
SET ANSRT=ANSRT+H
+4 QUIT
SBADD ;SET TEMP GLOBAL NODES FOR PRINTOUT
+1 IF '$DATA(^TMP("ANS",$JOB,ANSD,ANSSH,S))
SET ^TMP("ANS",$JOB,ANSD,ANSSH,S)=""
+2 SET $PIECE(^TMP("ANS",$JOB,ANSD,ANSSH,S),U,P)=$PIECE(^TMP("ANS",$JOB,ANSD,ANSSH,S),U,P)+A
SET ANSRT=$PIECE(^(S),U,P)
+3 QUIT
PERCENT ;CALCULATE THE PERCENT OF TIME REQUIRED PER SHIFT
+1 ;ANSNS = NUMBER OF SHIFTS
+2 KILL ANSP
+3 SET ANSNS=$PIECE(ANSPAR,U,5)
SET X=""
+4 SET X=$GET(^ANSD(51.1,ANSNS,1))
+5 FOR I=1:1:ANSNS
SET ANSP(I)=$PIECE(X,U,I)/100
+6 QUIT