YTSMINIC ;SLC/PIJ - Score MINI COG ; 01/08/2016
;;5.01;MENTAL HEALTH;**123,234,249**;DEC 30,1994;Build 30
;
;Public, Supported ICRs
; #2056 - Fileman API - $$GET1^DIQ
;
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 $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
SUM(QSTN,LIST) ; return sum for questions in LIST
N I,QID,SUM
S SUM=0 F I=1:1:$L(LIST,",") S QID=$P(LIST,",",I) D
. I QID=5536,(QSTN(5536)>0) S SUM=SUM+2 QUIT ; clock drawing correct
. I $G(QSTN(QID)) S SUM=SUM+QSTN(QID) ; everything else
Q SUM
;
SKIPCNT(QSTN,LIST) ; return the number of skipped questions
N I,QID,SKIP
S SKIP=0 F I=1:1:$L(LIST,",") S QID=$P(LIST,",",I) D
. I $G(QSTN(QID)),(QSTN(QID)="X") S SKIP=SKIP+1
Q SKIP
;
SCORESV ; Used for Graph and Table
I $D(^TMP($J,"YSG",1)),^TMP($J,"YSG",1)="[ERROR]" D Q ;-->out
.K ^TMP($J,"YSCOR")
.S ^TMP($J,"YSCOR",1)="[ERROR]"
.S ^TMP($J,"YSCOR",2)="Mini-Cog Scale not found"
;
K ^TMP($J,"YSCOR")
S ^TMP($J,"YSCOR",1)="[DATA]"
S ^TMP($J,"YSCOR",2)=$$GET1^DIQ(601.87,624_",",3,"I")_"="_TOTAL
Q
;
REPORT(TOTAL,QSTN,STXT,BODY) ; build report body
S STXT=TOTAL
I TOTAL="" S STXT="Too many items were skipped to score this administration."
I (TOTAL>2) S STXT=STXT_" Negative screen for dementia."
I (+TOTAL=TOTAL),(TOTAL<3) S STXT=STXT_" Positive for cognitive impairment"
S STXT="|Mini-Cog Results: "_STXT
S BODY=""
S BODY=BODY_"|Clock Drawing: "_$$ATXT($G(QSTN(5536)))
S BODY=BODY_"|Recall of FIRST WORD: "_$$ATXT($G(QSTN(5537)))
S BODY=BODY_"|Recall of SECOND WORD: "_$$ATXT($G(QSTN(5538)))
S BODY=BODY_"|Recall of THIRD WORD: "_$$ATXT($G(QSTN(5539)))_"|"
S BODY=BODY_"|Word List Version: "_$$WLVER($G(QSTN(9172),0))
I $D(QSTN(9173)),("^1155^1156^1157^"'[(U_QSTN(9173)_U)) S BODY=BODY_"|Person's Answers: "_QSTN(9173)
Q
ATXT(VALUE) ; return text answer for value
I VALUE="X" Q "SKIPPED"
I VALUE=1 Q "Correct"
I VALUE=0 Q "Incorrect"
Q ""
;
WLVER(AVER) ; return word list version and words
I AVER=0 Q "0 (Apple, Watch, Penny)"
I AVER=1 Q "1 (Banana, Sunrise, Chair)"
I AVER=2 Q "2 (Leader, Season, Table)"
I AVER=3 Q "3 (Village, Kitchen, Baby)"
I AVER=4 Q "4 (River, Nation, Finger)"
I AVER=5 Q "5 (Captain, Garden, Picture)"
I AVER=6 Q "6 (Daughter, Heaven, Mountain)"
Q "SKIPPED"
;
DLLSTR(YSDATA,YS,YSTRNG) ;
N QSTN,TOTAL,SKIPS
D BLDQSTN(.QSTN)
S TOTAL=$$SUM(.QSTN,"5536,5537,5538,5539")
S SKIPS=$$SKIPCNT(.QSTN,"5536,5537,5538,5539")
I SKIPS>0 S TOTAL=""
I YSTRNG=1 D SCORESV
I YSTRNG=2 D
. N N,SCORE,QANDA
. D REPORT(TOTAL,.QSTN,.SCORE,.QANDA)
. S N=$O(YSDATA(""),-1) ; get last node
. S YSDATA(N+1)="7771^9999;1^"_SCORE
. S YSDATA(N+2)="7772^9999;1^"_QANDA
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HYTSMINIC 3011 printed Oct 16, 2024@18:20:47 Page 2
YTSMINIC ;SLC/PIJ - Score MINI COG ; 01/08/2016
+1 ;;5.01;MENTAL HEALTH;**123,234,249**;DEC 30,1994;Build 30
+2 ;
+3 ;Public, Supported ICRs
+4 ; #2056 - Fileman API - $$GET1^DIQ
+5 ;
+6 QUIT
+7 ;
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 IF $PIECE($GET(^YTT(601.72,QID,2)),U,2)'=1
Begin DoDot:2
+6 SET QSTN(QID)=$GET(QSTN(QID))_$PIECE(YSDATA(I),U,3)
End DoDot:2
QUIT
+7 SET QSTN(QID)=$PIECE($GET(^YTT(601.75,CID,0)),U,2)
End DoDot:1
+8 QUIT
SUM(QSTN,LIST) ; return sum for questions in LIST
+1 NEW I,QID,SUM
+2 SET SUM=0
FOR I=1:1:$LENGTH(LIST,",")
SET QID=$PIECE(LIST,",",I)
Begin DoDot:1
+3 ; clock drawing correct
IF QID=5536
IF (QSTN(5536)>0)
SET SUM=SUM+2
QUIT
+4 ; everything else
IF $GET(QSTN(QID))
SET SUM=SUM+QSTN(QID)
End DoDot:1
+5 QUIT SUM
+6 ;
SKIPCNT(QSTN,LIST) ; return the number of skipped questions
+1 NEW I,QID,SKIP
+2 SET SKIP=0
FOR I=1:1:$LENGTH(LIST,",")
SET QID=$PIECE(LIST,",",I)
Begin DoDot:1
+3 IF $GET(QSTN(QID))
IF (QSTN(QID)="X")
SET SKIP=SKIP+1
End DoDot:1
+4 QUIT SKIP
+5 ;
SCORESV ; Used for Graph and Table
+1 ;-->out
IF $DATA(^TMP($JOB,"YSG",1))
IF ^TMP($JOB,"YSG",1)="[ERROR]"
Begin DoDot:1
+2 KILL ^TMP($JOB,"YSCOR")
+3 SET ^TMP($JOB,"YSCOR",1)="[ERROR]"
+4 SET ^TMP($JOB,"YSCOR",2)="Mini-Cog Scale not found"
End DoDot:1
QUIT
+5 ;
+6 KILL ^TMP($JOB,"YSCOR")
+7 SET ^TMP($JOB,"YSCOR",1)="[DATA]"
+8 SET ^TMP($JOB,"YSCOR",2)=$$GET1^DIQ(601.87,624_",",3,"I")_"="_TOTAL
+9 QUIT
+10 ;
REPORT(TOTAL,QSTN,STXT,BODY) ; build report body
+1 SET STXT=TOTAL
+2 IF TOTAL=""
SET STXT="Too many items were skipped to score this administration."
+3 IF (TOTAL>2)
SET STXT=STXT_" Negative screen for dementia."
+4 IF (+TOTAL=TOTAL)
IF (TOTAL<3)
SET STXT=STXT_" Positive for cognitive impairment"
+5 SET STXT="|Mini-Cog Results: "_STXT
+6 SET BODY=""
+7 SET BODY=BODY_"|Clock Drawing: "_$$ATXT($GET(QSTN(5536)))
+8 SET BODY=BODY_"|Recall of FIRST WORD: "_$$ATXT($GET(QSTN(5537)))
+9 SET BODY=BODY_"|Recall of SECOND WORD: "_$$ATXT($GET(QSTN(5538)))
+10 SET BODY=BODY_"|Recall of THIRD WORD: "_$$ATXT($GET(QSTN(5539)))_"|"
+11 SET BODY=BODY_"|Word List Version: "_$$WLVER($GET(QSTN(9172),0))
+12 IF $DATA(QSTN(9173))
IF ("^1155^1156^1157^"'[(U_QSTN(9173)_U))
SET BODY=BODY_"|Person's Answers: "_QSTN(9173)
+13 QUIT
ATXT(VALUE) ; return text answer for value
+1 IF VALUE="X"
QUIT "SKIPPED"
+2 IF VALUE=1
QUIT "Correct"
+3 IF VALUE=0
QUIT "Incorrect"
+4 QUIT ""
+5 ;
WLVER(AVER) ; return word list version and words
+1 IF AVER=0
QUIT "0 (Apple, Watch, Penny)"
+2 IF AVER=1
QUIT "1 (Banana, Sunrise, Chair)"
+3 IF AVER=2
QUIT "2 (Leader, Season, Table)"
+4 IF AVER=3
QUIT "3 (Village, Kitchen, Baby)"
+5 IF AVER=4
QUIT "4 (River, Nation, Finger)"
+6 IF AVER=5
QUIT "5 (Captain, Garden, Picture)"
+7 IF AVER=6
QUIT "6 (Daughter, Heaven, Mountain)"
+8 QUIT "SKIPPED"
+9 ;
DLLSTR(YSDATA,YS,YSTRNG) ;
+1 NEW QSTN,TOTAL,SKIPS
+2 DO BLDQSTN(.QSTN)
+3 SET TOTAL=$$SUM(.QSTN,"5536,5537,5538,5539")
+4 SET SKIPS=$$SKIPCNT(.QSTN,"5536,5537,5538,5539")
+5 IF SKIPS>0
SET TOTAL=""
+6 IF YSTRNG=1
DO SCORESV
+7 IF YSTRNG=2
Begin DoDot:1
+8 NEW N,SCORE,QANDA
+9 DO REPORT(TOTAL,.QSTN,.SCORE,.QANDA)
+10 ; get last node
SET N=$ORDER(YSDATA(""),-1)
+11 SET YSDATA(N+1)="7771^9999;1^"_SCORE
+12 SET YSDATA(N+2)="7772^9999;1^"_QANDA
End DoDot:1
+13 QUIT