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

YTSPEG.m

Go to the documentation of this file.
  1. YTSPEG ;BAL/KTL - Score PEG ; 3/25/22 2:02pm
  1. ;;5.01;MENTAL HEALTH;**234**;Dec 30, 1994;Build 38
  1. ;
  1. DLLSTR(YSDATA,YS,YSTRNG) ; compute scores or report text based on YSTRNG
  1. ; input
  1. ; YSDATA(2)=adminId^patientDFN^instrumentName^dateGiven^isComplete
  1. ; YSDATA(2+n)=questionId^sequence^choiceId
  1. ; YS("AD")=adminId
  1. ; YSTRNG=1 for score, 2 for report
  1. ; output if YSTRNG=1: ^TMP($J,"YSCOR",n)=scaleId=score
  1. ; output if YSTRNG=2: append special "answers" to YSDATA
  1. ;
  1. I YSTRNG=1 D SCORESV
  1. I YSTRNG=2 D
  1. . N SCORES,N
  1. . D LDSCORES^YTSCORE(.YSDATA,.YS) ; puts score into ^TMP($J,"YSCOR",2)
  1. . D REPORT(.SCORES)
  1. . ;S N=$O(YSDATA(""),-1) ; get last node
  1. Q
  1. ;
  1. SCORESV ; calculate the score
  1. ; expects YSDATA from DLLSTR (YSDATA from LOADANSW^YTSCORE,SCALEG^YTQAPI3)
  1. N I,J,CHOICE,SKPCNT,AVE,QUES,TOT
  1. S (SKPCNT,AVE,TOT)=0
  1. S I=2 F S I=$O(YSDATA(I)) Q:'I D
  1. . S QUES=$P(YSDATA(I),U)
  1. . S CHOICE=$P(YSDATA(I),U,3)
  1. . I CHOICE=1155 S SKPCNT=SKPCNT+1 Q
  1. . S TOT=TOT+CHOICE
  1. I SKPCNT>0 S TOT=TOT*($S(SKPCNT=1:1.5,SKPCNT=2:3,1:1)) ; Estimated total if skipped questions
  1. S AVE=$J(TOT/3,"",0) ;Whole number rounded average of answered questions
  1. ;
  1. ; set scores into ^TMP($J,"YSCOR",n)=scaleName=score {rawScore^tScore}
  1. K ^TMP($J,"YSCOR")
  1. I $D(^TMP($J,"YSG",1)),(^TMP($J,"YSG",1)="[ERROR]") D Q ;-->out
  1. . S ^TMP($J,"YSCOR",1)="[ERROR]"
  1. . S ^TMP($J,"YSCOR",2)="No Scale found for ADMIN"
  1. ;
  1. N SCLID,SCLNM
  1. S ^TMP($J,"YSCOR",1)="[DATA]"
  1. S I=2,J=1 F S I=$O(^TMP($J,"YSG",I)) Q:'I D
  1. . S SCLID=+$P(^TMP($J,"YSG",I),"=",2)
  1. . S SCLNM=$P(^TMP($J,"YSG",I),U,4)
  1. . S J=J+1
  1. . I SCLID=1502 S ^TMP($J,"YSCOR",J)=SCLNM_"="_AVE
  1. Q
  1. REPORT(SCORES) ; build the scoring display for the report
  1. ; expects ^TMP($J,"YSCOR",...) and ^TMP($J,"YSG") from DLLSTR
  1. ; YSDATA from DLLSTR
  1. Q
  1. N I,NAME,VAL
  1. S SCORES="Negative"
  1. S I=0 F S I=$O(^TMP($J,"YSCOR",I)) Q:'I D
  1. . S NAME=$E($P(^TMP($J,"YSCOR",I),"="),1,5)
  1. . S VAL=$P(^TMP($J,"YSCOR",I),"=",2)
  1. . I NAME="BIPOL" S SCORES=$S(+VAL=0:"Negative",1:"Positive")
  1. Q