YTSMOC81 ;BAL/KTL - Score MOCA 8.1 ; 10/14/18 2:02pm
;;5.01;MENTAL HEALTH;**249**;Dec 30, 1994;Build 30
;
;
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)
Q
;
SCORESV ; calculate the score
; expects YSDATA from DLLSTR
N YTI,YTRAW,YTCNT,YTCHC,SCORE,YTMIS,YTQ,YTVAL
S (YTRAW,YTCNT,YTMIS)=0
S YTI=2 F S YTI=$O(YSDATA(YTI)) Q:'YTI D
. S YTQ=$P(YSDATA(YTI),U)
. S YTCHC=$P(YSDATA(YTI),U,3)
. I (YTCHC=1155)!(YTCHC=1156)!(YTCHC=1157) Q ; N/A or skipped
. S YTCNT=YTCNT+1
. S YTVAL=$P(^YTT(601.75,YTCHC,0),U,2)
. I YTQ>9423,(YTQ<9429) S YTVAL=$S(YTVAL=3:1,1:0) ;3 scored as 1 in Total
. S YTRAW=YTRAW+YTVAL
. I YTQ>9423,(YTQ<9429) S YTMIS=YTMIS+$P(^YTT(601.75,YTCHC,0),U,2)
I YTCNT=0 S (SCORE,YTMIS)=0 I 1 ; everything skipped or N/A
E S SCORE=YTRAW
;
; 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,1582,0),U,4)_"="_SCORE
S ^TMP($J,"YSCOR",3)=$P(^YTT(601.87,1583,0),U,4)_"="_YTMIS
Q
REPORT(YSDATA) ; build the numerical answer array for the report
; expects ^TMP($J,"YSCOR",...) and ^TMP($J,"YSG") from DLLSTR
; YSDATA from DLLSTR
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HYTSMOC81 1824 printed Dec 13, 2024@02:20:08 Page 2
YTSMOC81 ;BAL/KTL - Score MOCA 8.1 ; 10/14/18 2:02pm
+1 ;;5.01;MENTAL HEALTH;**249**;Dec 30, 1994;Build 30
+2 ;
+3 ;
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)
End DoDot:1
+13 QUIT
+14 ;
SCORESV ; calculate the score
+1 ; expects YSDATA from DLLSTR
+2 NEW YTI,YTRAW,YTCNT,YTCHC,SCORE,YTMIS,YTQ,YTVAL
+3 SET (YTRAW,YTCNT,YTMIS)=0
+4 SET YTI=2
FOR
SET YTI=$ORDER(YSDATA(YTI))
if 'YTI
QUIT
Begin DoDot:1
+5 SET YTQ=$PIECE(YSDATA(YTI),U)
+6 SET YTCHC=$PIECE(YSDATA(YTI),U,3)
+7 ; N/A or skipped
IF (YTCHC=1155)!(YTCHC=1156)!(YTCHC=1157)
QUIT
+8 SET YTCNT=YTCNT+1
+9 SET YTVAL=$PIECE(^YTT(601.75,YTCHC,0),U,2)
+10 ;3 scored as 1 in Total
IF YTQ>9423
IF (YTQ<9429)
SET YTVAL=$SELECT(YTVAL=3:1,1:0)
+11 SET YTRAW=YTRAW+YTVAL
+12 IF YTQ>9423
IF (YTQ<9429)
SET YTMIS=YTMIS+$PIECE(^YTT(601.75,YTCHC,0),U,2)
End DoDot:1
+13 ; everything skipped or N/A
IF YTCNT=0
SET (SCORE,YTMIS)=0
IF 1
+14 IF '$TEST
SET SCORE=YTRAW
+15 ;
+16 ; set scores into ^TMP($J,"YSCOR",n)=scaleId=rawScore^tScore
+17 KILL ^TMP($JOB,"YSCOR")
+18 ;-->out
IF $DATA(^TMP($JOB,"YSG",1))
IF ^TMP($JOB,"YSG",1)="[ERROR]"
Begin DoDot:1
+19 SET ^TMP($JOB,"YSCOR",1)="[ERROR]"
+20 SET ^TMP($JOB,"YSCOR",2)="No Scale found for ADMIN"
End DoDot:1
QUIT
+21 SET ^TMP($JOB,"YSCOR",1)="[DATA]"
+22 SET ^TMP($JOB,"YSCOR",2)=$PIECE(^YTT(601.87,1582,0),U,4)_"="_SCORE
+23 SET ^TMP($JOB,"YSCOR",3)=$PIECE(^YTT(601.87,1583,0),U,4)_"="_YTMIS
+24 QUIT
REPORT(YSDATA) ; build the numerical answer array for the report
+1 ; expects ^TMP($J,"YSCOR",...) and ^TMP($J,"YSG") from DLLSTR
+2 ; YSDATA from DLLSTR
+3 QUIT