YTSPHQ2 ;SLC/PIJ - Score PHQ-2 ; 01/08/2016
;;5.01;MENTAL HEALTH;**123**;DEC 30,1994;Build 73
;
;Public, Supported ICRs
; #2056 - Fileman API - $$GET1^DIQ
;
Q
;
DATA1 ;
S SKIP=0
S YSINSNAM=$P($G(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=""!(SKIP) D ; Start at YSDATA(3)
.S DATA=YSDATA(NODE)
.S YSQN=$P(DATA,U,1)
.S YSCDA=$P($G(DATA),U,3)
.D DESGNTR^YTSCORE(YSQN,.DES)
.I (YSCDA=1155)!(YSCDA=1156)!(YSCDA=1157)!(YSCDA="NOT ASKED") S TOTAL="",SKIP=1 Q
.S LEG=$$GET1^DIQ(601.75,YSCDA_",",4,"I")
.S TOTAL=TOTAL+LEG-1
Q
;
STRING ;
N RES
I '$D(^TMP($J,"YSCOR")) D Q
.S STRING="| "_YSINSNAM_" score could not be determined. "
S TOTAL=$P($G(^TMP($J,"YSCOR",2)),"=",2)
; If TOTAL = "", there are skipped questions and instrument is not valid
I TOTAL="" D Q
.S STRING="| Due to missing Items, this administration cannot be scored. |"
S RES=$S(TOTAL<=2:"negative",1:"positive")
S STRING="| The score on this administration is "_TOTAL_", which indicates a "
S STRING=STRING_RES_" screen on the Depression Scale over the past two weeks."
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"
;
K ^TMP($J,"YSCOR")
S ^TMP($J,"YSCOR",1)="[DATA]"
S ^TMP($J,"YSCOR",2)=$$GET1^DIQ(601.87,492_",",3,"I")_"="_TOTAL
Q
;
DLLSTR(YSDATA,YS,YSTRNG) ;
; YSTRNG = 1 Score Instrument
; YSTRNG = 2 get Report Answers and Text
N DATA,DES,LEG,NODE,YSQN,YSCDA,TOTAL
N YSINSNAM,STRING,SKIP
;
S STRING=""
S TOTAL=""
D DATA1
I YSTRNG=1 D SCORESV
;
I YSTRNG=2 D
.D LDSCORES^YTSCORE(.YSDATA,.YS)
.D STRING
.S YSDATA($O(YSDATA(""),-1)+1)=999999999999_U_U_STRING
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HYTSPHQ2 1861 printed Nov 22, 2024@17:30:34 Page 2
YTSPHQ2 ;SLC/PIJ - Score PHQ-2 ; 01/08/2016
+1 ;;5.01;MENTAL HEALTH;**123**;DEC 30,1994;Build 73
+2 ;
+3 ;Public, Supported ICRs
+4 ; #2056 - Fileman API - $$GET1^DIQ
+5 ;
+6 QUIT
+7 ;
DATA1 ;
+1 SET SKIP=0
+2 SET YSINSNAM=$PIECE($GET(YSDATA(2)),U,3)
+3 IF $GET(YSINSNAM)=""
SET YSINSNAM=$GET(YS("CODE"),"NO NAME PASSED")
+4 ; Start at YSDATA(3)
SET NODE=2
FOR
SET NODE=$ORDER(YSDATA(NODE))
if NODE=""!(SKIP)
QUIT
Begin DoDot:1
+5 SET DATA=YSDATA(NODE)
+6 SET YSQN=$PIECE(DATA,U,1)
+7 SET YSCDA=$PIECE($GET(DATA),U,3)
+8 DO DESGNTR^YTSCORE(YSQN,.DES)
+9 IF (YSCDA=1155)!(YSCDA=1156)!(YSCDA=1157)!(YSCDA="NOT ASKED")
SET TOTAL=""
SET SKIP=1
QUIT
+10 SET LEG=$$GET1^DIQ(601.75,YSCDA_",",4,"I")
+11 SET TOTAL=TOTAL+LEG-1
End DoDot:1
+12 QUIT
+13 ;
STRING ;
+1 NEW RES
+2 IF '$DATA(^TMP($JOB,"YSCOR"))
Begin DoDot:1
+3 SET STRING="| "_YSINSNAM_" score could not be determined. "
End DoDot:1
QUIT
+4 SET TOTAL=$PIECE($GET(^TMP($JOB,"YSCOR",2)),"=",2)
+5 ; If TOTAL = "", there are skipped questions and instrument is not valid
+6 IF TOTAL=""
Begin DoDot:1
+7 SET STRING="| Due to missing Items, this administration cannot be scored. |"
End DoDot:1
QUIT
+8 SET RES=$SELECT(TOTAL<=2:"negative",1:"positive")
+9 SET STRING="| The score on this administration is "_TOTAL_", which indicates a "
+10 SET STRING=STRING_RES_" screen on the Depression Scale over the past two weeks."
+11 QUIT
+12 ;
SCORESV ;
+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,492_",",3,"I")_"="_TOTAL
+9 QUIT
+10 ;
DLLSTR(YSDATA,YS,YSTRNG) ;
+1 ; YSTRNG = 1 Score Instrument
+2 ; YSTRNG = 2 get Report Answers and Text
+3 NEW DATA,DES,LEG,NODE,YSQN,YSCDA,TOTAL
+4 NEW YSINSNAM,STRING,SKIP
+5 ;
+6 SET STRING=""
+7 SET TOTAL=""
+8 DO DATA1
+9 IF YSTRNG=1
DO SCORESV
+10 ;
+11 IF YSTRNG=2
Begin DoDot:1
+12 DO LDSCORES^YTSCORE(.YSDATA,.YS)
+13 DO STRING
+14 SET YSDATA($ORDER(YSDATA(""),-1)+1)=999999999999_U_U_STRING
End DoDot:1
+15 QUIT