source: FOIAVistA/trunk/r/MENTAL_HEALTH-YS-RUCL-YI-YT/YTQAPI8.m@ 1801

Last change on this file since 1801 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 5.7 KB
Line 
1YTQAPI8 ;ASF/ALB- MHAX SCORING ; 11/15/07 11:14am
2 ;;5.01;MENTAL HEALTH;**85**;Dec 30, 1994;Build 48
3 Q
4OLDSCORE ;score answers fro 601.2
5 D SCOREIT^YTQAPI14(.YSDATA,.YS)
6 I YSDATA(1)="[ERROR]" S ^TMP($J,"YSCOR",1)="[ERROR]",^TMP($J,"YSCOR",2)="bad OLDSCORE" Q ;-->out
7 D MVSCORE
8 Q
9LGSCORE ;score legacy test in 84
10 N YSEE
11 S YSEE=0
12 S X1=^YTT(601.84,YSAD,0)
13 S DFN=$P(X1,U,2),YSDATE=$P(X1,U,4)
14 S YSOLDI=$O(^YTT(601,"B",YSCODE,0))
15 S YSQN=0,N=1,X=""
16 F S YSQN=$O(^YTT(601.85,"AC",YSAD,YSQN)) Q:YSQN'>0 D
17 . S YSANSI=$O(^YTT(601.85,"AC",YSAD,YSQN,0))
18 . S YSCI=$P($G(^YTT(601.85,YSANSI,0)),U,4)
19 . I YSCI'?1N.N S YSEE=1 Q ;-->out ASF 3/7/07
20 . I '$D(^YTT(601.75,YSCI)) S YSEE=1 Q ;-->out ASF 3/7/07
21 . S YSLG=$P(^YTT(601.75,YSCI,0),U,2) S:YSLG="" YSLG=" "
22 . S X=X_YSLG
23 . I $L(X)=200 S ^YTD(601.2,DFN,1,YSOLDI,1,YSDATE,N)=X,X="",N=N+1
24 I YSEE K ^YTD(601.2,DFN,1,YSOLDI,1,YSDATE) S ^TMP($J,"YSCOR",1)="[ERROR]",^TMP($J,"YSCOR",2)="bad LG CHOICE" Q ;-->out
25 S:$L(X) ^YTD(601.2,DFN,1,YSOLDI,1,YSDATE,N)=X
26 S ^YTD(601.2,DFN,1,YSOLDI,1,YSDATE,0)=YSDATE_U_U_$P(X1,U,6)_U_$P(X1,U,7)
27 S YS("DFN")=DFN,YS("CODE")=YSCODE,YS("ADATE")=YSDATE
28 D SCOREIT^YTQAPI14(.YSDATA,.YS) ;ASF 7/12/07
29 K ^YTD(601.2,DFN,1,YSOLDI,1,YSDATE)
30 I YSDATA(1)="[ERROR]" S ^TMP($J,"YSCOR",1)="[ERROR]",^TMP($J,"YSCOR",2)="bad LG SCORE" Q ;-->out
31 D MVSCORE
32 Q
33MVSCORE ;move results
34 K ^TMP($J,"YSCOR")
35 S ^TMP($J,"YSCOR",1)="[DATA]"
36 S N1=1,N2=5
37 F S N2=$O(YSDATA(N2)) Q:N2'>0 S N1=N1+1,^TMP($J,"YSCOR",N1)=$P(YSDATA(N2),U,2)_"="_$P(YSDATA(N2),U,3)_U_$P(YSDATA(N2),U,4)
38 K YSDATA S YSDATA=$NA(^TMP($J,"YSCOR"))
39 Q
40GETSCORE(YSDATA,YS) ;get scales and scale grps for a test
41 ; input: AD as administration ID
42 ; output: Scale name=Raw Score
43 N YSCODE,YSCODEN,N,N2,X,X1,I,YSAD,YSAI,YSTARG,YSAN,YSCALEI,YSKEYI,YSQN,YSRAW,YSVAL,YSDA,YSLG,N1,YSADATE,YSANSI,YSCI,YSDATE,YSDFN,YSOLDI,YSLIMIT,YSXT,DFN
44 K ^TMP($J,"YSCOR") S YSDATA=$NA(^TMP($J,"YSCOR"))
45 S YSAD=$G(YS("AD"))
46 S YSADATE=$G(YS("ADATE")),YSCODE=$G(YS("CODE")),DFN=$G(YS("DFN"))
47 I (YSADATE?7N.E)&(YSAD'?1N.N) D OLDSCORE Q ;-->out Score answers from 601.2
48 I YSAD'?1N.N S ^TMP($J,"YSCOR",1)="[ERROR]",^TMP($J,"YSCOR",2)="bad ad num" Q ;-->out
49 I '$D(^YTT(601.85,"AC",YSAD)) S ^TMP($J,"YSCOR",1)="[ERROR]",^TMP($J,"YSCOR",2)="no such reference" Q ;-->out
50 S YSCODE=$$GET1^DIQ(601.84,YSAD_",",2)
51 S YSCODEN=$$GET1^DIQ(601.84,YSAD_",",2,"I")
52 I '$D(^YTT(601.71,"B",YSCODE)) S ^TMP($J,"YSCOR",1)="[ERROR]",^TMP($J,"YSCOR",2)="no ins" Q ;-->out
53 S YSDA=$O(^YTT(601.71,"B",YSCODE,0))
54 S YSLG=$$GET1^DIQ(601.71,YSDA_",",23)
55 I YSLG="Yes" D LGSCORE Q ;-->out Score legacy answers in 601.85
56 I '$D(^YTT(601.86,"AC",YSCODEN)) S ^TMP($J,"YSCOR",1)="[ERROR]",^TMP($J,"YSCOR",2)="no scale grps found" Q ;-->out
57 S YS("CODE")=YSCODE
58 D SCALEG^YTQAPI3(.YSDATA,.YS)
59 S YSDATA=$NA(^TMP($J,"YSCOR"))
60 S ^TMP($J,"YSCOR",1)="[DATA]",N=1
61 F I=2:1 Q:'$D(^TMP($J,"YSG",I)) I ^TMP($J,"YSG",I)?1"Scale".E S YSRAW="0",N=N+1,^TMP($J,"YSCOR",N)=$P(^TMP($J,"YSG",I),U,4)_"=" D S ^TMP($J,"YSCOR",N)=^TMP($J,"YSCOR",N)_YSRAW
62 . S YSCALEI=$P(^TMP($J,"YSG",I),U),YSCALEI=$P(YSCALEI,"=",2)
63 . S YSKEYI=0 F S YSKEYI=$O(^YTT(601.91,"AC",YSCALEI,YSKEYI)) Q:YSKEYI'>0 D
64 .. S G=^YTT(601.91,YSKEYI,0)
65 .. S YSQN=$P(G,U,3),YSTARG=$P(G,U,4),YSVAL=$P(G,U,5)
66 .. S YSAI=$O(^YTT(601.85,"AC",YSAD,YSQN,0))
67 .. Q:YSAI'>0
68 .. Q:'$D(^YTT(601.85,YSAI,0)) ;ASF 11/15/07
69 .. S YSAN=""
70 .. I $D(^YTT(601.85,YSAI,1,1,0)) S YSAN=^YTT(601.85,YSAI,1,1,0)
71 .. I $P(^YTT(601.85,YSAI,0),U,4)?1N.N S YSAN=$P(^YTT(601.85,YSAI,0),U,4),YSAN=$G(^YTT(601.75,YSAN,1))
72 .. I YSAN=YSTARG S YSRAW=YSRAW+YSVAL
73 Q
74DELSG(YSDATA,YS) ; DELETE SCALES AND SCALEGROUP-careful!!!
75 ;input: ID as ien of 601.86 scalegroup
76 ;output DATAvsERROR
77 N YSIEN,YSID,I,N,DA,DIK
78 S YSID=$G(YS("ID"),-1)
79 I '$D(^YTT(601.86,YSID,0)) S YSDATA(1)="[ERROR]",YSDATA(2)="bad id" Q ;-->out
80 S N=0,YSDATA(1)="[DATA]"
81 S YSEQ=0 F S YSEQ=$O(^YTT(601.87,"AC",YSID,YSEQ)) Q:YSEQ'>0 D
82 . S DA=$O(^YTT(601.87,"AC",YSID,YSEQ,0))
83 . S DIK="^YTT(601.87,"
84 . S N=N+1
85 . D ^DIK
86 S DA=YSID,DIK="^YTT(601.86," D ^DIK
87 S YSDATA(2)=N_" scales deleted"
88 Q
89SCALEGRP(YSDATA,YS) ;return scalegroup info
90 ; input: CODE as instrument name
91 ; output: SCALEGROUP ID^INSTRUMENT ID^SCALEGROUP NAME^GROUP SEQUENCE^ORDINATE TITLE^ORDINATEMIN^ORDINATEINCREMENT^ORDINATEMAX^GRID1^GRID2^GRID3
92 N YSCODE,YSCODEN,YSEQ,G,YSIEN,N
93 K ^TMP($J,"YSSG")
94 S YSDATA=$NA(^TMP($J,"YSSG"))
95 S YSCODE=$G(YS("CODE"),0)
96 I '$D(^YTT(601.71,"B",YSCODE)) S ^TMP($J,"YSSG",1)="[ERROR]",^TMP($J,"YSSG",2)="no ins" Q ;-->out
97 S YSCODEN=$O(^YTT(601.71,"B",YSCODE,0))
98 I '$D(^YTT(601.86,"AC",YSCODEN)) S ^TMP($J,"YSSG",1)="[ERROR]",^TMP($J,"YSSG",2)="no scale grps here" Q ;-->out
99 S N=1,^TMP($J,"YSSG",1)="[DATA]"
100 S YSEQ=0 F S YSEQ=$O(^YTT(601.86,"AC",YSCODEN,YSEQ)) Q:YSEQ="" D
101 . S YSIEN=$O(^YTT(601.86,"AC",YSCODEN,YSEQ,0))
102 . S G=^YTT(601.86,YSIEN,0)
103 . S N=N+1,^TMP($J,"YSSG",N)=G
104 Q
105LEGACY(YSDATA,YS) ;
106 K ^TMP("YSDATA",$J) S YSDATA=$NA(^TMP("YSDATA",$J))
107 S YSAD=$G(YS("AD"))
108 I YSAD'?1N.N S YSDATA(1)="[ERROR]",YSDATA(2)="bad ad num" Q ;-->out
109 I '$D(^YTT(601.85,"AC",YSAD)) S YSDATA(1)="[ERROR]",YSDATA(2)="no such reference" Q ;-->out
110 S YSDATA(1)="[DATA]"
111 S X1=^YTT(601.84,YSAD,0)
112 S DFN=$P(X1,U,2),YSDATE=$P(X1,U,4)
113 S YSCODE=$$GET1^DIQ(601.84,YSAD_",",2)
114 S YSOLDI=$O(^YTT(601,"B",YSCODE,0))
115 S YSQN=0,N=1,X=""
116 F S YSQN=$O(^YTT(601.85,"AC",YSAD,YSQN)) Q:YSQN'>0 D
117 . S YSANSI=$O(^YTT(601.85,"AC",YSAD,YSQN,0))
118 . S YSCI=$P(^YTT(601.85,YSANSI,0),U,4)
119 . Q:YSCI'?1N.N
120 . S YSLG=$P(^YTT(601.75,YSCI,0),U,2) S:YSLG="" YSLG=" "
121 . S X=X_YSLG
122 . I $L(X)=200 S ^YTD(601.2,DFN,1,YSOLDI,1,YSDATE,N)=X,X="",N=N+1
123 S:$L(X) ^YTD(601.2,DFN,1,YSOLDI,1,YSDATE,N)=X
124 S ^YTD(601.2,DFN,1,YSOLDI,1,YSDATE,0)=YSDATE_U_U_$P(X1,U,6)_U_$P(X1,U,7)
125 S YSDFN=DFN,YSXT=YSDATE_","_YSOLDI D INTRMNT^YTRPWRP(.YSDATA,YSDFN,YSXT)
126 K ^YTD(601.2,DFN,1,YSOLDI,1,YSDATE)
127 Q
Note: See TracBrowser for help on using the repository browser.