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

YTSPOQ.m

Go to the documentation of this file.
YTSPOQ ;SLC/PIJ - Score POQ ; 01/08/2016
 ;;5.01;MENTAL HEALTH;**123**;DEC 30,1994;Build 73
 ;
 ;Public, Supported ICRs
 ; #2056 - Fileman API - $$GET1^DIQ
 ;
 Q
 ;
DATA1 ;
 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=""  D
 .S DATA=YSDATA(NODE)
 .S YSQN=$P(DATA,U,1)
 .S ANS=$P($G(DATA),U,3) ; questions 2-20, track bar, 3rd piece answer value
 .D DESGNTR^YTSCORE(YSQN,.DES)
 .I ANS'?1N.N Q
 .I (DES=1) Q
 .I (DES=2) S PAIN=PAIN+ANS Q
 .I (DES=3)!(DES=4)!(DES=5)!(DES=6) D  Q
 ..S MOBIL=MOBIL+ANS
 .I (DES=7)!(DES=8)!(DES=9)!(DES=10) D  Q
 ..S ADL=ADL+ANS
 .I (DES=12)!(DES=13)!(DES=14) D  Q
 ..S VITAL=VITAL+(10-ANS)
 .I (DES=11)!(DES=15)!(DES=16)!(DES=19)!(DES=20) D  Q
 ..S NA=NA+ANS
 .I (DES=17) D  Q
 ..S FEAR=FEAR+ANS
 .I (DES=18) S FEAR=FEAR+(10-ANS)
 S TOTAL=PAIN+ADL+FEAR+MOBIL+VITAL+NA
 Q
 ;
STRING ;
 N PADSPACE
 I '$D(^TMP($J,"YSCOR")) D  Q
 .S STRING="| "_YSINSNAM_" score could not be determined. "
 ;
 S PAIN=$P($G(^TMP($J,"YSCOR",2)),"=",2)
 S ADL=$P($G(^TMP($J,"YSCOR",3)),"=",2)
 S FEAR=$P($G(^TMP($J,"YSCOR",4)),"=",2)
 S MOBIL=$P($G(^TMP($J,"YSCOR",5)),"=",2)
 S NA=$P($G(^TMP($J,"YSCOR",6)),"=",2)
 S VITAL=$P($G(^TMP($J,"YSCOR",7)),"=",2)
 S TOTAL=$P($G(^TMP($J,"YSCOR",8)),"=",2)
 ; PAIN
 D PAIN,PAD(PAIN)
 S STRING=STRING_"   Pain             "_PAIN_$J(IPCT,PADSPACE)_$J(OPCT,13)
 ; ADL
 D ADL,PAD(ADL)
 S STRING=STRING_"| ADL              "_ADL_$J(IPCT,PADSPACE)_$J(OPCT,13)
 ; FEAR
 D FEAR,PAD(FEAR)
 S STRING=STRING_"| Fear             "_FEAR_$J(IPCT,PADSPACE)_$J(OPCT,13)
 ; MOBILITY
 D MOBIL,PAD(MOBIL)
 S STRING=STRING_"| Mobility         "_MOBIL_$J(IPCT,PADSPACE)_$J(OPCT,13)
 ; NEGATIVLY AFFECTED
 D NA,PAD(NA)
 S STRING=STRING_"| Neg Affect       "_NA_$J(IPCT,PADSPACE)_$J(OPCT,13)
 ; VITALITY
 D VITAL,PAD(VITAL)
 S STRING=STRING_"| Vitality         "_VITAL_$J(IPCT,PADSPACE)_$J(OPCT,13)
 ; TOTAL
 S STRING=STRING_"||    Total         "_TOTAL_"|"
 Q
 ;
ADL   ;
 S (IPCT,OPCT)=0
 I ADL=0 S IPCT=6,OPCT=12 Q
 I ADL=1 S IPCT=13,OPCT=25 Q
 I ADL=2 S IPCT=15,OPCT=28 Q
 I ADL=3 S IPCT=18,OPCT=31 Q
 I ADL=4 S IPCT=22,OPCT=36 Q
 I ADL=5 S IPCT=26,OPCT=42 Q
 I ADL=6 S IPCT=29,OPCT=47 Q
 I ADL=7 S IPCT=32,OPCT=50 Q
 I ADL=8 S IPCT=36,OPCT=53 Q
 I ADL=9 S IPCT=40,OPCT=55 Q
 I ADL=10 S IPCT=44,OPCT=57 Q
 I ADL=11 S IPCT=47,OPCT=59 Q
 I ADL=12 S IPCT=50,OPCT=61 Q
 I ADL=13 S IPCT=53,OPCT=63 Q
 I ADL=14 S IPCT=55,OPCT=64 Q
 I ADL=15 S IPCT=58,OPCT=66 Q
 I ADL=16 S IPCT=61,OPCT=67 Q
 I ADL=17 S IPCT=64,OPCT=68 Q
 I ADL=18 S IPCT=67,OPCT=70 Q
 I ADL=19 S IPCT=69,OPCT=71 Q
 I ADL=20 S IPCT=72,OPCT=73 Q
 I ADL=21 S IPCT=74,OPCT=76 Q
 I ADL=22 S IPCT=76,OPCT=78 Q
 I ADL=23 S IPCT=78,OPCT=80 Q
 I ADL=24 S IPCT=80,OPCT=83 Q
 I ADL=25 S IPCT=83,OPCT=85 Q
 I ADL=26 S IPCT=85,OPCT=86 Q
 I ADL=27 S IPCT=86,OPCT=88 Q
 I ADL=28 S IPCT=87,OPCT=89 Q
 I ADL=29 S IPCT=88,OPCT=90 Q
 I ADL=30 S IPCT=89,OPCT=91 Q
 I ADL=31 S IPCT=90,OPCT=92 Q
 I ADL=32 S IPCT=92,OPCT=93 Q
 I ADL=33 S IPCT=93,OPCT=94 Q
 I ADL=34 S IPCT=94,OPCT=95 Q
 I ADL=35 S IPCT=95,OPCT=96 Q
 I ADL=36 S IPCT=96,OPCT=96 Q
 I ADL=37 S IPCT=96,OPCT=96 Q
 I ADL=38 S IPCT=97,OPCT=97 Q
 I ADL=39 S IPCT=97,OPCT=97 Q
 I ADL=40 S IPCT=99,OPCT=99 Q
 Q
FEAR  ;
 S (IPCT,OPCT)=0
 I FEAR=0 S IPCT=2,OPCT=2 Q
 I FEAR=1 S IPCT=4,OPCT=3 Q
 I FEAR=2 S IPCT=4,OPCT=4 Q
 I FEAR=3 S IPCT=6,OPCT=6 Q
 I FEAR=4 S IPCT=8,OPCT=7 Q
 I FEAR=5 S IPCT=10,OPCT=10 Q
 I FEAR=6 S IPCT=13,OPCT=14 Q
 I FEAR=7 S IPCT=16,OPCT=16 Q
 I FEAR=8 S IPCT=19,OPCT=19 Q
 I FEAR=9 S IPCT=24,OPCT=22 Q
 I FEAR=10 S IPCT=32,OPCT=28 Q
 I FEAR=11 S IPCT=42,OPCT=35 Q
 I FEAR=12 S IPCT=50,OPCT=41 Q
 I FEAR=13 S IPCT=58,OPCT=48 Q
 I FEAR=14 S IPCT=66,OPCT=54 Q
 I FEAR=15 S IPCT=75,OPCT=61 Q
 I FEAR=16 S IPCT=82,OPCT=69 Q
 I FEAR=17 S IPCT=88,OPCT=75 Q
 I FEAR=18 S IPCT=93,OPCT=83 Q
 I FEAR=19 S IPCT=97,OPCT=90 Q
 I FEAR=20 S IPCT=99,OPCT=96 Q
 Q
 ;
MOBIL  ;
 S (IPCT,OPCT)=0
 I MOBIL=0 S IPCT=1,OPCT=1 Q
 I MOBIL=1 S IPCT=1,OPCT=1 Q
 I MOBIL=2 S IPCT=2,OPCT=1 Q
 I MOBIL=3 S IPCT=2,OPCT=2 Q
 I MOBIL=4 S IPCT=2,OPCT=2 Q
 I MOBIL=5 S IPCT=3,OPCT=2 Q
 I MOBIL=6 S IPCT=3,OPCT=3 Q
 I MOBIL=7 S IPCT=3,OPCT=3 Q
 I MOBIL=8 S IPCT=4,OPCT=4 Q
 I MOBIL=9 S IPCT=5,OPCT=5 Q
 I MOBIL=10 S IPCT=6,OPCT=7 Q
 I MOBIL=11 S IPCT=7,OPCT=9 Q
 I MOBIL=12 S IPCT=9,OPCT=10 Q
 I MOBIL=13 S IPCT=10,OPCT=12 Q
 I MOBIL=14 S IPCT=12,OPCT=14 Q
 I MOBIL=15 S IPCT=14,OPCT=16 Q
 I MOBIL=16 S IPCT=16,OPCT=19 Q
 I MOBIL=17 S IPCT=17,OPCT=21 Q
 I MOBIL=18 S IPCT=20,OPCT=25 Q
 I MOBIL=19 S IPCT=22,OPCT=29 Q
 I MOBIL=20 S IPCT=25,OPCT=32 Q
 I MOBIL=21 S IPCT=28,OPCT=37 Q
 I MOBIL=22 S IPCT=32,OPCT=41 Q
 I MOBIL=23 S IPCT=35,OPCT=43 Q
 I MOBIL=24 S IPCT=38,OPCT=46 Q
 I MOBIL=25 S IPCT=42,OPCT=49 Q
 I MOBIL=26 S IPCT=46,OPCT=52 Q
 I MOBIL=27 S IPCT=50,OPCT=55 Q
 I MOBIL=28 S IPCT=53,OPCT=57 Q
 I MOBIL=29 S IPCT=56,OPCT=59 Q
 I MOBIL=30 S IPCT=60,OPCT=61 Q
 I MOBIL=31 S IPCT=65,OPCT=65 Q
 I MOBIL=32 S IPCT=68,OPCT=68 Q
 I MOBIL=33 S IPCT=72,OPCT=70 Q
 I MOBIL=34 S IPCT=76,OPCT=73 Q
 I MOBIL=35 S IPCT=80,OPCT=77 Q
 I MOBIL=36 S IPCT=83,OPCT=80 Q
 I MOBIL=37 S IPCT=86,OPCT=83 Q
 I MOBIL=38 S IPCT=90,OPCT=87 Q
 I MOBIL=39 S IPCT=93,OPCT=90 Q
 I MOBIL=40 S IPCT=97,OPCT=95 Q
 Q
 ;
NA ;
 S (IPCT,OPCT)=0
 I NA=0 S IPCT=1,OPCT=1 Q
 I NA=1 S IPCT=1,OPCT=3 Q
 I NA=2 S IPCT=1,OPCT=4 Q
 I NA=3 S IPCT=2,OPCT=5 Q
 I NA=4 S IPCT=2,OPCT=6 Q
 I NA=5 S IPCT=2,OPCT=7 Q
 I NA=6 S IPCT=3,OPCT=8 Q
 I NA=7 S IPCT=4,OPCT=9 Q
 I NA=8 S IPCT=5,OPCT=10 Q
 I NA=9 S IPCT=5,OPCT=11 Q
 I NA=10 S IPCT=6,OPCT=14 Q
 I NA=11 S IPCT=7,OPCT=17 Q
 I NA=12 S IPCT=8,OPCT=19 Q
 I NA=13 S IPCT=9,OPCT=21 Q
 I NA=14 S IPCT=9,OPCT=22 Q
 I NA=15 S IPCT=10,OPCT=24 Q
 I NA=16 S IPCT=12,OPCT=27 Q
 I NA=17 S IPCT=15,OPCT=29 Q
 I NA=18 S IPCT=17,OPCT=30 Q
 I NA=19 S IPCT=18,OPCT=32 Q
 I NA=20 S IPCT=20,OPCT=34 Q
 I NA=21 S IPCT=22,OPCT=36 Q
 I NA=22 S IPCT=24,OPCT=39 Q
 I NA=23 S IPCT=27,OPCT=42 Q
 I NA=24 S IPCT=30,OPCT=43 Q
 I NA=25 S IPCT=32,OPCT=45 Q
 I NA=26 S IPCT=36,OPCT=47 Q
 I NA=27 S IPCT=39,OPCT=49 Q
 I NA=28 S IPCT=42,OPCT=52 Q
 I NA=29 S IPCT=45,OPCT=54 Q
 I NA=30 S IPCT=49,OPCT=57 Q
 I NA=31 S IPCT=52,OPCT=60 Q
 I NA=32 S IPCT=56,OPCT=62 Q
 I NA=33 S IPCT=60,OPCT=64 Q
 I NA=34 S IPCT=64,OPCT=68 Q
 I NA=35 S IPCT=68,OPCT=72 Q
 I NA=36 S IPCT=72,OPCT=76 Q
 I NA=37 S IPCT=75,OPCT=80 Q
 I NA=38 S IPCT=79,OPCT=83 Q
 I NA=39 S IPCT=82,OPCT=86 Q
 I NA=40 S IPCT=85,OPCT=87 Q
 I NA=41 S IPCT=88,OPCT=89 Q
 I NA=42 S IPCT=90,OPCT=91 Q
 I NA=43 S IPCT=92,OPCT=92 Q
 I NA=44 S IPCT=94,OPCT=93 Q
 I NA=45 S IPCT=95,OPCT=94 Q
 I NA=46 S IPCT=97,OPCT=95 Q
 I NA=47 S IPCT=98,OPCT=96 Q
 I NA=48 S IPCT=99,OPCT=97 Q
 I NA=49 S IPCT=99,OPCT=97 Q
 I NA=50 S IPCT=99,OPCT=99 Q
 Q
 ;
PAIN ;
 S (IPCT,OPCT)=0
 I PAIN=0 S IPCT=1,OPCT=1
 I PAIN=1 S IPCT=1,OPCT=1
 I PAIN=2 S IPCT=1,OPCT=1
 I PAIN=3 S IPCT=1,OPCT=2
 I PAIN=4 S IPCT=5,OPCT=4
 I PAIN=5 S IPCT=14,OPCT=11
 I PAIN=6 S IPCT=27,OPCT=23
 I PAIN=7 S IPCT=47,OPCT=43
 I PAIN=8 S IPCT=72,OPCT=69
 I PAIN=9 S IPCT=90,OPCT=86
 I PAIN=10 S IPCT=97,OPCT=96
 Q
 ;
VITAL ;
 S (IPCT,OPCT)=0
 I VITAL=0 S IPCT=1,OPCT=1 Q
 I VITAL=1 S IPCT=1,OPCT=1 Q
 I VITAL=2 S IPCT=1,OPCT=1 Q
 I VITAL=3 S IPCT=1,OPCT=1 Q
 I VITAL=4 S IPCT=1,OPCT=1 Q
 I VITAL=5 S IPCT=1,OPCT=1 Q
 I VITAL=6 S IPCT=2,OPCT=2 Q
 I VITAL=7 S IPCT=3,OPCT=2 Q
 I VITAL=8 S IPCT=3,OPCT=3 Q
 I VITAL=9 S IPCT=3,OPCT=3 Q
 I VITAL=10 S IPCT=4,OPCT=5 Q
 I VITAL=11 S IPCT=6,OPCT=7 Q
 I VITAL=12 S IPCT=7,OPCT=9 Q
 I VITAL=13 S IPCT=8,OPCT=9 Q
 I VITAL=14 S IPCT=10,OPCT=11 Q
 I VITAL=15 S IPCT=13,OPCT=15 Q
 I VITAL=16 S IPCT=18,OPCT=19 Q
 I VITAL=17 S IPCT=23,OPCT=24 Q
 I VITAL=18 S IPCT=29,OPCT=30 Q
 I VITAL=19 S IPCT=35,OPCT=35 Q
 I VITAL=20 S IPCT=41,OPCT=41 Q
 I VITAL=21 S IPCT=50,OPCT=49 Q
 I VITAL=22 S IPCT=60,OPCT=57 Q
 I VITAL=23 S IPCT=68,OPCT=65 Q
 I VITAL=24 S IPCT=76,OPCT=72 Q
 I VITAL=25 S IPCT=83,OPCT=78 Q
 I VITAL=26 S IPCT=88,OPCT=82 Q
 I VITAL=27 S IPCT=92,OPCT=87 Q
 I VITAL=28 S IPCT=95,OPCT=92 Q
 I VITAL=29 S IPCT=97,OPCT=95 Q
 I VITAL=30 S IPCT=99,OPCT=98 Q
 Q
 ;
 ; Pad results with spaces in order to line up the numbers.
PAD(RAW) ;
 S PADSPACE=0
 I $L(RAW)=1 S PADSPACE=13
 I $L(RAW)=2 S PADSPACE=12
 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,1080_",",3,"I")_"="_PAIN
 S ^TMP($J,"YSCOR",3)=$$GET1^DIQ(601.87,1081_",",3,"I")_"="_ADL
 S ^TMP($J,"YSCOR",4)=$$GET1^DIQ(601.87,1082_",",3,"I")_"="_FEAR
 S ^TMP($J,"YSCOR",5)=$$GET1^DIQ(601.87,1083_",",3,"I")_"="_MOBIL
 S ^TMP($J,"YSCOR",6)=$$GET1^DIQ(601.87,1084_",",3,"I")_"="_NA
 S ^TMP($J,"YSCOR",7)=$$GET1^DIQ(601.87,1085_",",3,"I")_"="_VITAL
 S ^TMP($J,"YSCOR",8)=$$GET1^DIQ(601.87,1086_",",3,"I")_"="_TOTAL
 Q
DLLSTR(YSDATA,YS,YSTRNG) ;
 ;  YSTRNG = 1 Score Instrument
 ;  YSTRNG = 2 get Report Answers and Text
 N DATA,DES,NODE,ANS,YSQN
 N YSINSNAM,STRING
 N ADL,FEAR,PAIN,NA,MOBIL,TOTAL,VITAL
 N IPCT,OPCT
 ;
 S (ADL,FEAR,NA,PAIN,MOBIL,VITAL,TOTAL)=0
 S (IPCT,OPCT)=0
 S STRING=""
 ;
 I YSTRNG=1 D
 .D DATA1
 .D SCORESV
 ;
 I YSTRNG=2 D
 .D LDSCORES^YTSCORE(.YSDATA,.YS)
 .D STRING
 .S YSDATA($O(YSDATA(""),-1)+1)=999999999999_U_U_STRING
 Q