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

YTSNUDEC.m

Go to the documentation of this file.
YTSNUDEC ;SLC/BLD- MHAX ANSWERS SPECIAL HANDLING FOR:  Nursing Delirium Screening Scale - (NuDESC)
 ;;5.01;MENTAL HEALTH;**150**;DEC 30,1994;Build 210
 ;
 ;Public, Supported ICRs
 ; #2056 - Fileman API - $$GET1^DIQ
 ;
 ;
DLLSTR(YSDATA,YS,YSTRNG) ;
 ;  YSTRNG = 1 Score Instrument
 ;  YSTRNG = 2 get Report Answers and Text
 N DATA,YSSCALIEN,TOTSCORE,YSINSNAM,STRING,TOTSCORE,CNT
 ;
 ; returns a scale score which is calculated and stored, no special text in report
 I YSTRNG=1 D SCORESV Q
 I YSTRNG=2 D STRING Q
 ;
 Q
 ;
STRING ;
 ;
 N YSCHOICE,YSTEXT,YSMAXLL
 D DATA1
 S N=N+1
 I TOTSCORE>1 S YSDATA(N)="7771^9999;1^POSITIVE"  S N=N+1
 E  S YSDATA(N)="7771^9999;1^NEGATIVE"  S N=N+1
 S YSMAXLL=76 ;Maximum line length to display
 F I=3:1:7 Q:'YSDATA(I)  D                             ;5035,5038,5041,5044,5047 D
 .S YSCHOICE=$P(YSDATA(I),"^",3)
 .S YSTEXT=$$GET1^DIQ(601.75,$P(YSDATA(I),"^",3)_",",3,"E")
 .I YSCHOICE=5036 D WRAPTEXT(YSMAXLL)
 .I YSCHOICE=5037 D WRAPTEXT(YSMAXLL)
 .I YSCHOICE=5039 D WRAPTEXT(YSMAXLL)
 .I YSCHOICE=5040 D WRAPTEXT(YSMAXLL)
 .I YSCHOICE=5042 D WRAPTEXT(YSMAXLL)
 .I YSCHOICE=5043 D WRAPTEXT(YSMAXLL)
 .I YSCHOICE=5045 D WRAPTEXT(YSMAXLL)
 .I YSCHOICE=5046 D WRAPTEXT(YSMAXLL)
 .I YSCHOICE=5048 D WRAPTEXT(YSMAXLL)
 .I YSCHOICE=5049 D WRAPTEXT(YSMAXLL)
 .I I=3 S YSDATA(N)="7772^9999;1^"_YSTEXT S N=N+1
 .I I=4 S YSDATA(N)="7773^9999;1^"_YSTEXT  S N=N+1
 .I I=5 S YSDATA(N)="7774^9999;1^"_YSTEXT  S N=N+1
 .I I=6 S YSDATA(N)="7775^9999;1^"_YSTEXT  S N=N+1
 .I I=7 S YSDATA(N)="7776^9999;1^"_YSTEXT  S N=N+1
 ;
 ;F I=5036,5039,5042,5045,5048 D
 ;.S YSTEXT=$$GET1^DIQ(601.75,$P(YSDATA(I),"^",3)_",",3,"E")
 ;.I I=5036 D
 ;..S YSDATA(N)="7773^999;1^Mild to moderate. Barely expressed and noticeable through to being present and undeniable. Patient still can provide some orientating information to time, place and/or person." S N=N+1
 ;
 Q
 ;
DATA1 ;
 ;
 N I,II,UNANS,MEAN
 S (TOTSCORE,CNT,UNANS)=0
 F I=3:1 Q:'$D(YSDATA(I))  S TOTSCORE=$G(TOTSCORE)+$$GET1^DIQ(601.75,$P(YSDATA(I),"^",3)_",",4,"I")
 Q
 ;
SCORESV ;
 N YSSCGROUP,I
 D DATA1
 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)=$G(YSINSNAM)_" Scale not found"
 ;
 K ^TMP($J,"YSCOR")
 ;
 S ^TMP($J,"YSCOR",1)="[DATA]"
 S YSSCALIEN=$P($P(^TMP($J,"YSG",3),"^",1),"=",2)
 S ^TMP($J,"YSCOR",2)=$$GET1^DIQ(601.87,YSSCALIEN_",",3,"I")_"="_TOTSCORE
 Q
 ;
WRAPTEXT(YSMAXLL) ; Parses text and creats line feeds that does not split words
 N YSPOS,YSTEMP,YSSPOS,YSEPOS ;YSSPOS & YSEPOS are starting and ending position
 S YSPOS="" ;YSPOS is the position of the line break within the line
 S YSTEMP=YSTEXT
 S YSSPOS=1,YSEPOS=YSMAXLL ;YSMAXLL is the maximum line length
 S YSPOS=$$POSITION(YSTEMP,YSSPOS,YSEPOS)
 S YSTEXT=$E(YSTEMP,YSSPOS,YSPOS)_"|  "
 S YSSPOS=YSPOS+1,YSEPOS=YSPOS+YSMAXLL
 S YSPOS=$$POSITION(YSTEMP,YSSPOS,YSEPOS)
 I $E(YSTEMP,YSSPOS)=" " S YSSPOS=YSSPOS+1
 S YSTEXT=YSTEXT_$E(YSTEMP,YSSPOS,YSPOS)_"|  "
 I $L(YSTEXT)<$L(YSTEMP) D
 . S YSPOS=YSPOS+1
 . I $E(YSTEMP,YSPOS)=" " S YSPOS=YSPOS+1
 . S YSTEXT=YSTEXT_$E(YSTEMP,YSPOS,999)
 Q
 ;
POSITION(YSTEXT,YSSPOS,YSEPOS) ;
 N TEMPS
 S TEMPS=$E(YSTEXT,YSSPOS,YSEPOS)
 I $L(TEMPS)<YSMAXLL S YSPOS=$L(TEMPS)+YSSPOS-1 Q YSPOS
 I $E(YSTEMP,YSEPOS,YSEPOS+1)[" " S YSPOS=YSEPOS Q YSPOS
 S YSPOS=$L(TEMPS)+2-$F($RE(TEMPS)," ")
 S YSPOS=YSPOS+YSSPOS-1
 Q YSPOS
 ;