YTSBHS ;SLC/PIJ - Score BHS ; 01/16/2016
;;5.01;MENTAL HEALTH;**123**;Dec 30, 1994;Build 73
;
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 YSSEQ=$P($G(DATA),U,2)
.S YSCDA=$P($G(DATA),U,3)
.S YSAN=$$GET1^DIQ(601.75,YSCDA_",",3,"I")
.S DES=YSSEQ
.S LEG=$$GET1^DIQ(601.75,YSCDA_",",4,"I")
.D VALUES
.D REST
.S SCORE=SCORE+LEG
Q
;
STRING ;
I '$D(^TMP($J,"YSCOR")) D Q
.S STRING1="| "_YSINSNAM_" score could not be determined."
.S STRING1=STRING1_"|| Questions and answers"
;
S SCORE=$P($G(^TMP($J,"YSCOR",2)),"=",2)
S FEEL=$P($G(^TMP($J,"YSCOR",3)),"=",2)
S MOTIVATE=$P($G(^TMP($J,"YSCOR",4)),"=",2)
S FUTURE=$P($G(^TMP($J,"YSCOR",5)),"=",2)
;
S RISK=$S(SCORE<4:"None or minimal hopelessness",SCORE<9:"mild hopelessness",SCORE<15:"moderate hopelessness. Evaluate suicide risk",1:"severe hopelessness. Definite suicide risk")
S RANGE=$S(SCORE<4:" between 0 - 3",SCORE<9:" between 4 - 8",SCORE<15:" between 9 - 14",1:" above 14")
;
S STRING="| "_YSINSNAM_" Score: "_SCORE_" indicates "_RISK_"."
S STRING=STRING_"| The overall range is 0 to 20 with "_$S(SCORE<4:"low hopelessness",SCORE<9:"mild hopelessness",SCORE<15:"moderate hopelessness",1:"severe hopelessness")_RANGE_"."
S STRING=STRING_"|| Feelings of Future: "_FEEL
S STRING=STRING_"| Loss of Motivation: "_MOTIVATE
S STRING=STRING_"| Future Expectations: "_FUTURE
S STRING=STRING_"|| Questions and answers |"
Q
;
REST ;
; Save patient response
N X
S X=$P($G(DATA),U,3)
S STRING1=STRING1_"| "_DES_". "_$P(^YTT(601.75,X,1),U,1)_" ("_LEG_" point)"
Q
VALUES ;
;Feeling of Future - 1,6,13,15,19
;Loss of Motivation - 2,3,9,11,12,16,17,20
;Future Expectations - 4,7,8,14,18
;
N STR
S STR="FTFTFFTFTFTTFTFTTTFT"
I $E(STR,DES)=LEG S LEG=1 D Q
.I (DES=1)!(DES=6)!(DES=13)!(DES=15)!(DES=19) S FEEL=FEEL+1 Q ;FALSE
.I (DES=2)!(DES=9)!(DES=11)!(DES=12)!(DES=16)!(DES=17)!(DES=20) S MOTIVATE=MOTIVATE+1 Q ;TRUE
.I (DES=3) S MOTIVATE=MOTIVATE+1 Q ;FALSE
.I (DES=4)!(DES=7)!(DES=14)!(DES=18) S FUTURE=FUTURE+1 Q ;TRUE
.I (DES=8) S FUTURE=FUTURE+1 Q ;FALSE
S LEG=0
Q
;
SCORESV ;
;
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"
;
S YSSCNAM=$P($G(^TMP($J,"YSG",3)),U,4)
K ^TMP($J,"YSCOR")
S ^TMP($J,"YSCOR",1)="[DATA]"
S ^TMP($J,"YSCOR",2)=$$GET1^DIQ(601.87,902_",",3,"I")_"="_SCORE
S ^TMP($J,"YSCOR",3)=$$GET1^DIQ(601.87,903_",",3,"I")_"="_FEEL
S ^TMP($J,"YSCOR",4)=$$GET1^DIQ(601.87,904_",",3,"I")_"="_MOTIVATE
S ^TMP($J,"YSCOR",5)=$$GET1^DIQ(601.87,905_",",3,"I")_"="_FUTURE
Q
;
DLLSTR(YSDATA,YS,YSTRNG) ;
; YSTRNG = 1 Score Instrument
; YSTRNG = 2 get Report Answers and Text
N DATA,DES,NODE,LEG,RISK,YSAN,YSQN,YSINSNAM,YSSEQ,YSCDA,YSSCNAM
N FEEL,FUTURE,MOTIVATE,RANGE,SCORE,STRING,STRING1
;
S (STRING,STRING1)=""
S (FEEL,FUTURE,MOTIVATE,SCORE)=0
;
D DATA1
I YSTRNG=1 D SCORESV
I YSTRNG=2 D
.D LDSCORES^YTSCORE(.YSDATA,.YS)
.D STRING
.S STRING=STRING_STRING1
.S YSDATA($O(YSDATA(""),-1)+1)=999999999999_U_U_STRING
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HYTSBHS 3398 printed Dec 13, 2024@02:19:23 Page 2
YTSBHS ;SLC/PIJ - Score BHS ; 01/16/2016
+1 ;;5.01;MENTAL HEALTH;**123**;Dec 30, 1994;Build 73
+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 YSSEQ=$PIECE($GET(DATA),U,2)
+7 SET YSCDA=$PIECE($GET(DATA),U,3)
+8 SET YSAN=$$GET1^DIQ(601.75,YSCDA_",",3,"I")
+9 SET DES=YSSEQ
+10 SET LEG=$$GET1^DIQ(601.75,YSCDA_",",4,"I")
+11 DO VALUES
+12 DO REST
+13 SET SCORE=SCORE+LEG
End DoDot:1
+14 QUIT
+15 ;
STRING ;
+1 IF '$DATA(^TMP($JOB,"YSCOR"))
Begin DoDot:1
+2 SET STRING1="| "_YSINSNAM_" score could not be determined."
+3 SET STRING1=STRING1_"|| Questions and answers"
End DoDot:1
QUIT
+4 ;
+5 SET SCORE=$PIECE($GET(^TMP($JOB,"YSCOR",2)),"=",2)
+6 SET FEEL=$PIECE($GET(^TMP($JOB,"YSCOR",3)),"=",2)
+7 SET MOTIVATE=$PIECE($GET(^TMP($JOB,"YSCOR",4)),"=",2)
+8 SET FUTURE=$PIECE($GET(^TMP($JOB,"YSCOR",5)),"=",2)
+9 ;
+10 SET RISK=$SELECT(SCORE<4:"None or minimal hopelessness",SCORE<9:"mild hopelessness",SCORE<15:"moderate hopelessness. Evaluate suicide risk",1:"severe hopelessness. Definite suicide risk")
+11 SET RANGE=$SELECT(SCORE<4:" between 0 - 3",SCORE<9:" between 4 - 8",SCORE<15:" between 9 - 14",1:" above 14")
+12 ;
+13 SET STRING="| "_YSINSNAM_" Score: "_SCORE_" indicates "_RISK_"."
+14 SET STRING=STRING_"| The overall range is 0 to 20 with "_$SELECT(SCORE<4:"low hopelessness",SCORE<9:"mild hopelessness",SCORE<15:"moderate hopelessness",1:"severe hopelessness")_RANGE_"."
+15 SET STRING=STRING_"|| Feelings of Future: "_FEEL
+16 SET STRING=STRING_"| Loss of Motivation: "_MOTIVATE
+17 SET STRING=STRING_"| Future Expectations: "_FUTURE
+18 SET STRING=STRING_"|| Questions and answers |"
+19 QUIT
+20 ;
REST ;
+1 ; Save patient response
+2 NEW X
+3 SET X=$PIECE($GET(DATA),U,3)
+4 SET STRING1=STRING1_"| "_DES_". "_$PIECE(^YTT(601.75,X,1),U,1)_" ("_LEG_" point)"
+5 QUIT
VALUES ;
+1 ;Feeling of Future - 1,6,13,15,19
+2 ;Loss of Motivation - 2,3,9,11,12,16,17,20
+3 ;Future Expectations - 4,7,8,14,18
+4 ;
+5 NEW STR
+6 SET STR="FTFTFFTFTFTTFTFTTTFT"
+7 IF $EXTRACT(STR,DES)=LEG
SET LEG=1
Begin DoDot:1
+8 ;FALSE
IF (DES=1)!(DES=6)!(DES=13)!(DES=15)!(DES=19)
SET FEEL=FEEL+1
QUIT
+9 ;TRUE
IF (DES=2)!(DES=9)!(DES=11)!(DES=12)!(DES=16)!(DES=17)!(DES=20)
SET MOTIVATE=MOTIVATE+1
QUIT
+10 ;FALSE
IF (DES=3)
SET MOTIVATE=MOTIVATE+1
QUIT
+11 ;TRUE
IF (DES=4)!(DES=7)!(DES=14)!(DES=18)
SET FUTURE=FUTURE+1
QUIT
+12 ;FALSE
IF (DES=8)
SET FUTURE=FUTURE+1
QUIT
End DoDot:1
QUIT
+13 SET LEG=0
+14 QUIT
+15 ;
SCORESV ;
+1 ;
+2 ;-->out
IF $DATA(^TMP($JOB,"YSG",1))
IF ^TMP($JOB,"YSG",1)="[ERROR]"
Begin DoDot:1
+3 KILL ^TMP($JOB,"YSCOR")
+4 SET ^TMP($JOB,"YSCOR",1)="[ERROR]"
+5 SET ^TMP($JOB,"YSCOR",2)=YSINSNAM_" Scale not found"
End DoDot:1
QUIT
+6 ;
+7 SET YSSCNAM=$PIECE($GET(^TMP($JOB,"YSG",3)),U,4)
+8 KILL ^TMP($JOB,"YSCOR")
+9 SET ^TMP($JOB,"YSCOR",1)="[DATA]"
+10 SET ^TMP($JOB,"YSCOR",2)=$$GET1^DIQ(601.87,902_",",3,"I")_"="_SCORE
+11 SET ^TMP($JOB,"YSCOR",3)=$$GET1^DIQ(601.87,903_",",3,"I")_"="_FEEL
+12 SET ^TMP($JOB,"YSCOR",4)=$$GET1^DIQ(601.87,904_",",3,"I")_"="_MOTIVATE
+13 SET ^TMP($JOB,"YSCOR",5)=$$GET1^DIQ(601.87,905_",",3,"I")_"="_FUTURE
+14 QUIT
+15 ;
DLLSTR(YSDATA,YS,YSTRNG) ;
+1 ; YSTRNG = 1 Score Instrument
+2 ; YSTRNG = 2 get Report Answers and Text
+3 NEW DATA,DES,NODE,LEG,RISK,YSAN,YSQN,YSINSNAM,YSSEQ,YSCDA,YSSCNAM
+4 NEW FEEL,FUTURE,MOTIVATE,RANGE,SCORE,STRING,STRING1
+5 ;
+6 SET (STRING,STRING1)=""
+7 SET (FEEL,FUTURE,MOTIVATE,SCORE)=0
+8 ;
+9 DO DATA1
+10 IF YSTRNG=1
DO SCORESV
+11 IF YSTRNG=2
Begin DoDot:1
+12 DO LDSCORES^YTSCORE(.YSDATA,.YS)
+13 DO STRING
+14 SET STRING=STRING_STRING1
+15 SET YSDATA($ORDER(YSDATA(""),-1)+1)=999999999999_U_U_STRING
End DoDot:1
+16 QUIT