YTSPSEQ2 ;SLC/KCM - Score PSEQ-2 ; 3/25/22 2:02pm
;;5.01;MENTAL HEALTH;**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 SCORES,N
. D LDSCORES^YTSCORE(.YSDATA,.YS) ; puts score into ^TMP($J,"YSCOR",2)
. D REPORT(.SCORE)
. S N=$O(YSDATA(""),-1) ; get last node
. S YSDATA(N+1)="7771^9999;1^"_SCORE
Q
;
SCORESV ; calculate the score
; expects YSDATA from DLLSTR (YSDATA from LOADANSW^YTSCORE,SCALEG^YTQAPI3)
N I,QID,SKIP,TOTAL
S (SKIP,TOTAL)=""
S I=2 F S I=$O(YSDATA(I)) Q:'I D
. S QID=$P(YSDATA(I),U),VAL=$P(YSDATA(I),U,3)
. I VAL=1155!(VAL=1156)!(VAL=1157) S SKIP=1 QUIT
. S TOTAL=TOTAL+VAL
I SKIP S TOTAL=""
;
; 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 SCLID,SCLNM,J
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=1547 S ^TMP($J,"YSCOR",J)=SCLNM_"="_TOTAL
Q
REPORT(SCORE) ; build .SCORE string
; expects score in ^TMP($J,"YSCOR",n)
N I,NAME,VAL
S I=0 F S I=$O(^TMP($J,"YSCOR",I)) Q:'I D
. S NAME=$P(^TMP($J,"YSCOR",I),"=")
. S VAL=$P(^TMP($J,"YSCOR",I),"=",2)
I NAME="Total" S SCORE=$S(VAL="":"Cannot score due to skipped questions",1:VAL)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HYTSPSEQ2 1856 printed Nov 22, 2024@17:30:41 Page 2
YTSPSEQ2 ;SLC/KCM - Score PSEQ-2 ; 3/25/22 2:02pm
+1 ;;5.01;MENTAL HEALTH;**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 SCORES,N
+12 ; puts score into ^TMP($J,"YSCOR",2)
DO LDSCORES^YTSCORE(.YSDATA,.YS)
+13 DO REPORT(.SCORE)
+14 ; get last node
SET N=$ORDER(YSDATA(""),-1)
+15 SET YSDATA(N+1)="7771^9999;1^"_SCORE
End DoDot:1
+16 QUIT
+17 ;
SCORESV ; calculate the score
+1 ; expects YSDATA from DLLSTR (YSDATA from LOADANSW^YTSCORE,SCALEG^YTQAPI3)
+2 NEW I,QID,SKIP,TOTAL
+3 SET (SKIP,TOTAL)=""
+4 SET I=2
FOR
SET I=$ORDER(YSDATA(I))
if 'I
QUIT
Begin DoDot:1
+5 SET QID=$PIECE(YSDATA(I),U)
SET VAL=$PIECE(YSDATA(I),U,3)
+6 IF VAL=1155!(VAL=1156)!(VAL=1157)
SET SKIP=1
QUIT
+7 SET TOTAL=TOTAL+VAL
End DoDot:1
+8 IF SKIP
SET TOTAL=""
+9 ;
+10 ; set scores into ^TMP($J,"YSCOR",n)=scaleName=score {rawScore^tScore}
+11 KILL ^TMP($JOB,"YSCOR")
+12 ;-->out
IF $DATA(^TMP($JOB,"YSG",1))
IF ^TMP($JOB,"YSG",1)="[ERROR]"
Begin DoDot:1
+13 SET ^TMP($JOB,"YSCOR",1)="[ERROR]"
+14 SET ^TMP($JOB,"YSCOR",2)="No Scale found for ADMIN"
End DoDot:1
QUIT
+15 ;
+16 NEW SCLID,SCLNM,J
+17 SET ^TMP($JOB,"YSCOR",1)="[DATA]"
+18 SET I=2
SET J=1
FOR
SET I=$ORDER(^TMP($JOB,"YSG",I))
if 'I
QUIT
Begin DoDot:1
+19 SET SCLID=+$PIECE(^TMP($JOB,"YSG",I),"=",2)
+20 SET SCLNM=$PIECE(^TMP($JOB,"YSG",I),U,4)
+21 SET J=J+1
+22 IF SCLID=1547
SET ^TMP($JOB,"YSCOR",J)=SCLNM_"="_TOTAL
End DoDot:1
+23 QUIT
REPORT(SCORE) ; build .SCORE string
+1 ; expects score in ^TMP($J,"YSCOR",n)
+2 NEW I,NAME,VAL
+3 SET I=0
FOR
SET I=$ORDER(^TMP($JOB,"YSCOR",I))
if 'I
QUIT
Begin DoDot:1
+4 SET NAME=$PIECE(^TMP($JOB,"YSCOR",I),"=")
+5 SET VAL=$PIECE(^TMP($JOB,"YSCOR",I),"=",2)
End DoDot:1
+6 IF NAME="Total"
SET SCORE=$SELECT(VAL="":"Cannot score due to skipped questions",1:VAL)
+7 QUIT