YTSEQ5D ;SLC/KCM - Score EQ-5D-5L ; 3/25/22 2:02pm
;;5.01;MENTAL HEALTH;**233**;Dec 30, 1994;Build 13
;
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 Q
I YSTRNG=2 D
. N SCORES,STATE,N
. D LDSCORES^YTSCORE(.YSDATA,.YS) ; puts score into ^TMP($J,"YSCOR",2)
. D REPORT(.STATE)
. S N=$O(YSDATA(""),-1) ; get last node
. S YSDATA(N+1)="7771^9999;1^"_STATE
Q
SCORESV ; calculate the score
; expects YSDATA from DLLSTR (YSDATA from LOADANSW^YTSCORE,SCALEG^YTQAPI3)
N QSTN,MOBILE,SELFCARE,ACTIVITY,PAIN,ANXIETY,EQVAS
D BLDQSTN(.QSTN)
S MOBILE=$G(QSTN(9049))
S SELFCARE=$G(QSTN(9050))
S ACTIVITY=$G(QSTN(9051))
S PAIN=$G(QSTN(9052))
S ANXIETY=$G(QSTN(9053))
S EQVAS=$G(QSTN(9054))
;
; set scores into ^TMP($J,"YSCOR",n)=scaleName=score {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"
;
N I,J,SCLID,SCLNM
S ^TMP($J,"YSCOR",1)="[DATA]"
S I=2,J=1 F S I=$O(^TMP($J,"YSG",I)) Q:'I D
. S SCLID=+$P(^TMP($J,"YSG",I),"=",2)
. S SCLNM=$P(^TMP($J,"YSG",I),U,4)
. S J=J+1
. I SCLID=1486 S ^TMP($J,"YSCOR",J)=SCLNM_"="_MOBILE
. I SCLID=1487 S ^TMP($J,"YSCOR",J)=SCLNM_"="_SELFCARE
. I SCLID=1488 S ^TMP($J,"YSCOR",J)=SCLNM_"="_ACTIVITY
. I SCLID=1489 S ^TMP($J,"YSCOR",J)=SCLNM_"="_PAIN
. I SCLID=1490 S ^TMP($J,"YSCOR",J)=SCLNM_"="_ANXIETY
. I SCLID=1491 S ^TMP($J,"YSCOR",J)=SCLNM_"="_EQVAS
Q
BLDQSTN(QSTN) ; build list of questions and response values in .QSTN
; expects YSDATA from DLLSTR
N I,CID,QID
S I=2 F S I=$O(YSDATA(I)) Q:'I D
. S CID=$P(YSDATA(I),U,3),QID=$P(YSDATA(I),U)
. I CID=1155!(CID=1156)!(CID=1157) Q ; don't include skipped questions
. I $P($G(^YTT(601.72,QID,2)),U,2)'=1 D QUIT
. . S QSTN(QID)=$G(QSTN(QID))_$P(YSDATA(I),U,3)
. S QSTN(QID)=$P($G(^YTT(601.75,CID,0)),U,2)
Q
;
REPORT(STATE) ; Build EQ-5D-5L score string
N I,NAME,VALUE,MOBILE,SELFCARE,ACTIVITY,PAIN,ANXIETY,X,SKIP
S I=0 F S I=$O(^TMP($J,"YSCOR",I)) Q:'I D
. S NAME=$P(^TMP($J,"YSCOR",I),"=")
. S VALUE=$P(^TMP($J,"YSCOR",I),"=",2)
. I NAME="Mobility" S MOBILE=VALUE
. I NAME="Self-Care" S SELFCARE=VALUE
. I NAME="Activities" S ACTIVITY=VALUE
. I NAME="Pain" S PAIN=VALUE
. I NAME="Anxiety" S ANXIETY=VALUE
S X="",SKIP="_"
S X=X_$S(+$G(MOBILE):MOBILE,1:SKIP)
S X=X_$S(+$G(SELFCARE):SELFCARE,1:SKIP)
S X=X_$S(+$G(ACTIVITY):ACTIVITY,1:SKIP)
S X=X_$S(+$G(PAIN):PAIN,1:SKIP)
S X=X_$S(+$G(ANXIETY):ANXIETY,1:SKIP)
S STATE=X
Q
TESTSCR(YSAD) ; Test scoring routine
N YS,YSDATA
S YS("AD")=YSAD,YS("CODE")="EQ-5D-5L"
D LOADANSW^YTSCORE(.YSDATA,.YS)
D SCALEG^YTQAPI3(.YSDATA,.YS)
D DLLSTR(.YSDATA,.YS,1)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HYTSEQ5D 3114 printed Oct 16, 2024@18:20:28 Page 2
YTSEQ5D ;SLC/KCM - Score EQ-5D-5L ; 3/25/22 2:02pm
+1 ;;5.01;MENTAL HEALTH;**233**;Dec 30, 1994;Build 13
+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
QUIT
+10 IF YSTRNG=2
Begin DoDot:1
+11 NEW SCORES,STATE,N
+12 ; puts score into ^TMP($J,"YSCOR",2)
DO LDSCORES^YTSCORE(.YSDATA,.YS)
+13 DO REPORT(.STATE)
+14 ; get last node
SET N=$ORDER(YSDATA(""),-1)
+15 SET YSDATA(N+1)="7771^9999;1^"_STATE
End DoDot:1
+16 QUIT
SCORESV ; calculate the score
+1 ; expects YSDATA from DLLSTR (YSDATA from LOADANSW^YTSCORE,SCALEG^YTQAPI3)
+2 NEW QSTN,MOBILE,SELFCARE,ACTIVITY,PAIN,ANXIETY,EQVAS
+3 DO BLDQSTN(.QSTN)
+4 SET MOBILE=$GET(QSTN(9049))
+5 SET SELFCARE=$GET(QSTN(9050))
+6 SET ACTIVITY=$GET(QSTN(9051))
+7 SET PAIN=$GET(QSTN(9052))
+8 SET ANXIETY=$GET(QSTN(9053))
+9 SET EQVAS=$GET(QSTN(9054))
+10 ;
+11 ; set scores into ^TMP($J,"YSCOR",n)=scaleName=score {rawScore^tScore}
+12 KILL ^TMP($JOB,"YSCOR")
+13 ;-->out
IF $DATA(^TMP($JOB,"YSG",1))
IF ^TMP($JOB,"YSG",1)="[ERROR]"
Begin DoDot:1
+14 SET ^TMP($JOB,"YSCOR",1)="[ERROR]"
+15 SET ^TMP($JOB,"YSCOR",2)="No Scale found for ADMIN"
End DoDot:1
QUIT
+16 ;
+17 NEW I,J,SCLID,SCLNM
+18 SET ^TMP($JOB,"YSCOR",1)="[DATA]"
+19 SET I=2
SET J=1
FOR
SET I=$ORDER(^TMP($JOB,"YSG",I))
if 'I
QUIT
Begin DoDot:1
+20 SET SCLID=+$PIECE(^TMP($JOB,"YSG",I),"=",2)
+21 SET SCLNM=$PIECE(^TMP($JOB,"YSG",I),U,4)
+22 SET J=J+1
+23 IF SCLID=1486
SET ^TMP($JOB,"YSCOR",J)=SCLNM_"="_MOBILE
+24 IF SCLID=1487
SET ^TMP($JOB,"YSCOR",J)=SCLNM_"="_SELFCARE
+25 IF SCLID=1488
SET ^TMP($JOB,"YSCOR",J)=SCLNM_"="_ACTIVITY
+26 IF SCLID=1489
SET ^TMP($JOB,"YSCOR",J)=SCLNM_"="_PAIN
+27 IF SCLID=1490
SET ^TMP($JOB,"YSCOR",J)=SCLNM_"="_ANXIETY
+28 IF SCLID=1491
SET ^TMP($JOB,"YSCOR",J)=SCLNM_"="_EQVAS
End DoDot:1
+29 QUIT
BLDQSTN(QSTN) ; build list of questions and response values in .QSTN
+1 ; expects YSDATA from DLLSTR
+2 NEW I,CID,QID
+3 SET I=2
FOR
SET I=$ORDER(YSDATA(I))
if 'I
QUIT
Begin DoDot:1
+4 SET CID=$PIECE(YSDATA(I),U,3)
SET QID=$PIECE(YSDATA(I),U)
+5 ; don't include skipped questions
IF CID=1155!(CID=1156)!(CID=1157)
QUIT
+6 IF $PIECE($GET(^YTT(601.72,QID,2)),U,2)'=1
Begin DoDot:2
+7 SET QSTN(QID)=$GET(QSTN(QID))_$PIECE(YSDATA(I),U,3)
End DoDot:2
QUIT
+8 SET QSTN(QID)=$PIECE($GET(^YTT(601.75,CID,0)),U,2)
End DoDot:1
+9 QUIT
+10 ;
REPORT(STATE) ; Build EQ-5D-5L score string
+1 NEW I,NAME,VALUE,MOBILE,SELFCARE,ACTIVITY,PAIN,ANXIETY,X,SKIP
+2 SET I=0
FOR
SET I=$ORDER(^TMP($JOB,"YSCOR",I))
if 'I
QUIT
Begin DoDot:1
+3 SET NAME=$PIECE(^TMP($JOB,"YSCOR",I),"=")
+4 SET VALUE=$PIECE(^TMP($JOB,"YSCOR",I),"=",2)
+5 IF NAME="Mobility"
SET MOBILE=VALUE
+6 IF NAME="Self-Care"
SET SELFCARE=VALUE
+7 IF NAME="Activities"
SET ACTIVITY=VALUE
+8 IF NAME="Pain"
SET PAIN=VALUE
+9 IF NAME="Anxiety"
SET ANXIETY=VALUE
End DoDot:1
+10 SET X=""
SET SKIP="_"
+11 SET X=X_$SELECT(+$GET(MOBILE):MOBILE,1:SKIP)
+12 SET X=X_$SELECT(+$GET(SELFCARE):SELFCARE,1:SKIP)
+13 SET X=X_$SELECT(+$GET(ACTIVITY):ACTIVITY,1:SKIP)
+14 SET X=X_$SELECT(+$GET(PAIN):PAIN,1:SKIP)
+15 SET X=X_$SELECT(+$GET(ANXIETY):ANXIETY,1:SKIP)
+16 SET STATE=X
+17 QUIT
TESTSCR(YSAD) ; Test scoring routine
+1 NEW YS,YSDATA
+2 SET YS("AD")=YSAD
SET YS("CODE")="EQ-5D-5L"
+3 DO LOADANSW^YTSCORE(.YSDATA,.YS)
+4 DO SCALEG^YTQAPI3(.YSDATA,.YS)
+5 DO DLLSTR(.YSDATA,.YS,1)
+6 QUIT