YTSBIPF ;SLC/KCM - Score B-IPF ; 10/14/18 2:02pm
;;5.01;MENTAL HEALTH;**177,234**;Dec 30, 1994;Build 38
;
DLLSTR(YSDATA,YS,YSTRNG) ; compute scores or report text based on YSTRNG
; input
; YSDATA(2)=adminId^patientDFN^instrumentName^dateGiven^isComplete
; YSDATA(2+n)=questionId^sequence^choiceId
; YS("AD")=adminId
; YSTRNG=1 for score, 2 for report
; output if YSTRNG=1: ^TMP($J,"YSCOR",n)=scaleId=score
; output if YSTRNG=2: append special "answers" to YSDATA
;
I YSTRNG=1 D SCORESV
I YSTRNG=2 D
. N SCOREVAL,LEVEL,N
. D LDSCORES^YTSCORE(.YSDATA,.YS) ; puts score into ^TMP($J,"YSCOR",2)
. D REPORT(.SCOREVAL,.LEVEL)
. S N=$O(YSDATA(""),-1) ; get last node
. S YSDATA(N+1)="7771^9999;1^"_SCOREVAL
. S YSDATA(N+2)="7772^9999;1^"_LEVEL
Q
;
SCORESV ; calculate the score
; expects YSDATA from DLLSTR
N YTI,YTRAW,YTCNT,YTCHC,SCORE
S YTRAW=0,YTCNT=0
S YTI=2 F S YTI=$O(YSDATA(YTI)) Q:'YTI D
. S YTCHC=$P(YSDATA(YTI),U,3)
. I YTCHC=5226!(YTCHC=1155)!(YTCHC=1156)!(YTCHC=1157) Q ; N/A or skipped
. S YTCNT=YTCNT+1
. S YTRAW=YTRAW+$P(^YTT(601.75,YTCHC,0),U,2)
; score is (raw score / maximum given number answered) * 100
I YTCNT=0 S SCORE="" I 1 ; everything skipped or N/A
E S SCORE=$FN((YTRAW/(YTCNT*6))*100,"",0)
;
; set scores into ^TMP($J,"YSCOR",n)=scaleId=rawScore^tScore
K ^TMP($J,"YSCOR")
I $D(^TMP($J,"YSG",1)),^TMP($J,"YSG",1)="[ERROR]" D Q ;-->out
. S ^TMP($J,"YSCOR",1)="[ERROR]"
. S ^TMP($J,"YSCOR",2)="No Scale found for ADMIN"
S ^TMP($J,"YSCOR",1)="[DATA]"
S ^TMP($J,"YSCOR",2)=$P(^YTT(601.87,1395,0),U,4)_"="_SCORE
Q
REPORT(VAL,LVL) ; build the scoring display for the report
; expects ^TMP($J,"YSCOR",...) and ^TMP($J,"YSG") from DLLSTR
; YSDATA from DLLSTR
S VAL=$P(^TMP($J,"YSCOR",2),"=",2),LVL=""
I VAL="" S LVL="No score" Q
I VAL<11 S LVL="No impairment" Q
I VAL<31 S LVL="Mild impairment" Q
I VAL<51 S LVL="Moderate impairment" Q
I VAL<81 S LVL="Severe impairment" Q
I VAL<101 S LVL="Extreme impairment" Q
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HYTSBIPF 2053 printed Dec 13, 2024@02:19:24 Page 2
YTSBIPF ;SLC/KCM - Score B-IPF ; 10/14/18 2:02pm
+1 ;;5.01;MENTAL HEALTH;**177,234**;Dec 30, 1994;Build 38
+2 ;
DLLSTR(YSDATA,YS,YSTRNG) ; compute scores or report text based on YSTRNG
+1 ; input
+2 ; YSDATA(2)=adminId^patientDFN^instrumentName^dateGiven^isComplete
+3 ; YSDATA(2+n)=questionId^sequence^choiceId
+4 ; YS("AD")=adminId
+5 ; YSTRNG=1 for score, 2 for report
+6 ; output if YSTRNG=1: ^TMP($J,"YSCOR",n)=scaleId=score
+7 ; output if YSTRNG=2: append special "answers" to YSDATA
+8 ;
+9 IF YSTRNG=1
DO SCORESV
+10 IF YSTRNG=2
Begin DoDot:1
+11 NEW SCOREVAL,LEVEL,N
+12 ; puts score into ^TMP($J,"YSCOR",2)
DO LDSCORES^YTSCORE(.YSDATA,.YS)
+13 DO REPORT(.SCOREVAL,.LEVEL)
+14 ; get last node
SET N=$ORDER(YSDATA(""),-1)
+15 SET YSDATA(N+1)="7771^9999;1^"_SCOREVAL
+16 SET YSDATA(N+2)="7772^9999;1^"_LEVEL
End DoDot:1
+17 QUIT
+18 ;
SCORESV ; calculate the score
+1 ; expects YSDATA from DLLSTR
+2 NEW YTI,YTRAW,YTCNT,YTCHC,SCORE
+3 SET YTRAW=0
SET YTCNT=0
+4 SET YTI=2
FOR
SET YTI=$ORDER(YSDATA(YTI))
if 'YTI
QUIT
Begin DoDot:1
+5 SET YTCHC=$PIECE(YSDATA(YTI),U,3)
+6 ; N/A or skipped
IF YTCHC=5226!(YTCHC=1155)!(YTCHC=1156)!(YTCHC=1157)
QUIT
+7 SET YTCNT=YTCNT+1
+8 SET YTRAW=YTRAW+$PIECE(^YTT(601.75,YTCHC,0),U,2)
End DoDot:1
+9 ; score is (raw score / maximum given number answered) * 100
+10 ; everything skipped or N/A
IF YTCNT=0
SET SCORE=""
IF 1
+11 IF '$TEST
SET SCORE=$FNUMBER((YTRAW/(YTCNT*6))*100,"",0)
+12 ;
+13 ; set scores into ^TMP($J,"YSCOR",n)=scaleId=rawScore^tScore
+14 KILL ^TMP($JOB,"YSCOR")
+15 ;-->out
IF $DATA(^TMP($JOB,"YSG",1))
IF ^TMP($JOB,"YSG",1)="[ERROR]"
Begin DoDot:1
+16 SET ^TMP($JOB,"YSCOR",1)="[ERROR]"
+17 SET ^TMP($JOB,"YSCOR",2)="No Scale found for ADMIN"
End DoDot:1
QUIT
+18 SET ^TMP($JOB,"YSCOR",1)="[DATA]"
+19 SET ^TMP($JOB,"YSCOR",2)=$PIECE(^YTT(601.87,1395,0),U,4)_"="_SCORE
+20 QUIT
REPORT(VAL,LVL) ; build the scoring display for the report
+1 ; expects ^TMP($J,"YSCOR",...) and ^TMP($J,"YSG") from DLLSTR
+2 ; YSDATA from DLLSTR
+3 SET VAL=$PIECE(^TMP($JOB,"YSCOR",2),"=",2)
SET LVL=""
+4 IF VAL=""
SET LVL="No score"
QUIT
+5 IF VAL<11
SET LVL="No impairment"
QUIT
+6 IF VAL<31
SET LVL="Mild impairment"
QUIT
+7 IF VAL<51
SET LVL="Moderate impairment"
QUIT
+8 IF VAL<81
SET LVL="Severe impairment"
QUIT
+9 IF VAL<101
SET LVL="Extreme impairment"
QUIT
+10 QUIT