Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: YTSPHQ9

YTSPHQ9.m

Go to the documentation of this file.
  1. YTSPHQ9 ;SLC/KCM - Score PHQ9 ; 01/08/2016
  1. ;;5.01;MENTAL HEALTH;**141**;DEC 30,1994;Build 85
  1. ;
  1. DLLSTR(YSDATA,YS,YSMODE) ; main tag for both scores and report text
  1. ;.YSDATA(1)=[DATA]
  1. ;.YSDATA(2)=adminId^dfn^testNm^dtGiven^complete
  1. ;.YSDATA(3..n)=questionId^sequence^choiceId
  1. ;.YS("AD")=adminId
  1. ;YSMODE=1 for calc score, 2 for report text
  1. ;
  1. ; if score, calculate based on answers in YSDATA, save in ^TMP($J,"YSCOR")
  1. I YSMODE=1 D SCORE(.YSDATA) QUIT
  1. ; if report, build special text, add pseudo-question to YSDATA
  1. I YSMODE=2 D REPORT(.YSDATA) QUIT
  1. Q
  1. SCORE(YSDATA) ; iterate through answers and calculate score
  1. ; looks like this is in every scoring routine...
  1. ; SCOREINS^YTSCORE sets up ^TMP($J,"YSG") with scales
  1. ; if no scales are defined, we can't score instrument
  1. I $D(^TMP($J,"YSG",1)),^TMP($J,"YSG",1)="[ERROR]" D Q ;-->out
  1. .K ^TMP($J,"YSCOR")
  1. .S ^TMP($J,"YSCOR",1)="[ERROR]"
  1. .S ^TMP($J,"YSCOR",2)="No Scale found for ADMIN"
  1. ;
  1. N I,Q,C,S,V,T,E ; Q=question,C=choice,S=skips,V=value,T=total,E=error
  1. S S=0,T=0,E=""
  1. S I=2 F S I=$O(YSDATA(I)) Q:'I D
  1. . S Q=$P(YSDATA(I),U) Q:Q=4019 ; q10 not part of score
  1. . S C=$P(YSDATA(I),U,3)
  1. . ; use choice ID's of 212, 1008, 1009, 1010 for scoring
  1. . ; skipped questions are 1155, 1156, or 1157
  1. . S V=$S(C=212:0,C=1008:1,C=1009:2,C=1010:3,C=1155!(C=1156)!(C=1157):"X",1:"?")
  1. . S T=T+V S:V="X" S=S+1
  1. ; if 1 or 2 skipped questions, set their value to average and add to total
  1. I S>0,(S<3) S V=T/(9-S) S T=T+(S*V) S T=+$P((T+0.5),".")
  1. I S>2 S T="Due to missing Items, this administration cannot be scored."
  1. I $L(E) S T="Due to unrecognized responses, this administration cannot be scored."
  1. ;
  1. S S=$P(^YTT(601.87,419,0),U,4) ; 419 is PHQ9 Total scale
  1. K ^TMP($J,"YSCOR")
  1. S ^TMP($J,"YSCOR",1)="[DATA]"
  1. S ^TMP($J,"YSCOR",2)=S_"="_T
  1. Q
  1. REPORT(YSDATA) ; return special question 9 text
  1. ; this was formerly handled in YTAPI2A
  1. ; Questions: 3382 = PHQ9 question #9
  1. ; Choices: 1008 = Several days, 1009 = More than half the days,
  1. ; 1010 = Nearly every day
  1. N I,A
  1. S A=0 ; A=answer
  1. S I=2 F S I=$O(YSDATA(I)) Q:'I D Q:A
  1. . I $P(YSDATA(I),U)=3382 S A=+$P(YSDATA(I),U,3) ; q9 is #3382
  1. I A=1008!(A=1009)!(A=1010) D
  1. . S I=$O(YSDATA(""),-1)+1
  1. . S YSDATA(I)="7771^9999;1^Question 9 answered in the POSITIVE direction, additional clinical assessment is indicated."
  1. Q