source: FOIAVistA/trunk/r/MENTAL_HEALTH-YS-RUCL-YI-YT/YTAPI10A.m@ 1397

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

initial load of FOIAVistA 6/30/08 version

File size: 4.8 KB
Line 
1YTAPI10A ;ALB/ASF- PSYCH TEST API FOR CLINICAL REMINDERS ;09/20/2004
2 ;;5.01;MENTAL HEALTH;**77**;Dec 30, 1994
3 ;Reference to ^PXRMINDX(601.2, supported by DBIA #4114
4SET(X) ;
5 S N=N+1
6 S YSSUB(N)=X
7 Q
8OCCUR(YSSUB,YS) ;occurances OF TESTS,GAF,ASI
9 ;Input:
10 ;YS("CODE"): Test code NUMBER from file 601 including "ASI","GAF"
11 ;YS("BEGIN"): inclusive date in %DT acceptable format (11/11/2011) to begin search [optional]
12 ;YS("END"): inclusive date in %DT acceptable format (11/11/2011) to end search [optional]
13 ;YS("LIMIT"): Last N administrations [optional]
14 ;Output
15 ;^TMP($J,YSSUB,1)=[DATA]^NUMBER FOUND
16 ;^TMP($J,YSSUB,DFN,OCCURANCE)=DAS^DFN^TEST (DAS=entry endas^ytapi10)
17 N G,YSLIMIT,YSJJ,YSSONE,S,R,N,YSN2,N4,I,II,DFN,YSCODE,YSADATE,YSSCALE,YSBED,YSEND,YSAA,DAS,YSOCC,YSZN,YST,YSLM
18 N IFN,R1,R2,R3,SFN1,SFN2,YSBEG,YSCK,YSDFN,YSED,YSIFN,YSINUM,YSITEM,YSN2,YSNODE,YSPRIV,YSQT,YSR,YSSTAFF,YSTYPE,YSCODE,NI,YSID
19 D PARSE^YTAPI(.YS)
20 S YSLM=$G(YS("LIMIT")) S:YSLM'?1N.N YSLM=1
21 S N=0
22 K ^TMP($J,YSSUB)
23 I '$D(^YTT(601,"B",YSCODE)) S ^TMP($J,YSSUB,1)="[ERROR]^BAD TEST CODE #" Q ;-->out
24 S YSCODE=$O(^YTT(601,"B",YSCODE,0))
25 I $P(^YTT(601,YSCODE,0),U)="ASI" D ASIOC Q ;-->out
26 I $P(^YTT(601,YSCODE,0),U)="GAF" D GAFOC Q ;-->out
27P0 S DFN=0,NI=0 F S DFN=$O(^PXRMINDX(601.2,"IP",YSCODE,DFN)) Q:DFN'>0 S YS("DFN")=DFN D P1
28 S ^TMP($J,YSSUB)="[DATA]"_U_NI
29 Q
30P1 I $D(^YTT(601,YSCODE)) S YSN2=YSEND+.1,YSOCC=0 F S YSN2=$O(^YTD(601.2,DFN,1,YSCODE,1,YSN2),-1) Q:YSN2'>0!(YSN2<YSBEG) D
31 . S YSOCC=YSOCC+1
32 . Q:(YSOCC>YSLM)
33 . S NI=NI+1
34 . S ^TMP($J,YSSUB,DFN,YSOCC)=DFN_";1;"_YSCODE_";1;"_YSN2_U_YSN2_U_YSCODE
35 Q
36GAFOC ;all axis5 DXs in time frame
37 S YST=YSEND+.0000001,NI=0
38 F S YST=$O(^YSD(627.8,"B",YST),-1) Q:YST'>0!(YST<YSBEG) S IFN=0 F S IFN=$O(^YSD(627.8,"B",YST,IFN)) Q:IFN'>0 D
39 . S X=$P($G(^YSD(627.8,IFN,60)),U,3)
40 . Q:X=""
41 . S DFN=$P($G(^YSD(627.8,IFN,0)),U,2) Q:DFN'>0 ;bad dfn
42 . S YSOCC=$O(^TMP($J,YSSUB,DFN,999999),-1)+1
43 . Q:(YSOCC>YSLM)
44 . S NI=NI+1
45 . S ^TMP($J,YSSUB,DFN,YSOCC)=DFN_";1;"_YSCODE_";1;"_IFN_U_YST_U_YSCODE
46 S ^TMP($J,YSSUB)="[DATA]"_U_NI
47 Q
48ASIOC ;
49 S NI=0,DFN=0,YSID=YSEND+.01
50 F S YSID=$O(^YSTX(604,"AD",YSID),-1) Q:(YSID'>0)!(YSID<YSBEG) S IFN=0 F S IFN=$O(^YSTX(604,"AD",YSID,IFN)) Q:IFN'>0 D
51 . Q:'$D(^YSTX(604,IFN,.5)) ; no sig
52 . S G=$G(^YSTX(604,IFN,0))
53 . S DFN=$P(G,U,2) Q:DFN'>0 ;bad dfn
54 . S YSOCC=$O(^TMP($J,YSSUB,DFN,999999),-1)+1
55 . Q:(YSOCC>YSLM)
56 . S NI=NI+1
57 . S ^TMP($J,YSSUB,DFN,YSOCC)=DFN_";1;"_YSCODE_";1;"_IFN_U_$P(G,U,5)_U_Y
58 S ^TMP($J,YSSUB)="[DATA]"_U_NI
59 Q
60PTTEST(YSDATA,YS) ;all data scores for a specific patient
61 ;Input:
62 ;YS("DFN"): Patient IFN from file2
63 ;YS("CODE"): Test code NUMBER from file 601 including "ASI","GAF"
64 ;YS("BEGIN"): inclusive date in %DT acceptable format (11/11/2011) to begin search [optional]
65 ;YS("END"): inclusive date in %DT acceptable format (11/11/2011) to end search [optional]
66 ;YS("LIMIT"): Last N administrations [optional]
67 ;Output
68 ;YSDATA(1)=[DATA]^NUMBER FOUND
69 ;YSDATA(OCCURANCE,1:999) most recent to least recent occurance for this test for this patient
70 N YSBEG,YSCODE,R1,R2,R3,YSADATE,YSEND,YSLIMIT,YSLM,YSOCC,YSSCALE,YSSTAFF,YSZ,YSZN,G,YSORT
71 D PARSE^YTAPI(.YS)
72 S YSLM=$G(YS("LIMIT")) S:YSLM="" YSLM=1
73 I YSLM'?1NP.N!(YSLM=0) S YSDATA(1)="[ERROR]",YSDATA(2)="bad limit" Q ;-->out
74 S YSORT=$S(YSLM<0:1,1:-1) ;set sort order
75 I YSLM>0 S YSID=YSEND+.00001
76 E S YSID=YSBEG-.00001,YSLM=YSLM*-1
77 I YSCODE="ASI" D ASIPT Q ;-->out
78 I YSCODE="GAF" D GAFPT Q ;-->out
79 S YSCODE=$O(^YTT(601,"B",YSCODE,0))
80 S NI=0
81 F S YSID=$O(^PXRMINDX(601.2,"PI",DFN,YSCODE,YSID),YSORT) Q:(YSID'>0)!(YSID<YSBEG)!(YSID>YSEND)!(NI=YSLM) D
82 . S DAS=DFN_";;"_YSCODE_";;"_YSID
83 . S DAS=DFN_";1;"_YSCODE_";1;"_YSID
84 . S YSOCC=$O(YSDATA(9999999),-1)+1 S:YSOCC<2 YSOCC=2
85 . S YSDATA(YSOCC)=DAS_U_YSID,NI=NI+1
86 S YSDATA(1)="[DATA]"_U_NI
87 Q
88GAFPT ;gaf for pt IN time
89 S IFN=$S(YSORT=1:0,1:9999999),NI=0
90 K ^TMP($J,"YSGAF")
91 S YSCODE=$O(^YTT(601,"B","GAF",0))
92 F S IFN=$O(^YSD(627.8,"C",DFN,IFN),YSORT) Q:(IFN'>0)!(NI=YSLM) D
93 . S X=$P($G(^YSD(627.8,IFN,60)),U,3)
94 . Q:X=""
95 . S X=$P($G(^YSD(627.8,IFN,0)),U,3)
96 . Q:(X<YSBEG)!(X>YSEND)
97 . S NI=NI+1
98 . S ^TMP($J,"YSGAF",X,IFN)=""
99 S X=$S(YSORT=1:0,1:9999999)
100 F S X=$O(^TMP($J,"YSGAF",X),YSORT) Q:X'>0 S IFN=0 F S IFN=$O(^TMP($J,"YSGAF",X,IFN)) Q:IFN'>0 D
101 . S YSOCC=$O(YSDATA(9999999),-1)+1 S:YSOCC<2 YSOCC=2
102 . S DAS=DFN_";1;"_YSCODE_";1;"_IFN
103 . S YSDATA(YSOCC)=DAS_U_X
104 S YSDATA(1)="[DATA]"_U_NI
105 Q
106ASIPT ;asis for pt IN time
107 S IFN=$S(YSORT=1:0,1:9999999),NI=0
108 S YSCODE=$O(^YTT(601,"B","ASI",0))
109 F S IFN=$O(^YSTX(604,"C",DFN,IFN),YSORT) Q:IFN'>0!(NI=YSLM) D
110 . Q:'$D(^YSTX(604,IFN,.5)) ; no sig
111 . S X=$P($G(^YSTX(604,IFN,0)),U,5)
112 . Q:X=""
113 . Q:(X<YSBEG)!(X>YSEND)
114 . S YSOCC=$O(YSDATA(9999999),-1)+1 S:YSOCC<2 YSOCC=2
115 . S NI=NI+1
116 . S DAS=DFN_";1;"_YSCODE_";1;"_IFN
117 . S YSDATA(YSOCC)=DAS_U_X
118 S YSDATA(1)="[DATA]"_U_NI
119 Q
Note: See TracBrowser for help on using the repository browser.