source: FOIAVistA/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMMH.m@ 1458

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

initial load of FOIAVistA 6/30/08 version

File size: 7.3 KB
Line 
1PXRMMH ; SLC/PKR - Handle mental health findings. ;11/23/2007
2 ;;2.0;CLINICAL REMINDERS;**4,6**;Feb 04, 2005;Build 123
3 ;
4 ;=======================================================
5EVALFI(DFN,DEFARR,ENODE,FIEVAL) ;Evaluate mental health findings.
6 D EVALFI^PXRMINDX(DFN,.DEFARR,ENODE,.FIEVAL)
7 Q
8 ;
9 ;=======================================================
10EVALPL(FINDPA,ENODE,TERMARR,PLIST) ;Evaluate mental health term findings
11 ;for patient lists.
12 D EVALPL^PXRMINDL(.FINDPA,ENODE,.TERMARR,PLIST)
13 Q
14 ;
15 ;=======================================================
16EVALTERM(DFN,FINDPA,ENODE,TERMARR,TFIEVAL) ;Evaluate mental
17 ;health instrument terms.
18 D EVALTERM^PXRMINDX(DFN,.FINDPA,ENODE,.TERMARR,.TFIEVAL)
19 Q
20 ;
21 ;=======================================================
22GETDATA(DASP,FIEVT) ;Return the data for a MH Administrations entry.
23 ;Some tests require the YSP key in order to get a score.
24 N DAS,DATA,IND,SCALE
25 S DAS=$P(DASP,"S",1)
26 S SCALE=+$P(DASP,"S",2)
27 ;DBIA #5043
28 D ENDAS71^YTQPXRM6(.DATA,DAS)
29 I $G(DATA(1))="[ERROR]" Q
30 I SCALE=0 S SCALE=+$O(DATA("SI",""))
31 S FIEVT("MH TEST")=$P(DATA(2),U,3)
32 S IND=0
33 F S IND=$O(DATA("SI",IND)) Q:IND="" S FIEVT("S",IND)=$P(DATA("SI",IND),U,3,4)
34 S IND=0
35 F S IND=$O(DATA("R",IND)) Q:IND="" S FIEVT("R",IND)=$P(DATA("R",IND),U,6)
36 I $D(DATA("SI",SCALE)) S FIEVT("VALUE")=FIEVT("S",SCALE),FIEVT("SCALE NAME")=$P(DATA("SI",SCALE),U,2)
37 Q
38 ;
39 ;=======================================================
40MHVOUT(INDENT,IFIEVAL,NLINES,TEXT) ;Produce the MHV output.
41 N DATE,IND,JND,MHTEST,NOUT,SCALE,SNAME,SCORE,TEXTOUT
42 S MHTEST="Mental Health Test: "_IFIEVAL("MH TEST")_" = "
43 S IND=0
44 F S IND=+$O(IFIEVAL(IND)) Q:IND=0 D
45 . S DATE="("_$$EDATE^PXRMDATE(IFIEVAL(IND,"DATE"))_")"
46 . S TEMP=MHTEST_DATE
47 . S SNAME=$G(IFIEVAL(IND,"SCALE NAME"))
48 . I SNAME'="" S TEMP=TEMP_" scale: "_SNAME_" -"
49 . S SCORE=$G(IFIEVAL(IND,"VALUE"))
50 . I SCORE'="" S TEMP=TEMP_" raw score: "_$P(SCORE,U,1)_", transformed score: "_$P(SCORE,U,2)
51 . D FORMATS^PXRMTEXT(INDENT+2,PXRMRM,TEMP,.NOUT,.TEXTOUT)
52 . F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
53 S NLINES=NLINES+1,TEXT(NLINES)=""
54 Q
55 ;
56 ;=======================================================
57OUTPUT(INDENT,IFIEVAL,NLINES,TEXT) ;Produce the clinical
58 ;maintenance output.
59 N IND,JND,MHTEST,NOUT,SCALE,SNAME,SCORE,TEXTOUT
60 S MHTEST=IFIEVAL("MH TEST")
61 S NLINES=NLINES+1
62 S TEXT(NLINES)=$$INSCHR^PXRMEXLC(INDENT," ")_"Mental Health Test: "_MHTEST
63 S IND=0
64 F S IND=+$O(IFIEVAL(IND)) Q:IND=0 D
65 . S TEMP=$$EDATE^PXRMDATE(IFIEVAL(IND,"DATE"))
66 . S SNAME=$G(IFIEVAL(IND,"SCALE NAME"))
67 . I SNAME'="" S TEMP=TEMP_" scale: "_SNAME_" -"
68 . S SCORE=$G(IFIEVAL(IND,"VALUE"))
69 . I SCORE'="" S TEMP=TEMP_" raw score: "_$P(SCORE,U,1)_", transformed score: "_$P(SCORE,U,2)
70 . D FORMATS^PXRMTEXT(INDENT+2,PXRMRM,TEMP,.NOUT,.TEXTOUT)
71 . F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
72 S NLINES=NLINES+1,TEXT(NLINES)=""
73 Q
74 ;
75 ;=======================================================
76SCHELP(MHIEN) ;Xecutable help for MH SCALE
77 N DATA,IND,JND,NUM,SCALE,SNUM
78 I MHIEN=0 D Q
79 . S SCALE(1)="This is not a valid Mental Health finding, selecting an MH scale does"
80 . S SCALE(2)="not make sense"
81 . D EN^DDIOL(.SCALE)
82 ;DBIA #5053
83 D SCALES^YTQPXRM5(.DATA,MHIEN)
84 I DATA(1)="ERROR" D Q
85 . S SCALE(1)="There are no scales for this test."
86 . D EN^DDIOL(.SCALE)
87 S SCALE(1)="Valid scales are:"
88 S SCALE(2)="SCALE NUMBER SCALE NAME"
89 S SCALE(3)="------------------------"
90 S IND=0,JND=3
91 F S IND=$O(DATA("S",IND)) Q:IND="" D
92 . S JND=JND+1
93 . S NUM=6-$L(IND)
94 . S SCALE(JND)=$$INSCHR^PXRMEXLC(NUM," ")_(IND)_" "_$P(DATA("S",IND),U,1)
95 D EN^DDIOL(.SCALE)
96 Q
97 ;
98 ;=======================================================
99SCHELPD(DA) ;Xecutable help for MH SCALE in Result Group file 801.41
100 N MHIEN
101 S MHIEN=+$P($G(^PXRMD(801.41,DA,50)),U)
102 D SCHELP^PXRMMH(MHIEN)
103 Q
104 ;=======================================================
105SCHELPF ;Xecutable help for MH SCALE in 811.9 findings.
106 N FIND0,MHIEN
107 S FIND0=^PXD(811.9,DA(1),20,DA,0)
108 I FIND0["YTT(601.71" S MHIEN=$P(FIND0,";",1)
109 E S MHIEN=0
110 D SCHELP(MHIEN)
111 Q
112 ;
113 ;=======================================================
114SCHELPT ;Xecutable help for MH SCALE in 811.5 findings.
115 N MHIEN,TFIND0
116 S TFIND0=^PXRMD(811.5,DA(1),20,DA,0)
117 I TFIND0["YTT(601.71" S MHIEN=$P(TFIND0,";",1)
118 E S MHIEN=0
119 D SCHELP(MHIEN)
120 Q
121 ;
122 ;=======================================================
123SCNAME(TEST,SCNUM) ;Given the test ien and scale number return the
124 ;scale name.
125 N DATA,SCNAME
126 D SCALES^YTQPXRM5(.DATA,TEST)
127 Q $G(DATA("S",SCNUM))
128 ;
129 ;=======================================================
130SEVALFI(DFN,ITEM,NGET,SDIR,BDT,EDT,NFOUND,FLIST) ;
131 N FIEV,FINDING,IND,YS,DATA
132 S YS("CODE")=ITEM,YS("DFN")=DFN
133 S YS("BEGIN")=BDT,YS("END")=EDT
134 ;PTTEST^YTQPXRM2 does not understand "*" for a limit so use 99.
135 I NGET="*" S NGET=99
136 S YS("LIMIT")=$S(SDIR=-1:NGET,1:-NGET)
137 ;DBIA #5035
138 D PTTEST^YTQPXRM2(.DATA,.YS)
139 S NFOUND=$P(DATA(1),U,2)
140 I NFOUND=0 Q
141 F IND=1:1:NFOUND S FLIST(IND)=DATA(IND+1)
142 Q
143 ;
144 ;=======================================================
145SEVALPL(ITEM,NOCC,BDT,EDT,PLIST) ;Use MH API to get patient list. Called
146 ;from PXRMINDL.
147 N YS
148 ;YTAPI10A does not understand "*" for a limit so use 99.
149 ;OCCUR^YTQPXRM1 does not understand "*" for a limit so use 99.
150 I NOCC="*" S NOCC=99
151 S YS("CODE")=ITEM,YS("BEGIN")=BDT,YS("END")=EDT,YS("LIMIT")=NOCC
152 ;DBIA #5034
153 D OCCUR^YTQPXRM1(PLIST,.YS)
154 Q
155 ;
156 ;=======================================================
157VSCALE(X,FIND0) ;Make sure that the mental health scale is valid.
158 ;Either the scale number or the scale name can be used.
159 N DATA,IND,MHIEN,MHTEST,SCALE,VALID
160 S MHTEST=$P(FIND0,U,1)
161 S MHIEN=$P(MHTEST,";",1)
162 D SCALES^YTQPXRM5(.DATA,MHIEN)
163 I +X>0 S VALID=$S($D(DATA("S",X)):1,1:0)
164 E D
165 . S IND=1,VALID=0
166 . F S IND=$O(DATA("S",IND)) Q:(VALID)!(IND="") D
167 .. I X=$P(DATA("S",IND),U,1) S VALID=1 Q
168 I 'VALID D EN^DDIOL(X_" is not a valid scale for this test!")
169 I $O(DATA(""),-1)>20 H 1
170 Q VALID
171 ;
172 ;=======================================================
173VSCALED(X,DA) ;Make sure that the mental health scale is valid for a result
174 ;group.
175 I X="" Q 1
176 ;Do not execute as part of a verify fields.
177 I $G(DIUTIL)="VERIFY FIELDS" Q 1
178 ;Do not execute as part of exchange.
179 I $G(PXRMEXCH) Q 1
180 N MHTEST
181 S MHTEST=$P($G(^PXRMD(801.41,DA,50)),U)
182 Q $$VSCALE(X,MHTEST)
183 ;
184 ;=======================================================
185VSCALEF(X) ;Make sure that the mental health scale is valid for a finding.
186 I X="" Q 1
187 ;Do not execute as part of a verify fields.
188 I $G(DIUTIL)="VERIFY FIELDS" Q 1
189 ;Do not execute as part of exchange.
190 I $G(PXRMEXCH) Q 1
191 N FIND0
192 S FIND0=^PXD(811.9,DA(1),20,DA,0)
193 Q $$VSCALE(X,FIND0)
194 ;
195 ;=======================================================
196VSCALET(X) ;Make sure that the mental health scale is valid for a
197 ;term finding.
198 I X="" Q 1
199 ;Do not execute as part of a verify fields.
200 I $G(DIUTIL)="VERIFY FIELDS" Q 1
201 ;Do not execute as part of exchange.
202 I $G(PXRMEXCH) Q 1
203 N TFIND0
204 S TFIND0=^PXRMD(811.5,DA(1),20,DA,0)
205 Q $$VSCALE(X,TFIND0)
206 ;
207 ;=======================================================
208WARN ;Warn the user that they must select a scale if they intend to use
209 ;a condition.
210 W !,"Remember that the score is returned as raw score^transformed score,"
211 W !,"so if your Condition uses the raw score use +V or $P(V,U,1) and if"
212 W !,"it uses the transformed score use $P(V,U,2)."
213 Q
214 ;
Note: See TracBrowser for help on using the repository browser.