YTSBDI2 ;SLC/PIJ - Score BDI2 ; 01/16/2016
;;5.01;MENTAL HEALTH;**123,199**;Dec 30, 1994;Build 18
;
Q
;
DATA1 ;
S YSINSNAM=$P(YSDATA(2),U,3)
I $G(YSINSNAM)="" S YSINSNAM=$G(YS("CODE"),"NO NAME PASSED")
S NODE=2 F S NODE=$O(YSDATA(NODE)) Q:NODE="" D ; Start at YSDATA(3)
.S DATA=YSDATA(NODE)
.S YSQN=$P($G(DATA),U,1)
.S YSCDA=$P($G(DATA),U,3)
.D DESGNTR^YTSCORE(YSQN,.DES)
.S LEG=$$GET1^DIQ(601.75,YSCDA_",",4,"I")
.S YSAN=$$GET1^DIQ(601.75,YSCDA_",",3,"I")
.; Question2 #16 and #18
.I (DES=16)!(DES=18) D
..I (LEG=2) S LEG=1 Q
..I (LEG=3)!(LEG=4) S LEG=2 Q
..I (LEG=5)!(LEG=6) S LEG=3 Q
.I (DES=9) D
..I (YSCDA=1155)!(YSCDA=1156) Q
..I LEG>0 S RFLAG=1
.D REST2
.S SCORE=SCORE+LEG
Q
;
RPT ;
I '$D(^TMP($J,"YSCOR")) D Q
.S STRING1="| "_YSINSNAM_" score could not be determined. "
;
S SCORE=$P($G(^TMP($J,"YSCOR",2)),"=",2)
I SCORE=-1 D Q
.S STRING1=STRING1_"| "_YSINSNAM_" score could not be determined."
.S STRING1=STRING1_"|| Questions and answers"
;
S RISK=$S(SCORE<14:"low",SCORE<20:"mild",SCORE<29:"moderate",1:"severe")
S RANGE=$S(SCORE<14:" between 0 - 13",SCORE<20:" between 14 - 19",SCORE<29:" between 20 - 28",1:" above 29")
S STRING=STRING_"| "_YSINSNAM_" Score: "_SCORE_" indicates "_RISK_" depression."
S STRING=STRING_" The overall range is 0 to 63"
S STRING=STRING_"| "_"with "_RISK_" depression"_RANGE_"."
I RFLAG D
.S STRING=STRING_"|| Responses consistent with the presence of suicidal ideation were endorsed "
.S STRING=STRING_"| in positive direction (item-9), additional clinical assessment is"
.S STRING=STRING_"| indicated."
;
S STRING=STRING_"|| 1 point = mild symptom level | 2 points = moderate symptom level | 3 points = severe symptom level "
S STRING=STRING_"|| Questions and answers|"
Q
;
REST2 ; setting up Report Question and Answer section; will move this to YSDATA so
N I
F I=1:1 Q:'$D(^YTT(601.72,YSQN,1,I,0)) D
.S TMP(NODE)=YSQN_U_"9999;1^"_DES_". "_$$GET1^DIQ(601.75,YSCDA_",",3,"E")_" ("_LEG
.S:LEG'=1 TMP(NODE)=TMP(NODE)_" points)"
.S:LEG=1 TMP(NODE)=TMP(NODE)_" point)"
Q
TRANS ; move Answers from TMP to YSDATA
N I,STR,ANS
F I=3:1 Q:'$D(YSDATA(I)) K YSDATA(I)
;
S ANS=7770
F I=3:1:23 S ANS=ANS+1 S:ANS=7788 ANS=7921
;
S ANS=7770
F I=3:1 Q:'$D(TMP(I)) S STR=$P(TMP(I),U,2,4) D
.S ANS=ANS+1 S:ANS=7788 ANS=7921
.S YSDATA(I)=ANS_U_STR
Q
SCORESV ; For the Graph/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)=YSINSNAM_" Scale not found"
;
K ^TMP($J,"YSCOR")
S ^TMP($J,"YSCOR",1)="[DATA]"
S ^TMP($J,"YSCOR",2)=$$GET1^DIQ(601.87,332_",",3,"I")_"="_SCORE
Q
;
DLLSTR(YSDATA,YS,YSTRNG) ;
; YSTRNG = 1 Score Instrument
; YSTRNG = 2 get Report Answers and Text
N CTR,DATA,DES,LEG,NODE,SCORE,TMP,YSAN,YSQN
N YSCDA,YSSCNAM,YSINSNAM,RISK
N STRING,STRING1,RANGE,RFLAG
;
S (STRING,STRING1)=""
S (CTR,LEG,RFLAG,SCORE)=0
;
D DATA1
I YSTRNG=1 D SCORESV
I YSTRNG=2 D
.D LDSCORES^YTSCORE(.YSDATA,.YS)
.D TRANS
.D RPT
.S STRING=STRING_STRING1
.S YSDATA($O(YSDATA(""),-1)+1)=999999999999_U_U_STRING
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HYTSBDI2 3229 printed Dec 13, 2024@02:19:22 Page 2
YTSBDI2 ;SLC/PIJ - Score BDI2 ; 01/16/2016
+1 ;;5.01;MENTAL HEALTH;**123,199**;Dec 30, 1994;Build 18
+2 ;
+3 QUIT
+4 ;
DATA1 ;
+1 SET YSINSNAM=$PIECE(YSDATA(2),U,3)
+2 IF $GET(YSINSNAM)=""
SET YSINSNAM=$GET(YS("CODE"),"NO NAME PASSED")
+3 ; Start at YSDATA(3)
SET NODE=2
FOR
SET NODE=$ORDER(YSDATA(NODE))
if NODE=""
QUIT
Begin DoDot:1
+4 SET DATA=YSDATA(NODE)
+5 SET YSQN=$PIECE($GET(DATA),U,1)
+6 SET YSCDA=$PIECE($GET(DATA),U,3)
+7 DO DESGNTR^YTSCORE(YSQN,.DES)
+8 SET LEG=$$GET1^DIQ(601.75,YSCDA_",",4,"I")
+9 SET YSAN=$$GET1^DIQ(601.75,YSCDA_",",3,"I")
+10 ; Question2 #16 and #18
+11 IF (DES=16)!(DES=18)
Begin DoDot:2
+12 IF (LEG=2)
SET LEG=1
QUIT
+13 IF (LEG=3)!(LEG=4)
SET LEG=2
QUIT
+14 IF (LEG=5)!(LEG=6)
SET LEG=3
QUIT
End DoDot:2
+15 IF (DES=9)
Begin DoDot:2
+16 IF (YSCDA=1155)!(YSCDA=1156)
QUIT
+17 IF LEG>0
SET RFLAG=1
End DoDot:2
+18 DO REST2
+19 SET SCORE=SCORE+LEG
End DoDot:1
+20 QUIT
+21 ;
RPT ;
+1 IF '$DATA(^TMP($JOB,"YSCOR"))
Begin DoDot:1
+2 SET STRING1="| "_YSINSNAM_" score could not be determined. "
End DoDot:1
QUIT
+3 ;
+4 SET SCORE=$PIECE($GET(^TMP($JOB,"YSCOR",2)),"=",2)
+5 IF SCORE=-1
Begin DoDot:1
+6 SET STRING1=STRING1_"| "_YSINSNAM_" score could not be determined."
+7 SET STRING1=STRING1_"|| Questions and answers"
End DoDot:1
QUIT
+8 ;
+9 SET RISK=$SELECT(SCORE<14:"low",SCORE<20:"mild",SCORE<29:"moderate",1:"severe")
+10 SET RANGE=$SELECT(SCORE<14:" between 0 - 13",SCORE<20:" between 14 - 19",SCORE<29:" between 20 - 28",1:" above 29")
+11 SET STRING=STRING_"| "_YSINSNAM_" Score: "_SCORE_" indicates "_RISK_" depression."
+12 SET STRING=STRING_" The overall range is 0 to 63"
+13 SET STRING=STRING_"| "_"with "_RISK_" depression"_RANGE_"."
+14 IF RFLAG
Begin DoDot:1
+15 SET STRING=STRING_"|| Responses consistent with the presence of suicidal ideation were endorsed "
+16 SET STRING=STRING_"| in positive direction (item-9), additional clinical assessment is"
+17 SET STRING=STRING_"| indicated."
End DoDot:1
+18 ;
+19 SET STRING=STRING_"|| 1 point = mild symptom level | 2 points = moderate symptom level | 3 points = severe symptom level "
+20 SET STRING=STRING_"|| Questions and answers|"
+21 QUIT
+22 ;
REST2 ; setting up Report Question and Answer section; will move this to YSDATA so
+1 NEW I
+2 FOR I=1:1
if '$DATA(^YTT(601.72,YSQN,1,I,0))
QUIT
Begin DoDot:1
+3 SET TMP(NODE)=YSQN_U_"9999;1^"_DES_". "_$$GET1^DIQ(601.75,YSCDA_",",3,"E")_" ("_LEG
+4 if LEG'=1
SET TMP(NODE)=TMP(NODE)_" points)"
+5 if LEG=1
SET TMP(NODE)=TMP(NODE)_" point)"
End DoDot:1
+6 QUIT
TRANS ; move Answers from TMP to YSDATA
+1 NEW I,STR,ANS
+2 FOR I=3:1
if '$DATA(YSDATA(I))
QUIT
KILL YSDATA(I)
+3 ;
+4 SET ANS=7770
+5 FOR I=3:1:23
SET ANS=ANS+1
if ANS=7788
SET ANS=7921
+6 ;
+7 SET ANS=7770
+8 FOR I=3:1
if '$DATA(TMP(I))
QUIT
SET STR=$PIECE(TMP(I),U,2,4)
Begin DoDot:1
+9 SET ANS=ANS+1
if ANS=7788
SET ANS=7921
+10 SET YSDATA(I)=ANS_U_STR
End DoDot:1
+11 QUIT
SCORESV ; For the Graph/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)=YSINSNAM_" 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,332_",",3,"I")_"="_SCORE
+9 QUIT
+10 ;
DLLSTR(YSDATA,YS,YSTRNG) ;
+1 ; YSTRNG = 1 Score Instrument
+2 ; YSTRNG = 2 get Report Answers and Text
+3 NEW CTR,DATA,DES,LEG,NODE,SCORE,TMP,YSAN,YSQN
+4 NEW YSCDA,YSSCNAM,YSINSNAM,RISK
+5 NEW STRING,STRING1,RANGE,RFLAG
+6 ;
+7 SET (STRING,STRING1)=""
+8 SET (CTR,LEG,RFLAG,SCORE)=0
+9 ;
+10 DO DATA1
+11 IF YSTRNG=1
DO SCORESV
+12 IF YSTRNG=2
Begin DoDot:1
+13 DO LDSCORES^YTSCORE(.YSDATA,.YS)
+14 DO TRANS
+15 DO RPT
+16 SET STRING=STRING_STRING1
+17 SET YSDATA($ORDER(YSDATA(""),-1)+1)=999999999999_U_U_STRING
End DoDot:1
+18 QUIT