YTSLEC ;ISP/LMT - Report for LEC ;Nov 29, 2023@08:59:02
;;5.01;MENTAL HEALTH;**239**;Dec 30, 1994;Build 16
;
;
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
;
N YSN,YSTEXT
;
I YSTRNG=1 QUIT ; There is no custom scoring for this instrument
;
I YSTRNG=2 D
. S YSTEXT=$$REPORT(.YSDATA)
. S YSN=$O(YSDATA(""),-1) ; get last node
. S YSN=YSN+1
. S YSDATA(YSN)="7771^9999;1^"_YSTEXT
Q
;
;
REPORT(YSDATA) ;
;
N YSANSWER,YSCHOICE,YSCNT,YSHDR,YSI,YSNODE,YSQUESTION,YSRESULT,YSSORT
;
S YSI=2
F S YSI=$O(YSDATA(YSI)) Q:'YSI D
. S YSNODE=$G(YSDATA(YSI))
. S YSQUESTION=$P(YSNODE,U,1)
. S YSANSWER=$P(YSNODE,U,3)
. I YSQUESTION=""!(YSANSWER="") QUIT
. ;
. F YSCHOICE=5816:1:5819 D
. . I YSANSWER[$G(^YTT(601.75,YSCHOICE,1)) D
. . . S YSSORT(YSCHOICE,YSQUESTION)=""
;
S YSHDR(5816)="Veteran Experienced:"
S YSHDR(5817)="Veteran Witnessed:"
S YSHDR(5818)="Veteran Learned About:"
S YSHDR(5819)="Job related:"
;
S YSRESULT=""
F YSCHOICE=5816:1:5819 D
. S YSRESULT=YSRESULT_"||"_YSHDR(YSCHOICE)
. ;
. I '$D(YSSORT(YSCHOICE)) D QUIT
. . S YSRESULT=YSRESULT_"| N/A"
. ;
. S YSCNT=0
. S YSQUESTION=0 F S YSQUESTION=$O(YSSORT(YSCHOICE,YSQUESTION)) Q:'YSQUESTION D
. . S YSCNT=YSCNT+1
. . S YSRESULT=YSRESULT_$$QFORMAT(YSCNT,YSQUESTION,7)
;
Q YSRESULT
;
QFORMAT(YSCNT,YSQUESTION,YSINDENT) ; format the question nicely
;
N DIWF,DIWL,DIWR,X,YSI,YSLINE,YSRESULT
;
S YSINDENT=$G(YSINDENT,7)
S DIWL=YSINDENT+3
S DIWR="78"
S DIWF="|"
K ^UTILITY($J,"W")
;
S YSI=0 F S YSI=$O(^YTT(601.72,YSQUESTION,1,YSI)) Q:'YSI D
. S X=$G(^YTT(601.72,YSQUESTION,1,YSI,0))
. D ^DIWP
;
S YSRESULT=""
S YSI=0 F S YSI=$O(^UTILITY($J,"W",DIWL,YSI)) Q:'YSI D
. S YSLINE=$G(^UTILITY($J,"W",DIWL,YSI,0))
. I YSI=1 D QUIT
. . S YSRESULT="|"_$$RJ^XLFSTR(YSCNT_". ",YSINDENT)_YSLINE
. S YSRESULT=YSRESULT_"|"_$$REPEAT^XLFSTR(" ",YSINDENT)_YSLINE
K ^UTILITY($J,"W")
Q YSRESULT
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HYTSLEC 2312 printed Dec 13, 2024@02:19:56 Page 2
YTSLEC ;ISP/LMT - Report for LEC ;Nov 29, 2023@08:59:02
+1 ;;5.01;MENTAL HEALTH;**239**;Dec 30, 1994;Build 16
+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 NEW YSN,YSTEXT
+10 ;
+11 ; There is no custom scoring for this instrument
IF YSTRNG=1
QUIT
+12 ;
+13 IF YSTRNG=2
Begin DoDot:1
+14 SET YSTEXT=$$REPORT(.YSDATA)
+15 ; get last node
SET YSN=$ORDER(YSDATA(""),-1)
+16 SET YSN=YSN+1
+17 SET YSDATA(YSN)="7771^9999;1^"_YSTEXT
End DoDot:1
+18 QUIT
+19 ;
+20 ;
REPORT(YSDATA) ;
+1 ;
+2 NEW YSANSWER,YSCHOICE,YSCNT,YSHDR,YSI,YSNODE,YSQUESTION,YSRESULT,YSSORT
+3 ;
+4 SET YSI=2
+5 FOR
SET YSI=$ORDER(YSDATA(YSI))
if 'YSI
QUIT
Begin DoDot:1
+6 SET YSNODE=$GET(YSDATA(YSI))
+7 SET YSQUESTION=$PIECE(YSNODE,U,1)
+8 SET YSANSWER=$PIECE(YSNODE,U,3)
+9 IF YSQUESTION=""!(YSANSWER="")
QUIT
+10 ;
+11 FOR YSCHOICE=5816:1:5819
Begin DoDot:2
+12 IF YSANSWER[$GET(^YTT(601.75,YSCHOICE,1))
Begin DoDot:3
+13 SET YSSORT(YSCHOICE,YSQUESTION)=""
End DoDot:3
End DoDot:2
End DoDot:1
+14 ;
+15 SET YSHDR(5816)="Veteran Experienced:"
+16 SET YSHDR(5817)="Veteran Witnessed:"
+17 SET YSHDR(5818)="Veteran Learned About:"
+18 SET YSHDR(5819)="Job related:"
+19 ;
+20 SET YSRESULT=""
+21 FOR YSCHOICE=5816:1:5819
Begin DoDot:1
+22 SET YSRESULT=YSRESULT_"||"_YSHDR(YSCHOICE)
+23 ;
+24 IF '$DATA(YSSORT(YSCHOICE))
Begin DoDot:2
+25 SET YSRESULT=YSRESULT_"| N/A"
End DoDot:2
QUIT
+26 ;
+27 SET YSCNT=0
+28 SET YSQUESTION=0
FOR
SET YSQUESTION=$ORDER(YSSORT(YSCHOICE,YSQUESTION))
if 'YSQUESTION
QUIT
Begin DoDot:2
+29 SET YSCNT=YSCNT+1
+30 SET YSRESULT=YSRESULT_$$QFORMAT(YSCNT,YSQUESTION,7)
End DoDot:2
End DoDot:1
+31 ;
+32 QUIT YSRESULT
+33 ;
QFORMAT(YSCNT,YSQUESTION,YSINDENT) ; format the question nicely
+1 ;
+2 NEW DIWF,DIWL,DIWR,X,YSI,YSLINE,YSRESULT
+3 ;
+4 SET YSINDENT=$GET(YSINDENT,7)
+5 SET DIWL=YSINDENT+3
+6 SET DIWR="78"
+7 SET DIWF="|"
+8 KILL ^UTILITY($JOB,"W")
+9 ;
+10 SET YSI=0
FOR
SET YSI=$ORDER(^YTT(601.72,YSQUESTION,1,YSI))
if 'YSI
QUIT
Begin DoDot:1
+11 SET X=$GET(^YTT(601.72,YSQUESTION,1,YSI,0))
+12 DO ^DIWP
End DoDot:1
+13 ;
+14 SET YSRESULT=""
+15 SET YSI=0
FOR
SET YSI=$ORDER(^UTILITY($JOB,"W",DIWL,YSI))
if 'YSI
QUIT
Begin DoDot:1
+16 SET YSLINE=$GET(^UTILITY($JOB,"W",DIWL,YSI,0))
+17 IF YSI=1
Begin DoDot:2
+18 SET YSRESULT="|"_$$RJ^XLFSTR(YSCNT_". ",YSINDENT)_YSLINE
End DoDot:2
QUIT
+19 SET YSRESULT=YSRESULT_"|"_$$REPEAT^XLFSTR(" ",YSINDENT)_YSLINE
End DoDot:1
+20 KILL ^UTILITY($JOB,"W")
+21 QUIT YSRESULT